akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define NL '\n'
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define sz(x) x.size()
#define all(x) (x).begin(), (x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define rep(ii,aa,bb) for(ll (ii)=ll(aa);(ii)<(ll)(bb);++(ii))
#define _fastIO() ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)

//#define LOCAL
vector<string>vec_spltr(string s){s+=',';vector<string>res;while(!s.empty())
res.push_back(s.substr(0, s.find(','))),s=s.substr(s.find(',')+1);return res;}
void dbg_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,
__attribute__((unused))int LINE_NUM){cerr<<endl;}template<typename Head,typename... Tail>
void dbg_out ( vector <string> args, int idx, int LINE_NUM, Head H, Tail... T)
{if(idx>0)cerr<<", ";else cerr << "Line(" << LINE_NUM << ") ";stringstream ss;ss<<H;
cerr<<args[idx]<<" = "<<ss.str();dbg_out(args,idx+1,LINE_NUM, T...);}
#ifdef LOCAL
#define debug(...) dbg_out(vec_spltr(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 6660999
#endif

const int M = 1e5+9; 
int marked[(M>>6)+9];
vector<int>primes;
#define ifc(z, n) (z[n>>6]&(1<<((n>>1)&31))) 
#define isc(z, n) (z[n>>6]|=(1<<((n>>1)&31))) 
void sieve(int n){ 
    memset(marked, 0, sizeof marked);
    for(int i = 3; i*i <= n; i+=2) if(!ifc(marked, i)) 
        for(int j = i * i; j <= n; j += (i + i)) isc(marked, j); 
}


int cnt[M];


void absinthe() {
    sieve(M);
    cnt[3] = 1;
    for(int i = 5; i < M; i+=2) 
        if(!ifc(marked, i) && !ifc(marked, (i+1)/2) && ((i+1)/2)&1) cnt[i] = 1;
    rep(i, 1, M) cnt[i] += cnt[i-1];
    int q, l, r; cin >> q;
    while(q--){
        cin >> l >> r;
        cout << cnt[r] - cnt[l-1] << NL;
    }
}
 
int main(){
  _fastIO();
  int tx = 1; 
  //cin >> tx;
  while(tx--) absinthe();
} 

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

typedef long long ll;

int main() {
    int x1, y1, x2, y2, x3, y3, x4, y4, dx, dy;
    cin >> x1 >> y1 >> x2 >> y2;
    dx = x2 - x1;
    dy = y2 - y1;
    x3 = x2 - dy;
    y3 = y2 + dx;
    x4 = x3 - dx;
    y4 = y3 - dy;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
long conb(int n,int k);

int main(void){
  int N,P;
  int A[50];
  int i,j;
  int even_num=0,odd_num=0;
  long long int ans_a=0,ans_b=0;
  for(i=0;i<50;i++)
    A[i]=0;
  
  scanf("%d %d",&N,&P);

  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    if(A[i]%2==0)
      even_num++;
    else
      odd_num++;
  }
  if(P==0){
    for(i=0;i<=odd_num/2;i++){
      ans_a+=conb(odd_num,2*i);
    }
    for(i=0;i<=even_num;i++){
      ans_b+=conb(even_num,i);
    }
    printf("%lld\n",ans_a*ans_b);
  } else{
    if(odd_num==0) {printf("0\n");return 0;}
    if(odd_num%2==1){
      for(i=0;i<=odd_num/2;i++){
	ans_a+=conb(odd_num,2*i+1);
      }
    }else{
      for(i=0;i<odd_num/2;i++){
	ans_a+=conb(odd_num,2*i+1);
      }
    }
    for(i=0;i<=even_num;i++){
      ans_b+=conb(even_num,i);
    }
    printf("%lld\n",ans_a*ans_b);
  }
  return 0;
}
long conb(int n, int k)
{
    int i;
    long p=1;

    for (i=1;i<=k;i++)
      p=p*(n-i+1)/i; 
    return p;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int r;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> r; 
  cout << 3 * r * r << endl;
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)    for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)
#define FOR(i,b,e)  for (common_type_t <decltype (b), decltype (e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FORR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (e), i ## __begin = (b); i -- > i ## __begin;)
#define ALL(x)      begin (x), end (x)
using namespace std;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t N;
  int64_t X;
  cin >> N >> X;

  array <int64_t, 51> height;
  height [0] = 1;
  FOR (i, 1, height.size ())
  {
    height [i] = height [i - 1] * 2 + 3;
  }

  map <pair <size_t, int64_t>, int64_t> memo;
  auto eat = [&] (auto self, size_t n, int64_t x) -> int64_t
  {
    assert (x > 0);
    x = min (x, height [n]);
    {
      auto ite = memo.find (make_pair (n, x));
      if (ite != memo.end ())
      {
        return ite -> second;
      }
    }
    auto middle = height [n] / 2 + 1;
    if (n == 0)
    {
      return 1;
    }
    if (x == 1)
    {
      return memo [make_pair (n, x)] = 0;
    }
    else if (x < middle)
    {
      return memo [make_pair (n, x)] = self (self, n - 1, x - 1);
    }
    else if (x == middle)
    {
      return memo [make_pair (n, x)] = self (self, n - 1, x - 1) + 1;
    }
    else
    {
      return memo [make_pair (n, x)] = self (self, n - 1, height [n - 1]) + 1 + self (self, n - 1, x - middle);
    }
  };

  cout << eat (eat, N, X) << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;
int main(){
    int n; cin>>n;
    map<int,bool> v;
    int cnt = 1;
    v[n] = true;
    while(1){
        cnt++;
        if(n%2==0) n=n/2;
        else n=3*n+1;
        if(v[n]){
            cout<<cnt;
            return 0;
        }
        v[n] = true;
    }
}

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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

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

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

int ans[50];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout<<setprecision(10)<<fixed;
	ll a, b;
	cin>>a>>b;
	if(a&1){
		if((b-a)%4>=2){
			ans[0]=0;
		}
		else{
			ans[0]=1;
		}
	}
	else{
		if((b-a)%4==0 || (b-a)%4==3){
			ans[0]=0;
		}
		else{
			ans[0]=1;
		}
	}
	ll mask=2;
	FOR(i, 1, 40){
		mask<<=1;
		ll c=a%mask, d=b%mask;
		if(c<mask/2){
			if(d<mask/2 || d&1){
				ans[i]=0;
			}
			else{
				ans[i]=1;
			}
		}
		else{
			if(c&1){
				if(d>=mask/2 && ~d&1){
					ans[i]=0;
				}
				else{
					ans[i]=1;
				}
			}
			else{
				if(d<mask/2 || d&1){
					ans[i]=0;
				}
				else{
					ans[i]=1;
				}
			}
		}
	}
	ll res=0;
	FORR(i, 0, 40){
		res<<=1;
		res+=ans[i];
	}
	cout<<res<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=5e6+5;
int n,ans;
bitset<maxn> s;
int main(){
    cin>>n;
    s[0]=1;
    for(int i=1,x;i<=n;++i)
	{
        cin>>x;
        s|=s<<x;
        ans+=x;
    }
    for(int i=ans+1>>1;i<=ans;++i)
	{
        if(s[i])
		{
			cout<<i<<endl;
			break;
		}
    }
}

Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
string S;
int e, f1, f2, g1, g2;
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int main() {
	cin >> S; string T; bool flag = false;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '.') { e = stoi(T); T = ""; }
		else if (S[i] == '(') { if (T.size() >= 1) { f1 = stoi(T); } f2 = pow(10, T.size()); T = ""; flag = true; }
		else if (S[i] == ')') { g1 = stoi(T); g2 = pow(10, T.size()) - 1; T = ""; }
		else { T += S[i]; }
	}
	if (flag == false) { f1 = stoi(T); f2 = pow(10, T.size()); g1 = 0; g2 = 1; }
	int E1 = e*f2*g2 + f1*g2 + g1, E2 = f2*g2;
	cout << E1 / gcd(E1, E2) << "/" << E2 / gcd(E1, E2) << endl;
	return 0;
}

Measured memory_bytes: 3348
import heapq

n,k=map(int,input().split())
v=list(map(int,input().split()))
s=-10**7-1

if n>k:
    for l in range(k//2+1):
        for i in range(k+1-l):
            d=v[:i]
            d.extend(v[(n-k+l+i):])
            heap=heapq.heapify(d)
            res=sum(d)
            for j in range(l):
                t=heapq.heappop(d)
                if t<0:
                    res-=t
                else:
                    break
            if s<res:
                s=res
else:
    for l in range(n+1):
        for i in range(n-l+1):
            d=v[:i]
            d.extend(v[(l+i):])
            heap=heapq.heapify(d)
            res=sum(d)
            for j in range(k-(n-l)):
                if not d:
                    break
                t=heapq.heappop(d)
                if t<0:
                    res-=t
                else:
                    break
            if s<res:
                s=res

        
if s<0:
    print(0)
else:
    print(s)
        


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

int n[5010];
int dp[5010][5010];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N;
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> n[i];
	};
	sort(n, n + N);

	memset(dp, -1, sizeof dp);
	for(int i = 0; i < N; i++){
		for(int j = 0; j < i; j++){
			dp[i][j] = 2;
		}
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < i; j++){
			if(dp[i][j] == -1) continue;
			int pre = n[j];
			int d = n[i] - pre;
			int idx = lower_bound(n, n + N, n[i] + d) - n;
			if(idx < N && n[i] + d == n[idx]){
				dp[idx][i] = max(dp[idx][i], dp[i][j] + 1);
			}
		}
	}

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



Measured memory_bytes: 101276
N,M=map(int, input().split())
now=[0]*N
pena=0
for i in range(M):
    num,result=input().split()
    num=int(num)-1
    if result=="AC":
        if now[num]>0:
            pena+=now[num]
        now[num]=-1
    else:
        if now[num]>=0:
            now[num]+=1
print(now.count(-1), pena)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> id(n);
  vector<ll> A(n);
  rep(i, n) {
    cin >> A[i];
    id[i] = i;
  }
  sort(all(id), [&](int i, int j) {
    return A[i] < A[j];
  });
  SegmentTree<int> seg(n, [](int a, int b) { return max(a, b); }, 0);
  auto lbsearch = [&](int pos) {
    auto test = [&](int k) {
      return seg.query(k, pos+1) == 0;
    };
    int ok = pos, ng = -1;
    while(ok-ng > 1) {
      int mid = (ok+ng)/2;
      (test(mid) ? ok : ng) = mid;
    }
    return ok;
  };
  auto rbsearch = [&](int pos) {
    auto test = [&](int k) {
      return seg.query(pos, k+1) == 0;
    };
    int ok = pos, ng = n;
    while(ng-ok > 1) {
      int mid = (ok+ng)/2;
      (test(mid) ? ok : ng) = mid;
    }
    return ok;
  };
  ll ans = 0;
  for(int i: id) {
    int l = lbsearch(i);
    int r = rbsearch(i);
    ans += 1LL * (i-l+1) * (r-i+1) * A[i];
    seg.update(i, A[i]);
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 7660
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
using namespace std;

int main() {
int r;
cin >> r;
cout << 6.28*r;

return 0;
}
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

Measured memory_bytes: 3784
#include <bits/stdc++.h> //AtCoder
#include <iostream> //Codeforces
#include <vector> //Codeforces

#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Vc vector<char>
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl

using namespace std;
/****************************** START ******************************/

signed main(){
  int x;
  cin >> x;
  cout << 1-x;
}


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

long int gcd(long int x, long int y){
    if(y == 0) return x;
    else return gcd(y, x%y);
}

int main() {
    long int A, B;
    cin >> A >> B;
    long int c = gcd(A, B);

    long int ans = 1;
    for (long int n = 2; n*n <= c; n++)
    {
        if(c % n == 0) ans++;
        while (c % n == 0)
        {
            c /= n;
        }
    }
    if(c != 1) ans++;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> array(n);
  for(int i=0;i<n;i++)
  cin>>array[i];
  vector<int> dp(n,999999999);
  dp[0]=0;
  for(int i=0;i<n;i++)
  {
      int dist=0;
      for(int j=0;j+i<n && j<=k;j++)
      {
          dp[i+j]=min(abs(array[j+i]-array[i])+dp[i],dp[i+j]);
      }
  }
cout<<dp[n-1];
return 0;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;

public class Main {

	/** 選ぶ人数 */
	private static final int N = 3;
	/** 対象となる頭文字 */
	private static final Set<Character> MARCHS = new HashSet<>(Arrays.asList('M', 'A', 'R', 'C', 'H'));

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			Map<Character, Integer> map = new HashMap<>();
			IntStream.range(0, n).forEach(i -> {
				String s = scanner.next();
				char c = s.charAt(0);
				if (MARCHS.contains(c)) {
					map.put(c, map.getOrDefault(c, 0) + 1);
				}
			});
			int[] count = map.values().stream().mapToInt(Integer::intValue).toArray();
			System.out.println(IntStream.range((1 << N) - 1, (1 << count.length)).filter(i -> N == Integer.bitCount(i))
					.mapToLong(i -> IntStream.range(0, count.length).filter(j -> 0 != (i & (1 << j)))
							.mapToLong(j -> (long) count[j]).reduce(1L, (a, b) -> a * b))
					.sum());
		}
	}
}


Measured memory_bytes: 48640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main() {
  uint32_t N, K = 0;
  std::cin >> N >> K;
  std::vector<uint32_t> A(N);
  for(auto &&a : A) std::cin >> a;

  for(uint32_t i = K; i < N ; i++){
    std::cout << (A[i-K] < A[i] ? "Yes" : "No") << std::endl;
  }

  return 0;
}

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

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);

  int n, q; cin >> n >> q;
  VI c(n); rep(i, n) cin >> c[i];
  vector<pair<int, int>> lr(q); rep(i, q) cin >> lr[i].first >> lr[i].second;
  rep(i, q) lr[i].first--;

  const int sq = 700;
  vector<tuple<int, int, int>> lri(q);
  rep(i, q) lri[i] = make_tuple(lr[i].first / sq, lr[i].second, i);
  sort(lri.begin(), lri.end());

  VI ans(q);

  VI cnt(n+1);
  int prev = -1;
  int lx, rx; lx = rx = get<0>(lri[0]);
  int sum = 0;
  VI changed;
  for (auto [ls, r, i] : lri) {



    // ここのコメントを外すとhandmade03-05, random06がWAになる

    // if (ls != prev) {
    //   for (auto cx : changed) cnt[cx] = 0;
    //   changed.clear();
    //   lx = rx = r;
    //   prev = ls;
    // }



    int l = lr[i].first;
    assert(r == lr[i].second);  // assert(rx <= r);
    int cx;
    while (lx > l) if (cnt[cx=c[--lx]]++ == 0) sum += 1;//changed.push_back(cx);
    while (rx < r) if (cnt[cx=c[rx++]]++ == 0) sum += 1;//changed.push_back(cx);
    while (lx < l) if (--cnt[c[lx++]] == 0) sum -= 1;
    while (rx > r) if (--cnt[c[--rx]] == 0) sum -= 1;
    ans[i] = sum;
  }
  rep(i, q) cout << ans[i] << "\n";
}


Measured memory_bytes: 19316
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
    int n;
    ll k;
    cin>>n>>k;
    ll a[n],m=0;bool flag=false;
    rep(i,n){
        cin>>a[i];
        m=max(m,a[i]);
        if(k==a[i]) flag=true;
    }
    if(flag){cout<<"POSSIBLE"<<endl;return 0;}
    ll g=gcd(a[0],a[1]);
    for(int i=2;i<n;i++){
        g=gcd(g,a[i]);
    }
    if(m<k) cout<<"IMPOSSIBLE"<<endl;
    else if(g==1) cout<<"POSSIBLE"<<endl;
    else if(k%g==0) cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


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

using namespace std;

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

struct UnionFind {
  vector<int> d;

  UnionFind(int n) : d(n, -1) {}
  int root(int x) {
    if(d[x] < 0) return x;
    return d[x] = root(d[x]);
  }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }

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

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

void milkshake() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  int ans = n - 1;
  for(int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    if(!uf.same(a, b)) {
      uf.unite(a, b);
      ans--;
    }
  }
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt=1;
  //cin >> tt;
  while(tt--) milkshake();

  return 0;
}



Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
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;}
 
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}
void pv(vector<int>&v){
	for(int i = 0;i<v.size();i++){
		if(i)cout<<' ';
		cout<<v[i];
	}
	cout<<endl;
}

signed main()
{
	IOS();
	int N;
	cin>>N;
	int sz = 0;
	vector<pair<int,int>>g[20];
	vector<int>cnt(19,0);
	int n = N,tmp = 0,flg=0,ma = -1,now = 0;
	while(n){
		if(n&1){cnt[tmp]++;flg++;ma = tmp;}
		n /= 2;
		tmp++;
		
		if(tmp == 19 && n){
			ma = 19;
			now = (1ll << 19);
			n = 0;
		}
		//cout<<tmp<<" "<<n<<endl;
	}
	/*
	if(flg==tmp){
		rrep(i,0,19){
			if(cnt[i]){
				g[i].push_back({i+1,1ll<<i});
				sz++;
			}
			g[i].push_back({i+1,0});
			sz++;
		}
		cout<<20<<" "<<sz<<endl;
		rep(i,0,20){
			for(auto e:g[i]){
				cout<<i+1<<" "<<e.fi+1<<" "<<e.se<<endl;
			}
		}
		return 0;
	}*/
	int co = flg;
	int t = N - (1ll << (ma));
	rrep(i,0,19){
		//cout<<i<<" "<<cnt[i]<<endl;
		if(ma <= i){
			g[19-(i+1)].push_back({19-i,0});
			sz++;
		}else{
			g[19-(i+1)].push_back({19-i,1ll<<i});
			g[19-(i+1)].push_back({19-i,0});
			sz+=2;
		}
		//cout<<t<<" "<<(1ll << i)<<endl;
		if(t>=(1ll << i)){
			g[0].push_back({19-i,now});
			sz++;
			t -= (1ll << i);
		}
		if(cnt[i])now |= (1ll << i);
		//cout<<sz<<endl;
	}
	cout<<20<<" "<<sz<<endl;
	rep(i,0,20){
		for(auto e:g[i]){
			cout<<i+1<<" "<<e.fi+1<<" "<<e.se<<endl;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;

int main() {
  string a;
  int ans, anss;
  cin >> a;
  for(int i = 0; i < a.length(); i++) {
    if(a[i] == 'A') {
      ans = i;
      break;
    }
  }
  for(int i = a.length() - 1; i >= 0; i--) {
    if(a[i] == 'Z') {
      anss = i;
      break;
    }
  }

  cout << anss - ans + 1 << endl;
}


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

int main () {
  int n;
  cin >> n;
  vector<int>vec(n);
  int ans=1;
  for(int i=0;i<n;i++){
    cin >> vec[i];
  }
  int s=vec[0];
  for(int i=1;i<n;i++){
    s=max(s,vec[i]);
    if(s<=vec[i]){
      ans++;
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>

int main() {
  int x[3], y[3];
  for (int i=0; i<3; ++i)
    scanf("%d %d", &x[i], &y[i]);

  for (int i=1; i<3; ++i) {
    x[i] -= x[0];
    y[i] -= y[0];
  }
  x[0] = y[0] = 0;

  double a[3];
  for (int i=0; i<3; ++i)
    a[i] = std::hypot(x[i]-x[(i+1)%3], y[i]-y[(i+1)%3]);

  std::sort(a, a+3);
  double s=0.5*std::abs(x[1]*y[2]-x[2]*y[1]);
  double r=2*s/(a[0]+a[1]+a[2]);
  printf("%.16f\n", 1.0/(1/r+2/a[2]));
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main() {
	ll N;cin>>N;
	for(ll h=1;h<=5000;h++){
		for(ll n=1;n<=5000;n++){
			ll a=4*h*n-N*n-N*h;
			if(a<=0)continue;
			if((N*h*n)%a)continue;
			ll w=(N*h*n)/a;
			cout<<h<<' '<<n<<' '<<w<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
m,f,r = gets.split.map &:to_i
grade = ""
score = 0

while m!=-1 || f!=-1 || r!= -1 do
    score = m+f
    if(m==-1 || f ==-1)
        grade = "F"
    elsif(score >= 80)
        grade = "A"
    elsif(score < 80 && score >= 65)
        grade = "B"
    elsif(score < 65 && score >= 50)
        grade = "C"
    elsif(score < 50 && score >= 30)
        if(r>=50)
            grade = "C"
        else
            grade = "D"
        end
    else
        grade = "F"
    end
    puts grade
    m,f,r = gets.split.map &:to_i
end

Measured memory_bytes: 8688
def solve():
    K = int(input()) 
    array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

    print(array[K-1])

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
def c(lst,idx):
    for i in range(len(lst)):
        if lst[i] > 0 and i != idx:
            return False
    return True
            
while 1:
    N, P = list(map(int,input().split()))
    if not N:break
    h = [0] * N

    while 1:
        flg = False
        for i in range(N):
            if P > 0:
                h[i] += 1
                P -= 1
                if P == 0 and c(h,i):
                    print(i)
                    flg = True
                    break
            elif h[i] > 0:
                P = h[i]
                h[i] = 0


        if flg:break

Measured memory_bytes: 6720
#include <iostream>
#include<stack>
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N];
int color [N], d[N], f[N], tt;
int nt[N];

int next(int u) {
  for (int v = nt[u]; v < n; v++) {
    nt[u] = v + 1;
    if (M[u][v]) return v;
  }
  return -1;
}

void dfs_visit(int r) {
  for (int i = 0; i < n; i++) nt[i] = 0;

  stack<int> S;
  S.push(r);
  color[r] = GRAY;
  d[r] = ++tt;

  while(!S.empty()) {
    int u = S.top();
    int v = next(u);
    if(v != -1) {
      if (color[v] == WHITE) {
        color[v] = GRAY;
        d[v] = ++tt;
        S.push(v);
      }
    } else {
      S.pop();
      color[u] = BLACK;
      f[u] = ++tt;
    }
  }
}

void dfs() {
  for (int i = 0; i < n; i++) {
    color[i] = WHITE;
    nt[i] = 0;
  }
  tt = 0;

  for (int u = 0; u < n; u++) {
    if ( color[u] == WHITE) dfs_visit(u);
  }
  for (int i = 0; i < n; i++) {
    cout << i+1 << " " << d[i] << " " << f[i] << endl;
  }
}

int main() {
  int u, k, v;

  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) M[i][j] = 0;
  }

  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    u--;
    for (int j = 0; j < k; j++) {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;
struct po{int lx,ly,rx,ry;};
int w,h;
string mp[2][51];
bool ans,memo[51][51][51][51],visited[51][51][51][51];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};

void saiki(int lx,int ly,int rx,int ry){

  if(ans)return;
  if(mp[0][ly][lx]=='%'&&mp[1][ry][rx]=='%')ans=1;
  if(memo[lx][ly][rx][ry]||mp[0][ly][lx]=='%'||mp[1][ry][rx]=='%')return;
  memo[lx][ly][rx][ry]=1;
  for(int i=0;i<4;i++){
    int flg=0;
    int nlx=lx+dx[i],nly=ly+dy[i];
    int nrx=rx-dx[i],nry=ry+dy[i];
    if(nlx<0||nly<0||nlx>=w||nly>=h||mp[0][nly][nlx]=='#')nlx=lx,nly=ly,flg++;
    if(nrx<0||nry<0||nrx>=w||nry>=h||mp[1][nry][nrx]=='#')nrx=rx,nry=ry,flg++;
    if(flg==2)continue;
    saiki(nlx,nly,nrx,nry);
  }
}

bool bfs(int a,int b,int c,int d){
  queue <po> Q;
  Q.push((po){a,b,c,d});
  while(!Q.empty()){
    po t=Q.front();Q.pop();
    //cout << t.lx<<" "<<t.ly<<" "<<t.rx<<" "<<t.ry<<endl;
    if(mp[0][t.ly][t.lx]=='%'&&mp[1][t.ry][t.rx]=='%')return true;
    if(visited[t.lx][t.ly][t.rx][t.ry]||mp[0][t.ly][t.lx]=='%'||mp[1][t.ry][t.rx]=='%')continue;
    visited[t.lx][t.ly][t.rx][t.ry]=1;
    for(int i=0;i<4;i++){
      int flg=0;
      int nlx=t.lx+dx[i],nly=t.ly+dy[i];
      int nrx=t.rx-dx[i],nry=t.ry+dy[i];
      if(nlx<0||nly<0||nlx>=w||nly>=h||mp[0][nly][nlx]=='#')nlx=t.lx,nly=t.ly,flg++;
      if(nrx<0||nry<0||nrx>=w||nry>=h||mp[1][nry][nrx]=='#')nrx=t.rx,nry=t.ry,flg++;
      if(flg==2||visited[nlx][nly][nrx][nry])continue;
      Q.push((po){nlx,nly,nrx,nry});
    }
  }
  return false;
}

int main(){
  while(1){
    cin >>w>>h;
    if(!w&&!h)break;
    for(int i=0;i<h;i++)cin>>mp[0][i]>>mp[1][i];
    int lx,ly,rx,ry;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	if(mp[0][i][j]=='L')lx=j,ly=i;
	if(mp[1][i][j]=='R')rx=j,ry=i;
      }
    memset(memo,0,sizeof(memo));
    memset(visited,0,sizeof(visited));
    ans=0;
    // saiki(lx,ly,rx,ry);
    if(bfs(lx,ly,rx,ry))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 16200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const int INF = 1e9;
double temp_start = 100.0;
double temp_end = 0.001; 
int climb_loop = 10000000;
double temp;

int main(){
  int seed = 12345;
  mt19937 eng(seed);
  uniform_real_distribution<> uniform_01;

  // input
  int D;
  cin >> D;
  int c[26];
  rep(i,26) cin >> c[i];
  int s[D+1][26];
  rep(i,D) rep(j,26) cin >> s[i+1][j];
  
  // define parameter
  int last[D+1][26];
  int t[D+1];
  rep(i,D+1) rep(j,26) last[i][j] = 0;
  
  // calculate initial content climbing
  int content = 0;
  for(int day = 1; day <= D; day++) {
    int content_after = -INF;
    int best_kind = 0;
    rep(kind,26) {
      int res = content + s[day][kind];
      rep(j,26) {
        if(j == kind) last[day][j] = day;
        else last[day][j] = last[day-1][j];
        res -= c[j] * (day - last[day][j]);
      }
      if(res > content_after) {
        best_kind = kind;
        content_after = res;
      }
    }
    t[day] = best_kind;
    content = content_after;
    rep(j,26) {
      if(j == t[day]) last[day][j] = day;
      else last[day][j] = last[day-1][j];
    }
  }
   
  // simulated annealing
  rep(x,climb_loop) {
    int d = (eng() % D) + 1;
    int q = eng() % 26;
    if(q != t[d]) {
      temp = temp_start + (temp_end - temp_start)*x/climb_loop;
      int diff = s[d][q] - s[d][t[d]];
      int cur = d;
      while(cur <= D && last[cur][t[d]] == d) {
        diff -= c[t[d]] * (d - last[cur-1][t[d]]);
        last[cur][t[d]] = last[cur-1][t[d]];
        cur++;
      }
      cur = d;
      while(cur <= D && last[cur][q] < d) {
        diff += c[q] * (d - last[cur][q]);
        last[cur][q] = d;
        cur++;
      }
      if(diff > 0 || uniform_01(eng) < exp((double)diff/temp)) {
        t[d] = q;
        content += diff;
      } else {
        int day = d;
        while(day <= D && last[day][t[d]] < d) {
          last[day][t[d]] = d;
          day++;
        }
        day = d;
        while(day <= D && last[day][q] == d) {
          last[day][q] = last[day-1][q];
          day++;
        }
      }
    }
  }
  // output
  for(int day = 1; day <= D; day++) cout << t[day]+1 << endl;
  return 0;
}


Measured memory_bytes: 4324
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {

	uint N, W;
	cin >> N >> W;

	vector<pair<uint, uint>> wv(N);
	ull vmax = 0;
	ull wmax = 0;
	for(uint i=0; i<N; i++) {
		uint w, v;
		cin >> w >> v;
		wv[i] = make_pair(w, v);
		vmax += v;
		wmax += w;
	}

	//sort(wv.begin(), wv.end());
	vector<vector<ull>> dp(vmax+1, vector<ull>(N+1, wmax));

	for(uint i=0; i<=N; i++) {
		dp[0][i] = 0;
	}

	ull ans = 0;

	for(uint i=1; i<=N; i++) {
		for(uint j=1; j<=vmax; j++) {
			uint wi = wv[i-1].first;
			uint vi = wv[i-1].second;

			if(j >= vi) {
				dp[j][i] = min(dp[j-vi][i-1] + wi, dp[j][i-1]);
			} else {
				dp[j][i] = dp[j][i-1];
			}

			if(dp[j][i] <= W) {
				ans = j;
			}
		}
	}

	cout << ans;

	return 0;
}


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

int main() {
	//string s[100], res = "";
	//int N, M;
	//int a[60], b[60], res[60] = { 0 };
	//string S;
	int X,A,B;
	//int A[110];

	cin >> X >> A >> B;

	//int y = 700;
	int res = X-A*1;
	res -= (res / B)*B;
	/*for (int i = 0; i < M; ++i) {
		cin >> A[i];
	}
	int mae = 0;
	int ushiro = 0;
	for (int i = 0; i < M; ++i) {
		if (A[i] < X) {
			++mae;
		}
		else if (A[i] > X) {
			++ushiro;
		}
		//X -= m[i];
	}
	int res = min(mae, ushiro);
	/*
	sort(m, m + N);
	int res = N;
	res += X / m[0];
	*/

	//string res = "NO";
	/*
	if (A <= X && X <= (A + B)) {
	res = "YES";
	}
	*/
	cout << res << endl;
	return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>
#include <string.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> triple;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll powmod(ll x, ll y) {
  ll r = 1;
  while (y) {
    if (y & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    y >>= 1;
  }
  return r;
}

vector<int> Zalgo(const string &S) {
  int N = (int)S.size();
  vector<int> res(N);
  res[0] = N;
  int i = 1, j = 0;
  while (i < N) {
    while (i+j < N && S[j] == S[i+j]) ++j;
    res[i] = j;
    if (j == 0) {++i; continue;}
    int k = 1;
    while (i+k < N && k+res[k] < j) res[i+k] = res[k], ++k;
    i += k, j -= k;
  }
  return res;
}

int main(int argc, char** argv) {
  int N;
  cin >> N;
  string S;
  cin >> S;

  int ans = 0;
  for (int i = 1; i < N; ++i) {
    string T = S.substr(i) + "$" + S.substr(0, i);
    vector<int> lcp = Zalgo(T);
    for (int j = N - i + 1; j <= N; ++j) {
      ans = max(ans, lcp[j]);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(A+B>=C)  cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
while True :
    try :
        min_y = float(input())
        t = min_y / 9.8
        y = 4.9 * (t ** 2)
        if y % 5 > 0 : N = int(y // 5 + 2)
        else         : N = int(y // 5 + 1)
        print(N)
    except : break

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

typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> ans(N+1, 0);
    for (int i = 1; i < N; i++) {
        int a; cin >> a;
        ans[a]++;
    }
    for (int i = 1; i<= N; i++) {
        cout << ans[i] << endl;
    }
}


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

int main(int argc, char const *argv[])
{
	ll h;
	cin>>h;
	int n;
	cin>>n;
	ll sm=0;
	ll d;
	for (int i = 0; i < n; ++i)
	{
		cin>>d;
		sm+=d;
	}
	cout<<(sm>=h?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b,c,m;
    cin>>a>>b>>c;

    if(a>b){
        m =a;
        a=b;
        b=m;
        if(b>c){
            m=b;
            b=c;
            c=m;
            if(a>b){
                m=a;
                a=b;
                b=m;
            }
        }
    }
    else{
        if(b>c){
            m=b;
            b=c;
            c=m;
            if(a>b){
                m=a;
                a=b;
                b=m;

            }
        }
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0; 

}


Measured memory_bytes: 3016
#include <iostream>
#include <sstream>
#include <fstream>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>

using namespace std;
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){
    os << "{ ";
    for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
        os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", ");
    os << " }";
    return os;
}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define vv(type,w,h,init) vector<vector<type>>(h,vector<type>(w,init))
typedef vector<string> vs;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define loop(i,a,b) for(ull i=(a); i<(ull)(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define mp make_pair

string const resstr[] = {"Impossible","Possible","No","Yes"};

int const rs[]={60,80,100,120,140,160,int(1e8)}; 
int const rw[]={2,5,10,15,20,25,int(1e8)}; 
int const p[]={600,800,1000,1200,1400,1600,int(1e8)};

int solve(int n, int x){
    int ans = 0;
    loop(i,1,n+1)loop(j,i+1,n+1)loop(k,j+1,n+1){
        if(i+j+k==x) ans++;
    }
    return ans;
}

int main(){
    ull n;
    while (cin >> n, n){
        ull div5=0, div2=0;
        loop(i,2,n+1){
            ull t=i;
            while(t%2==0){
                div2++;
                t/=2;
            }
            while(t%5==0){
                div5++;
                t/=5;
            }
        }
        cout << min(div2,div5) << endl;
    }
}

Measured memory_bytes: 1192
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include<numeric>

using namespace std;

int main() {
     int N,K;
    double a,ans=0;
    cin>>N>>K;
    for(int i=1;i<N+1;i++){
        a=1.0/N;
        
        
        for(int k=i;k<K;k=k*2){
                a=a/2;
            }
            ans=ans+a;
    }
    cout<<setprecision(11)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <utility>
#include <iostream>
#include <cmath>

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

void solve() {
  int n, m;
  std::cin >> n >> m;
  std::map<int, int> num;
  rep(i,3) num.insert(std::pair<int, int>((i+1), -1));
  int s[5];
  int c[5];
  rep(i,5) s[i] = c[i] = -1;
  rep(i,m) std::cin >> s[i] >> c[i];
  bool ans = true;
  rep(i,m) {
    if (num[s[i]] == -1) num[s[i]] = c[i];
    else if (num[s[i]] != c[i]) {
      ans = false;
      break;
    }
  }
  if (num[1] == 0 && n > 1) ans = false;
  int real_num = 0;
  if (ans) {
    rep(i,n) {
      if (i == 0 && n > 1 && num[1] == -1) real_num += std::pow(10, n-1);
      else real_num += ((num[i+1] == -1 ? 0 : num[i+1]) * std::pow(10, n-i-1));
    }
    std::cout << real_num << std::endl;
  } else {
    std::cout << -1 << std::endl; 
  }
}

int main() {
  solve();
  return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
	const ll INF = 1e18;
	ll A, B, Q;
	cin >> A >> B >> Q;
	vector<ll> s(A);
	vector<ll> t(B);
	//vector<ll> x(Q);
	for (int i = 0; i < A; ++i) { cin >> s[i]; }
	for (int i = 0; i < B; ++i) { cin >> t[i]; }
    //for (int i = 0; i < Q; ++i) { cin >> x[i]; }
 
    s.insert(s.begin(), -1e18);
    t.insert(t.begin(), -1e18);
    s.push_back(1e18);
    t.push_back(1e18);
    for (int i = 0; i < Q; ++i) {
        ll u;
        cin >> u;
        long long s2[2];
        long long t2[2];
        s2[0] = *lower_bound(s.begin(), s.end(), u);
        //s2[1] = *prev(upper_bound(s.begin(), s.end(), u));
        s2[1] = *(lower_bound(s.begin(), s.end(), u)-1);
        t2[0] = *lower_bound(t.begin(), t.end(), u);
        //t2[1] = *prev(upper_bound(t.begin(), t.end(), u));
        t2[1] = *(lower_bound(t.begin(), t.end(), u)-1);
        long long ans = 8e18;
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                ans = min(ans, abs(u - s2[i]) + abs(s2[i] - t2[j]));
                ans = min(ans, abs(u - t2[j]) + abs(s2[i] - t2[j]));
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 2912
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;

int main() {

    vector<int> num(3);
    int sum = 0;
    for (int i = 0; i < 3; i++) {
        cin >> num[i];
        sum += num[i];
    }

    sort(num.begin(), num.end());
    int max;
    max = num[2];
    int ans;
    if (max % 2 == sum % 2) {
        ans = ((num[2] - num[0]) + (num[2] - num[1])) / 2;
    } else {
        ans = 1 + ((num[2]+1 - num[0]) + (num[2]+1 - num[1])-1) / 2;
    }
    
    cout << ans << endl;
    
/*
    int a, b, c;
    cin >> a >> b >> c;

    int cnt = 0;
    if (a % 2 != 0) cnt ++;
    if (b % 2 != 0) cnt ++;
    if (c % 2 != 0) cnt ++;

    int tmp, ans;

    if (cnt == 0 || cnt  == 3) {
        tmp = max(a, b);
        tmp = max(tmp, c);
        ans = ( (tmp-a) + (tmp-b) + (tmp-c) ) / 2;
    } else if (cnt == 1) {
        if (a % 2 == 0) {a ++;ans ++;}
        if (b % 2 == 0) {b ++;ans ++;}
        if (c % 2 == 0) {c ++;ans ++;}
        tmp = max(a, b);
        tmp = max(tmp, c);
        ans += ( (tmp-a) + (tmp-b) + (tmp-c) ) / 2;
    } else {
        if (a % 2 != 0) {a ++;ans ++;}
        if (b % 2 != 0) {b ++;ans ++;}
        if (c % 2 != 0) {c ++;ans ++;}
        tmp = max(a, b);
        tmp = max(tmp, c);
        ans += ( (tmp-a) + (tmp-b) + (tmp-c) ) / 2;
    }
    
    cout << ans << endl;   
*/
}

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

using namespace std;
char c[100][100];
int main()
{
	int n,i,p,t,l,j,k,q,r;
	string s;
	
	do
	{
		cin >>n;
		l=0;
		if(n!=0)
		{
			for(i=0; i<n; i++)
			{
				cin >> s;
				c[i][0]=s[0];
				p=0;
				for(j=1; j<s.size(); j++)
				{
					if(s[j-1]=='a' || s[j-1]=='i' || s[j-1]=='u' || s[j-1]=='e' || s[j-1]=='o')
					{
						p++;
						c[i][p]=s[j];
					}
				}
				if(p>l) l=p;
			}
			l++;
			p=0;
			t=0;
			while(p!=1)
			{
				t++;
				r=0;
				for(i=0; i<n-1; i++)
				for(j=i+1; j<n; j++)
				{
					q=0;
					for(k=0; k<t; k++)
						if(c[i][k]!=c[j][k])
							q=1;
					if(q==0) r=1; 	
				}
				if(r==0) p=1;
				
				if(t>l) p=1;
				
			}
			if(t>l) cout << "-1" << endl;
			else cout << t << endl;
			for(i=0; i<n; i++)
			for(j=0; j<=l; j++)
				c[i][j]='A';
		}
	}while(n!=0);
	
}



Measured memory_bytes: 3076
#!/usr/bin/env python3
import sys


def solve(S: str):
    print(S.replace("2017","2018"))
    return

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String c1 = sc.next();
    String c2 = sc.next();
    if(c1.charAt(0) == c2.charAt(2)){
      if(c1.charAt(1) == c2.charAt(1)){
        if(c1.charAt(2) == c2.charAt(0)){
          System.out.println("YES");
          return;
        }
      }
    }
    System.out.println("NO");
  }
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<math.h>
int main()
{
    int a,b,c,temp,temp1;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    //swaping
    temp=b;
    temp1=c;
    b=a;
    c=temp;
    a=temp1;
    printf("%d %d %d",a,b,c);



     return 0;

}




Measured memory_bytes: 128
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #a,b,c=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    n=int(readline())
    arr=list(map(int, readline().rstrip().split()))
    x=0
    for a in arr:
        x+=1/a
    print(1/x)
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 5624
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
using namespace std;

//ABC129 B
int main() {
	int N;
	cin >> N;
	vector<int> A;
	for (int i=0; i<N; i++){
		int x;
		cin >> x;
		A.push_back(x);
	}
	int mini = 1e9;
	for (int i=0; i<N; i++) {
		int s1 = accumulate(A.begin(), next(A.begin(), i), 0);
		int s2 = accumulate(next(A.begin(), i), A.end(), 0);
		if (abs(mini) > abs(s1 - s2)) {
			mini = abs(s1 - s2);
		}
	}
	cout << mini << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n, k;
    scanf("%d", &n);
    scanf("%d", &k);
    
    int i, total = 1;

    for (i = 0; i < n; i++) {
        if (total < k) {
            total = total * 2;
        } else {
            total = total + k;
        }
    }
    
    printf("%d\n", total);
    
    return 0;
}

Measured memory_bytes: 1692