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

template <typename T>
struct BinaryIndexedTree{
// アーベル群に対応するデータ構造
// 1要素更新:O(logN), 区間演算:O(logN)
  vector<T> m_BIT;
  size_t m_sz_pow2;
 
  BinaryIndexedTree(int N)
  : m_BIT(N+1)
#ifdef __GNUC__
  , m_sz_pow2(1 << (31- __builtin_clz(N)))
#endif
  {
#ifndef __GNUC__
    m_sz_pow2= N;
    m_sz_pow2|= (m_sz_pow2 >>  1);
    m_sz_pow2|= (m_sz_pow2 >>  2);
    m_sz_pow2|= (m_sz_pow2 >>  4);
    m_sz_pow2|= (m_sz_pow2 >>  8);
    m_sz_pow2|= (m_sz_pow2 >> 16);
    m_sz_pow2++;
    m_sz_pow2 >>= 1;
#endif
  }
 
  void add(int idx, T diff){ /* 1-indexed */
    for(size_t i=idx; i< m_BIT.size(); i+= i&-i){
      m_BIT.at(i)+= diff;
    }
  }
 
  T cumulative(int right) const{// [1, right)
    T ans= 0;
    for(int i=right-1; i>0; i-= i&-i){
      ans+= m_BIT.at(i);
    }
    return ans;
  }
 
  T range(int left, int right) const{// [left, right)
    return cumulative(right)- cumulative(left);
  }
 
  void set_val(int idx, T val){
    T a_i= range(idx, idx+ 1);
    add(idx, val- a_i);
  }

  size_t lower_bound(T val) const{// a[i]>= 0 のとき
    size_t offset= 0;
    for(size_t s= m_sz_pow2; s>0; s>>=1){
      if(offset+ s < m_BIT.size() && m_BIT.at(offset+ s) < val){
        offset+= s;
        val-= m_BIT.at(offset);
      }
    }
    return offset+ 1;
  }
};

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

  BinaryIndexedTree<int> data(N+1);

  int ans= 0;
  int buf;
  for(int i=1; i<=N; i++){
    cin >> buf;

    int cnt_larger= data.range(buf, N+1);
    if(cnt_larger==i-1){ ans++; }

    data.set_val(buf, 1); // 1-indexed
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<queue>
#include<cstdio>
#include<vector>

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

using namespace std;

typedef	vector<bool>	vb;
typedef	vector<int>		vi;
typedef	vector<vi>		vvi;

const int INF=1<<29;

int Edmonds_Karp(const vvi &adj,int src,int snk){
	int n=adj.size(),ans=0;
	vector<vi> flow(n,vi(n));

	while(1){
		bool ok=false;
		vi augpath(n);	augpath[src]=-1;
		vi maxflow(n);	maxflow[src]=INF;
		{
			vb visited(n);	visited[src]=true;
			queue<int> qu;	qu.push(src);
			while(!qu.empty()){
				int u=qu.front();	qu.pop();
				if(u==snk){ ok=true; break; }

				rep(v,n){
					int capa=adj[u][v];
					if(!visited[v] && capa-flow[u][v]>0){
						visited[v]=true;
						augpath[v]=u;
						maxflow[v]=min(maxflow[u],capa-flow[u][v]);
						qu.push(v);
					}
				}
			}
		}
		if(!ok)	break;

		for(int u=snk;~augpath[u];u=augpath[u]){
			flow[augpath[u]][u]+=maxflow[snk];
			flow[u][augpath[u]]-=maxflow[snk];
		}
		ans+=maxflow[snk];
	}

	return ans;
}

int main(){
	for(int h,w,c,m,nw,nc,nm;scanf("%d%d%d%d%d%d%d",&h,&w,&c,&m,&nw,&nc,&nm),h>=0;){
		int nn=1+h+2*(w+c+m)+1;
		int n=nn+5;
		int src=0,snk=nn-1;
		vvi adj(n,vi(n));
		for(int v=1;v<1+h;v++)									adj[src][v]=1;
		for(int u=1+h,v=u+w;u<1+h+w;u++,v++)					adj[u][v]=1;
		for(int u=1+h+2*w,v=u+c;u<1+h+2*w+c;u++,v++)			adj[u][v]=1;
		for(int u=1+h+2*w+2*c,v=u+m;u<1+h+2*w+2*c+m;u++,v++)	adj[u][v]=1;
		for(int u=nn-m-1;u<snk;u++)								adj[u][snk]=1;
		adj[nn+0][nn+1]=nw;
		adj[nn+2][nn+3]=nc;
		adj[nn+4][snk]=nm;
		for(int u=1;u<1+h;u++)							adj[u][nn+0]=1;
		for(int v=1+h+2*w;v<1+h+2*w+c;v++)				adj[nn+1][v]=1;
		for(int u=1+h+w;u<1+h+2*w;u++)					adj[u][nn+2]=1;
		for(int v=1+h+2*w+2*c;v<1+h+2*w+2*c+m;v++)		adj[nn+3][v]=1;
		for(int u=1+h+2*w+c;u<1+h+2*w+2*c;u++)			adj[u][nn+4]=1;
		rep(b,w){
			int num;	scanf("%d",&num);
			rep(i,num){
				int a;	scanf("%d",&a);
				int u=1+(a-1),v=1+h+b;
				adj[u][v]=1;
			}
		}
		rep(b,c){
			int num;	scanf("%d",&num);
			rep(i,num){
				int a;	scanf("%d",&a);
				int u=1+h+w+(a-1),v=1+h+2*w+b;
				adj[u][v]=1;
			}
		}
		rep(b,m){
			int num;	scanf("%d",&num);
			rep(i,num){
				int a;	scanf("%d",&a);
				int u=1+h+2*w+c+(a-1),v=1+h+2*w+2*c+b;
				adj[u][v]=1;
			}
		}

		printf("%d\n",Edmonds_Karp(adj,src,snk));
	}

	return 0;
}

Measured memory_bytes: 1828
/* Filename: ABC073C.java
 * Author: Mushiyo
 */

import java.util.Scanner;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		while(input.hasNext()){
			int N = input.nextInt();
			int[] A = new int[N];
			
			for(int i = 0; i < A.length; ++i){
				A[i] = input.nextInt();
			}
			
			Arrays.sort(A);
			
			int oddNum = 0;
			int l = 0;
			int r = l + 1;
			while(r < A.length){
				while(r < A.length && A[l] == A[r]){
					++r;
				}
				
				oddNum += (r - l) % 2;
				l = r;
			}
			
			System.out.println(oddNum);
		}
	}

}


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

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

typedef long long LL;
typedef unsigned long UL;

using namespace std;

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

    int n, i;
    cin >> n >> i;

    cout << n + 1 - i << endl;

    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
x = [int(i) for i in input().split()]
x.sort()
if n >= m:
    ans = 0
else:
    x_sa = [x[i+1]-x[i] for i in range(m-1)]
    x_sa.sort(reverse = True)
    if n >1:
        del x_sa[:(n-1)]
    ans = sum(x_sa)
print(ans)

Measured memory_bytes: 19912
#include <stdio.h>
#define MOD 1000000007
typedef long long ll;
int main() {
	int n, k, a[2000];
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (a[i] > a[j]) {
				if (i < j) {
					ans += (ll)k * (k + 1) / 2;
				} else {
					ans += (ll)k * (k - 1) / 2;
				}
				ans %= MOD;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1740
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const int MX = 200 * 1000 + 7;
const ll INF = 1e18;

ll t[4 * MX];
ll mod[4 * MX];

ll getv(int v) {
    return t[v] + mod[v];
}

void push(int v) {
    mod[v + v] += mod[v];
    mod[v + v + 1] += mod[v];
    mod[v] = 0;
}

void ad(int v, int tl, int tr, int l, int r, ll x) {
    if (r < tl || l > tr) {
        return;
    }
    if (tl >= l && tr <= r) {
        mod[v] += x;
        return;
    }
    push(v);
    int tm = (tl + tr) >> 1;
    ad(v + v, tl, tm, l, r, x);
    ad(v + v + 1, tm + 1, tr, l, r, x);
    t[v] = max(getv(v + v), getv(v + v + 1));
}

ll gt(int v, int tl, int tr, int l, int r) {
    if (r < tl || l > tr) {
        return -INF;
    }
    if (tl >= l && tr <= r) {
        return getv(v);
    }
    push(v);
    int tm = (tl + tr) >> 1;
    ll ans =max(gt(v + v, tl, tm, l, r), gt(v + v + 1, tm + 1, tr, l, r));
    t[v] = max(getv(v + v), getv(v + v + 1));
    return ans;
}
vector<pair<int, int>> add[MX], rm[MX];
ll f[MX];
int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int l, r, x;
        cin >> l >> r >> x;
        add[l].emplace_back(l - 1, x);
        rm[r].emplace_back(l - 1, x);
    }

    for (int i = 1; i <= n; i++) {
        for (const auto& q : add[i]) {
            ad(1, 0, n, 0, q.first, q.second);
        }
        f[i] = gt(1, 0, n, 0, i - 1);
        ad(1, 0, n, i, i, f[i]);
        for (const auto& q : rm[i]) {
            ad(1, 0, n, 0, q.first, -q.second);
        }
    }

    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, f[i]);
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 33280
N, M = map(int, input().split())
a = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(M)]

a.sort()
X.sort(key=lambda x: x[1], reverse=True)

idx = 0
for b, c in X:
  for j in range(idx, min(N, idx + b)):
    if a[j] < c:
      a[j] = c
  idx += b
print(sum(a))


Measured memory_bytes: 32968
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define mz(x,y) x=min(x,y)
typedef long long ll;
int K[2000],S[100000];
ll inf=1e17;
ll dp[2][2001];
ll sum[100001];
vector<ll> ash;
int N,M,L;
ll dis(int a,int b){
	if(a>b) return inf;
	return (sum[ash[b]+1]-sum[ash[a]])/L;
}
int main(){
	cin>>N>>M>>L;
	rep(i,N) cin>>K[i];
	rep(i,N) K[i]--;
	rep(i,N) ash.pb(K[i]);
	sort(all(ash));
	ash.erase(unique(all(ash)),ash.end());
	rep(i,N) K[i]=lower_bound(all(ash),K[i])-ash.begin();
	rep(i,M) cin>>S[i];
	rep(i,M) sum[i+1]=sum[i]+S[i];
	sort(K,K+N);
	M=ash.size();
	rep(j,M+1) dp[0][j]=inf;
	dp[0][0]=0;
	rep(i,N-1){
		rep(j,M+1) dp[1-i%2][j]=inf; 
		rep(j,M){
			mz(dp[1-i%2][j],dp[i%2][j]+dis(K[i],K[i+1]));
			mz(dp[1-i%2][K[i]],dp[i%2][j]+dis(j,K[i+1]));
		}
	}
	ll ans=inf;
	rep(j,M) mz(ans,dp[1-N%2][j]+dis(j,K[N-1]));
	cout<<ans<<endl;
}

Measured memory_bytes: 2456
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N,K;
  int d;
  int e;
  int c;
  cin >> N >> K ;
  vector<int> a(N);
  for(int j=0;j<N;j++)
  {
    a.at(j)=0;
  }
  for(int l=0;l<K; l++)
  {
    cin >> d;
    for(int i=0; i < d; i++)
    {
      cin >> e;
      a.at(e-1) = 1 ;
    }
  }
  for(int m=0;m < N ; m++)
  {
    if(a.at(m) == 0)
      c++;
  }
  cout <<c<< endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll INF = 1LL<<60;
/////////////////////////////////
template<class T> inline bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

ll dp[110][100010] = {0};
int n;
ll W;
ll v[110], w[110];

int main(){
    cin >> n >> W;
    rep(i, n) cin >> w[i] >> v[i];
    for (int i = 0; i < n;i++){
        for (int j=0; j <= W;j++){
            if(j-w[i]>=0)
                chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
            chmax(dp[i + 1][j], dp[i][j]);
        }
        
    }
    cout << dp[n][W] << endl;
}

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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	int n; cin >> n;
	vector<int> v(n), w(n);
	for(int i=0; i<n; i++) cin >> v[i] >> w[i];
	int q; cin >> q;
	vector<int> u(q), l(q);
	for(int i=0; i<q; i++) cin >> u[i] >> l[i];

	vector<vector<pair<int, int>>> xs;

	const int H = 9;
	xs.push_back(vector<pair<int, int>>{{0, 0}, {w[0], v[0]}});
	for(int i=1; i<min(n, 1<<H); i++){
		vector<pair<int, int>> x(xs[(i-1)/2]);
		int m = x.size();
		for(int j=0; j<m; j++){
			x.push_back({x[j].first+w[i], x[j].second+v[i]});
		}
		sort(x.begin(), x.end());
		for(int j=1; j<x.size(); j++){
			x[j].second = max(x[j].second, x[j-1].second);
		}

		xs.push_back(x);
	}

	for(int i=0; i<q; i++){
		u[i]--;
		if(u[i]<(1<<H)){
			int ans = 0;
			int k = lower_bound(xs[u[i]].begin(), xs[u[i]].end(), pair<int, int>{l[i]+1, 0})-xs[u[i]].begin();
			if(k>0) ans = xs[u[i]][k-1].second;
			cout << ans << endl;
			continue;
		}

		vector<pair<int, int>> y(1, {0, 0});
		int t = u[i];
		while(t>=(1<<H)){
			int m = y.size();
			for(int j=0; j<m; j++){
				y.push_back({y[j].first+w[t], y[j].second+v[t]});
			}
			t = (t-1)/2;
		}

		int ans = 0;
		for(auto p: y){
			int k = lower_bound(xs[t].begin(), xs[t].end(), pair<int, int>{l[i]-p.first+1, 0}) - xs[t].begin();
			if(k==0) continue;
			ans = max(ans, p.second+xs[t][k-1].second);
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 7464
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def calc(N):
    return sum(int(x) for x in str(N))


def main():
    # sys.stdin = open("sample.txt")
    N = Scanner.int()
    A = Scanner.map_int()
    B = sorted(A)
    m1 = B[N // 2 - 1]
    m2 = B[N // 2]

    for i in range(N):
        if A[i] < m2:
            print(m2)
        else:
            print(m1)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 86740
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}

bool check(vl& vec, ll n){
    rep(i, n)   {if(vec[i] != n)    return 0;}
    return 1;
}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll n, k;
        cin>>n>>k;
        vl vec(n);
        rep(i, n)   cin>>vec[i];
        vl open(n, 0);
        vl close(n, 0);
        ll cnt = 0;
        rep(i, k){
            if(check(vec, n))   break;
            rep(j, n)   open[j] = close[j] = 0;
            rep(j, n){
                open[max(j - vec[j], 0LL)]++;
                close[min(j + vec[j], n-1)]++;
            }
            ll cur = 0;
            rep(j, n){
                cur += open[j];
                vec[j] = cur;
                cur -= close[j];
            }
            cnt++;
        }
        rep(i, n)   cout<<vec[i]<<" ";
    }
}

Measured memory_bytes: 7952
<?php
$n = int();
$str = str();
$flag = true;
if($n % 2 == 1){
  echo "No";exit;
}
for($i = 0; $i < $n / 2; $i++){
  if($str[$i] != $str[$i+$n/2]){
    $flag = false;
  }
}
echo $flag ? "Yes" : "No";
function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 4728
import sys
def is_pal(s):
    #print(s,'s')
    i,j=0,len(s)-1
    while i<=j:
        if s[i]==s[j]:
            i+=1
            j-=1
        else:
            return False
    return True
s=sys.stdin.readline()[:-1]
n=len(s)
if n%2!=0:
    if is_pal(s[:n//2]) and is_pal(s[n//2+1:]) and is_pal(s):
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
 
  ll l,r,d;
  cin>>l>>r>>d;
  ll c=0;
  for(int i=l;i<=r;i++)
  {
    if(i%d==0)
     c++;
  }
  cout<<c;
}


Measured memory_bytes: 3468
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        int h1,h2,m1,m2,k,total;
        h1=s.nextInt();
        m1=s.nextInt();
        h2=s.nextInt();
        m2=s.nextInt();
        k=s.nextInt();
        if(m2>=m1)
            total=(h2-h1)*60+(m2-m1)-k;
        else
            total=(h2-h1-1)*60+(m2+60-m1)-k;
        System.out.println(total);
    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 25340
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
use std::cmp;
fn main() {
    input! {
        n: usize,
        s: chars, 
    }
    let mut black_cnt = 0;
    let mut white_cnt = 0;
    for c in &s {
        if *c == '#' {
            black_cnt += 1;
        } else {
            white_cnt += 1;
        }
    }
    let mut fwd_b = 0;
    let mut bwd_w = white_cnt;
    let mut ans = cmp::min(black_cnt, white_cnt);

    for c in &s {
        if *c == '#' {
            fwd_b += 1;
        } else {
            bwd_w -= 1;
        }
        ans = cmp::min(ans, fwd_b + bwd_w);
    }
    println!("{}", ans);
 }


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

int main(){
    int n;
    cin>>n;
    int d[n][2];
    

    rep(i,n){
        cin>>d[i][0]>>d[i][1];
    }
    
    string ans="No";

    rep(i,n-2){
        if(d[i][0]==d[i][1]&&d[i+1][0]==d[i+1][1]&&d[i+2][0]==d[i+2][1]){
            ans="Yes";
            break;
        }
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 3624
from collections import defaultdict
r=lambda : list(map(int,input().split()))#anonymous function used to take input
n,k=r()
l=r()
d=defaultdict(int) #taking dictionary of each length
d[1]=0
temp=[1]
t=1
loop=-1  
while True:
    t=l[t-1] #jumping based on the value at tth position in the arr
    if t in d: #if t is already in dictionary then we find the array
        loop=d[t] #just take the length of the array
        break    #now break the loop
    d[t]=len(temp)   #t key and value with the length of temp
    temp.append(t)
head=temp[:loop]
rloop=temp[loop:]
if k<loop:
    print(head[k])
else:
    print(rloop[(k-loop)%len(rloop)])


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

###
# main
if(__name__ == '__main__'):
    # input
    n = int(input())
    a_list = list(map(int, input().split(" ")))
    a_list.sort()

    ans = 1

    for elem in a_list:
        ans *= elem
        if ans > 10**18:
            ans = -1
            break

    print(ans)

# else:
    # do nothing

Measured memory_bytes: 21784
#include <bits/stdc++.h>
using namespace std;
int i,j,k,n,m,x,y,t;
int main(){
	scanf("%d",&n);
	if (n&1)m=n;else m=1+n;
	for (i=1;i<=n;i++)for (j=i+1;j<=n;j++)if (i+j!=m)x++;
	printf("%d\n",x);
	for (i=1;i<=n;i++)for (j=i+1;j<=n;j++)if (i+j!=m)printf("%d %d\n",i,j);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            //ここから
            int[] str = ReadLineToIntArray();
            int N = str[0];
            int X = str[1];

            List<int> x = ReadLineToIntList();
            x.Add(X);

            int gcd = Math.Abs(x[0]-X);
            for(int i = 0; i < N; i++)
            {
                gcd = (int)GCD(gcd, Math.Abs(x[i] - x[i + 1]));
                if (gcd == 1)
                {
                    break;
                }
            }

            //ここまで
            Console.WriteLine(gcd);
            Console.ReadKey();
        }

        static public void Factoring(long num,ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for(long i = 2; i < (long)Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }


        long mod = 1000000007;
        static public void Swap<T>(ref T a,ref T b) { T temp = a;a = b;b = temp; }
        static public long GCD(int a, int b){ return b != 0 ? GCD(b, a % b) : a;}
        static public long LCM(int a, int b){ return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n,int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }

        
        static public string ReadLineToString(){return Console.ReadLine();}
        static public int ReadLineToInt(){return int.Parse(Console.ReadLine());}
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray(){return Console.ReadLine().Split(' ').ToArray();}
        static public int[] ReadLineToIntArray(){return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();}
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList(){return Console.ReadLine().Split(' ').ToList();}
        static public List<int> ReadLineToIntList(){return Console.ReadLine().Split(' ').Select(int.Parse).ToList();}
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    }
    
}


Measured memory_bytes: 19296
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T>
T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T>
T round(T a, T b) {
    return (a + b / 2) / b;
}
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;
}
template <class T>
bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

bool bigger(string S, string T) {
    int s = S.size(), t = T.size();
    if (s > t) {
        return true;
    } else if (s < t) {
        return false;
    }
    REP(i, s) {
        if (S[i] > T[i]) {
            return true;
        } else if (S[i] < T[i]) {
            return false;
        }
    }
    return true;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int cost[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    REP(i, M) {
        cin >> A[i];
    }
    vector<string> dp(N + 1, "");
    REP(i, N + 1) {
        REP(j, M) {
            int k = i - cost[A[j] - 1];
            if (k < 0) {
                continue;
            } else if (k > 0 && dp[k] == "") {
                continue;
            }
            string S = to_string(A[j]);
            if (A[j] >= dp[k][0] - '0') {
                S = S + dp[k];
            } else {
                S = dp[k] + S;
            }
            if (bigger(S, dp[i])) {
                dp[i] = S;
            }
        }
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 35200
int n,v[1000],i;
float r,q;
int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int main(){
    scanf("%d",&n);
    for(i=n;i--;)scanf("%d",&v[i]);
    qsort(v,n,4,comp);
    q=v[0];
    for(i=1;i<n;i++){
        r=(q+v[i])/2.;
        q=r;
    }
    printf("%f",r);
    return 0;
}

Measured memory_bytes: 128
using Yorukatsu051.Questions;
using Yorukatsu051.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu051.Questions
{
    /// <summary>
    /// https://atcoder.jp/contests/abc141/tasks/abc141_a
    /// </summary>
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var s = inputStream.ReadLine();
            switch (s)
            {
                case "Sunny":
                    yield return "Cloudy";
                    yield break;
                case "Cloudy":
                    yield return "Rainy";
                    yield break;
                case "Rainy":
                    yield return "Sunny";
                    yield break;
                default:
                    throw new ArgumentException();
            }
        }
    }
}


namespace Yorukatsu051
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu051.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu051.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 9044
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll A, B, C;

int main() {
	scanf("%lld %lld %lld", &A, &B, &C);
	printf("%lld\n", max(C - A + B, 0ll));
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector a(1, 0L);
    int64_t t = 0;
    for (auto c : s) {
        if (c == '0') {
            a.push_back(t);
        } else {
            ++t;
        }
    }
    a.push_back(t);

    int64_t k;
    cin >> k;
    k = min(k, a.back());

    int64_t n = a.size();

    constexpr auto M = 998244353L;

    vector dp(k + 1, vector(a.back() + 1, 0L));
    dp[0][0] = 1;
    for (auto i : irange(0L, n - 1)) {
        vector next(k + 1, vector(a.back() + 1, 0L));

        for (auto j : irange(0L, k + 1)) {
            int64_t ss = 0;
            for (auto c : irange(a[i + 1], a.back() + 1)) {
                next[j][c] += ss + dp[j][a[i] + (c - a[i + 1])];
                ss += dp[j][a[i] + (c - a[i + 1])];
                next[j][c] %= M;
            }

            for (auto c : irange(a[i + 1], a.back() + 1)) {
                for (auto b : irange(a[i] + (c - a[i + 1]) + 1, c + 1)) {
                    auto w = j + b - (a[i] + (c - a[i + 1]));
                    if (w > k) {
                        break;
                    }
                    next[w][c] += dp[j][b];
                    next[w][c] %= M;
                }
            }
        }

        dp = std::move(next);
    }

    int64_t ans = 0;
    for (auto i : irange(0L, k + 1)) {
        ans += dp[i][a.back()];
        ans %= M;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4768
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int a=0;
  int b=0;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]=='A')
       a++;
    else
      b++;
  }
  if(a>0 &&b>0)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 1000000007;

long long N, M;
set<long long> A;

void read() {
  cin >> N >> M;
  for (long long i = 0; i < M; i++) {
    long long a;
    cin >> a;
    A.insert(a);
  }
}

int main() {
  read();

  vector<long long> DP;
  DP.push_back(1);
  DP.push_back(A.find(1) == A.end() ? 1 : 0);

  for (long long i = 2; i <= N; i++) {
    long long size = static_cast<long long>(DP.size());
    long long back = DP.at(size - 1);
    long long tick = DP.at(size - 2);
    if (A.find(i) == A.end())
      DP.push_back((back + tick) % MOD);
    else
      DP.push_back(0);
  }

  cout << DP.back() << endl;
}


Measured memory_bytes: 6136
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	int ret = 0;
	while (n) {
		ret++;
		n /= k;
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 3108
N,K=gets.split.map &:to_i
A=N.times.map{gets.split.map &:to_i}.sort
x,y=A.transpose
Y=y.sort
r=(x[-1]-x[0])*(Y[-1]-Y[0])
N.times{|i|(i+1...N).each{|j|N.times{|k|(k+1...N).each{|l|
	lx=x[i];rx=x[j];ly=Y[k];ry=Y[l]
	q=(rx-lx)*(ry-ly)
	r=q if r>q&&j-i+1>=K&&(i..j).count{|z|
		ly<=y[z]&&y[z]<=ry
	}>=K
}}}}
p r

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;

  // [0, n/2]
  int ok = 0;
  int ng = n / 2 + 1;

  while (abs(ok - ng) > 1) {
    int len = (ok + ng) / 2;

    bool flag = false;
    REP(i, (n - len + 1)) {
      auto sub = s.substr(i, len);
      auto res = s.substr(i + len, n - i - len);
      if (res.find(sub) != string::npos) {
        flag = true;
        break;
      }
    }
    if (flag) {
      ok = len;
    } else {
      ng = len;
    }
  }
  cout << ok << endl;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;
int op[200];

int main() {
    int n, x, y, ans = 1;
    cin >> n;
    for (int i = 1; i <= n; i++)cin >> op[i];
    for (int i = 2; i <= n; i++) {
        bool flag = true;
        for (int j = 1; j < i; j++)
            if (op[j] > op[i]) {
                flag = false;
                break;
            }
        if (flag)ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 5, M = 1e9 + 7;
int main()
{
    ll a, b;
    cin >> a >> b;
    if (a && b && a < 10 && b < 10)
        cout << a * b;
    else
        cout << -1;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
s = []
for _ in range(n):
    s.append(int(input()))
s.sort()
a = sum(s)

if a%10!=0:
    print(a)
    exit()

for i in range(n):
    if s[i]%10==0:
        continue
    a -= s[i]
    if a%10!=0:
        print(a)
        exit()

print(0)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  long long N;
  cin >> N;
  vector<long long> A(N), count(N + 1, 0);
  rep(i, N)
  {
    cin >> A[i];
    count[A[i]]++;
  }
  long long sum_ans = 0;
  rep(i, N + 1)
  {
    sum_ans += count[i] * (count[i] - 1) / 2;
  }
  rep(i, N)
  {
    long long n = A[i];
    long long ans = sum_ans - (count[n] * (count[n] - 1) / 2);
    ans += (count[n] - 1) * (count[n] - 2) / 2;
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 5760
h, w = gets.split.map(&:to_i)
a = readlines.map {|line| line.strip.split.map(&:to_i) }

one_route = []
tmp_route = []
count=0

have_odd = false
h.times do |i|
  y=i
  w.times do |j|
    x = j
    x = w-1-x if y.odd?

    tmp_route << [y, x] if have_odd
    if a[y][x].odd?
      have_odd = !have_odd
      if have_odd
        tmp_route << [y, x]
      else
        count += tmp_route.length-1
        one_route << tmp_route
        tmp_route = []
      end
    end

  end
end

p count
one_route.each do|route|
  pre = route.shift
  route.each do |point|
    puts [pre, point].flatten.map {|e| e+1 }.join(' ')
    pre = point
  end
end



Measured memory_bytes: 42364
n,k=map(int,input().split())
a=[]

for i in range(1,n+1):
  x=0
  while i*(2**x)<k:
    x+=1
  a.append(x)
    
ans=0
for j in range(0,n):
  ans+=(1/n)*(2**(-a[j]))
  
print(ans)  
    
  


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

int n;

void dfs(int d, int m, string s) {
    if (d == n) {
        cout << s << endl;
        return;
    }
    for (int i = 0; i < m; ++i)
        dfs(d + 1, m, s + (char)('a' + i));
    dfs(d + 1, m + 1, s + (char)('a' + m));
}

int main() {
    cin >> n;
    dfs(0, 0, "");

    return 0;
}

Measured memory_bytes: 1536
import sys

n = int(input())

n_concecutive = 0

for _ in range(n):
    d1, d2 = map(lambda x: int(x), input().split())
    if d1 == d2:
        n_concecutive += 1
        if n_concecutive >= 3:
            print('Yes')
            sys.exit()
    else:
        n_concecutive = 0
print('No')

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000;
vector<int> par(maxn), rank(maxn);
int q;

void init(int n) {
  for (int i=0; i<n; i++) {
    par[i]=i;
    rank[i]=0;
  }
}
int find(int val) {
  if (val==par[val]) {
    return val;
  } else {
    par[val]=find(par[val]);
    return par[val];
  }
}
void unite(int x,int y) {
  x=find(x);
  y=find(y);
  if (x==y) {
    return;
  }
  if (rank[x]<rank[y]) {
    par[x]=y;
  } else {
    par[y]=x;
    if (rank[x]==rank[y]) {
      rank[x]++;
    }
  }
}
bool same(int x,int y) {
  x=find(x);
  y=find(y);
  return x==y;
}
int main() {
  int n;
  cin >> n >> q;
  init(n);
  for (int i=0; i<q; i++) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com==0) {
      unite(x,y);
    } else {
      printf("%d\n",same(x,y));
    }
  }
  return 0;
}

Measured memory_bytes: 3476
#include<iostream>
#include<stdio.h>
#include<cmath>
 
using namespace std;
int main () {
    int n;
    while(cin >> n,n!=0){
        double ave,hensa[999],sum=0,s[999];
        for(int i=0;n>i;i++){
            cin >> s[i];
            sum+=s[i];
        }
        ave=sum/n;
        sum=0;
        for(int i=0;n>i;i++) sum+=(s[i]-ave)*(s[i]-ave);
        printf("%.6f\n",sqrt(sum/n));
    }
}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
 
int main (){
  string S,T;
  cin>>S>>T;
  int s,t,ans=10000;
  s=S.length();
  t=T.length();
  for(int i=0;i<s-t+1;i++){
    int a=0;
    for(int j=0;j<t;j++){
      if(S[i+j]==T[j]){
        a++;
      }
    }
    ans=min(ans,t-a);
  }
  cout<<ans;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#define MAX_N 1001
using namespace std;
//lcs
int n,m;
string s,t;
int dp[MAX_N+1][MAX_N+1];
void solve(){
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++){
      if(s[i]==t[j]) dp[i+1][j+1]=dp[i][j]+1;
      else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
    }
  cout<<dp[n][m]<<endl;
}
 
 
int main(){
  int N;
  cin>>N;
  while(N--){
    cin>>s>>t;
    n=s.size();
    m=t.size();
    solve();
  }
  return 0;
}

Measured memory_bytes: 5124
N = int(input())
rates = list(map(int, input().split()))

l = [0]*8
over = 0
for r in rates:
    if r >= 3200:
        over += 1
    else:
        l[r//400] += 1

col_num = len(list(filter(lambda x: x > 0, l)))

if col_num == 0:
    print(1, over)
else:
    print(col_num, col_num+over)


Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    i64 k;
    cin >> n >> k;
    akari<i64> as(n), fs(n), xs(n);
    for (int i = 0; i < n; i++)
    {
        cin >> as[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> fs[i];
    }
    sort(as.begin(), as.end());
    sort(fs.rbegin(), fs.rend());
    for (int i = 0; i < n; i++)
    {
        xs[i] = as[i] * fs[i];
    }
    i64 ng = -1, ok = 1e15;
    while (ng + 1 < ok)
    {
        i64 m = (ng + ok) / 2;
        i64 cnt = 0;
        for (int i = 0; i < n; i++)
        {
            cnt += max(i64(0), (xs[i] - m + fs[i] - 1) / fs[i]);
        }
        (cnt <= k ? ok : ng) = m;
    }
    cout << ok << endl;
}

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

Measured memory_bytes: 4992
S=input()
K=int(input())
chars=sorted(list(set(list(S))))
strings=set()

for c in chars:
  if len(strings)>=5:
    break
  for i in range(len(S)):
    if S[i]==c:
      for j in range(5):
        if i+j<=len(S):
          strings.add(S[i:i+j+1]) 
          
print(sorted(list(strings))[K-1])

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

int main(int argc, const char * argv[]) {
    string s;
    string p;
    
    getline(cin,s);
    getline(cin,p);
    
    s+=s;
    
    if(s.find(p)!=string::npos){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3236
#include <stdio.h>

int main(){
  int n, x, i, j, k, c = 0;
  while(scanf("%d%d", &n, &x)){
    if(n == 0 && x == 0) break;
    for(i = 1;i < n - 1;i++)
      for(j = i + 1;j < n;j++)
        for(k = j + 1;k < n + 1;k++)
          if((i + j + k) == x) c++;
    printf("%d\n", c);
    c = 0;
  }
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define LL long long
int N, M;
char d[3010][3010];
char dango[] = {'R', 'G', 'W'};
int solve(int a, int b){
    int dp[3010][2][2] = {};
    int idx = 0;
    int res = 0;
    while(0 <= a && a < N && 0 <= b && b < M){
        dp[idx + 1][0][0] = max(dp[idx][0][0], dp[idx][0][1]);
        dp[idx + 1][0][1] = max(dp[idx][1][0], dp[idx][1][1]);
        bool t = true, y = true;
        for(int i = 0; i < 3; i++){
            if(d[a + i][b] != dango[i]) t = false;
        }
        if(t){
            dp[idx + 1][0][0] = max(dp[idx + 1][0][0], dp[idx][0][0] + 1);
        }
        for(int i = 0; i < 3; i++){
            if(d[a][b + i] != dango[i]) y = false;
        }
        if(y){
            dp[idx + 1][1][0] = max({dp[idx + 1][1][0], dp[idx][0][0] + 1, dp[idx][0][1] + 1});
            dp[idx + 1][1][1] = max({dp[idx + 1][1][1], dp[idx][1][0] + 1, dp[idx][1][1] + 1});
        }
        idx++;
        a--,b++;
    }
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 2; j++){
            res = max(res, dp[idx][i][j]);
        }
    }
    return res;
}


int main(){
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            cin >> d[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans += solve(i, 0);
    }
    for(int i = 1; i < M; i++){
        ans += solve(N - 1, i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11984