akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

using namespace std;

int a, b, c, ans;

int main() {

	scanf("%d %d %d", &a, &b, &c);
	if (a == b && a == c) {
		printf("1");
	} else if (a != b && a != c && b != c) {
		printf("3");
	} else {
		printf("2");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'

int main() {
    int n;
    long long suma=0;
    cin >> n;
    int numeros[n];
    for(int i=1;i<=n;i++){
        numeros[i-1]=i;
    }
    for(int i=0;i<n;i++){
        if(numeros[i]%3==0 || numeros[i]%5==0){
            numeros[i]=0;
        }
    }
    for(int i=0;i<n;i++){
        suma+=numeros[i];
    }
    cout << suma << endl;
    return 0;
}


Measured memory_bytes: 7456
#include <bits/stdc++.h>
#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
int main(){
    int n,m;
    int t[20020],s[20020],d[20020];
    while(1){
        cin>>n>>m;
        if(n==0&&m==0)break;
        vector<pair<int,int> >V;
        REP(i,m){
            cin>>t[i]>>s[i]>>d[i];s[i]--;d[i]--;
            V.PB(MP(t[i],i));
        }
        bool infect[20020];
        memset(infect,false,sizeof(infect));
        infect[0]=true;
        sort(ALL(V));
        REP(i,V.size()){
            int sn=s[V[i].second],dn=d[V[i].second];
            if(infect[sn])infect[dn]=true;
        }
        int ans=0;
        REP(i,n){
            if(infect[i])ans++;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3536
#!/usr/bin/env python3
#第二回全国統一プログラミング王決定戦予選 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
if n % 2 == 0:
    print(n//2 - 1)
else:
    print(n//2)


Measured memory_bytes: 38468
N, M = map(int, input().split())
Doors = [list(map(int, input().split())) for _ in range(M)]
IDs = [0 for _ in range(N+1)]

for Door in Doors:
    IDs[Door[0] - 1] += 1
    IDs[Door[1]]     -= 1
   

for i in range(N):
    IDs[i+1] = IDs[i] + IDs[i+1]
    

res = 0
for i in range(N):
    if IDs[i] == M:
        res += 1
        
    
print(res)

Measured memory_bytes: 31416
c = []
c_diff = []

for i in range(3) :
    c.append([int(x) for x in input().split()])

for i in range(3) :
    c_min = min(c[i])
    c_diff.append([c[i][j] - c_min for j in range(3)])

if c_diff[0] == c_diff[1] == c_diff[2] :
    print('Yes')
else :
    print('No')

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

using namespace std;

int main(){
    long long int n;
    cin >> n;
    string t_string = "";

    vector<int> v(7,0);
 string s = "";
 char ch;
   while(1){
       int b;
       b = n%26;
       n = n/26;
       if(b==0){
            
         ch = 'z';
            n = n-1;
       }else{
            ch = b+96;
       }

      
      
       s = ch + s;
        //v.push_back(b+96);
       //printf("%c", b+96);
       //sprintf(ch, "%d", b);
       
       //cout << b << endl;
       

       if(n==0){break;}
    } 
    cout << s << endl;
    /*
    for(int i=v.size()-1; i>=0; i++){
        if(v[i] == 0) continue;
        else{
            printf("%c", v[i]);
        }
    }
    */
    //cout << t_string << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int h,w;
  cin>>h>>w;
  string s[h][w];
  char ap[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  for(int i = 0; i < h; i++)
  {
    for(int j = 0; j < w; j++)
    {
      cin>>s[i][j];
    }
  }
  for(int i = 0; i < h; i++)
  {
    for(int j = 0; j < w; j++)
    {
      if(s[i][j] == "snuke") {
        char let = toupper(ap[j]);
        cout << let << i + 1 << endl;
        return 0;
      }
    }
  }

  

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int n = sc.nextInt(), m = sc.nextInt(), q = sc.nextInt();
        int[][] loc = new int[m][2];
        int[][] ques = new int[q][2];
        int[][] count = new int[n][n];

        for (int i = 0; i < m; i++) {
            loc[i][0] = sc.nextInt() - 1;
            loc[i][1] = sc.nextInt() - 1;
        }
        for (int i = 0; i < q; i++) {
            ques[i][0] = sc.nextInt() - 1;
            ques[i][1] = sc.nextInt() - 1;
        }

        for (int i = 0; i < m; i++) {
            for (int j = loc[i][1]; j < n; j++) {
                count[loc[i][0]][j]++;
            }
        }
        for (int i = 0; i < q; i++) {
            int ans = 0;
            for (int j = ques[i][0]; j <= ques[i][1]; j++) {
                ans += count[j][ques[i][1]];
            }
            System.out.println(ans);
        }
    }
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class FPure {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> E(n + 1);
    for (int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        E[a].push_back(b);
    }

    auto bfs = [&](int v){
        queue<int> Q;
        Q.push(v);
        vector<bool> visited(n + 1);
        vector<int> pre(n + 1, -1);

        while (!Q.empty()){
            int u = Q.front(); Q.pop();
            for (const auto &e: E[u]){
                if (visited[e])
                    continue;
                visited[e] = true;
                pre[e] = u;
                Q.push(e);
            }

        }

        vector<int> res;
        if (pre[v] == -1)
            return res;
        int cur = v;
        res.push_back(v);
        while (pre[cur] != v){
            cur = pre[cur];
            res.push_back(cur);
        }

        return res;
    };

    vector<int> ans(n + 1);
    for (int i = 1; i <= n; i++){
        vector<int> tmp = bfs(i);
        if (!tmp.empty() and tmp.size() < ans.size())
            ans = tmp;
    }

    if (ans.size() > n){
        cout << -1 << endl;
        return;
    }

    cout << ans.size() << endl;
    copy(ans.begin(), ans.end(), ostream_iterator<int>(cout, "\n"));
}
};

int main() {
	FPure solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#define DEBUG 1
#include <bits/stdc++.h>
using namespace std;
typedef          char      s8;
typedef unsigned char      u8;
typedef          short    s16;
typedef unsigned short    u16;
typedef          int      s32;
typedef unsigned int      u32;
typedef          long int s64;
typedef unsigned long int u64;
typedef float             f32;
typedef double            f64;
#define rep(_i, _n) for (int _i = 0; _i < (int)(_n); _i++)
#if DEBUG
#define PHERE()			{ cerr << "L" << setw(3) << __LINE__ << ": PHERE" << clock() << endl; }
#define PVAL( _var )	{ cerr << "L" << setw(3) << __LINE__ << ":" << #_var "=" << (_var) << endl; }
#else
#define PHERE()
#define PVAL( _var )
#endif


int main()
{
	//////// 入力 ////////
	s64 N, M, K;
	cin >> N >> M >> K;
	
	s64 ASum[N];
	s64 AMax = -1;
	rep( i, N ) {
		cin >> ASum[i];
		if( i > 0 ) {
			ASum[i] += ASum[i-1];
		}
		if( AMax < 0 ) {
			if( ASum[i] > K ) {
				AMax = i;
			}
		}
	}
	if( AMax < 0 ) {
		AMax = N;
	}
	s64 BSum[M];
	s64 BMax = -1;
	rep( i, M ) {
		cin >> BSum[i];
		if( i > 0 ) {
			BSum[i] += BSum[i-1];
		}
		if( BMax < 0 ) {
			if( BSum[i] > K ) {
				BMax = i;
			}
		}
	}
	if( BMax < 0 ) {
		BMax = M;
	}
	
	/////////////////////
	
	s64 outMax = max( AMax, BMax );
//DEL 	for( s64 i = AMax-1; i >= 0; --i ) {
	for( s64 i = -1; i < AMax; ++i ) {
		s64 posMin = 0;
		s64 posMax = BMax;
		s64 find = -1;
		s64 curA = 0;
		if( i >= 0 ) {
			curA = ASum[i];
		}
		while(1) {
			s64 bPos = (posMin + posMax)/2;
			if( curA + BSum[bPos] <= K ) {
				posMin = bPos;
			}
			else {
				posMax = bPos;
			}
			if( posMax - posMin <= 1 ) {
				if( curA + BSum[posMin] <= K ) {
					find = posMin;
				}
				break;
			}
		}
		if( find >= 0 ) {
			if( i+find+2 > outMax ) {
				outMax = i+find+2;
			}
		}
#if 0
		for( s64 j = max(0,outMax - i - 1); j < BMax; ++j ) {
			if( ASum[i] + BSum[j] <= K ) {
				outMax = i+j+2;
			}
		}
#endif
	}
	
	
	//////// 出力 ////////
	cout << outMax;
	/////////////////////
	
	return 0;
}
#if 0
#endif


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

using namespace std;

int main()
{
    int N, answer = 0;

    cin >> N;
    vector<int> a(N);
    for (int count = 0; count < a.size(); count++)
    {
        cin >> a.at(count);
    }

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    for (int count = 0; count < a.size(); count++)
    {
        if (count % 2 == 0)
        {
            answer += a.at(count);
        }
        else
        {
            answer -= a.at(count);
        }
        
    }

    cout << answer << endl;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> l(m);
    vector<int> r(m);
    rep(i, m) {
        cin >> l[i] >> r[i];
    }

    sort(l.begin(), l.end(), greater<int>());
    sort(r.begin(), r.end());

    int ans = (r[0] - l[0] >= 0) ? r[0] - l[0] + 1 : 0;

    cout << ans << endl;
}


Measured memory_bytes: 1024
N = int(input())
prev = [0,0,0]
now = [0,0,0]
for i in range(N):
    acts = list(map(int,input().split()))
    for pi in range(3):
        for ni in range(3):
            if pi == ni:
                continue
            now[ni] = max(now[ni], prev[pi]+acts[ni])
    prev = now.copy()
print(max(now))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

int main()
{
    double x1, y1;
    cin >> x1 >> y1;
    double x2, y2;
    cin >> x2 >> y2;
    double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
    cout << std::fixed << std::setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 3264
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

  int answer = abs(a[N-1] - a[0]);

  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int zettai(int x){
  if(x>=0){
    return x;
  }
  else return -x;
}
 
int checker(int a, int b){
  if(zettai(a)>zettai(b)){
    return zettai(a)+zettai(b)*2;
  }
  else return zettai(a)*2+zettai(b);
}
int main(){
  int N, K; cin >> N >> K;
  vector<int> MY(N);
  for(int i=0;i<N;i++){
    cin >> MY.at(i);
  }
  int check=-1;
  for (int i=0;i<N;i++){
    if(MY.at(i)>=0){
      check=i;
      break;
    }
  }
  if(check==-1){
    cout << MY.at(N-K)*(-1) << endl;
    return 0;
  }
  if(check==0){
    cout << MY.at(K-1) << endl;
    return 0;
  }
  if(K==1){
    cout << min(MY.at(check), MY.at(check-1)*-1) << endl;
    return 0;
  }
  int count=300000000;
  for(int i=0;i<=min(check, N-K);i++){
    if(checker(MY.at(i), MY.at(i+K-1))<count){
      count=checker(MY.at(i), MY.at(i+K-1));
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;
using namespace atcoder;

typedef long long ll;

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

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

	int n, m;
	cin >> n >> m;

	int ans = 0;
	dsu uf(n);
	rep(i, m){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		uf.merge(a, b);
	}

	set<int> st;
	rep(i, n){
		st.insert(uf.leader(i));
	}

	cout << st.size() - 1 << endl;
}


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

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

Measured memory_bytes: 256
// B - RGB Boxes

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	int R, G, B, N;
	cin >> R >> G >> B >> N;

	ll ans = 0;

	for (int r=0; r*R <= N; r++) {
		for (int g=0; r*R + g*G <= N; g++) {
			if ((N - r*R - g*G) % B == 0) ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3632
/*
 * 2019年  2月 25日 月曜日 12:20:59 JST
 */

#include <bits/stdc++.h>
using namespace std;

using P = pair<int, int>;

const int N_MAX = 8;
const int INF = 1000*8     * 100;

int N, A[3];
int l[N_MAX];
int dp[3+1][(1<<N_MAX)];

P dfs(int idx, int state, const int used, const int num_bumboo, const int target){
  if(idx == num_bumboo){
    int length = 0;
    int mp = 0;
    for(int i = 0; i < N; i++){
      if((state & (1<<i))){
        length += l[i];
        mp+=10;
      }
    }
    mp += abs(target - length) - 10;
    return make_pair(mp, state);
  }

  P res = make_pair(INF, 0);
  for(int i = 0; i < N; i++){
    if((used & (1 << i)) || (state & (1 << i))){
      continue;
    }
    P r = dfs(idx+1, state | (1 << i), used, num_bumboo, target);
    res = min(res, r);
  }
  return res;
}

int calc(int target_idx, int prv, int nxt){
  vector<int> pop;
  for(int i = 0; i < N; i++){
    if((nxt & (1 << i)) && !(prv & (1 << i))){
      pop.push_back(i);
    }
  }
  if(pop.size() <= 0) return INF;
  int sum = 0;
  for(int i = 0; i < (int)pop.size(); i++){
    sum += l[pop[i]];
  }
  return 10*pop.size()-10 + abs(sum - A[target_idx]);
}

int main(void){
  cin >> N >> A[0] >> A[1] >> A[2];
  for(int i = 0; i < N; i++){
    cin >> l[i];
  }

  for(int i = 0; i <= 3; i++){
    for(int j = 0; j < (1<<N_MAX); j++){
      dp[i][j] = INF;
    }
  }

  dp[0][0] = 0;
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < (1<<N); j++){
      for(int l = 0; l < (1<<N); l++){
        if((j & l) != j) continue;
        dp[i+1][l] = min(dp[i+1][l], dp[i][j] + calc(i, j, l));
      }
    }
  }

  int ans = INF;
  for(int j = 0; j < (1<<N); j++){
    ans = min(ans, dp[3][j]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=100005,INF=1<<28;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,W,H;cin>>N>>W>>H;
        int maxi=-1;
        if(N==0) break;
        
        vector<vector<int>> A(H,vector<int>(W));
        
        for(int i=0;i<N;i++){
            int a,b;cin>>a>>b;
            a--;b--;
            A[b][a]++;
        }
        
        int S,T;cin>>S>>T;
        
        for(int i=0;i+T-1<H;i++){
            for(int j=0;j+S-1<W;j++){
                int cnt=0;
                for(int k=0;k<T;k++){
                    for(int l=0;l<S;l++){
                        cnt+=A[i+k][j+l];
                    }
                }
                maxi=max(maxi,cnt);
            }
        }
        
        cout<<maxi<<endl;
    }
}



Measured memory_bytes: 3176
/** "Ever tried.
         Ever failed.
               No matter.
                   Try Again.
                        Fail again.
                             Fail better.**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define pb push_back
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define Unique(n)        (n).erase(unique(s(n)), (n).end())
#define NumofDigits(n)   ((long long)log10(n)+1)
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-9;
const int MOD = 1e9+7;
/*
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
int dx[] = {- 1, 0, 0, 1, 0 };
int dy[] = { 0,- 1, 1, 0, 0 };*/
void File()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}

int arr[105],a[105];
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>arr[i],a[i]=arr[i];
    int m;
    cin>>m;
    while(m--)
    {
        ll sum=0;
        int p,x;
        cin>>p>>x;
        a[p]=x;
        for(int i=1;i<=n;i++)
            sum+=a[i];
        cout<<sum<<endl;
        for(int i=1;i<=n;i++)
            a[i]=arr[i];
    }
}


Measured memory_bytes: 3612
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
C = Counter(a)
if len(C) == 1:
    if a[0] == 0:
        print('Yes')
    else:
        print('No')
elif len(C) == 3:
    v = list(C.keys())
    if v[0] ^ v[1] != v[2]:
        print('No')
        quit()
    x = C[a[0]]
    for k in C:
        if C[k] != x:
            print('No')
            quit()
    print('Yes')
else:
    if 0 not in C:
        print('No')
        quit()
    for k in C:
        if k != 0:
            if C[k] == 2 * C[0]:
                print('Yes')
            else:
                print('No')
            break


Measured memory_bytes: 14468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string L;
    cin >> L;
    ll N = L.size();
    ll over = 0, not_over = 1;
    reverse(L.begin(), L.end());
    rep(i,0,N){
        if(L[i] == '1'){
            not_over *= 3;
            not_over += over;
            not_over %= MOD;
            over *= 2;
            over %= MOD;
        }else{
            over = over * 3 + not_over * 2;
            over %= MOD;
        }
    }
    print(not_over);

    
}

Measured memory_bytes: 512
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
A=get_i
puts A.inject(0){|res,x| res.gcd(x)}

Measured memory_bytes: 11532
#include <iostream>
#include <string>
#include <set>
#include <map>

using namespace std;


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

  int a[13] = {-1, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  
  int x,y;
  cin >> x >> y;

  if(a[x] == a[y]){
	cout << "Yes" << endl;
  }else{
	cout << "No" << endl;
  }
  

  return 0;
}


Measured memory_bytes: 256
function Main(input) {
  const ary = input
                .trim()
                .split(" ")
                .map(n => Number(n))
                .sort((a,b) => b - a)
  ary.shift()
  const ans = ary.reduce((a,b) => a + b)
  console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 11468
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    auto s = readln.chomp;
    writeln(s.canFind('9') ? "Yes" : "No");
}


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

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

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

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

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

int N;
map<vector<int>, int> vis;
int ans;

void dfs(int d, vector<int> &A, bool first)
{
    if (first) {
        if (!vis.count(A) || d < vis[A]) vis[A] = d;
    } else {
        if (vis.count(A)) ans = min(ans, d + vis[A]);
    }
    if (d == 4) return;

    for (int i=0; i<N; i++) {
        for (int j=i+1; j<N; j++) {
            reverse(A.begin() + i, A.begin() + j + 1);
            dfs(d+1, A, first);
            reverse(A.begin() + i, A.begin() + j + 1);
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);

    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    ans = N-1;
    dfs(0, A, true);
    vector<int> B(N); iota(B.begin(), B.end(), 1);
    dfs(0, B, false);
    cout << ans << endl;

#ifdef DEBUG
    cerr << vis.size() << endl;
    for (auto v : vis) {
        cerr << "(";
        rep(i, N) cerr << v.first[i] << ", ";
        cerr << ") " << v.second << endl;
    }
#endif
}

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

int main(){
    int N; cin >> N;
    int p[N];
    for(int i=0; i<N; i++) cin >> p[i];
    int count = 0;
    for(int i=1;i<=N;i++){
        if(p[i-1] != i) count++;
    }
    if(count<=2) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
<?php
$points = explode(" ",trim(fgets(STDIN)));
$distances[0] = $points[1] - $points[0];
if ($distances[0] < 0) {
    $distances[0] *= -1; 
}
$distances[1] = $points[2] - $points[0];
if ($distances[1] < 0) {
    $distances[1] *= -1;
}
if ($distances[0] > $distances[1]) {
    echo "B";
} else {
    echo "A";
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(n),b(n),c(m),d(m),l(n);
  for (int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  for (int i=0;i<m;i++){
    cin >> c[i] >> d[i];
  }
  for (int i=0;i<n;i++){
    int dis=400000001;
    for (int j=0;j<m;j++){
      if(dis>abs(a[i]-c[j])+abs(b[i]-d[j])){
        dis=abs(a[i]-c[j])+abs(b[i]-d[j]);
        l[i]=j+1;
      }
    }
    cout << l[i] << endl;
  }
}

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

#define ll long long int

int main()
{
    int n;
    string s;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        if (s == "Y")
        {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
}


Measured memory_bytes: 256
a = sorted(list(map(int, input().split())))
plus = 0
if a[0] % 2 == a[1] % 2 and a[1] % 2 == a[2] % 2:
    pass
else:
    plus = 1
    if a[0] % 2 == a[1] % 2:
        a[0] += 1
        a[1] += 1
    elif a[0] % 2 == a[2] % 2:
        a[0] += 1
        a[2] += 1
    else:
        a[1] += 1
        a[2] += 1
print(a[-1] - (a[0] + a[1]) // 2 + plus)

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
using namespace std;
const int MAX = 1e5 + 10; //N
const ll MOD = 1e9 + 7;
int N, M, K, Q;

vector<int> mv[2];
int dest[2];
int dp[16010][4010];

int rec(int pos, int op, int dir, bool f) {
	if (op == mv[dir].size()) {
		if (pos == dest[dir]) return 1;
		else return 0;
	}
	int &ret = dp[pos][op];
	if (ret != -1) return ret;
	ret = 0;
	if (f) {
		ret = rec(pos + mv[dir][op], op + 1, dir, 0);
	}
	else {
		ret = rec(pos + mv[dir][op], op + 1, dir, 0);
		ret |= rec(pos - mv[dir][op], op + 1, dir, 0);
	}
	return ret;
}

int main()
{
	int i, j;
	string s;
	cin >> s;
	scanf("%d %d", &dest[0], &dest[1]);
	dest[0] += 8000;
	dest[1] += 8000;
	
	i = 0;
	int n = s.size();
	int dir = 0;
	bool f = false;
	if (s[0] == 'F') f = true;
	while (i < n) {
		int Fcnt = 0;
		int Tcnt = 0;
		while (i < n && s[i] == 'T') Tcnt++, i++;
		while (i < n && s[i] == 'F') Fcnt++, i++;
		if (Tcnt % 2 == 1) dir = !dir;
		if(Fcnt) mv[dir].push_back(Fcnt);
	}


	memset(dp, -1, sizeof(dp));
	int a = rec(8000, 0, 0, f);
	memset(dp, -1, sizeof(dp));
	int b = rec(8000, 0, 1, 0);
	if (a&&b) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 251264
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#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 all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (string S; cin >> S && S != "$";) {
		int K; cin >> K;
		char cnt[128] = {};
		rep(i, 0, S.size()) {
			cnt[S[i]]++;
		}
		int ans = 0;
		if (cnt[S[0]] == S.size()) {
			ans = S.size() * K / 2;
		}
		else if (S.size() > 1 && K >= 2 && S.front() == S.back()) {
			vector<int> v;
			int t = 1;
			rep(i, 0, S.size() - 1) {
				if (S[i] == S[i + 1])
					t++;
				else {
					v.push_back(t);
					t = 1;
				}
			}
			v.push_back(t);
			dump(v);
			rep(i, 0, v.size()) {
				ans += v[i] / 2 * K;
			}
			if (v.front() % 2 && v.back() % 2)
				ans += K - 1;
		}
		else {
			vector<int> v;
			int t = 1;
			rep(i, 0, S.size() - 1) {
				if (S[i] == S[i + 1])
					t++;
				else {
					if (t > 1) v.push_back(t);
					t = 1;
				}
			}
			if (t > 1) v.push_back(t);
			dump(v);
			rep(i, 0, v.size()) {
				ans += v[i] / 2 * K;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main () {
	int n,ans=0;
	cin>>n;
	int x[n+5];
	for(int i=1; i<=n; i++){
		cin>>x[i];
	}
	int j=0;
	for(int i=1; i<n; i++){
		if(x[i]<x[i+1]){
			j=0;
			}
		else{ j++;
		}
		if(j>ans){
			ans=j;
		}
	}
	
	cout<<ans<<endl;
}


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

int main() {
    /*変数定義，入力*/
    int N, K;
    cin >> N >> K;
    int d[K];
    bool A[N] = {false};
    int a;
    rep(i, K){
        cin >> d[i];
        rep(j, d[i]){
            cin >> a;
            A[a - 1] = true;
        }
    }
    
    int counter = 0;
    rep(i, N){
        if(!A[i]) counter ++;
    }
    cout << counter << endl;

    /*終了*/
    return 0;
}

Measured memory_bytes: 3636
def soinsuubunkai(listdata):
    cnt = 0
    for i in listdata:
        while True:
            if i % 2 == 0:
                cnt += 1
                i /= 2
            else:
                break
    return cnt

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

print(soinsuubunkai(a))

Measured memory_bytes: 4148
/*
    BY - Darkworld1 ( Tanu kumar )
    college - AIT
    Problem - contest ( div 3 )
*/
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define rep(i,a,n) for( int i = a ; i < n ; i++ )
#define prep( i, a , n ) for ( int i = a ; i>= n ; i--)
#define   pr pair<int,int>
const int N = 13 , M=N,inf=(int)1e9;
const int mod=1e9+7;
int fastAbs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
ll ans = 1;
map< pair<int,int> , int > mp;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
ll memo[101100][100];
ll combination(ll n, ll r){
    if( memo[n][r] ) return memo[n][r];
    if( r == 0 || r == n) return memo[n][r] = 1;
    return memo[n][r] = (combination(n-1, r-1) + combination(n-1, r)) % mod;
}
void solve(){

      ll n , m ;
      cin >> n >> m ;
      ll x = m ;
      for( ll i = 2 ; (i * i) <= x ; i++ ){
                    int cnt = 0 ;
                    while( m%i == 0){
                        m/= i ;
                        cnt++;
                    }
                    if( cnt ){
                    ans = (ans * combination(n+cnt-1, cnt)) % mod;
                    }
      }
      if( m != 1) ans = (ans * n)%mod;
      cout << ans ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}
/*
    ---------------- lemmas-----------------------------------
   1)
   2)
   3)

*/


Measured memory_bytes: 83072
#include <stdio.h>
#include <iostream>
#include <string>
#include <map>
int main(void){
        std::map<std::string, int> r;
        std::map<std::string, int> b;
        int n,m;
        std::string key;
        std::cin >> n;
        for(int i=0;i<n;i++){
                std::cin >> key;
                if(b[key] != 0){
                        b[key] += 1;
                }else{
                        b[key] = 1;
                }
        }
        std::cin >> m;
        for(int i=0;i<m;i++){
                std::cin >> key;
                if(b[key] != 0){
                        b[key] -= 1;
                }else{
                        b.insert(std::make_pair(key,-1));
                }
        }
        int max = 0;
        for(std::map<std::string, int>::iterator i = b.begin();i != b.end();++i){
                if(i->second > max){
                        max = i->second;
                }
        }
        printf("%d",max);
        return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int x[6]={};
    for(int i=0;i<6;i++){
        cin>>x[i];
    }
    int y[6][5]={{1,2,4,3,1},{0,3,5,2,0},{0,1,5,4,0},{0,4,5,1,0},{0,2,5,3,0},{1,3,4,2,1}};
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int A,B,a=0,b=0,c=0;
        cin>>A>>B;
        while(1){
            if(x[a]==A){
                break;
            }
            a++;
        }
        while(1){
            if(x[b]==B){
                break;
            }
            b++;
        }
        while(1){
            if(b==y[a][c]){
                break;
            }
            c++;
        }
        
        cout<<x[y[a][c+1]]<<endl;
    }

    return 0;
}


Measured memory_bytes: 3092
import math

a,b,h,m = map(int,input().split())
if h ==0:
    h=12
mi=m
if m==0:
    mi=60

tns = a*(math.sin((2*math.pi/720)*(h*60+m)))
tnc = a*(math.cos((2*math.pi/720)*(h*60+m)))
tys = b*(math.sin((2*math.pi/60)*mi))
tyc = b*(math.cos((2*math.pi/60)*mi))

print(math.sqrt((tns-tys)**2+(tnc-tyc)**2))

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pcase cout<<"Case "<<++cs<<": "
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define mp make_pair
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int m, d, cnt = 0; cin>>m>>d;
    for(i = 4; i <= m; i++){
        for(j = 22; j <= d; j++){
            int a, b; a = j % 10, b = j / 10;
            if(a>=2 && b>=2 && a*b == i) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int check(int a,int b,int c){ //OK なら１をかえす
    int flag=0;
    if(a < b && b < c)  flag=1;
    if(a > b && b > c)  flag=1;
    return flag;
}


int main(){
    int n;
    int p[25];
    int count=0;
    cin>>n;
    for(int i=0;i<n;i++) cin>>p[i];
    for(int i=0;i<n-2;i++){
        if(check(p[i], p[i+1], p[i+2])) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
string in[101];
int main()
{
	int n;
	cin>>n>>in[1];
	for(int i=2; i<=n; i++)
		{
			cin>>in[i];
			string a=in[i],b=in[i-1];
			if(a[0]!=b[b.size()-1])
				{
					cout<<"No";
					return 0;
				}
			for(int j=1; j<i; j++)
				if(!in[j].compare(in[i]))
					{
						cout<<"No";
						return 0;
					}
		}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N,M=map(int, input().split())
#スイッチN,電球M
S=[[0]*N for _ in range(M)]
for i in range(M):
  ks=map(int, input().split())
  for j,s in enumerate(ks):
    if j==0:
      continue
    S[i][s-1]+=1


P=list(map(int, input().split()))
S=np.array(S)
P=np.array(P)
#スイッチにつけtかた 
ans=0
for i in range(2**N):
  now=np.zeros(M)
  for j in range(N):
    if i>>j&1==1:
      #スイッチONの時
      now+=S[:,j]
  #print((now%2).astype(int))
  ans+=int(((now%2)==P).all())
  #print(i,j,now)
#print(P)
print(ans)

Measured memory_bytes: 12500
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n)for(int i=0;i<n;i++)
int N,M;
int P[100000],Y[100000];
vector<int>yd[100001];
int main()
{
scanf("%d%d",&N,&M);
rep(i,M)scanf("%d%d",&P[i],&Y[i]),yd[P[i]].push_back(Y[i]);
rep(i,N)sort(yd[i+1].begin(),yd[i+1].end());
rep(i,M)printf("%012lld\n",ll(P[i])*1000000+int(lower_bound(yd[P[i]].
begin(),yd[P[i]].end(),Y[i])-yd[P[i]].begin())+1);
}

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

using namespace std;

typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vector<ll> vs;
  for(int i = 0; i < n; i++)
  {
	ll v;
	cin >> v;
	if(vs.empty() or vs.back() != v)
	{
	  vs.push_back(v);
	}
  }

  if(n == 1)
  {
	cout << 1 << endl;
  }
  else
  {
	int count = 1;
	bool isInc = vs[0] < vs[1];
	for(int i = 1; i < vs.size() - 1; i++)
	{
	  if((isInc && vs[i] > vs[i + 1]) ||
		 (!isInc && vs[i] < vs[i + 1]))
	  {
		count++;
		if(i < vs.size() - 2)
		{
		  isInc = vs[i + 1] < vs[i + 2];
		}
	  }
	}
	cout << count << endl;
  }
}


Measured memory_bytes: 1400
#include<stdio.h>
#include<math.h>
#include<float.h>
#define  DB_MAX 30


int main (void){
	
	long int n,dis[1001]={},manD=0,eucD=0,p3D=0,cheD=0,d,i,t,k;
	long int disx[1001]={},x;
	long int disy[1001]={},y;
	long int max=0;
	double che,l2,l,cheDD,cheDDD;
	x=0;
	y=0;
	
	scanf("%ld",&n);
	//x??§?¨?
	for(i=0;i<n;i++){
		scanf("%ld",&disx[i]);
	}
	//y??§?¨?
	for(i=0;i<n;i++){
		scanf("%ld",&disy[i]);
	}
	
	for(i=0;i<n;i++){
	
	x=disx[i];
	y=disy[i];
	d=x-y;
	
	if(d<0){
		d = -1*d;
	}
	if(max<d){
		max=d;
	}
	//p=1
	manD +=d;
	
	//p=2
	eucD += d*d;
	
	//p=3
	
	p3D += d*d*d;
	}
	printf("%lf\n",(double)manD);
	printf("%lf\n",sqrt(eucD));
	printf("%lf\n",pow(p3D,1.0/3.0));
	printf("%lf\n",(double)max);

return 0;
}

Measured memory_bytes: 688
#pragma gcc optimize (o3)
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first
#define ll long long
#define ld long double
#define U unsigned
#define pi acos(-1)

using namespace std;

const ll N = 1e5;

ll dp[N], arr[N], n;

ll solveI()
{
    for(int i = n-1 ; i > 0 ; i--)
    {
        dp[i] = 1e18;
        if(i+1<=n) dp[i] = min(dp[i], dp[i+1] + abs(arr[i] - arr[i+1]));
        if(i+2<=n) dp[i] = min(dp[i], dp[i+2] + abs(arr[i] - arr[i+2]));
    }
    return dp[1];
}

int main()
{
    scanf("%lld", &n);
    for(int i = 1 ; i <= n ; i ++) scanf("%lld", arr+i);
    printf("%lld", solveI());
    return 0;
}


Measured memory_bytes: 1792
/* Author : Pranav Deshmukh
            PICT,Pune
   Purpose: Practice Atcoder
*/

#include<bits/stdc++.h>
using namespace std;

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int             long long
#define dip(type,var)   type var; cin>>var;
#define dipi(x)			int x; cin>>x;
#define w(x)            int x; cin>>x; while(x--)
#define mka(arr,n,type) type *arr=new type[n];
#define fo(i,n)			for(int i=0;i<n;i++)
#define mod             pow(10,9)+7
#define inf             1e18
#define pi 				3.141592653589793238
#define fo(i,n)        for(int i=0;i<n;i++)
#define endl			"\n"
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mimp             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >

void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {
	c_p_c();
	dipi(n);
	dipi(m);
	cout << ((n * (n - 1)) / 2) + ((m * (m - 1)) / 2);
}

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

using namespace std;

int main(void) {
  int A, B, C; cin >> A >> B >> C;
  int D = max(A, max(B, C));

  if ((A + B + C) % 2 == 1) {
    if (D % 2 == 1) {
      cout << (D*3 - A - B - C) / 2 << endl;
    } else {
      cout << ((D+1)*3 - A - B - C) / 2 << endl;
    }
  } else {
    if (D % 2 == 0) {
      cout << (D*3 - A - B - C) / 2 << endl;
    } else {
      cout << ((D+1)*3 - A - B - C) / 2 << endl;
    }
  }
  return 0;
}

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

using namespace std;

#define int long long

const int mod = 1e9 + 7;

int bp(int a, int b) {
    if (b == 0) return 1;
    int val = bp(a, b / 2);
    if (b % 2) return (((val * val) % mod) * a) % mod;
    return (val * val) % mod;
}

int obr(int a) {
    return bp(a, mod - 2);
}

void solve() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i) cin >> a[i];
    int ans = 0;
    for (int i = 0; i < 60; ++i) {
        int cnt = 0;
        for (int j = 0; j < n; ++j) if (a[j] & (1ll << i)) ++cnt;
        //cout << cnt << ' ' << ans << ' ';
        ans = (ans + ((cnt * (n - cnt)) % mod) * ((1ll << i) % mod)) % mod;
        //cout << ans << '\n';
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define mp make_pair
#define pb push_back
using namespace std; 
typedef long long ll; 
int main()
{
	// freopen("ARC088-C.in", "r", stdin); 
	ll l, r; 
	scanf("%lld%lld", &l, &r); 
	int ans = 0; 
	while (l <= r)
	{
		ans++; 
		l <<= 1; 
	}
	printf("%d\n", ans);
	return 0; 
}


Measured memory_bytes: 256
parseInt(x) = parse(Int,x)
function main()
  s = readline()
  y,m,d = map(parseInt,split(s,'/'))
  if y<2019
    println("Heisei")
  elseif y>2019
    println("TBD")
  elseif m<=4
    println("Heisei")
  else
    println("TBD")
  end
end
main()


Measured memory_bytes: 164752
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K, sum = 0;
  cin >> N >> K;
  vector<int> vec(N);
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    A.at(i) = min(vec.at(i), K - vec.at(i));
    sum += A.at(i);
  }
  cout << sum*2 << endl;
}

Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const ll MOD = 1e9 + 7;

void add(ll &a, ll b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
}
const int MX = 55;

ll dp[MX][MX][2 * MX];
int n;
ll cnk[MX][MX];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	for (int i = 0; i < MX; ++i)
		for (int j = 0; j < MX; ++j) {
			if (i == j || j == 0)
				cnk[i][j] = 1;
			else if (j > i)
				cnk[i][j] = 0;
			else
				cnk[i][j] = (cnk[i - 1][j] + cnk[i - 1][j - 1]) % MOD;
		}
	cin >> n;
	dp[0][0][MX] = 1;
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j)
			for (int k = 0; k < 2 * MX; ++k) {
				for (int a = 0; j + a < n; ++a)
					for (int b = 0; j + a + b < n; ++b) {
						if (a + b == 0)
							continue;
						if (k - MX > b)
							continue;
						if (MX - k > a)
							continue;
						int nk = k - MX;
						int na = a + nk;
						int nb = b - nk;
						nk = na - nb + MX;
						if (nk >= 0 && nk < 2 * MX)
							add(dp[i + 1][j + a + b][nk], dp[i][j][k] * cnk[j + a + b][a] % MOD * cnk[j + b][b] % MOD);
					}
			}
		add(ans, dp[i][n - 1][MX + 1] * n % MOD);
		add(ans, dp[i][n - 1][MX] * n % MOD);
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 2560
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int N;
	scanf("%d", &N);
	int P[N], Q[N], perm[N];
	for (int i = 0; i < N; ++i) scanf("%d", &P[i]);
	for (int i = 0; i < N; ++i) scanf("%d", &Q[i]);
	for (int i = 0; i < N; ++i) perm[i] = i + 1;
	int x = 0;
	int ptr = 0;
	while (next_permutation(perm, perm + N)) {
		++ptr;
		bool mat = true;
		for (int i = 0; i < N; ++i) {
			if (perm[i] != P[i]) mat = false;
		}
		if (mat) x -= ptr;
		mat = true;
		for (int i = 0; i < N; ++i) {
			if (perm[i] != Q[i]) mat = false;
		}
		if (mat) x += ptr;
	}
	printf("%d", x > 0 ? x : -x);
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
LL a, b;
LL x, y;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    x = y = 0;
    forn(i, n) {
        cin >> a >> b;
        LL mul = max((x + a - 1) / a, (y + b - 1) / b);
        if (i == 0) {
            mul = 1;
        }
        x = a * mul;
        y = b * mul;
        //cerr << x << ' ' << y << endl;
    }
    cout << x + y << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,s,a;
  a=1;
  string str;
  cin>>n>>str;
  s=str.size();
  for(int i=0; i<s; i++){
    str.at(i)=str.at(i)+n;
    if(str.at(i)>90){
      str.at(i)=str.at(i)-26;
    }
  }
  cout<<str;
}

Measured memory_bytes: 256
w = input()
a = "abcdefghijklmnopqrstuvwxyz"
co = 0
ch = True
for i in a:
    for j in w:
        if i == j:
            co += 1
    if co % 2:
        ch = False
        break
    co = 0
    
    
if ch:
    print("Yes")
else:
    print("No")


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

const int mod = 1e9 + 7;

namespace {
  inline int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
  inline int mul(int x, int y) { return 1LL * x * y % mod; }
  inline int kissme(int x, int y = mod - 2) {
    int c = 1;
    for(; y; y >>= 1, x = mul(x, x)) {
      if(y & 1) c = mul(c, x);
    }
    return c;
  }
}

int n;

int main(void) {
  scanf("%d", &n);
  vector<int> fac(n + 1, 1), ifac(n + 1), ele(n + 1);
  for(int i = 1, pw = 3; i <= n; i++, pw = mul(pw, 3)) {
    ele[i] = mul(n, mul(n - i + 1, pw));
    fac[i] = mul(fac[i - 1], ele[i]);
  }
  ifac[n] = kissme(fac[n]);
  for(int i = n - 1; i >= 1; i--) {
    ifac[i] = mul(ifac[i + 1], ele[i + 1]);
  }
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    ans = add(ans, mul(ifac[i], fac[i - 1]));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12032
#include<iostream>

using namespace std;

int main(){

  int b, r, g, c, s, t;

  while(1){
    cin >> b >> r >> g >> c >> s >> t;

    if(b==0&&r==0&&g==0&&c==0&&s==0&&t==0) break;

    int sum = 100;

    sum += 16 * b * 5;
    sum += 16 * r * 3;
    sum += b * 15;
    sum += r * 15;
    sum += g * 7;
    sum += c * 2;
    t -= s;
    sum -= t * 3;

    cout << sum << endl;
  }

  return 0;
}


    

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

int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  vector<int> r(n);
  int i;
  int ans = 0;
  for(i = 0; i < n; i++)
  {
    cin >> v.at(i);
  }
  for(i = 0; i < n; i++)
  {
    cin >> c.at(i);
    r.at(i) = v.at(i)-c.at(i);
  }
  sort(r.begin(), r.end());
  for(i = n-1; i >= 0; i--)
  {
    if(r.at(i) > 0)
    {
      ans += r.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int r,d,x,t,f;
	scanf("%d %d %d",&r,&d,&x);
	t=x;
	for (int i = 0; i < 10; ++i)
	{
		f=r*t-d;
		printf("%d\n",f);
		t=f;
	}
}

Measured memory_bytes: 128