akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<bits/stdc++.h>
#define int long long int
#define e 1000000007
using namespace std;

bool compare(pair<int,int> mp1, pair<int,int> mp2){
    return mp1.second > mp2.second;
}
 
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int x1,x2,x3,x4,x5;
  cin>>x1>>x2>>x3>>x4>>x5;
  if(x1==0){
 cout<<1;
  }if(x2==0){
    cout<<2;
  }if(x3==0){
    cout<<3;
  }if(x4==0){
    cout<<4;
  }if(x5==0){
    cout<<5;
  }
}

Measured memory_bytes: 3640
n, m = map(int, input().split())
events = []
for i in range(m):
    a, b = map(int, input().split())
    events.append((a, 0, i))
    events.append((b-1, 1, i))
events.sort()
solved = [False] * m
todo = []
ans = 0
for i, etype, req in events:
    if etype == 0:
        todo.append(req)
    else:
        if not solved[req]:
            ans += 1
            for req_id in todo:
                solved[req_id] = True
print(ans)

Measured memory_bytes: 112236
s = input()

a = s[:(len(s)-1)//2]
b = s[(len(s)+2)//2:]

for i in range(len(a)):
    if a[i] != a[-i-1]:
        print("No")
        exit()

for i in range(len(b)):
    if b[i] != b[-i-1]:
        print("No")
        exit()

for i in range(len(s)):
    if s[i] != s[-i-1]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(f) (f).begin(),(f).end()
#define allr(f) (f).rbegin(),(f).rend()
const int mod = 1e9+7, A = 1e2+5;
using namespace std;
ll GCD (ll x, ll y) {
	return (!y) ? x : GCD(y, x % y);
}
ll LCM (ll x, ll y) {
	return x / GCD(x, y) * y;
}
ll num2 (ll x) {
	ll cnt = 0;
	while (x % 2 == 0)
		cnt++, x /= 2;
	return cnt;
}
int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n, m;
	cin >> n >> m;
	int a[n];
	for (int i = 0; i < n; i++)
		cin >> a[i], a[i] /= 2;
	ll d = num2(a[0]), lcm = a[0];
	for (int i = 1; i < n; i++) {
		if (d != num2(a[i]) || (lcm > m))
			return cout << 0, 0;
		lcm = LCM(lcm, a[i]);
	}
	ll cnt = 0, x = 1;
	while (lcm*x <= m)
		cnt++, x += 2;
	cout << cnt;
	return 0;
}


Measured memory_bytes: 640
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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



int main() {
	llong N,K;
    cin >> N >> K;
    llong ans =0;
    ans =0;
    string S;
    cin >> S;
    S[K-1]=tolower(S[K-1]);


    if (true ){ 

    }else{


    }

    cout << S << endl;





}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
using ll = long long;

const int N = 1e6 + 5;
int ar[N], cnt[N], spf[N];
int n;

void sieve() {
    for (int i = 1; i < N; i++) {
        spf[i] = i;
    }
    for (int i = 2; i < N; i += 2) {
        spf[i] = 2;
    }
    for (int i = 3; i * i < N; i++) {
        if (spf[i] != i) continue;
        for (int j = i * i; j < N; j += i) {
            if (spf[j] == j) {
                spf[j] = i;
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    sieve();
    cin >> n;
    int gc = 0;
    int mx = 0;
    for (int i = 0; i < n; i++) {
        cin >> ar[i];
        mx = max(mx, ar[i]);
        gc = __gcd(gc, ar[i]);
    }
    for (int i = 0; i < n; i++) {
        set<int> cur;
        while (ar[i] != 1) {
            cur.insert(spf[ar[i]]);
            ar[i] /= spf[ar[i]];
        }
        for (auto c: cur) cnt[c]++;
    }
    bool pwcp = true;
    for (int i = 2; i <= mx; i++) {
        // cout << i << ' ' << cnt[i] << '\n';
        if (cnt[i] > 1) pwcp = false;
    }
    if (pwcp) {
        cout << "pairwise coprime" << '\n';
        exit(0);
    }
    if (gc == 1) {
        cout << "setwise coprime" << '\n';
    } else {
        cout << "not coprime" << '\n';
    }
    return 0;
}

Measured memory_bytes: 15256
N=int(input())
*H,=map(int,input().split())


i=0
cnt=0
ans=0
while i < N-1:
    if 1<=H[i]/H[i+1]:
        cnt+=1
    else:
        ans=max(ans,cnt)
        cnt=0
    i+=1
ans=max(ans,cnt)
print(ans)

Measured memory_bytes: 20516
# 写経
N,K = map(int,input().split())
A = list(map(int,input().split()))
pos = 0
visit = [0] * N
move = []
loop = []
while visit[pos]!=2:
    if visit[pos]==0:
        move.append(pos)
    else:
        loop.append(pos)
    visit[pos] += 1
    pos = A[pos] - 1
if len(move)>K:
    print(move[K]+1)
else:
    print(loop[(K-(len(move)-len(loop)))%len(loop)]+1)


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

ll a[5];

int main() {
    int n;
    cin >> n;
    rep(i, n) {
        string s;
        cin >> s;
        if (s[0] == 'M') a[0]++;
        else if (s[0] == 'A') a[1]++;
        else if (s[0] == 'R') a[2]++;
        else if (s[0] == 'C') a[3]++;
        else if (s[0] == 'H') a[4]++;
    }
    ll ans = 0;
    for (int i=0; i<5; ++i) {
        for (int j=i+1; j<5; ++j) {
            for (int k=j+1; k<5; ++k) {
                ans += a[i]*a[j]*a[k];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
n = int(input())
s = []
for i in range(4):
	s.append(n//(10**i)-(n//(10**(i+1)))*10)
s.reverse()

def sgn(i):
	if i==0:
		return 1
	else:
		return -1

x = []
m = 0

for i in range(2):
	for j in range(2):
		for k in range(2):
			m +=1
			x.append(s[0]+s[1]*sgn(i)+s[2]*sgn(j)+s[3]*sgn(k))

z = x.index(7)
u = []
for i in range(3):
	u.append(z//(2**i)-(z//(2**(i+1)))*2)
u.reverse()

def ppp(i):
	if i==0:
		return "+"
	else:
		return "-"
print(s[0],ppp(u[0]),s[1],ppp(u[1]),s[2],ppp(u[2]),s[3],"=7",sep="")

Measured memory_bytes: 3064
io = STDIN
ary=[]
$n=io.gets.to_i
$n.times do
  x,y=io.gets.split.map(&:to_i)
  ary << [x,y,:r]
end
$n.times do
  x,y=io.gets.split.map(&:to_i)
  ary << [x,y,:b]
end
ary.sort_by!{|x,y,color|x}
$ar=ary.to_enum.with_index.map{|(x,y,color),i|[x,y,color,i]}
def search_red(upper_x,upper_y)
  sel=$ar.select{|x,y,color,i|color==:r && upper_y>y && upper_x>x}
     .max_by{|x,y,color,i|y}
  if sel
    x,y,color,i = sel
    $ar[i][2] = nil
    return true
  else
    return false
  end
end
#red < blue
cnt=0
$ar.each do |x,y,color,i|
  if color == :b
    # p [$ar[i],$ar]
    if search_red(x,y)
      $ar[i][2]=nil
      cnt +=1
    end
  end
end
puts cnt


Measured memory_bytes: 1912
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b;
    cin >> a >> b;
    cout << a - b + 1;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
int h, w, n;
char fi[32][32];
char ori[32][32];
void init() {
	rep(i,32) {
		rep(j,32) {
			fi[i][j] = ori[i][j];
		}
	}
	return;
}
void fall() {
	rep(k, 40) {
		rep1(i, h - 1) {
			rep1(j, w) {
				if (fi[i + 1][j] == '.')swap(fi[i][j], fi[i + 1][j]);
			}
		}
	}
	return;
}
int con(P x) {
	int nx = x.first; int ny = x.second;
	char t = fi[nx][ny];
	int cnt1 = 1; int j = 1;
	while (fi[nx + j][ny] == t) {
		j++;
	}
	cnt1 += j - 1;
	j = 1;
	while (fi[nx - j][ny] == t) {
		j++;
	}
	cnt1 += j - 1;
	int cnt2 = 1; j = 1;
	while (fi[nx][ny + j] == t) {
		j++;
	}
	cnt2 += j - 1;
	j = 1;
	while (fi[nx][ny - j] == t) {
		j++;
	}
	cnt2 += j - 1;
	return max(cnt1,cnt2);
}
bool del() {
	bool f = false;
	int d[32][32] = {};
	rep1(i, h) {
		rep1(j, w) {
			if (fi[i][j] == '.')continue;
			if (con({ i,j }) >= n) {
				d[i][j] = 1;
			}
		}
	}
	rep1(i, h) {
		rep1(j, w) {
			if (d[i][j]) {
				fi[i][j] = '.'; f = true;
			}
		}
	}
	if (f)return true;
	else return false;
}
void delphase() {
	while (del()) {
		fall();
	}
	return;
}
bool allc() {
	rep1(i, h) {
		rep1(j, w) {
			if (fi[i][j] != '.')return false;
		}
	}
	return true;
}
int main() {
	cin >> h >> w >> n;
	rep(i, 32) {
		rep(j, 32) {
			ori[i][j] = '.';
		}
	}
	string s;
	rep1(i, h) {
		cin >> s;
		rep1(j, w) {
			ori[i][j] = s[j - 1];
		}
	}
	rep1(i, h) {
		rep1(j, w - 1) {
			init();
			if (fi[i][j] == '.' && fi[i][j + 1] == '.')continue;
			swap(fi[i][j], fi[i][j + 1]);
			fall();
			delphase();
			if (allc()) {
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 3200
import sys
n = int(input())
bottun = [int(input()) for i in range(n)]
i = 0
cnt = 0
while 1:
  if bottun[i] == 0:
    print(-1)
    sys.exit()
  if bottun[i] == 2:
    print(cnt+1)
    sys.exit()
  temp = bottun[i] - 1
  bottun[i] = 0
  i = temp
  cnt += 1

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

int main() {
  int n;
  cin >> n;
  vector<int> num;
  int i, j;
  for (i = 0; i < 100; i++) {
    for (j = 0; j < 100; j++) {
      num.push_back(i * 4 + j * 7);
      num.push_back(i * 7 + j * 4);
    }
  }
  sort(num.begin(), num.end());
  for (i = 0; num[i] <= 100; i++) {
    if (num[i] == n) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
#define rep(var,n) for(int var=0;var<(n);++var)
const ll MOD = 1e9+7;
 
#define MAX_V (long long)(1e5*2+200)
 
ll MAX_VAL;
ll fac[MAX_V], mmi[MAX_V], temp[MAX_V];
 
inline void factorial(){
	fac[0] = fac[1] = 1;
	for(long long i = 2; i < MAX_VAL; fac[i]%=MOD,i++)
		fac[i] = fac[i-1]*(i%MOD);
}
 
inline long long power_mod(long long x, long long n){
  long long ans = 1;
  for(;n;n>>=1,x*=x,ans%=MOD,x%=MOD)
    if(n&1)ans*=x;
  return ans;
}
 
inline void modular_multiplicatibe_inverse(){
  mmi[MAX_VAL-1] = power_mod(fac[MAX_VAL-1],MOD-2);
  for(long long i = MAX_VAL-2; i >= 0; mmi[i]%=MOD,i--)
    mmi[i] = mmi[i+1]*(i+1);
}
 
inline long long combination(long long n, long long r){
  return fac[n]*(mmi[r]*mmi[n-r]%MOD)%MOD;
}
 
int main(){
  ll n,k; cin >> n >> k;
 
  MAX_VAL = n+3;
 
  factorial();
  modular_multiplicatibe_inverse();
 
  rep(i,k) cout << (combination(k-1,i)*combination(n-k+1,i+1))%MOD << endl;
  return 0;
}

Measured memory_bytes: 2304
YES = "YES"
NO = "NO"

def sq(x)
    return x * x
end

gets.to_i.times do
    puts ->(l){
        if sq(l[0]) + sq(l[1]) == sq(l[2])
            return YES
        elsif sq(l[1]) + sq(l[2]) == sq(l[0])
            return YES
        elsif sq(l[2]) + sq(l[0]) == sq(l[1])
            return YES
        end
        return NO
    }.call gets.split(' ').map(&:to_i)
end

Measured memory_bytes: 6112
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();
        int n = nextInt();
        List<Integer> pList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            pList.add(nextInt());
        }
        List<Integer> qList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            qList.add(nextInt());
        }

        String p = pList.toString();
        String q = qList.toString();
        List<String> permutations = permutations(n);
        int pIndex = -1;
        int qIndex = -1;
        for (int i = 0; i < permutations.size(); i++) {
            if (permutations.get(i).equals(p)) {
                pIndex = i;
            }
            if (permutations.get(i).equals(q)) {
                qIndex = i;
            }
        }

        System.out.println(Math.abs(pIndex - qIndex));
    }

    private static List<String> perms;
    private static List<Integer> perm;
    private static boolean[] chosen;

    private static List<String> permutations(int n) {
        perms = new ArrayList<>();
        perm = new ArrayList<>();
        chosen = new boolean[n + 1];
        permuationHelper(n);
        perms.sort(String::compareTo);
        return perms;
    }

    private static void permuationHelper(int n) {
        if (perm.size() == n) perms.add(perm.toString());
        else {
            for (int i = 1; i <= n; i++) {
                if (!chosen[i]) {
                    chosen[i] = true;
                    perm.add(i);
                    permuationHelper(n);
                    perm.remove((Integer)i);
                    chosen[i] = false;
                }
            }
        }
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}

Measured memory_bytes: 48292
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<double>vec(N);
    for (int i=0; i<N; i++) {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end());
    double num = vec[0];
    for (int i=1; i<N; i++) {
        num = (num + vec[i]) / 2;
    }

    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility> // pairとか
#include <vector>
#include <array>
#include <list>
#include <deque>
#include <map>
#include <algorithm> // sortとか findとか
#include <functional> // algorithmに渡せる関数
#include <cmath>
#include <cstdio>
#include <numeric> // gcd,lcmとか
#define rep(iter, beg, end, step) for (long(iter) = (beg); (iter) < (end); (iter) += (step))
using namespace std;

int main() {
	int N,M;
	map<string, int> m;
	string str;

	cin >> N;	
	rep(i, 0, N, 1)
	{
		cin >> str;
		m[str]++;
	}
	cin >> M;	
	rep(i, 0, M, 1)
	{
		cin >> str;
		m[str]--;
	}

	int mx = 0;
	for (auto i = m.begin(); i != m.end(); i++)
	{
		mx = (mx > i->second) ? mx : i->second;
	}
	cout << mx << "\n";
	return 0;
}

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

int main() {
  int64_t N,M,tmp,two=2;
  cin >> N >> M;
  //vector<int64_t> A(N);
  priority_queue<int64_t> A;
  for(int i = 0; i < N; i++){
    cin >> tmp;
    A.push(tmp);
  }
  for(int i = 0; i < M; i++){
    tmp = A.top();
    A.pop();
    A.push(tmp/two);
  }
  int64_t ans=0;
  while(!A.empty()){
    ans+=A.top();
    A.pop();
  }
  cout << ans;
}

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

#define MAX_N 300000
#define MAX_Q 300000

int N, Q, tmp, cnt = 0, x, y;

int a[MAX_N];
int b[MAX_N];
int X[MAX_Q];
int Y[MAX_Q];

int main() {

  cin >> N;

  for(int i=0; i<N; ++i) {
    cin >> a[i];
    b[i] = a[i];
  }

  sort(b, b+N);

  cin >> Q;

  for(int i=0; i<Q; ++i) {
    cin >> X[i] >> Y[i];
  }

  for(int i=0; i<N; ++i) {
    if(a[i]==b[i]) ++cnt;
  }

  if(cnt==N) {
    cout << "0" << endl;
    return 0;
  }

  for(int i=0; i<Q; ++i) {
    x = --X[i];
    y = --Y[i];

    if(a[x]==b[x]) --cnt;
    if(a[y]==b[y]) --cnt;

    swap(a[x], a[y]);

    if(a[x]==b[x]) ++cnt;
    if(a[y]==b[y]) ++cnt;

    if(cnt==N) {
      cout << i+1 << endl;
      return 0;
    }
  }

  cout << "-1" << endl;

  return 0;
}



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

int lex_smaller(char* s1, char* s2)
{
	int i;
	for (i = 0; s1[i] != 0 && s2[i] != 0; i++) {
		if (s1[i] < s2[i]) return 1;
		else if (s1[i] > s2[i]) return -1;
	}
	if (s1[i] == s2[i]) return 0;
	else if (s1[i] == 0) return 1;
	else return -1;
}

int main()
{
	int i, N, M;
	char s[101][11], t[101][11];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%s", s[i]);
	scanf("%d", &M);
	for (i = 1; i <= M; i++) scanf("%s", t[i]);
	
	int j, max = 0, flag[101] = {}, point;
	for (i = 1; i <= N; i++) {
		if (flag[i] == 1) continue;
		point = 1;
		for (j = i + 1; j <= N; j++) {
			if (flag[j] == 0 && lex_smaller(s[j], s[i]) == 0) {
				point++;
				flag[j] = 1;
			}
		}
		for (j = 1; j <= M; j++) {
			if (lex_smaller(t[j], s[i]) == 0) point--;
		}
		if (point > max) max = point;
	}
	
	printf("%d\n", max);
	fflush(stdout);
	return 0;
}

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

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

using namespace std;

signed main(){
  string S;
  cin >> S;
  char S1[S.length()];
  char S2[S.length()];

  int sum1 = 0;
  int sum2 = 0;
  
  rep(i, S.length()){
    if(i%2==0){
      S1[i] = '1';
      S2[i] = '0';
    }else{
      S2[i] = '1';
      S1[i] = '0';
    }
  }
  
  rep(i, S.length()){
    if(S[i]!=S1[i]) sum1++;
    if(S[i]!=S2[i]) sum2++;
       
  }

  cout << min(sum1, sum2) << endl;
  return 0;
}


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

#define ll long long int
#define maximum 0x7f

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

int vis[100001];
vector<int>adj[100001];

int dfs(int u)
{
    if(vis[u]!=-1)
        return vis[u];
    int ret=0;
    for(auto v:adj[u])
    {
        ret=max(ret,1+dfs(v));
    }
    return vis[u]=ret;
}

int main()
{
    int n,m,u,v;
    cin>>n>>m;
    memset(vis,-1,sizeof vis);
    for(int i=0; i<m; i++)
    {
        cin>>u>>v;
        adj[u].push_back(v);
    }
    int ans=0;
    for(int i=1; i<=n; i++)
    {
        ans=max(ans,dfs(i));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8192
/*In the name of ALLAH, Most Gracious, Most Merciful*/
#include<bits/stdc++.h>

#define ll                      long long int
#define ull                     unsigned long long int
#define PI                      2*acos(0.0)
#define sqr(x)                  (x)*(x)
#define EPS                     10E-10
#define MOD                     1000000007
#define longlimit               92233720368547758
#define infinity                (1<<28)
#define setbits                 __builtin_popcount
#define zerobits                __builtin_ctzll
#define parity(n)               __builtin_parity(n)
#define pb(a)                   emplace_back(a)
#define mp                      make_pair
#define ff                      first
#define ss                      second
#define gcd(a, b)               __gcd(a,b)
#define lcm(a, b)               ((a)*(b))/gcd(a,b)
#define watch(x)                cout << (#x) << " is " << (x) << endl
#define TEST_CASES()            ll t;cin>>t;while (t--)
#define PRECISION(a,x)          fixed<<setprecision(x)<<a<<endl;
#define endl                    "\n"
#define all(a)                  (a.begin()),(a.end())
#define UNIQUE(X)               (X).erase(unique(all(X)),(X).end())
#define DELETE(X)               (X).erase (remove (all(X)),(X).end())
#define SORT_UNIQUE(c)          (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define FAST_IO()               ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define FILE_IO()               freopen("output.txt", "w", stdout);freopen("input.txt", "r", stdin)
using namespace std;


void solve()
{
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    
}

int32_t main()
{
    FAST_IO();
    //TEST_CASES()
        solve();
}




Measured memory_bytes: 3648
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long N = sc.nextInt();
		long M = sc.nextInt();
		
		List<Shop> shops = new ArrayList<Shop>();
		
		for(int i = 0; i < N; i++) {
			shops.add(new Shop(sc.nextLong(), sc.nextLong()));
		}
		
		Comparator<Shop> comp = new Comparator<Shop>() {
			@Override
			public int compare(Shop o1, Shop o2) {
				if(o1.money == o2.money) return 0;
				return o1.money < o2.money ? -1 : 1;
			}
		};
		
		Collections.sort(shops, comp);
		
		long res = 0;
		
		loop: for(Shop shop : shops) {
			for(int i = 0; i < shop.stock; i++) {
				if(M  > 0) {
					res+=shop.money;
					M-=1;
				}else{
					break loop;
				}
			}
		}
		
		System.out.println(res);
		
	}
}

class Shop{
	public long money;
	public long stock;
	
	public Shop(long money, long stock) {
		this.money = money;
		this.stock = stock;
	}
}

Measured memory_bytes: 83888
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
ll m=1000000007;
std::vector<std::vector<ll> > a(100005);
std::vector<ll> dp1(100005,0);
std::vector<ll> dp2(100005,0);
void dfs(ll v,ll pv){
	ll p1=1,p2=1;
	for(int i=0;i<a[v].size();++i){
		ll z=a[v][i];
		if(z==pv)continue;
		dfs(z,v);
		p1=(p1*dp2[z])%m;
		p2=(p2*(dp1[z]+dp2[z]))%m;
	}
	dp1[v]=p1;
	dp2[v]=p2;;
	//cout<<v<<" "<<dp1[v]<<" "<<dp2[v]<<"\n";
}
int main()
{
    ll n;cin>>n;
    
    for (int i = 0; i < (n-1); ++i)
    {
    	ll x,y;cin>>x>>y;
    	a[x].pb(y);
    	a[y].pb(x);
    }
    dfs(1,0);
    cout<<(dp1[1]+dp2[1])%m<<"\n";
}


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


int main()
{
  int n;
  cin >> n;
  vector<int> A(n);
  vector<int> B(n);
  vector<int> C(n - 1);
  for (int i = 0; i < n; ++i)
  {
    cin >> A[i];
  }
  for (int i = 0; i < n; ++i)
  {
    cin >> B[i];
  }
  for (int i = 0; i < n - 1; ++i)
  {
    cin >> C[i];
  }
  int sum = 0;
  for (int i = 0; i < n; ++i)
  {
    sum += B[A[i] - 1];
    if (i > 0 && A[i] == A[i - 1] + 1)
      sum += C[A[i - 1] - 1];
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long n;
int x, m;
int vis[100009];
long long tmp[100009];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> x >> m;
	if (x == 0) {
		cout << 0 << endl;
		return 0;
	}
	memset(vis, 0xff, sizeof(vis));
	long long ans = -1, pre, cur;
	tmp[0] = x;
	vis[x] = 0;
	pre = x;
	for (int i = 1; i < n; i++) {
		cur = pre * pre;
		cur %= m;
		if (cur == 0) {
			ans = tmp[i - 1];
			break;
		}
		if (vis[cur] >= 0) {
			if (vis[cur] > 0) ans = tmp[vis[cur] - 1];
			else ans = 0;
			long long k = n - vis[cur];
			long long tt = tmp[i - 1];
			int d = i - vis[cur];
			if (vis[cur] > 0) tt -= tmp[vis[cur] - 1];
			ans += tt * (k / d);
			if (k % d) {
				ans += tmp[k % d - 1 + vis[cur]];
				if (vis[cur] > 0)
					ans -= tmp[vis[cur] - 1];
			}
			break;
		}
		tmp[i] = cur + tmp[i - 1];
		vis[cur] = i;
		pre = cur;
	}
	if (ans < 0) ans = tmp[n - 1];
	cout << ans << endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 4384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		
		if (a > 0 && b > 0) {
			System.out.println("Positive");
		} else if (a < 0 && b < 0 && (a + b) % 2 == 0 && a != b) {
			System.out.println("Negative");
		} else if (a < 0 && b < 0 && (a + b) % 2 == 1 && a != b) {
			System.out.println("Positive");
		} else if (a * b <= 0) {
			System.out.println("Zero");
		} else {
			System.out.println("Positive");
		}
		
	}
}


Measured memory_bytes: 21844
a = int(input())
b = int(input())
c = int(input())
x = int(input())

setc = set()
for i in range(c+1):
    setc.add(50*i)

ans = 0
for i in range(a+1):
    for j in range(b+1):
        if x - 500*i - 100*j in setc:
            ans += 1

print(ans)  

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
    int i;

    //入力
    int n;
    scanf("%d", &n);
    int R[n];
    for( i = 0; i < n; ++i )
        scanf("%d", &R[i]);

    //minが最小になるようにmaxを選ぶ
    int min = R[0], max = R[1] - R[0];
    for( i = 1; i < n; ++i ){
        max = max < R[i] - min ? R[i] - min : max;
        min = min > R[i] ? R[i] : min; //minは後から更新しないと R[i]-min == min-min になる
    }

    printf("%d\n", max);

    return 0;
}


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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;

    ll n;
    cin>>n;

    map<string, ll> dict;

    map<string,ll>::iterator it;
    ll mx=0;
    while(n--) {
        string s;
        cin>>s;

        if(dict.find(s)!=dict.end()) {
            dict[s]++;
        }
        else {
            dict[s]=1;
        }
        mx=max(mx, dict[s]);
    }

    //for(it=dict.begin();it!=dict.end();it++) { 
    //    cout<<"key: "<<it->first<<endl;
    //    cout<<"value: "<< it->second<<endl;
    //    cout<<"__________"<<endl;
    //}

    for(it=dict.begin();it!=dict.end();it++) {
        if(it->second==mx) {
            cout<<it->first<<endl;
        }
    }
}




Measured memory_bytes: 19292
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#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 all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int main(){
    ll x , y;
    cin >> x >> y;
    puts(abs(x - y) <= 1 ? "Brown" : "Alice");
    return 0;
}


Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod1 1000000007
#define mod2 1000000009

using namespace std;
using ll=long long;

class BGoToJail {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int n;
        cin>>n;
        int a[n][2];
        for (int i=0;i<n;i++)cin>>a[i][0]>>a[i][1];
        int flag=0;
        for (int i=0;i<n-2;i++){
            if (a[i][0]==a[i][1]){
                if (a[i+1][0]==a[i+1][1]&&a[i+2][0]==a[i+2][1]){
                    flag=1;break;
                }
            }
        }
        if (flag) cout<<"Yes";
        else cout<<"No";
	}
};


int main() {
	BGoToJail solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define FOR(i,l,r) for(int i=l;i<=r;i++)
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;

ll S;
ll x2,y2,x3,y3;

int main(){
    cin>>S;
    if(S!=1e18)x2=y3=sqrt(S)+1;
    else x2=y3=sqrt(S);
    ll diff=x2*y3-S;
    x3=1,y2=diff;
    cout<<"0 0"<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "4 11" ].parse.expand.solve == "+" );
	assert( [ "3 5" ].parse.expand.solve == "*" );
	assert( [ "1 1" ].parse.expand.solve == "x" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ab = input.front.split.to!( long[] );
	return tuple( ab[ 0 ], ab[ 1 ] );
}

auto solve( long a, long b )
{
	if( a + b == 15 ) return "+";
	if( a * b == 15 ) return "*";
	return "x";
}


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

#define ll long long

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<ll> a(N);
    ll x = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        x ^= a[i];
    }
    if(x == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 1152
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 100 + 10 , mod = 1e9 + 7 ;
int n , h[N] ;

int inv2 = (mod + 1) >> 1 ;

int z = 1 ;
set <pii> dp ;

inline void add (int &a , int b) {
	a += b ;
	if (a >= mod) a -= mod ;
}

inline int pw (int a , int b) {
	int res = 1 ;
	for (; b ; b >>= 1 , a = 1ll * a * a % mod) 
		if (b & 1) res = 1ll * res * a % mod ;
	return res ;
}

inline int get (int start , int len) {
	return (2 * start - (2ll * start * pw(inv2 , len)) % mod + mod) % mod ;
}

int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;
	
	cin >> n ;
	for (int i = 0 ; i < n ; i ++) cin >> h[i] ;

	if (h[0] > 1) dp.insert({1 , pw(2 , h[0] - 1)}) ; 
	dp.insert({h[0] , 2}) ;

	for (int i = 1 ; i < n ; i ++) {
		if (h[i - 1] >= h[i]) {
			int sum = 0 , last = h[i - 1] + 1 ;
			while (dp.size() && dp.rbegin() -> F > h[i]) {
				pii p = *dp.rbegin() ;
	
				add(sum , get(p.S , last - p.F)) ;

				last = p.F ;

				dp.erase(p) ;
			}

			if (dp.size()) {
				pii p = *dp.rbegin() ;
				add(sum , get(1ll * p.S * pw(inv2 , h[i] - p.F) % mod , last - h[i])) ;
				if (p.F == h[i]) dp.erase(p) ;
			}

			add(sum , sum) ;

			dp.insert({h[i] , sum}) ; 
		}
		else {
			z = 1ll * z * pw(2 , h[i] - h[i - 1]) % mod ;

			pii p = *dp.rbegin() ;

			dp.insert({h[i] , 2ll * p.S * pw(inv2 , h[i] - h[i - 1]) % mod}) ;
		}
	}

	int last = h[n - 1] + 1 , ans = 0 ;
	while (_sz(dp)) {
		pii p = *dp.rbegin() ;
	
		add(ans , get(p.S , last - p.F)) ;

		last = p.F ;

		dp.erase(p) ;
	}

	ans = 1ll * ans * z % mod ;

	cout << ans << '\n' ;
}

Measured memory_bytes: 256
number=list(map(int,input().split()))
n,m=number[0],number[1]
height=list(map(int,input().split()))
load=[[] for i in range(n+1)]
for i in range(m):
    tmp=list(map(int,input().split()))
    if tmp[1] not in load[tmp[0]]:
        load[tmp[0]].append(tmp[1])
    if tmp[0] not in load[tmp[1]]:
        load[tmp[1]].append(tmp[0])


answer=0

for i in range(1,n+1):
    if load[i]==[]:
        answer+=1
    while load[i] != []:
        if height[i-1]<=height[load[i][-1]-1]:
            break
        load[i].pop()
        if load[i] == []:
            answer+=1
        
print(answer)
            

Measured memory_bytes: 94628
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;

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

    for (int i = 0; i < k || s.size(); i++) {
        if (s[i] != '1') {
            cout << s[i] << endl;
            return 0;
        }
        if (i == k - 1) {
            cout << 1 << endl;
            return 0;
        }
    }
    //cout << s[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <string.h>

int main(){
  char  str[100];      //初期の入力
  char  out[100]={};      //出力用
  int   l, p=0;       //l:長さチェック p;行列の長さ把握

  scanf("%s",str);
  l = strlen(str);    //入力された文章の長さをチェック

  for(int i=0;i<l;i++){
    if(str[i] == '0'){
      out[p++] = '0';
    }
    if(str[i] == '1'){
      out[p++] = '1';
    }
    if(str[i] == 'B'){
      if(p!=0){
      out[--p]='\0';
      }
    }
  }
  printf("%s",out);

  return 0;
}


Measured memory_bytes: 128
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn is_palindrome(n:u32) -> bool {
    let mut dig:Vec<u32> = Vec::new();
    let mut rev:Vec<u32> = Vec::new();
    let mut m = n;
    while m > 0 {
        dig.push(m % 10);
        rev.push(m % 10);
        m /= 10;
    }
    rev.reverse();
    dig.iter().zip(rev.iter()).all(|(x,y)| x == y)
}

fn main() {
    let v = read_vec::<u32>();
    let mut count = 0;
    for n in v[0]..v[1]+1 {
        if is_palindrome(n) {
            count+=1;
        }
    }
    println!("{}",count);
}


Measured memory_bytes: 4352
#!/usr/bin/env python3
#ABC74 C

a,b,c,d,e,f = map(int,input().split())

s = f//(100*a)
t = f//(100*b)
u = f//c
v = f//d

concentration = 0
water = []
suger = []
for A in range(s+1):
    for B in range(t+1):
        if 100*a*A + 100*b*B != 0:
            water.append(100*a*A + 100*b*B)

for C in range(u+1):
    for D in range(v+1):
        suger.append(c*C + d*D)

ans1 = 0
ans2 = 0
for W in water:
    for S in suger:
        if W + S <= f:
            if W//100*e >= S:
                if concentration < S/(W+S):
                    concentration = S/(W+S)
                    ans1 = W+S
                    ans2 = S
if ans1 == 0:
    ans1 = 100*a
print(ans1,ans2)


Measured memory_bytes: 70836
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	string S;
	cin >> S;
	string U = "AKIHABARA";
	int k = 0;
	rep(i,U.size()){
		if(k < S.size() && U[i] == S[k])k ++;
		else {
			if(U[i] != 'A'){
				puts("NO");
				return 0;
			}
		}
	}
	if(k == S.size()){
		puts("YES");
	}
	else puts("NO");
}



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

int main(){
	int n, m, c;
	cin >> n >> m >> c;
	
	int b[m];
	for(int i=0; i<m; i++) cin >> b[i];
	
	int cnt=0;
	for(int i=0; i<n; i++){
		int sum=c;
		for(int j=0; j<m; j++){
			int a;
			cin >> a;
			sum += a*b[j];
		}
		if(sum>0) cnt++;
	}
	cout << cnt << endl;

}

Measured memory_bytes: 256
sentence = []
cnt = 0
for string in iter(input, "END_OF_TEXT"):
    if cnt == 0:
        w = string.lower()
    else:
        sentence.append(string.lower().rstrip(".").split())
    cnt += 1

w_cnt = 0

for s in sentence:
    w_cnt += sum([1 for i in s if i == w])

print(w_cnt)


Measured memory_bytes: 5564
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Get Everything
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 12;
const int NBITS = 1 << MAX_N;
const int MAX_M = 1000;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int dp[2][NBITS];

/* subroutines */

inline void setmin(int &a, int b) { if (a > b) a = b; }

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int nbits = 1 << n;

  fill(dp[0], dp[0] + nbits, INF);
  dp[0][0] = 0;
  int cur = 0, nxt = 1;

  for (int i = 0; i < m; i++) {
    int ai, bi;
    scanf("%d%d", &ai, &bi);
    int cbits = 0;
    for (int j = 0; j < bi; j++) {
      int ci;
      scanf("%d", &ci);
      ci--;
      cbits |= (1 << ci);
    }

    memcpy(dp[nxt], dp[cur], sizeof(dp[cur]));
    for (int bits = 0; bits < nbits; bits++)
      if (dp[cur][bits] < INF)
	setmin(dp[nxt][bits | cbits], dp[cur][bits] + ai);

    swap(cur, nxt);
  }

  printf("%d\n", (dp[cur][nbits - 1] >= INF) ? -1 : dp[cur][nbits - 1]);
  return 0;
}


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

using namespace std;

typedef long long ll;

void decode() {
	ll n;
	cin >> n;
	string s = "";
	while(n--) {
		s += (char)('a' + (n % 26));
		n /= 26;
	}
	reverse(s.begin(), s.end());
	cout << s << "\n";
}	
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	decode();
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll N;
    cin >> N;
    bool ok = true;
    rep(i, N) {
        ll a;
        cin >> a;
        if(a % 2 == 0) {
            if(a % 3 != 0 && a % 5 != 0) ok = false;
        }
    }
    if(ok) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define M 62
#define MAXN (400000)
#define MOD ((ll) 1e9 + 7)

ll s[M][MAXN][2];
ll a[MAXN];
ll n;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (ll i = 0; i < M; i++) {
		ll mask = (1LL << i);
		for (int j = n - 1; j >= 0; j--) {
			for (ll l = 0; l < 2; l++) {
				s[i][j][l] += s[i][j + 1][l];
				ll xmask = l << i;
				s[i][j][l] += (a[j] & mask) ^ xmask;
				s[i][j][l] %= MOD;
			}
		}
	}
/*	for (int j = 0; j < 4; j++) {
		for (int i = 0; i < n; i++) {
			for (int l = 0; l < 2; l++) {
				cerr << j << " " << i << " " << l << " " << s[j][i][l] << endl;
			}
		}
	}
*/
	ll ret = 0;
	for (int i = 0; i < n - 1; i++) {
		for (ll j = 0; j < M; j++) {
			ll b = (a[i] & (1LL << j)) >> j;
//			cerr << j << " " << i + 1 << " " << b << " " << s[j][i + 1][b] << " " << b << endl;
			ret += s[j][i + 1][b];
			ret %= MOD;
		}
	}
	cout << ret << endl;
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  vector<int> d(N);
  for (int i = 0; i < N; i++) cin >> d.at(i);
  
  long sum = 0;
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i != j) sum += d.at(i) * d.at(j);
    }
  }
  
  cout << sum / 2;
  
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b) { return a>b?a:b;}
ll min(ll a,ll b) { return a<b?a:b;}

void solve()
{
    int n;
    cin>>n;
    int t = 1000;
    while(t<n)
    {
      t+=1000;
    }
    cout<<(t-n);
}
int main() {
   //FT()
        solve();
    

    
    return 0;
}


Measured memory_bytes: 3616
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#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 rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<par<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m;
    cin>>n>>m;
    vector<set<int>> s(m);
    rep(i,m){
        int k;
        cin>>k;
        rep(j,k){
            int t;
            cin>>t;
            s[i].insert(t);
        }
    }
    vi p(m);
    rep(i,m)cin>>p[i];
    int ans=0;
    rep(i,1<<n){
        int t=0;
        rep(j,m){
            int c=0;
            for(int x:s[j]){
                if((i>>(x-1))&1)c++;
            }
            if(c%2==p[j])t++;
        }
        if(t==m)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
x = list(map(int,input().split()))
if n >= m:
    print(0)
else:
    x.sort()
    y = [x[i+1]-x[i] for i in range(m-1)]
    y.sort()
    sp = 0
    for i in range(n-1):
        sp += y[-i-1]
    print(x[m-1]-x[0]-sp)

Measured memory_bytes: 13968
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	for(int x=0;x<n;++x){
		float m1,m2;
		float x1,x2,y1,y2;
		scanf("%f %f %f %f",&x1,&y1,&x2,&y2);
		m1 = (y2-y1)/(x2-x1);
		scanf("%f %f %f %f",&x1,&y1,&x2,&y2);
		m2 = (y2-y1)/(x2-x1);
		if(m1==m2){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

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

using namespace std;
using std::vector;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x, y) x = max(x,y)
#define chmin(x, y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i, n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b != 0) return(gcd(b, a%b));
  return b;
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int main(){

  int n; cin >> n;
  vl v(n);
  vector<bool> flag(n, false);

  ll minv = linf;
  ll ans = 0;

  rep(i, n){
    cin >> v[i];
    if(v[i] > 0){
      flag[i] = true;
    }
    chmin(minv, abs(v[i]));
    ans += abs(v[i]);
  }

  rep(i, n - 1){
    if(!flag[i] and !flag[i + 1]){
      flag[i] = flag[i + 1] = true;
    }
  }

  int cnt = 0;
  rep(i, n){
    if(!flag[i]) 
      cnt++;
  }

  if(cnt % 2 == 1)
    pr(ans - 2 * minv);
  else
    pr(ans);
  
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main(void) {
	int a, b, c;

	cin >> a >> b >> c;

	if (a + b == c || a + c == b || b + c == a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x,0))
#define vec1(a,n) vector<int> a(n);rep(i,n)cin>>a[i]
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int a,b,t;
  cin>>a>>b>>t;
  int cnt=0;
  REP(i,1,100){
    if(a*i<=t) cnt +=b;
    else break;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
class MinCostFlow:
    INF = 10**18

    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap, cost):
        forward = [to, cap, cost, None]
        backward = forward[3] = [fr, 0, -cost, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

    def flow(self, s, t, f):
        N = self.N; G = self.G
        INF = MinCostFlow.INF

        res = 0
        H = [0]*N
        prv_v = [0]*N
        prv_e = [None]*N

        d0 = [INF]*N
        dist = [INF]*N

        while f:
            dist[:] = d0
            dist[s] = 0
            que = [(0, s)]

            while que:
                c, v = heappop(que)
                if dist[v] < c:
                    continue
                r0 = dist[v] + H[v]
                for e in G[v]:
                    w, cap, cost, _ = e
                    if cap > 0 and r0 + cost - H[w] < dist[w]:
                        dist[w] = r = r0 + cost - H[w]
                        prv_v[w] = v; prv_e[w] = e
                        heappush(que, (r, w))
            if dist[t] == INF:
                return None

            for i in range(N):
                H[i] += dist[i]

            d = f; v = t
            while v != s:
                d = min(d, prv_e[v][1])
                v = prv_v[v]
            f -= d
            res += d * H[t]
            v = t
            while v != s:
                e = prv_e[v]
                e[1] -= d
                e[3][1] += d
                v = prv_v[v]
        return res

N,K = map(int,input().split())
A = [list(map(int,input().split())) for i in range(N)]

G = MinCostFlow(2*N+2)
G.add_edge(0,2*N+1,10**18,10**9)

for i in range(N):
    G.add_edge(0,i+1,K,0)
    for j in range(N):
        G.add_edge(i+1,N+1+j,1,10**9-A[i][j])

for j in range(N):
    G.add_edge(N+1+j,2*N+1,K,0)

f = G.flow(0,2*N+1,N**2)
print(N*N*10**9-f)

res = [["." for j in range(N)] for i in range(N)]
for i in range(N):
    for w, cap, _, _ in G.G[i+1]:
        if N+1<=w<=2*N:
            j = w - (N+1)
            if cap==0:
                res[i][j] = "X"
for i in range(N):
    print("".join(res[i]))

Measured memory_bytes: 73008