akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

vector<int> e[1010];
int n, m;

int fr[200010];
int to[200010];
char gyaku[200010];

bitset<1001> reach[1001], todo;
queue<int> q;

void F(int x){
	todo.reset();
	auto& v = e[x];
	int s = v.size();
	for(int i=0; i<s; ++i){
		int y = to[v[i]];
		if(todo[y]){
			gyaku[v[i]] = 1;
		} else {
			q.push(y);
			todo[y]=1;
			while(q.size()){
				int a=q.front(); q.pop();
				for(int ei:e[a]){
					int b=to[ei];
					if(b == x || todo[b]) continue;
					todo[b]=1; q.push(b);
				}
			}
		}
	}
	reach[x] = todo;
	todo.reset();
	for(int i=s-1; 0<=i; --i){
		int y = to[v[i]];
		if(todo[y]){
			gyaku[v[i]] = 1;
		} else {
			q.push(y);
			todo[y]=1;
			while(q.size()){
				int a=q.front(); q.pop();
				for(int ei:e[a]){
					int b=to[ei];
					if(b == x || todo[b]) continue;
					todo[b]=1; q.push(b);
				}
			}
		}
	}
}

int main()
{
	read(n, m);
	for(int i=1; i<=m; ++i){
		int a, b; read(a, b);
		fr[i] = a; to[i] = b;
		e[a].pb(i);
	}
	for(int i=1; i<=n; ++i) F(i);
	
	for(int i=1; i<=m; ++i){
		if(gyaku[i] != reach[to[i]][fr[i]]){
			puts("diff");
		} else {
			puts("same");
		}
	}
	return 0;
}


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

int main() {
    int N; cin >> N;
    vector <string> data(N);
    for(int i = 0; i < N; i++){
        string tmp; cin >> tmp;
        data[i] = tmp;
    }
    sort(data.begin(), data.end());

    string tmp2 = data[0];
    int ans = 1;
    for(int i = 1; i < N; i++){
        string tmp3 = data[i];
        if(tmp2 != tmp3){
            ans ++;
        }
        tmp2 = tmp3;
    }

    cout << ans << endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) max_element(x.begin(),x.end())
#define MIN(x) min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
//cout << std::fixed << std::setprecision(15);
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
signed main(){
    int n,k; cin >> n >> k;
    vint h(n); rep(i,n) cin >> h[i];
    sort(all(h));
    int res=0;
    rep(i,n-k) res+=h[i];
    cout<<res<<endl;
}

Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}
fn main() {
    let a: u32 =  read();
    let p: u32 =  read();

    println!("{}" , (a*3+p)/2);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define PI atan(1)*4
typedef long long int ll;
using namespace std;
char s[15];
char t[15]; 
int main()
{
	io;
	cin >> s >> t;
	int l = strlen(s);
	for(int i = 0;i < l;++i){
		if(s[i] != t[i]){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef double db;

void file_put() {
    freopen("filename.in", "r", stdin);
    freopen("filename.out", "w", stdout);
}

const int N=2e5+5;
stack <int> S; char s[N]; int n,ans=0;

int main() {
//	file_put();
	
	scanf("%s",s),n=strlen(s);
	rep(i,0,n) if (s[i]=='S') S.push(1); else if (!S.empty() && S.top()==1) S.pop(),ans+=2; else S.push(0);
	printf("%d\n",n-ans); 
	
	return 0;
}



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

int main(){
  int a[3], b[3];
  for (int i = 0; i < 3; i++)
  {
    cin >> a[i] >> b[i];
  }
  int c[4];
  for (int i = 0; i < 4; i++)
  {
    c[i] = 0;
  }
  for (int i = 0; i < 3; i++)
  {
    c[a[i]-1]++;
    c[b[i]-1]++;
  }
  for (int i = 0; i < 4; i++)
  {
    if (3 <= c[i])
    {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


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

int main(){
    int m, nmin, nmax;
    while(cin >> m >> nmin >> nmax, m && nmin && nmax){
        vector<int> p(m);
        rep(i, 0, m) cin >> p[i];
        int MAX = -1;
        int ans = -1;
        rep(i, nmin, nmax + 1){
            int tmp = p[i - 1] - p[i];
            if(tmp >= MAX){
                MAX = tmp;
                ans = i;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    class BIT{
            ll n;
      		vector<ll> bitree;
        public:
        	BIT(unsigned long _n) : bitree(_n + 1, 0){
              n = _n;
            }
        	void add(ll id, ll x){
              while(id <= n){
                bitree[id] += x;
                id += id & -id;
              }
              return;
            }
        	ll sum(ll id){
              ll temp = 0;
              while(id > 0){
                temp += bitree[id];
                id -= id & -id;
              }
              return temp;
            }
      };
    cin>>N>>M;
    vec l(N), r(N), ord(N);
    rep(i,N) cin>>l[i]>>r[i], ord[i] = i;
    BIT bit(M + 10);
    rep(i,N){
        bit.add(l[i], 1);
        bit.add(r[i] + 1, -1);
    }
    sort(ALL(ord), [&](int x, int y){
        return r[x] - l[x] > r[y] - l[y];
    });
    ord.push_back(0);
    vec ans(M);
    int buy = 0; //確定で購入
    Rreps(m, M + 1, 1){
        int id = ord[buy];
        while(buy != N && r[id] - l[id] >= m){
            bit.add(l[id], -1);
            bit.add(r[id] + 1, 1);
            ++buy;
            id = ord[buy];
        }
        //buy以外は、BITでの重複カウントはされない
        ans[m - 1] = buy;
        for(int j = m; j <= M; j += m) ans[m - 1] += bit.sum(j);
    }
    rep(i,M) cout<<ans[i]<<endl;
}

Measured memory_bytes: 12032
#include <iostream>
#include <vector>

using namespace std;

int main(void){
  int n, r, p, c;
  vector<int> v, buf1, buf2;

  while(cin >> n >> r, n || r){
    v.clear();
    for(int i=1; i<=n; i++){
      v.push_back(i);
    }

    for(int i=0; i<r; i++){
      cin >> p >> c;

      buf1.clear();  buf2.clear();
      for(int j=0; j<v.size(); j++){
        if(j < n-p-(c-1) || n-p < j){
          buf1.push_back(v[j]);
        } else {
          buf2.push_back(v[j]);
        }
      }

      v.clear();
      for(int j=0; j<buf1.size(); j++){
        v.push_back(buf1[j]);
      }
      for(int j=0; j<buf2.size(); j++){
        v.push_back(buf2[j]);
      }
    }

    cout << v[v.size()-1] << endl;
  }

  return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
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; }

vvint to(101010);
vint dist;
int n;

void dfs(int u,int d = 0,int p = -1){
  dist[u] = d;
  for(auto v2:to[u]){
    if(v2 == p) continue;
    dfs(v2,d+1,u);
  }
}
vint distcalc(int a){
  dist = vector<int>(n);
  dfs(a);
  return dist;
}
signed main(){
  cin >> n;
  rep(i,0,n-1){
    int a,b;
    cin >> a >> b;
    a--;b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  vint distu = distcalc(0);
  vint distv = distcalc(n-1);
  int up = 0;
  int down = 0;
  rep(i,0,n){
    if(distu[i] <= distv[i]){
      up++;
    }
    else down++;
  }
  if(down < up) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
}

Measured memory_bytes: 12800
use std::io;

fn get_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    return buf;
}

fn main() {
    // NとAを読む
    let _n = get_line();
    let mut a: Vec<i32> = get_line()
                        .split_whitespace()
                        .map(|x| {x.parse().unwrap()})
                        .collect();
    a.sort();
    a.reverse();

    let mut alice = 0;
    let mut bob = 0;

    for (i,e) in a.into_iter().enumerate(){
        if i%2 == 0 {
            alice += e;
        } else {
            bob += e;
        }
    }

    println!("{}", alice-bob);
}

Measured memory_bytes: 4352
n=int(input())
a=list(map(int,input().split()))

#所持金1000

flag=0
start=a[0]
b=[]

for i in range(1,n):
    #print(a[i],start)
    if flag==0:
        if start>a[i]:
            start=a[i]
        elif start<a[i]:
            end=a[i]
            flag=1
    if flag==1:
        if end<=a[i]:
            end=a[i]
            if i==n-1:
                b.append([start,end])
        elif end>a[i]:
            b.append([start,end])
            start=a[i]
            flag=0

saifu=1000
#print(b)
for (s,e) in b:
    saifu=saifu+(e-s)*(saifu//s)
    #print(saifu)

print(saifu)

        


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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

vector<string> s;
int k;
signed main()
{
    cin >> k;

    vector<string> tmp1;
    FOR(i, 1, 10){
        tmp1.push_back(to_string(i));
        s.push_back(to_string(i));
    }

    while(s.size() <= k){
        vector<string> tmp2;
        REP(i, tmp1.size()){
            string t = tmp1[i];
            REP(i, 3){
                int tail = (int)(t.back() - '0') + i - 1;
                if (!(0 <= tail && tail <= 9)) continue;
                tmp2.push_back(t + to_string(tail));
            }
        }
        s.insert(s.end(), ALL(tmp2));
        swap(tmp1, tmp2);
    }

    // REP(i, s.size()){
    //     cout << s[i] << endl;
    // }
    cout << s[k-1] << endl;
    return 0;
}

Measured memory_bytes: 13120
$n=<>;$l{$_}++for glob<>;$k=1;
for(keys%l){
    $f=1,last if($n%2==$_%2);
    $f=1,last if($_<1&&$l{$_}!=1);
    $f=1,last if($_>0&&$l{$_}!=2);
    next if!$_;
    $k=$k*2%(1e9+7);
}
print$f?0:$k

Measured memory_bytes: 25728
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int A[1001];
    int num;
    for(int i=0;i<1001;i++){
        A[i] = 0;
    }
    
    cin >>num;
    
    for(int i=0;i<num;i++){
        scanf("%d",&A[i]);
    }
    void insertionSort(int* A,int N);
    insertionSort(A,num);
    
    return 0;
}

void insertionSort(int* A,int N){
    int key,j;
    
    for(int k=0;k<N-1;k++){
        cout <<A[k] <<" ";
    }
    cout <<A[N-1];
    cout <<endl;
    
    for(int i=1;i<N;i++){
        key = A[i];
        j = i -1;
        while(j >= 0 && A[j] > key){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = key;
        
        for(int k=0;k<N-1;k++){
            cout <<A[k] <<" ";
        }
        cout <<A[N-1];
        cout <<endl;
    }
}

Measured memory_bytes: 1248
n = int(input())
print(0)
st = input()
if st == "Vacant":
    exit()
print(n - 1)
en = input()
if en == "Vacant":
    exit()
l = 1
r = n - 1

while True:
    mid = (l + r) // 2
    print(mid)
    ask = input()
    if ask == "Vacant":
        exit()
    if (mid - l) & 1:
        if st == ask:
            l = mid + 1
            st = ask
        else:
            r = mid
            en = ask
    else:
        if st == ask:
            r = mid
            en = ask
        else:
            l = mid + 1
            st = ask


Measured memory_bytes: 9164
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			final long a = scn.nextLong();
			final long b = scn.nextLong();

			System.out.println(a / gcd(a, b) * b);
		}
	}

	static long gcd(long a, long b) {
		if (a == 0) {
			return b;
		} else if (b == 0) {
			return a;
		}

		final long m = Math.max(a, b);
		final long n = Math.min(a, b);
		return gcd(n, m % n);
	}
}


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

int N;
int ans = 100000;

int sumofdigits(int n) {
    int s = 0;
    while (n > 0) {
        s += n % 10;
        n /= 10;
    }
    return s;
}


int main() {
    cin >> N;
    
    for (int A = 2; A <= N / 2 + 1; A++) {
        int B = N - A;
        int sa = sumofdigits(A);
        int sb = sumofdigits(B);
        if (sa + sb < ans) ans = sa + sb;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (ll r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
#define mp(a, b) make_pair(a, b)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, count=0;
    cin>>n;
    vector<int>A(n), B(n);
    rep(i,0,n)cin>>A[i];
    rep(i,0,n)cin>>B[i];
    rep(i,0,n){
		if(A[i]<B[i]){
			break;	
		}else if(A[i]>B[i]){
					do{
				if(A!=B){
					count++;
				}else{
					cout<<count<<"\n";
					return 0;
				}
			}while(next_permutation(B.begin(), B.end()));
		}
	}
	do{
		if(A!=B){
			count++;
		}else{
			cout<<count<<"\n";
			return 0;
		}
	}while(next_permutation(A.begin(), A.end()));
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int gcd(int a, int b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  int n, m;
  cin >> n >> m;
  int ans = 1;
  for(int i = 1; i * i <= m; i++) {
    if(m % i == 0) {
      if(i <= m / n) ans = max(ans, i);
      if(i >= n) ans = max(ans, m / i);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
typedef long long ll;
using namespace std;
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 R, C, K;
vector<vector<ll>> item;
vector<vector<vector<ll>>> dp;

 
int main(){
    cin >> R >> C >> K;
    item.resize(R);
    dp.resize(R);
    for(size_t i=0; i<R; i++){
        item[i].resize(C);
        dp[i].resize(C);
        for(size_t j=0; j<C; j++){
            item[i][j]=0;
            dp[i][j].resize(4);
            for(size_t k=0; k<4; k++){
                dp[i][j][k] = -1;
            }
        }
    }
    
 
    for(int i=0; i<K; i++){
        int x, y, v;
        cin >> x >> y >> v;
        item[x-1][y-1] = v;
    }
    
    ll ans = 0;
    dp[0][0][0] = 0;
    
    for(int i=0; i<R; i++){
        for(int j=0; j<C; j++){
            for(int k=2; k>=0; k--){
                if (dp[i][j][k] >= 0) {
                    chmax(dp[i][j][k+1], dp[i][j][k]+item[i][j]);
                }
            }
            for(int k=0; k<4; k++){
                if (dp[i][j][k] >= 0) {
                    if (i+1<R) {
                        chmax(dp[i+1][j][0], dp[i][j][k]);
                    }
                    if (j+1<C) {
                        chmax(dp[i][j+1][k], dp[i][j][k]);
                    }
                }
            }
        }
    }
    for(int k=0; k<4; k++){
        chmax(ans, dp[R-1][C-1][k]);        
    }

    cout << ans << endl;
}

Measured memory_bytes: 707340
#include <functional>
#include <string>
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
#include <type_traits>
namespace loquat {
template <int MOD>
class modulus_integer {
public:
	typedef modulus_integer<MOD> self_type;
private:
	int m_value;
	static self_type unsafe_construct(int x) noexcept {
		self_type y;
		y.m_value = x;
		return y;
	}
public:
	modulus_integer() noexcept
		: m_value(0)
	{ }
	modulus_integer(int x) noexcept
		: m_value(x % MOD)
	{
		if(m_value < 0){ m_value += MOD; }
	}
	int operator*() const noexcept { return m_value; }
	self_type& operator=(const self_type& x) noexcept {
		m_value = x.m_value;
		return *this;
	}
	self_type operator+(const self_type& x) const noexcept {
		const int y = m_value + x.m_value;
		return unsafe_construct(y >= MOD ? y - MOD : y);
	}
	self_type operator*(const self_type& x) const noexcept {
		return unsafe_construct(
			static_cast<long long>(m_value) * x.m_value % MOD);
	}
	self_type& operator+=(const self_type& x) noexcept {
		return (*this = *this + x);
	}
};
template <int MOD>
inline std::ostream& operator<<(
	std::ostream& os, const modulus_integer<MOD>& x)
{
	os << *x;
	return os;
}
}
using namespace std;
static const int MOD = 1000000007;
using mint = loquat::modulus_integer<MOD>;
static mint dp[201][100001];
int main(){
	ios_base::sync_with_stdio(false);
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	sort(a.begin(), a.end(), greater<int>());
	dp[0][x] = 1;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j <= x; ++j){
			dp[i + 1][j % a[i]] += dp[i][j];
			if(i + 1 != n){
				dp[i + 1][j] += dp[i][j] * (n - i - 1);
			}
		}
	}
	mint answer = 0;
	for(int j = 0; j <= x; ++j){
		answer += mint(j) * dp[n][j];
	}
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 78720
#include <bits/stdc++.h>
using namespace std;
//#define DEBUG
#ifdef DEBUG
#define dump(x) cout << "[*] " #x ": " << x << endl
#define debug(x) x
#else
#define dump(x)
#define debug(x)
#endif

typedef long long ll;
//#define int long long
#define stepn(i, s, e, n) decltype(e) i = (s); i < (e); i += (n)
#define step(i, s, e) decltype(e) i = (s); i < (e); ++i
#define range(i, n) step(i, 0, n)
constexpr int INF = 1e9;

decltype(1) main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (range(i, n)) {
        cin >> h[i];
    }

    int base = 0;
    for (range(i, n)) {
        dump(base);
        dump(i);
        dump(h[i]);
        if (base == h[i] - 1 || base == h[i]) {
            dump(1);
            continue;
        } else if (base < h[i]) {
            dump(2);
            base = h[i] - 1;
        } else {
            dump(3);
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;
int main() {
	int N,D=0;//N:行,D:列
	int i, j;
	int mini = 0;
	int X[20][20] = {};
	int count = 0;//整数カウント
	int sum = 0;//和
	int sumpow = 0;//和の二条
	double heihou = 0;//和の平方根
	cin >> N >> D;
	for (i = 0; i < N; ++i) {
		for (j = 0; j < D; ++j) {
			cin>>X[i][j];
		}
	}
	while (mini < N) {
		for (i = mini + 1; i < N; ++i) {
			for (j = 0; j < D; ++j) {
				sum = X[mini][j] - X[i][j];
				sumpow += sum * sum;
			}
		//	cout << "sumpow=" << sumpow << endl;
			heihou = sqrt(sumpow);
			//cout << "heihou" << heihou << endl;
			if (floor(heihou) == heihou) {
				++count;
			}
			//cout << "count" << count << endl;
			sumpow = 0;

		}
		++mini;
	}
	
	
	cout << count << endl;







}


Measured memory_bytes: 256
#include <iostream>
#include <unistd.h>
#include <cmath>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int n,m;
vector<vector<int> >G;
vector<vector<int> >invG;
vector<int>memo;

int search(int v){
    if(invG[v].size() == 0){
        memo[v] = 0;
    }else{
        rep(i, invG[v].size()){
            if(memo[invG[v][i]] != -1){
                memo[v] = max(memo[v], memo[invG[v][i]] + 1);
                continue;
            }  
            memo[v] = max(memo[v], search(invG[v][i]) + 1);
        }
    }
    return memo[v];
}

int main(){
    cin >> n >> m;
    G.resize(n);
    invG.resize(n);
    memo.resize(n);
    rep(i, n)   memo[i] = -1;
    rep(i, m){
        int x,y;
        cin >> x >> y;
        --x;    --y;
        G[x].push_back(y);
        invG[y].push_back(x);
    }
    rep(i, n)   search(i);
    int ans = 0;
    rep(i, n)   ans = max(ans, memo[i]);
    cout << ans << endl;
}


Measured memory_bytes: 16128
#include <iostream>

using namespace std;

int main() {
  int a, b;
  string op;
  while(cin >> a >> op >> b, op!="?")
    {
     if (op == "+")
       {
         cout << a + b << endl;
       }
     else if (op == "-")
       {
         cout << a - b << endl;
       }
     else if (op == "*")
       {
         cout << a * b << endl;
       }
     else if (op == "/")
       {
         cout << a / b << endl;
       }
     else break;
    }
  return 0;
}

Measured memory_bytes: 1204
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long inf = numeric_limits<long long>::max();
int main()
{
  int d;
  cin >> d;
  if (d == 25) {
    cout << "Christmas" << endl;
  } else if (d == 24) {
    cout << "Christmas Eve" << endl;
  } else if (d == 23) {
    cout << "Christmas Eve Eve" << endl;
  } else if (d =- 22) {
    cout << "Christmas Eve Eve Eve" << endl;
  }
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(){
	string S;
	cin >> S;
	vector<ll> check(26, 0);
	bool flag = true;
	REP(i, S.size()){
		if(check[S[i]-'a']!=0) flag = false;
		check[S[i]-'a']++;
	}
	cout << (flag?"yes":"no") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] ab=reader.readLine().split(" ");
        int a=Integer.parseInt(ab[0]);
        int b=Integer.parseInt(ab[1]);
        
        if(a<b){
        	System.out.println("a < b");
        }else if(a>b){
        	System.out.println("a > b");
        }else{
        	System.out.println("a == b");
        }
	}
}

Measured memory_bytes: 24428
#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

std::vector<int> UpFlags(int n) {
  std::vector<int> up_flags;
  for (int i = 0; (1<<i) <= n; i++) {
    if (n & (1<<i)) up_flags.push_back(i);
  }
  return up_flags;
}

int main() {
  std::string s; std::cin >> s;
  int op_num = s.size() - 1;
  long num_pattern = (1<<op_num);
  long total = 0;
  for (int n = 0; n < num_pattern; n++) {
    int i = 0;
    for (auto v : UpFlags(n)) {
      total += std::stol(s.substr(i, v+1-i));
      i = v+1;
    }
    total += std::stol(s.substr(i));
  }
  std::cout << total << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int r,g,b,n,ans=0;
    cin>>r>>g>>b>>n;
    for(int i=0;i*r<=n;i++){
        for(int j=0;j*g<=n;j++){
            if(n<(r*i+g*j))continue;
            if((n-(r*i+g*j))==0||(n-(r*i+g*j))%b==0)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <fstream>
//#include <vector>
#include <string>

using namespace std;
using ul = unsigned long;



int main(int argc, const char * argv[]) {
//            ifstream in("input.txt");
//            cin.rdbuf(in.rdbuf());
    
    string S;
    cin >> S;
    
    ul n = S.length();
    ul num0 = 0;
    ul num1 = 0;
//    auto g = S[0];
    for (ul i=0; i<n; ++i)
    {
        if (i%2==0 && (int)(S[i] - '0')==1)
        {
            num1 += 1;
        }
        else if (i%2==0 && (int)(S[i] - '0')==0)
        {
            num0 += 1;
        }
        else if (i%2==1 && (int)(S[i] - '0')==1)
        {
            num0 += 1;
        }
        else if (i%2==1 && (int)(S[i] - '0')==0)
        {
            num1 += 1;
        }
//        else{
//            assert("error!!");
//        }
    }
    
    cout << min(num0, num1) << endl;
    
    
    
    
    return 0;
}


Measured memory_bytes: 888
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int[] h = sc.nextIntArray(n);
    Deque<List<Integer>> queue = new ArrayDeque<>();
    queue.add(new ArrayList<Integer>() {
      {
        for (int hi : h) {
          add(hi);
        }
      }
    });
    int count = 0;
    while (!queue.isEmpty()) {
      List<Integer> list = queue.poll();
      int min = Integer.MAX_VALUE;
      for (int hi : list) {
        min = Math.min(min, hi);
      }
      count += min;
      List<Integer> next = new ArrayList<>();
      for (int hi : list) {
        if (hi - min > 0) {
          next.add(hi - min);
        } else {
          if (next.size() > 0) queue.add(next);
          next = new ArrayList<>();
        }
      }
      if (next.size() > 0) queue.add(next);
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 23380
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int N = S.length();
  bool ans = N % 2 == 0;
  for (int i = 0; i < N; i += 2) {
    if (S.substr(i, 2) == "hi")continue;
    ans = false;
    break;
  }
  cout << (ans ? "Yes" : "No") << endl;
}


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


int main(){
	int n;cin>>n;
	vector<vector<int> > arr(n,vector<int>(2));
	long long w ; cin>>w;
	for(int i=0;i<n;i++){
		cin>>arr[i][0]>>arr[i][1];
	}
	int sumval = 0;
	for(int i=0;i<arr.size();i++){
		sumval += arr[i][1];
	}
	long long  INF = 1000000000000000;
	vector<long long> dp(sumval+1,INF);
	dp[0] = 0;
	long long ans =0;
	for(int i=0;i<n;i++){
		for(int j=sumval;j>=arr[i][1];j--){
			if(sumval-arr[i][1]>=0)
			dp[j] = min(dp[j],dp[j-arr[i][1]] + arr[i][0] );
			//ans = m(ans,dp[j]);
		}
			
	}
	for(long long i=0;i<dp.size();i++){
		if(dp[i]<=w) ans = max(ans,i);
	}
	cout<<ans;
	
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> ans;
    for(int i = 1; i < N; i++){
        for(int j = i + 1; j <= N; j++){
            if(N % 2 == 0 && i + j == N + 1)continue;
            if(N % 2 == 1 && i + j == N)continue;
            ans.push_back(make_pair(i, j));
        }
    }
    
    cout << ans.size() << endl;
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i].first << " " << ans[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
	int b1,b2,b3;
	scanf("%d %d %d",&b1,&b2,&b3);
	if(b1+b2==2){
		printf("Open\n");
	}
	else if(b3==1){
		printf("Open\n");
	}
	else{
		printf("Close\n");
	}
	return 0;
}


Measured memory_bytes: 2104
/*------U Have To DO It------*/
/* BY-> RicoProg */
/*        ___ 
           __|__|
          |  |___       */
#include <bits/stdc++.h>
using namespace std;
 
 
//---------------------------------------------------MACROS----------------------------------------------------------
#define ll long long
#define beg(i ,n) for(int i=0;i<n;i++)
#define beg1(i ,n) for(int i=1;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back 
#define mp make_pair
#define nl "\n" 
#define vec(v , n) vector<ll> v(n)
#define all(x) x.begin() , x.end()
#define pii pair<int , int>
#define pll pair<ll , ll>
#define mii map<int , int>
#define mll map<ll , ll>
#define msi map<string , int>
#define mci map<char , int>
#define f1 first
#define f2 second
 
//---------------------------------------------------GLOBAL----------------------------------------------------------
const ll MOD = 998244353 ;
const ll MAX = 1e5 + 7;
//---------------------------------------------------FUNCTIONS-------------------------------------------------------

void solve(){
	ll n ;
	vector<vector<ll>> dp(100001) ;
	cin >> n ;
	vector<vector<ll>> ar(n) ;
	beg(i , n) ar[i] = vector<ll> (3) , dp[i] = vector<ll> (3 , INT_MIN) ;
	beg(i , n) cin >> ar[i][0] >> ar[i][1] >> ar[i][2] ;
	dp[0][0] = ar[0][0] ;
	dp[0][1] = ar[0][1] ;
	dp[0][2] = ar[0][2] ;
	beg1(i , n){
		dp[i][0] = max(dp[i-1][1] , dp[i-1][2]) + ar[i][0] ;
		dp[i][1] = max(dp[i-1][0] , dp[i-1][2]) + ar[i][1] ;
		dp[i][2] = max(dp[i-1][1] , dp[i-1][0]) + ar[i][2] ;
	}
	cout << max(dp[n-1][0] , max(dp[n-1][1] , dp[n-1][2] )) ;
}
 
//---------------------------------------------------DRIVER----------------------------------------------------------
int main()
{
    fast ;
    int t=1 ;
    //cin >> t ;
    while(t--){
        solve() ;
    }
    return 0;
}	

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using std::cout;
using ll =long long;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  int n;
  cin>> n ;
  vector <tuple<string, int, int >>  a(n);
  for(int i=0 ;i<n; i++ ){
    string s;
    cin >>s;
    int p;
    cin>>p;
    a[i] = make_tuple( s, 100-p, i+1 );
  }
  sort(a.begin(),a.end());
  for (int i=0; i<n; i++)cout << get<2>(a[i]) << endl; 
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N, X, T;
    cin >> N >> X >> T;
    cout << T*((N+X-1)/X) << endl;
}

Measured memory_bytes: 3592
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))


s = IS()
for i in s:
    if s.count(i) >= 2:
        print('no')
        exit()
print('yes')


Measured memory_bytes: 65516
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
bool prime[1100100];
void mainmain(){
	int n,x;
	rep(i,1100100) prime[i]=true;
	prime[0]=prime[1]=false;
	for(int i=2;i*i<1100100;i++){
		if(prime[i]){
			for(int j=i*i;j<1100100;j+=i){
				prime[j]=false;
			}
		}
	}
	while(cin>>n>>x,n||x){
		vint v(n);
		rep(i,n) cin>>v[i];
		sort(ALL(v));
		vint dp(x+1,0);
		dp[0]=1;
		rep(i,x+1){
			if(dp[i]==0) continue;
			rep(j,n){
				int t=i+v[j];
				if(x<t) break;
				dp[t]=1;
			}
		}
		int ans=0;
		rep(i,x+1){
			if(prime[i]&&dp[i]) ans=i;
		}
		if(ans==0) cout<<"NA"<<endl;
		else cout<<ans<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 9236
#include<bits/stdc++.h>
#define maxN 200005
using namespace std;
int n,t,x,vf,st[maxN];
long long sol;
pair<int,int> v[maxN];
bool Intersect(pair<int,int> a,pair<int,int> b)
{
    if(a.second<b.first) return 0;
    if(b.second<a.first) return 0;
    return 1;
}
void Merge(pair<int,int> &a,pair<int,int> b)
{
    a.first=min(a.first,b.first);
    a.second=max(a.second,b.second);
}
int main()
{
    scanf("%d%d",&n,&t);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        v[i]={x,x+t};
        while(vf && Intersect(v[st[vf]],v[i]))
        {
            Merge(v[i],v[st[vf]]);
            vf--;
        }
        st[++vf]=i;
    }
    for(int i=1;i<=vf;i++)
        sol=sol+1LL*(v[st[i]].second-v[st[i]].first);
    printf("%lld\n",sol);
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++){
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());

  cout << d.at(N/2) - d.at(N/2-1) << endl;
  
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

using ll = long long;

ll calc(const string& S, int bit)
{
    int N = S.size();
    string t;
    for (int i = 0; i < N; i++) {
        t += S[i];
        if (i < N - 1 && bit >> i & 1) {
            t += "+";
        }
    }

    ll sum = 0;
    string num;
    for (auto& ch : t) {
        if (ch == '+') {
            sum += stoll(num);
            num.clear();
        } else {
            num += ch;
        }
    }

    if (!num.empty()) {
        sum += stoll(num);
    }
    
    return sum;
}

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

    ll sum = 0, N = S.size() - 1;
    for (int i = 0; i < (1 << N); i++) {
        sum += calc(S, i);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int a,b;
    cin >> a >> b;

    cout << a*b << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <unordered_set>
#include <algorithm>
#include <cassert>
using namespace std;

class DisjointSet {
private:
	const int vertex_n;
	vector<int> P;		//添え字の頂点の根
	vector< unordered_set<int> > Set;		//添え字の頂点に子として繋がっている頂点の集合
public:
	DisjointSet(int n);
	void unite(int x, int y);
	bool same(int x, int y);
	int tree_number();
};

DisjointSet::DisjointSet(int n) : vertex_n(n), P(n), Set(n) {
	for (int i = 0; i<n; ++i) {
		P[i] = i;
		Set[i].insert(i);
	}
}

void DisjointSet::unite(int x, int y) {
	if (P[x] == P[y])
		return;
	int big, small;
	if (Set[P[x]].size() >= Set[P[y]].size()) {
		big = P[x];
		small = P[y];
	}
	else {
		big = P[y];
		small = P[x];
	}
	for (auto i = Set[small].begin(); i != Set[small].end(); ++i) {
		P[*i] = big;
		Set[big].insert(*i);
	}
}

bool DisjointSet::same(int x, int y) {
	return P[x] == P[y];
}

int DisjointSet::tree_number() {
	int sum = 0;
	for (int i = 0; i < vertex_n; i++)
		if (P[i] == i)
			sum++;
	return sum;
}

const int N = 1001;
int F[1001];

int main() {
	int V, d;
	F[0] = 1; F[1] = 2;
	for (int i = 2; i < N; i++)
		F[i] = (F[i - 1] % N + F[i - 2] % N) % N;
	while (cin >> V >> d) {
		DisjointSet fs(V + 1);
		for (int i = 1; i <= V; i++)
			for (int j = i + 1; j <= V; j++) {
				if (max(F[i], F[j]) - min(F[i], F[j]) < d)
					fs.unite(i, j);
			}
		cout << fs.tree_number() - 1 << endl;
	}
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};


class LowLink {
    const int N;
    vector<vector<int>> G;
    set<int> used_v;
    vector<int> ord, low, parent;

    void dfs(int v, int &k)
    {
        used_v.insert(v);
        ord[v] = low[v] = k++;

        for (auto u : G[v]) {
            if (!used_v.count(u)) {
                parent[u] = v;
                dfs(u, k);
                low[v] = min(low[v], low[u]);
            } else if (u != parent[v]) {
                low[v] = min(low[v], ord[u]);
            }
        }
    }

    void calc_lowlink()
    {
        int k = 0;
        dfs(0, k);
    }

public:
    LowLink(int _N) : N(_N), G(_N), ord(_N), low(_N), parent(_N) {}

    vector<int> articulation_points()
    {
        vector<int> res;

        parent[0] = -1;
        calc_lowlink();

        int root_deg = 0;
        for (int i=1; i<N; i++) {
            int p = parent[i];
            if (p == 0) root_deg++;
            else if (ord[p] <= low[i]) {
                res.push_back(p);
            }
        }

        if (root_deg > 1) res.push_back(0);
        sort(res.begin(), res.end());
        res.erase(unique(res.begin(), res.end()), res.end());

        return res;
    }

    void add_edge(int u, int v)
    {
        G[u].push_back(v);
        G[v].push_back(u);
    }
};

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

    LowLink LL(N);

    rep(i, M) {
        int U, V;
        cin >> U >> V;
        LL.add_edge(U, V);
    }

    vector<int> ap = LL.articulation_points();
    for (auto a : ap) cout << a << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, K; cin >> N >> K;
    ll cnt = 0;
    ll zero = 0;
    if (K == 0){
        cout << N * N << endl;
    } else {
        rep2(b, K + 1, N + 1){
            ll quotient = N / b;
            cnt += quotient * ((b - 1) - K + 1); // あまりがK~b-1なものの個数
            ll remainder = N % b;
            cnt += max(zero, remainder - K + 1);
        }
        cout << cnt << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
// #define endl '\n'

map<int,int> mem;

int q(int y){
  cout << y << endl;
  string s;
  cin >> s;
  int a = -1;
  if (s == "Male") return 1;
  else if (s == "Female") return 2;
  else {
    exit(0);
  }
}

const ll m = 1e9 + 7;
void solve(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  forn(i,n) cin >> a[i];
  ll ans = 0;
  ll cur = 0;
  forn(i,60){
    ll o = 0;
    forn(j,n) o += (a[j] >> i) & 1;
    cur = (n - o) * o;
    cur %= m;
    forn(j, i) {
      cur *= 2;
      cur %= m;
    }
    ans += cur;
    ans %= m;
  }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

6
1 1
7 1
2 2
6 2
1 3
7 3

 */

Measured memory_bytes: 2560