akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define inf 1000000000000000000
#define norm 0
#define mod 998244353
#define IO                    \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
using namespace std;
const int N=1e5+5;
ll gcd(ll a,ll b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
int main()
{
    IO
    //cout<<gcd(20,36)<<endl;
   ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll lcm=c*d;
    lcm/=gcd(c,d);
    ll res=b-a+1;
    ll tmp=a/c;
    if(a%c==0)tmp--;
    ll del1=0;
    del1=b/c;
    del1-=tmp;
    ll del2=0;
    tmp=a/d;
    if(a%d==0)tmp--;
    del2=b/d;
    del2-=tmp;
    ll del3=0;
    del3=b/lcm;
    tmp=a/lcm;
    if(a%lcm==0)tmp--;
    del3-=tmp;
    cout<<(ll)res-((del1+del2)-del3);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


//最大公約数
ll gcd(ll x,ll y){

	x = abs(x);
	y = abs(y);

	if(x < y){
		swap(x,y);
	}
	if(y == 0){
		return x;
	}else{
		return gcd(y,x%y);
	}
}

//最小公倍数
ll lcm(ll x,ll y){

	return (x*y)/gcd(x,y);
}

int main(){

	ll A,B;
	scanf("%lld %lld",&A,&B);

	printf("%lld\n",lcm(A,B));

	return 0;
}


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


def solve(n: int, p: "List[int]"):
    res = 0
    for i in range(len(p)-2):
        if p[i+1] == list(sorted(p[i:i+3]))[1]:
            res += 1
    print(res)


    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    p = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, p)

if __name__ == '__main__':
    main()


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

signed main(void){
    int n; cin >> n;
    vector<vector<int>>inp(n-1,vector<int>(2));
    for(int i=0;i<n-1;i++) cin >> inp[i][0] >> inp[i][1],inp[i][0]--,inp[i][1]--;
    vector<vector<int>>G(n);
    for(int i=0;i<inp.size();i++){
        G[inp[i][0]].push_back(inp[i][1]);
        // G[inp[1]].push_back(inp[0]);
    }
    vector<int>from_col(n,-1);

    for(int i=0;i<G.size();i++){
        int col = 0;
        for(int j=0;j<G[i].size();j++){
            if (col == from_col[i]){
                col++;
            }
            from_col[G[i][j]] = col++;
        }
    }

    cout << *max_element(from_col.begin(),from_col.end())+1 << endl;
    for(int i=0;i<inp.size();i++){
        cout << from_col[inp[i][1]]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    ll N; cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A.at(i);
    
    sort(ALL(A));
    reverse(ALL(A));
    ll ans = 0;

    rep(i, N){
        if(i==0) continue;
        ans += A.at(i/2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4796
#include<iostream>
#include<vector>
using namespace std;
int main ()
{
	int n,m,i;
	vector <int> s;
	vector <int> v;
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		s.push_back(n);
	}
	for(i=0;i<n;i++)
	{
		v.push_back(m);
	}
	if(s[0]>v[0])
	{
	for(i=0;i<v.size();i++)
	{
		std::cout<<v.at(i);
	}}
	if(s[0]<=v[0])
	{
	for(i=0;i<s.size();i++)
	{
		std::cout<<s.at(i);
	}}	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String S = sc.nextLine();
    int ans = 0;
    char a = S.charAt(0);
    
    for(int i = 1; i < S.length(); i++){
      if(a != S.charAt(i)){
        ans++;
        a = S.charAt(i);
      }
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 26316
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  int num, i;
  int *data;

  scanf("%d", &num);

  data = (int *)malloc(sizeof(int) * num);

  for (i = 0; i < num; i++) {
    scanf("%d", &data[i]);
  }

  for (i = num - 1; i >= 0; i--) {
    printf("%d", data[i]);
    
    if (i == 0)
      printf("\n");
    else
      printf(" ");
  }

  free(data);

  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
// Begin Header {{{
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
using namespace std;
using Graph = vector<vector<lli>>;
using P = pair<int, int>;
// }}} End Header

int main(){
	lli n, m, ans;
	cin >> n >> m;
	if(n == 1 || m == 1){
		if(n == m) ans = 1;
		else if(n == 2 || m == 2) ans = 0;
		else ans = max(n, m) -2;
	}else if(n == 2 || m == 2) ans = 0;
	else ans = (n-2)*(m-2);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n,p=map(int,input().split())
rem=[0]*n
cnt=[0]*p
s=input()[::-1]
if p==5:
    s=s[::-1]
    ans=0
    for i in range(n):
        if int(s[i])%5==0:
            ans+=i+1
    print(ans)
    exit()
if p==2:
    s=s[::-1]
    ans=0
    for i in range(n):
        if int(s[i])%2==0:
            ans+=i+1
    print(ans)
    exit()
kake=1
for i in range(n):
    rem[i]=rem[i-1]+int(s[i])*kake
    rem[i]%=p
    cnt[rem[i]]+=1
    kake*=10
    kake%=p
    
ans=0
for i in range(p):
    ans+=cnt[i]*(cnt[i]-1)//2
print(ans+cnt[0])

Measured memory_bytes: 45040
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>

int main(int argc, void **argv)
{
	long long n;
    long long x = 0;

	scanf("%lld", &n);

    if( n >= 10 )           x += 10 - 1;
    else                    x += n;
    
    if( n >= 1000 )         x += 1000 - 100;
    else if( n >= 100 )     x += n - 100 + 1;

    if( n >= 100000 )       x += 100000 - 10000;
    else if( n >= 10000 )   x += n - 10000 + 1;
    
    printf("%lld\n", x);

	return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll W[10][10];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	W[1][0]=W[0][1]=1;
	for(N=3;N<=10;N++) {
		vector<int> V;
		FOR(i,N-1) V.push_back(i);
		ll ma=0;
		do {
			if(V[0]>V.back()) continue;
			ll ret=0;
			FOR(i,N-2) ret+=W[V[i]][V[i+1]];
			ma=max(ma,ret);
		} while(next_permutation(ALL(V)));
		
		ma++;
		int cand[]={1,2,4,7,12,20,29,38,52,73};
		FOR(x,N-1) {
			W[N-1][x]=W[x][N-1]=ma*cand[x];
		}
	}
	
	cin>>N;
	vector<int> V;
	FOR(i,N) V.push_back(i);
	set<ll> C;
	
	do {
		if(V[0]>V.back()) continue;
		ll ret=0;
		FOR(i,N-1) ret+=W[V[i]][V[i+1]];
		assert(C.count(ret)==0);
		
	} while(next_permutation(ALL(V)));
	
	
	FOR(y,N) {
		FOR(x,N) cout<<W[y][x]<<" ";
		cout<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
S = str(input())
if S[0] == S[1] and S[1] != S[2] and S[2] == S[3]:
    print('Yes')
elif S[0] == S[2] and S[1] != S[2] and S[1] == S[3]:
    print('Yes')
elif S[0] == S[3] and S[3] != S[2] and S[1] == S[2]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
s = int(input())
s_list = []
def collatz(s):
    if s % 2 == 0:
        return int(s / 2)
    else:
        return int(3 * s + 1)
while s not in s_list:
    s_list.append(s)
    s = collatz(s)
    
print(len(s_list) + 1)

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

int main() {
  long long n,a,b,c,d,e;
  cin>>n;
  cin >>a>>b>>c>>d>>e;
  cout<<fixed<<setprecision(0)<<(n-1)/min(a,min(b,min(c,min(d,e))))+5<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <map>
#include <numeric>
typedef long long lld;
const int MAXN = 1e5+5;
int A[MAXN];
std::map<int,lld> cnt;

int main() {
    int M, N;
    scanf(" %d%d", &N, &M);
    for (int i = 0; i < N; ++i) {
        scanf("%d", &A[i]);
    }
    std::sort(A, A + N);
    for (int i = 0; i < M; ++i) {
        int B, C;
        scanf(" %d%d", &B, &C);
        cnt[C] += B;
    }
    int j = 0;
    while (!cnt.empty()) {
        auto itr = cnt.rbegin();
        int val = itr->first;
        int k = itr->second;
        for (int i = 0; (i < k) && (j < N); ++i, ++j) {
            if (A[j] >= val) {
                j = N;
                break;
            }
            A[j] = val;
        }
        if (j >= N) break;
        cnt.erase(val);
    }
    lld ret = std::accumulate(A, A + N, 0LL);
    printf("%lld\n", ret);
    return 0;
}


Measured memory_bytes: 6912
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << endl;
using LL=long long;
using VI=vector<int>;
using VL=vector<long long>;
using VS=vector<string>;
using VVI=vector<vector<int>>;
using PII=pair<int, int>;
const int inf = (int)1e9;
const LL mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

template <class T>void Sort(T & a) { sort(a.begin(), a.end()); }
template <class T>void ReSort(T& a) { sort(a.rbegin(), a.rend()); }
template <class T>void Reverse(T& a) { reverse(a.begin(), a.end()); }
template <class T>void Unique(T& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T>auto Max(T a) { return *max_element(a.begin(), a.end()); }
template <class T>auto Min(T a) { return *min_element(a.begin(), a.end()); }
template <class T, class U>int Count(T a, U c) { return count(a.begin(), a.end(), c); }
template <class T, class U>U Sum(T a, U init = 0) { return accumulate(a.begin(), a.end(), init); }

//INPUT//
void CINPUT() {}
template <class H, class ...T> void CINPUT(H&& h, T&& ...t) { cin >> h; CINPUT(forward<T>(t)...); }
#define Cin(T,...) T __VA_ARGS__; CINPUT(__VA_ARGS__);
#define VecIn(T,name,n) vector<T> name(n); for(auto &i:name)cin>>name[i];

//OUTPUT//
void print() { cout << endl; }
template <class H> void print(H&& h) { cout << h << endl; }
template <class H, class... T> void print(H&& h, T&& ... t) { cout << h << " "; print(forward<T>(t)...); }
template <class T>void out(T n) { cout << n << endl; }
template <class T>void out(vector<T> a, string sep = " ", string end = "\n") { for (int i = 0; i < (int)a.size(); ++i)cout << a[i] << (i == (int)a.size() - 1 ? end : sep); }
template <> void out(double a) { printf("%.20f\n", a); }
void yes(bool f) { puts(f ? "yes" : "no"); }
void Yes(bool f) { puts(f ? "Yes" : "No"); }
void YES(bool f) { puts(f ? "YES" : "NO"); }
void Yay(bool f) { puts(f ? "Yay!" : ":("); }
void poss(bool f) { puts(f ? "possible" : "impossible"); }
void Poss(bool f) { puts(f ? "Possible" : "Impossible"); }
void POSS(bool f) { puts(f ? "POSSIBLE" : "IMPOSSIBLE"); }

int main() {
	Cin(int, a, b, c, d);
	Yes(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  string s;
  cin >> n >> s;
  string ans = "Yes";
  if (n%2 == 1){
    ans = "No";
  }
  else{
    for (int i = 0; i < n/2; i++){
      if (s[i] != s[i+n/2]){
        ans = "No";
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b;

	scanf("%d %d", &a, &b);

	if (a == b)
		printf("Draw");
	else if (a == 1)
		printf("Alice");
	else if (b == 1)
		printf("Bob");
	else if (a > b)
		printf("Alice");
	else 
		printf("Bob");

	return 0;
}

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

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

	int n;
	cin >> n;
	map<string, ll> M;
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		ll cur = M[s];
		ans -= (cur * (cur - 1)) / 2;
		M[s] = cur + 1;
		ans += (cur * (cur + 1)) / 2;
	}
	cout << ans << '\n';
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int x,y,z,k;cin>>x>>y>>z>>k;
    vl a(x),b(y),c(z),d;
    rep(i,x)cin>>a[i];
    sort(all(a));
    rep(i,y)cin>>b[i];
    sort(all(b));
    rep(i,z)cin>>c[i];
    sort(all(c));
    rep(i,x)rep(j,y)d.PB(a[i]+b[j]);
    sort(all(d));
    ll r=3e10,l=0;
    while(r-l>1){
        ll m=(r+l)/2;
        int cnt=0;
        rep(i,d.size()){
            int count=c.end()-lower_bound(all(c),m-d[i]);
            cnt+=count;
        }
        if(cnt>=k)l=m;
        else r=m;
    }
    int cnt=0;
    rep(i,d.size()){
        int count=c.end()-lower_bound(all(c),r-d[i]);
        cnt+=count;
    }
    if(cnt>=k)l=r;
    vl ans;
    rep(i,d.size()){
        int s=lower_bound(all(c),l-d[i])-c.begin();
        for(int j=s;j<z;++j){
            ans.PB(d[i]+c[j]);
        }
    }
    sort(all(ans));
    reverse(all(ans));
    rep(i,k)cout<<ans[i]<<endl;
}

Measured memory_bytes: 141152
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int N;
  cin >> N;
  vector<vector<int>> A(N + 1, vector<int>(3));
  REP(i, N) REP(j, 3) cin >> A[i][j];
  vector<vector<ll>> DP(N + 1, vector<ll>(4, 0));

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (j == k) continue;
        chmax(DP[i + 1][k], DP[i][j] + A[i][k]);
      }
    }
  }
  ll res = 0;
  for (int j = 0; j < 3; j++) {
    chmax(res, DP[N][j]);
  }
  cout << res << endl;
}

Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
namespace Mylib{
    using namespace std;
    
    
}
int main(void){
    using namespace std;
    int N,K;
    cin >> N >> K;
    vector<double> vDouble;
    int tempInt;
    for(int i=0;i<N;i++){
        cin >> tempInt;
        tempInt++;//補正する
        vDouble.push_back(tempInt/2.0);
    }
    
    double MaxSum=0.0000000000;
    double Sum=0.0;
    queue<double> dQue;
    for(int i=0;i<N;i++){
        dQue.push(vDouble[i]);
        Sum+=dQue.back();
        
        if(dQue.size()>K){
            Sum-=dQue.front();
            dQue.pop();
        }
        if(dQue.size()==K){
            MaxSum=max(Sum,MaxSum);
        }

    }
    
    cout << fixed;
    cout << setprecision(12) << MaxSum << endl;
    
    return 0;
}

Measured memory_bytes: 3440
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());
	if (s < t)
		puts("Yes");
	else
		puts("No");
	return 0;
}

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

int main() {
    int n,ans = 1;
    cin >> n;
    for(int i = 1;;i++){
        if(n < 2)break;
        n /= 2;
        ans *= 2;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
N = int(input())

"""考え方
1.青色を第一要素（x）が小さい順にソートする
2.青色の点より左にある赤い点のうち、yが小さく、かつ一番大きい赤い点を選択する
"""

## 1.必要な配列を取得し、x軸でソートしておく
## 1-1.赤色
AB = []
for n in range(N):
  AB.append(list(map(int, input().split())))
  
AB = sorted(AB, key=lambda x: x[1], reverse=True)

## 1-2.青色
CD = []
for n in range(N):
  CD.append(list(map(int, input().split())))
CD = sorted(CD, key=lambda x: x[0], reverse=False)


## 2.青色の点について、左から順に取得していく
used_idx = []
ans = 0
for _ in CD:
  c = _[0]
  d = _[1]
  red_max_y = -1
  ## 左側にある赤色の要素を検索
  for idx, __ in enumerate(AB):
    a = __[0]
    b = __[1]
    if a < c:
      if b < d:
        if idx not in used_idx:
          used_idx.append(idx)
          ans += 1
          break
  
    
print(ans)

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


int main(){

  long long A;
  string _B;
  long long B;
    
  cin >> A >> _B;
  B = (_B.at(0) - '0') * 100 + (_B.at(2) - '0') * 10 + (_B.at(3) - '0');
  
  
  cout << A * B / 100 << endl;

}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// abc121d
ll f(ll a){
    if (a<=0) return 0;
    ll ans = 0;
    ll cnt = (a+1)/2;
    ll tmp = (a+1)%2;
    if (cnt%2){
        ans += 1;
        if (tmp%2){
            ans ^= a;
        }
    }else{
        if (tmp%2){
            ans ^= a;
        }
    }
    return ans;
}

int main(){
    ll a, b;
    cin >> a >> b;
    ll ans = f(b)^f(a-1);
    cout << ans << endl;
    return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acos(-1);

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int x, a, b;
	cin >> x >> a >> b;

	if(b <= a) cout << "delicious" << endl;
	else if(b <= (a + x)) cout << "safe" << endl;
	else cout << "dangerous" << endl;
	return 0;
}

Measured memory_bytes: 256
<?php  //?????§??? tamesi
while (true) {
    list($height, $width) = getInputExplodeBySpaces();
    
    if ($height == 0 && $width == 0) {
       break;
    }
        
    $chessBoardRectangle = new ChessBoardRectangle($height, $width);
    echo $chessBoardRectangle->makeChessBoardRectangle(), PHP_EOL;
}
 
function getInputExplodeBySpaces()
{
    return explode(' ', trim(fgets(STDIN)));
}
  
class Rectangle
{
    public $height;
    public $width;
    public $hashSymbol  = '#';
    
    public function __construct($height, $width)
    {
        $this->height = $height;
        $this->width  = $width;
    }

    public function setRectangleParts()
    {
        for ($i = 0; $i < $this->height; $i++) {
            for($j = 0; $j < $this->width; $j++) {
                $rectangleParts[$i][$j] = $this->hashSymbol;
            }
        }
        return $rectangleParts;
    }
    
    public function mergeRectangleParts($rectangleParts)
    {
        for ($i = 0; $i < $this->height; $i++) {
            $lines[] = implode($rectangleParts[$i]).PHP_EOL;
        }
        return implode($lines);
    }
}
 
class FrameRectangle extends Rectangle
{
    public $dotSymbol = '.';
    
    public function makeFrameRectangle()
    {
        $lines = $this->setRectangleParts();
        for ($i = 1; $i < $this->height - 1; $i++) {
            for($j = 1; $j < $this->width - 1; $j++) {
                $lines[$i][$j] = $this->dotSymbol; 
            }
        }
        
        return $this->mergeRectangleParts($lines);
    }
}

class ChessBoardRectangle extends FrameRectangle
{
    public function makeChessBoardRectangle()
    {
        $lines = $this->setRectangleParts();
        for ($i = 0; $i < $this->height; $i++) {
            for ($j = 0; $j < $this->width; $j++) {
                if ($j % 2 == 0 && $i % 2 ) {
                    $lines[$i][$j] = $this->dotSymbol;
                } elseif ($j % 2 && $i % 2 == 0) {
                    $lines[$i][$j] = $this->dotSymbol;
                }
            }
        }
        
        return $this->mergeRectangleParts($lines);
    }
}

Measured memory_bytes: 17916
#include <iostream>
#include <vector>
#include <string>

using namespace std;

string LCS;

void longestSubsequence(vector<vector <int> > &dp, string &lcs, int fLength, int sLenght, string &word)
{
    if (fLength == 0 || sLenght == 0)
        {
            cout << lcs;
            return;
        }

    int longestPathUp = dp[fLength - 1][sLenght];
    int longestPathLeft = dp[fLength][sLenght - 1];

    if (dp[fLength][sLenght] == longestPathUp)
        longestSubsequence(dp, lcs, fLength - 1, sLenght, word);
    else if (dp[fLength][sLenght] == longestPathLeft)
            longestSubsequence(dp, lcs, fLength, sLenght - 1, word);
        else
        {
            //cout << word[fLength - 1] << " ";
            lcs = word[fLength - 1] + lcs;
            longestSubsequence(dp, lcs, fLength - 1, sLenght - 1, word);
        }
}

int main()
{
    string firstString, secondString;

    cin >> firstString >> secondString;

    vector <vector <int>> dp(3005, vector<int>(3005, 0));

    int firstLength, secondLenght;

    firstLength = firstString.length();
    secondLenght = secondString.length();

    for (int i = 0; i < firstLength; i++)
        for (int j = 0; j < secondLenght; j++)
        {
            int chose1 = dp[i][j + 1];
            int chose2 = dp[i + 1][j];

            if (firstString[i] == secondString[j])
            {
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
            }
            else
            {
                if (chose1 > chose2)
                    dp[i + 1][j + 1] = max (chose1, dp[i + 1][j + 1]);
                else
                    dp[i + 1][j + 1] = max (chose2, dp[i + 1][j + 1]);
            }
        }

    longestSubsequence(dp, LCS, firstLength, secondLenght, firstString);

    return 0;
}


Measured memory_bytes: 36096
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define ARRAY_MAX 55
#define MOD 1000000007

int n,m;

int a[ARRAY_MAX],b[ARRAY_MAX];
bool area[ARRAY_MAX][ARRAY_MAX];
bool visited[ARRAY_MAX];


void dfs(int now){

    visited[now] = true;
    REP(i,n){

        if(area[now][i] == false){
            //隣接していない
            continue;
        }
        if(visited[i]){
            //既に行ったことがある
            continue;
        }
        dfs(i);
    }
}

int main(){

    cin >> n >> m;
    int ans = 0;
    REP(i,m){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;//配列の添え字に合わせる
        area[a[i]][b[i]] = area[b[i]][a[i]] = true;
    }

    REP(i,m){

        area[a[i]][b[i]] = area[b[i]][a[i]] = false;//隣接を切る

        REP(j,ARRAY_MAX){
            visited[j] = false;//全て行ってない
        }

        dfs(0);//0番目の都市から行けるかdfs、隣接を切っても全ていけるなら端ではない

        bool bridge = false;
        REP(j,n){
            if(visited[j] == false){
                //行けないので橋になっている
                bridge = true;
            }
        }
        if(bridge){
            ans++;
        }
        area[a[i]][b[i]] = area[b[i]][a[i]] = true;//隣接を戻す
    }
    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt
    if (N != 0) {
      val A = Array.fill[(Int, Int)](N)((sc.nextInt,
        sc.nextInt * 60 + sc.nextInt
          + sc.nextInt * 60 + sc.nextInt
          + sc.nextInt * 60 + sc.nextInt
          + sc.nextInt * 60 + sc.nextInt
      )).sortBy(_._2)
      println(A(0)._1)
      println(A(1)._1)
      println(A(A.size - 2)._1)
      solve(sc)
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    solve(sc)
  }
}

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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = (l);x<=(u);x++)
#define RREP(x,l,u) for(ll x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

ll A,B,ans;

void Work(){
	if(A==B)return void(puts("1"));
	int r=60;
	while((A>>r)==(B>>r))r--;
	A&=(1ll<<r+1)-1;
	B&=(1ll<<r+1)-1;
//	cout<<r<<endl;
	ll T=1ll<<r;
	ans=T-A;
//	cout<<ans<<endl;
	int r2=r-1;
	while(~r2&&!((B>>r2)&1))r2--;
//	cout<<r2<<endl;
	ll b1=(1ll<<r2+1)-1+T;
	ll a1=T;
	ll b2=T*2-1;
	ll a2=T+A;
//	cout<<a1<<' '<<b1<<endl;
	if(b1>=a2)ans+=b2-a1+1;
	else ans+=b2-a2+b1-a1+2;
	lout(ans);
}

void Init(){
	read(A,B);
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
N=input()

#1-indexed
bit=[ 0 for i in range(N+1) ]
bit[0]=None

#BIT
def add(x,w):
	while x<=N:
		bit[x]+=w
		x+=x&(-1*x)

def bitsum(x):
	s=0
	while 0<x:
		s+=bit[x]
		x-=x&(-1)*x
	return s

def search(wa):
	if wa<=0: return 0
	if bitsum(N)<wa: return N+1
	r=N
	l=0
	while r-l!=1:
		m=(l+r)/2
		if bitsum(m)<wa:
			l=m
		else:
			r=m	
	return r


#0-indexed
A=map(int, sys.stdin.readline().split())
#配列のAの数字の位置を1-indexedで格納。例 B[8]=1 は、Aで数字8が配列Aの1番目（1-indexed)にあることを示す
B=[ 0 for i in range(N+1) ]
for i,a in enumerate(A):
	B[a]=i+1

ans=0
#1番大きい数字はBITに追加するだけ
x=N
add(B[x],1)

#2番目に大きい数字から順番に、その数字が2番目に大きい数字として何回カウントされることがあるかをカウント
for x in range(N-1,0,-1):
	cur_p=B[x]	#current position
	cur_v=bitsum(cur_p)
	l1=search(cur_v)
	l2=search(cur_v-1)
	r1=search(cur_v+1)
	r2=search(cur_v+2)
	#print "l2,l1,r1,r2 :: ",l2,l1,r1,r2
	#print "ans+=( (",l1-l2,")*(",r1-cur_p,")+(",cur_p-l1,")*(",r2-r1,") )*",x
	#(左に自分より大きい数字がある場合＋右に自分より大きい数字がある場合)*自分の数字
	ans+=( (l1-l2)*(r1-cur_p)+(cur_p-l1)*(r2-r1) )*x
	#数字をBITに追加
	add(B[x],1)

print ans


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    vi d(n);
    rep(i, n) cin >> d[i];

    if (d[0] != 0) {
        cout << 0 << endl;
        return 0;
    }

    for (int i = 1; i < n; i++) if (d[i] == 0) {
        cout << 0 << endl;
        return 0;
    }

    ll mod = 998244353;
    ll ans = 1;

    vi m(n, 0);
    rep(i, n) {
        m[d[i]]++;
    }

    int xn = m[0];
    for (int i = 1; i < n; i++) {
        if (m[i] == 0) break;
        rep(j, m[i]) {
            ans *= m[i - 1];
            ans %= mod;
        }
        xn += m[i];
    }

    if (xn < n) {
        cout << 0 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
map<string,int> me;
string s[110];
int main()
{
	int n;cin>>n;
	rep(i,n){
		cin>>s[i];
		if(i>0){
			if(s[i-1][s[i-1].size()-1]!=s[i][0] || me[s[i]]>0){
				cout<<"No"<<endl;return 0;
			}
		}
		me[s[i]]++;
	}
	cout<<"Yes"<<endl;
}


Measured memory_bytes: 888
import java.io.{BufferedReader, InputStream, InputStreamReader}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}

object Main {
  val MOD = 1000000007
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val d = b - a
    val c = d * (d + 1) / 2
    val ans = c - b
    println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }
}


Measured memory_bytes: 25408
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
typedef pair<int, int> P;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
vector<P> A[16];

bool check(bitset<15> bs) {
  queue<int> que;
  bool searched[N];
  fill(searched, searched+N, false);
  rep(i, N) {
    if (searched[i]) continue;
    if (bs[i]) {
      que.push(i);
      while(!que.empty()) {
        int now = que.front(); que.pop();
        searched[now] = true;
        rep(j, A[now].size()) {
          P p = A[now][j];
          if (p.second) {
            int next = p.first;
            if (!bs[next]) return false;
            if (!searched[next]) que.push(next);
          } else {
            int next = p.first;
            if (bs[next]) return false;
          }
        }
      } 
    }
  }
  return true;
}

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

  cin >> N;
  int c;
  rep(i, N) {
    cin >> c;
    rep(j, c) {
      int a,b;
      cin >> a>> b;
      a--;
      A[i].push_back(make_pair(a,b));
    }
  }

  int ans = 0;
  rep(i, 1<<N) {
    bitset<15> bs(i);
    if (check(bs)) {
      int a = bs.count();
      ans = max(ans, a);
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long
const int N=(int)1e2+5,INF=(int)1e18+7;


	
void solve()
{
    int n,we;
    
    cin>>n>>we;
    int w[n+1],v[n+1];
    for(int i=1;i<=n;i++)cin>>w[i]>>v[i];
    int sum=0;
    for(int i=1;i<=n;i++)sum+=v[i];
   
    //dp[i] min weight can be achieved using exactly val i
    
    vector<int>dp(sum+1,INF);
    dp[0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int value=sum-v[i];value>=0;value--)
        {
            dp[value+v[i]]=min(dp[value+v[i]],dp[value]+w[i]);
        }
    }
    int ans=0;
    for(int i=0;i<=sum;i++)
    {
        if(dp[i]<=we)
        ans=max(ans,i);
    }
    
    
    cout<<ans<<'\n';
    
   
}

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
	int t=1;
	//cin>>t;
	while(t--)solve();
	    
   
}


Measured memory_bytes: 3968
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    

    int n; cin >> n;
    string s; cin >> s;
    int d; cin >> d;
    set<int> st;
    for(int i = 0; d > 0 && i < (int)s.size(); i++){
        if(s[i] == '0'){
            d--;
            s[i] = '1';
            st.insert(i);
        }
    }

    for(int i = (int)s.size() - 1; d > 0 && i >= 0; i--){
        if(s[i] == '1' && st.find(i) == st.end()){
            d--;
            s[i] = '0';
        }
    }
    
    cout << s << endl;
    
    return 0;
}




Measured memory_bytes: 3232
#include<iostream>
#include<iomanip>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<cmath>
using namespace std;
typedef vector<int> vi;
const int inf=1e9;
int n;
double ans;
double x[105];
double y[105];
double z[105];
double r[105];
double dis[105][105];
double mincost[105];
bool used[105];
double prim()
{
  for(int i=0;i<n;i++)
    {
      mincost[i]=inf;
      used[i]=false;
    }
  mincost[0]=0;
  double ret=0;
  while(true)
    {
      int v=-1;
      for(int u=0;u<n;u++)
	{
	  if(!used[u] && (v==-1 || mincost[u]<mincost[v])) v=u;
	}
      if(v==-1) break;
      used[v]=true;
      ret+=mincost[v];
      for(int u=0;u<n;u++)
	{
	  mincost[u]=min(mincost[u],dis[v][u]);
	}
    }
  return ret;
}

int main()
{
  while(cin >> n &&n)
    {
      memset(dis,inf,sizeof(dis));
      for(int i=0;i<n;i++)
	{
	  cin >> x[i] >> y[i] >> z[i] >> r[i];
	}
      for(int i=0;i<n;i++)
	{
	  for(int j=0;j<n;j++)
	    {
	      if(i!=j)
		{
		  dis[i][j]=max(0.0,sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2)+pow(z[i]-z[j],2))-r[i]-r[j]);
		}
	    }
	}
      ans=prim();
      if(ans<1e-9)
	{
	  cout << fixed << setprecision(3) << 0.000 << endl;
	}
      else
	{
	  cout << fixed << setprecision(3) << ans << endl;
	}
    }
}



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

// DP テーブル (配列全体が false に自然に初期化される)
bool dp[110000]; // 局面数は最大 100001 だが少し余裕もたせる

int main() {
    // 入力受け取り
    int N, K; cin >> N >> K;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    // DP
    for (int i = 1; i <= K; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i - a[j] >= 0) dp[i] |= !dp[i - a[j]];
        }
    }

    // 答え
    if (dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;
}

Measured memory_bytes: 3700
S = input()

if len(S) % 2 != 0:
    print("No")
    exit()

if len(S) == 2 and S == "hi":
    print("Yes")
    exit()
elif len(S) == 4 and S == "hihi":
    print("Yes")
    exit()
elif len(S) == 6 and S == "hihihi":
    print("Yes")
    exit()
elif len(S) == 8 and S == "hihihihi":
    print("Yes")
    exit()
elif len(S) == 10 and S == "hihihihihi":
    print("Yes")
    exit()

print("No")

Measured memory_bytes: 3064
from math import factorial
from collections import defaultdict


def cmb(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))


N = int(input())
A = list(map(int, input().split()))

dA = defaultdict(int)
for i in A:
    dA[i] += 1

sm = 0

for i in dA.values():
    if i >= 2:
        sm += cmb(i, 2)
    else:
        sm += 0

for j in A:
    print(sm - (dA[j] - 1))

Measured memory_bytes: 114636
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

//UnionFindのライブラリを重み付きに改変

struct UnionFind {
  vi par, count;
  vll diff_weight;

  UnionFind(int N) : par(N), count(N, 1), diff_weight(N, 0LL){
    for(int i = 0; i < N; i++) par.at(i) = i;
  }

  int root(int x){
    if(par.at(x) == x) return x;
    int r = root(par.at(x));
    diff_weight.at(x) += diff_weight.at(par.at(x));
    return par.at(x) = r;
  }

  ll weight(int x){
    root(x);
    return diff_weight.at(x);
  }

  int unite(int x, int y){
    if(root(x) == root(y)) return 0;
    if(size(x) < size(y)){
      count.at(root(y)) += count.at(root(x));
      par.at(root(x)) = root(y);
    }
    else{
      count.at(root(x)) += count.at(root(y));
      par.at(root(y)) = root(x);
    }
    return 1;
  }

  int unite(int x, int y, ll w){
    if(root(x) == root(y)) return 0;
    w += weight(x); w -= weight(y);
    int rx = root(x); int ry = root(y);
    if(size(x) < size(y)){
      w = -w;
      count.at(root(y)) += count.at(root(x));
      par.at(root(x)) = root(y);
      diff_weight.at(rx) = w;
    }
    else{
      count.at(root(x)) += count.at(root(y));
      par.at(root(y)) = root(x);
      diff_weight.at(ry) = w;
    }
    return 1;
  }

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

  int size(int x){
    return count.at(root(x));
  }

  ll diff(int x, int y){
    if(!same(x, y)) return INT_INF;
    return weight(y) - weight(x);
  }
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M;
  cin >> N >> M;
  UnionFind uf(100010);
  for(int i = 0; i < M; i++){
    ll L, R, D;
    cin >> L >> R >> D;
    L--; R--;
    if(!uf.same(L, R)) uf.unite(L, R, D);
    else if(uf.diff(L, R) != D){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000


int main()
{
    unsigned short *A, *B;

    int C[VMAX + 1];
    int n, i, j;
    scanf("%d", &n);

    A = malloc(sizeof(short) * n + 1);
    B = malloc(sizeof(short) * n + 1);

    for( i = 0; i <= VMAX; i++) C[i] = 0;

    for( i = 0; i < n; i++){
        scanf("%hu", &A[ i + 1 ]);
        C[A[ i + 1 ]]++;
    }

    for( i = 1; i <= VMAX; i++) C[i] += C[ i - 1 ];

    for( j = n; j > 0; j--){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }

    for( i = 1; i <= n ; i++){
        if( i > 1 ) printf(" ");
        printf("%d", B[i]);
    }

    printf("\n");
    return 0;
}



Measured memory_bytes: 9712
void main()
{
    long[] tmp = rdRow;
    long n = tmp[0], k = tmp[1];

    long result;
    if (k)
    {
        foreach (i; k+1 .. n+1)
        {
            long d = n / i;
            long cnt = (i - k) * d;
            long rem = n - i * d;
            cnt += max(0, rem-k+1);
            result += cnt;
        }
    }
    else result = n ^^ 2;

    result.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define ALL(x) begin(x), end(x)
using namespace std;

int main() {
    // input
    int n; scanf("%d", &n);
    vector<int> a(n); REP (i, n) scanf("%d", &a[i]);

    // solve
    int sum_a = accumulate(ALL(a), 0);
    bitset<2000 * 2000 + 1> dp = {};
    dp[0] = 1;
    for (int a_i : a) {
        dp |= dp << a_i;
    }
    int j = (sum_a + 1) / 2;
    while (not dp[j]) ++ j;

    // output
    printf("%d\n", j);
    return 0;
}


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

def main():
    #入力
    [n, k] = [int(i) for i in input().split()] 
    h = [int(i) for i in input().split()] 

    print(len(able_ride_jet(k, h)))


def able_ride_jet(const, heights):
    """ ジェットコースターに乗れる人の身長のリストを返す関数
    """
    return list(filter(lambda x: x >= const, heights))


if __name__ == '__main__':
    main()

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

#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define sc(a) scanf("%c",&a)
#define ss(a) scanf("%s",a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pc(a) putchar(a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i, a, b) for(register int i=a;i<=b;++i)
#define repd(i, a, b) for(register int i=a;i>=b;--i)
#define reps(s) for(register int i=head[s];i;i=Next[i])
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pii pair<int,int>
#define mii unordered_map<int,int>
#define msi unordered_map<string,int>
#define lowbit(x) ((x)&(-(x)))
#define ce(i, r) i==r?'\n':' '
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;

inline int qr() {
    int f = 0, fu = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')fu = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        f = (f << 3) + (f << 1) + c - 48;
        c = getchar();
    }
    return f * fu;
}

int n;

long long Max[10];
long long Min[10];

int main() {

    n = qr();
    for (int i = 0; i < 10; i++)
        Max[i] = -1e15, Min[i] = 1e15;
    long long x, y;
    for (int i = 0; i < n; i++) {
        x = qr(), y = qr();
        Max[0] = max(Max[0], x + y);
        Max[1] = max(Max[1], -x + y);
        Max[2] = max(Max[2], x - y);
        Max[3] = max(Max[3], -x - y);
        Min[0] = min(Min[0], x + y);
        Min[1] = min(Min[1], -x + y);
        Min[2] = min(Min[2], x - y);
        Min[3] = min(Min[3], -x - y);
    }
    long long ans = 0;
    for (int i = 0; i < 4; i++)
        ans = max(Max[i] - Min[i], ans);
    pl(ans);
    return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
bool cmp(int a,int b)
{
  return (a%10)>(b%10);
}
int main()
{
  vector<int> v;
  int ans=0;
  for(int i=0;i<5;i++)
  {
    int h;
    cin>>h;
    if(h%10==0)
      ans+=h;
    else
      v.push_back(h);
  }
  sort(v.begin(),v.end(),cmp);
  for(auto i:v)
    ans += (i+10) - (i%10);
  if(v.size()>0)
  {ans-=(v.back()+10)-(v.back()%10); ans+=v.back();}
  cout<<ans<<"\n";
  return 0; 
}


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

from fractions import gcd

def lcm(x, y):
  return (x * y) // gcd(x, y)

def main():
  a, b, c, d = map(int, input().strip().split())
  a -= 1
  x = (b - a) - ((b//c - a//c) + (b//d - a//d) - (b//lcm(c, d) - a//lcm(c, d)))
  print(x)

if __name__=='__main__':
  main()



Measured memory_bytes: 5304