akhauriyash/Code-Regression huggingface dataset:
//// Journey of Harry Singh from Diploma in Cse to Red Coder of India.///////////////////////////////////////////////////
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
int main(){

int p[100005]={0};
for(int i=2;i<=100005;i++)
{
	int d=0;
	if(isPrime(i) && isPrime(((i+1)/2)))d++;;
	p[i]=d+p[i-1];
}

int q;cin>>q;
while(q--)
{    
	int l,r;
	cin>>l>>r;
	cout<<p[r]-p[l-1]<<"\n";
}








}

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

int main(){
    int m, f, r;
    while(cin >> m >> f >> r, m!=-1||f!=-1||r!=-1){
        if((m==-1 || f==-1) || (m+f<30)) cout << "F" << endl;
        else if(m+f>=80) cout << "A" << endl;
        else if(m+f>=65) cout << "B" << endl;
        else if(m+f>=50||r>=50) cout << "C" << endl;
        else cout << "D" << endl;
    }
}


Measured memory_bytes: 3064
import itertools


def main():
    N, C = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(C)]
    CC = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(N)]

    cost = [[0 for _ in range(C)] for _ in range(3)]
    for c in range(C):
        for i in range(N):
            for j in range(N):
                cost[(i + j) % 3][c] += D[CC[i][j]][c]

    res = float("inf")
    color = [i for i in range(C)]
    for i, c in enumerate(list(itertools.permutations(color, 3))):
        tmp = 0
        for it in range(3):
            tmp += cost[it][c[it]]
        res = min(res, tmp)

    print(res)

main()

Measured memory_bytes: 7540
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    int cnt=0;
    cin>>s>>t;
    for(int i=0;i<s.size() && i<t.size();i++)
    {
        if(s[i]!=t[i])
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
#define Min(a,b,c) min((a),min((b),(c)))
#define Max(a,b,c) max((a),max((b),(c)))
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-11
#define N 300005
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi 3.14159265359
using namespace std;
typedef long long LL;
int main()
{
	int a[N];
	int n;
	scanf("%d",&n);
	for(int i=0;i<3*n;i++)
	scanf("%d",&a[i]);
	LL prefix[N];
	for(int i=0;i<N;i++)
	prefix[i]=-1e18;
	priority_queue<int,vector<int>,greater<int> > pq;
	LL sum=0; 
	for(int i=0;i<n;i++){
		sum+=a[i];
		pq.push(a[i]);
	}
	prefix[n-1]=sum;
	for(int i=n;i<3*n;i++){
		sum+=a[i];
		pq.push(a[i]);
		sum-=pq.top();
		pq.pop();
		prefix[i]=sum;
	}
		priority_queue<int,vector<int>,less<int> > pq2;
	LL suffix[N];
	for(int i=0;i<N;i++)
	suffix[i]=1e18;
	sum=0;
	for(int i=3*n-1;i>=2*n;i--){
		sum+=a[i];
		pq2.push(a[i]);
	}
	suffix[2*n]=sum;
	for(int i=2*n-1;i>=0;i--){
		sum+=a[i];
		pq2.push(a[i]);
		sum-=pq2.top();
		pq2.pop();
		suffix[i]=sum;
	}
	LL ans=-1e18;
	for(int i=0;i<3*n-1;i++){
		ans=max(ans,prefix[i]-suffix[i+1]);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 7288
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	int n;
	vector<int> p(n);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> p[i];
	int ans = 0;
	for (int t = 0; t < n - 2; t++)
	{
		if ((p[t] < p[t + 1] && p[t + 1] < p[t + 2])||(p[t] > p[t + 1] && p[t + 1] > p[t + 2]))
		{
			ans++;
		}
	}

	cout << ans << "\n";


	return 0;
}

Measured memory_bytes: 3756
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

int main(){
    int x,y,z;
    cin >> x>>y>>z;
    swap(x,y);swap(x,z);
    cout<<x<< " "<<y<<" "<<z;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

int64_t dp[3001][3001][4] = {};
int64_t v[3001][3001] = {};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int r, c, k; cin >> r >> c >> k;
	FOR_LT(i, 0, k) {
		int cr, cc, cv; cin >> cr >> cc >> cv;
		v[cr][cc] = cv;
	}

	FOR_LE(i, 1, r) {
		FOR_LE(j, 1, c) {
			//cout << i << " " << j << " " << v[i][j];
			{
				int64_t zerov = 0;
				FOR_LE(k, 0, 3) {
					zerov = max(zerov, dp[i - 1][j][k]);
				}
				dp[i][j][0] = max(dp[i][j - 1][0], zerov);
			}
			FOR_LE(k, 1, 3) {
				dp[i][j][k] = dp[i][j - 1][k];
			}
			if (v[i][j] != 0) {
				FOR_DW(k, 3, 1) {
					dp[i][j][k] = max(dp[i][j - 1][k], dp[i][j][k - 1] + v[i][j]);
				}
			}
			//cout << " : " << dp[i][j][0] << " " << dp[i][j][1] << " " << dp[i][j][2] << " " << dp[i][j][3] << endl;
		}
	}

	int64_t ans = 0;
	FOR_LE(k, 0, 3) {
		ans = max(ans, dp[r][c][k]);
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 355156
#include<iomanip>
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
using ll = long long;
#define nin(n) int n; cin >> n;
int main(){
  int n,m,t,s;
  cin >> n >> m;
  priority_queue<ll> q;
  for(int i=0;i<n;i++){
    cin >> t;
    q.push(t);
  }
  for(int i=0;i<m;i++){
    s=q.top();
    q.pop();
    s/=2;
    q.push(s);
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    ans+=q.top();
    q.pop();
  }
  cout << ans << endl;
}
    

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#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 PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    REP(i,9){
	string name;
	int p,t1,t2;
	cin >> name >> t1 >> t2;
	printf("%s %d %d\n",name.c_str(),t1+t2,t1*200+t2*300);
    }
    return 0;
}

Measured memory_bytes: 1204
/**
*	created: 10.08.2020 17:36:11
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

// 素因数分解してmapに格納
map<int,int> mp;

void prime(int n) {
    if (n == 1) return;
    for (int i = 2; i*i<= n; i++) {
        if (n % i == 0) {
            prime(i);
            prime(n/i);
            return;
        }
    }
    mp[n]++;
    return;
}

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n; cin >> n;
    rep2(i,2,n+1) prime(i);
    int cnt74 = 0, cnt2 = 0, cnt24 = 0, cnt4 = 0, cnt14 = 0;
    for (auto p : mp) {
        int m = p.second;
        if (m >= 74) {cnt74++; cnt2++; cnt24++; cnt4++; cnt14++;}
        else if (m >= 24) {cnt2++; cnt24++; cnt4++; cnt14++;}
        else if (m >= 14) {cnt2++; cnt4++; cnt14++;}
        else if (m >= 4) {cnt2++; cnt4++;}
        else if (m >= 2) cnt2++;
    }
    int ans = cnt74 + cnt14*(cnt4-1) + cnt24*(cnt2-1) + cnt4*max(cnt4-1,0ll)*(cnt2-2)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
#include "iostream"
#include "random"
#include "string"
#include "bitset"
#include "algorithm"
#include "map"
#include "queue"
#include "list"
#include "set"
#include "climits"
#include "iomanip"
#include "stack"
#include "functional"

using namespace std;

int N, M, K, L, R, H, W;

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

	cin >> N >> M >> K;
	while (N) {
		vector<int>v(N);
		for (auto &i : v)cin >> i;
		int ans = 0;
		for (int i = M; i <= K; i++) {
			int st = 10000;
			for (int j = 0; j < N;j++) {
				if (i%v[j] == 0) {
					st = min(st, j);
				}
			}
			if (st == 10000) {
				if (N % 2 == 0)ans++;
			}
			else if (st % 2==0) {
				ans++;
			}
		}
		cout << ans << endl;
		cin >> N >> M >> K;
	}
}


Measured memory_bytes: 3088
#include <stdio.h>


int main(int argc, char *argv[]){

  int i;
  int N, K, X, Y;
  int cost = 0;

  scanf("%d", &N);
  scanf("%d", &K);
  scanf("%d", &X);
  scanf("%d", &Y);

  if(N <= K){
    cost = X * N;
  }else{
    cost = X * K + Y * (N - K);
  }

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

  return 0;
}


Measured memory_bytes: 128
n=int(input())
S=input().split(' ')
q=int(input())
T=input().split(' ')

def equal_element(S,T):
	m=0
	for i in range(len(T)):
		for j in range(len(S)):
			if S[j]==T[i]:
				m+=1
				break
	return(m)
	
print(equal_element(S,T))


Measured memory_bytes: 6076
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt() , h = s.nextInt();
        int a = -1;
        int [] b = new int[n];
        for(int i = 0; i < n; ++i) {
            int x = s.nextInt();
            a = Math.max(a, x);
            b[i] = s.nextInt();
        }
        Arrays.sort(b);
        long cnt = 0;
        int lst = n - 1;
        while(h > 0 && lst >= 0 && b[lst] >= a) {
            h -= b[lst --];
            cnt ++;
        }
        cnt += (Math.max(h,0)+ a - 1) / a;
        System.out.println(cnt);

    }
}


Measured memory_bytes: 63320
def gcd(a,b): #最大公約数
    if b == 0:
        return abs(a)
    else:
        return gcd(b, a%b)

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

for i in range(N):
    a = A[i]
    if i == 0:
        ans = a
    else:
        ans = gcd(ans, a)

print(ans)


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

int main () {
    int d;
    cin >> d;
    if (d == 25){
        cout << "Christmas";
    } else if (d ==24) {
        cout << "Christmas Eve";
    } else if (d == 23) {
        cout << "Christmas Eve Eve";
    } else if (d == 22) {
        cout << "Christmas Eve Eve Eve";
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
      boolean ok_flag = true;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      List<String> list = new ArrayList<>();
      for(int i=0; i<n; i++){
list.add(sc.next());
      }
Set<String> set = new HashSet<>(list);
List<String> list2 = new ArrayList<>(set);

 if(n!=list2.size()) {
   System.out.println("No");
   System.exit(0);
 }
      for(int i=1; i<list.size(); i++){
      String str_end = list.get(i-1);
      String str_str = list.get(i);
      char c_end = str_end.charAt(str_end.length()-1);
        char c_str = str_str.charAt(0);
        if(c_end != c_str) ok_flag = false;
      }
      if(ok_flag) System.out.println("Yes");
      else System.out.println("No");
	}
}


Measured memory_bytes: 21844
from collections import defaultdict


def main():
    N, A, B = map(int, input().split())
    x_list = list(map(int, input().split()))

    ans = 0
    for i in range(len(x_list) - 1):
        d = x_list[i + 1] - x_list[i]
        ans += min(d * A, B)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14636
// यथा चतुर्भिः कनकं परीक्ष्यते निघर्षणच्छेदनतापताडनैः।
// तथा चतुर्भिः पुरुषः परीक्ष्यते त्यागेन शीलेन गुणेन कर्मणा॥
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv std::vector<int>
#define mapii std::map<int,int>
#define mpaci std::map<char,int>
#define umapii std::unordered_map<int,int>
#define umapci std::unordered_map<char,int>
#define seti std::set<int>
#define useti std::unordered_set<int>
#define qi std::queue<int>
#define qc std::queue<char>
#define sti std::stack<int>
#define stc std::stack<char>
#define endl "\n"
#define test(i) cout<<i<<endl
#define tests(i) cout<<"i: "<<i<<endl;
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
#define all(x) x.begin(),x.end() 
#define printv(v) for(auto x: v){ cout<< x << " ";}
#define pi 3.14159265358979323846

void file(){
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
bool sortdesk(const pair<int,int> &a, const pair<int,int> &b){return a.ff>b.ff;}
bool sortdesv(const pair<int,int> &a, const pair<int,int> &b){return a.ss>b.ss;}
bool sortascv(const pair<int,int> &a, const pair<int,int> &b){return a.ss<b.ss;}
bool sortasck(const pair<int,int> &a, const pair<int,int> &b){return a.ff<b.ff;}
bool is_prime(int n){if(n==1){return false;}int i=2;while(i*i<=n){if(n%i==0){return false;}i+=1;}return true;}
int gcd(int a, int b){if (b == 0){return a;} return gcd(b, a % b);}
int cntdiv(int n){int cnt=0;for(int i=1;i<=sqrt(n);++i){if(n%i==0){if(n/i==i)++cnt;else{cnt = cnt + 2;}}}return cnt;}
lld posnegmod(lld x,lld mod){return (x%mod+mod)%mod;}
// lld fact(lld n);
// lld nCr(lld n,lld r){return fact(n) / (fact(r) * fact(n - r));}
// lld fact(lld n){ lld res = 1; for(lld i = 2; i <= n; i++){res = res * i;}return res;} 
// const int maxi = 1e6+10;
// vector<int> v[maxi];
// long long a[maxi];
// void dfs(int x,int y){
//     a[x]+=a[y];
//     for(int i:v[x]){
//         if(i!=y){
//             dfs(i,x);
//         }
//     }
// }

void test_case(){
    int n,m;
    cin>>n>>m;
    vv v(m);
    int sum=0;
    fors(i,m){
        cin>>v[i];
        sum+=v[i];
    }
    if(sum<=n){
        cout<<n-sum;
        return;
    }
    cout<<-1;
}

int main(){
    fastio;
    file();
    int T=1;
    // int T;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
        test_case();
    }
}

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

int main(){
  vector<vector<int>> data(3, vector<int> (3));
  int point;
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3;j++){
      cin >> data.at(i).at(j);
    }
  }
  for(int b1 = 0;b1 <= data.at(0).at(0);b1++){
    for(int b2 = 0;b2 <= data.at(0).at(1);b2++){
      for(int b3 = 0;b3 <= data.at(0).at(2);b3++){
        int a1 = data.at(0).at(0) - b1;
        int a2 = data.at(1).at(1) - b2;
        int a3 = data.at(2).at(2) - b3;
        int c12 = a1 + b2;
        int c13 = a1 + b3;
        int c21 = a2  +b1;
        int c31 = a3 + b1;
        int c23 = a2 + b3;
        int c32 = a3 + b2;
        if(c12 == data.at(0).at(1) && c13 == data.at(0).at(2) && c21 == data.at(1).at(0) && c31 == data.at(2).at(0) && c23 == data.at(1).at(2) && c32 == data.at(2).at(1)){
          point = 0;
          break;
        }
        else point = 1;
      }
    }
  }
  if(point == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}
        

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

int main(){
    int n;
    cin >>n;
    cout<<1-n<<endl;
    return 0;
}


Measured memory_bytes: 3632
// cout << "Case #" << k << ": ";
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(a[i] * 4 * m >= sum) {
            ans++;
        }
    }
    if(ans >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)((n)-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

bool solve(){
    int n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    string s; cin >> s;

    set<ll, greater<ll>> bases({0});
    rrep(i,n){
        ll v = a[i];
        for(auto base : bases) v = min(v, v^base);
        if(v){
            if(s[i] == '1'){
                return 1;
            }else{
                bases.insert(v);
            }
        }
    }
    return 0;
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int t; cin >> t;
    while(t--){
        cout << solve() << endl;
    }
    return 0;
}

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

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

    string s;cin>>s;
    bool p=(s[0]==s[s.length()-1]),q=(s.length()%2==1);
    if(p ^ q) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}


Measured memory_bytes: 512
N,A,B=map(int,raw_input().split())

ans=0
for i in range(1,N+1):
	S=str(i)
	sum_s=0
	for j in range(len(S)):
		sum_s+=int(S[j])
	if sum_s>=A and sum_s<=B:
		ans+=i
print ans



Measured memory_bytes: 2948
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    int n;
    cin >> n;
    vector<ll> v;
    ll sum = 0;
    for (int i = 1; i <= n; ++i) {
        int a;
        scanf("%d", &a);
        sum += a-i;
        v.emplace_back(a-i);
    }
    ll ans = 0, p, q, r;
    sort(v.begin(), v.end());
    if(n%2){
        p = v[n/2];
        q = v[n/2];
        r = v[n/2];
    }else {
        p = (v[n/2]+v[n/2-1])/2;
        q = (v[n/2]+v[n/2-1])/2+1;
        r = (v[n/2]+v[n/2-1])/2-1;
    }
    
    ll ans2 = 0, ans3 = 0;
    for (int i = 0; i < n; ++i) {
        ans += abs(v[i]-p);
    }
    for (int i = 0; i < n; ++i) {
        ans2 += abs(v[i]-q);
    }
    for (int i = 0; i < n; ++i) {
        ans3 += abs(v[i]-r);
    }
    cout << min({ans, ans2, ans3}) << "\n";
    return 0;
}


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

int main()
{
	int n, k;
	std::cin >> n >> k;
	std::vector<int> P;
	for (int i = 0; i < n; i++)
	{
		int p;
		std::cin >> p;
		P.push_back(p);
	}
	std::sort(P.begin(), P.end());
	int sum = 0;
	int i = 0;
	while (k > 0)
	{
		sum += P.at(i);
		i++;
		k--;
	}
	std::cout << sum <<'\n';
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long l, r, t1 = 0, t2 = 0, sum;
	scanf("%lld %lld", &l, &r);
	if(!(r & 1)) t1 = r, --r;
	if(l & 1) t2 = l, ++l;
	sum = (r - l + 1) / 2;
//	cout << t1 <<" " << t2;
	sum &= 1;
	printf("%lld\n", sum ^ t1 ^ t2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl;
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T>
using MaxHeap = priority_queue<T>;
template<class T>
using MinHeap = priority_queue<T,vector<T>,greater<T> >;
template<class T,class U>
ostream& operator << (ostream& os,pair<T,U>& p){
  os << p.fi << ',' << p.sec; return os;
}
template<class T,class U>
istream& operator >> (istream& is,pair<T,U>& p){
  is >> p.fi >> p.sec; return is;
}
template<class T>
ostream& operator << (ostream &os,const vector<T> &vec){
  for(int i=0;i<vec.size();i++){
    os << vec[i];
    if(i+1<vec.size())os << ' ';
  }
  return os;
}
template<class T>
istream& operator >> (istream &is,vector<T>& vec){
  for(int i=0;i<vec.size();i++)is >> vec[i];
  return is;
}
void fastio(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(20);
}
int N;
int main(){
  fastio();
  cin >> N;
  multiset<int> ms;
  for(int i=0;i<(1<<N);i++){
    int k;
    cin >> k;
    ms.insert(k);
  }
  multiset<int> v;
  v.insert(*(ms.rbegin()));
  ms.erase(--(ms.rbegin().base()));
  for(int i=0;i<N;i++){
    vector<int> ve;
    for(auto it = v.rbegin();it!=v.rend();it++){
      ve.pb(*it);
      // cout << *it << ' ';
    }
    // cout << endl;
    for(int j=0;j<ve.size();j++){
      auto it = ms.lower_bound(ve[j]);
      if(it==ms.begin()){
        cout << "No" << endl;
        return 0;
      }
      it--;
      v.insert(*it);
      ms.erase(it);
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 13304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    char c; cin >> c;
    if('a'<=c && c<='z') cout << 'a';
    else cout << 'A';
    cout << endl;
}


Measured memory_bytes: 3628
time = []
total = 0
for _ in range(5):
    t = int(input())
    if t % 10 == 0:
        total += t
    else:
        total += (t//10+1)*10
        time.append(t)
if time:
    last = min(time, key=lambda x: int(str(x)[-1]))
    print(total - 10+last%10)
else:
    print(total)

Measured memory_bytes: 3064
var
	n, i, r: integer;
	s: real;
	A: array[0..99] of integer;
begin
	s := 0;
	read(n);
	for i := 0 to n - 1 do begin
		read(A[i]);
		s += A[i];
	end;
	r := 0;
	for i := 0 to n - 1 do begin
		r += sqr(A[i] - Round(s / n));
	end;
	writeln(r);
end.

Measured memory_bytes: 128
import sys
input=sys.stdin.buffer.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
N,R = map(int,input().split())
if N >= 10:
    print(R)
else:
    print(R+100*(10-N))
    



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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String input = br.readLine();
		
		StringBuffer sb = new StringBuffer();
		
		for(int i = 0; i < input.length() ; i+= 2){
			sb.append(input.charAt(i));
		}
		
		System.out.println(sb.toString());
	}

}


Measured memory_bytes: 23252
#include<stdio.h>
#define max(a,b) ( (a) > (b) ? (a) : (b) )

int n,temp,a[500001];

int main(void){
	register int i,Max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&temp),
		a[temp]++,a[temp-1]++,a[temp+1]++;
	for(i=0;i<=500000;i++)
		Max=max(Max,a[i]);
	printf("%d\n",Max);
	return 0;
}

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

using namespace std;
using ll = long long;

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

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int k, n; cin >> k >> n;
    vector<int> A(n);
    REP(i, n) cin >> A.at(i);

    int max_d = 0;
    int max_i = 0;

    for (int i = 0; i < n; i++) {
        int d;
        if (i == n - 1) {
            d = A.at(0) + k - A.at(i);
        } else {
            d = A.at(i + 1) - A.at(i);
        }
        max_d = max(d, max_d);
    }

    cout << k - max_d << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
string s, t;
int dp[3030][3030];

int main() {
    cin >> s >> t;
    int slen = s.length();
    int tlen = t.length();

    for(int i = 0; i <= slen; ++i) {
        for(int j = 0; j <= tlen; ++j) {
            dp[i][j] = 0;
        }
    }

    for(int i = 0; i < slen; ++i) {
        for(int j = 0; j < tlen; ++j) {
            if(s.at(i) == t.at(j)) {
                dp[i+1][j+1] = dp[i][j] + 1;
            }else {
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }

    int len = dp[slen][tlen];
    vector<char> ans(len);
    int k = slen;
    int l = tlen;
    while(len > 0) {
        if(s.at(k-1) == t.at(l-1)) {
            ans.at(len-1) = s.at(k-1);
            len--;
            k--;
            l--;
        }else if(dp[k][l] == dp[k-1][l]) {
            k--;
        }else {
            l--;
        }
    }

    for(int i = 0; i < ans.size(); ++i) {
        cout << ans.at(i);
    }
    cout << endl;
}

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

int main() {
  int64_t n, k;
  std::cin >> n >> k;

  if (k == 0) {
    std::cout << n * n << std::endl;
    return 0;
  }

  int64_t count = 0;
  for (int64_t b = k + 1; b <= n; b++) {
    const auto i = (n - k) / b + 1;
    count += (i - 1) * (b - k);
    const auto n_lim = (n - ((i - 1) * b + k) + 1);
    const auto k_lim = (i * b - ((i - 1) * b + k));
    count += std::min(n_lim, k_lim);
  }
  std::cout << count << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

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

  vector<ll> B(N);
  for (ll i = 0; i < N; i++) {
    cin >> B[i];
  }

  ll sum = 0;
  ll mod = 0;
  for (ll i = 0; i < N + 1; i++) {
    // まずは前回のあまりで倒す。
    if (mod > A[i]) {
      sum += A[i];
      A[i] = 0;
    } else {
      sum += mod;
      A[i] -= mod;
    }

    // 繰り越しをリセットして倒す
    mod = 0;
    ll now = 0;
    if (i < N) {
      now += B[i];
    }
    if (now > A[i]) {
      mod = now - A[i];
      sum += A[i];
    } else {
      mod = 0;
      sum += now;
    }

  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
#define ld long double
#define ff first
#define ss second

using namespace std;

ll calc(ll n) {
    vector<ll> power;
    ll cont, total = 0;

    for(ll i = 2; i <= sqrt(n); i++) {

        if(n % i == 0) {
            power.push_back(0);

            while(n % i == 0) {
                power.back()++;
                n /= i;
            }
        }
    }

    if(n != 1)
        power.push_back(1);

    // cout << primes.size() << endl;
    ll tam = power.size();
    // cout << "tam = " << tam << endl;

    for(ll i = 0; i < tam; i++) {
        cont = 1;
        // cout << power[i] << endl << endl;
        while(power[i] >= cont) {
            // cout << power[i] << " " << cont << endl;
            power[i] -= cont;
            cont++;
            total++;
        }
    }

    return total;
}

int main() {
    ll n;

    cin >> n;

    cout << calc(n) << endl;

    return 0;
}

Measured memory_bytes: 3660
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var D = new Dictionary<int,int>();
		for(int i=0;i<N;i++){
			if(D.ContainsKey(A[i]) == false) D.Add(A[i],0);
			D[A[i]]++;
		}
		
		int cnt = 0;
		foreach(var k in D.Keys){
			if(D[k] > k) cnt += D[k] - k;
			if(D[k] < k) cnt += D[k];
		}
		
		Console.WriteLine(cnt);
		
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 25308
n, m = map(int, input().split())
st = []
for _ in range(n):
    st.append(tuple(map(int, input().split())))
st.sort()
i = 0
c = 0
while m > 0:
    b = min(m, st[i][1])
    c += b * st[i][0]
    m -= b
    i += 1
print(c)


Measured memory_bytes: 16988
#include <iostream>
#include <time.h>
#include <string>
#include <iomanip>
#include <algorithm>
#include <map>


using namespace std;

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

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

int main(){
  int n;
  cin >> n;
  bool flag;
  flag = false;
  for(int i=1; i<10; i++){
    for(int j=1; j<10; j++){
      if(i*j == n){flag = true;}
    }
  }
  if(flag){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
  return 0;
}

Measured memory_bytes: 256
Imports System.Collections
Imports System.Collections.Generic
Imports System.Linq
Imports System.xml
Imports System.xml.Linq

Module Module1
	public sub main()

		dim N as string = Console.ReadLine()
		dim num as integer = convert.toint32(N)
		dim result as double = num * 2.0 * math.pi

		console.writeLine(result.tostring())
	  
	end sub 
End Module

Measured memory_bytes: 27588
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}


//return pos more than m
fn bin_search(v: &Vec<usize>, m: usize) -> usize{

    if v.len() == 0{
        return std::usize::MAX;
    }

    // (left..right]
    let mut left = 0;
    let mut right = v.len()-1;

    while left < right{
        let mid = (left+right)/2;
        //println!("left = {}, right = {}, mid = {}", left, right, mid);
        if v[mid] < m{
            left = mid + 1;
        }else{
            right = mid;
        }
    }
    if v[right] < m{
        return std::usize::MAX;
    }else{
        return v[right];
    }
}

fn main(){
    /*
    let v = vec![10];
    let hoge = bin_search(&v, 10);
    println!("{}", hoge);
    return;
     */

    let n: usize = read_as_vec()[0];
    let s = read_as_string();

    let mut ans_v = vec![vec![vec![false;10];10];10];
    let mut v = vec![vec![];10];

    for (pos, c) in s.bytes().enumerate(){
        v[(c-48) as usize].push(pos);
    }


    //println!("{:?}", v);
    let dummy = std::usize::MAX;
    //first digit
    for i in 0..10{
        //eprintln!("\ni = {}", i);
        let first_digit_pos = bin_search(&v[i], 0);
        //println!("first_digit_pos = {}", first_digit_pos);
        if dummy == first_digit_pos{
            continue;
        }
        //second digit
        for j in 0..10{
            //println!("--j = {}--", j);
            let second_digit_pos = bin_search(&v[j], first_digit_pos+1);
            //println!("second_digit_pos = {}", second_digit_pos);
            if dummy == second_digit_pos{
                continue;
            }
            for k in 0..10{

                if std::usize::MAX != bin_search(&v[k], second_digit_pos+1){
                    ans_v[i][j][k] = true;
                }
            }
        }


    }


    let mut ans = 0;
    for i in 0..10{
        for j in 0..10{
            for k in 0..10{
                if ans_v[i][j][k]{
                    //println!("true: {}{}{}", i, j, k);
                    ans += 1;
                }
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    string w;
    cin >> w;
    map<char, int> cnt;
    for (int i = 0; i < w.size(); i++){
        char b;
        b = w[i];
        cnt[b] = cnt[b] + 1;
    }    
    for (int i = 0; i < w.size(); i++){
        char b;
        b = w[i];
        if (cnt[b] % 2 == 1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
} 

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

int main(){
	double x[2][2], y[2][2];
	while (cin >> x[0][0] >> y[0][0]){
		for (int i = 0; i < 2; i++){
			for (int j = 0; j < 2; j++){
				if (i == 0 && j == 0) continue;
				cin >> x[i][j] >> y[i][j];
			}
		}
		if (x[0][0] <= x[1][1] && y[0][0] <= y[1][1] && x[0][1] >= x[1][0] && y[0][1] >= y[1][0])
			printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int s;
    cin >> s;
    map<int, int> mp;
    int count = 0;
    while (1)
    {
        ++count;
        if (mp[s] == 1)
        {
            cout << count << endl;
            return 0;
        }
        mp[s]++;
        if (s % 2 == 0)
        {
            s /= 2;
        }
        else
        {
            s = 3 * s + 1;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n,x,y;
	cin >> n >> x >> y;
	x--;y--;

	vector<int> cnt(n,0);

	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
		{
			int mn=j-i;
			int tmp=abs(i-x)+abs(j-y)+1;
			if(mn>tmp)
				mn=tmp;
			cnt[mn]++;
		}

	for(int i=1;i<n;i++)
		cout << cnt[i] << endl;



}


Measured memory_bytes: 256
def bubbleSort(a, n):
    flag = True
    count = 0
    while flag:
        flag = False
        for j in range(1, n)[::-1]:
            if a[j] < a[j-1]:
                a[j], a[j-1] = a[j-1], a[j]
                count += 1
                flag = True
    return count

def show(a, n):
    for i in range(n):
        if i == n-1:
            print "%d" % a[i]
        else:
            print "%d" % a[i],

n = input()
a = map(int, raw_input().split())
c = bubbleSort(a, n)
show(a, n)
print "%d" % c

Measured memory_bytes: 6476
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    int l = 0, r = 0;
    ll sum = 0;
    while (l < n) {
        while (r < n && (sum^a[r]) == (sum+a[r])) {
            sum ^= a[r++];
            ans++;
        }
        sum ^= a[l++];
        ans += r-l;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}




int main(){

  int a,ans=0;
  FOR(i,0,4){
    cin >> a;
    ans += a;
  }
  cout << ans << endl;
}




Measured memory_bytes: 3092
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	string s;cin>>s;
	ll cnt[26]={0};
	rep(i,0,sz(s))cnt[s[i]-'A']++;
	bool ok=1;
	rep(i,0,26)if(cnt[i]>0) if(cnt[i]!=2)ok=0;
	ll c=0;
	rep(i,0,26)if(cnt[i]==2)c++;
	if(c!=2)ok=0;
	if(!ok)cout<<"No";
	else cout<<"Yes";
	
	
	return 0;
}



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

int f22() {
    string N;
    cin >> N;
    int sum = 0;
    for(auto c : N) {
        sum += (c - '0');
    }
    if(sum % 9 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

int main() {
    f22();
    return 0;
}



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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
    string s;
    cin >> s;
    cout << s[0] << s.length() - 2 << s.back();
}

Measured memory_bytes: 256
from collections import defaultdict

n, x, y = map(int, input().split())
x -= 1
y -= 1

d = defaultdict(int)
for i in range(n-1):
    for j in range(i+1, n):
        path = min(j-i, abs(x-i)+abs(y-j)+1)
        d[path] += 1

for i in range(1, n):
    print(d[i])


Measured memory_bytes: 49372
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <cmath>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define step(i, f, n, a) for(int (i) = (f); (i) < (n); (i)+=a)
#define rstep(i, f, n, a) for(int (i) = (f); (i) >= (n); (i)-=a)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

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

ll n;
string s, animals = "";

void animalAlignment(string start){
	animals = start;
	FOR(i, 1, n){ //2文字目から順に
		if (animals[i] == 'S'){
			if (s[i] == 'o'){
				animals += animals[i-1]; //等しい
			}else{
				animals += animals[i-1] == 'S'? 'W':'S'; //'x'の時
			}
		}else{ //Wの時
			if (s[i] == 'o'){
				animals += animals[i-1] == 'S'? 'W':'S'; //等しくない
			}else{
				animals += animals[i-1]; //'x'なら等しい
			}
		}
	}
	bool flag = false;
	if (animals[animals.size()-1] == animals[0]){
		animals.pop_back();
		flag = true;
	}

	if (flag){
		if (animals[0] == 'S'){
			if (s[0] == 'o'){
				if (animals[animals.size()-1] == animals[1]){
					puts(animals)
					exit(0);
				}
			}else{
				if (animals[animals.size()-1] != animals[1]){
					puts(animals)
					exit(0);
				}
			}
		}else{
			if (s[0] == 'o'){
				if (animals[animals.size()-1] != animals[1]){
					puts(animals)
					exit(0);
				}
			}else{
				if (animals[animals.size()-1] == animals[1]){
					puts(animals)
					exit(0);
				}
			}
		}
	}
}

int main(){
	gets(n) gets(s)
	animalAlignment("SS");
	animalAlignment("SW");
	animalAlignment("WS");
	animalAlignment("WW");
	puts(-1)

}


Measured memory_bytes: 776
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int n,x,y;
	ll ans[2002]={};
	cin>>n>>x>>y;
	for(int i=1; i<n; i++){
		for(int j=i+1; j<n+1; j++){
			int t=min(j-i,abs(x-i)+1+abs(y-j));
			ans[t]++;
		}
	}
	for(int i=1; i<n; i++){
		cout<<ans[i]<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int D;
  cin >> D;
  string S;
  if (D == 25) {
    S = "Christmas";
  } else if (D == 24) {
    S = "Christmas Eve";
  } else if (D == 23) {
    S = "Christmas Eve Eve";
  } else {
    S = "Christmas Eve Eve Eve";
  }
  cout << S << endl;
}

Measured memory_bytes: 256
package main

import (
	"sort"
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	m := scanInt64()
	as := scanInts(n)
	
	sums := make([]int64, n+1)

	sort.Ints(as)

	for i := 0; i < n; i++ {
		sums[i+1] = sums[i] + int64(as[i])
	}

	cnt := make([]int, 2*as[n-1]+1)

	for i := 0; i < n; i++ {
		cnt[as[i]]++
	}

	for i := 2*as[n-1]; i > 0; i-- {
		cnt[i-1] += cnt[i]
	}

	l, r := -1, 2*as[n-1]+1

	for r-l > 1 {
		mid := (l+r)/2

		c := 0
		for i := 0; i < n; i++ {
			idx := mid-as[i]
			if idx < 0 {
				idx = 0
			}

			c += cnt[idx]
		}

		if m <= int64(c) {
			l = mid
		} else {
			r = mid
		}
	}

	ans := int64(0)
	x := l

	c := m
	for i := 0; i < n; i++ {
		ll, rr := -1, n
		for rr-ll>1 {
			mid := (rr+ll)/2
			if as[mid]+as[i]<x {
				ll = mid
			} else {
				rr = mid
			}
		}

		// fmt.Println(sums[n]-sums[rr],int64((n-rr)), as[i])

		ans += sums[n]-sums[rr]
		ans += int64((n-rr)*as[i])
		c -= int64(n-rr)
	}

	ans += c*int64(x)

	fmt.Println(ans)

}


Measured memory_bytes: 4736
n=int(input())
lis=list(map(lambda x:format(int(x),'b'),input().split()))
l=0
for i in range(n):
    l=max(l,len(lis[i]))

d0=[0]*60
d1=[0]*60

for i in range(n):
    lis[i]=lis[i].zfill(l)
    for j in range(l):
        if lis[i][-j-1]=='0':
            d0[j]+=1
        else:
            d1[j]+=1

ans=0
for i in range(60):
    ans+=(d0[i]*d1[i]*2**i)%(10**9+7)
print(ans%(10**9+7))

Measured memory_bytes: 168300