akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    int n = size(s) + size(t);
    string ans = "";
    for(int i = 0; i < n; i++) {
        if(i & 1 ^ 1) ans += s[i / 2];
        else ans += t[(i - 1) / 2];
    }
    cout << ans << endl;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e9 + 7

using namespace std;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void)
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (((((max(a, b) - min(a, b)) <= d) && ((max(b, c) - min(b, c)) <= d)) || (((max(a, c) - min(a, c))) <= d)) ? "Yes" : "No") << endl;
    return 0;
}

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

bool kaibun(string s){
    string t = s;
    bool res = false;
    reverse(t.begin(),t.end());
    if(s == t){
        res = true;
    }else{
        res = false;
    }
    return res;
}

int main(void){
    bool ans;
    string s;
    cin >> s;
    bool ans1 = kaibun(s);
    int n = s.size();

    string t = s.substr(0,(n-1)/2);
    bool ans2 = kaibun(t);

    string u = s.substr((n+1)/2);
    bool ans3 = kaibun(u);

    if(ans1 && ans2 && ans3){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

void solve() {
	int N, M; cin >> N >> M;
	vector<pair<int, int>> cities[100001];
	int pref, year;
	rep(i, M) {
		scanf("%d%d", &pref, &year);
		cities[pref].push_back({ year, i });
	}

	pair<int, int> res[100001];
	for (int i = 1; i <= N; i++) {
		sort(cities[i].begin(), cities[i].end());
		for (int j = 0; j < cities[i].size(); j++) {
			res[cities[i][j].second] = { i, j + 1 };
		}
	}

	rep(i, M) printf("%06d%06d\n", res[i].first, res[i].second);
}

int main(void) {
	solve();

	return 0;
}

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  int cnt=0;
  for(int i=0;i<n-2;i++){
    if(s[i]=='A'){
      if(s[i+1]=='B'){
        if(s[i+2]=='C'){
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}

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

int main() {
	int x, y;
	for (int i = 1;; i++) {
		cin >> x >> y;
		if (x == 0 && y == 0)break;
		if (x > y) swap(x, y);
		cout << x << " " << y << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
ll modpow(ll a, ll n=MOD-2, ll mod=MOD){ // a^n % MOD の計算
    ll res = 1;
    while (n > 0){
        if(n & 1) res = res * a % mod;
        a = a * a  % mod;
        n >>= 1;
    }
    return res;
}
//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    sort(ALL(A),greater<ll>());
    // 全体の場合の数*それを取る確率*(それより左の個数の期待値+1)*それ
    // 2^(N*2)*(1/2)*
    ll ans=0;
    ll ans2=modpow(2,N*2-1);
    ll han=modpow(2);
    vector<ll> B(N,0);
    rep(i,N){
        ans+=A[i]*(1+(han*i)%MOD);
        ans%=MOD;
    }
    ans*=ans2;
    ans%=MOD;
    cout<< ans <<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; k < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  int K;
  cin >> N >> K;
  string S;
  cin >> S;
  if(S[K-1] == 'A') {
    S[K-1] = 'a';
  } else if(S[K-1] == 'B') {
    S[K-1] = 'b';
  } else {
    S[K-1] = 'c';
  }
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
/*╔═══╗──╔╗╔╗───────────────────╔╗────────╔═══╦═══╗
  ║║─║╠╗╠╗╔╣╚═╦══╦═╗╔╦╗╔═╗╔══╦══╣╚═╦╦══╦══╣║─║║║─╚╝
  ║╔═╗║╚╝║╚╣║║║╚╝║║─╔╦╗║║║║╚╝║╚╝║╚╝║║║═╬══║╔═╗║╚╩═║
  ╚╝─╚╩══╩═╩╝╚╩══╩╝─╚╩╝╚╝╚╩══╩══╩══╩╩══╩══╩╝─╚╩═══╝*/
#include<bits/stdc++.h>
#define mod 1000000007
#define modc 998244353
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define deb(x) cout << #x << " " << x << endl;
#define deb2(x,y) cout << #x << " " << x << " " <<  #y << " " << y << endl
#define deb3(x,y,z) cout << #x << " " << x << " " << #y << " " << y << " " << #z << " "  << z << endl;
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define nl cout << "\n"
using namespace std;
template <class T>
string to_binary(T n)
{
	string binaryNum;
	int i = 0;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
		i++;
	}
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
template<class T>
bool perfectSq(T n)
{
	if(sqrt(n) == floor(sqrt(n)))
		return true;
	else
		false;
}
template<class T>
void print(T &v)
{
	for(auto x : v)
		cout << x << " " ;
	nl;
}
void solve()
{
	int i,j;
	ll sum = 0,prod = 1;
	ll n,k;
	cin >> n >> k;
	ll arr[n+1];
	for(i=1;i<=n;i++)
		cin >> arr[i];
	map<int,int>b;
	sum =0;
	int curr = 1;
	int next;
	while(1)
	{
		sum++;
		next = arr[curr];
		if(sum == k)
		{
			cout << next << endl;
			return;
		}
		if(b[next])
			break;
		b[next] = sum;
		curr = next;
	}
	int cycle = sum - b[next];
	ll rem = k - sum;
	ll ayush = rem%cycle;
	curr = next;
	while(ayush--)
	{
		next = arr[curr];
		curr = next;
	}
	cout << next << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	while(t--)
	{
		solve();
	}
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    int n;
    cin >> n;
    if(n>=400 && n<600)
        cout << 8 << endl;
    else if(n>=600 && n<800)
        cout << 7 << endl;
    else if(n>=800 && n<1000)
        cout << 6 << endl;
    else if(n>=1000 && n<1200)
        cout << 5 << endl;
    else if(n>=1200 && n<1400)
        cout << 4 << endl;
    else if(n>=1400 && n<1600)
        cout << 3 << endl;
    else if(n>=1600 && n<1800)
        cout << 2 << endl;
    else if(n>=1800 && n<2000)
        cout << 1 << endl;

	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int w[300010],c[300010],f[300010];
int V,n,mx;
int main(){
    scanf("%d%d",&V,&n);
    for(int i=1; i<=n; i++){
        scanf("%d%d",&w[i],&c[i]);
        mx=max(mx,w[i]);
    }
    memset(f,0x3f,sizeof f);
    f[0]=0;
    for(int i=1; i<=n; i++)
        for(int j=w[i]; j<=V+mx; j++)
            f[j]=min(f[j],f[j-w[i]]+c[i]);
    int ans=f[V];
    for(int i=V+1;i<=V+mx;++i){
        ans=min(f[i],ans);
    }
    printf("%d\n",ans);
    return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    int sum = 0;
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
        sum += A[i];
    }
    sort(A.rbegin(), A.rend());

    bool flag = true;
    rep(i, M) {
        if(double(A[i])/sum<1.0/4/M)
            flag = false;
    }

    flag ? cout << "Yes": cout << "No";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
k = gets.to_i

min = Float::INFINITY

["a","b"].repeated_permutation(n).each do |ptn|
    total = 1
    ptn.each do |m|
        if m=="a"
            total*=2
        else
            total+=k
        end
    end
    min = [min, total].min
end

p min

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A1,A2,A3;
  cin>>A1>>A2>>A3;
    vector<int>vec={A1,A2,A3};
  sort(vec.begin(),vec.end());
  cout<<vec.at(2)-vec.at(0)<<endl;
}
    
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int d[10][10];
int n,k;
bool ok=true;
void dfs(int now, int m){
  if(now<n){
    rep(i,0,k){
        dfs(now+1, m^d[now][i]);
    }
  }else{
    if(m==0) ok=false;
  }
  return ;
}
int main(){
  int n,k;  cin >>n>>k;
  vector<int> v(n);
  map<ll,ll> ma;
  rep(i,0,n){
    cin >> v[i];
    ma[v[i]]++;
  }
  priority_queue<ll,vector<ll>, greater<ll> > que;
  for(auto j : ma){
    que.push(j.se);
  }
  ll sum = 0;
  while(que.size()>k){
    sum += que.top();
    que.pop();
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 15732
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			scanner.nextLine();
			int a[] = new int[n];
			IntStream.range(0, n).forEach(i -> a[i] = scanner.nextInt());
			scanner.nextLine();
			int average = (int) Math.round(Arrays.stream(a).average().getAsDouble());
			System.out.println(Arrays.stream(a).map(i -> (i - average) * (i - average)).sum());
		}
	}
}


Measured memory_bytes: 30928
def floor_sum(n, m, a, b):
    ans = 0
    if a >= m:
        ans += (n - 1) * n * (a // m) // 2
        a %= m
    if b >= m:
        ans += n * (b // m)
        b %= m

    y_max = (a * n + b) // m
    x_max = (y_max * m - b)
    if y_max == 0:
        return ans
    ans += (n - (x_max + a - 1) // a) * y_max
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a)
    return ans


def atcoder_practice2_c():
    T = int(input())
    for _ in range(T):
        N, M, A, B = map(int, input().split())
        print(floor_sum(N, M, A, B))

if __name__ == "__main__":
    atcoder_practice2_c()


Measured memory_bytes: 76744
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;
int dp[10005][105];
const int inf = 10000000;
int main(){
    int n,h;
    cin>>h>>n;
    vector <int> a(n+1,0);
    vector <int> b(n+1,0);
    rep(i,n){
        cin>>a[i]>>b[i];
    }
 
    for(int j=0;j<=h;j++){
        dp[j][0]=(j+a[0]-1)/a[0]*b[0];
    }

    for(int i=1;i<n;i++){
        for(int j=0;j<=h;j++){
            if(j<=a[i]){
                dp[j][i]=min(dp[j][i-1],b[i]);
            }else{
                dp[j][i]=min(dp[j][i-1],dp[j-a[i]][i]+b[i]);
            }
        }
    }
    /**
    rep(i,h+1){
        rep(j,n){
            cout <<dp[i][j]<< " "; 
        }
        cout<<endl;
    }**/

    cout<<dp[h][n-1]<<endl;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) cin >> L[i];
  unordered_map<int, int> counts;
  for (int l : L) counts[l]++;
  sort(L.begin(), L.end());
  L.erase(unique(L.begin(), L.end()), L.end());

  int answer = 0;
  N = L.size();
  for (int a = 0; a < N; a++) {
    for (int b = a + 1; b < N; b++) {
      for (int c = b + 1; c < N; c++) {
        if (L[a] + L[b] > L[c] && L[b] + L[c] > L[a] && L[c] + L[a] > L[b]) {
          answer += counts[L[a]] * counts[L[b]] * counts[L[c]];
        }
      }
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3644
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
ll a,b;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a>>b;
	if(a<=b)cout<<"unsafe";
	else cout<<"safe";
	return 0;
}


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

#define int long long

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

/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/

int N, A, B, S[100001];
int mod = 1e9 + 7;

// Binary Indexed Tree(1-indexed)
const int MAX_N = 100001;

struct BIT {
    int n, bit[MAX_N + 1] = {};

    int sum(int i) {
        int s = 0;
        while (i > 0) {
            s += bit[i];
            s %= mod;
            i -= i & -i;
        }
        return s;
    }

    void add(int i, int x) {
        while (i <= n) {
            bit[i] += x;
            bit[i] += mod;
            bit[i] %= mod;
            i += i & -i;
        }
    }
};

signed main() {
    cin >> N >> A >> B;
    S[0] = -2e18;
    for (int i = 1; i <= N; i++) {
        cin >> S[i];
    }
    if (A > B)
        swap(A, B);
    for (int i = 3; i <= N; i++) {
        if (S[i] - S[i - 2] < A) {
            cout << 0 << endl;
            return 0;
        }
    }
    int last_zero = 0;
    BIT dp = {N + 1};
    dp.add(1, 1);
    for (int i = 1; i <= N; i++) {
        int lb = -1, ub = N;
        while (ub - lb > 1) {
            int mid = (lb + ub) / 2;
            if (S[i] - S[mid] >= B) {
                lb = mid;
            } else {
                ub = mid;
            }
        }
        dp.add(i + 1, dp.sum(lb + 1));
        if (S[i] - S[i - 1] < A) {
            for (int j = last_zero; j < i - 1; j++) {
                dp.add(j + 1, -dp.sum(j + 1));
            }
            last_zero = i - 1;
        }
    }
    cout << dp.sum(N + 1) << endl;
    return 0;
}

Measured memory_bytes: 1920
import scala.annotation.tailrec

object Main extends App {

  import scala.io.StdIn._
  import scala.math._


  val Array(n, q) = readLine.trim.split(' ').map(_.toInt)
  val history = List.tabulate(n){_ ⇒
    val Array(y, n) = readLine.trim.split(' ')
    (y.toInt, n)
  }
  println(
    history.foldLeft("kogakubu10gokan"){
      case (_, (year, next)) if year <= q ⇒ next
      case (prev, _) ⇒ prev
    }
  )
  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}



Measured memory_bytes: 44136
#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;
typedef vector<vector<ll>> vvl;
#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()
ll MOD = 1000000007;
ll INF = 1e18;

int main() {
  //
  ll n, k;
  cin >> n >> k;
  vector<pll> dt;
  rep(i, n) {
    ll t, d;
    cin >> t >> d;
    dt.push_back({d, t});
  }

  ll cur = 0;
  sort(ALL(dt), greater<pll>());
  unordered_set<ll> used_t;
  priority_queue<ll, vl, greater<ll>> used_second;
  priority_queue<ll> unused_first;
  ll types = 0;
  rep(i, n) {
    ll d = dt[i].first;
    ll t = dt[i].second;
    if (i < k) {
      if (used_t.find(t) == used_t.end()) {
        used_t.insert(t);
        types++;
      } else {
        used_second.push(d);
      }
      cur += d;
    } else {
      if (used_t.find(t) == used_t.end()) {
        used_t.insert(t);
        unused_first.push(d);
      }
    }
  }
  cur += types * types;
  ll ans = cur;
  while (!used_second.empty() && !unused_first.empty()) {
    ll remove = used_second.top();
    used_second.pop();
    ll add = unused_first.top();
    unused_first.pop();
    cur = cur - remove + add;
    cur += types * 2 + 1;
    types++;
    ans = max(ans, cur);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6256
#include<stdio.h>
int main(void){
	int r,g,b,sum;
	scanf("%d",&r);
	scanf("%d",&g);
	scanf("%d",&b);
	sum=r*100+g*10+b;
	if(sum%4==0){
		printf("YES");
	}else{
		printf("NO");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll int128_t
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
int const mod = 998244353;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x){
    return power(x,mod-2,mod);
}

int const N = 5e5+5;
int const inf = 2e16;

void solve(){  
    int i,j;
    long double pi = 6.28318530717958623200/2.0;
    int n;cin>>n;
    long double cir = 2.0 * pi;
    cir = cir * (ld)n;
    cout<<fixed<<setprecision(10)<<cir<<endl;
}             


int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}


/*

*/

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int dp(int n,int k,int h[])
{
    int d[n];d[0]=0;
    for(int i=1;i<n;i++)
    d[i]=INT_MAX;
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i+j<n)
            d[i+j]=min(d[i+j],d[i]+abs(h[j+i]-h[i]));
        }
    }
    return d[n-1];
}
int main()
{
    fastio;
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++)
    cin>>h[i];
    cout<<dp(n,k,h)<<endl;
    return 0;
}


Measured memory_bytes: 1024
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	n <- readInt
	as <- map pred <$> readInts
	mapM_ print $ solve as

solve as = runST $ do
	let
		n = length as + 1
	res <- newArray ( 0, n - 1 ) 0 :: ST s ( STUArray s Int Int )
	forM_ ( zip as [ 1 .. ] ) $ \( a, i ) -> do
		modifyArray res a succ
	getElems res

Measured memory_bytes: 35984
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b;
	if(b*2>=a){
		cout<<0;
	}else{
		cout<<a-b*2;
	}
	return 0;
}

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

#define mod 1000000007
#define maxn 1000005

int n;
ll a[maxn], b[maxn];
ll k;

bool cmp(int x, int y) { return x > y; }
bool C(ll m)
{
    ll res = 0;
    for (int i = 1; i <= n; i++)
    {
        if (a[i] * b[i] <= m)
            continue;
        res += ceil(1.0 * (a[i] * b[i] - m) / b[i]);
    }
    if (res <= k)
        return 1;
    return 0;
}

int main()
{
    //freopen("monotonic.in", "r", stdin);
    //freopen("monotonic.out", "w", stdout);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        scanf("%lld", &a[i]);
    for (int i = 1; i <= n; i++)
        scanf("%lld", &b[i]);
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1, cmp);
    ll l = -1, r = 1e13;
    while (r - l > 1)
    {
        ll m = (r + l) / 2;
        if (C(m))
            r = m;
        else
            l = m;
    }
    printf("%lld\n", r);

    return 0;
}

Measured memory_bytes: 5888
#include<iostream>
using namespace std;
int main(){
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(x-r<0||x+r>W||y-r<0||y+r>H){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    long double a, b;
    long double c;

    cin >> a >> c;

    ll sum = (a * c + 0.000000000001);

    cout << sum << endl;
}

Measured memory_bytes: 3748
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0

for a in range(int(X/500)+1):
  if a <= A:
    for b in range(int((X-a*500)/100)+1):
      if b <= B:
        if a+b+int((X-a*500-b*100)/50) >= 1 and int((X-a*500-b*100)/50) <= C:
          cnt = cnt + 1
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) cin >> x[i];
    copy(x.begin(), x.end(), y.begin());
    sort(y.begin(), y.end());
    for (int k : x) {
        if (k <= y[n/2-1]) cout << y[n/2  ] << endl;
        else               cout << y[n/2-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3712
fun main(array: Array<String>) {
    val s = readLine() ?: return
    val t = readLine() ?: return

    val candidates = 0.until(s.length - t.length + 1).mapNotNull {
        val candidate = s.substring(it, it + t.length)
        candidate.forEachIndexed { i, c ->
            if (t[i] != c && c != '?') {
                return@mapNotNull null
            }
        }
        Pair(it, candidate)
    }
    if (candidates.isEmpty()) {
        println("UNRESTORABLE")
        return
    }
    val c = candidates.last()
    val a = (s.substring(0, c.first) + t + s.substring(c.first + c.second.length, s.length))
        .replace("?", "a")
    println(a)
}


Measured memory_bytes: 38096
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AExpired solver = new AExpired();
        solver.solve(1, in, out);
        out.close();
    }

    static class AExpired {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            if (b <= n) {
                out.println("delicious");
            } else if (b <= a + n) {
                out.println("safe");
            } else {
                out.println("dangerous");
            }
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

        public void close() {
        }

    }
}



Measured memory_bytes: 23504
a,b,c,d=map(int,input().split())
flag="F"
while flag=="F":
  c=c-b
  if c<=0:
    flag="Y"
  else:
    a=a-d
    if a<=0:
      flag="N"
if flag=="Y":
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9176
N = int(input())
a = list(map(int,input().split()))
sum = 0
for n in range(N-1):
    if a[n] > a[n+1]:
        dif = a[n] - a[n+1]
        a[n+1] = a[n+1] + dif
        sum += dif
print(sum)

Measured memory_bytes: 32240
N, M = map(int, input().split())
i = 1
j = N
for m in range(M):
    l, r = map(int, input().split())
    i = max(i,l)
    j = min(j,r)
ans = j + 1 - i
if ans < 0:
    print(0)
else:
    print(ans)

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

typedef pair<int,int> P;

int main(){
	int H,W;
	cin >> H >> W;
	vector<string> M(H);
	rep(i,H){ cin >> M[i]; }
	vector<int> dx = {0,1,0,-1};
	vector<int> dy = {1,0,-1,0};

	int ans = 0;
	for(int a=0; a<W; a++){
	  for(int b=0; b<H; b++){
	  	if(M[b][a]=='#')continue;
	  	for(int c=0; c<W; c++){
	  	  for(int e=0; e<H; e++){
	  	  	if(M[e][c]=='#')continue;

	P s(a,b);
	P g(c,e);

	queue<P> que;
	que.push(s);
	vector<vector<int>> d(H,vector<int>(W,-1));
	d[s.second][s.first] = 0;
	while(!que.empty()){
		P p = que.front(); que.pop();
		int x = p.first, y = p.second;
		// printf("(%d,%d)\n",x,y);
		if(x==g.first && y==g.second)break;
		for(int i=0; i<4;  i++){
			int u = dx[i], v = dy[i];
			if(x+u<W && x+u>=0 && y+v<H && y+v>=0 && M[y+v][x+u]=='.' && d[y+v][x+u]==-1){
				d[y+v][x+u] = d[y][x] + 1;
				que.push(make_pair(x+u,y+v));
			}
		}
	}

	ans = max(ans, d[g.second][g.first]);

	  	  }
	  	}
	  }
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
// 2020-06-22 19:55:55
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  const ll INF = 1e18;
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<vector<ll> > dp(n+1, vector<ll>(3, -INF));
  ll x = n % 2 + 1;
  dp[0][0] = 0;
  rep(i, n) repc(j, x) {
    if((i+j)%2==0) {
      chmax(dp[i+1][j], dp[i][j] + a[i]);
      if(j < x) chmax(dp[i+1][j+1], dp[i][j]);
    } else {
      chmax(dp[i+1][j], dp[i][j]);
    }
  }
  cout << max(dp[n][x], dp[n][x-1]) << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 15568
#include<stdio.h>
#include<math.h>

typedef struct{
  double x;
  double y;
}point;

void koch(int n,point a,point b){
  point s,t,u;
  
  if(n==0) return;
  
  double th=M_PI*60.0/180.0;
  
  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}

int main(){
  point p1,p2;
  int n;

  scanf("%d",&n);
  p1.x=0;
  p1.y=0;
  p2.x=100;
  p2.y = 0;
  
  printf("%.8f %.8f\n",p1.x,p1.y);
  koch(n,p1,p2);
  printf("%.8f %.8f\n",p2.x,p2.y);
  
  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int n,ans=0; cin >>n;
  int v[n],c[n];
  for(auto &i:v) cin >>i;
  for(auto &i:c) cin >>i;
  for(int i=0; i<n; i++) ans+=max(v[i]-c[i],0);
  cout <<ans;
}

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

Measured memory_bytes: 3592
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(o) {cerr<<#o<<" "<<o<<endl;}
#define DUMPC(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	int N; cin >> N;
	REP(i, N) {
		vector<int> a(10);
		REP(j, 10)cin >> a[j];
		REP(j, 2) {
			int M = 0;
			REP(k, 10) {
				if (M < a[k]) {
					M = a[k];
					a[k] = 0;
				}
			}
		}
		if (*max_element(ALL(a)) == 0)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
  int n,ans=0,sum=0;
  cin>>n;
  int a[n+2];
  a[0]=0;
  a[n+1]=0;
  for(int i=1;i<=n;i++){
    cin >> a[i];
    sum+=abs(a[i]-a[i-1]);
  }
  sum+=abs(a[n]);
  for(int i=1;i<=n;i++){
    if(a[i-1]<=a[i]&&a[i]<=a[i+1]){
      cout<<sum<<endl;
    }else{
      cout<<sum-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1664
/*
 * 16-10-15_ABC046_A.cpp
 *
 *  Created on: 2016/10/15
 *      Author: ryoma
 */

#include<iostream>

using namespace std;

int main(){
	int a,b,c,ans=0;
	cin >> a >> b >> c;
	if(a!=b)
		ans++;
	if(b!=c)
		ans++;
	if(c!=a)
		ans++;
	if(ans==0)
		ans = 1;
	cout << ans<<endl;
	return 0;
}



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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(long long n, long long k, long long s){
    if(s!=1000000000){
        REP(i,0,k) cout<<s<<" ";
        REP(i,0,n-k) cout<<1000000000<<" ";
        cout<<endl;
    }else{
        REP(i,0,k) cout<<s<<" ";
        REP(i,0,n-k) cout<<1<<" ";
        cout<<endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long S;
    scanf("%lld",&S);
    solve(N, K, S);
    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
const int N=3e5+5;
typedef long long ll;
const ll mod=1e9+7;
int n;ll a[N];
int main() {
    scanf("%d",&n);
    ll ans=0;
    for(int i=1;i<=n;i++) {
        scanf("%lld",a+i);
    }
    int cnt[2];
    for(int i=0;i<60;i++) {
        cnt[0]=cnt[1]=0;
        ll tot=0;
        for(int j=1;j<=n;j++) {
            tot+=cnt[(a[j]>>i&1)^1];
            cnt[a[j]>>i&1]++;
        }
        ans=(ans+tot%mod*((1LL<<i)%mod))%mod;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <complex>
#include <regex>
#include <random>
using namespace std;

#define rep(i,n)	for(lint i = 0; i < n; i++)
#define repr(i,n)	for(lint i = n - 1; i >= 0; i--)
#define repi(i,ini,n)	for(lint i = ini; i < n; i++)
#define repir(i,ini,n)	for(lint i = n-1; i >= ini; i--)
#define repb(i,start,end)	for(lint i = start; i <= end; i++)
#define repbr(i,start,end)	for(lint i = end; i >= start; i--)

#define bit(n)				(1LL << (n))

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define rg(v, ini, end) v.begin() + ini, v.begin()+end

#define ret return 0;
#define chmax(a, b) a=mmax(a,b)
#define chmin(a, b) a=mmin(a,b)

using lint = long long;
using ulint = unsigned long long;
using ld = long double;
struct xy
{
	lint x, y;
	xy() :x(0), y(0) {}
	xy(lint _x, lint _y) : x(_x), y(_y) {}
	xy operator+(const xy& p) const
	{
		return xy(x + p.x, y + p.y);
	}
	bool operator<(xy p) const
	{
		if (y == p.y)
			return x < p.x;
		return y < p.y;
	}
};
struct xyd
{
	ld x, y;
	xyd() :x(0), y(0) {}
	xyd(long double _x, long double _y) : x(_x), y(_y) {}
};
using vec = vector<lint>;
using vecd = vector<ld>;
using vecs = vector<string>;
using vecp = vector<xy>;
template<class T> using vect = vector<T>;
class vec2 : public vector<vector<lint>>
{
public:
	vec2() {}
	vec2(lint n) : vector(n) {}
	vec2(lint h, lint w) : vector(h, vector<lint>(w)) {}
	vec2(lint h, lint w, lint v) : vector(h, vector<lint>(w, v)) {}
};

template<class T> using priq = priority_queue<T>;
template<class T> using rpriq = priority_queue<T, vector<T>, greater<T>>;
template<class Key, class Val> using hashmap = unordered_map<Key, Val>;
template<class Key> using hashset = unordered_set<Key>;

mt19937 mtrand((random_device())());

const double pi = 3.141592653589793238462;
const lint intmax = 9223372036854775807;
const lint inf = 1100100100100100100LL;

constexpr lint div2(lint p, lint q)
{
	return (p + q - 1) / q;
}

#if(__cplusplus < 201703L)

	lint gcd(lint a, lint b) {
		while (1) {
			if (a < b) swap(a, b);
			if (!b) break;
			a %= b;
		}
		return a;
	}

	lint lcm(lint a, lint b)
	{
		return a / gcd(a, b) * b;
	}

#endif

template<class T>
struct nval {
	lint n;		// counts
	T val;
	nval() : n(0) {};
	nval(lint _n, T _val) : n(_n), val(_val) {};
};

template<class It, class It2>
auto spacel(It i, It2 end)
{
	if (i + 1 == end)
	{
		return '\n';
	}
	else
	{
		return ' ';
	}
}

ostream& setp(ostream& ost)
{
	cout << setprecision(60) << fixed;
	return ost;
}

const ulint mod = 1000000007;
//const ulint mod = 998244353;
const ld eps = 0.0000001;


int main()
{
	while (1)
	{
		string s;
		cin >> s;
		if (s == "0")
			break;
		lint a = 0;
		rep(i, s.length())
		{
			a += s[i] - '0';
		}
		cout << a << endl;
	}
	return 0;
}



Measured memory_bytes: 3164
#include<iostream>
#include<string.h>
using namespace std;

int main(){
    int n;
    int c[4001]={0};
    for(int i=0;i<1001;i++)
        for(int j=0;j<1001;j++)
            c[i+j]++;
    while(cin>>n){
        int an=0;
        for(int i=0;i<=n;i++)
            an+=c[i]*c[n-i];
        cout<<an<<endl;
    }
}

Measured memory_bytes: 1184
function Main(input) {
    var list = getLineAndSplit(input, 1);
    var min = 99;
    list.forEach(e => {
        var i = 0;
        var tmp = Number(e);
        while (true) {
            if (tmp % 2 !== 0 || i > min) {
                break;
            }
            tmp = tmp / 2;
            i++;
        }
        min = Math.min(i, min);
    });
    console.log(min)
}

function getLine(input, rowNum) {
    var inputs = input.split("\n");
    return inputs[rowNum];
}

function getLineAndSplit(input, rowNum) {
    return getLine(input, rowNum).split(" ");
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require("fs").readFileSync("./input", "utf8"));

Measured memory_bytes: 7628
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
using ll = long long;
#define pi 3.1415926
 
int a[3];
 
int main(){
    string s;
    cin >> s;
    int x = 0;
    for(int i = 0; i < 4; i++){
        if(s[i] == '+')
            x++;
        else 
            x--;
    }
    cout << x;

}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    int n;
    cin >> n;

    int p[9] = {};
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a > 3200) a = 3200;
        p[a / 400]++;
    }

    int r = 0;
    for (int i = 0; i < 8; i++) {
        if (p[i]) r++;
    }

    if (r == 0) {
        cout << 1 << ' ' << p[8] << endl;
    } else {
        cout << r << ' ' << r + p[8] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int n,S[1000000000];

int binary(int key){
  int left = 0;
  int right = n;
  

  while(left < right){
    int mid = (left + right) / 2;
    if(S[mid] == key ){
      return mid;
    }
    else if(key < S[mid]){
      right = mid;
    }
    else{
      left = mid + 1;
    }
  }
    return -1;
}


int main(){

  int q,key,i,count=0;

  scanf("%d",&n);
  if(n > 100000) return 0;

  for(i = 0;i<n;i++){
    scanf("%d",&S[i]);

  }

  scanf("%d",&q);
  if(q> 50000) return 0;

  for(i = 0;i<q;i++){
    scanf("%d",&key);

    if(  binary(key) != -1){
      count++;
    }
  }
  printf("%d",count);
  printf("\n");

  return 0;

}


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

int main(){
float a,b;
cin>>a>>b;
int ans=-1;
int as, bs;
for(int i=0;i<10000;i++){
  as=0.08*i;
  bs=0.1*i;
  if(as==a&&bs==b){
    ans=i;
    break;
  }
}
cout<<ans<<endl;
return 0;
}



Measured memory_bytes: 256
S = input()
a = int(S[0:2])
b = int(S[2:4])

if 0 < a <= 12 and 0 < b <= 12:
    print("AMBIGUOUS")
elif a >= 0 and 0 < b <= 12:
    print("YYMM")
elif b >= 0 and 0 < a <= 12:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

// 切り上げ割り算
template <typename T>
T ceil_div(T a, T b) {
    return a > 0 && b > 0 ? (a + b - 1) / b : a / b;
}

int main() {
    int n;
    cin >> n;
    ll t, a;
    cin >> t >> a;
    for (int i = 0; i < n - 1; ++i) {
        ll ti, ai;
        cin >> ti >> ai;
        ll k = max(ceil_div(t, ti), ceil_div(a, ai));
        t = k * ti, a = k * ai;
    }

    cout << t + a << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
#define pb push_back
#define fi first
#define se second
map<ll,ll>mp;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,x,s=0,ans = 0;
	cin>>n;
	mp[0] = 1; 
	for(int i=1;i<=n;i++){
		cin>>x; 
		s+=x; 
		ans+=mp[s];
		mp[s]++;
	}
	cout<<ans<<endl;
	
	return 0;
}



Measured memory_bytes: 12800