akhauriyash/Code-Regression huggingface dataset:
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); for(int i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
int main()
{
	fio;
	ll n;
	cin>>n;
	vector<ld> a;
	ll i;
	ll o=0;
	forin(i,0,n-1)
	{
		long double q;
		cin>>q;
		a.push_back(q);
	}
	sort(a.begin(),a.end());
	ld sum=a[0];
	forin(i,1,n-1)
	{
		sum=sum+a[i];
		sum/=2;
	}
	cout<<setprecision(9)<<sum<<endl;
}



Measured memory_bytes: 256
n,m=gets.split.map &:to_i
a=[?.*(m+2)]+(1..n).map{?.+gets.chomp+?.}+[?.*(m+2)]
puts (1..n*m).any?{|e|
    i, j=e/m, e%m
    a[i][j]==?# && a[i-1][j]==?. && a[i+1][j]==?. && a[i][j-1]==?. && a[i][j+1]==?.
} ? :No : :Yes

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n; cin >> n;
	vector <vector<pair<int, int>>> edg(n);
	for (int i = 0; i < n - 1; i++) {
		int u, v, w; cin >> u >> v >> w;
		u--; v--;
		edg[u].emplace_back(v, w);
		edg[v].emplace_back(u, w);
	}
	vector<int> ans(n, -1);
	deque<int> que;
	que.push_back(0);
	ans[0] = 0;
	while (!que.empty()) {
		int pos = que.front();
		que.pop_front();

		for (const auto &p : edg[pos]) {
			if (ans[p.first] != -1) continue;
			que.push_back(p.first);
			ans[p.first] = p.second & 1 ? 1 - ans[pos] : ans[pos];
		}
	}
	for (int i = 0; i < n; i++) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
char s[100000+5];
char head[2*100000+5],tail[2*100000+5];
int n;
int main(){
    scanf("%s %d",s,&n);
    int ls=strlen(s);
    bool f=0;
    int t,tt;
    char ttt;
    int hc=0,tc=0;
    for(int i=0;i<n;i++){
        scanf("%d",&t);
        if(t==1)
            f=1-f;
        else{
            scanf("%d %c",&tt,&ttt);
            if((f+tt)%2)
                head[hc++]=ttt;
            else
                tail[tc++]=ttt;
        }


    }
    if(f){
        for(int i=tc-1;i>=0;i--)
            printf("%c",tail[i]);
        for(int i=ls-1;i>=0;i--)
            printf("%c",s[i]);
        for(int i=0;i<hc;i++)
            printf("%c",head[i]);
    }
    else{
        for(int i=hc-1;i>=0;i--)
            printf("%c",head[i]);
        for(int i=0;i<ls;i++)
            printf("%c",s[i]);
        for(int i=0;i<tc;i++)
            printf("%c",tail[i]);
    }
    printf("\n");
}


Measured memory_bytes: 896
import math

N, D = map(int, input().split())

X_list = []

for _ in range(N):
    X_list.append(list(map(int, input().split())))

res = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        dist_sq = 0
        for k in range(D):
            dist_sq += (X_list[i][k] - X_list[j][k]) ** 2
        if int(math.sqrt(dist_sq)) ** 2 == dist_sq:
            res += 1

print(res)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=998244353;
const int siz=1e5;
const long inf=1e9;
int main(){
	int A,B,C,X; cin>>A>>B>>C>>X;
	X /= 50;
	int cnt = 0;
	rep(i,0,A+1)rep(j,0,B+1)rep(k,0,C+1){
		if(10*i + 2*j + k == X) cnt++;
	}cout<<cnt<<endl;
}

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

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

    int sum = 0;
    int T[N + 1];
    for (int i = 1; i <= N; i++)
    {
        cin >> T[i];
        sum += T[i];
    }

    int M;
    cin >> M;
    int P, X;
    for (int i = 0; i < M; i++)
    {
        cin >> P >> X;
        cout << sum - T[P] + X << endl;
    }
}


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

char s[1000][1001];
int d[1000][1000],cnt[1000][1000];
int main(){
	int h,w;scanf("%d%d",&h,&w);
	rep(i,h)scanf("%s",s[i]);
	int Max=0;
	queue<P>que;
	rep(i,h)rep(j,w){
		if(s[i][j]=='.')continue;
		for(int k=-1;k<=1;k++){
			for(int l=-1;l<=1;l++){
				int x=i+k,y=j+l;
				if(0<=x&&x<h&&0<=y&&y<w&&s[x][y]=='.')cnt[i][j]++;
			}
		}
		if(cnt[i][j]>=s[i][j]-'0'){
			d[i][j]=Max=1;que.push(P(i,j));
		}
	}
	while(!que.empty()){
		P p=que.front();que.pop();
		for(int i=-1;i<=1;i++)for(int j=-1;j<=1;j++){
			int x=p.first+i,y=p.second+j;
			if(0<=x&&x<h&&0<=y&&y<w&&s[x][y]!='.'&&!d[x][y]){
				if(++cnt[x][y]>=s[x][y]-'0'){
					d[x][y]=Max=d[p.first][p.second]+1;que.push(P(x,y));
				}
			}
		}
	}
	printf("%d\n",Max);
}

Measured memory_bytes: 12064
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
#define N 110
#define W 100010
using namespace std;
ll dp[N][W], A[N], B[N], n;
ll fun(int a, int b){
	if(b < 0)
		return -1e9;
	if(a == n)
		return 0;
	if(dp[a][b] != -1)
		return dp[a][b];
	return dp[a][b] = max(A[a] + fun(a + 1, b - B[a]), fun(a + 1, b));
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int w;
	cin >> n >> w;
	for(int i = 0; i < n; i++)
		cin >> B[i] >> A[i];
	memset(dp, -1, sizeof(dp));
	cout << fun(0, w) << '\n';

}

Measured memory_bytes: 86272
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        if(x >= 2000) {
            System.out.println(1);
            return;
        }
        int y = x/100;
        int z = x%100;
        if(z > y * 5) {
            System.out.println(0);
        } else {
            System.out.println(1);
        }


    }

}


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

using namespace std;

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

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

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

int main(void){
  int N, M;
  cin >> N >> M;
  
  vector<int> count(N);
  vector<int> road(2*M);
  
  for (int i = 0; i < 2 * M; i++) {
    cin >> road.at(i);
  }
  
  for  (int i = 0; i < 2 * M; i++) {
    count.at(road.at(i) -1 )++;
  }
  
  for (int i = 0; i < N; i++){
    cout << count.at(i) << endl;
  }
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ii pair<ll, ll>
#define x first
#define y second
#define ll long long

using namespace std;

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

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

    vector<int> p(m+1);
    vector<int> sw[m+1];

    for(int i = 1; i<=m; i++)
    {
        int k;
        cin>>k;
        int s;
        while(k--)
        {
            cin>>s;
            sw[i].push_back(s);
        }
    }

    for(int i = 1; i<=m; i++)
    {
        cin>>p[i];
    }

    ll ans = 0;

    for(ll i = 0; i < (1LL << n); i++)
    {
        vector<bool> st(n+1, false);
        for(int bit = 0; bit<n; bit++)
        {
            if(i & (1LL << bit))
            {
                st[bit+1] = true;
            }
        }

        int onCnt = 0;

        for(int i = 1; i<=m; i++)
        {
            int cnt = 0;
            for(auto it : sw[i])
            {
                if(st[it])
                    cnt++;
            }
            if(cnt%2 == p[i])
                onCnt++;
        }

        if(onCnt == m)
            ans++;
    }

    cout<<ans;

    return 0;

}


Measured memory_bytes: 256
N=int(input())
A,B=[],[]
for i in range(N):
  x,y=map(int, input().split())
  A.append(x+y)
  B.append(x-y)
  
A=sorted(A)
B=sorted(B)
print(max(abs(A[0]-A[-1]),abs(B[0]-B[-1])))

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

#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MAX (int)1e9 + 99
#define maxof(a,b,c) max(a,max(b,c))
#define minof(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vb vector<bool>
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pa pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define MOD 998244353
#define bitcnt(x) __builtin_popcount(x)
#define gcd(a,b) __gcd(a,b)
#define all(x) (x).begin(),(x).end()
#define ts(x) to_string(x)
#define set0(x) memset(x, 0, sizeof(x))
const double pi = 3.14159265358979323846;
ll binpow(ll, ll);
ll mult(ll, ll);
ll add(ll , ll);
ll division(ll, ll);
ll nCr(ll, ll);
ll inv(ll);
void calc();
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) {if (!v.empty()) {os << v.front();for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];} return os;}
const int N=50010;
//ll fact[N];

void solve()
{
    int n;
    cin>>n;
    vector<double> p(n+1,0);
    srep(i,1,n) cin>>p[i];

    double dp[n+1][n+1];

    set0(dp);

    dp[0][0] = 1.0;

    srep(i,1,n)
    {
        dp[i][0] = dp[i-1][0] * (1-p[i]);
        srep(j,1,i)
        {
            dp[i][j] = dp[i-1][j] * (1-p[i]) + dp[i-1][j-1]*p[i];
        }
    }

    double ans = 0.0;
    srep(j,(n+1)/2,n)
    ans += dp[n][j];

    cout<<fixed<<setprecision(10)<<ans;
}

int main()
{
    fastio;
    
    int t=1;
    //cin>>t;
    
    rep(i,t)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}

ll add(ll a, ll b){
    a+=b;
    while(a>=MOD) a-=MOD;
    while(a<0) a+=MOD;
    return a;
}

ll mult(ll a, ll b){
    return (a * 1ll * b) % MOD;
}


ll binpow(ll a, ll b){
    ll c = 1;
    while(b > 0)
    {
        if(b % 2 == 1)
            c = mult(c, a);
        a = mult(a, a);
        b /= 2;
    }
    return c;   
}

ll inv(ll a){
    return binpow(a, MOD-2);
}

ll division(ll a, ll b){
    return mult(a, inv(b));
}
/*
ll nCr(ll n, ll r){
    if(r > n) return 0;
    return division(fact[n], mult(fact[n-r], fact[r]));
}

void calc(){
    fact[0] = 1;
    srep(i,1,N-1)
        fact[i] = (i*1ll*fac[i-1])%MOD;

}*/

Measured memory_bytes: 74180
#include <iostream>
 #include <cmath>
 using namespace std;
 int main(){
   long long n,a,b,c,d,e;cin>>n>>a>>b>>c>>d>>e;
   long long mx = 0;
   mx = max(0+(n%a == 0 ? n/a : n/a+1),++mx);
   mx = max(1+(n%b == 0 ? n/b : n/b+1),++mx);
   mx = max(2+(n%c == 0 ? n/c : n/c+1),++mx);
   mx = max(3+(n%d == 0 ? n/d : n/d+1),++mx);
   mx = max(4+(n%e == 0 ? n/e : n/e+1),++mx);
   cout << mx << endl;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define fi first
#define se second
#define mod 998244353
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // order_of_key
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int maxx = 3000000;
#define PI 3.14159265
ll dp[3005][3005];
int main()
{
    fastio;
    int n,s;
    cin>>n>>s;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=0;i<3002;i++)for(int j=0;j<3002;j++)dp[i][j] = 0;
    ll ans = 0;
    for(int i=1;i<=n;i++)
    {
        for(int j=a[i]+1;j<3002;j++)
        {
            dp[i][j]+= dp[i-1][j-a[i]];
            dp[i][j]%=mod;
        }
        dp[i][a[i]]+=i;
        dp[i][a[i]]%=mod;
        //trace2(i,dp[i][s]);
        ans = ans + 1LL*dp[i][s]*(n-i+1);
        ans%=mod;
        for(int j=0;j<3002;j++)
        {
            dp[i][j]+= dp[i-1][j];
            dp[i][j]%=mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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


void solve(long long A, long long B){
    cout << max(A+B, max(A-B, A*B)) << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  lol n, p, memo, ans = 1;
  cin >> n >> p;
  map<int, int> PrimeCount;
  if(n == 1) {
    ans *= p;
  } else {
    memo = p;
    for(lol i = 2;i * i <= p;i ++){
      while(memo % i == 0){
	PrimeCount[i] ++;
	memo /= i;
      }
      if(PrimeCount[i] >= n){
	ans *= pow(i, (PrimeCount[i] / n));
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 47104
from copy import deepcopy
from typing import List
import sys
input = sys.stdin.readline


def delete_cell_line(line: List[int], k: int) -> int:
    prev = -1
    block = 1
    point = 0
    for idx, num in enumerate(line+[0]):
        if num == prev:
            block += 1

        else:
            if block >= k:
                point += prev * block
                for i in range(idx-block, idx):
                    line[i] = 0
            block = 1
            prev = num
    return point


def drop_down(board: List[List[int]]):
    w = len(board[0])
    h = len(board)

    for x in range(w):
        vertical_line = []
        for y in range(h):
            cell = board[y][x]
            if cell:
                vertical_line.append(cell)

        vertical_line = [0]*(h-len(vertical_line)) + vertical_line
        for y, new_cell in enumerate(vertical_line):
            board[y][x] = new_cell


def calc_score(y: int, x: int, k: int, board: List[List[int]]) -> int:
    board[y][x] = 0
    drop_down(board)
    chain = 0
    score = 0
    while True:
        point = 0
        for line in board:
            point += delete_cell_line(line, k)
        if not point:
            break

        score += point * 2**chain
        chain += 1
        drop_down(board)
    return score


def main():
    h, w, k = map(int, input().split())
    board = []
    for _ in range(h):
        pre_line = input().rstrip("\n")
        line = list(map(int, list(pre_line)))
        board.append(line)

    ans = 0
    for y in range(h):
        for x in range(w):
            new_board = deepcopy(board)
            score = calc_score(y, x, k, new_board)
            if ans < score:
                ans = score

    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
  string n;
  cin>>n;
  int m[4];
  for(int i=0;i<4;++i) m[i]=n[i]-'0';
  
  string s="";
  for(int bit=0;bit<(1<<3);++bit){
    int sum=m[0];
    s="";
    for(int i=0;i<3;++i){
      if(bit&(1<<i)){
        sum+=m[i+1];
        s+='+';
      }
      else{
        sum-=m[i+1];
        s+='-';
      }
    }
    //cout<<bit<<":"<<sum<<endl;
    if(sum==7) break;
  }
  
  cout<<m[0]<<s[0]<<m[1]<<s[1]<<m[2]<<s[2]<<m[3]<<"=7"<<endl;
}

Measured memory_bytes: 256
sum_div = 0
M = []
for i in range(5):
    num = int(input())
    sum_div += num // 10
    mod = num % 10
    if mod != 0:
        M.append(mod)

if M:
    waiting = 10*(len(M)-1) + min(M)
else:
    waiting = 0
total = sum_div*10 + waiting
print(total)


Measured memory_bytes: 2940
N,Y = map(int,input().split())

x = -1
y = -1
z = -1

if Y <= N*10000 :
  for i in range(N+1):
    for j in range(N-i+1):
      if Y == i*10000 + j*5000 + (N-i-j)*1000:
        x = i
        y = j
        z = N-i-j
        break

print(f"{x} {y} {z}")

Measured memory_bytes: 9180
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <functional>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <valarray>
#include <algorithm>
#include <time.h>
#include <cstdlib>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main (void)
{
	long n,a[10000],b[10000],A,B;

	for (int i = 0; i < 10000; i++)
	{
		cin >> n;

		if (n == 0)
		{
			break;
		}

		for ( int j = 0; j < n; j++)
		{
			cin >> a[j] >> b[j];

			if (a[j] > b[j])
			{
				A += a[j] + b[j];
			}
			else if (a[j] < b[j])
			{
				B += a[j] + b[j];
			}
			else
			{
				A += a[j];
				B += b[j];
			}

		}
		cout << A << " " << B << endl;

		A = B = 0;
	}
}

Measured memory_bytes: 3160
#include<iostream>
#include<queue>
using namespace std;
int main(void){
	int num;
	queue<int> qu;
	int a,b;
	int n;

	cin>>n;
	while(n--){
		for(int i=0;i<10;i++){//ツボツーツδ仰づーツ詰ツづ淞づゥ
			cin>>num;
			qu.push(num);
		}
		a=0;
		b=0;
		while(1){
			if(a < qu.front()){
				a=qu.front();
			}else if(b < qu.front()){
				b=qu.front();
			}else{
				cout<<"NO"<<endl;
				break;
			}
			qu.pop();
			if(qu.empty()==true){
				cout<<"YES"<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
long long int Q,H,S,D,n,m;
int main ()
{
	while(cin>>Q>>H>>S>>D>>n)
	{
	    m=S;
        if(Q*4<m)
            m=4*Q;
        if(H*2<m)
            m=2*H;
        if(m*2<=D)
            cout<<n*m<<endl;
        else
        {
            if(n%2==1)
                cout<<m+n/2*D<<endl;
            else
                cout<<n/2*D<<endl;
        }
	}
}


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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; 0 <= i; i--)
#define CIN(A) int A; cin >> A;
#define CIN2(A, B) int A, B; cin >> A >> B;
#define CIN3(A, B, C) int A, B, C; cin >> A >> B >> C;
#define CINVEC(A, N) vector<int> A; REP(i, N) { int a; cin >> a; A.emplace_back(a); }
#define ANS(ans) cout << (ans) << endl
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())

#define DEBUGV(V) REP(i, V.size()) cout << V.at(i) << " "; cout << endl 

int
main()
{
  CIN3(A, B, K);

  vector<int> v;
  for (int i = A; i < A + K && i <= B; i++) v.emplace_back(i);
  for (int i = B; B - K < i && A <= i; i--) v.emplace_back(i);
  SORT(v);
  v.erase(unique(v.begin(), v.end()), v.end());
  
  
  REP(i, v.size()) ANS(v.at(i));

  return 0;
}
/* 3 8 2 */


Measured memory_bytes: 384
// LNU_Algotesters
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <fstream>
#include <complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 555;
const int MOD = INF;


int X[MAX];
int L[MAX];
int G[MAX];
int U[MAX];
int ANS[MAX * MAX];

int main()
{
    //freopen("in.txt", "r", stdin);
    //ios::sync_with_stdio(false); cin.tie(0);
    
    int I, O, J, L, X;
    cin >> I >> O >> X >> J >> L >> X >> X;
    LL ans = 2 * O;
    ans += I / 2 * 4;
    ans += L / 2 * 4;
    ans += J / 2 * 4;
    
    LL res = 2 * O;
    if (L && J && I)
    {
        res += 6;
        L--, J--, I--;
    }
    res += I / 2 * 4;
    res += L / 2 * 4;
    res += J / 2 * 4;
    
    cout << max(res, ans) / 2 << endl;
    
    
}




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var abcxy = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var result = 0;
        var min = Min(abcxy[3], abcxy[4]);
        if (abcxy[0] + abcxy[1] > 2 * abcxy[2])
        {
            result += abcxy[2] * 2 * min;
            if (min == abcxy[3])
                if (abcxy[1] > 2 * abcxy[2])
                    result += 2 * abcxy[2] * (abcxy[4] - abcxy[3]);
                else result += abcxy[1] * (abcxy[4] - abcxy[3]);
            else
            {
                if (abcxy[0] > 2 * abcxy[2])
                    result += 2 * abcxy[2] * (abcxy[3] - abcxy[4]);
                else result += abcxy[0] * (abcxy[3] - abcxy[4]);
            }
        }
        else result += abcxy[0] * abcxy[3] + abcxy[1] * abcxy[4];
        WriteLine(result);
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
using namespace std;
 
int N,Q;
string s;
vector<vector<char>> ju;
 
bool isdeadleft(int xp){
    int oxp = xp;
    for (int i=0; i<Q; i++){
    	char comp = ju[i][0];
    	char comm = ju[i][1];
    	if (s[xp] == comp) {
    		if (comm == 'L') {
	    		xp -= 1;
    		} else {
    			xp += 1;
    		}
    	}
    	if (xp < 0){
    		return true;
    	}
    	if (xp > N-1){
    		xp = N-1;
    	}
    }
    return false;
}
bool isdeadright(int xp){
    int oxp = xp;
    for (int i=0; i<Q; i++){
    	char comp = ju[i][0];
    	char comm = ju[i][1];
    	if (s[xp] == comp) {
    		if (comm == 'L') {
	    		xp -= 1;
    		} else {
    			xp += 1;
    		}
    	}
    	if (xp < 0){
    		xp=0;
    	}
    	if (xp > N-1){
    		return true;
    	}
    }
    return false;
}
 
int mid(int x1, int x2){
    return (int)((x1+x2)/2);
}
 
 
int main(void){

  cin >> N >> Q;
  cin >> s;
  for (int i=0; i<Q; i++){
  	char c1,c2;
  	cin >> c1 >> c2;
  	ju.emplace_back(vector<char>({c1,c2}));
  }
 
  int p1, p2, p3, ap;
 
if (isdeadleft(N-1) || isdeadright(0)){
    cout<<0<<endl;
    exit(0);
}
 
//left
p1 = 0;
p3 = N-1;
p2 = mid(p1,p3);
while (p3 - p1 != 1){
    if (isdeadleft(p2)){
    	p1 = p2; p2 = mid(p2,p3);
    } else {
    	p3 = p2; p2 = mid(p1,p2);
    }
}
int p;
if (isdeadleft(p1)){
	p = p3;
} else {
	p = p1;
}
//right
p1 = 0;
p3 = N-1;
p2 = mid(p1,p3);
while (p3 - p1 != 1){
    if (isdeadright(p2)){
        p3 = p2;
        p2 = mid(p1,p2);
    } else {
        p1 = p2;
        p2 = mid(p2,p3);
    }
}
int q;
if (isdeadright(p3)){
	q = p1;
} else {
	q = p3;
}
 
if (p > q){
	cout << 0 << endl;
} else {
    cout << q-p+1 << endl;
}
 
 
  return 0;
}

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

int main() {
  int a,first,i,sum=0;
  cin >> a >> first;
  for(first; first%2 == 0;first=first/2){
    i++;
  }
  
  
  for(a; a > 1; a--){
  	int M,temp=0;
    cin >> M;
    for(M; M%2 ==0;M=M/2){
      temp++;
    }
    if(temp <= i){
      sum = temp;
      i = temp;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    
    int a;
    int b;
    int c;
    int d;
    scanf("%d", &a);
    scanf("%d", &b);
    
    c = 2*(a + b);
    d = a * b;
    printf("%d %d\n", d, c);
    
    return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;
#define int long long
#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 FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;


signed main(){
	int N,K;
	cin >> N >> K;
	vector<int>a(N);
	vector<vector<int>>g(N);
	int ans = 0;
	REP(i,N){
		cin >> a[i];
		--a[i];
		if(i){
			g[a[i]].emplace_back(i);
		}else{
			ans += a[i] != 0;
		}
	}
	{
		auto dfs = [&](auto&&f,int now,int par) -> int {
			int height = 0;
			for(auto e:g[now]){
				if(e == par)continue;
				CHMAX(height,f(f,e,now));
			}
			if(now && height >= K - 1 && par != 0){
				++ans;
				height = -1;
			}
			return height + 1;
		};
		dfs(dfs,0,-1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 10112
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;


int N;
ll ans=0;

void solve();

int main(){
    scanf("%d", &N);

    solve();

    return 0;
}

void solve(){

    for(int i=1; i<N; i++){
        ans += (N - 1) /i;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int k,s;
  cin>>k>>s;
  int ans=0;
  for(int x=0;x<=k;x++){
    for(int y=0;y<=k;y++){
      int z=s-x-y;
      if(z>=0 && z<=k){
        ++ans;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int h, w;
    int i, j;

    for(;;){
      h = sc.nextInt();
      w = sc.nextInt();
      if(h == 0 && w == 0)break;

      for(i = 0;i < h;i++){
        for(j = 0;j < w;j++){
          if(i == 0 || j == 0 || i == h - 1 || j == w - 1){
            System.out.print("#");
          }else{
            System.out.print(".");
          }
        }
        System.out.println();
      }
      System.out.println();
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 24944
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  vector<Int> as(n),fs(n);
  for(Int i=0;i<n;i++) cin>>as[i];
  for(Int i=0;i<n;i++) cin>>fs[i];

  sort(as.rbegin(),as.rend());
  sort(fs.begin(),fs.end());

  auto check=
    [&](Int x)->Int{
      Int cnt=0;
      for(Int i=0;i<n;i++){
        if(cnt>k) return 0;
        Int ub=x/fs[i];
        cnt+=max(0LL,as[i]-ub);
      }
      return cnt<=k;
    };

  Int L=-1,R=1e12+1;
  while(L+1<R){
    Int M=(L+R)>>1;
    if(check(M)) R=M;
    else L=M;
  }
  cout<<R<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <cstdlib>
using namespace std;
 
int main () {
	int n,i,j,v,k;
	cin >> n;
	int a[n];
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	for(k=0;k<n;k++){
		if(k==n-1) cout << a[k];
		else cout << a[k] << " ";
	}
	cout << endl;
	for(i=1;i<=n-1;i++){
		v=a[i];
		j=i-1;
		while((j>=0)&&(a[j]>v)){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=v;
		for(k=0;k<n;k++){
			if(k==n-1) cout << a[k];
			else cout << a[k] << " ";
		}
		cout << endl;
	}
}

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

typedef long long ll;

bool vis[100050];
ll w[100050], nxt[100050], que[100050], output[100050];

int main(){
	int n, m;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%lld", &w[i]), nxt[i] = i;
	for(int i = n; i >= 1; i--) w[i] -= w[i-1];
	ll k;
	ll a;
	scanf("%d %lld", &m, &k);
	for(int i = 1; i <= m; i++) scanf("%lld", &a), swap(nxt[a], nxt[a+1]);
	for(int i = 1; i <= n; i++){
		if(!vis[i]) {
			int now = i, cnt = 0;
			while(!vis[now]){
				vis[now] = 1;
				que[++cnt] = now;
				now = nxt[now];
			}
			for(int j = 1; j <= cnt; j++){
				ll t = (0ll+j+k-2)%cnt+1;
				output[que[j]] = w[nxt[que[t]]];
			}
		}
	}
	ll p = 0;
	for(int i = 1; i <= n; i++) p += output[i], printf("%lld\n", p);
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
const int MAXN = 1e2+5,MAXM = 2e6+5,MOD = 1e9+7,INF = 0x3f3f3f3f,N=2e5;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const db eps = 1e-9;
#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define mid l + ((r-l)>>1)
#define rep(i,a,b) for(register int i=(a);i<=(b);i++)
#define pii pair<int,int>
#define vii vector<pii>
#define vi vector<int>
using namespace std;
char s[MAXN];
int k,n;
int main(){
    ios::sync_with_stdio(false);
    //freopen("../A.in","r",stdin);
    //freopen("../A.out","w",stdout);
    cin>>(s+1)>>k;
    n = strlen(s+1);
    s[n+1] = s[0] = 33;
    int cnt=0,a=1,b=1;
    ll ans=0;
    for(int i=1;i<=n+1;i++){
        if(s[i]!=s[i-1]){
            ans += cnt/2;
            cnt=1;
            continue;
        }
        cnt++;
    }
    for(int i=2;i<=n+1;i++){
        if(s[i] != s[i-1]){
            a=i-1;
            break;
        }
    }
    for(int i=n-1;i>=0;i--){
        if(s[i] != s[i+1]){
            b=n-i;
            break;
        }
    }
    bool ok=true;
    for(int i=2;i<=n;i++){
        if(s[i]!=s[i-1]){
            ok=false;
            break;
        }
    }
    if(ok)cout<<(ll)n*k/2<<'\n';
    else if(s[1] == s[n])cout<< ans*k - (a/2 + b/2 - (a+b)/2)*((ll)k-1)<<'\n';
    else cout<<ans*k<<'\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

class Graph {
	public int totalVertex;
	private int count=0;
	private LinkedList<LinkedList<Integer>> adjList;
	public LinkedList<Integer> visited;
	public LinkedList<LinkedList<Integer>> output;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		output = new LinkedList<LinkedList<Integer>>();
		visited = new LinkedList<Integer>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			output.add(new LinkedList<Integer>());
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	
	public void preVisit(int v) {
		output.get(v).add(++count);
	}
	
	public void setVisited(int v) {
		visited.add(v);
	}
	
	public void postVisit(int v) {
		output.get(v).add(++count);
	}
	
	public boolean ifVisited(int v) {
		return visited.contains(v);
	}
	
	public List<Integer> getNeighbors(int v){
		return adjList.get(v);
	}

	public void DFS(int v) {
		preVisit(v);
		setVisited(v);
		List<Integer> neighbors = getNeighbors(v);
		for(int i=0;i<neighbors.size();i++) {
			int v1 = neighbors.get(i);
			if(ifVisited(v1)==false) {
				DFS(v1);
			}
		}
		postVisit(v);
	}
}

public class Main {

	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.DFS(0);
		for(int i=0;i<g.totalVertex;i++) {
			if(!g.visited.contains(i)) {
				g.DFS(i);
			}
		}
		for(int i=0;i<g.output.size();i++) {
			System.out.println(i+1+" "+g.output.get(i).get(0)+" "+g.output.get(i).get(1));
		}
	}

}


Measured memory_bytes: 28492
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    map<ll,ll> mp;
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N){
        mp[A[i]] = i;
    }
    sort(A.begin(), A.end());
    //ll OtoE = 0;
    //ll EtoO = 0;
    ll cnt = 0;
    rep(i,N){
        if((mp[A[i]] % 2 == 0 && i % 2 == 1)){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 10392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (int) (1e9+7)
#define INF (int) 2e9

int main(){
    int a[10];
    rep(i, 10){
        cin >> a[i];
    }

    sort(a, a+10, greater<>());

    rep(i, 3){
        cout << a[i] << endl;
    }
    // printf("%d\n", N);
    return 0;
}


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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int A, B;
  cin >> A >> B;
  cout << max({A+B, A-B, A*B}) <<endl;
}

Measured memory_bytes: 3652
import itertools

N, K = map(int, input().split())

N_acum = list(itertools.accumulate(range(N+1)))
mod = 10**9+7
ans = 0
for i in range(K, N+1):
    ans += (N_acum[-1] - N_acum[-(i+1)]) - N_acum[i-1] + 1
    ans %= mod

ans = (ans+1)%mod

print(ans)

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

using namespace std;

int n,x;
int a[101];

int main()
{
    scanf("%d%d",&n,&x);
    for(int i = 1;i <= n;i++)
        scanf("%d",&a[i]);
    int ans = 1;
    int s = 0;
    for(int i = 1;i <= n;i++)
    {
        ans++;
        s += a[i];
        if(s >= x)
        {
            if(s > x)
                ans--;
            break;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ull = unsigned long long;
using ul = unsigned;
using ll = long long;
#define mod 10e+7+7
#define rep(i,a,b) for (int i =a;i<b;++i)
using namespace std;
void solve();
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin); 
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
#endif
	int t=1;
	//cin>>t;
	while(t--)
	{
	solve();
	 cout<<"\n";
	}
	
	cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	return 0;

}

void solve()
{
	ll n,wt;
	cin>>n>>wt;
	ll w[n];
	ll v[n];
	rep(i,0,n)
	{
		cin>>w[i]>>v[i];

	}
	
	ll dp[n][wt+1];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=wt;j++)
			dp[i][j]=0;
	}
	dp[0][0]=0;
	dp[0][w[0]]=v[0];
	for(int i=1;i<n;i++)
	{
		dp[i][0]=0;
		for(int j=1;j<=wt;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j>=w[i])
			dp[i][j]=max(dp[i][j],v[i]+dp[i-1][j-w[i]]);
		}

	}
	 ll an=0;
	 for(ll j=1;j<=wt;j++)
	 {
	 	//cout<<dp[n-1][j]<<endl;
	 	an=max(an,dp[n-1][j]);
	 } 
	 cout<<an;
	




	

}

Measured memory_bytes: 81892
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
const ll mod =1e9+7;
struct node
{
    int v,w;
};
vector<node>g[N];
int vis[N];
void dfs(int x)
{
    int sz=g[x].size();
    for(int i=0;i<sz;i++)
    {
        int v=g[x][i].v,w=g[x][i].w;
        if(vis[v]!=-1)continue;
        if(w&1)
            vis[v]=1^vis[x];
        else
            vis[v]=vis[x];
        dfs(v);
    }
}
int main()
{
    memset(vis,-1,sizeof vis);
    int n,u,v,w;
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        scanf("%d%d%d",&u,&v,&w);
        g[u].push_back({v,w});
        g[v].push_back({u,w});
    }
    vis[1]=0;
    dfs(1);
    for(int i=1;i<=n;i++)printf("%d\n",vis[i]);
    return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define PI 3.14159265359
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  ll n;
  cin >> n;
  ll a[n];
  vector<vector<ll>> v(n);
  FOR(i,0,n-1) {
    cin >> a[i];
    ll input = a[i];
    FOR(j,0,65){
      if(input>0){
        v[i].PB(input%2);
        input /= 2;
      }
      else{
        v[i].PB(0);
      }
    }
  }

  ll ans = 0;
  const ll MOD = pow(10,9) + 7;

  FOR(i,0,60){
    ll cnt = 0;
    FOR(j,0,n-1){
      if(v[j][i]==1) ++cnt;
    }
    ans += (cnt * (n-cnt) % MOD) * ((1LL << i)%MOD) % MOD;
    ans %= MOD;
  }

  cout << ans << endl;

}



Measured memory_bytes: 314368
import java.util.*;
public class Main
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); int l = sc.nextInt();
        int [] a = new int [n];
        long total = 0; boolean ok = false; int stor = -1;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt(); total += a[i];
            if (i != 0) {
                if (a[i] + a[i-1] >= l) {
                    stor = i - 1; ok = true;
                }
            }
        }
        if (!ok) System.out.println("Impossible");
        else {
            System.out.println("Possible");
            for (int i = 0; i < stor; i++) {
                System.out.println(i + 1);
            }
            for (int i = n - 1; i > stor + 1; i--) {
                System.out.println(i);
            }
            System.out.println(stor + 1);
        }
    }


}

Measured memory_bytes: 61136
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<ext/pb_ds/priority_queue.hpp>
using namespace std;

const int maxn = 3E5 + 30;
typedef long long LL;

int n,A[maxn];
LL Ans;

int main()
{
	#ifdef DMC
		freopen("DMC.txt","r",stdin);
	#endif
	
	cin >> n;
	for (int i = 1; i <= 3 * n; i++) scanf("%d",&A[i]);
	sort(A + 1,A + 3 * n + 1);
	for (int i = 0; i < n; i++) Ans += 1LL * A[3 * n - 1 - 2 * i];
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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 x,y;
    cin >> x >> y;
    if(x*4<y||x*2>y){
        cout << "No" << endl;
    }
    else{
        int a=y-x*2;
        if(a%2==1){
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
        }
    }
}


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

int main() {
  int64_t a,b;
  cin>>a>>b;
  int x = b-a;
  if (a*b <= 0) cout << "Zero" << endl;
  else if (a>=0) cout << "Positive" << endl;
  else if (x%2) cout << "Positive" << endl;
  else cout << "Negative" << endl;
  
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
   int a=700;
   string s;
   cin >> s;
   if(s[0]=='o') a+=100;
   if(s[1]=='o') a+=100;
   if(s[2]=='o') a+=100;
   cout << a <<endl;
   
   return 0;
  
}

Measured memory_bytes: 256
n = int(input())
la = list(map(int, input().split()))
lb = list(map(int, input().split()))
lc = list(map(int, input().split()))

ans = 0
e = -1
for a in la:
  ans += lb[a - 1]
  if e == a - 1:
    ans += lc[e - 1]
  e = a
 
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

int main() {
  int i, n, j, a, b;
  char c;
  while(cin >> n) {
    getchar();
    while(n--) {

      vector<int> v;
      while( scanf("%c", &c) != EOF ) {
	if(c == '\n') break;
	v.push_back(c - '0');
      }
      sort(v.begin(), v.end());
      a = b = 0;
      
      for(j = 0; j < v.size(); j++) {
	a += v[j] * pow(10, j);
      }
     
      reverse(v.begin(), v.end());
      
      for(j = 0; j < v.size(); j++) {
	b += v[j] * pow(10, j);
      }
      
      cout << a - b << endl;
      
    }
  }
  return 0;
}
    
    
    

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

class Dice{
    int _num[6];
  public:

    void set(int num[6]){
        for(int i=0;i<6;i++){
            _num[i] = num[i];
        }
    }
    int Get(int n){
        return _num[n];
    }
    void N(){
        int buf = _num[0];
        _num[0] = _num[1];
        _num[1] = _num[5];
        _num[5] = _num[4];
        _num[4] = buf;
    }
    void S(){
        int buf = _num[0];
        _num[0] = _num[4];
        _num[4] = _num[5];
        _num[5] = _num[1];
        _num[1] = buf;
    }
    void W(){
        int buf = _num[0];
        _num[0] = _num[2];
        _num[2] = _num[5];
        _num[5] = _num[3];
        _num[3] = buf;
    }
    void E(){
        int buf = _num[0];
        _num[0] = _num[3];
        _num[3] = _num[5];
        _num[5] = _num[2];
        _num[2] = buf;
    }
    void SetTop(int n){
        if(_num[2]==n)
            W();
        else if(_num[3]==n)
            E();
        else{
            while(true){
                if(_num[0]==n)
                    break;
                S();
            }
        }
    }
    void SetFront(int n){
            while(true){
                if(_num[1]==n)
                    break;
                S();
                W();
                N();
            }
    }
};

int main(void){
    int num[6];
    for(int i=0;i<6;i++){
        int n;
        cin >> n;
        num[i] = n;
    }
    
    Dice d1;
    d1.set(num);
    
    for(int i=0;i<6;i++){
        int n;
        cin >> n;
        num[i] = n;
    }
    
    Dice d2;
    d2.set(num);
    
    d1.SetTop(d2.Get(0));
    d1.SetFront(d2.Get(1));
    
    bool same = true;
    for(int i=0;i<6;i++){
        if(d1.Get(i) != d2.Get(i)){
            same=false;
            break;
        }
    }
    
    if(same){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import queue
dxy=[(1,0),(0,1),(-1,0),(0,-1)]
def bfs(sx,sy,H,W):#幅優先探索
    q=queue.Queue()
    visited=[[False]*W for _ in range(H)]
    q.put((sx,sy))
    visited[sx][sy]=True
    ans=1
    while not q.empty():
        px,py=q.get()
        for dx,dy in dxy:
            nx=px+dx
            ny=py+dy
            if 0<=nx<H and 0<=ny<W:
                if c[nx][ny]=='.' and visited[nx][ny]==False:
                    visited[nx][ny]=True
                    q.put((nx,ny))
                    ans+=1
    return ans
while True:
    W,H=map(int,input().split())
    if(W==0 and H==0):
        break
    c=[input() for _ in range(H)]
    for i in range(H):
        if "@" in c[i]:
            sx=i
            sy=c[i].index("@")
    print(bfs(sx,sy,H,W))


Measured memory_bytes: 6848
function Main(input) {
	const data = input.split('\n');
	const n = data[0];
	let givenCards = '';
	const egara = ['S', 'H', 'C', 'D'];
	let tramps = [];
	let result = '';

	for (let i = 1; i <= n; i++) {
		givenCards += data[i] + '  ';
	}

	for (let i = 0; i < 4; i++) {
		for (let j = 1; j <= 13; j++) {
			tramps.push(egara[i] + ' ' + j);
		}
	}

	for (let i = 0; i < 52; i++) {
		if (givenCards.indexOf(tramps[i] + ' ') === -1) {
			console.log(tramps[i]);
		}
	}
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int LinearSearch(int n,int q,int S[],int T) {
	int i = 0;
	S[n] = T;
	while (S[i] != T) i++;

	
	return i!=n;

}
int main() {

	int S[100000],T,n,q,i,c=0;

	cin >> n;
	for (i = 0; i < n; i++) cin >> S[i];
	cin >> q;

	for (i = 0; i < q; i++) {
		cin >> T;

		if (LinearSearch(n, q, S, T)) c++;
	}

	cout << c<<endl;


	
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	
	float n,x,t;
	cin>>n>>x>>t;
	float a=n/x;
	
	ll ans=(ll)(ceil(a)*t);
	cout<<ans;



	return 0;
}

Measured memory_bytes: 3704