akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
import sys
from math import factorial
from collections import Counter, defaultdict

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def comb(n, r):  # 組み合わせ
    if n <= 0 or r > n: return 0
    return factorial(n) // factorial(n - r) // factorial(r)

N = ir()
A = lr()
counter = Counter(A)
case = 0
dic = defaultdict(int)
for k, v in counter.items():
    dic[k] = v
    case += comb(v, 2)

for a in A:
    num = dic[a]
    answer = case - (num - 1)
    print(answer)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 18) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(S == T) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inp_ll;

const int MAXN = 200010;
const int MAXK = 20;

int n;
int a[MAXN];
int s[MAXK][MAXN];

int main()
{
	
	n = inp();
	for (int i = 1; i <= n; ++ i)
	{
		a[i] = inp();
		for (int k = 0; k < MAXK; ++ k)
			s[k][i] = s[k][i-1]+(a[i]>>k&1);
	}
	ll ans = 0;
	for (int i = 1; i <= n; ++ i)
	{
		int j = n;
		for (int k = 0; k < MAXK; ++ k)
		{
			j = min((long int)j, upper_bound(s[k]+1, s[k]+n+1, s[k][i-1]+1)-s[k]-1);
		}
		ans += j-i+1;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 17024
import bisect
N = int(input())
A = list()
for i in range(N):
  A.append(int(input()))
L = list()
for j in range(N-1, -1, -1):
  n = A[j]
  if(len(L) == 0):
    L.append(n)
  elif(L[-1] <= n):
    L.append(n)
  else:
    x = bisect.bisect_right(L, n)
    L[x] = n
print(len(L))

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


int main()
{
  int a,b;
  cin>>a>>b;
  if(a!=1&&b!=1){
    cout<<1<<endl;
  }else if(a!=2&&b!=2)
    cout<<2<<endl;
  else
    cout<<3<<endl;
  
}



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

long long mod = 1e9 + 7;
long long N, K;
long long ans = 1;
vector<vector<long long>> es(1e5, vector<long long>());
vector<long long> g(1e5 + 10, 0);
vector<bool> visited(1e5 + 1 + 10, false);
vector<long long> gs(1e5 + 1 + 10, 0);

void rec(long long v, long long bf)
{
    visited.at(v) = true;
    gs.at(v)++;
    gs.at(bf)++;

    // long long q = (mod + ans - 1) / ans;
    // long long x = K - gs.at(bf);
    // long long buf = 0;
    // while (q < x)
    // {
    //     buf += (ans * q) % mod;
    //     buf %= mod;
    //     x -= q;
    // }
    // if (x > 0)
    // {
    //     buf += (ans * x) % mod;
    //     buf %= mod;
    // }
    // ans = buf;

    ans = ans * (K - gs.at(bf)) % mod;
    for (long long nv : es.at(v))
    {
        if (visited.at(nv) == false)
        {
            rec(nv, v);
        }
    }
}

int main()
{
    cin >> N >> K;
    for (long long i = 0; i < N - 1; i++)
    {
        long long a, b;
        cin >> a >> b;
        a--;
        b--;
        es.at(a).push_back(b);
        g.at(a)++;
        es.at(b).push_back(a);
        g.at(b)++;
    }
    gs.at(0) = -1;
    gs.at(N) = -1;
    rec(0, N);
    cout << ans << endl;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const ll mod=1e+9+7;
int main(void){
    int n;cin>>n;
    map<pair<ll,ll>,int> mp;
    int zero=0;
    rep(i,n){
        ll a,b;cin>>a>>b;
        if(a==0&&b==0){
            zero++;
            continue;
        }
        ll g=gcd(a,b);//片方が0だともう片方の絶対値が出てくる
        a/=g;b/=g;
        /*if(b<0||(b==0&&a<0)){
            b*=-1;a*=-1;//第3象限と第4象限の座標をそれぞれ第1象限と第2象限にまとめる
        }*/
        mp[{a,b}]++;
    }
    vector<ll> s(2*n+1,1);
    rep(i,n*2){
        s[i+1]=s[i]*2;
        s[i+1]%=mod;
    }
    ll res=1;
    for(auto& p:mp){
        ll a=p.first.first,b=p.first.second;
        int x=p.second,y=mp[{-a,-b}],z=mp[{-b,a}],t=mp[{b,-a}];
        if(x==-1)continue;//すでに見られている
        ll tmp=1;
        tmp+=s[x+y]-1;tmp%=mod;
        tmp+=s[z+t]-1;tmp%=mod;
        res*=tmp;res%=mod;
        mp[{-b,a}]=-1;mp[{-a,-b}]=-1;mp[{a,b}]=-1;mp[{b,-a}]=-1;
        //cout<<a<<" "<<b<<" "<<x<<" "<<t<<" "<<res<<endl;
    }
    res+=zero;
    res=(res+mod-1)%mod;
    cout<<res<<endl;
}

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

using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a[5];
    for (int i = 0; i < 5; i++) cin >> a[i];
    for (int i = 0; i < 5; i++) {
        if (a[i] == 0) {
            cout << i + 1 << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3500
/**
*	created: 15.08.2020 20:59:07
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
using P = pair<int,int>;
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string s; cin >> s;
    if (s == "RRR") cout << 3 << endl;
    else if (s == "RRS" || s == "SRR") cout << 2 << endl;
    else if (s == "SSS") cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3656
import numpy as np

n, m = [int(i) for i in input().split()]

connected_1 = {}

for i in range(m):
    a, b = [int(i) for i in input().split()]
    
    if a == 1:
        if connected_1.get(b) is None:
            connected_1[b] = 1
        elif connected_1[b] ==1:
            print("POSSIBLE")
            break
        
        
    if b == n:
        if connected_1.get(a) is None:
            connected_1[a] = 1
        elif connected_1[a] ==1:
            print("POSSIBLE")
            break
        
       
        
    if i==m-1:
        print("IMPOSSIBLE")

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

#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 ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

ll mod_pow(ll x, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  ll n, k;
  cin >> n >> k;
  mint ans = 1;
  combination c(n + 5);
  FOR(i, 1, min(k + 1, n)) { ans += c(n, n - i) * c(n - 1, i); }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int) (v).size()

#define rep(i,a,b) for(int (i) = (a); (i) < (b); ++(i))
#define trav(a, x) for(auto& a : x)

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define shandom_ruffle random_shuffle
#define funoredered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using funordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

constexpr int INF = 0x3f3f3f3f;
constexpr int NINF = 0xc0c0c0c0;
constexpr double EPS = 1e-8;
constexpr ll MOD = 1000000007LL;

template <typename T>
using ordered_set = 
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll modPow( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

inline int cmp_double( double x, double y, double tol = EPS) {
    return (x <= y + tol) ? ( x + tol < y) ? -1 : 0 : 1;
}

constexpr int ms = 3003;

double dp[ms][ms];

int main()
{
	ios::sync_with_stdio(0); cin.tie(NULL);
    int n;
    cin >> n;
    vector< double > p(n);
    for(auto& x : p) cin >> x;

    dp[0][0] = (1.0 - p[0] );
    dp[0][1] = p[0];

    for(int i = 1; i < n; ++i) {
        for(int C = 0; C < ms; ++C) {
            if(C == 0) dp[i][C] = dp[i - 1][C] * (1 - p[i] );
            else dp[i][C] = (dp[i - 1][C] * (1 - p[i]) + dp[i - 1][C - 1] * p[i] );
        }
    }

    double ACC = 0;
    for(int C = n / 2 + 1; C <= n; ++C) ACC += dp[n - 1][C];
    printf("%.10lf\n", ACC);
    return 0;
}



Measured memory_bytes: 70656
#include <iostream>
#include <algorithm>
#include <queue>

#define rep(i,n) for (int i=0; i < (n); ++i)
using ll = long long ;
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;

int main() {

    int n ;
    cin >> n ;

    int f[n],l[n] ;

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

    for(int i=0;i<(n-2);i++){
            if((f[i]==l[i]) && (f[i+1]==l[i+1]) &&
              (f[i+2]==l[i+2])){
                  cout << "Yes" << endl ;
                  return 0 ;
              }
    }

    cout << "No" << endl ;
    return 0 ;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long lli;
lli n;
vector<pair<lli,lli> > x;
vector<lli> ans;
int taboo(){
    cout << "No" << endl;
    return 0;
}
int main(){
    cin >> n;
    x = vector<pair<lli,lli> > (n);
    ans = vector<lli> (n*n);
    for(lli i = 0;i < n;i++){
        cin >> x[i].first;
        x[i].first--;
        x[i].second = i+1;
    }
    sort(x.begin(),x.end());
    lli e = 0;
    for(lli i = 0;i < n;i++){
        ans[x[i].first] = x[i].second;
        for(lli j = 1;j < x[i].second;j++){
            while(e < n*n && ans[e])e++;
            if(e > x[i].first) return taboo();
            ans[e] = x[i].second;
        }
    }
    reverse(x.begin(),x.end());
    e = n*n-1;
    for(lli i = 0;i < n;i++){
        for(lli j = n - x[i].second;j > 0;j--){
            while(e >= 0 && ans[e]) e--;
            if(e < x[i].first) return taboo();
            ans[e] = x[i].second;
        }
    }
    cout << "Yes" << endl;
    for(lli i = 0;i < n*n-1;i++){
        cout << ans[i] << " ";
    }
    cout << ans[n*n-1] << endl;

    return 0;
}

Measured memory_bytes: 3072
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();
        int F[][]=new int[N][10];
        int P[][]=new int[N][11];
        int result[]=new int[N];
        int ans=-(1<<30),tmp=0;
        Arrays.fill(result,0);
        for(int i=0;i<N;i++){
            for(int j=0;j<10;j++){
                F[i][j]=sc.nextInt();
            }
        }
        for(int i=0;i<N;i++){
            for(int j=0;j<11;j++){
                P[i][j]=sc.nextInt();
            }
        }
        for(int i=1;i<(1<<10);i++){
            int c=0;
            for(int j=0;j<N;j++){
                int cc=0;
                for(int k=0;k<10;k++){
                    if(((i>>k)&1)==1&&F[j][k]==1){
                        cc++;
                    }
                }
                c+=P[j][cc];
            }
            ans=Math.max(ans, c);
        }
        System.out.println(ans);
    }
}

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

namespace keyence2020_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var h = int.Parse(Console.ReadLine());
            var w = int.Parse(Console.ReadLine());
            var n = int.Parse(Console.ReadLine());
            var m = Math.Max(h, w);
            Console.WriteLine(n % m == 0 ? n / m : n / m + 1);
        }
    }
}


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

using namespace std;
#define Rep(i,a,b) for (int i=a;i<b;i++)
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define maxn 100005
pair<int,int> s[maxn];int n;
int mnr[maxn];
int calc(int l,int r){
	if (l<=r)return r-l+1;else return 0;
}
int main(){
	scanf("%d",&n);
	rep(i,1,n){
		int l,r;scanf("%d%d",&l,&r);
		s[i]=make_pair(l,r);
	}
	sort(s+1,s+n+1);
	int mxl=s[n].first;
	mnr[n]=s[n].second;
	for (int i=n-1;i>=1;i--)
		mnr[i]=min(mnr[i+1],s[i].second);
	int mn=1e9+7,mx=0;
	int res=0;
	Rep(i,1,n){
		mn=min(mn,s[i].second);mx=max(mx,s[i].second);
		int l=mxl,r=mnr[i+1];
		if (l>r)res=max(res,mx-s[i].first+1);
		else {
			res=max(res,calc(l,r)+calc(s[i].first,mn));
			if (i!=1)res=max(res,calc(l,min(mn,r))+calc(s[i].first,mx));
		}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 1408
a = [input().split() for l in range(2)]
n = int(a[0][0])
count=0
for i in range(n-2):
    p1=int(a[1][i])
    p2=int(a[1][i+1])
    p3=int(a[1][i+2])
    p=[p1,p2,p3]
    p.sort()
    if p.index(p2)==1:
        count=count+1

print(count)


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

using namespace std;

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

	string s;
	cin >> s;
	string st;
	int n = s.size();
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		st.push_back(s[i]);
		while (st.size() >= 2) {
			if ((st[st.size() - 1] == '1' && st[st.size() - 2] == '0') || (st[st.size() - 1] == '0' && st[st.size() - 2] == '1')) {
				for (int i = 0; i < 2; i++) {
					st.pop_back();
					cnt++;
				}
				continue;
			}		
			break;
		}
	}
	cout << cnt << '\n';
	
	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include<queue>
using namespace std;
#define ALL(v) (v).begin(), (v).end()
#define mod 1000000007;
#define ll long long;

bool color[200000];
vector<pair<int,int>> g[200000];

void dfs(int u, int d){
    for(auto v:g[u]){
        if(v.first != d){
            if(v.second&1) color[v.first] = 1 - color[u];
			else color[v.first] = color[u];
			dfs(v.first,u);
        }
    }
}

int main(){
    int n; cin >> n;
    for(int i=0;i<n-1;i++){
        int u,v,w;
        cin >> u >> v >> w;
        g[u].push_back({v,w});
		g[v].push_back({u,w});
    }
    dfs(1,0);
    for(int i=1;i<=n;i++) cout << color[i] << endl;
    return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#include <atcoder/dsu>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int,int> P;
bool checkL[100005];

int main()
{
	int N,M;
	cin >> N >> M;
	dsu d(N);
	rep(i,M)
	{
		int a,b;
		cin >> a >> b;
		a--; b--;
		d.merge(a,b);
	}
	int ans = 0;
	rep(i,N)
	{
		int temp = d.leader(i);
		if (!checkL[temp])
		{
			ans++;
			checkL[temp] = true;
		}
	}
	cout << ans-1 << endl;
	return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll calc(ll x){
  if(x <= 0) return 0;
  x++;
  ll res = 0;
  for(int i = 0; i < 50; i++){
    long long loop = (1LL << (i + 1));
    long long cnt = (x / loop) * (loop / 2);
    cnt += max(0LL, (x % loop) - (loop / 2));
    
    if(cnt % 2 == 1){
      res += 1LL << i;
    } 
  }
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b;
  cin>>a>>b;
  ll ans = calc(b) ^ calc(a-1);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
input_num = gets.to_i
nums = gets.split(' ').map { |num| num.to_i }

flag = true

input_num.times do |i|
  if nums[i] % 2 == 0 
    if nums[i] % 3 == 0 || nums[i] % 5 == 0
      flag = true
    else
      flag = false
      break
    end
  end
end

if flag
  puts 'APPROVED'
else
  puts 'DENIED'
end


Measured memory_bytes: 1788
function SumArray(H){
  var sum=0;
  for(var i=0 ; i<H.length ; i++){
    sum += H[i];
  }
  return sum;
}
function Main(input){
  //パラメータ受取り
  input = input.split("\n");
  inputStr = input[0].split(" ");
  const N = Number.parseInt(inputStr[0]);
  const K = Number.parseInt(inputStr[1]);
  inputStr = input[1].split(" ");
  //引数の筒配列
  const V = inputStr.map(inputStr => Number.parseInt(inputStr));
  var ans=0;

  if(K>1 && N>1){
    //K回処理する全探索
    //左から宝石を抜くループ
    for(var i=0 ; i<=K ; i++ ){
      //右から宝石を抜くループ
      for(var j=0 ; j<=K-i ; j++){
        //安全装置
        if(i+j>V.length){ break;}

        //変数の初期化
        var H = [];
        //左からi個宝石を抜く
        H = H.concat(V.slice(0,i));
        
        //右からj個宝石を抜く。slice特性上0を除外する。
        if(j>0){ H = H.concat(V.slice(j*-1)); }
        //事前にマイナス値が前に来るようソートする
        H.sort(function(a,b){
        		if( a < b ) return -1;
        		if( a > b ) return 1;
        		return 0;
		});
        //console.log(H);
        
        //console.log(H,SumArray(H));
        
        //手持ちの意思からマイナス値をK-(i+j)個戻す
        for(var r=0 ; r<K-(i+j) ; r++){
          if( H[0]<0 ){
            H.shift();
          }  
        }
        ans = Math.max(ans,SumArray(H));
      }
    }
  } else {
    //
    ans = Math.max(ans,V[0],V[V.length-1]);
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9844
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define ISIN(x, y, w, h) (x >= 0 && x < w && y >= 0 && y < h)

#define f first
#define s second

using namespace std;

pair<int, int> joint[70];
int h, w, c;
int p[8][8];
bool f[8][8];

const int dx[4] = { 1,-1, 0, 0 };
const int dy[4] = { 0, 0, 1, -1};

int getInt(){ int r; scanf("%d", &r); return r; }

int solve(int now, int prev, int cnt){
  int ret = 0;

  //printf("solve(%d, %d, %d)\n", now, prev, cnt);

  if(now == 6) return cnt;

  for(int col = 1; col <= 6; col++){
    int cc = cnt;
    queue<pair<int, int> > q;

    if(now == 5 && col != c) continue;
    if(now == 0 && col != prev) continue;

    REP(i, cnt) q.push(joint[i]);

    while(q.size()){
      int x = q.front().s;
      int y = q.front().f;

      q.pop();

      REP(i, 4){
	int xx = x + dx[i];
	int yy = y + dy[i];

	if(ISIN(xx, yy, w, h) && p[yy][xx] == col && !f[yy][xx]){
	  f[yy][xx] = true;
	  joint[cc].f = yy;
	  joint[cc].s = xx;
	  q.push(joint[cc++]);
	}
      }
    }

    ret = max(ret, solve(now + 1, col, cc));
    
    for(int i = cnt; i < cc; i++){
      int x = joint[i].s;
      int y = joint[i].f;
      
      f[y][x] = false;
    }
  }

  return ret;
}

int main(){
  while(true){
    h = getInt();
    w = getInt();
    c = getInt();

    if(h + w + c == 0) break;

    REP(i, h) REP(j, w) p[i][j] = getInt();
    f[0][0] = true;

    printf("%d\n", solve(0, p[0][0], 1));
  }
  return 0;
}

Measured memory_bytes: 920
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;
using System.Text;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            return (consoleReader.Int + consoleReader.Int + 1) / 2;
        }

        #region いつもの
#pragma warning disable
        private ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
    }
    public class ConsoleReader
    {
        private string[] ReadLineSplit() => textReader.ReadLine().Split(Array.Empty<char>(), StringSplitOptions.RemoveEmptyEntries);
        private string[] line = Array.Empty<string>();
        private int linePosition;
        private TextReader textReader;
        public ConsoleReader(TextReader tr) { textReader = tr; }
        public int Int => int.Parse(String);
        public long Long => long.Parse(String);
        public double Double => double.Parse(String);
        public string String
        {
            get
            {
                if (linePosition >= line.Length)
                {
                    linePosition = 0;
                    line = ReadLineSplit();
                }
                return line[linePosition++];
            }
        }
        public class SplitLine
        {
            private string[] splited;
            public SplitLine(ConsoleReader cr) { splited = cr.ReadLineSplit(); cr.line = Array.Empty<string>(); }
            public int[] Int => String.Select(x => int.Parse(x)).ToArray();
            public int[] Int0 => String.Select(x => int.Parse(x) - 1).ToArray();
            public long[] Long => String.Select(x => long.Parse(x)).ToArray();
            public double[] Double => String.Select(x => double.Parse(x)).ToArray();
            public string[] String => splited;
        }
        public SplitLine Split => new SplitLine(this);
        public class RepeatReader : IEnumerable<ConsoleReader>
        {
            ConsoleReader cr; int count;
            public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; }
            public IEnumerator<ConsoleReader> GetEnumerator() => Enumerable.Repeat(cr, count).GetEnumerator();
            System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator();

            public IEnumerable<string> String => this.Select(cr => cr.String);
            public IEnumerable<int> Int => this.Select(cr => cr.Int);
            public IEnumerable<int> Int0 => this.Select(cr => cr.Int - 1);
            public IEnumerable<long> Long => this.Select(cr => cr.Long);
            public IEnumerable<double> Double => this.Select(cr => cr.Double);
        }
        public RepeatReader Repeat(int count) => new RepeatReader(this, count);
    }
    #endregion
}

Measured memory_bytes: 11220
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;

map<string,bool> ng;
char c[4] = {'A','G','T','C'};

void check(int n,string now){
	if(n == 4){
		if(now.substr(0,3) == "AGC" || now.substr(1,3) == "AGC"){
			ng[now] = true;
			return;
		}

		swap(now[0],now[1]);
		if(now.substr(0,3) == "AGC" || now.substr(1,3) == "AGC"){
			swap(now[0],now[1]);
			ng[now] = true;
			return;
		}
		swap(now[0],now[1]);

		swap(now[1],now[2]);
		if(now.substr(0,3) == "AGC" || now.substr(1,3) == "AGC"){
			swap(now[1],now[2]);
			ng[now] = true;
			return;
		}
		swap(now[1],now[2]);

		swap(now[2],now[3]);
		if(now.substr(0,3) == "AGC" || now.substr(1,3) == "AGC"){
			swap(now[2],now[3]);
			ng[now] = true;
			return;
		}
		return;
	}
	for(int i = 0;i < 4;i++){
		check(n+1,now+c[i]);
	}
}

int main(){
	int n;
	cin >> n;
	//直近1-4個分の情報を配列に持って走る.
	ng["AGC"] = true;
	ng["ACG"] = true;
	ng["GAC"] = true;
	string emp = "";
	check(0,emp);
	vector<pair<string,ll>> now;
	emp = "";
	now.push_back(make_pair(emp,1LL));
	for(int i = 0;i < n;i++){
		map<string,ll> next;
		while(now.size()){
			auto now_pair = now.back();
			string now_string = now_pair.first;
			ll now_count = now_pair.second;
			now.pop_back();
			for(int i = 0;i < 4;i++){
				string next_string;
				if(now_string.size() <= 3)next_string = now_string + c[i];
				else next_string = now_string.substr(1,3) + c[i];
				if(!ng[next_string]){
					next[next_string] += now_count;
					next[next_string] %= MOD;
				}
			}
		}
		for(auto p:next){
			now.push_back(make_pair(p.first,p.second));
		}
	}

	ll ans = 0;
	for(int i = 0;i < now.size();i++){
		ans += now[i].second;
		ans %= MOD;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		int  H1=sc.nextInt();
		int  M1=sc.nextInt();
		int  H2=sc.nextInt();
		int  M2=sc.nextInt();
		int  K=sc.nextInt();
		int ans=0;

		int A=H2*60+M2;
		int B=H1*60+M1;

		ans=A-B-K;

		System.out.println(ans);



		sc.close();

	}

}


Measured memory_bytes: 35720
from itertools import combinations
import numpy as np

n, d = map(int, input().split())
x = np.array([list(map(int, input().split())) for _ in range(n)], dtype="i2")

ans = 0
for y, z in combinations(x, 2):
    d = np.linalg.norm(y - z)
    if int(d) == d:
        ans += 1

print(ans)


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

//int main(){
    //A
    /*
    vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin>>K;
    cout<<a[K-1]<<endl;
    */
   //B
   /*
   long long H,W;
   cin>>H>>W;
   if(H==1||W==1) cout<<1<<endl;
   else cout<<(H*W+1)/2<<endl;
   */
   //C
   /*
   long long a,b,c; //int型は2*10^9くらいの値まで
   cin>>a>>b>>c;
   long long d = c-a-b;
   if(d>0&&d*d>4*a*b) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   */
   //D dfsのリターンについて・・・1度のdfs関数への代入で複数のreturnが起こる？
   int n;
   void dfs(string s,char end){
       if(s.size()==n){
           cout<<s<<endl;
           return ;
       }
       for(char i='a';i<=end;i++){
           char nxt = end;
           if(i==end) nxt++;
           dfs(s+i,nxt);
       }
   }
  // }
//return 0;
//}
    int main(){
        cin>>n;
        dfs("",'a');
        return 0;
    }

Measured memory_bytes: 1536
import java.io.*;

public class Main {

  static long n, ans;
  static String s;
  static int[] rgb = new int[3];

  static char[] c = {'R', 'G', 'B'};

  public static void main(String[] args) throws Exception {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] in = br.readLine().split(" ");
    n = Long.parseLong(in[0]);
    s = br.readLine();

    br.close();

    ans = n * (n-1) * (n-2) / 6;
    long sub = 0;
    long add = 0;

    for(int i = 0; i < n; i++){
      for(int j = 1; j < n; j++){
        if(i + 2*j >= n) break;
        
        ans--;
      }
    }

    for(int i = 0; i < n; i++){
      if(s.charAt(i) == 'R') rgb[0]++;
      if(s.charAt(i) == 'G') rgb[1]++;
      if(s.charAt(i) == 'B') rgb[2]++;
    }

    for(int i = 0; i < n-1; i++){
      for(int j = i+1; j < n; j++){
        if(s.charAt(i) != s.charAt(j)) continue;

        char now = s.charAt(i);
        
        int idx = 0;
        if(now == 'G') idx = 1;
        if(now == 'B') idx = 2;

        ans -= n-2;
        sub += (rgb[idx] - 2);
        
        if(2*i - j >= 0){
          if(s.charAt(2*i-j) == now)
            add++;
          else
            ans++;
        }
        if(2*j - i < n){
          if(s.charAt(2*j-i) == now)
            add++;
          else
            ans++;
        }
        if((j - i) % 2 == 0){
          if(s.charAt(i + (j-i)/2) == now)
            add++;
          else
            ans++;
        }
      }
    }

    System.out.println(ans + 2 * sub / 3 + add/3);

  }
}

Measured memory_bytes: 34408
#include <bits/stdc++.h>
    using namespace std;
    int main()
    {
       for (int i=0;i<10;i++)
    {
    char a;
    cin>>a;
    if (i==3)
    {
    cout<<'8';
    }
    else
    {
    cout<<a;
    }
    }
    }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int digitSum(int num) {
    int ret = 0;
    while (num > 0) {
        ret += num % 10;
        num /= 10;
    }
    return ret;
}
int main() {
    int N;
    cin >> N;
    int ans = N;
    for (int A = 1; A < N; A++) {
        int B = N - A;
        int t = digitSum(A) + digitSum(B);
        if (t < ans) ans = t;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
x = int(input())
count = 0
if x >= 500:
  count += (x // 500) * 1000
  t = x % 500
  count += (t // 5) * 5
  print(count)
elif x < 500 and x >= 5:
  count += (x // 5) * 5
  print(count)
else:
  print(0)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[][] s = new String[3][3];

        for (int i = 0; i < 3; i++) {
            String ss = sc.next();
            for (int j = 0; j < 3; j++) {
                s[i][j] = String.valueOf(ss.charAt(j));
            }
        }
        System.out.print(s[0][0] + s[1][1] + s[2][2]);
    }
}


Measured memory_bytes: 23124
import java.util.*;
import java.io.*;
class Main{
	public static void main(String[]args){
		Scanner in=new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out, true);
		int temp = in.nextInt();
		if(temp >= 30)
			out.println("Yes");
		else
			out.println("No");
	}
}


Measured memory_bytes: 35748
#include<stdio.h>


int main(void)
 {
     int a, b;
     scanf("%d %d", &a, &b);
     if(a < b) {
         printf("a < b\n");
     } else {if(a == b) {
         printf("a == b\n");
     }
     else {printf("a > b\n");
     }
     }
     return 0;
     }
         
         

Measured memory_bytes: 580
#include <stdio.h>
#include <queue>
#include <vector>

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

char str[10];
std::vector<std::queue<int>> Edge;
std::vector<bool> A;

int main(void){
    int n, m; scanf("%d%d", &n, &m);
    Edge.resize(n);
    REP(i, m){
        int x, y; scanf("%d%d%s", &x, &y, str); x--; y--;
        Edge[x].push(y);
        Edge[y].push(x);
    }

    A.resize(n, true);
    int res = 0;
    REP(i, n) if(A[i]){
        std::queue<int> V;
        V.push(i); A[i] = false;
        while(not V.empty()){
            int v = V.front(); V.pop();
            while(not Edge[v].empty()){
                int nv = Edge[v].front(); Edge[v].pop();
                if(A[nv]){
                    A[nv] = false; V.push(nv);
                }
            }
        }
        res++;
    }
    printf("%d\n", res);

    return 0;
}

Measured memory_bytes: 409984
#include<iostream>
using namespace std;
long long n,m,ans;
long long u[100001],v[100001];
long long f[100001],a[100001];
long long k[100001];
long long find(long long x)
{
    if(f[x]==x)return x;
    return f[x]=find(f[x]);
}
int main()
{
    cin>>n>>m;
    for(long long i=1;i<=n;i++)f[i]=i,k[i]=1;
    ans=(n-1)*n/2;
    for(long long i=1;i<=m;i++)
    {
        cin>>u[i]>>v[i];
    }
    for(long long i=m;i>=1;i--)
    {
        a[i]=ans;
        if(find(u[i])==find(v[i]))continue; 
        ans-=k[find(u[i])]*k[find(v[i])];
        long long s=k[find(u[i])]+k[find(v[i])];
        k[find(u[i])]=s;
        k[find(v[i])]=s;
        f[find(u[i])]=f[find(v[i])];
    }
    for(long long i=1;i<=m;i++)
    {
        cout<<a[i]<<endl;
    }
}

Measured memory_bytes: 5248
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<complex>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
const int mod=1000000007;
int n,m;
int s,t;
int box[100005],las[400005],edv[400005],edw[400005],cnt=0;
void adde(int u,int v,int w)
{
	las[++cnt]=box[u];
	box[u]=cnt;
	edv[cnt]=v;
	edw[cnt]=w;
}
long long dis1[100005],cnt1[100005],dis2[100005],cnt2[100005],diss[100005];
bool vis[100005];
queue<int>q;
int id[100005];
void spfa(int s,long long* dis,long long* cnt)
{
	memset(dis,23,8*n+8);
	memset(vis,0,sizeof(vis));
	dis[s]=0;
	q.push(s);
	while(!q.empty())
	{
		int now=q.front();
		vis[now]=0;
		q.pop();
		for(int i=box[now];i;i=las[i])
		{
			int v=edv[i];
			if(dis[v]>dis[now]+edw[i])
			{
				dis[v]=dis[now]+edw[i];
				if(!vis[v])
				{
					vis[v]=1;
					q.push(v);
				}
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		id[i]=i;
		diss[i]=dis[i];
	}
	sort(id+1,id+1+n,([](int a,int b){return diss[a]<diss[b];}));
	cnt[s]=1;
	for(int j=1;j<=n;j++)
		for(int i=box[id[j]];i;i=las[i])
			if(dis[edv[i]]==dis[id[j]]+edw[i])
				cnt[edv[i]]=(cnt[edv[i]]+cnt[id[j]])%mod;
}
int main()
{
	read(n);
	read(m);
	read(s);
	read(t);
	int a,b,c;
	for(int i=0;i<m;i++)
	{
		read(a);
		read(b);
		read(c);
		adde(a,b,c);
		adde(b,a,c);
	}
	spfa(s,dis1,cnt1);//cout<<"EM"<<endl;
//	for(int i=1;i<=n;i++)	cout<<i<<' '<<cnt1[i]<<endl;
	spfa(t,dis2,cnt2);
	long long gg=dis1[t];
	long long ans=(cnt1[t]*cnt1[t])%mod;//cout<<ans<<endl;
	for(int i=1;i<=n;i++)
	{
		if(dis1[i]==dis2[i] && dis1[i]+dis2[i]==gg)
			ans=(ans-((cnt1[i]*cnt2[i])%mod)*((cnt1[i]*cnt2[i])%mod))%mod;
		for(int j=box[i];j;j=las[j])
		{
			int v=edv[j];//cout<<dis1[i]<<' '<<dis2[v]<<' '<<edw[j]<<endl;
			if(dis1[i]+dis2[v]+edw[j]==gg && 2*dis1[i]<gg && 2*dis2[v]<gg)
				ans=(ans-((cnt1[i]*cnt2[v])%mod)*((cnt1[i]*cnt2[v])%mod))%mod;
		}
	}
	ans=(ans+mod)%mod;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define rep(loop, N) for (int loop = 0; loop < N; loop++)

struct Node {
	Node* parent = NULL;
	vector<Node*> child;
	long long value = 0;
};
struct Edge {
	int parent = 0;
	int child = 0;
	bool operator <(const Edge& right) const { return parent < right.parent; }
};
struct Tree {
	vector<Node> node;
	Tree(int, vector<Edge>);
};
Tree::Tree(int nodeNum, vector<Edge> edge) {
	node.resize(nodeNum);
	for (Edge& it : edge) {
		node[it.child].parent = &node[it.parent];
		node[it.parent].child.push_back(&node[it.child]);
	}
}

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}
long long gcd(long long num1, long long num2) {
	return num2 == 0 ? num1 : gcd(num2, num1 % num2);
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	long long m_module = 1000000007;
	vector<struct Memo> memo;
public:
	long long calculate(int, int);
	Combination1(int, long long);
};
long long Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, long long module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Sheep_and_Wolves(void) {

	int S, W; cin >> S >> W;

	cout << (S <= W ? "unsafe" : "safe") << endl;
	return;
}

int main(void) {

	cout << fixed << setprecision(15);

	A_Sheep_and_Wolves();
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; ++i)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define P pair<int, int>

P check(int a, int b){
  if(b == 0) return P(a, 0);
  else{
    P tmp = check(b, a % b);
    tmp.second += 1;
    return tmp;
  }
}

int main() {
  int a, b;
  while(cin >>a >>b && a){
    if(a < b) swap(a, b);
    P ans = check(a, b);
    cout <<ans.first <<" " <<ans.second <<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define forn(i,n) for(int i = 0; i < (int) n; ++i)
#define ios ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

int main() {
  int l,r,d;
  cin >> l >> r >> d;

  int cnt = 0;
  for(int i=l;i<=r;i++) if (i%d == 0) cnt++;
  cout << cnt << "\n";
}


Measured memory_bytes: 3636
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 2e5 + 5;
const int M = 5e5 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;

int n,k,a[N];

void init() {}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k;

    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }

    for (int i = k+1; i <= n; ++i) {
        cout << (a[i]>a[i-k] ? "Yes" : "No") << '\n';
    }

    return 0;
}

Measured memory_bytes: 4432
s = input()
lens = len(s)
# パーとグーを置換すると、その前後でスコアは変わらない
# ggの時,pgとgpの点数はともに1
# gpの時,pgとgpの点数はともに0 って感じ
#ので、パーをばらけさせても後ろに固めても回数が同じなら結果は同じ -> AtcoDeerくんがパーを出せる回数 - TopcoDeerくんがパーを出した回数が答え
numpar = lens // 2
toppar = 0
for i in range(lens):
    if s[i] == "p":
        toppar += 1
print(str(numpar - toppar))

Measured memory_bytes: 39280
#include<algorithm>
#include<iostream>
#define rep(i,a) for(int i=0;i<(a);++i)

int n;

int main()
{
	while( std::cin >> n, n )
	{
		int ma = 0, mi = 1001, S = 0;
	
		rep( i, n )
		{
			int a;
			std::cin >> a;
			ma = std::max( ma, a );
			mi = std::min( mi, a );
			S += a;		
		}
		
		std::cout << (S-ma-mi)/(n-2) << std::endl;
	}

	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
long long INF = 1e18;
const int mod = 1e9 + 7;

using namespace std;

#define MAX_N 50
int par[MAX_N+1]; //親
int rnk[MAX_N+1]; //木の深さ

//n要素で初期化
void init(int n){
  REP(i,n+1){
    par[i] = i;
    rnk[i] = 0;
  }
}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

//xとyの属する集合を併合
void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x == y) return;

  if(rnk[x] < rnk[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rnk[x] == rnk[y]) ++rnk[x];
  }
}

//xとyが同じ集合に属するか
bool same(int x, int y){
  return find(x) == find(y);
}

int main(){
  int n,m,ans=0;

  scanf("%d%d",&n,&m);
  vector<pair<int,int>> ab(m);
  init(n);
  REP(i,m) scanf("%d%d",&ab[i].first,&ab[i].second);

  REP(i,m){
    init(n);
    REP(j,m){
      if(i==j)continue;
      unite(ab[j].first,ab[j].second);
    }
    if(!same(ab[i].first,ab[i].second)) ++ans;
  }

  printf("%d\n",ans);
  return 0;
}


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

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

    vector<uint64_t> a(n);
    int sum = 0;
    for (auto i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    int count = 0;

    if(sum < x) count--;
    sort(a.begin(), a.end());
    for (auto i = 0; i < n; i++) {
        if(x >= a[i]) {
            x -= a[i];
            count++;
        }
        else break;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
const double eps=1e-7;
int n; double x,y;
struct cmp {
	bool operator () (double a,double b) {
		return a-b>eps;
	}
};
priority_queue<double,vector<double>,cmp> q;
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	while (n--) {
		read(x); q.push(x);
	}
	while (q.size()>1) {
		x=q.top(); q.pop();
		y=q.top(); q.pop();
		q.push((x+y)*0.5);
	}
	printf("%.6lf\n",q.top());
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())


kcd=0
kcd_half=0
for i in range(1,n+1):
    if k&1 and i%k==0:
        kcd+=1
    elif not k&1:
        if i%k==0:
            kcd+=1
        if i%k==k//2:
            kcd_half+=1

print(kcd*kcd*kcd+kcd_half*kcd_half*kcd_half)


Measured memory_bytes: 9120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

using ll = long long;
using my_tree = __gnu_pbds::tree<pair<ll, int>, __gnu_pbds::null_type, less<pair<ll, int>>, __gnu_pbds::rb_tree_tag,
    __gnu_pbds::tree_order_statistics_node_update>;

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n);
    for(auto& x : v) cin >> x;
    for(auto& x : v) x -= k;

    v.insert(begin(v), 0);

    partial_sum(begin(v), end(v), begin(v));

    my_tree t;

    ll rez = 0;

    int tmp = 0;
    for(const auto x : v){
        rez += t.order_of_key(make_pair(x, 1e9));
        t.insert(make_pair(x, tmp++)); }
    cout << rez << '\n';
    return 0; }


Measured memory_bytes: 15844
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

template<class In>
void print_array(In begin, In end) {
  cout << (*begin);
  begin++;
  for (; begin != end; begin++)
  {
    cout << " " << (*begin);
  }
  cout << endl;
}

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

  vector<ll> arr(N);
  for (auto i = 0; i < N; i++) cin >> arr[i];

  for (auto i = 0; i < N; i++) {
    ll v = arr[i];
    auto j = i - 1;
    for (; j >= 0 && v < arr[j]; j--)
    {
      arr[j + 1] = arr[j];
    }
    arr[j+1] = v;

    // print
    print_array(arr.begin(), arr.end());
  }

  return 0;
}



Measured memory_bytes: 3068
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		String[] s = new String[2];
		Arrays.fill(s, "");
		for(int i=0;i<b;i++) {
			s[0]+=a;
		}
		
		for(int i=0;i<a;i++) {
			s[1]+=b;
		}
		
		Arrays.sort(s);
		
		System.out.println(s[0]);

	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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


int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if(a + b >= k) cout << min(a, k) << endl;
    else cout << a - (k - a - b) << endl;

}


Measured memory_bytes: 3636