akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main()
{
	int n;
	string taro;
	string hanako;
	int taro_c = 0;
	int hanako_c = 0;
	int taro_s = 0;
	int hanako_s = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> taro >> hanako;
		for (int j = 0; j < taro.size()+1; j++) {
			if (taro.substr(j, 1) > hanako.substr(j, 1)) {
				taro_c = 3;
				hanako_c = 0;
				break;
			}
			else if (taro.substr(j, 1) < hanako.substr(j, 1)) {
				hanako_c = 3;
				taro_c = 0;
				break;
			}
			else 
			{
				taro_c = 1;
				hanako_c = 1;
			}
		}
		taro_s += taro_c;
		hanako_s += hanako_c;
	}

	cout << taro_s << ' ' << hanako_s << endl;
	
	return 0;

}


Measured memory_bytes: 3164
N = int(input())
job_list = list()
for i in range(N):
    job_list.append(tuple(map(int, str(input()).split())))

job_list = sorted(job_list, key=lambda x: (x[1], x[0]))

time = 0
for i in range(N):
    time += job_list[i][0]
    if time > job_list[i][1]:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 88164
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int p(1), n; cin >> n;
	for (int i = 1; i <= n; i++)p = (p*i) % MOD;
	cout << p << endl;
	return 0;
}

Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

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

int main(void) {
    ll N;
    cin >> N;
    ll tmp = 1, ans = 0;
    while (tmp < N) {
        tmp *= 3;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

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

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int n,k; cin>>n>>k;
	if(n%k) cout<<1;
	else cout<<0;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<math.h>
#include<queue>
#include<stdio.h>
#include<stdlib.h>
#include<stack>
#include<string>
#include<vector>

#define ll long long
#define ull unsigned long long

using namespace std;
int main(void) {

	ll A[101] = { 0 },N = 0;

	scanf("%lld", &N);
	for (ll i = 0; i < N; i++)
		scanf("%lld", &A[i]);
	ll min = A[0], max = A[0];
	for (ll i = 0; i < N; i++) {
		if (A[i] < min)
			min = A[i];
		if (A[i] > max)
			max = A[i];
	}
	printf("%lld\n", max - min);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int b[10000];
signed main(){
  int a,c=0,d=10000;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b[i];
  }
  sort(b,b+a,greater<int>());
  for(int i=0;i<a;i++){
    if(d>b[i]){
      d=b[i];
      c++;
    }
  }
  cout<<c<<"\n";
  return(0);
}

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

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x; cin >> x;
    cout << x/500*1000+(x%500)/5*5; 
    cout << endl;
    return 0;
}

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

int main() {
  string S;
  int K;
  cin >> K >> S;
  int a;
  a = S.size();
  if(a <= K) {
    cout << S << endl;
  }
  else {
    for(int i = 0; i < K; i++) {
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
  
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  ll N; cin >> N;

  ll ans = 0;
  for(ll i = 1; i <= N; i++){
    if( i%3 == 0 || i%5 == 0){

    } else {
      ans += i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>

using namespace std;

#define PI 3.141592653589793
#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define RFOR(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)

class Dice{
public:
    Dice()
    {
        face = new int[6];
        move = new int[6];
    }
    ~Dice()
    {
        delete[] face;
        delete[] move;
    }
    void roll(char c)
    {
        REP(i,6) move[i]=face[i];
	if (c == 'L') setLabel(move[0],move[2],move[4],move[1],move[3],move[5]);
	else if (c=='E') setLabel(move[3],move[1],move[0],move[5],move[4],move[2]);
        else if (c=='N') setLabel(move[1],move[5],move[2],move[3],move[0],move[4]);
        else if (c=='S') setLabel(move[4],move[0],move[2],move[3],move[5],move[1]);
        else setLabel(move[2],move[1],move[5],move[0],move[4],move[3]);
    }
    void setLabel(int i,int n) {face[i] = n;}
    void setLabel(int f0,int f1,int f2,int f3,int f4,int f5)
    {
        face[0] = f0;
        face[1] = f1;
        face[2] = f2;
        face[3] = f3;
        face[4] = f4;
        face[5] = f5;
    }
    int getAns() {return face[2];}
  int getLabel(int s) {return face[s];}
  void setDice(int s1,int s2)
  {
    REP(i,4) {
      //cout << "s1/" << face[0] << ":" << face[1] << endl;
      if (face[0]==s1) {
	break;
      } else if (i==3) {
	roll('L');
	i=-1;
      }
      roll('N');
    }
    REP(i,4) {
      //cout << "s2/" << face[0] << ":" << face[1] << endl;
      if (face[1]==s2) break;
      roll('L');
    }
  }
private:
    int *face;
    int *move;
};

int main() {
  Dice d1,d2;
  int n,flag;
    string str;
    flag = 0;
    REP(i,6) {
        cin >> n;
        d1.setLabel(i,n);
    }
    REP(i,6) {
      cin >> n;
      d2.setLabel(i,n);
    }
    REP(i,4) {
      if(d1.getLabel(0) != d1.getLabel(1)) break;
      d1.roll('N');
      if (d1.getLabel(0) == d1.getLabel(1) && i==3) {
	d1.roll('L');
	i = -1;
      }
    }
    d2.setDice(d1.getLabel(0),d1.getLabel(1));
    REP(i,6) if (d1.getLabel(i)!=d2.getLabel(i)) ++flag;
    cout << (flag==0?"Yes":"No") << endl;
    return 0;
}


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

int main(){
    int k;
    cin >> k;
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k-1] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<map>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
const double PI=acos(-1);
using namespace std;
int main(){

  int n;
  while(cin>>n,n){
    vector<int>in(n);
    int co=0;
    rep(i,n)cin>>in[i];
    while(1){
      bool han=true;
      rep(i,in.size())if(in[i]!=i+1)han=false;
      if(han)break;
      co++;
      //cout<<"!"<<endl;
      int tmp=in.size();
      for(vector<int>::iterator it=in.begin();it!=in.end();it++){
	//cout<<"#"<<endl;
	(*it)--;
	if(!*it){in.erase(it);it--;}
      }
      in.push_back(tmp);
      if(co>10000)break;
    }
    if(co<=10000)cout<<co<<endl;
    else cout<<-1<<endl;
  }
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

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

	if(n%500 <= a)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    int count = 0;
    for (int i = 0; i < N; i++) {
        int minj = i;
        for (int j = i; j < N; j++) {
            if (vec.at(j) < vec.at(minj)) {
                minj = j;
            }
        }
        if (i != minj) {
            swap(vec.at(i), vec.at(minj));
            count++;
        }
    }
    for (int i = 0; i < N-1; i++) {
        cout << vec.at(i) << " ";
    }
    cout << vec.at(N-1) << endl;
    cout << count << endl;
}


Measured memory_bytes: 3136
n = int(input())
a = input()
a = a.split()

Max = 0
Min = 10 ** 9

for i in range(n):
    if int(a[i]) > Max:
        Max = int(a[i])
    if int(a[i]) < Min:
           Min = int(a[i])

print(Max - Min)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int MAX=1e6+10;
int a[MAX];
int main()
{
    int a, b;
    cin >> a >> b;
    if(a > b)cout << a-1 << endl;
    else cout << min(a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

bool check[110000];
int cnt,n;
int a[110000];
void dfs(int n){
  if(check[n])return;
  check[n]=1;
  if(n==2)return;
  cnt++;
  dfs(a[n]);
}
int main(){cout<<fixed<<setprecision(10);
           cin>>n;
           rep(i,1,n+1)cin>>a[i];
           dfs(1);
           if(check[2])cout<<cnt<<endl;
           else cout<<-1<<endl;
}

Measured memory_bytes: 4040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		char[] s = scanner.next().toCharArray();
		int N = s.length;
		int ap=0,tp=0;
		for(int i=0; i<N;i++) {
			if(s[i]=='p') tp++;
		}
		if(N%2==0) ap=N/2;
		else ap = (N-1)/2;
		System.out.println(ap-tp);
		scanner.close();
	}

}


Measured memory_bytes: 27940
#include "bits/stdc++.h"
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__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=1e6+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
  }
  
 	
void solve() {
     string s;
     cin>>s;
     int len=sz(s),maxi=0;
     rep(i,0,len) {
		   int ct=0;
		   if(s[i]=='R') {
			      ct++;
			      rep(j,i+1,len) {
					    if(s[j]=='R') ct++;
					    else break;
					  }
				maxi=max(maxi,ct);	  
			   }
		 }
		 
		 cout<<maxi<<endl;    
                       
}

    
int32_t main() {
	cool;
	int t=1;	
  
	//cin>>t;
	while(t--)
	  solve();

  return 0;	   
}


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

int main(){
	int N=3, A[N], i;
	
	for(i=0; i<N; i++){
		cin >> A[i];
	}
	
	int min, max;
	if(A[0]<=A[1] && A[0]<=A[2]){
		min = A[0];
		if(A[1]<=A[2])	max = A[2];
		else		max = A[1];
	}
	if(A[1]<=A[2] && A[1]<=A[0]){
		min = A[1];
		if(A[2]<=A[0])	max = A[0];
		else		max = A[2];
	}
	if(A[2]<=A[0] && A[2]<=A[1]){
		min = A[2];
		if(A[0]<=A[1])	max = A[1];
		else		max = A[0];
	}
	cout << max-min << endl;
	return 0;
}



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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

int_fast64_t gcd(int_fast64_t a,int_fast64_t b){
  if(b==0)return a;
  return gcd(b,a%b);
}

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

  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  sort(rng(A));

  vector<int>a(1000001);
  vector<bool>isprime(1000001,true);
  isprime[0]=isprime[1]=false;
  for(int i=0;i<=1000000;i++){
    if(isprime[i])for(int j=i+i;j<=1000000;j+=i){
      isprime[j]=false;
      a[j]=i;
    }
  }

  vector<vector<pii>>div(1000001);
  for(int i=0;i<=1000000;i++){
    int n=i;
    map<int,int>ans;
    while(a[n]!=0){
      ans[a[n]]++;
      n=n/a[n];
    }
    if(n!=0&&n!=1)ans[n]++;
    for(auto it:ans)div[i].push_back({it.first,it.second});
  }

  vector<int>prime;
  for(int i=0;i<=1000000;i++)if(isprime[i])prime.push_back(i);

  bool pairwise=true;
  vector<int>x(1000001,0);

  for(auto it:div[A[0]])x[it.first]=max(x[it.first],it.second);

  for(int i=0;i<N-1;i++){
    for(auto it:div[A[i+1]])if(min(x[it.first],it.second)!=0)pairwise=false;
    for(auto it:div[A[i+1]])x[it.first]=max(x[it.first],it.second);
  }

  int GCD=A[0];
  for(int i=0;i<N-1;i++)GCD=gcd(GCD,A[i+1]);
  bool setwise=(GCD==1);

  if(pairwise)cout<<"pairwise coprime"<<endl;
  else if(setwise)cout<<"setwise coprime"<<endl;
  else cout<<"not coprime"<<endl;

  return 0;
}


Measured memory_bytes: 81624
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long  LLINF = 1e15;

using namespace std;

string S;
string ans;
int p=0;
void parse(int cnt){
  if(p==S.size()) return;
  if(S[p] == '['){
    p++;
    int l = ans.size();
    parse(cnt);
    reverse(ans.begin()+l,ans.begin()+ans.size());
    p++;
    parse(cnt);
  }else if(S[p]==']'){
    return;
  }else if('A' <= S[p] && S[p] <= 'Z'){
    ans += 'A' + ((S[p]-'A'+cnt+2600000)%26);
    cnt = 0;
    p++;
    parse(cnt);
  }else if(S[p] == '?'){
    ans += 'A';
    cnt = 0;
    p++;
    parse(cnt);
  }else if(S[p] == '+'){
    cnt++;
    p++;
    parse(cnt);
  }else if(S[p] == '-'){
    cnt--;
    p++;
    parse(cnt);
  }
  return;
}

int main(){
  while(1){
    cin>>S;
    if(S==".") break;
    ans = "";
    p=0;
    parse(0);
    cout<<ans<<endl;
  }
  return 0;
}

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

S = input()

ans_L = []
for i in range(1, len(S) + 1):
    A = S[0:i + 1]
    B = S[i + 1:]
    l = set()
    for j in A:
        if j in B:
            l.add(j)
    ans_L.append(l)

ans = []
for i in ans_L:
    ans.append(len(i))
print(max(ans))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define w(x) int x; cin>>x; while(x--)
#define f(i,n) for(ll i=0;i<n;i++)
#define ff first
#define ss second
const ll INF = 1e18 + 5;

void ganekasar()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

void add_self(ll& a, ll b)
{
    a += b;

    if(a >= mod)
        a -= mod;
}

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

    vector<vector<ll>> can(n, vector<ll>(n));

    f(i, n) f(j ,n) cin>>can[i][j];

    vector<ll> dp(1<<n);
    
    dp[0] = 1;

    for(ll mask=0; mask < (1<<n)-1; mask++)
    {
        ll a = __builtin_popcount(mask);

        for(ll b=0; b<n; b++)
        {
            if(can[a][b] && !(mask & (1<<b)))
            {
                ll m2 = mask^(1<<b);
                add_self(dp[m2], dp[mask]);
            }
        }
    }

    cout<<dp[(1<<n)-1]<<endl;

    return 0; 
} 

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

int main() {
int n, arr[100], count=0;
cin>>n;
for(int i = 1; i <= n; i++){
    cin>>arr[i];
    if(arr[i] % 2 == 1 && i % 2 == 1)
        count +=1;
}
cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 3592
n = int(input())
t, a = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]

h_ = [t - x*0.006 for x in h]

ans = 0
d = float('inf')
for i,x in enumerate(h_):
    d_ = abs(a - x)
    if d > d_:
        d = d_
        ans = i+1

print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

bool check(int i, int j, int h, int w, const vector<string>& field) {
  if (field[i][j] == '.') return true;
  if (i > 0 && field[i - 1][j] == '#') return true;
  if (i < h - 1 && field[i + 1][j] == '#') return true;
  if (j > 0 && field[i][j - 1] == '#') return true;
  if (j < w - 1 && field[i][j + 1] == '#') return true;
  return false;
}

int main() {
  //
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  int x = *(a.rbegin());
  vi::iterator it = lower_bound(ALL(a), x / 2);
  int y = *it;
  if (it != a.begin()) {
    it--;
    if (abs(*it - x / 2) < abs(y - x / 2) || y == x) {
      y = *it;
    }
  }
  cout << x << " " << y << endl;
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (min(a, b) < c && c < max(a, b))print("Yes");
	else print("No");


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        a[i]=(x==y);
    }
    for(int i=0;i<n-2;i++)
    {
        if(a[i]&&a[i+1]&&a[i+2])
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}



Measured memory_bytes: 3592
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

a, b, c = MAP()

print(len(set((a,b,c))))

Measured memory_bytes: 3884
#include<iostream>
#include<string>

#define DD(x, y) cout << #x" = " << x << " "  << #y" = " << y << endl;

using namespace std;
using ll = long long;
using P = pair<int, int>;

bool visited[400][400];
string grid[400];
int h, w;
int di[] = {0, 0, -1, 1};
int dj[] = {-1, 1, 0, 0};

P dfs(int i, int j, bool black) {
    // DD(i, j)
    visited[i][j] = true;
    P ans = black ? make_pair(1, 0) : make_pair(0, 1);
    for (int k = 0; k < 4; ++k) {
        int ni = i + di[k];
        int nj = j + dj[k];
        if (ni < 0 || ni >= h) continue;
        if (nj < 0 || nj >= w) continue;
        if (visited[ni][nj]) continue;
        if (black && grid[ni][nj] == '#') continue;
        if (!black && grid[ni][nj] == '.') continue;
        P res = dfs(ni, nj, !black);
        ans.first += res.first;
        ans.second += res.second;
    }
    return ans;
}

int main() {
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        cin >> grid[i];
        for (int j = 0; j < w; ++j) {
            visited[i][j] = false;
        }
    }

    ll ans = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (!visited[i][j] && grid[i][j] == '#') {
                P res = dfs(i, j, true);
                ans += (ll)res.first * res.second;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 10752
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;

int main()
{
	string s, t;
	cin >> s >> t;

	map<char, vector<ll>> mp;
	rep(i, s.size())mp[s[i]].push_back(i);

	ll loop = 0;
	ll now = -1;
	for (char c : t) {
		if (mp.find(c) == mp.end()) {
			cout << -1 << endl;
			return 0;
		}

		auto itr = upper_bound(mp[c].begin(), mp[c].end(), now);
		if (itr == mp[c].end()) {
			loop++;
			now = -1;
			itr = upper_bound(mp[c].begin(), mp[c].end(), now);
		}
		now = *itr;
	}

	cout << loop * s.size() + now + 1 << endl;
	return 0;
}


Measured memory_bytes: 1728
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int a = s.charAt(0);
		int cnt = 1;
		for(int i = 1; i < n; i++){
			if(s.charAt(i) != a){
				cnt++;
				a = s.charAt(i);
			}
		}
		System.out.print(cnt);
	}

}

Measured memory_bytes: 24532
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
using namespace std;


int main() {
	string a, b, u;
	int a1, b1;
	cin >> a >> b >> a1 >> b1 >> u;
	if(u == a) cout << a1 - 1 << " " << b1;
	else cout << a1 << " " << b1 - 1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string o,e;
	cin>>o;
	cin>>e;
	int odd = 0, even = 0;
	for(int i = 1; i<=o.length()+e.length();i++)
	{
		if(i&1)
			cout<<o[odd++];
		else
			cout<<e[even++];
	}
	return 0;
}

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

int main(void){
    
    int N;
    float total = 0;
    cin >>N;
    
    for(int i=0;i<N;i++){
        float x_i;
        string u_i;
        cin >> x_i >> u_i;
        
        if(u_i == "JPY"){
            total += x_i;
        }
        else{
            total += (x_i * 380000.0); 
        }
    }
    cout << total << endl;
}

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

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<ll> a(N);
    ll amax = -1000000 - 1;
    ll amin = 1000000 + 1;
    int amax_ele, amin_ele;
    REP(i, N) {
        cin >> a[i];
        amax = max(amax, a[i]);
        if (amax == a[i]) amax_ele = i;
        amin = min(amin, a[i]);
        if (amin == a[i]) amin_ele = i;
    }
    if (amax == amin) {
        cout << 0 << endl;
        return 0;
    }
    
    VI x, y;
    
    if (abs(amax) >= abs(amin)) {
        REP(i, N) {
            if (a[i] < 0) {
                a[i] += amax;
                x.push_back(amax_ele);
                y.push_back(i);
            }
        }
        REP(i, N-1) {
            if (a[i] > a[i + 1]) {
                a[i + 1] += a[i];
                x.push_back(i);
                y.push_back(i + 1);
            }
        }
    }
    
    if (abs(amax) < abs(amin)) {
        REP(i, N) {
            if (a[i] > 0) {
                a[i] += amin;
                x.push_back(amin_ele);
                y.push_back(i);
            }
        }
        REP(i, N - 1) {
            if (a[N - 1 - i]  < a[N - 1 - (i + 1)]) {
                a[N - 1 - (i + 1)] += a[N - 1 - i];
                x.push_back(N - 1 - i);
                y.push_back(N - 1 - (i + 1));
            }
        }
    }
    cout << x.size() << endl;
    REP(i, x.size()) cout << x[i] + 1 << " " << y[i] + 1 << endl;
    return 0;
}


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

using namespace std;

int n, p;

int main (void)
{
	scanf("%d",&n);
	p=n%10;
	if (p==2||p==4||p==5||p==7||p==9) puts("hon");
	else if (p==0||p==1||p==6||p==8) puts("pon");
	else puts("bon");
	
	return 0;
}

Measured memory_bytes: 3764
#include<stdio.h>
int main(){
    char mon[10];
    char day[10];
    scanf("2019/%s/%s",mon,day);
    if(mon[0]=='1'){
        printf("TBD\n");
    }else{
        if(mon[1]=='1'||mon[1]=='2'||mon[1]=='3'||mon[1]=='4'){
            printf("Heisei\n");
        }else{
            printf("TBD\n");
        }
    }

}

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

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin>>n;
    vector<int> h(n);
    for(int i = 0;i<n;i++)
    {
        cin>>h[i];
    }
    // vector<int> dp(n, INT_MAX);
    // dp[0] = 0;
    // if(n == 1)
    // {
    //     cout<<dp[0]<<"\n";
    //     return 0;
    // }
    // dp[1] = abs(h[0] - h[1]);
    // if(n == 2)
    // {
    //     cout<<dp[1]<<"\n";
    //     return 0;
    // }
    int a = 0, b = abs(h[0] - h[1]);
    if(n == 1)
    {
        cout<<0<<"\n";
        return 0;
    }
    if(n == 2)
    {
        cout<<b<<"\n";
        return 0;
    }
    for(int i = 2;i<n;i++)
    {
        // dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1], abs(h[i] - h[i-2]) + dp[i-2]);
        int x = min(abs(h[i] - h[i-1]) + b, abs(h[i] - h[i-2]) + a);
        a = b;
        b = x;
    }
    // cout<<dp[n-1]<<"\n";
    cout<<b<<"\n";
    return 0;
}

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

int main(void){
  int n; 
  string s;
  cin>>n>>s;
  int n_b_all=0;
  for(int i=0; i<n; ++i){
    if( s[i] == '#') n_b_all++;
  }
  int min = n - n_b_all, n_b = 0;
  for(int i=0; i<n; ++i){
    if( s[i] == '#') n_b++;
    if( min > ((n - (i+1) - (n_b_all - n_b)) + n_b)) min = n - (i+1) - n_b_all + 2*n_b;
  }
  cout<<min<<endl;
  return 0;
}


Measured memory_bytes: 640
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000


int main() {
	double w, h, x, y;
	cin >> w >> h >> x >> y;
	cout << fixed << setprecision(8) <<w * h / 2 << " " << endl;
	if (y * 2 == h && x * 2 == w) cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
	int t, h, m, s;
	scanf("%d", &t);
	s = t % 60;
	m = (t % 3600) / 60;
	h = t / 3600;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}


Measured memory_bytes: 2692
#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 reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<lli>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


ll total[51];
ll paty[51];

ll rec(ll x, ll level){ 
    if(x==1){
        if(level == 0) return 1;
        else return 0;
    }
    if(1 < x && x <= total[level]/2) return rec(x-1, level-1);
    if(x == total[level]/2+1) return paty[level-1]+1;
    if(total[level]/2+1 < x && x <= total[level]-1) return paty[level-1] + 1 + rec(x - (total[level]/2+1), level-1);
    return paty[level];
}
    
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, x;
    cin >> n >> x;

    total[0] = 1;
    paty[0] = 1;
    rep(i, n){
        total[i+1] = 2*total[i] + 3;
        paty[i+1] = 2*paty[i] + 1;
    }

    cout << rec(x, n) << endl;

    return 0;
}

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

int main(void){
  int n;
  cin >> n;
  cout << (n+1)/2 << endl;
  return 0;
}

Measured memory_bytes: 3612
h, w = map(int, input().split())
if(h == 1 or w == 1):
    print(1)
else:
    cCol = -(-w // 2)
    cRow = -(-h // 2)
    fCol = w - cCol
    fRow = h - cRow
    print(cRow * cCol + fRow * fCol)


Measured memory_bytes: 2940
import java.util.*;

// ABC 6-C
// http://abc006.contest.atcoder.jp/tasks/abc006_3
 
public class Main {
	
	public static int state = 0; // 0 ==> c1 == c2. -1 ==>  c1 < c2. 1 ==> c1 > c2
	
	public static void main (String[] args) throws java.lang.Exception {
		Scanner in = new Scanner(System.in);

		
		char[] c1 = in.next().toCharArray();
		char[] c2 = in.next().toCharArray();
		
		if (c1.length > c2.length) {
			state = 1;
		} else if (c1.length < c2.length) {
			state = -1;
		} else {
			solve(c1, c2, 0);
		}
		if (state == -1) {
			System.out.println("LESS");
		} else if (state == 1) {
			System.out.println("GREATER");
		} else {
			System.out.println("EQUAL");
		}
	}
	
	public static void solve(char[] a, char[] b, int index) {
		if (index == a.length) {
			return;
		}
		if (a[index] < b[index]) {
			state = -1;
			return;
		} else if (a[index] > b[index]) {
			state = 1;
			return;
		} else {
			solve(a, b, index + 1);
		}
	}
}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repe(i, n) for(i = 0; i <= (n); i++)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int i;
    string s;
    cin >> s;
    for(i = 0; i < s.size(); i++) {
        if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D');
        else {cout << "No" << endl; return 0;}
        i++;
        if(i < s.size());
        else break;
        if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D');
        else {cout << "No" << endl; return 0;}
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

int main() {
    int N, L;
    std::cin >> N >> L;
    
    std::string temp;
    std::vector<std::string> S;
    for (auto i=0; i<N; ++i) {
        std::cin >> temp;
        S.push_back(temp);
    }
    std::sort(S.begin(), S.end());
    for (auto str : S) std::cout << str;
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    int x = sc.nextInt();
    int[] ary = new int[n];
    int sum = 0;

    for(int i = 0; i < n; i++){
      int k = 0;
      ary[i] = sc.nextInt();
      while(k * ary[i] + 1 <= d){sum++; k++;}
    }

    System.out.println(x+sum);


  }
}

/*
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String blank = sc.nextLine();
String s = sc.nextLine();
System.out.println();
System.exit(0)
*/


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define int long long
typedef pair<int,int>pii;
typedef vector<int> vi;
typedef vector<vi> vii;
const int mxN=2e5+5,M=1e9+7;
//did u check when n=1?
//is mxN correct?
//int mod(int a,int b){int ret=a%b;if(ret<0)ret+=b;return ret;}
string n;
int k;
int dp[mxN][105][2];//position,sum,limit
int solve(int pos,int m,int e){
    m%=k;
    if(pos==sz(n)){
        if(m==0)return 1;
        return 0;
    }
    if(dp[pos][m][e]!=-1)return dp[pos][m][e];
    int ans=0;
    int lim=9;
    if(e==1)lim=(int)(n[pos]-'0');
    for(int i=0;i<=lim;i++){
        int ne=e;
        if(ne==1 && i<lim)ne=0;
        ans=(ans+solve(pos+1,(m+i)%k,ne))%M;
    }
    return dp[pos][m][e]=ans%M;
}
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    memset(dp,-1,sizeof(dp));
    cin>>n>>k;
    int ans=(solve(0,0,1)-1)%M;
    cout << (ans < 0 ? ans+M:ans);
    
}

Measured memory_bytes: 329344
#include <bits/stdc++.h>
int n,a[205];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=2*n;i++) scanf("%d",&a[i]);
	std::sort(a+1,a+2*n+1);
	long long sum=0;
	for (int i=1;i<=2*n;i+=2) sum+=a[i];
	printf("%lld\n",sum);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vl p(m), y(m);
    map<ll, set<pii>> cnt;
    for (int i = 0; i < m; ++i) {
        cin >> p[i] >> y[i];
        cnt[p[i]].emplace(y[i], i);
    }
    vector<string> ret(m);
    for (auto &p : cnt) {
        string l = to_string(10000000 + p.first).substr(2, 6);
        int idx  = 1;
        for (auto &pp : p.second) {
            string r       = to_string(10000000 + idx).substr(2, 6);
            ret[pp.second] = (l + r);
            idx++;
        }
    }
    for (auto &r : ret) {
        cout << r << "\n";
    }
    return 0;
}

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


int main(){
  int n;
  scanf("%d",&n);
  int d[n],sum=0,ans=0;
  rep(i,n) {
    scanf("%d",&d[i]); 
    sum += d[i];
  }
  rep(i,n) ans += d[i]*(sum-d[i]);
  printf("%d",ans/2);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
using lint  =                           long long int;
using pint  =                           pair<int, int>;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD                             1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
    int N;
    cin>>N;
    vector<lint> A(N);
    cin>>A;
    lint ret = 0;
    REP(d,60){
        lint on = 0,off = 0;
        for(auto a : A) (((a>>d)&1) ? on: off)++;
        ret += (1LL<<d) % MOD * on % MOD*off%MOD;
    }
    cout<<ret%MOD<<endl;
}

int main(){   
  
 solve();

 return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (unsigned i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());

    int alice = 0;
    int bob = 0;
    for (unsigned i = 0; i < n; ++i) {
        if (i % 2 == 0) alice += a[i];
        else bob += a[i];
    }

    cout << alice - bob << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    string s_prime, t;
    cin >> s_prime >> t;

    string s = "UNRESTORABLE";
    for (int i = 0; i + static_cast<int>(t.size()) - 1 < static_cast<int>(s_prime.size()); i++) {
        string key = s_prime;
        bool restored = true;
        for (int j = 0; j < static_cast<int>(s_prime.size()); j++) {
            if (i <= j && j < i + static_cast<int>(t.size())) {
                if (key[j] == '?') {
                    key[j] = t[j - i];
                } else if (key[j] != t[j - i]) {
                    restored = false;
                }
            } else if (key[j] == '?') {
                key[j] = 'a';
            }
        }

        if (restored && (s == "UNRESTORABLE" || s > key)) {
            s = key;
        }
    }

    cout << s << endl;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
P=list(map(int,input().split()))
C=list(map(int,input().split()))
for i in range(N):
  P[i]-=1
INF=-(10**20)
X=[[INF]*(N+1) for i in range(N)]
Y=[0]*N
Z=[0]*N
R=[0]*N
S=set()
V=0
for i in range(N):
  S=set()
  V=i
  S.add(i)
  for j in range(N):
    V=P[V]
    if V in S:
      Z[i]=V
      break
  X[i][0]=0
  for j in range(N):
    Y[i]+=1
    V=P[V]
    X[i][j+1]=X[i][j]+C[V]
    if Z[i]==V:
      R[i]=X[i][j+1]
      break
A=INF
Q=0
T=0
U=0
D=0
E=0
for i in range(N):
  D=K
  V=i
  E=0
  for j in range(min(N,K)):
    if Z[i]==V:
      break
    V=P[V]
    E+=C[V]
    D-=1
  i=V
  D,K=K,D
  if R[i]<=0:
    for j in range(1,min(Y[i],K)+1):
      A=max(A,X[i][j]+E)
  else:
    S=max((K//Y[i])-1,0)
    Q=R[i]*S
    T=0
    U=INF
    V=i
    for j in range(K-S*Y[i]):
      V=P[V]
      T+=C[V]
      U=max(T,U)
    Q+=U
    A=max(A,Q+E)
  D,K=K,D
print(A)


Measured memory_bytes: 666056
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX_N 1050
#define MAX_M 1050

int N, M, A[MAX_N + 1], B[MAX_M + 1], V[MAX_N + 1];

int main()
{
	memset(V, 0, sizeof(V));

	cin >> N >> M;

	for (int i = 1; i <= N; i++)
		cin >> A[i];

	for (int i = 1; i <= M; i++)
		cin >> B[i];

	for (int i = 1; i <= M; i++)
	{
		for (int j = 1; i <= N; j++)
		{
			if (A[j] <= B[i])
			{
				V[j]++;

				break;
			}
		}
	}

	cout << distance(V, max_element(V, V + N)) << endl;

	return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((int)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define root sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : ' ');
  }
  // os << '}';
  return os;
}

int main()
{
  ll n, m, ans = 0LL;
  cin >> n >> m;
  vi a(m);
  cin >> a;
  rep(i, m)
  {
    ans += a[i];
  }
  if (n - ans >= 0)
  {
    cout << n - ans << endl;
  }
  else
  {
    cout << -1 << endl;
  }
}

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

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


Measured memory_bytes: 3584
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
ans = a.inject(:+)
sa = 10000000000000000000000000000
count  = 0
a.each_with_index do |i,j|
	count += i
    tmp = ans -  count
    all = tmp - count
  	if j != n - 1
        sa = [sa,all.abs].min
    end
end
puts sa


Measured memory_bytes: 28532
#include <bits/stdc++.h>
#define mn(a, b) (a < b ? a : b)
#define mx(a, b) (a > b ? a : b)
#define f first
#define s second
#define all(v) (v).begin(), (v).end()
#define base 331

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int const MAXn = 1e5 + 2;

vector < int > adya[MAXn];
vector < int > adya2[MAXn];
int f[MAXn];

int sol[MAXn];

int main(){

    //freopen(".in","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin>>n>>m;
    for(int i = 1; i <= m; i++){
        int n1, n2;
        cin>>n1>>n2;
        adya[n1].push_back(n2);
        adya2[n2].push_back(n1);
    }
    queue < int > cola;
    for(int i = 1; i <= n; i++){
        f[i] = adya[i].size();
        if(!f[i]) cola.push(i);
    }
    while(!cola.empty()){
        int v = cola.front();
        cola.pop();
        for(auto to: adya2[v]){
            f[to]--;
            sol[to] = sol[v] + 1;
            if(!f[to]) cola.push(to);
        }
    }
    int best = 0;
    for(int i = 1; i <= n; i++)
        best = mx(best, sol[i]);
    cout<<best;
    return 0;
}


Measured memory_bytes: 12032
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

    int n,q;
    cin >> n >> q;
    char last = '-';
    vector<int> acs;
    rep(i,n){
        char s;
        cin >> s;
        if(s == 'C' && last == 'A'){
            acs.push_back(i);
        }
        last = s;
    }

    rep(i,q){
        int l,r;
        cin >> l >> r;
        int start = lower_bound(all(acs), l) - acs.begin();
        int end = lower_bound(all(acs), r) - acs.begin();
        cout << end - start << '\n';
    }
    return 0;
}

Measured memory_bytes: 1148