akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define LEN 100005
typedef  pair<string,int> P;
typedef long long ll;
//リングバッファの大きさ

P Q[LEN];
int head,tail,n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail+1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head+1) % LEN;
  return x;
}




int main(){
  int q,c,elaps=0;
  cin >> n >> q;
  P u;

  for(int i=1;i<=n;i++){
    cin >> Q[i].first >> Q[i].second;
  }

  head = 1, tail = n+1;

  while(head != tail){
    u = dequeue();
    c = min(q,u.second);
    u.second -= c;
    elaps += c;

    if(u.second > 0){
      enqueue(u);
    }else{
      cout << u.first <<" "<< elaps<< endl;
    }
  }

  return 0;
}



Measured memory_bytes: 6964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) \
  SORT(var);       \
  REVERSE(var)
#define OPTIMIZE_STDIO         \
  ios::sync_with_stdio(false); \
  cin.tie(0);                  \
  cout.precision(10);          \
  cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
  ll x;
  mint() : x(0) {
  }
  mint(ll x) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint& r) {
    if ((x += r.x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint& operator-=(const mint& r) {
    if ((x -= r.x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint& operator*=(const mint& r) {
    if ((x *= r.x) > MOD) {
      x %= MOD;
    }
    return *this;
  }
  mint& operator++() {
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint operator++(int) {
    mint ret = x;
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return ret;
  }
  mint& operator--() {
    if ((--x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint operator--(int) {
    mint ret = x;
    if ((--x) < 0) {
      x += MOD;
    }
    return ret;
  }
  mint operator+(const mint& r) {
    mint ret;
    return ret = x + r.x;
  }
  mint operator-(const mint& r) {
    mint ret;
    return ret = x - r.x;
  }
  mint operator*(const mint& r) {
    mint ret;
    return ret = x * r.x;
  }
  mint operator-() {
    return mint() - *this;
  }
  bool operator<(const mint& a) {
    return x < a.x;
  }
  bool operator>(const mint& a) {
    return x > a.x;
  }
  bool operator<=(const mint& a) {
    return x <= a.x;
  }
  bool operator>=(const mint& a) {
    return x >= a.x;
  }
  bool operator==(const mint& a) {
    return x == a.x;
  }
  bool operator!=(const mint& a) {
    return x != a.x;
  }
};
ostream& operator<<(ostream& os, const mint& r) {
  os << r.x;
  return os;
}
ostream& operator>>(ostream& os, const mint& r) {
  os >> r.x;
  return os;
}

void solve(istream& cin, ostream& cout) {
  ll n;
  cin >> n;
  if (n % 2 != 0) {
    cout << 0 << endl;
    return;
  }
  ll ans = 0;
  ll d = 10;
  while (d <= n) {
    ans += n / d;
    d *= 5;
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    char c;
    cin>>c;
    if(c=='A'){
        c='T';
    }else if(c=='T'){
        c='A';
    }else if(c=='G'){
        c='C';
    }else{
        c='G';
    }
    cout<<c<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono>
#include <climits>
#include <unordered_map>

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;


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

	auto start = high_resolution_clock::now(); 

	int n;
	cin >> n;
	int temp = n;
	int cnt = 0;
	while(temp > 0){
		temp = temp/10;
		cnt++;
	}
	int ans = 0;
	for(int i = 1; i < cnt; i += 2){
		ans += 9*pow(10, i-1);
	}
	if (cnt %2 == 0)
		cout << ans;
	else{
		if (cnt == 5)
			ans += n - 10000 + 1;
		if (cnt == 3)
			ans += n - 100 + 1;
		if (cnt == 1)
			ans += n - 1 + 1;
		cout << ans;
	}

	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << double(duration.count()) / 1000000 << endl; 

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d %d",&a,&b);
	if((1000<=a && a<=50000) || (1000<=b && b<=50000)){
		c=(a+b)/2;
		printf("%d\n",c);
	}
	else{
		printf("error\n");
	}
	return 0;
}


Measured memory_bytes: 2060
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

const int MAX_N=10000;
vector<VI> g1(MAX_N);
vector<VI> g2(MAX_N);
VI flag(MAX_N);
int fcnt = 0;
int gcnt = 0;
vector<bool>vis(MAX_N, false);
VI group(MAX_N);

void dfs(int v) {
	vis[v] = true;
	for (int w : g1[v]) {
		if (!vis[w])dfs(w);
	}
	flag[fcnt] = v;
	//cout << fcnt << " " << v << endl;
	fcnt++;
}

void rdfs(int v) {
	vis[v] = false;
	group[v] = gcnt;
	//cout << v << " " << gcnt << endl;
	for (int w : g2[v]) {
		if (vis[w])rdfs(w);
	}
}


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

	int N, M;
	cin >> N >> M;
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		g1[a].push_back(b);
		g2[b].push_back(a);
	}
	REP(i, N) {
		if (!vis[i])dfs(i);
	}
	//REP(i, N)cout << flag[i] << endl;

	for (int i = N - 1; i >= 0; i--) {
		if (vis[flag[i]]) {
			//cout << i << endl;
			rdfs(flag[i]);
			gcnt++;
		}
	}
	//REP(i, N)cout << group[i] << endl;

	int Q;
	cin >> Q;
	REP(i, Q) {
		int a, b;
		cin >> a >> b;
		cout << (group[a] == group[b]) << endl;
	}
	return 0;
}




Measured memory_bytes: 4660
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool maybe_month(const int num)
{
    if( 1 <= num && num <= 12){
        return true;
    }
    return false;
}

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

    bool high_maybe_month = maybe_month(num / 100);
    bool low_maybe_month = maybe_month(num % 100);
    
    string result;
    if(high_maybe_month && low_maybe_month){
        result = "AMBIGUOUS";
    } else if(high_maybe_month){
        result = "MMYY";
    } else if(low_maybe_month){
        result = "YYMM";
    } else {
        result = "NA";
    }

    cout << result << endl;

    return 0;
}



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

using namespace std;

#define INF 210000000
#define int long long

signed main() {
		int n;
		cin >> n;
		int ans = n + 1;
		for(int i=1;i<=sqrt(n);i++){
				if(n % i == 0 && (n/i)+i < ans) ans = (n/i) + i;
		}
		cout << ans -2 << endl;
}


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

using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds; 

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX

const int MAXN=2e6+1;
const int M=998244353;

char mat[1001][1001];
int n,m;

int x_v[]={0,0,1,-1};
int y_v[]={1,-1,0,0};

int cmp[1001][1001];

int dis[MAXN];

bool is_valid(int i,int j){
	if(i<0 || j<0 || i>=n || j>=m)
		return false;

	return true;
}

vector<int> v[MAXN];

int ct=1;

void dfs(int x,int y){
	cmp[x][y]=ct;

	for(int i=0;i<4;i++){
		int x1=x+x_v[i];
		int y1=y+y_v[i];

		if(is_valid(x1,y1) && mat[x1][y1]=='.' && cmp[x1][y1]==0){
			dfs(x1,y1);
		}
	}

}

int main(){
	
	
	sfi(n) sfi(m)

	int x,y,x1,y1;
	cin>>x>>y;
	--x;
	--y;
	
	cin>>x1>>y1;
	--x1;--y1;
	
	f(i,0,n){
		string s;
		cin>>s;
		for(int j=0;j<m;j++){
			mat[i][j]=s[j];
		}
	}

	

	f(i,0,n){
		f(j,0,m){
			if(mat[i][j]=='.' && cmp[i][j]==0){
				dfs(i,j);
				ct++;
			}
		}
	}



	f(i,0,n){
		f(j,0,m){
			if(mat[i][j]=='#')
				continue;
			for(int x_var=-2;x_var<=2;x_var++){
				for(int y_var=-2;y_var<=2;y_var++){
					if(x_var==0 && y_var==0) continue;

					int i1=x_var+i;
					int j1=y_var+j;

					if(is_valid(i1,j1) && mat[i1][j1]=='.'){
						int ind2=cmp[i][j];
						int ind1=cmp[i1][j1];
						if(ind1!=ind2)
						v[ind1].push_back(ind2);
					}
				}
			}
		}
	}

	f(i,0,n*m){
		dis[i]=INT_MAX;
	}


	if(mat[x][y]=='#' || mat[x1][y1]=='#')
	{
		cout<<"-1";
		return 0;
	}

	int p1=cmp[x][y];
	int p2=cmp[x1][y1];

	dis[p1]=0;


	queue<int> q1;

	q1.push(p1);

	while(!q1.empty()){
		int tp=q1.front();

		q1.pop();

		for(int x:v[tp]){
			if(dis[x]==INT_MAX){
				dis[x]=dis[tp]+1;
				
				q1.push(x);
			}
		}
	}

	if(dis[p2]==INT_MAX)
		dis[p2]=-1;
	
	cout<<dis[p2];


	return 0;
}

Measured memory_bytes: 70760
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int A,B;
  cin >> A >> B;
  char g[100][100];
  fill(g[0],g[50],'#');
  fill(g[50],g[100],'.');

  for(int i=1 ; i<=A-1 ; i++){
    int tmp1 = i/50;
    int tmp2 = i%50;
    int h = 2*tmp1 + 1;
    int w = 2*tmp2 - 1;
    g[h][w] = '.';
  }

  for(int i=1 ; i<=B-1 ; i++){
    int tmp1 = i/50;
    int tmp2 = i%50;
    int h = 2*tmp1 + 51;
    int w = 2*tmp2 -1;
    g[h][w] = '#';
  }

  cout << 100 << " " << 100 << endl;
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      cout << g[i][j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long i64;
const int P=1000000007;
int T;
i64 a,b,f[107],fs[107][107][2];
int main(){
	f[0]=f[1]=1;
	for(int i=2;i<=100;++i)f[i]=f[i-1]+f[i-2];
	fs[0][0][0]=fs[0][0][1]=1;
	for(int i=1;i<=100;++i){
		for(int j=0;j<i;++j){
			fs[i][j][0]=fs[i-1][j][0]+fs[i-1][j][1];
			fs[i][j][1]=fs[i-1][j][0];
		}
		fs[i][i][0]=f[i+2];fs[i][i][1]=f[i];
	}
	for(scanf("%d",&T);T;--T){
		scanf("%lld%lld",&a,&b);
		if(a>b)std::swap(a,b);
		int mv=1;
		for(;f[mv+1]<=a&&f[mv+2]<=b;++mv);
		if(mv==1)printf("1 %lld\n",a*b%P);
		else{
			i64 s=0;
			for(int i=0;i<mv;++i){
				i64 x=fs[mv-1][i][0],y=fs[mv-1][i][1];
				if(b>=x)s+=(a-y)/x;
				if(a>=x)s+=(b-y)/x;
				if(s>6e18||s<-6e18)s%=P;
			}
			printf("%d %lld\n",mv,(s%P+P)%P);
		}
	}
	return 0;
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var k = int.Parse(Console.ReadLine());
        var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var (a, b) = (ab[0], ab[1]);


        Console.WriteLine(b / k * k >= a ? "OK" : "NG");
    }
}


Measured memory_bytes: 28240
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int n,p,c,o;
	string event;
	
	cin>>n;
	while(n>0){
		p=o=c=0;
		while(1){
			cin>>event;
			if(event=="HOMERUN"){
				p+=c+1;
				c=0;
			}
			else if(event=="OUT"){
				o+=1;
			}
			else{
				c+=1;
				if(c==4){
					c--;
					p++;
				}
			}
			if(o==3)break;
		}
		cout<<p<<endl;
		n--;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int count=0;
			int N = cin.nextInt();
			if(N==0){
				break;
			}
			Dice di = new Dice(1, 2);
			count += di.dice[0];
			for(int i = 0; i < N; i++){
				String str = cin.next();
				int dir = 0;
				if(str.equals("North")){
					dir = 3;
				}
				else if(str.equals("East")){
					dir = 2;
				}
				else if(str.equals("West")){
					dir = 4;
				}
				else if(str.equals("South")){
					dir = 1;
				}
				else if(str.equals("Right")){
					dir = 6;
				}
				else if(str.equals("Left")){
					dir =5 ;
				}
				di.dice = di.roll(dir);
				count += di.dice[0];
			}
			System.out.println(count);
		}

	}

}
class Dice {
	static int[] dice;
	static int[][] dice_table=
	{   {  0, 0, 0, 0, 0, 0, 0},
		{  0, 0, 3, 5, 2, 4, 0},
		{  0, 4, 0, 1, 6, 0, 3},
		{  0, 2, 6, 0, 0, 1, 5},
		{  0, 5, 1, 0, 0, 6, 2},
		{  0, 3, 0, 6, 1, 0, 4},
		{  0, 0, 4, 2, 5, 3, 0}
	
	};

	Dice(int x, int y){
		dice = new int[6];
		dice[0] = x;
		dice[1] = y;
		dice[2] = dice_table[x][y];
		dice[3] = 7-y;
		dice[4] = dice_table[y][x];
		dice[5] = 7-x;
	}
	static int[] turn(int dir){
		int[] b = new int[6];
		// Right
		if(dir == 5){
			b[0]=dice[0];
			b[1]=dice[4];
			b[2]=dice[1];
			b[3]=dice[2];
			b[4]=dice[3];
			b[5]=dice[5];
		}
		else{
			b[0]=dice[0];
			b[1]=dice[2];
			b[2]=dice[3];
			b[3]=dice[4];
			b[4]=dice[1];
			b[5]=dice[5];
		}
		return b;
	}
	static int[] roll(int dir){
		int[] b = new int[6];
		if(dir==1){
			b[0]=dice[3];
			b[1]=dice[0];
			b[2]=dice[2];
			b[3]=dice[5];
			b[4]=dice[4];
			b[5]=dice[1];
		}
		else if(dir==2){
			b[0]=dice[4];
			b[1]=dice[1];
			b[2]=dice[0];
			b[3]=dice[3];
			b[4]=dice[5];
			b[5]=dice[2];
		}
		else if(dir==3){
			b[0]=dice[1];
			b[1]=dice[5];
			b[2]=dice[2];
			b[3]=dice[0];
			b[4]=dice[4];
			b[5]=dice[3];
		}
		else if(dir==4){
			b[0]=dice[2];
			b[1]=dice[1];
			b[2]=dice[5];
			b[3]=dice[3];
			b[4]=dice[0];
			b[5]=dice[4];
		}
		else if(dir == 5){
			b[0]=dice[0];
			b[1]=dice[4];
			b[2]=dice[1];
			b[3]=dice[2];
			b[4]=dice[3];
			b[5]=dice[5];
		}
		else{
			b[0]=dice[0];
			b[1]=dice[2];
			b[2]=dice[3];
			b[3]=dice[4];
			b[4]=dice[1];
			b[5]=dice[5];
		}
		return b;
		
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define fastcin {\
    cin.tie(0);\
    ios::sync_with_stdio(false);\
}
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i >= b; i--)
#define fore(i, a) for(auto &i:a)
#define print(x) cout << x << "\n"
#define SORT(a, n) sort(a, a+n);
#define REVERSE(a,n) reverse(a,a+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VREVERSE(v) reverse(v.begin(), v.end());
#define MOD 1000000007
#define yes "YES"
#define no "NO"
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;

int main() {
    fastcin;
    ll n, ans;
    cin >> n;
    if(n%2==0) ans = n;
    else ans = n*2;
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

struct UnionFind{
  vector<int> d, weight;
  UnionFind(int n) : d(n, -1), weight(n, 0){}
  int find(int x){
    if(d.at(x) < 0) return x;
    int ret = find(d.at(x));
    weight.at(x) += weight.at(d.at(x));
    return d.at(x) = ret;
  }
  int get_weight(int x){
    find(x);
    return weight.at(x);
  }
  int diff(int x, int y){
    return weight.at(y) - weight.at(x);
  }
  bool unite(int x, int y, int w){
    w += weight.at(x); w -= weight.at(y);
    x = find(x); y = find(y);
    if(x == y) return false;
    if(d.at(x) > d.at(y)) swap(x, y), w = -w;
    d.at(x) += d.at(y);
    d.at(y)= x;
    weight.at(y) = w;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d.at(find(x)); }
};

int main(){
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i, m){
    int l, r, d;
    cin >> l >> r >> d;
    l--; r--;
    if(uf.same(l, r) == true){
      if(uf.diff(l, r) != d){
        cout << "No" << endl;
        return 0;
      }
    }else{
      uf.unite(l, r, d);
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1024
import re
s = input()

def tasu(x):
  return x+1

wa = 0
for j in range(2**(len(s)-1)):
  bin_str = format(j, "0{}b".format(len(s)-1) ) #二進数の文字列を取得
  l_p = [ x.start() for x in re.finditer("1",bin_str)  ] 
  l_p = list( map(tasu,l_p) )
  l_p = [0]+l_p+[len(s)]

  for i in range(len(l_p)-1):
    wa = wa + int(s[ l_p[i] : (l_p[i+1]) ] )
print(wa) #なんかおかしい

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

const int mod = 1e9+7;
const int INF = 2000000;

int main() {
    int N,K;
    cin >> N >> K;
    vector<bool> ch(N+1,false);
    for (int i = 0; i < K; i++)
    {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            int a;
            cin >> a;
            ch[a] = true;
        }
        
    }
    int ans = 0;
    for (int i = 1; i <=N; i++)
    {
        if(!ch[i]) ans++;
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define mod 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
int n;
void dfs(string s,char mx){
  if(s.size()==n){
    cout <<s<<'\n';
  }else{
    for(char c='a';c<=mx;c++){
      dfs(s+c,((c==mx)?(char)(mx+1):mx));
    }
  }
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n;
  dfs("",'a');
  return (0);
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  LL a,b;
  cin >> n >> a >> b;
  vector<LL> x(n);
  for(int i=0;i<n;i++) cin >> x[i];
  LL ans=0;
  for(int i=1;i<n;i++){
    ans+=min((x[i]-x[i-1])*a,b);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
K = list(map(int, list(input())))
D = int(input())
N = len(K)
dp = [[[0]*D for _ in range(2)] for _ in range(N+1)]
mod = 10**9+7
dp[0][0][0] = 1

for i in range(N):
    for smaller in range(2):
        for j in range(D):
            for x in range(10 if smaller else K[i]+1):
                dp[i+1][smaller or int(x < K[i])][j] = (dp[i+1][smaller or int(x < K[i])][j] + dp[i][smaller][(j-x)%D]) % mod

print((dp[N][0][0]+dp[N][1][0]-1) % mod)

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

int main(void){
    
   int D,N;
   cin >> D >> N;
  
   if(D == 0){
       if(N == 100) cout << 101 << endl;
       else cout << N << endl;
   }
   else if(D == 1){
       if(N == 100)cout << 100 * N + 100<< endl;
       else cout << 100 * N << endl;
   }
   else{
       if(N == 100)cout << 10000 * N  + 10000<< endl;
       else cout << 10000 * N << endl;
   }
}

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

long larger(long x, long y){
	if(x > y){
		return x;
	}
	return y;
}

int main(){
	int N;
	int W;
	cin >> N >> W;
	int weight[N];
	long values[N];
	for(int i = 0; i < N; i++){
		cin >> weight[i] >> values[i];
	}
	long dp[N+1][W+1];
	for(int i = 0; i <= N; i++){
		for(int j = 0; j <= W; j++){
			dp[i][j] = -1;
		}
	}
	dp[0][0] = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < W; j++){
			if(dp[i][j] != -1){
				dp[i+1][j] = larger(dp[i][j], dp[i+1][j]);
				if(j+weight[i] <= W){
					dp[i+1][j+weight[i]] = larger(dp[i][j]+values[i], dp[i][j+weight[i]]);
				}
			}
		}
	}
	long max = 0;
	for(int i = 0; i <= W; i++){
		max = larger(max, dp[N][i]);
	}
	cout << max;
}


Measured memory_bytes: 79104
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

if A<B:
  A = A + V*T
  B = B + W*T
  if A>=B:
    print('YES')
  else:
    print('NO')
    
elif B<A:
  A = A - V*T
  B = B - W*T
  if A<=B:
    print('YES')
  else:
    print('NO')

Measured memory_bytes: 9200
N=int(input())
AB=[]
for _ in range(N):
    A,B=map(int,input().split())
    AB.append([A,B])
AB.sort(key=lambda x: x[1])
t=0
ans=True
for w in AB:
    t+=w[0]
    if t>w[1]:
        ans=False
print('Yes' if ans else 'No')

Measured memory_bytes: 38040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

struct UnionFind {
    vector<int> par, siz;

    UnionFind(int n) : par(n), siz(n, 1) {
        iota(par.begin(), par.end(), 0);
    }

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

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return siz[root(x)];
    }
};

signed main() {
    int n, m;
    cin >> n >> m;
    int a, b;
    UnionFind uf(n);
    rep(i, m) {
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a, b);
    }
    int ans = 0;
    rep(v, n) {
        ans = max(ans, uf.size(v));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    map<string, int> mp;
    int n;
    cin >> n;
    rep(i, n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(void){
    vector<vector<int>> card(3,vector<int>(3));
    for (int i=0;i<3;i++) {
        for(int j=0;j<3;j++) {
            cin >> card[i][j];
        }
    }
    int N;
    cin >> N;
    vector<int> appear(N);
    for (int i=0;i<N;i++) {
        cin >> appear[i];
    }
    vector<vector<bool>> bingo(3,vector<bool>(3,false));
    for (int i=0;i<N;i++) {
        for (int j=0;j<3;j++) {
            for (int k=0;k<3;k++) {
                if (appear[i]==card[j][k]) {
                    bingo[j][k]=true;
                }
            }
        }
    }
    
    string ans="No";
    for(int i=0;i<3;i++) {
            if(bingo[i][0]&&bingo[i][1]&&bingo[i][2]) {
                ans="Yes";
            }
            if(bingo[0][i]&&bingo[1][i]&&bingo[2][i]) {
                ans="Yes";
            }
    }   
            if(bingo[0][0]&&bingo[1][1]&&bingo[2][2]) {
                ans="Yes";
            }
            if(bingo[0][2]&&bingo[1][1]&&bingo[2][0]) {
                ans="Yes";
            }
        
    
    cout << ans << endl;
    
}


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

int __gcd(int a,int b){
  if(a==0) return b;
  return __gcd(b%a,a);
}

int main(){
  int n;
  cin >> n;
  int g=0;
  for(int i=0;i<n;i++){
  	int a;
    cin >> a;
    g = __gcd(g,a);
  }
  int ans=0;
  while(g%2==0) {ans++; g/=2;}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll   long long int   
#define pb push_back
using namespace std;
const int M=1e9 + 7;
int main()
{   
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    string s[n];
    map<string,ll> mp;
    for(int i=0;i<n;i++)
    {
    	cin>>s[i];
    	sort(s[i].begin(),s[i].end());
    	mp[s[i]]++;	
	}
	ll ans=0;
	for(auto it=mp.begin();it!=mp.end();it++)
	{
		ll a=it->second;
		ans+=((a*(a-1))/2);
	}
	cout<<ans<<endl;
	return 0;
}
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 16640
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

const int maxn = 17;

int swap(int v, int p1, int p2) {
	if (((v >> p1)&1) != ((v>>p2)&1)) {
		return v ^ (1<<p1) ^ (1<<p2);
	} else return v;
}

vector<int> build(int n, int A, int B) {
	if (n == 1) {
		vector<int> ret;
		ret.push_back(A); ret.push_back(B);
		return ret;
	} else {
		vector<int> ret;
		int cnt = 0, t = A^B;
		for (int i = 0; i < n; i++) {
			if (t & (1<<i)) {
				++ cnt;
			}
		}
		if (cnt == 1) {
			int p = 0;
			for (int i = 0; i < n; i++) {
				if (t & (1<<i)) {
					p = i;
					break;
				}
			}
			A = swap(A, p, n-1); B = swap(B, p, n-1);
			vector<int> a = build(n-1, 0, 1);
			for (int i = 0; i < a.size(); i++) ret.push_back(a[i]);
			for (int i = int(a.size()-1); i >= 0; i--) ret.push_back((1<<(n-1))|a[i]);
			for (int i = 0; i < ret.size(); i++) ret[i] ^= A;
			for (int i = 0; i < ret.size(); i++) ret[i] = swap(ret[i], p, n-1);
			return ret;
		} else if (cnt < n) {
			int p = 0;
			for (int i = 0; i < n; i++) {
				if (!(t & (1<<i))) {
					p = i;
					break;
				}
			}
			A = swap(A, p, 0); B = swap(B, p, 0);
			int q = 0;
			if (A & 1) {
				q = 1;
				A ^= q;
				B ^= q;
			}
			vector<int> a = build(n-1, A>>1, B>>1);
			vector<int> b = build(n-1, a[0], a[1]);
			vector<int> ret;
			ret.push_back(a[0]<<1);
			for (int i = 0; i < b.size(); i++) ret.push_back(b[i]<<1|1);
			for (int i = 1; i < a.size(); i++) ret.push_back(a[i]<<1);
			for (int i = 0; i < ret.size(); i++) ret[i] ^= q;
			for (int i = 0; i < ret.size(); i++) ret[i] = swap(ret[i], p, 0);
			return ret;
		} else {
			vector<int> ret;
			vector<int> a = build(n-1, 0, 1);
			vector<int> b = build(n-1, 1, (1<<(n-1))-1);
			for (int i = 0; i < a.size(); i++) ret.push_back(a[i]);
			for (int i = 0; i < b.size(); i++) ret.push_back((1<<(n-1)) | b[i]);
			for (int i = 0; i < ret.size(); i++) ret[i] ^= A;
			return ret;
		}
	}
}

int n, A, B;

int main() {
	scanf("%d%d%d", &n, &A, &B);
	int t = A^B, cnt = 0;
	for (int i = 0; i < n; i++) {
		if (t & (1<<i)) {
			++ cnt;
		}
	}
	if (cnt & 1) {
		puts("YES");
		vector<int> ans = build(n, A, B);
		for (int i = 0; i < (1<<n); i++) {
			printf("%d ", ans[i]);
		}
		printf("\n");
	} else puts("NO");
	return 0;
}

Measured memory_bytes: 1640
#include <bits/stdc++.h>
#include <atcoder/segtree>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return 0;
}

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int M = 300005;
    segtree<int, op, e> dp(M);
    for (int i = 0; i < N; i++) {
        int tmp = dp.prod(max(a[i]-K, 0), min(a[i]+K+1, M));
        dp.set(a[i], tmp + 1);
    }
    int ans = dp.all_prod();
    printf("%d\n", ans);

}

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

int main() {
   int n;
   cin >> n;
   deque<int> v;//両端キュー
   for (int i = 0; i < n; i++) {
      int a;
      cin >> a;
      if (i % 2 == 0) {
         v.push_back(a);
      } else {
         v.push_front(a);
      }
   }

   if (n&1) reverse(v.begin(), v.end());

   for (int i = 0; i < n-1; i++) {
      cout << v[i] << " ";
   }
   cout << v[n-1] << endl;
   return 0;
}

Measured memory_bytes: 2944
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	int answer = 0;
	for (int C = 1; C <= N; C += 2) {
		int num_of_divisors = 0;
		for (int X = 1; X <= C; ++X) {
			if (C % X == 0) {
				++num_of_divisors;
			}
		}
		if (num_of_divisors == 8) {
			++answer;
		}
	}
	cout << answer << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  sort(a.begin(), a.end(), greater<int>());

  ll e[2], ei=0;
  rep(i, n-1) {
    if(a[i] == a[i+1]) {
      e[ei++] = a[i];
      if(ei == 2) break;
      i += 1;
    }
  }

  if(ei == 2) {
    cout << e[0] * e[1] << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 640
n, k = map(int, input().split())
p = [int(x) for x in input().split()]

M = 0
for i in range(k):
    M += (1 + p[i]) / 2

e = M
for i in range(n-k):
    e -= (1 + p[i]) / 2
    e += (1 + p[i+k]) / 2
    if e > M:
        M = e
print('{:.12f}'.format(M))

Measured memory_bytes: 71792
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;


int main(){

    int N,count=0;

    cin>>N;
    int arr1[N],arr2[N];

    for(int i=0; i<N; i++){
        cin>>arr1[i];
        arr2[i] = arr1[i];

    }

    sort(arr2,arr2+N);

    for(int i=0; i<N; i++){
        if(arr1[i] != arr2[i]){
            count++;
        }

    }

    if(count <= 2 ){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }


}

Measured memory_bytes: 888
a = input()
b = input()
c = input()

ai = -1
bi = -1
ci = -1


def game(i):
    global ai,bi,ci
    if i == "a":
        ai += 1
        if (ai == len(a)):
            print("A")
            exit(0)
        game(a[ai])
    elif i == "b":
        bi +=1
        if (bi == len(b)):
            print("B")
            exit(0)
        game(b[bi])
    else:
        ci +=1
        if (ci == len(c)):
            print("C")
            exit(0)
        game(c[ci])


game("a")

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

int main()
{
    int n, k; cin>>n>>k;
    vector<pair<int, int>> a;
    for(int i=0; i<n; ++i) {
        int t, d; cin>>t>>d;
        a.emplace_back(d, t);
    }
    sort(rbegin(a), rend(a));

    unordered_map<int, int> m;
    stack<pair<int, int>> b;
    long delicious=0;
    for(int i=0; i<k; ++i) {
        int t, d;
        tie(d, t)=a[i];
        delicious+=d;
        if (++m[t]>1) b.emplace(d, t);
    }
    long variety=m.size();
    long res=delicious+variety*variety;

    for(int i=k; i<n; ++i) {
        int t, d;
        tie(d, t)=a[i];
        if (!m.count(t)) {
            m[t]++;
            while (b.size()) {
                int tt, dd;
                tie(dd, tt)=b.top();
                b.pop();
                if (m[tt]>0) {
                    m[tt]--;
                    delicious+=d-dd;
                    variety++;
                    res=max(res, delicious+variety*variety);
                    break;
                }
            }
        }
    }
    cout<<res<<endl;
}


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

int main()
{
    int N,M;
    cin >> N >> M;
    vector<int>height(N+1);
    map<int,queue<int>>conect;//行き先
    for(int i = 1 ; i <= N ; i++)
    {
        cin >> height.at(i);
    }
    
    for(int i = 0 ; i < M ; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        conect[a].push(b);
        conect[b].push(a);
    }

    // 良い展望台数　s
    int sum = 0;

    for(int i = 1 ; i <= N ; i++ )
    {
        bool good = true;
        while(!conect[i].empty())
        {

            if( height.at(conect[i].front()) >= height.at(i) )
            {
                good = false;
                break;
            }
            conect[i].pop();
        }
        if(good)
        {
            sum++;
        }
    }
    cout<<sum<<endl;

}

Measured memory_bytes: 75904
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include <climits>

using namespace std;

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

typedef long long ll;

void solve(){
}

int main(){
  int n;

  while(cin>>n,n){
    int sum = 0;
    int max = INT_MIN;
    int min = INT_MAX;

    rep(i,n){
      int s;
      cin>>s;
      sum += s;

      if(max < s) max = s;
      if(min > s) min = s;
    }

    cout<<(sum - max - min) / (n-2)<<endl;
  }
}

Measured memory_bytes: 0
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=2e5+5;
const int mod=1e9+7;
using namespace std;
int n,x,p[nmax],i;
ll ans,l,r;
set<ll>s;
set<ll>::iterator it;
int main()
{
	//freopen("sol.in","r",stdin);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	s.in(0),s.in(n+1);
	for(i=1;i<=n;i++)cin>>x,p[x]=i;
	for(i=1;i<=n;i++)
	{
		s.in(p[i]);
		it=s.find(p[i]);
		it--,l=*it,it++,it++,r=*it;
		ans+=(p[i]-l)*(r-p[i])*i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10368
s=require('fs').readFileSync('/dev/stdin','utf8').split('\n').map(n=>n|0);
c=0
Array(s[0]+1).fill().map((_,i)=>
Array(s[1]+1).fill().map((_,j)=>
Array(s[2]+1).fill().map((_,k)=>
i*500+j*100+k*50==s[3]&&c++)))
console.log(c)

Measured memory_bytes: 10224
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long answer = 0;
    int n = sc.nextInt();
    HashMap<Integer, Integer> mapL = new HashMap<>();
    HashMap<Integer, Integer> mapR = new HashMap<>();
    for(int i = 1; i <= n; i++){
      int height = sc.nextInt();
      int l = height + i;
      int r = i - height;
      if(mapL.containsKey(l)){
        mapL.put(l, mapL.get(l) + 1);
      } else {
        mapL.put(l, 1);
      }

      if(mapR.containsKey(r)){
        mapR.put(r, mapR.get(r) + 1);
      } else {
        mapR.put(r, 1);
      }
    }
    for(Entry<Integer, Integer> entry : mapL.entrySet()){
      long cntL = entry.getValue();
      long cntR = (mapR.containsKey(entry.getKey())) ? mapR.get(entry.getKey()) : 0 ;
      long temp = cntL * cntR;
      answer += temp;
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 78592
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
  	cin >> s;
  	if(s == "Sunny")
      cout << "Cloudy" << endl;
  	else if(s == "Cloudy")
	  cout << "Rainy" << endl;
  	else if(s == "Rainy")
	  cout << "Sunny" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
 
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
 
using namespace std;
void solve(){
    ll n;
    cin >> n;
    ll tmp = 5;
    ll ans = 0;
    if(n % 2 == 1){
        cout << 0;
        return;
    }
    while(n / tmp >= 1){
        ans += (n / tmp) / 2;
        tmp *= 5;
    }
    cout << ans;
}

 
int main(){
    barsik;
    int q = 1;
//    freopen("file.txt", "w", stdout);
//    cin >> q;
 
    for(ll i = 1; i <= q; i++){
        solve();
        cout << endl;
    }
}


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

int main() {
    int n;
    while(cin >> n, n) {
        vector<int> v(n);
        int sum = 0;
        for(int i=0; i<n; ++i) {
            cin >> v[i];
            sum += v[i];
        }
        sort(begin(v), end(v));
        cout << (sum - v[0] - v[v.size()-1])/(v.size()-2) << endl;
    }
}


Measured memory_bytes: 3124
while True:
    n = int(input())
    if n == 0: break
  
    data = {}
    staff = []
    for i in range(n):
        x, y, z = [int(el) for el in input().split(' ')]
        if x in data:
            data[x] += y * z
        else:
            data[x] = y * z
            staff.append(x)
  
    if max(data.values()) < 1e6:
        print('NA')
    else:
        for k in staff:
            if data[k] >= 1e6:
                print(k)

Measured memory_bytes: 7952
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();

		if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
			System.out.println(0);
			return;
		}

		long min = Long.MAX_VALUE;
		min = Math.min(min, a * b);
		min = Math.min(min, b * c);
		min = Math.min(min, c * a);
		System.out.println(min);
	}

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


Measured memory_bytes: 8916
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

int main() {
    int n; cin >> n;
    set <string> s;
    for (int i = 0; i < n; i++) {
        string t; cin >> t;
        s.insert(t);
    }

    cout << s.size() << endl;
}

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


int main(){
  long long n;
  long long sum =0;
  cin>>n;
  long long A[n] ;
  for(long long i=0;i<n;i++){
    cin>>A[i];
  }
  for(long long i=0;i<n-1;i++){
    if(A[i+1]<A[i]){
      sum+= (A[i]-A[i+1]);
      A[i+1] = A[i];
    }
  }
  cout<<sum;
  return 0;
}


Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N, M;
void func()
{
    string s, t;
    cin >> s;
    int ans(0);
    rep(i, 0, s.size() / 2)
    {
        if (s[i] != s[s.size() - i - 1])
            ++ans;
    }
    cout << ans << endl;
}
int main()
{
    func();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for (int i=0; i < N ; i++){
    cin >> S.at(i);
  }
  sort(S.begin(), S.end());
  for (int i=0; i < N ; i++){
    cout << S.at(i);
  }
  
  cout << endl;
} 


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int r, c, n;
const int N = 210000;
int sta[N], top;
vector <pair <int, int> > V;
int calc(int x, int y)
{
    if (x > 0 && x < r && y > 0 && y < c) return -1;
    if (y == 0) return x;
    if (x == r) return r + y;
    if (y == c) return r + c + r - x;
    return r + c + r + c - y;
}
int main()
{
    scanf("%d%d%d", &r, &c, &n);
    for (int i = 1; i <= n; ++ i)
    {
        int x1, y1, x2, y2;
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
        int d1 = calc(x1, y1), d2 = calc(x2, y2);
        if (d1 == -1 || d2 == -1) continue;
        if (d1 > d2) swap(d1, d2);
        V.push_back(make_pair(d1, i));
        V.push_back(make_pair(d2, i));
    }
    sort(V.begin(), V.end());
    for (int i = 0; i < V.size(); ++ i)
    {
        if (V[i].second == sta[top]) top --;
        else sta[++ top] = V[i].second;
    }
    if (!top) puts("YES"); else puts("NO");
}


Measured memory_bytes: 2420
import sys

S = list(input())

Wid = len(S)

for i in range(0, Wid):
  if i % 2 == 0 and S[i] == "L":
    print("No")
    sys.exit()
  elif i % 2 != 0 and S[i] == "R":
    print("No")
    sys.exit()
print("Yes")

Measured memory_bytes: 3060
pub fn read_parameters<T>() -> Result<Vec<T>, String>
where
    T: std::str::FromStr,
{
    let mut line = String::new();
    std::io::stdin()
        .read_line(&mut line)
        .map_err(|err| format!("{:?}", err))?;

    let xs = line.trim().split_whitespace();
    let mut result = Vec::new();

    for x in xs {
        let ans = x.parse::<T>().map_err(|_| format!("{}", "parse error"))?;
        result.push(ans);
    }
    Ok(result)
}

fn main() {
    let n = read_parameters::<usize>().unwrap();
    let n = n[0];

    let mut cards = Vec::new();
    for _ in 0..n {
        let card = read_parameters::<String>()
            .map(|xs| (xs[0].to_owned(), xs[1].parse::<usize>().unwrap()))
            .unwrap();
        cards.push(card);
    }

    cards.sort();

    let mut suit = &cards[0].0;
    let mut split = Vec::new();
    for i in 1..n {
        if suit != &cards[i].0 {
            split.push(i);
            suit = &cards[i].0;
        }
    }
    let c = &cards[0..split[0]];
    let d = &cards[split[0]..split[1]];
    let h = &cards[split[1]..split[2]];
    let s = &cards[split[2]..n];

    search('S', s);
    search('H', h);
    search('C', c);
    search('D', d);

    fn search(suit: char, cards: &[(String, usize)]) {
        let nums = cards.iter().map(|c| c.1).collect::<Vec<usize>>();
        for i in 1..14 {
            if !nums.contains(&i) {
                println!("{} {}", suit, i);
            }
        }
    }
}



Measured memory_bytes: 5040
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL X,Y;cin >> X >> Y;
    int ans = 0;
    LL tmp = X;
    while(tmp <= Y){
        ans++;
        tmp *= 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int a, b;
    string c;
    while(true){
        cin>>a>>c>>b;
        if(c=="?")break;
        else if(c=="+")cout<<a+b<<endl;
        else if(c=="-")cout<<a-b<<endl;
        else if(c=="*")cout<<a*b<<endl;
        else cout<<a/b<<endl;
    }
}



Measured memory_bytes: 3152
#include<stdio.h>
int result[5][4][11];
int main(){
    int a;
	int b,f,r,p;
	memset(result,0,sizeof(result));
	scanf("%d",&a);
	for(int i=0;i<a;++i){
		scanf("%d%d%d%d",&b,&f,&r,&p);
		result[b][f][r]+=p;}
	for(int i=1;i<5;++i){
		for(int j=1;j<4;++j){
			for(int k=1;k<11;++k)
				printf(" %d",result[i][j][k]);
			printf("\n");}
		if(i!=4)printf("####################\n");}
	return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 4009;
int a[MAXN]; char c[MAXN];
int wpos[MAXN], bpos[MAXN];
int wchoto[MAXN][MAXN], bchoto[MAXN][MAXN];

int dp[MAXN][MAXN];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n+n; i++) {
        cin >> c[i] >> a[i];
        if (c[i]=='W') wpos[a[i]] = i;
        else bpos[a[i]] = i;
    }

    for (int i = n+n; i > 0; i--) {
        for (int j = 1; j <= n; j++) {
            wchoto[i][j] = wchoto[i+1][j];
            wchoto[i][j] += c[i]=='W' && a[i] <= j;

            bchoto[i][j] = bchoto[i+1][j];
            bchoto[i][j] += c[i]=='B' && a[i] <= j;
        }
    }

    for (int w = 1; w <= n; w++) {
        dp[w][0] = dp[w-1][0]+wchoto[wpos[w]][w-1];
    }
    for (int b = 1; b <= n; b++) {
        dp[0][b] = dp[0][b-1]+bchoto[bpos[b]][b-1];
    }
    for (int w = 1; w <= n; w++) {
        for (int b = 1; b <= n; b++) {
            dp[w][b] = min( dp[w-1][b]+wchoto[wpos[w]][w-1]+bchoto[wpos[w]][b],
                            dp[w][b-1]+bchoto[bpos[b]][b-1]+wchoto[bpos[b]][w]);
        }
    }

    cout << dp[n][n] << endl;


    return 0;
}


Measured memory_bytes: 121804
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
#define MAXN 100005
#define MAXH 10005
ll dp[MAXN] = {};
ll h[MAXN] = {};
int n;

void make() {
	dp[1] = abs(h[1]-h[0]);

	for (int i=2; i<n; i++) {
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), 
			dp[i-2] + abs(h[i]-h[i-2]));
	}
}

int main(){
	cin >> n;
	rep(i,n) {
		cin >> h[i];
	}
	make();
	cout << dp[n-1] << endl;
}


Measured memory_bytes: 1792