akhauriyash/Code-Regression huggingface dataset:
// An efficient C++ program to compute 
// sum of bitwise OR of all pairs 
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long
const int MOD = 1e9 + 7, N = 1e5 + 10;
// Returns sum of bitwise OR 
// of all pairs 
ll modpow(ll x, ll y){
   ll ans=1;
   if(y==1){
      return x%MOD;
   }
   x=x % MOD;
   y=y % (MOD-1);
   while(y){
      if(y & 1){
         ans = (ans*x) %MOD;
      }
      x *= x;
      x = x % MOD;
      y >>= 1;
   }
   return ans;
}

ll modinv(ll x){
   return modpow(x,MOD-2);
}
long long int sumXOR(long long arr[], long long n) 
{ 
   long long int sum = 0; 
   for (int i = 0; i < 61; i++) 
   { 
      // Count of zeros and ones 
      long long zc = 0, oc = 0; 
      
      // Individual sum at each bit position 
      long long int idsum = 0; 
      for (int j = 0; j < n; j++) 
      { 
         if (arr[j] % 2 == 0) 
            zc++; 
         else
            oc++; 
         arr[j] /= 2; 
      } 
      
      // calculating individual bit sum 
      idsum = ((oc*zc)%MOD)*modpow(2,i);
      idsum%=MOD;

      // final sum    
      sum += idsum;

      sum%=MOD; 
   } 
   return sum; 
} 

int main() 
{ 
   long long int sum = 0; 
   
   long long n ;
   cin >> n;
   long long arr[n];
   for(int i=0;i<n;i++){
      cin >> arr[i];
   }
   sum = sumXOR(arr, n); 
   cout << sum; 
   return 0; 
} 


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    int counter=0;
    int count, counter1;
    cin >>N;
    map<string,int>memo;
    string s;
    for(int i=0;i<N;i++){
    cin>>s;
    memo[s]++;}
    for(auto p :memo){
    if(p.second>counter){
    counter=p.second;}}
    for(auto p :memo){
    if(p.second==counter){
    cout<<p.first<<endl;
    }}}
    

Measured memory_bytes: 25216
import math

class Point():
    def __init__(self, x, y):
        self.x = x
        self.y = y


def koch(n, a, b):
    if n == 0:
        return
    th = math.radians(60)
    s = Point((2*a.x+b.x)/3, (2*a.y+b.y)/3)
    t = Point((a.x+2*b.x)/3, (a.y+2*b.y)/3)
    u = Point((t.x-s.x)* math.cos(th) - (t.y-s.y)*math.sin(th)+s.x,
                (t.x-s.x)* math.sin(th) + (t.y-s.y)*math.cos(th)+s.y)

    koch(n-1, a, s)
    print(s.x, s.y)
    koch(n-1, s, u)
    print(u.x, u.y)
    koch(n-1, u, t)
    print(t.x, t.y)
    koch(n-1, t, b)

if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    n = int(input())

    a = Point(0, 0)
    b = Point(100, 0)

    print(a.x, a.y)
    koch(n, a, b)
    print(b.x, b.y)



Measured memory_bytes: 5784
//https://www.cnblogs.com/patricksu/p/8479527.html
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,x) for(int i=head[x];i;i=e[i].next)
#define mem(a,x) memset(a,x,sizeof(a))
typedef long long LL;
typedef double DB;
using namespace std;
template <typename T> inline T read(T &a) {
    T x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9') f=(ch=='-')?-1:f,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+(ch-'0'),ch=getchar();a=f*x;
}
const int maxn=500000+10,mo=998244353;
int fac[maxn*2],inv[maxn*2];
int i,j,k,l,t,n,m,ans;
int ksm(int x,int y) {
    int ret=1;
    for(;y;x=(LL)x*x%mo,y>>=1) if(y&1) ret=(LL)ret*x%mo;
    return ret;
} 
int C(int n,int m) {
    if(n<m||m<0) return 0;
    return (LL)fac[n]*inv[m]%mo*inv[n-m]%mo;
}
int main() {
    read(n),read(m);
    if(n<m) swap(n,m);
    fac[0]=1;
    fo(i,1,n*2) fac[i]=(LL)fac[i-1]*i%mo;
    inv[n*2]=ksm(fac[n*2],mo-2);
    fd(i,n*2-1,0) inv[i]=(LL)inv[i+1]*(i+1)%mo;
    fo(i,1,m) (ans+=(LL)C(2*i,i)*C(n+m-2*i,n-i)%mo)%=mo;
    ans=(LL)ans*ksm(2*C(n+m,n)%mo,mo-2)%mo;
    ans=((n+ans)%mo+mo)%mo;
    printf("%d\n",ans);
}

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

int main(){
    int c[3][3];
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> c[i][j];
        }
    }
    
    bool ans=true;
    for(int r=0; r<2; r++){
        for(int i=0; i<2; i++){
            int diff = c[0][i+1] - c[0][i];
            for(int j=0; j<3; j++){
                if(c[j][i+1] -c[j][i] != diff) ans = false;
            }
        }
        swap(c[0][1], c[1][0]);
        swap(c[0][2], c[2][0]);
        swap(c[1][2], c[2][1]);
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }   
    return 0;
}


Measured memory_bytes: 256
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,n) for(int i=(1);i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 200005;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Test.insert(x)late ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}

/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    int n,k;
    cin>>n>>k;
    map<int,int>mp;
    rep(i,n){
        int x;cin>>x;
        mp[x]++;
    }
    vi ans;
    for(auto val:mp){
        if(val.s)ans.pb(val.s);
    }
    sort(all(ans));
    n=ans.size();
    if(n<=k){
        cout<<0;
        return 0;
    }
    int res=0;
    rep(i,n-k){
        res+=ans[i];
    }
    cout<<res<<enl;

    return 0;
}


Measured memory_bytes: 17796
N, K = map(int, input().split())

if K % 2 != 0:
    ans_odd = []
    for i in range(N):
        if ((i + 1) % K) == 0:
            ans_odd.append(i + 1)

    len_ans = len(ans_odd)
    print(len_ans * len_ans * len_ans)

else:
    ans_even_zero = []
    ans_even_k = []
    for i in range(N):
        if (i + 1) % K == 0:
            ans_even_zero.append(i + 1)
        elif (i + 1) % K == (K // 2):
            ans_even_k.append(i + 1)

    len_ans_even_zero = len(ans_even_zero)
    len_ans_even_k = len(ans_even_k)

    ans = len_ans_even_zero * len_ans_even_zero * \
        len_ans_even_zero + len_ans_even_k * len_ans_even_k * len_ans_even_k
    print(ans)


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

// persistent BIT
class BIT {
public:
	BIT() : w(log2(100010)) {}

	void add(int k, long long v) {
		root = add(root, k + 1, v, w);
	}

	long long sum(int k) {
		return sum(root, k + 1);
	}

private:
	struct node {
		node *l = nullptr, *r = nullptr;
		long long val = 0;
	};

	int w;
	node *root = nullptr;

	node *add(node *x, int k, long long v, int d) {
		if (d == -1) return nullptr;
		int e = 1 << d;
		x = x ? new node(*x) : new node();
		if (k <= e) x->val += v;
		if (k == e) return x;
		if (k < e) x->l = add(x->l, k, v, d - 1);
		else x->r = add(x->r, k - e, v, d - 1);
		return x;
	}

	long long sum(node *x, int k) {
		int res = 0;
		for (int i = 1 << w; i > 0; i >>= 1) {
			if (!x) return res;
			if (k < i) {
				x = x->l;
			} else {
				res += x->val;
				k -= i;
				x = x->r;
			}
		}
		return res;
	}
};

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

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

	int L, Q;
	cin >> L >> Q;

	vector<int> a(Q), b(Q);
	for (int i = 0; i < Q; i++) {
		scanf("%d %d", &a[i], &b[i]);
		if (a[i] > b[i]) swap(a[i], b[i]);
		a[i]--; b[i]--;
	}

	vector<vector<int>> pos(n);
	for (int i = 0; i < Q; i++) {
		pos[a[i]].push_back(i);
	}

	vector<BIT> bits(n + 1);

	vector<int> ans(Q);

	for (int i = n - 1; i >= 0; i--) {
		int ok = i;
		int ng = n;
		
		while (ng - ok > 1) {
			int mid = (ok + ng) / 2;

			if (x[mid] - x[i] <= L) {
				ok = mid;
			} else {
				ng = mid;
			}
		}

		bits[i] = bits[ok];
		bits[i].add(i + 1, 1);

		for (int id : pos[i]) {
			ans[id] = bits[i].sum(b[id]);
		}
	}

	for (int i = 0; i < Q; i++) {
		printf("%d\n", ans[i]);
	}
}

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

int main()
{
    char a, b;
    cin >> a >> b;
    
    if(a == 'H')
    {
        cout << b << endl;
        return 0;
    }
    else if(a == 'D')
    {
        if(b == 'H')
        {
            cout << "D" << endl;
            return 0;
        }
        else if(b == 'D')
        {
            cout << "H" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans[100005];
int main(void){
	string s; cin>>s;
	int c=0;
	bool t=true;
	int k[100005],K=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='R'){
			if(t==false){
				t=true;
				ans[k[K-1]]+=c/2;
				ans[k[K-1]+1]+=c/2;
				if(c%2==1){
					if((i-k[K-1])%2==1){
						ans[k[K-1]]++;
					}else{
						ans[k[K-1]+1]++;
					}
				}
				c=0;
			}
			c++;
		}else{
			if(t){
				k[K]=i-1;
				K++;
			}
			t=false;
			c++;
		}
	}
	ans[k[K-1]]+=c/2;
				ans[k[K-1]+1]+=c/2;
				if(c%2==1){
					if((s.size()-k[K-1])%2==1){
						ans[k[K-1]]++;
					}else{
						ans[k[K-1]+1]++;
					}
				}
				
	t=true;
	/*for(int i=0;i<s.size();i++){
		if(ans[i]!=0&&t){
			swap(ans[i],ans[i+1]);
			t=false;
		}
	}*/
	for(int i=0;i<s.size();i++){
		cout<<ans[i];
		if(i!=s.size()-1){
			cout<<" ";
		}
	}
	cout<<endl;
	
	    
}


Measured memory_bytes: 1280
N = int(input())
A = list(map(int, input().split()))

mem = []
h = 0
for i in range(N-1, -1, -1):
    h += A[i]
    mem.append(h)

tmp = 0
for i in range(N-1):
    tmp += A[i]*mem[-(i+1+1)]
print(tmp % (10**9+7))


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

int main() {
  double a;
  while(cin>>a){
    double ans = a;
    for(int i=2;i<=10;i++) {
      if (i%2==1)
        a/=3;
      else
        a*=2;
      ans += a;
    }
    printf("%.8lf\n",ans);
  }
}


Measured memory_bytes: 3264
N,M = map(int,input().split())
sub = [list(input().split()) for i in range(M)]

wa = [0 for i in range(N)]

ac = [0 for i in range(N)]

waans = 0
acans = 0

for i in range(M):
    if sub[i][1] == 'AC' and ac[int(sub[i][0])-1] == 0:
        acans += 1
        waans += wa[int(sub[i][0])-1]
        ac[int(sub[i][0])-1] = 1
    elif sub[i][1] == 'WA' and ac[int(sub[i][0])-1] == 0:
        wa[int(sub[i][0])-1] += 1

print(acans,waans)

Measured memory_bytes: 27568
#include<bits/stdc++.h>
#define int long long

#define MAX_N 200000

using namespace std;

signed main(){
  int n, r[MAX_N];
  
  cin >> n;
  for(int i=0;i<n;i++) cin >> r[i];

  int minv = r[0];
  int maxv = r[1] - r[0];
  for (int i=1;i<n;i++) {
    maxv = max(maxv, r[i] - minv);
    minv = min(minv, r[i]);
  }

  cout << maxv << endl;
}

Measured memory_bytes: 2720
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
from collections import deque


# from decorator import stop_watch
#
#
# @stop_watch
def solve(N):
    dq = deque([(3, {3: 1, 5: 0, 7: 0}),
                (5, {3: 0, 5: 1, 7: 0}),
                (7, {3: 0, 5: 0, 7: 1})])
    ans = 0
    while dq:
        num, check = dq.popleft()
        if num > N:
            break
        if sum(check.values()) == 3:
            ans += 1
        for i in (3, 5, 7):
            new_num = num * 10 + i
            if new_num > N:
                break
            new_check = check.copy()
            new_check[i] = 1
            dq.append((new_num, new_check))
    print(ans)


if __name__ == '__main__':
    N = int(input())
    solve(N)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


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

int mDist(P ab, P cd) {
    int x = abs(ab.first-cd.first);
    int y = abs(ab.second-cd.second);
    return x+y;
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<P> ab(n), cd(m);
    rep(i, n) cin >> ab[i].first >> ab[i].second;
    rep(i, m) cin >> cd[i].first >> cd[i].second;
    rep(i, n) {
        int p = 1;
        int dist = mDist(ab[i], cd[0]);
        for (int j=1; j<m; j++) {
            int tmp = mDist(ab[i], cd[j]);
            if (dist > tmp) {
                dist = tmp;
                p = j+1;
            }
        }
        cout << p << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    K, X = map(int, input().split())
    n = map(lambda x: str(x), filter(lambda x: x >= -1000000 and x <= 1000000, [i for i in range(X-(K-1), X+K)]))
    print(" ".join(n))

main()


Measured memory_bytes: 2940
n = int(input())
b = [int(_) for _ in input().split(' ')]

answer = []
p = True
for i in range(n, 0, -1):
    for j in range(i, 0, -1):
        if b[j - 1] == j:
            answer.append(j)
            b.pop(j - 1)
            break
        elif b[j - 1] > j:
            p = False

if p:
    answer.reverse()
    for i in answer:
        print(i)
else:
    print(-1)


Measured memory_bytes: 3064
import numpy as np
N,K=map(int, input().split())
D = np.zeros((K, N))
for i in range(K):
    d=int(input())
    A=np.array(list(map(int, input().split())))
    for j in range(len(A)):
        D[i][A[j]-1] = 1
ans = D.sum(axis=0)
print(sum(ans == 0))


Measured memory_bytes: 27196
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    ll n,m;;
    in>>n>>m;
    vector<ll> a(n),s(n+1);
    for(auto&i:a) in>>i;
    sort(a.begin(),a.end());
    ll l=0,r=2e5+1,d;
    while(r-l>1){
        d=(r+l)>>1;
        ll c{};
        fr(i,n){
            int j=a.begin()+i+1-upper_bound(a.begin(),a.begin()+i+1,d-a[i]);
            if(j) c+=2*j-1;
        }
        if(c>m) l=d;
        else r=d;
        //cout<<d<<" "<<c<<endl;
    }
    //cout<<"!"<<r<<endl;
    fr(i,n) s[i+1]=a[i]+s[i];
    ll ans{},c{};
    fr(i,n){
        int j=a.begin()+i+1-lower_bound(a.begin(),a.begin()+i+1,r-a[i]);
        //cout<<i<<" "<<j<<endl;
        if(j) c+=2*j-1;
        if(j) ans+=2*(s[i+1]-s[i+1-j])+a[i]*2*(j-1);
    }
    ans-=(c-m)*r;
    cout<<ans<<endl;
}

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

int main(){
  double N = 0.0;
  double x = 0.0;
  string u;
  cin>>N;
  const double btcrate = 380000;
  
  double sum = 0.0;
  for(int i = 0; i < N; i++){
    cin >> x >> u;
    if(u == "JPY"){
      sum += x;
    }else{
      sum += x*btcrate;
    }
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

vs split(string str, char sep) {
	vs v; stringstream ss(str); string t;
	while (getline(ss, t, sep)) v.push_back(t);
	return v;
}

void init_global() {}

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

	string A, B; cin >> A >> B;
	int AL = A.size(), BL = B.size();

	string ans = "";
	if (AL > BL) {
		ans = "GREATER";
	}
	else if (AL < BL) {
		ans = "LESS";
	}
	else {
		if (A > B) ans = "GREATER";
		else if (A < B) ans = "LESS";
		else ans = "EQUAL";
	}

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


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

#define   ll     long long int

int main( )
{
    int a, b, c;
    cin >> a >> b >> c;
    if (c % __gcd(a, b) == 0) {
        cout << "YES\n";
    }
    else {
        cout << "NO\n";
    }
    return 0;
}



Measured memory_bytes: 256
n, x, y = map(int, input().split())
ans = [0] * n
for i in range(1, n):
  for j in range(i + 1, n + 1):
    ans[min(j - i, abs(i - x) + 1 + abs(y - j))] += 1
    # print("頂点" + str(i), "頂点" + str(j), "距離" + str(min(j - i, abs(i - x) + 1 + abs(y - j))))
# i, j 頂点のノード(i < j)　例えば 5 と 25
# j - i 追加されたエッジを使わない場合の距離 i と j の距離
# abs(i - x) + 1 + abs(y - j) 追加されたエッジを使う場合の距離 i と j の距離
# min　で短い方を選択
for i in range(1, n):
  print(ans[i])

Measured memory_bytes: 3444
program ABC088C
    implicit none
    integer(8)::C(3,3),i,j,A(3)
    read*,C
    A(1)=C(1,1)+C(1,2)-2*C(1,3)
    A(2)=C(2,1)+C(2,2)-2*C(2,3)
    A(3)=C(3,1)+C(3,2)-2*C(3,3)
    if(A(1)==A(2).and.A(2)==A(3))then
        print'(A)',"Yes"
    else
        print'(A)',"No"
    end if
end program ABC088C

Measured memory_bytes: 2888
#include<iostream>
using namespace std;
 
int main() {
	int n;
  	cin >> n;
  	double numArr[n];
  	int index = 0;
  	while (n != index) {
      	int input;
    	cin >> input;
      	numArr[index] = input;
      	index += 1;
    }
  
  	double sum = 0;
 
    for (int i = 0; i < n; ++i) 
    {
		sum += 1.0/numArr[i];
    }
  
  	cout << 1.0/sum;
  	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    int num,rest=0,result=0;
    cin>>str;
    for(long int i=str.size()-1;i>=0;i--){
        num=str[i]-'0'+rest;
        if(num<(10-num) || (num==5 && str[i-1]<'5')){
            rest=0;
            result+=num;
        }
        else{
            rest=1;
            result+=(10-num);
        }
    }
    result+=rest;
    cout<<result;
}




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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n;
  string q, s;
  set<string> st;
  cin >> n;
  while (n--) {
    cin >> q >> s;
    if (q[0] == 'i') st.insert(s);
    else if (st.count(s)) cout << "yes\n";
    else cout << "no\n";
  }
}


Measured memory_bytes: 29796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans[214514];
int main(){
	string s;
	cin>>s;
	ll rl,rr,ll,lr,now;
	rl=0,now=0;

	for(int i=1;i<s.size();i++){
		if(s[i]=='L'&&!now){
			rr=i-1;
			ll=i;
			now=1;
		}
		if(i==s.size()-1){
			lr=i;
			ans[rr]=(rr-rl+2)/2+(lr-ll+1)/2;
			ans[ll]=(rr-rl+1)/2+(lr-ll+2)/2;
		}
		if(s[i]=='R'&&now){
			lr=i-1;
			ans[rr]=(rr-rl+2)/2+(lr-ll+1)/2;
			ans[ll]=(rr-rl+1)/2+(lr-ll+2)/2;
			now=0;
			rl=i;
		}
	}
	for(int i=0;i<s.size();i++)cout<<ans[i]<<' ';
	return 0;
}


Measured memory_bytes: 4496
using System;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;

class Program
{
	//回文かを判定する関数
	static bool Checker(string s){
			string rev = new string(s.Reverse().ToArray());
			if(s == rev){
					return true;
			}else{
					return false;
			}
	}

	//Main
	static void Main(string[] args)
	{
		//読み込む
		string S = Console.ReadLine();
		int N = S.Length;

		string S2 = S.Substring(0, (N-1)/2);
		string S3 = S.Substring((N+3)/2 - 1);


		if(Checker(S) && Checker(S2) && Checker(S3)){
				Console.WriteLine("Yes");
		}else{
				Console.WriteLine("No");
		}
	}
}



Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
int main(void)
{
	scanf("%d%d",&n,&m);
	if(n%2==1)
	{
		for(ll i=1;i<=m;i++)
		{
			printf("%lld %lld\n",i,n-i+1);
		}
	}
	else
	{
		ll cnt=0;
		for(ll i=1;i<=n/2/2;i++)
		{
			cnt++;
			printf("%lld %lld\n",i,n/2-i+1);
			if(cnt==m) return 0;
		}
		for(ll i=1;i<=n/2/2;i++)
		{
			cnt++;
			printf("%lld %lld\n",i+n/2,n-i);
			if(cnt==m) return 0;
		}
	}
}

Measured memory_bytes: 3844
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    int max=0;
    int kioku=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(max<a[i]){
            max=a[i];
            kioku=i;
        }
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for(int i=0;i<n;i++){
        if(kioku==i){
            cout << a[1] << endl;
        }
        else{
            cout << a[0] << endl;
        }
    }
}

Measured memory_bytes: 2432
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
	Scanner sc = new Scanner(System.in);
	int x = sc.nextInt();int y = sc.nextInt();
	  if(x<y){
	  System.out.println("a < b");
	}
	  else if(x>y){
	  System.out.println("a > b");
	}
	  else{
	  System.out.println("a == b");
	}
}
}


Measured memory_bytes: 26152
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }
 
#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)
 
// constexpr int MOD = 1e9+7;
 
int main(void){
    Cin(int, n);
    Cin(string, s);
    unordered_map<char, int> m;
    for(const char &c : s) m[c] ++;
    ll ans = (ll)m['R'] * m['G'] * m['B'];
 
    for(int d = 1; d <= n; d ++){
        for(int x = 0; x+2*d < n; x ++){
            if(s[x] != s[x+d] && s[x+d] != s[x+2*d] && s[x+2*d] != s[x]) ans --;
        }        
    }
 
    Cout(ans);
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    long long n; cin >> n;
    long long ans = (1 + n) * n / 2 + (15 + n / 15 * 15) * (n / 15) / 2;
    ans -= n / 3 * (3 + n / 3 * 3) / 2;
    ans -= n / 5 * (5 + n / 5 * 5) / 2;
    cout << ans << '\n';

}


Measured memory_bytes: 3648
/*
~~ Author : Bhaskar
~~ Dated : 01~06~2020
*/

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long int
#define db long double
#define str string
#define mod 1000000007
#define ff first
#define ss second
#define PQi priority_queue<int>
#define sitr set<int>::iterator
#define vitr vector<int>::iterator
#define Vi vector<int>
#define Si set<int>
#define Li list<int>
#define mk make_pair
#define pii pair<int,int>
#define all(x) (x.begin(),x.end())
#define pb(x) push_back(x)
#define For(i,n,s) for(int i=s;i<n;i++)
#define mat2D(T,r,c) vector<vector<int> > T(r,vector<int>(c))
#define vec2D vector<vector<int> >
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define getVal(x) {int val;cin>>val;x.pb(val);}
#define debug(x) {for(auto i :x) cout << i << " ";cout << endl;}

unordered_map <int,int> mp;

void solve(){
    int n;
    cin >> n;
    while (n%2 == 0){
        mp[2]++;
        n /= 2;
    }
    int i = 3;
    while (i*i <= n){
        if (n%i == 0){
            while (n%i == 0){
                mp[i]++;
                n /= i;
            }
        }
        i += 2;
    }
    if (n != 1) mp[n]++;
    int ans = 0;
    for (auto x : mp){
        int minn = 1;
        while (x.ss-minn >= 0){
            x.ss -= minn;
            minn++;
            ans++;
        }
    }
    cout << ans << endl;
}

int32_t main(){
    fastIO;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
    # endif
    solve();
    return 0;
}


Measured memory_bytes: 3624
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 100000;

int ii[N + 1], ll[N + 2], rr[N + 2];
bool used[N + 2];

int main() {
	int n; cin >> n;
	for (int i = 1; i <= n; i++) {
		int a; cin >> a;
		ii[a] = i;
	}
	long long ans = 0;
	for (int a = 1; a <= n; a++) {
		int i = ii[a], l = i, r = i;
		used[i] = true;
		if (used[l - 1])
			l = ll[l - 1];
		if (used[r + 1])
			r = rr[r + 1];
		rr[l] = r, ll[r] = l;
		if (r < n) {
			int p = i - l + 1;
			int q = used[r + 2] ? rr[r + 2] - r : 1;
			ans += (long long) p * q * a;
		}
		if (l > 1) {
			int p = used[l - 2] ? l - ll[l - 2] : 1;
			int q = r - i + 1;
			ans += (long long) p * q * a;
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 4768
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 100002;

int n;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;

	vector<int> d(n);
	for (int i = 0; i < n; ++i)
		cin >> d[i];

	sort(d.begin(), d.end());

	int idx = n/2 - 1;
	int ans = d[idx+1] - d[idx];

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

Measured memory_bytes: 640
/**
 * PrintRectangle.cpp
 * Create:20180420
 * Description:複数のH,Wのリストを読み込み、
 * その分の四角形を表示する。
 * 四角形は一辺を"#"で表す。
 */
#include <iostream>
#include <vector>

/**
 * 長方形クラス
 * @param height 高さ
 * @param width  幅
 */
class Rectangle {
private:
  int width;
  int height;
public:
  /**
   * コンストラクタ
   * @param width  横幅
   * @param height 縦幅
   */
  Rectangle(int height, int width){
    this->width = width;
    this->height = height;
  }

  /**
   * 描写
   */
  void draw(){
    for(int i = 0; i < height; i++) {
      for (int j = 0; j < width; j++) {
        std::cout << "#";
      }
      std::cout << std::endl;
    }
  }
};

int main(int argc, char* argv[]){
  std::vector<Rectangle> vec;
  int h, w;

  while (true){
    std::cin >> h >> w;
    if (h == 0 && w == 0)
      break;
    Rectangle r = Rectangle(h, w);
    vec.push_back(r);
  }

  for(Rectangle r: vec){
    r.draw();
    std::cout << std::endl;
  }

  return 0;
}


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

#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void input(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}

void solveTest(){
	
}

int main(){
	fastio();
	//input();

	/*int t;
	cin>>t;
	while(t--){
		solveTest();
	}*/

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

	return 0;
}


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n, m;
  cin >> n >> m;
  vii g(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vi ans(n,-1);
  queue<int> q;
  q.push(0);
  ans[0] = 0;
  while(sz(q)) {
    int v = q.front(); q.pop();
    for(int nv : g[v]) {
      if(ans[nv] != -1) continue;
      ans[nv] = v;
      q.push(nv);
    }
  }
  cout << "Yes" << endl;
  REP(i,n) {
    cout << ans[i] + 1 << endl;
  }
}

Measured memory_bytes: 10292
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin>>s;
  int sum=0;
  for(int i;i<4;i++){
    if('+' == s[i]){
      sum++;
    }
    else{
      sum--;
    }
  }
  cout<<sum<<endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		String S[] = new String[N];
		long num[] = new long[5];
		Arrays.fill(num, 0);
		for(int i = 0; i < N; i++) {
			S[i] = sc.next();
			if(S[i].substring(0, 1).equals("M")) {
				num[0]++;
			}
			if(S[i].substring(0, 1).equals("A")) {
				num[1]++;
			}
			if(S[i].substring(0, 1).equals("R")) {
				num[2]++;
			}
			if(S[i].substring(0, 1).equals("C")) {
				num[3]++;
			}
			if(S[i].substring(0, 1).equals("H")) {
				num[4]++;
			}
		}
		
		long ans = 0;
		int P[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
		int Q[] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
		int R[] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};
		for(int i = 0; i < 10; i++) {
			ans += num[P[i]] * num[Q[i]] * num[R[i]];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 57588
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

const lint mod = 1e9+7;
const lint INF = mod*mod;
const int MAX =100010;

int main(){
    lint n, x, d;
    scanf("%lld%lld%lld", &n, &x, &d);
    if(d==0){
        if(x==0) printf("%d\n", 1);
        else printf("%lld\n", n+1);
        return 0;
    }

    vector<pll> seg[n+1];
    map<lint, int> idx;
    int cur=0;
    for(lint k=0; k<n+1; ++k){
        lint r=k*x%d;
        if(idx.find(r)==idx.end()) idx[r]=cur++;
    }

    for(lint k=0; k<n+1; ++k){
        lint q=k*x/d, r=k*x%d;
        seg[idx[r]].emplace_back(k*(k-1)/2+q, k*(2*n-k-1)/2+q);
    }
    rep(i, n+1) sort(seg[i].begin(), seg[i].end());

    lint ans=0;
    rep(i, n+1){
        stack<pll> st;
        for(auto s: seg[i]){
            if(st.empty() || st.top().se<s.fi) st.push(s);
            else if(st.top().se>=s.se) continue;
            else st.top().se=s.se;
        }
        while(!st.empty()){
            auto s=st.top(); st.pop();
            ans+=s.se-s.fi+1;
        }
    }

    printf("%lld\n", ans);
}

Measured memory_bytes: 23680
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<cstring>
using namespace std;
const int inf=1e9+5;
const int maxn=100000;
typedef vector<int> vi;
typedef long long ll;
#define fi first
#define se second
typedef pair<int,int> P;
vector<pair<int,int> > Edge[maxn+5];
int d[maxn+5];
bool visited[maxn+5];
int v,e,r;

void dijkstra(int s)
{
  memset(visited,false,sizeof(visited));
  for(int i=0;i<maxn+5;i++)
  {
    d[i]=inf;
  }
  priority_queue<P,vector<P>,greater<P> > que;
  d[s]=0;
  que.push(P(0,s));
  while(!que.empty())
  {
    P f=que.top();que.pop();
    int u=f.se;
    visited[u]=true;
    if(d[u]<f.fi) continue;
    for(int j=0;j<Edge[u].size();j++)
    {
      int v=Edge[u][j].se;
      if(visited[v]) continue;
      if(d[v]>d[u]+Edge[u][j].fi)
      {
        d[v]=d[u]+Edge[u][j].fi;
        que.push(P(d[v],v));
      }
    }
  }
  for(int i=0;i<v;i++)
  {
    if(d[i]==inf)
    {
      cout << "INF" << endl;
    }
    else
    {
      cout << d[i] << endl;
    }
  }
}

int main(void)
{
  cin >> v >> e>> r;
  for(int i=0;i<e;i++)
  {
    int s,t,d;
    cin >> s >> t >> d;
    Edge[s].push_back(P(d,t));
    //Edge[t].push_back(P(d,s));
  }
  dijkstra(r);
}


Measured memory_bytes: 13084
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

#define mp(a, b) make_pair(a, b)

struct edge {
    int to, cost;
    edge(int to, int cost) {
        this->to = to, this->cost = cost;
    }
};

typedef pair< int, pair< int, int > > iP;

int n, m, r;
vector< int > city;
map< int, int > idx;
vector< vector< edge > > g;

int d[201][201];

bool isVisited(int v) {
    for(int i = 0; i < r; i++) {
        if(!(v >> i & 1)) return false;
    }
    return true;
}

int dijkstra() {
    priority_queue< iP, vector< iP >, greater< iP > > q;
    int mincost[201][1 << 10];
    fill_n(*mincost, 201 * (1 << 10), 1e+8);
    for(int i = 1; i <= r; i++) {
        q.push(iP(0, mp(city[i - 1], 1 << i)));
        mincost[city[i - 1]][1 << i] = 0;
    }
    while(!q.empty()) {
        iP p = q.top(); q.pop();
        if(isVisited(p.second.second)) return p.first;
        for(int i = 0; i < g[p.second.first].size(); i++) {
            edge &e = g[p.second.first][i];
            int next_bit = p.second.second | (1 << idx[e.to]);
            if(e.cost + p.first < mincost[e.cost][next_bit]) {
                mincost[e.cost][next_bit] = e.cost + p.first;
                q.push(iP(e.cost + p.first, mp(e.to, next_bit)));
            }
        }
    }
    return -1;
}

int dp[201][1 << 9];
int rec(int now, int visited) {
    if(isVisited(visited)) return 0;

    if(dp[now][visited]) return dp[now][visited];
    int ret = 1e+8;
    for(int i = 0; i < r; i++) {
        if(!(visited >> i & 1))
        ret = min(ret, rec(city[i], visited | (1 << i)) + d[now][city[i]]);
    }
    return dp[now][visited] = ret;
}

int main() {

    cin >> n >> m >> r;
    g.resize(n + 1);
    city.resize(r);


    fill_n(*d, 201 * 201, 1e+8);

    for(int i = 0; i < r; i++) {
        cin >> city[i];
        idx[city[i]] = i + 1;
    }
    for(int i = 0; i < m; i++) {
        int a, b, c; cin >> a >> b >> c;
        d[a][b] = d[b][a] = c;
        g[a].push_back(edge(b, c));
        g[b].push_back(edge(a, c));
    }

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            for(int k = 1; k <= n; k++) {
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }

    int mini = 1e+8;
    for(int i = 0; i < r; i++) {
        mini = min(mini, rec(city[i], 1 << i));
    }
    cout << mini << endl;
    //cout << dijkstra() << endl;
}


Measured memory_bytes: 896
import sys
input = sys.stdin.readline
N, M, L = map(int, input().split())
INF = float('inf')
VD = [[INF] * N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    VD[a][b] = c
    VD[b][a] = c
for i in range(N):
    VD[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            if VD[i][j] > VD[i][k] + VD[k][j]:
                VD[i][j] = VD[i][k] + VD[k][j]

WD = [[INF] * N for _ in range(N)]
for i in range(N):
    WD[i][i] = 0
    for j in range(i+1,N):
        d = VD[i][j]
        if d <= L:
            WD[i][j] = 1
            WD[j][i] = 1

for k in range(N):
    for i in range(N):
        for j in range(N):
            if WD[i][j] > WD[i][k] + WD[k][j]:
                WD[i][j] = WD[i][k] + WD[k][j]

Q = int(input())
for _ in range(Q):
    s, t = map(int, input().split())
    print(WD[s-1][t-1]-1 if WD[s-1][t-1] < INF else -1)


Measured memory_bytes: 73820
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
# endregion
S = list(rs())
print('yes' if len(S) == len(set(S)) else 'no')

Measured memory_bytes: 63084
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define method(name,res,...) function<res (__VA_ARGS__) > name = [&](__VA_ARGS__) -> res
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

string reversed(string str){
  reverse(all(str));
  return str;
}

int func(){
  string str = in<string>();
  set<string> s;
  int n = str.size();
  rep(i,n){
    string a = str.substr(0,i);
    string b = str.substr(i, n-i);
    s.emplace(a+b);
    s.emplace(reversed(a) + b);
    s.emplace(a + reversed(b));
    s.emplace(reversed(a) + reversed(b));
    s.emplace(b+a);
    s.emplace(reversed(b) + a);
    s.emplace(b + reversed(a));
    s.emplace(reversed(b) + reversed(a));
  }
  return s.size();
}

int main(){
  int n = in();
  rep(i,n){
    cout << func() << endl;
  }
  return 0;
}



Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll x=0;
void dfs(int u,vector<int>adj[],ll vis[]) {
    vis[u]=1;
    x++;
    for(auto i: adj[u]) {
        if(!vis[i])
        dfs(i,adj,vis);
    }
}
int main() {
    string a,b;
    cin>>a>>b;
    int min1=INT_MAX;
    for(int i=0;i<=a.size()-b.size();i++) {
            int k=i,x=0;
            for(int j=0;j<b.size();j++) {
                if(b[j]!=a[k++]) {
                    x++;
                }
            }
            min1=min(x,min1);
    }
    cout<<min1;
    
}

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

using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;int m,sum=0;
    for(int i=1;i<=n;i+=1){
        cin>>m;
        if(i%2==1 && m%2==1)sum++;
    }
    cout<<sum<<endl;









    return 0;
}




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

using namespace std;

typedef long long ll;

int main() {
  ll n,k;

  cin >> n >> k;

  ll ans = 0;

  if(k == 0) {
    cout << n * n << endl;
    return 0;
  }

  for(ll b = k + 1; b <= n; b++) {
    ll p = n / b;
    ll q = n % b;
    ll y = max((ll)0,q - k + 1);
    ll x = b - k - y;
    ans += (p + 1) * y + p * x;

  }

  cout << ans << endl;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int g[13]={-1,1,3,1,2,1,2,1,1,2,1,2,1};
  	int a,b;
  cin>>a>>b;
  if(g[a]==g[b]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
	int n;
	int ans;

	cin >> n ;
	ans=0;
	rep2(i, 1, n){
		ans+=(n-1)/i;
	}

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

Measured memory_bytes: 3628
h, w, k = map(int, input().split())
c = [list(input()) for i in range(h)]
ans = 0
for hh in range(2**h):
    for ww in range(2**w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if (hh >> i) & 1 and (ww >> j) & 1:
                    if c[i][j] == '#':
                        cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Measured memory_bytes: 74064
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <limits>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define x first
#define y second
#define sf scanf
#define pf printf
#define vec vector
#define pb push_back
#define mp make_pair
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define clr(a,b) memset(a,b,sizeof(a))
#define bin_cnt(x) __builtin_popcount(x)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define srep(sub,s) for(int sub=s&(s-1);sub;sub=(sub-1)&s)
#define irep(i,a) for(__typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define irrep(i,a) for(__typeof(a.rbegin()) i=a.rbegin();i!=a.rend();i++)
#define inf numeric_limits<int>::max()
#define finf numeric_limits<double>::infinity()
#define eps 1e-8
#pragma GCC optimize ("O3")
#define o3 __attribute__((optimize("O3")))
#pragma comment(linker, "/STACK:32505856")

template<class T> inline T sqr(T a) {return a*a;}
template<class T> inline int gmin(T&a,T b) {if(a>b){a=b;return 1;}return 0;}
template<class T> inline int gmax(T&a,T b) {if(a<b){a=b;return 1;}return 0;}
inline int dcmp(const double &a) {return a>eps?1:(a<-eps?-1:0);}
struct Initializer{Initializer(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}}initializer;

char st[1024];
char ok[1024] = " CODEFESTIVAL2016";

int main() {
  while (~sf("%s", st + 1)) {
    int cnt = 0;
    rep(i, 1, 16) {
      if (ok[i]!=st[i]) cnt++;
    }
    pf("%d\n", cnt);
  }
  return 0;
}


Measured memory_bytes: 256