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

using namespace std;

int main(int argc, char* argv[])
{
    int N; cin >> N;

    int total = 0;
    for (int i = 0; i < N; i++) {
        int l, r; cin >> l >> r;
        total += r-l+1;
    }

    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <list>
#include <set>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()

using namespace std;

int N, M, K, W,X;
int dp[101];

int main() {
	int Ma, Mb,sum=0;
	double k,res=101,num;

	cin >> N;

	vector <int> a(N),b(N);
	
	rep(i, N) {
		cin >> a[i];
		sum += a[i];
	}
	k = sum / double(N);
	//もっとも差が小さい項を選びたい。
	//なんかいいやり方あったかな？
	//
	rep(i, N) {
		if (fabs(a[i] - k) < res) {
			res = min(res, fabs(a[i] - k));
				num=i;

		}
	}
	cout << num;
	


}



Measured memory_bytes: 256
N, A, B = gets.split.map(&:to_i)
X = gets.split.map(&:to_i)

ans = 0

X.each_cons(2) do |x1, x2|
  d = x2 - x1

  if (d * A) < B
    ans += d * A
  else
    ans += B
  end
end

puts ans


Measured memory_bytes: 8580
from itertools import permutations
from math import sqrt
n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())

p = [i for i in range(n)]
c = 0
d = 0.0
for a in permutations(p):
    c += 1
    for i in range(n - 1):
        d += sqrt((x[a[i]] - x[a[i + 1]]) ** 2 + (y[a[i]] - y[a[i + 1]]) ** 2)
print("{:10f}".format(d / c))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	vi b(n);
	rep(i, n) {
		int a;
		cin >> a;
		b[i] = a - 1 - i;
	}
	sort(all(b));

	ll ans = 0;
	rep(i, n)ans += abs(b[i] - b[(n - 1) / 2]);

	cout << ans << endl;

}

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    int N;
    ll K;
    cin >> N >> K;

    vint As(N);
    rep(i, N) {
        cin >> As[i];
    }

    int now = 0;
    vint route(N);
    vint visited(N, -1);
    route[0] = 0;
    visited[0] = 0;
    int loopNum;
    int loopStart;
    rep(i, N) {
        // cout << i << endl;
        int dest = As[now] - 1;
        // cout << dest << endl;
        if (visited[dest] != -1) {
            // cout << "ls" << dest << endl;
            loopStart = visited[dest];
            loopNum = i + 1 - visited[dest];
            break;
        }
        visited[dest] = i+1;
        // cout << "visited[]" << dest << " " << i+1 << endl;
        route[i+1] = dest;
        now = dest;
    }
    // cout << "loop" << loopStart << "  " << loopNum << endl;
    if (loopStart + 1 > K) {
        cout << route[K] + 1 << endl;
    } else {
        cout << route[(K - loopStart) % loopNum + loopStart] + 1 << endl;
    }
}

Measured memory_bytes: 5636
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	int h,w;
	cin >> h >> w;
	char s[h][w];
	rep(i,h) rep(j,w) cin >> s[i][j];

	int col[h][w] = {};
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			int cnt = 0;
			if(s[i][j] == '.'){
				for(int tj = j; tj < w && s[i][tj] == '.'; tj++) cnt++;
				for(int tj = j; tj < j+cnt; tj++) col[i][tj] = cnt;
				j += cnt-1;
			}
		}
	}
	int row[h][w] = {};
	for(int j = 0; j < w; j++){
		for(int i = 0; i < h; i++){
			int cnt = 0;
			if(s[i][j] == '.'){
				for(int ti = i; ti < h && s[ti][j] == '.'; ti++) cnt++;
				for(int ti= i; ti < i+cnt; ti++) row[ti][j] = cnt;
				i += cnt-1;
			}
		}
	}

	int ans = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			ans = max(ans,row[i][j]+col[i][j]-1);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using Int = int64_t;

int main() {
   for(;;) {
      Int n, r;
      std::cin >> n >> r;
      if( n == 0 and r == 0 ) break;
      std::vector<Int> xs(n);
      for(Int i = 0; i < n; ++i) {
         xs[i] = n - i;
      }
      for(Int i = 0; i < r; ++i) {
         Int p, c;
         std::cin >> p >> c;
         std::vector<Int> ys(n);
         for(Int k = 0; k < c; ++k) {
            ys[k] = xs[k+p-1];
         }
         for(Int k = c; k < c+p-1; ++k) {
            ys[k] = xs[k-c];
         }
         for(Int k = p-1+c; k < n; ++k) {
            ys[k] = xs[k];
         }
         xs = ys;
      }
      std::cout << xs[0] << std::endl;
   }
}




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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

const int N=1407,K=38;
//const int N=13,K=4;
int mat[55][55];
int res[2000][55];

int main(){
	rep(i,K-1)rep(j,K-1)mat[i][j]=K+1+(K-1)*i+j;

  rep(i,K){
    res[i][0]=1;
    repl(j,1,K){
      res[i][j]=i*(K-1)+1+j;
    }
  }
  
  rep(b,K-1){
    rep(i,K-1){
      int r=b*(K-1)+K+i;
      int crt=i;
      res[r][0]=b+2;
      repl(j,1,K){
        res[r][j]=mat[j-1][crt];
        crt=(crt+b)%(K-1);
      }
    }
  }

  cout<<N<<" "<<K<<endl;
  rep(i,N){
    rep(j,K){
      cout<<res[i][j]<<" ";
    }
    cout<<endl;
  }
	return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

using namespace std;

int main(){
    char a, b, c, d;
    scanf("%c%c%c%c", &a, &b, &c, &d);
    // printf("%c%c%c%c", a, b, c, d);
    if(a==b && b==c || b==c && c==d){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
int N;
int dp[18][1 << 18];
int dist[18][18];

int solve(int i, int bit)
{
	if (dp[i][bit] != -1) return dp[i][bit];
	if ((bit >> 1) == (1 << (N - 1)) - 1) return dp[i][bit] = dist[i][0];
	int res = INF;
	FOR(j, 1, N)
	{
		if (i == j || (bit >> j) & 1) continue;
		int nbit = bit | (1 << j);
		chmin(res, solve(j, nbit) + dist[i][j]);
	}
	return dp[i][bit] = res;
}

int main()
{
	int n, m, l, s, t;
	while (cin >> n >> m >> l >> s >> t, n)
	{
		MS(dp, -1);
		s--;
		vector<vi> d(n, vi(n, INF));
		REP(i, m)
		{
			int a, b, c;
			cin >> a >> b >> c;
			a--; b--;
			d[a][b] = d[b][a] = c;
		}
		REP(k, n)REP(i, n)REP(j, n) chmin(d[i][j], d[i][k] + d[k][j]);
		vi v, e;
		v.push_back(s); e.push_back(0);
		REP(i, l)
		{
			int a, b; cin >> a >> b;
			a--;
			v.push_back(a);
			e.push_back(b);
		}
		N = v.size();
		REP(i, N)
		{
			REP(j, N)
			{
				if (i == j) dist[i][j] = INF;
				else dist[i][j] = d[v[i]][v[j]];
			}
		}
		int ans = 0;
		REP(i, (1 << l) - 1)
		{
			int bit = i << 1, cnt = -1;
			int time = 0;
			REP(j, N)
			{
				if (((bit >> j) & 1) == 0)
				{
					time += e[j];
					cnt++;
				}
			}
			time += solve(0, bit);
			if (time <= t) chmax(ans, cnt);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 21656
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << (x) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

template<class T> class segtree {
	int n;
	vector<T> data;
	T id = inf;
	T operation(T a, T b) { return min(a, b); };
public:
	segtree(int _n) {
		n = 1;
		while (n < _n + 2) n <<= 1;
		data = vector<T>(2 * n, id);
	}
	void change(int i, T x) {
		i += n;
		data[i] = x;
		while (i > 1) {
			i >>= 1;
			data[i] = operation(data[i << 1], data[i << 1 | 1]);
		}
	}
	void add(int i, T x) { change(i, data[i + n] + x); }
	T get(int a, int b) {
		T left = id; T right = id;
		a += n; b += n;
		while (a < b) {
			if (a & 1) left = operation(left, data[a++]);
			if (b & 1) right = operation(data[--b], right);
			a >>= 1; b >>= 1;
		}
		return operation(left, right);
	}
	T get_all() { return data[1]; }
	T operator[](int i) { return data[i + n]; }
};

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

	int n, m;
	cin >> n >> m;
	vector<int> a(n), cnt(n + 1);
	rep(i, n) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	segtree<int> seg(n + 1);
	rep(i, n + 1) seg.change(i, i - cnt[i]);
	vector<int> dp(200010, inf);
	dp[0] = 0;
	rep(i, n) {
		if (cnt[i + 1] == 0) dp[i + 1] = dp[i] + 1;
		else {
			for (int j = i; j >= i - cnt[i + 1] + 1 && j >= 0; j--) {
				chmin(dp[i + 1], dp[j]);
			}
		}
	}
	int ans = dp[n];
	vector<P> vec;
	rep(i, n + 1) {
		while (!vec.empty() && vec.back().second >= dp[i]) vec.pop_back();
		vec.pb({ i,dp[i] });
	}
	set<int> st;
	for (auto i : vec) st.insert(i.first);
	while (m--) {
		int x, y;
		cin >> x >> y;
		x--;
		if (a[x] == y) {
			cout << ans << '\n';
			continue;
		}
		if (seg[a[x]] >= 0) {
			if (seg.get(seg[a[x]] + 1, a[x]) > seg[a[x]] && seg.get(a[x] + 1, n + 2) > seg[a[x]]) {
				ans++; st.insert(seg[a[x]]);
			}
		}
		seg.add(a[x], 1);
		if (st.count(seg[y] - 1)) {
			ans--; st.erase(seg[y] - 1);
		}
		seg.add(y, -1);
		cnt[a[x]]--;
		cnt[y]++;
		a[x] = y;
		cout << ans << '\n';
	}
}

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

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

  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i] >> b[i] >> c[i];

  vector<vector<int>> dp(n, vector<int>(3));
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];

  for (int i = 1; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      int curr, x, y;
      if (j == 0) // a -> (b, c)
        curr = a[i], x = 1, y = 2;
      if (j == 1) // b -> (c, a)
        curr = b[i], x = 2, y = 0;
      if (j == 2) // c -> (a, b)
        curr = c[i], x = 0, y = 1;
      dp[i][j] = curr + max(dp[i - 1][x], dp[i - 1][y]);
    }
  }
  cout << max({dp.back()[0], dp.back()[1], dp.back()[2]}) << endl;
}

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

using namespace std;

int main(){
	int k, s, i, j, count = 0;
	cin >> k >> s;
	for(i = 0; i <= k; i++){
		for(j = 0; j <= k; j++){
			if(s - i - j >= 0 && s - i - j <= k) count++; 
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

signed main() {
	tezz
 
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	int n;
	cin >> n;
	int a[n][3];
	for(int i=0; i<n; i++){
		for(int j=0; j<3; j++){
			cin >> a[i][j];
		}
	}
	int dp[n][3];
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(int i=1; i<n; i++){
		for(int j=0; j<3; j++){
			dp[i][j]=0;
			for(int k=0; k<3; k++){
				if(j!=k){
					dp[i][j] = max(dp[i][j], dp[i-1][k]+a[i][j]);
				}
			}
		}
	}
	int ans=0;
	for(int i=0; i<3; i++)ans=max(ans, dp[n-1][i]);
		cout << ans << endl;
 
	return 0;
}  

Measured memory_bytes: 8276
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
int a[200010];
map<ll, ll> mp;
ll res;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++) cin >>a[i];
	for (int i=0;i<n;i++)
	{
		res+=mp[a[i]-i]; 
		mp[-a[i]-i]++;
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 27032
#include<algorithm>
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
	long long n=0,q=0,x=0,a=0,b=1;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>q>>x;
		if(q==1)
		{
			a*=x;
			b*=x;
		}
		else if(q==2)
		{
			a+=x;
		}
		else
		{
			a-=x;
		}
	}
	cout<<-a<<" "<<b<<endl;
	return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 1000000
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
char c[N]; int s0[N],s1[N];
int main()
{	int n,ans=1e9; cin>>n; scanf("%s",c+1);
	for(rint i=1;i<=n;i++) s0[i]=s0[i-1]+(c[i]=='W');
	for(rint i=n;i>=1;i--) s1[i]=s1[i+1]+(c[i]=='E');
	for(rint i=1;i<=n;i++) ans=min(ans,s0[i-1]+s1[i+1]);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
#define fori(x,y)   for(ll i=x;i<y;i++)
#define forj(x,y)   for(ll j=x;j<y;j++)
#define rfori(a,b)   for(int i=a;i>=b;i--)
#define for_it(a)     for(auto it: a)
#define pb          push_back
#define pf          push_front
#define ff          first
#define ss          second
#define all(x)      x.begin(),x.end()
#define mp          make_pair
#define mod         1000000007
#define mem(a,b)    memset(a,b,sizeof(a))
#define ld          long double
#define endl        "\n"
#define ll          long long
#define lli         long long int
#define llu         unsigned long long 
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define vl         vector<ll> 
#define vi          vector<int> 
#define vc          vector<char> 
#define vs          vector<string> 
#define si          set<int>
#define spii        set<pii>
#define usi         unordered_set<int>
#define uspii       unordered_set<pii>
#define mii         map<int,int>
#define umii        unordered_map<int,int>
#define pqmx        priority_queue<int>
#define pqmn        priority_queue<int,vi,greater<int>>
#define setbits(x)  __builtin_popcountll(x)
#define fast        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define testcase    int t;cin>>t;for(ll i=0;i<t;i++)
int xx[4]={0,0,1,-1};
int yy[4]={-1,1,0,0};

/*-----------------------------------------------------------------------------------------------------------------*/



int main()
{
	#ifndef ONLINE_JUDGE
	freopen("B_IN.txt","r",stdin);
	freopen("B_Out.txt","w",stdout);
	#endif
	fast;
	
	string s;
	cin>>s;

	int n=s.length();

	char ch=s[n-1];

	if(ch=='s')
	{
		s.pb('e');
		s.pb('s');
	}
	else 
		s.pb('s');

	cout<<s<<endl;

	return 0;
}





Measured memory_bytes: 3672
#include <stdio.h>

int main(void) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    int flag = 0;
    for (int i = 0;  i < 100; i++) {
        if ((b * i + c) % a == 0) {
            flag = 1;
            break;
        }
    }

    if (flag == 1) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		int a,b, val;
		String op;
		String plus = "+";	
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		op = sc.next();	
		b = sc.nextInt();
		if(op.equals(plus)){
			val = a + b;
		}else{
			val = a - b;
		}
		System.out.println(val);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int p[50][50]={0},t=0,n,m,k;
void d(int c,int v){
t++;
for(int i=0;i<50;i++)p[t][i]=p[t-1][i];
for(int i=c;i<50;i++)p[t][i]=max(p[t][i],v+p[t-1][i-c]);
}
main(){
string s;
cin>>n;
for(cin>>m;m--;){
cin>>s>>k;
if(s=="D")d(1,k);
}
for(cin>>m;m--;){
cin>>s>>k;
if(s=="DD")d(2,k);
}
cout<<p[t][n]<<endl;
}


Measured memory_bytes: 1212
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int alice = 0, bob = 0;
		for (int i = n - 1; i >= 0; i = i - 2) {
			alice += a[i];
		}
		for (int i = n - 2; i >= 0; i = i - 2) {
			bob += a[i];
		}
		System.out.println(alice - bob);
	}
}


Measured memory_bytes: 21844
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val S = ns()
    val T = ns()
    val ok = T.length == S.length + 1 && T.startsWith(S)
    out.println(if (ok) "Yes" else "No")
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}

Measured memory_bytes: 35956
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

inline lli getint(){
    lli n;
    scanf("%lld",&n);
    return n;
}

inline vector<lli> getints(int n){
    vector<lli> a(n);
    for(int i=0;i<n;i++)scanf("%lld",&a[i]);
    return a;
}

inline string getstr(){
  string s;
  cin>>s;
  return s;
}

inline string slice(string s,int a,int b){
  return s.substr(a,b-a-1);
}
void dumpints(vector<lli> a){
  cout<<"[";
  for(int i=0;i<a.size()-1;i++){
    cout<<a[i]<<",";
  }
  cout<<a[a.size()-1]<<"]"<<endl;
}

template<class T> bool ifinclude(vector<T> a,T x){
    auto itr=find(a.begin(),a.end(),x);
    return distance(a.begin(),itr)!=a.size();
}

int main(void){
  int N=getint();
  string s=getstr();
  string t=getstr();
  if(s==t){
    cout<<N<<endl;
    return 0;
  }
  int maxi=0;
  for(int i=1;i<N;i++){
    if(s.substr(N-i)==t.substr(0,i)){
      maxi=max(maxi,i);
    }
  }
  cout<<2*N-maxi<<endl;
  return 0;
}


Measured memory_bytes: 256
use std::io;
use std::io::prelude::*;

fn main() {
    let mut s = String::new();
    let _ = io::stdin().read_to_string(&mut s).unwrap();
    let v: Vec<i32> = s.trim_right()
                       .to_string()
                       .split_whitespace()
                       .map(|x| x.parse::<i32>().unwrap())
                       .collect();
    // let v: Vec<&str> = s.split('\n').collect();
    let n = v[0];
    let d = v[1];

    let m = n / (2 * d + 1);
    let r = n % (2 * d + 1);

    if r == 0 {
        println!("{}", m);
    } else {
        println!("{}", m + 1);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007LL
#define all(x) x.begin() , x.end()
#define ld long double
void solve();
vector<vector<ll> >adjx, adjy;
int32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int t = 1; //cin >> t;
	while (t--)
		solve();
	return 0;
}
void solve()
{
	ll h, w, tp; cin >> h >> w >> tp;
	adjx.resize(h);
	map<ll , ll >m;
	for (int i = 0; i < tp; i++)
	{
		ll u, v; cin >> u >> v;
		u--, v--;
		adjx[u].push_back(v);
		m[v]++;
	}
	multiset<pair<ll , ll > >s;
	for (auto x : m)
	{
		s.insert({x.second , x.first});
	}
	ll res = 0;
	for (int i = 0; i < h; i++)
	{
		for (auto y : adjx[i])
		{
			s.erase(s.find({m[y] , y}));
			m[y]--;
			s.insert({m[y] , y});
		}
		if (!adjx[i].empty())res = max({res , (ll)(s.rbegin()->first + adjx[i].size())});
		for (auto y : adjx[i])
		{
			s.erase(s.find({m[y] , y}));
			m[y]++;
			s.insert({m[y] , y});
		}
	}
	cout << res;
	cout << "\n";
	return ;
}


Measured memory_bytes: 57056
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  ll ans = 1;
  rep(i, 8) {
    if ((1 << i) > n) {
      ans = (1 << (i-1));
      break;
    }
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;
using ll = long long;


int main()
{
	ll a, b, c; cin >> a >> b >> c;
	if(c <= (a + b) ) {
		cout << b + c << endl;
	}else {
		cout << (a + b) + b + 1<< endl;
	}
}	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
int dig[100010] = {1};
ll dp[100010][13];
string S;
int main(){
    cin >> S;
    reverse(S.begin(), S.end());

    for(int i = 1; i <= S.size(); i++){
        dig[i] = dig[i - 1] * 10 % 13;
    }
    vector<int> q;
    dp[0][0] = 1;
    for(int i = 0; i < S.size(); i++){
        for(int j = 0; j < 13; j++){
            if(S[i] == '?') {
                for(int k = 0; k < 10; k++){
                    int r = (j + k * dig[i]) % 13;
                    dp[i + 1][r] = (dp[i + 1][r] + dp[i][j]) % mod;
                }        
            }
            else {
                int r = (j + (S[i] - '0') * dig[i]) % 13;
                dp[i + 1][r] = (dp[i + 1][r] + dp[i][j]) % mod;
            }
        }
    }
    cout << dp[S.size()][5] << endl;
    return 0;
}


Measured memory_bytes: 11008
#include <iostream>
#include <algorithm>
#include <stack>
#include <cstdio>
#include <string>

using namespace std;

int main(){ 
   char s[100];
   int ans=0;
   stack<int> S;
   int a,b;
   int x=0;
   while(scanf("%s",s)!=EOF){
       if(s[0]=='+'){
           b=S.top();
           S.pop();
           a=S.top();
           S.pop();
           S.push(a+b);
       }else if(s[0]=='-'){
           b=S.top();
           S.pop();
           a=S.top();
           S.pop();
           S.push(a-b);
       }else if(s[0]=='*'){
           b=S.top();
           S.pop();
           a=S.top();
           S.pop();
           S.push(a*b);
       }else{
           S.push(atoi(s));

       }
   }
   cout<<S.top()<<endl;
   return 0;
}


Measured memory_bytes: 3208
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i=0;i<N;i++) {
            A[i] = sc.nextInt();
        }
        Arrays.sort(A);
        long[] dp = new long[N+1];
        for (int i=0;i<N;i++) {
            dp[i+1] = dp[i]+A[i];
        }

        int ans = 0;
        for (int i=1;i<N;i++) {
            if (dp[i]*2>=A[i]) ans++;
            else ans=0;
        }
        System.out.println(ans+1);
    }
}

Measured memory_bytes: 50068
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    int A, B, P, Q, R; cin >> A >> B >> P >> Q >> R;
    double ans = (double)(B * (P + R) + A * Q) / (Q + R);
    cout << fixed << setprecision(9) << ans << endl;
    return 0;
}



Measured memory_bytes: 3292
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# 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;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9; 
const int N = 6e5+5;                                         
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}

int main () {
	SpeedForce;
	
	string res = "No";
	int cur = 0;
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int a, b;
		cin >> a >> b;
		if(a == b) {
			++cur;
		} else {
			cur = 0;
		}
		if(cur == 3) res = "Yes";
	}
	cout << res << '\n';
	
	return Accepted;
}

// B...a


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

int main() {
    int ans = 0;
    rep(i, 3) {
        char s;
        cin >> s;
        if (s == '1') ans++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<iomanip>
#include<math.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;

int main(){
    string s; cin >> s;
    int c = 0;
    rep(i, s.length()){
        if(s[i] == '?') s[i] = 'D';
    }
    cout << s << endl;
}


Measured memory_bytes: 3724
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
using namespace std;

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,m;
	cin>>n>>m;
	vector<int> v;
	v.push_back(m);
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	if(v.size()==2){
		cout<<v[1]-v[0]<<endl;
		return 0;
	}
	int ans=__gcd(v[1]-v[0],v[2]-v[1]);
	for(int i=3;i<v.size();i++){
		ans=__gcd(ans,v[i]-v[i-1]);
	}
	cout<<ans<<endl;
	return 0;
}
/*
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
using namespace std;

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,m;
	cin>>n>>m;
	vector<int> v;
	v.push_back(m);
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	int ans=0;
	for(int i=1;i<v.size();i++){
		ans=__gcd(ans,v[i]-v[i-1]);
	}
	cout<<ans<<endl;
	return 0;
}
*/
/*
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
using namespace std;
int n,m;
int a[100010];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>a[i];
	vector<int> v;
	v.push_back(abs(m-a[0]));
	for(int i=0;i<n-1;i++)v.push_back(abs(a[i]-a[i+1]));
	int ans=v[0];
	for(int i=1;i<v.size();i++)ans=__gcd(ans,v[i]);
	cout<<ans<<endl;
	return 0;
}
*/

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

int main(){
  int n;
  cin >> n;
  vector<int> v(n,0);
  r(i,n)cin >> v.at(i);
  int count=0,ma=0;
  r(i,n-1){
    if(v.at(i)>=v.at(i+1)){
      count++;
      ma=max(ma,count);
    }
    else count=0;
  }
  cout << ma <<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
using namespace std;



int main() {

	int n, a;
	cin >> n >> a;

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




Measured memory_bytes: 256
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <iostream>
#include <algorithm>
using namespace std;

long long K;
long long now = 0;

int main()
{
	cin >> K;
	if(K % 2 == 0 || K % 5 == 0)
	{
		printf("-1\n");
		return 0;
	}
	for(int i = 1;i <= K + 10;++i)
	{
		if(i == 1)
			now = 7 % K;
		else
			now = (now * 10 + (7 % K)) % K;
		if(now == 0)
		{
			printf("%d\n", i);
			return 0;
		}
	}
}

Measured memory_bytes: 3748
str_K = input()
k = int(str_K)
tmp_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(tmp_list[k-1])

Measured memory_bytes: 3060
#include<stdio.h>
  
int max(int a,int b){return (a<b?b:a);};
typedef struct {
  int p,s,deg,dep,h,left,right;
} Node;
  
Node t[100000];
int n;
  
void setdepth(int x){
  if(t[x].p==-1){
    t[x].dep=0;
    return;
  }
  if(t[x].dep==-1){
    setdepth(t[x].p);
    t[x].dep=t[t[x].p].dep+1;
  }
}
  
void setheight(int x){
  
  int l=t[x].left;
  int r=t[x].right;
  if(t[x].deg==0){
    t[x].h=0;
    return;
  }
  if(t[x].h==-1){
    if(l!=-1){
      setheight(l);
      t[x].h=max(t[x].h,t[l].h+1);
    }
    if(r!=-1){
      setheight(r);
      t[x].h=max(t[x].h,t[r].h+1);
    }
  }
}
  
void init(){
  int i;
  for(i=0;i<100000;i++){
    t[i].p=t[i].s=t[i].deg=t[i].dep=t[i].h=t[i].left=t[i].right=-1;
  }
}
  
int main(){
  init();
  int i,id,a,b;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&a,&b);
    if(a!=-1){
      t[id].left=a;
      t[a].p=id;
    }
    if(b!=-1){
      t[id].right=b;
      t[b].p=id;
    }
    if(a!=-1&&b!=-1){
      t[a].s=b;
      t[b].s=a;
    }
    t[id].deg=(a!=-1)+(b!=-1);
     
  }
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, ",i,t[i].p,t[i].s,t[i].deg);
    setdepth(i);
    setheight(i);
    printf("depth = %d, height = %d, ",t[i].dep,t[i].h);
      
    if(t[i].p==-1)printf("root\n");
    else if(t[i].deg!=0)printf("internal node\n");
    else printf("leaf\n");
      
  }
  return 0;
}



Measured memory_bytes: 5444
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>
#include <unordered_set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))
#define MAX(x,y) ((x)<(y)?(y):(x))

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

#define INF 1000000000

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return (ret);
}
/*
小数の桁数を指定する
	cout << setprecision(8)<< mp[0]-mx << endl;
*/
	ll mp[40000][10] = {0};
	ll two[40000][100] = {0};
	ll ans[1000] = {0};

int main()
{
	ll i,j,k,a,b,ans=0;
	char c;
	ll N,M,T, X,Y;
	cin >> N;
	ll mp[64] = {0};
	for(i=0;i<N;++i)
	{
		cin >> j;
		for(k=0;k<62;++k)
		{
			if(j & 1)
				mp[k] ++;
			j >>= 1;
		}
	}
	for(i=0;i<62;++i)
	{
		k = (mp[i]*(N-mp[i]))%1000000007;
		k *= ((ll)1<<i)%1000000007;
		ans += k;
		ans %= 1000000007;
	}
	cout << ans << endl;
	return 0;
}




















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

int main()
{
    int n,mini=100;
    int s[] = {0,0};
    cin >> n;
    int w[n];
    int sum[n];

    for(int i=0; i < n; ++i){
        cin >> w[i];
    }

    for(int j=0; j < n; ++j){
        for(int i=0; i < n; ++i){
            if(i < j){
                s[0] += w[i];
            }
            else{
                s[1] += w[i];
            }
        }
        if(s[0] > s[1]){
            sum[j] = s[0] - s[1];
        }
        else{
            sum[j] = s[1] - s[0];
        }
        s[0]=0;
        s[1]=0;
    }

    for(int t=0; t < n; ++t){
        if(mini > sum[t]){
            mini = sum[t];
        }
    }
        
    cout << mini;
    
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main (){
  
  	int a,b;
  	
  	cin>>a>>b;
  
  	if(a >= 13) cout<<b<<endl;
  
  	else if(a < 13 && a >= 6) cout<<b/2<<endl;
  
  	else if(a <= 5) cout<<"0"<<endl;	
  
 	return 0; 
  
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1

typedef struct{
  int parent, left, right;
}Node;

Node Tree[MAX];
int n, Depth[MAX];

int getDepth(int);
void print(int);

int child[MAX];

int main(void){
  int i, j;
  int degree, vertex;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    Tree[i].parent = NIL;
    Tree[i].left = NIL;
    Tree[i].right = NIL;
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &vertex, &degree);
    for ( j = 0; j < degree; j++ ){
      scanf("%d", &child[j]);

      Tree[child[j]].parent = vertex;
      
      //rightを決める基準となる。
      if(j == 0)
	Tree[vertex].left = child[0];
      
      else
	Tree[child[j - 1]].right = child[j];
    }
  }
  
  for ( i = 0; i < n; i++ )
    Depth[i] = getDepth(i);
  
  for ( i = 0; i < n; i++ )
    print(i);
  
  return 0;
}

int getDepth(int u){
  int d = 0;

  while(Tree[u].parent >= 0){
    u = Tree[u].parent;
    d++;
  }

  return d;
}

void print(int u){

  int i, cnt = 0;

  printf("node %d: parent = %d, depth = %d, ",u,Tree[u].parent,Depth[u]);

  if(Tree[u].parent == NIL)
    printf("root, [");

  else if(Tree[u].left == NIL)
    printf("leaf, [");

  else
    printf("internal node, [");

  u = Tree[u].left;
  while(u != NIL){
    if(cnt == 0)
      printf("%d",u); 

    else
      printf(", %d",u);
  
    u = Tree[u].right;
    cnt++;

    
 
 }


    printf("]\n");

}

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

const int mod = 1e9 + 7;
const int N = 5e5 + 50;

int n, f[N][3][3];
char s[N];

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

int main()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
	f[0][0][0] = 1;
	for (int i = 1; i <= n; ++i)
		for (int j = 0; j < 3; ++j)
			for (int k = 0; k < 3; ++k) // with j ones and k zeros.
			{
				if (s[i] != '1')
				{
					if (k == 2) add(f[i][j][k - 1], f[i - 1][j][k]);
					else add(f[i][j][k + 1], f[i - 1][j][k]);
				}
				if (s[i] != '0')
				{
					if (k == 0) add(f[i][j + (j != 2)][0], f[i - 1][j][k]);
					else add(f[i][j][k - 1], f[i - 1][j][k]);
				}
			}
	int ans = 0;
	for (int i = 0; i < 3; ++i) for (int j = 0; j <= i; ++j) add(ans, f[n][i][j]);
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 12288
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    ll L, R;
    cin >> L >> R;

    if (R - L >= 2019) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 2019;
    for (ll i = L; i <= R; i++) {
        for (ll j = i + 1; j <= R; j++) {
            // printf("%d, %d, %d\n", i, j, (i * j) % 2019);
            ll x = (i * j) % 2019;
            chmin(ans, x);
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace Contest
{

    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private long N;
        private long[] Pow;
        private void Scan()
        {
            Scanner sc = new Scanner();
            N = sc.NextInt();
        }

        public void Solve()
        {
            Scan();
            Pow = new long[32];
            Pow[0] = 1;
            for (int i = 1; i < 32; i++)
            {
                Pow[i] = Pow[i - 1] * -2;
            }
            Console.WriteLine(Calc(N));
        }

        private string Calc(long n)
        {
            if (n == 1 || n==0)
            {
                return n.ToString();
            }
            if (n > 0)
            {
                long nn = 0;
                int i;
                for (i = 0; true; i += 2)
                {
                    nn += Pow[i];
                    if (nn >= n) break;
                }

                string child = Calc(n - Pow[i]);
                return "1" + child.PadLeft(i, '0');
            }
            else if (n < 0)
            {
                long nn = 0;
                int i;
                for (i = 1; true; i += 2)
                {
                    nn += Pow[i];
                    if (nn <= n) break;

                }

                string child = Calc(n - Pow[i]);
                return "1" + child.PadLeft(i, '0');
            }

            return "";
        }

        static void Main() => new Program().Solve();
    }
}

Measured memory_bytes: 13268
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str0[105];

void solve()
{
    scanf("%s", str0);
    int n=strlen(str0);
    int i;
    for(i=0; i<n; i++) {
        str0[i]='x';
    }
    printf("%s\n", str0);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
typedef pair<long long, long long> P;
int main(){
    long long N;
    cin >> N;
    vector<long long> A(N), B(N);
    for(int i = 0; i < N; i++) cin >> A[i] >> B[i];
    priority_queue<P> q;
    vector<int> used(N, 0);
    for(int i = 0; i < N; i++){
        q.push(P(A[i] + B[i], i));
    }
    long long a = 0, b = 0;
    int flag = 0;
    while(!q.empty()){
        P v = q.top();
        q.pop();
        if(flag % 2 == 0) a += A[v.second];
        else b += B[v.second];
        flag++;
    }
    cout << a - b << endl;
}

Measured memory_bytes: 4340