akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi = acos(-1);
#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

bool solve(vector<ll> A) {
    ll n = A.size();
    // ΣA[i] を求める
    ll sum = 0;
    REP(i, n) {
        sum += A[i];
    }
    // 1回の操作で取り除く個数
    ll K = n * (n+1) / 2;
    // 割り切れないとどう頑張ってもちょうど全部取り除けない
    if (sum % K != 0) {
        return false;
    }
    // 合計操作回数
    ll T = sum / K;
    REP(i, n) {
        // 隣との差を埋められるか
        ll d = A[(i+1)%n] - A[i] - T;
        if (d > 0 || -d % n != 0) {
            return false;
        }
    }
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // メインプログラムここから
    ll n; cin >> n;
    vector<ll> A(n);
    REP(i, n) {
        cin >> A[i];
    }
    if (solve(A)) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


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

const int INF = 2e9 + 10;

int main() {

    int n; scanf("%d", &n);

    vector <int> h(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &h[i]);
    }

    vector <int> dp(n + 1, INF);
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i]);
        if (i - 2 >= 0) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    printf ("%d\n", dp[n - 1]);

    return 0;
}

Measured memory_bytes: 1024
n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=[sum(p[0:k])]
for i in range(1,n-k+1):
  ans.append(ans[i-1]+p[i+k-1]-p[i-1])
max_value=max(ans)
max_index=ans.index(max_value)
total=0
for i in p[max_index:max_index+k]:
  total+=(i+1)/2
print(total)

Measured memory_bytes: 25060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long int count=0;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				if(arr[i]+arr[j]>arr[k] && arr[i]+arr[k]>arr[j] && arr[j]+arr[k]>arr[i] && arr[i]!=arr[j] && arr[i]!=arr[k] && arr[j]!=arr[k])
					count++;
			}
		}
	}
	cout<<count;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
vector<vector<int> > g;
int n,m;
int s=1;
int main()
{
	cin >> n >> m;
	g.resize(n+1);
	for (int i = 0;i < m;i++)
	{
		int p, t;
		cin >> p >> t;
		g[p].push_back(t);
		g[t].push_back(p);
	}
	queue<int> q;
	q.push(s);
	vector<bool> used(n+1);
	vector<int> d(n+1), p(n+1);
	used[s] = true;
	p[s] = -1;
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		for (size_t i = 0; i<g[v].size(); ++i) {
			int to = g[v][i];
			if (!used[to]) {
				used[to] = true;
				q.push(to);
				d[to] = d[v] + 1;
				p[to] = v;
			}
		}
	}
	if (d[n] == 2)
		cout << "POSSIBLE";
	else
		cout << "IMPOSSIBLE";
	//system("pause");
	return 0;
}

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

int main() {
  int A,B,C,D,E,F; cin >> A >> B >> C >> D >> E >> F;
  double maxP = -1.0;
  int ans1,ans2;
  for ( int i = 0; i < 31; i++ ) {
    for ( int j = 0; j < 31; j++ ) {
      if ( i == 0 && j == 0 ) continue;      
      for ( int k = 0; k < 101; k++ ) {
	for ( int l = 0; l < 101; l++ ) {
	  int water = 100*A*i + 100*B*j;
	  int sugar = k * C + l * D;
	  int sum = water + sugar;
	  if ( sum > F ) continue;
	  double p = 100.0*sugar/sum;
	  if ( p <= 100.0*E/(100.0+E) && maxP < p ) {
	    maxP = p;
	    ans1 = sum;
	    ans2 = sugar;
	  }
	}
      }
    }
  }
  cout << ans1 << " " << ans2 << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
ss = []
for _ in range(N):
    ss.append(''.join(sorted(input())))
d = {}
for s in ss:
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
print(sum(int((v * (v - 1)) / 2) for v in d.values() if v > 1))


Measured memory_bytes: 19404
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int cnt = 0;
		if(n/100 == 1) cnt++;
		if(n/10%10 == 1) cnt++;
		if(n%10 == 1) cnt++;
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21588
#[macro_use]
mod utils {
    macro_rules! input {
        ($($r:tt)*) => {
            let stdin = std::io::stdin();
            let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
            let mut next = move || -> String{
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c|c.is_whitespace())
                    .take_while(|c|!c.is_whitespace())
                    .collect()
            };
            input_inner!{next, $($r)*}
        };
    }
    macro_rules! input_inner {
        ($next:expr) => {};
        ($iter:expr, ) => {};

        ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
            let $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
        ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
            let mut $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
        ($next:expr, _ : $t:tt $($r:tt)*) => {
            let _ = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
    }
    macro_rules! read_value {
        ($next:expr, ( $($t:tt),* )) => {
            ( $(read_value!($next, $t)),* )
        };
        ($next:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        };
        ($next:expr, chars) => {
            read_value!($next, String).chars().collect::<Vec<char>>()
        };
        ($next:expr, usize1) => {
            read_value!($next, usize) - 1
        };
        ($next:expr, $t:ty) => {
            $next().parse::<$t>().expect("Parse error")
        };
    }
}

fn main() {
    input! {
        a:i32,b:i32
    }

    for i in 0..100_000 {
        if (i as f64 * 0.08) as i32 == a && (i as f64 * 0.1) as i32 == b {
            println!("{}", i);
            return;
        }
    }
    println!("-1");
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<std::string> s(n);
    std::vector<int> t(n);
    for (int i = 0; i < n; i++) std::cin >> s[i] >> t[i];
    int sum = std::accumulate(t.begin(), t.end(), 0);
    std::string x; std::cin >> x;
    for (int i = 0; i < n; i++) {
        sum -= t[i];
        if (s[i] == x) break;
    }
    std::cout << sum << std::endl;
    return 0;
}


Measured memory_bytes: 256
//35
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

struct P{
  char c;
  int x,y;
  bool operator<(P a)const{
    if(c!=a.c){
      return c<a.c;
    }else{
      return x<a.x;
    }
  }
};

int main(){
  int m,n;
  cin>>m>>n;
  vector<P> v;
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      char c;
      cin>>c;
      if(c!='.'){
	P p={c,j,i};
	v.push_back(p);
      }
    }
  }
  sort(v.begin(),v.end());
  int s=0;
  for(;;){
    int b=s;
    for(int i=0;i<v.size();i+=2){
      if(v[i].x==v[i+1].x){
	if(abs(v[i].y-v[i+1].y)==1)goto next;
	for(int j=0;j<v.size();j++){
	  if(v[j].x==v[i].x&&min(v[i].y,v[i+1].y)<v[j].y&&v[j].y<max(v[i].y,v[i+1].y))goto next;

	}
	v.erase(v.begin()+i,v.begin()+i+2);
	s+=2;
	break;
      }else if(v[i].y==v[i+1].y){
	if(abs(v[i].x-v[i+1].x)==1)goto next;
	for(int j=0;j<v.size();j++){
	  if(v[j].y==v[i].y&&min(v[i].x,v[i+1].x)<v[j].x&&v[j].x<max(v[i].x,v[i+1].x))goto next;

	}
	v.erase(v.begin()+i,v.begin()+i+2);
	s+=2;
	break;
      }else{
	bool o[2]={};
	for(int j=0;j<v.size();j++){
	  if(v[i].y<v[i+1].y){
	    o[0]|=(v[i].y==v[j].y&&v[i].x<v[j].x&&v[j].x<=v[i+1].x)
	      ||(v[i+1].x==v[j].x&&v[i].y<=v[j].y&&v[j].y<v[i+1].y);
	    o[1]|=(v[i].x==v[j].x&&v[i].y<v[j].y&&v[j].y<=v[i+1].y)
	      ||(v[i+1].y==v[j].y&&v[i].x<=v[j].x&&v[j].x<v[i+1].x);
	  }else{
	    o[0]|=(v[i].y==v[j].y&&v[i].x<v[j].x&&v[j].x<=v[i+1].x)
	      ||(v[i+1].x==v[j].x&&v[i+1].y<v[j].y&&v[j].y<=v[i].y);
	    o[1]|=(v[i].x==v[j].x&&v[i+1].y<=v[j].y&&v[j].y<v[i].y)
	      ||(v[i+1].y==v[j].y&&v[i].x<=v[j].x&&v[j].x<v[i+1].x);
	  }
	}
	if(o[0]&&o[1])goto next;
	v.erase(v.begin()+i,v.begin()+i+2);
	s+=2;
	break;
      }
    next:
      ;
    }
    if(b==s)break;
  }
  cout<<s<<endl;
  return 0;
}

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

#define int long long
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()

#define fast ios::sync_with_stdio(0); cin.tie(0)
#define print(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1> void __f(const char* name, Arg1&& arg1){
  cout << name << ": " << arg1 << '\n';
}

template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

const int sz = 2e5+1;
const int mod = 1e9+7;
int fact[sz],ifact[sz];


int fastmod(int base,int exp){

  if(exp==0) return 1;
  else if(exp%2==0){
    int ans=fastmod(base,exp/2);
    return (ans%mod*ans%mod)%mod;
  }
  else{
    return (fastmod(base,exp-1)%mod*base%mod)%mod;
  }
}

void factifact(){
    
    fact[0] = 1;
    for(int i=1;i<sz;i++) fact[i] = (i * fact[i-1])%mod;
    
    ifact[sz-1] = fastmod(fact[sz-1],mod-2);
    for(int i=sz-2;i>=0;i--) ifact[i] = (ifact[i+1] * (i+1))%mod;
}

int nCr(int n,int r){
  return (fact[n]*(ifact[n-r]%mod*ifact[r]%mod)%mod)%mod;
}

int32_t main(){

    fast;
    factifact();

    int h,w,a,b; cin >> h >> w >> a >> b;
    h--;
    w--;

    int cnt = 0;

    for(int i=h-a+1;i<=min(b+h-a,h);i++){
      cnt+=(nCr(b+h-a,i)%mod*nCr(w-b+a,h-i)%mod)%mod;
      cnt%=mod;
    }
    
    int ans = (nCr(w+h,h)%mod - cnt%mod + mod)%mod;

    cout << ans << '\n';
 
    return 0;
} 


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
const int N=1e18;



int32_t main()
{

	
    IOS;
	

	int n,K;
	cin>>n>>K;
	int mincost[n+1];
	int A[n+1];
	// int cost1,cost2;
	
	for(int i=1;i<=n;i++)
	{
		cin>>A[i];
	}
	mincost[1]=0;

	if(n==1) return cout<<0<<endl,0;

	int cost=N;

	for(int i=2;i<=n;i++)
	{
		for(int j=max(i-K,1LL);j<=(i-1);j++)
		cost=min(cost,(mincost[j]+abs(A[i]-A[j])));

		mincost[i]=cost;
		cost=N;
	}

	cout<<mincost[n]<<endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  string s; cin >> s;
  int count = 0; rep(i,N) if (s[i]=='R') count++;
  string result = (count>N-count) ? "Yes" : "No";
  cout << result << endl;
  return 0;
}

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

public class Hello
{
    public static void Main()
    {
        var t = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < t; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var k = int.Parse(line[1]);
            string[] line2 = Console.ReadLine().Trim().Split(' ');
            var a = Array.ConvertAll(line2, int.Parse);
            var deff = new List<int>();
            for (int j = 1; j < n; j++) deff.Add(a[j] - a[j - 1]);
            deff.Sort();
            deff.Reverse();
            var ret = 0;
            for (int j = k - 1; j < deff.Count(); j++) ret += deff[j];
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 27032
#include<iostream>

int main(){
	int a, b, c, d, e,f,g;
	f = 0;
	g = 0;
	std::cin >> a >> b >> c >> d >> e;
	if (a <= c && a <= b){
		f = a;
	}
	if (b <= c && b <= a){
		f = b;
	}
	if (c <= a && c <= b){
		f = c;
	}
	if (d <= e){
		g = d;
	}
	if (e < d){
		g = e;
	}
	std::cout << f + g - 50 << std::endl;
	return 0;
}

Measured memory_bytes: 3092
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    r = i_input()
    g = i_input()

    print(g+g-r)
 
if __name__ == '__main__':
    main()


Measured memory_bytes: 77104
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      	String a[] = sc.next().split("");
        for(int i = 0;i < a.length;i++){
          if(a[i].equals(",")){
            System.out.print(" ");
          }else{
            System.out.print(a[i]);
          }
        }
      	System.out.println("");
      
    }
}

Measured memory_bytes: 35644
#include<iostream>
#include<algorithm>
using namespace std;
int n,a,fp,fc,tc,hc,tp,hp,t[201],h[201],T[100],H[100];
void init();
int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    init();
    for(int i=0;i<n;i++){
      cin>>a;
      t[a]=1;
      T[i]=a;
    }
    a=0;
    for(int i=1;i<=2*n;i++){
      if(t[i]==0){
	h[i]=1;
	H[a++]=i;
      }
    }
    sort(T,T+n);
    sort(H,H+n);
    // for(int i=0;i<n;i++){
    //   cout<<T[i]<<' '<<H[i]<<endl;
    //  }
    tc=hc=fc=fp=0;
    tp=hp=n;
    
    while(1){
      if(tp==0||hp==0)break;
      
      tc=hc=0;
      
      if(fc%2==0){	
	fc++;
	while(T[tc]<fp&&tc<n)tc++;
	if(tc==n){
	  fp=0;
	  continue;
	}
	//cout<<T[tc]<<" t "<<fc<<endl;
	fp=T[tc++];
	T[tc-1]=-1;
	tp--;
	

      }else{
	fc++;
	while(H[hc]<fp&&hc<n)hc++;
	if(hc==n){
	  fp=0;
	  continue;
	}
	//cout<<H[hc]<<" h "<<fc<<endl;
	fp=H[hc++];
	H[hc-1]=-1;
	hp--;
      

      }
    }
    
    cout<<hp<<endl;
    cout<<tp<<endl;
  }
  return 0;
}
void init(){
  for(int i=0;i<201;i++){
    t[i]=h[i]=0;
  }
  for(int i=0;i<100;i++){
    T[i]=H[i]=-1;
  }
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    
    int a,b;
    cin >> a >> b;
    Yes((a&1)&&(b&1));
    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    a = LI()
    p = [c / 100.0 for c in LI()]
    d = collections.defaultdict(lambda: 1.0)
    e = collections.defaultdict(lambda: 1)

    r = 0
    for k in range(1,1<<n):
        t = [i for i in range(n) if k & (1 << i)]
        l = k & (k-1)
        d[k] = d[l] * p[t[0]]
        e[k] = e[l] * a[t[0]] // fractions.gcd(a[t[0]], e[l])
        o = m // e[k]
        if len(t) % 2 == 1:
            r += o * d[k]
        else:
            r -= o * d[k]


    return '{:0.8f}'.format(r)


print(main())



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  ll n, yin;
  cin >> n >> yin;
  yin /= 1000;
  if (n > yin)
  {
    cout << "-1 -1 -1";
    return;
  }

  for(int x = 0; x <= yin/10 + 1; ++x)
  {
    for(int y = 0; y <= yin/5 + 1; ++y)
    {
      int z = n - x - y;
      if (z < 0) continue;
      if (10 * x + 5 * y + z == yin)
      {
        cout << x << " " << y << " " << z;
        return;
      }
    }
  }
  cout << "-1 -1 -1";
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

using namespace std;

int main() {
    stack<int> s;

    string op;
    while (cin >> op) {
        //cout << op << endl;
        if (op == "+") {
            int a = s.top(); s.pop();
            int b = s.top(); s.pop();
            s.push(a + b);
        } else if (op == "-") {
            int a = s.top(); s.pop();
            int b = s.top(); s.pop();
            s.push(b - a);
        } else if (op == "*") {
            int a = s.top(); s.pop();
            int b = s.top(); s.pop();
            s.push(a * b);
        } else {
            s.push(atoi(op.c_str()));
        }
        //cout << s.top() << endl;
    }

    cout << s.top() << endl;

    return 0;
}


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

int main() {
 string num;
 cin >> num;
 int n = num.length();
 if(n == 3){
   cout << "ABC" << num << endl;
 }
 else if(n == 2){
   cout << "ABC" << '0' + num << endl;
 }
 else{
   cout << "ABC" << "00" + num << endl;
 }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int main() {
    int a[10001];
    int G[101][101];
    int h,w,n,temp=1;
    scanf("%d %d %d",&h,&w,&n);
    for(int i=1;i<=n;++i){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=h;++i){
        if(i%2){
            for(int j=1;j<=w;++j){
               if(a[temp]>0) {
                    G[i][j]=temp;
                    --a[temp];
                }
               else if(a[temp]==0) {
                    ++temp;
                    G[i][j]=temp;
                    --a[temp];
                }
            }
        }else{
            for(int j=w;j>=1;--j){
                if(a[temp]>0) {
                    G[i][j]=temp;
                    --a[temp];
                }
               else if(a[temp]==0) {
                    ++temp;
                    G[i][j]=temp;
                    --a[temp];
                }
            }
        }
    }
    for(int i=1;i<=h;++i){
        for(int j=1;j<=w;++j){
            if(j!=w) 
                printf("%d ",G[i][j]);
            else 
                printf("%d\n",G[i][j]);
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

const double PI=acos(-1.0);

int main() {
    double r;
    cin >> r;

    double ans = 2 * r * PI;

    printf("%.10f", ans);
    
    return 0;
}


Measured memory_bytes: 3752
S = input()
T = input()

dp = [[0]*(len(T)+1) for _ in range(len(S)+1)]

for i in range(1, 1+len(S)):
    for j in range(1, 1 + len(T)):
        dp[i][j] = max(dp[i-1][j], dp[i][j-1], dp[i-1]
                       [j-1] + (S[i-1] == T[j-1]))

#print(*dp, sep='\n')
# print(dp[-1][-1])

length = dp[-1][-1]
ans = ''
i = len(S)
j = len(T)
while length > 0:
    if S[i-1] == T[j-1]:
        ans = S[i-1] + ans
        i -= 1
        j -= 1
        length -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        j -= 1

print(ans)


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

int main() {
    unsigned long long h,w;
    cin >> h >> w;
  if(h==1||w==1){
    cout << 1 << endl;
    return 0;
  }
  if(h%2LL==0)cout << (h/2LL)*w << endl;
  else if(w%2LL==0)cout << h*(w/2LL) << endl;
  else cout << ((h-1LL)/2LL)*w +w/2LL +1LL << endl;
}


Measured memory_bytes: 256
#include <iostream>
#define INF 1e+9
using namespace std;

int main(){
	int n,c;
	while(cin >> n >> c,n){
		int a[30] = {},b[30] = {},p[1 << 16][30],dp[31][1 << 16];
		for(int i = 0;i <= n;i++){
			for(int j = 0;j < 1 << 16;j++) dp[i][j] = -INF;
		}
		dp[0][0] = 0;
		for(int i = 0;i < n;i++){
			for(int j = 0;j < 16;j++){
				int t;
				cin >> t;
				a[i] = a[i] * 2 + t;
			}
		}
		for(int i = 0;i < c;i++){
			for(int j = 0;j < 16;j++){
				int t;
				cin >> t;
				b[i] = b[i] * 2 + t;
			}
			for(int j = 0;j < 1 << 16;j++){
				int cnt = 0;
				for(int k = 0;k < 16;k++) if((j >> k & 1) && (b[i] >> k & 1)) cnt++;
				p[j][i] = cnt;
			}
		}
		int ma = 0;
		for(int i = 0;i < n;i++){
			for(int j = 0;j < 1 << 16;j++){
				for(int k = 0;k < c;k++){
					dp[i + 1][(j | a[i]) & ~b[k]] = max(dp[i][j] + p[j | a[i]][k],dp[i + 1][(j | a[i]) & ~b[k]]);
					ma = max(ma,dp[i + 1][(j | a[i]) & ~b[k]]);
				}
			}
		}
		cout << ma << endl;
	}
	return 0;
}

Measured memory_bytes: 18680
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
#[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    println!("{}", solve(&stdin!()));
}
fn solve(src: &str) -> String {
    input! {
        source = src,
        n:usize,
        a:[usize;n],
    }

    a.sort();
    let mut bi = 1;
    let mut dp = vec![true; *a.last().unwrap()];
    for (i, &ai) in a.iter().enumerate() {
        for fi in bi..ai {
            dp[fi - 1] = false;
        }
        bi = ai + 1;

        let ai_start = if i == 0 || a[i - 1] != ai { ai * 2 } else { ai };
        for aii in (ai_start..=*a.last().unwrap()).step_by(ai) {
            dp[aii - 1] = false;
        }
    }

    dp.iter().filter(|&&v| v).count().to_string()
}
test! {
    include_str!("d1_in.txt") => "3",
    include_str!("d2_in.txt") => "0",
    include_str!("d3_in.txt") => "5",
}


Measured memory_bytes: 6016
#include<iostream>
#include<string>

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

int main() {

	int n,sum=0;
	cin>>n;
	vector <int> row(n);

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

	for(int i=0;i<n-1;++i) {
		for(int j=i+1;j<n;++j) {
			sum+=row[i]*row[j];
		}
	}

	cout<<sum;

	return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())

if K==0:
    print(N*N)
    exit()

X=0
for b in range(1,N+1):
    if b<=K:
        X+=N+1
    else:
        q,r=divmod(N,b)
        X+=K*q+min(r+1,K)
print(N*(N+1)-X)

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

void solve() {
  string str;
  cin >> str;

  int store[3];
  int longest = 0;

  for (int i = 0; i < 3; i++) {
    if (str[i] == 'R') {
      store[i] = i == 0 ? 1 : store[i - 1] + 1;
    } else {
      store[i] = 0;
    }

    longest = max(longest, store[i]);
  }

  cout << longest << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1
#define j0 gray_cat_j0

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 16;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

void solve(){
	string s;
	cin >> s;
	cout << s.substr(0, 3) << endl;
	
}

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

struct BIT{
	vi data;
	int s;
	BIT(int n){
		s=n;
		data.resize(s,0);
	}
	void Add(int i,int v){
		while(i<s){
			data[i]+=v;
			i+=(i+1)&(-i-1);
		}
	}
	int Get(int i){
		int res=0;
		while(i>=0){
			res+=data[i];
			i-=(i+1)&(-i-1);
		}
		return res;
	}
};

int Wafrelka(string a,string b){
	vi head(26,0);
	const auto GetNext=[&](int c){
		while(a[head[c]]!='a'+c)
			head[c]++;
		return head[c]++;
	};
	int n=a.size(),ans=0;
	BIT bit(n);
	REP(i,n){
		int c=b[i]-'a';
		int pos=GetNext(c);
		ans+=pos+bit.Get(pos)-i;
		bit.Add(0,1);
		bit.Add(pos,-1);
	}
	return ans;
}

signed main(){
	string s=readString();
	vi cnt(26,0);
	int n=s.size();
	REP(i,n)cnt[s[i]-'a']++;
	int odds=0;
	REP(i,26)if(cnt[i]%2)odds++;
	if(odds>1){
		cout<<-1<<endl;
		return 0;
	}
	string left,dst;
	vi idx(26,0);
	REP(i,n){
		int c=s[i]-'a';
		if(idx[c]<cnt[c]/2){
			left+=s[i];
			idx[c]++;
		}
	}
	dst=left;
	REP(i,26)if(cnt[i]%2)dst+='a'+i;
	reverse(ALL(left));
	dst+=left;
	cout<<Wafrelka(s,dst)<<endl;
}

Measured memory_bytes: 4864
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 100000;
int N, A[Nmax], B[Nmax];

void dfs1(int n, int d, int p, vector<vector<int> > &graph, vector<int> &depth){
	depth[n] = d;
	for(int i=0; i<graph[n].size(); i++){
		int m = graph[n][i];
		if(m == p) continue;
		dfs1(m, d+1, n, graph, depth);
	}
}

bool dfs2(int n, int p, vector<vector<int> > &graph, vector<bool> &path){
	if(n == N-1){
		path[n] = true;
		return true;
	}
	for(int i=0; i<graph[n].size(); i++){
		int m = graph[n][i];
		if(m == p) continue;
		if(dfs2(m, n, graph, path)){
			path[n] = true;
			return true;
		}
	}

	return false;
}

int dfs3(int n, int p, vector<vector<int> > &graph, int last, int next){
	int ret = 1;

	for(int i=0; i<graph[n].size(); i++){
		int m = graph[n][i];
		if(m == p) continue;
		if(n == last && m == next) continue;
		ret += dfs3(m, n, graph, last, next);
	}

	return ret;
}

int main(){
	cin >> N;
	vector<vector<int> > graph(N);
	for(int i=0; i<N-1; i++){
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
		graph[A[i]].push_back(B[i]);
		graph[B[i]].push_back(A[i]);
	}

	vector<int> depth(N);
	dfs1(0, 0, -1, graph, depth);

	vector<bool> path(N);
	dfs2(0, -1, graph, path);

	int dist = depth[N-1];
	int black, white;
	for(int i=0; i<N; i++){
		if(depth[i] == dist/2 && path[i]){
			black = i;
		}
		else if(depth[i] == dist/2+1 && path[i]){
			white = i;
		}
	}

	//cout << black+1 << " " << white+1 << endl;
	int nblack = dfs3(0, -1, graph, black, white);
	//cout << nblack << endl;

	cout << (nblack > N-nblack ? "Fennec" : "Snuke") << endl;

	return 0;
}


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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 205, INF = 0x3f3f3f3f;

int n;
char tmp[N];
int a[N][N], dist[N][N];

int myabs(int a) {
	return a > 0 ? a : -a;
}

int main() {
	read(n);
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			dist[i][j] = INF;
		}
		dist[i][i] = 0;
	}
	for (int i = 1; i <= n; ++i) {
		readStr(tmp + 1);
		for (int j = 1; j <= n; ++j) {
			a[i][j] = tmp[j] - '0';
			if (a[i][j]) {
				dist[i][j] = 1;
			}
		}
	}
	for (int k = 1; k <= n; ++k) {
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= n; ++j) {
				dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	int ans = -1;
	for (int k = 1; k <= n; ++k) {
		bool flag = 1;
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= n; ++j) {
				if (a[i][j] && myabs(dist[k][i] - dist[k][j]) != 1) {
					flag = 0;
					break;
				}
			}
			if (!flag) {
				break;
			}
		}
		if (!flag) {
			continue;
		}
		for (int i = 1; i <= n; ++i) {
			ans = std::max(ans, dist[k][i] + 1);
		}
	}
	print(ans);
}


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


int main() {
    int n;cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int flag=1;
    for(int i=0;i<n;i++){
        if(a[i]%2==0){
            if(a[i]%3==0 || a[i]%5==0){
                continue;
            }else{
                flag=0;
            }
        }
    }
    if(flag==0) cout<<"DENIED"<<endl;
    else cout<<"APPROVED"<<endl;
}

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

void fnInput(vector<int>& rvnMonstr, vector<int>& rvnBrave)
{
  int nMonstrSiz;
  cin >> nMonstrSiz;
  rvnMonstr.resize(nMonstrSiz + 1);
  rvnBrave.resize(nMonstrSiz);

  for (int& rnMonstr : rvnMonstr)
    cin >> rnMonstr;

  for (int& rnBrave : rvnBrave)
    cin >> rnBrave;
}
  
int64_t fnDeftMonstr(vector<int>& rvnMonstr, vector<int>& rvnBrave)
{
  int64_t nDeftMonstr = 0;

  for (int nBgn = 0; nBgn < rvnBrave.size(); nBgn++)
    for (int nFoward = nBgn; nFoward < nBgn + 2; nFoward++)
      if (rvnBrave[nBgn] <= rvnMonstr[nFoward])
      {
        nDeftMonstr += rvnBrave[nBgn];
        rvnMonstr[nFoward] -= rvnBrave[nBgn];
        rvnBrave[nBgn] = 0;
        break;
      }
      else
      {
        nDeftMonstr += rvnMonstr[nFoward];
        rvnBrave[nBgn] -= rvnMonstr[nFoward];
        rvnMonstr[nFoward] = 0;
      }

  return nDeftMonstr;
}
  
int main()
{
  vector<int> vnMonstr, vnBrave;

  fnInput(vnMonstr, vnBrave);
  cout << fnDeftMonstr(vnMonstr, vnBrave) << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;


ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n,all=0;
    cin >> n;
    string s[n],s2;
    ll t[n];
    for (ll i=0;i<n;i++){
        cin >> s[i] >> t[i];
        all+=t[i];
    }
    cin >> s2;
    for (ll i=0;i<n;i++){
        if (s[i]!=s2){
            all-=t[i];
        }else{
            all-=t[i];
            break;
        }
    }
    cout << all << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
int n,ans;
int cnt[70];
int main()
{
	scanf("%d",&n);
	long long x;
	for(int i=1;i<=n;++i)
	{
		scanf("%lld",&x);
		for(int j=0;j<60;++j)if(x>>j&1)++cnt[j];
	}
	for(int j=0;j<60;++j)ans=(ans+1ll*cnt[j]*(n-cnt[j])%mod*((1ll<<j)%mod))%mod;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;


int main(){
	int n;
	while(cin>>n,n){
		int ans = 0;
		FOR(i,n){
			int x,y,h,w; cin>>x>>y>>h>>w;
			int len = x+y+h;
			int a = max(0,min((len-1)/20 - 2,6));
			int b = min(6,((w-1)/5+1) * (w>=3));
		  if(max(a,b)!=6)ans += 600+200*max(a,b);
		}
		cout << ans << endl;

	}

	return 0;
}

Measured memory_bytes: 1160
n = int(input())
*s1, = input().split()
s2 = s1[:]

def bubbleSort(s):
    flag = True
    while flag:
        flag = False
        for i in range(n-1):
            if int(s[i][1]) > int(s[i+1][1]):
                s[i],s[i+1] = s[i+1],s[i]
                flag = True
    return s

def selectionSort(s):
    for i in range(n):
        minj = i
        for j in range(i+1,n):
            if int(s[minj][1]) > int(s[j][1]):
                minj = j
        s[i],s[minj] = s[minj],s[i]
    return s

print(' '.join(bubbleSort(s1)))
print("Stable")
print(' '.join(selectionSort(s2)))
if s1 == s2:
    print("Stable")
else:
    print("Not stable")



Measured memory_bytes: 5608
#include <stdio.h>

#define INF 100000

int m[101][101];

int p[101];
 

void matrixChain(int n){
 
  int i,j,l,k,q;
 
  for(i = 1;i <= n;i ++)
    {
      m[i][i] = 0;
    }
   
  for(l = 2;l <= n;l ++)
    {
      for(i = 1;i <= n - l + 1;i ++)
	{

	  j = i + l - 1;

	  m[i][j] = INF;

	  for(k = i;k < j;k ++)
	    {
	      q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];

	      m[i][j] = min(m[i][j],q);

	    }
	}
    }
}
 
int min(int x,int y){

  if(x > y) return y;

  else return x;
}


int main(){

  int n,i;
 
  scanf("%d",&n);
  
  for(i = 0;i < n;i ++)
    {
      scanf("%d%d",&p[i],&p[i+1]);
    }
 
  matrixChain(n);
 
  printf("%d\n",m[1][n]);
 
  return 0;
}

Measured memory_bytes: 636
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  string s,t;
  cin >> s >> t;
  ll c=0,n;
  n = s.size();
  for(int i=0;i<n;i++){
    if(s[i]!=t[i]) c++;
  }
  cout << c << endl;
}


Measured memory_bytes: 3800
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();

        Set<String> prizes = new HashSet<>();
        for (int i = 0; i < n; i++) {
            String prize = sc.next();
            prizes.add(prize);
        }

        int result = prizes.size();

        System.out.println(result);
    }
}

Measured memory_bytes: 66160
package main

import (
	"fmt"
)

const mod = 1000000007

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	if n == 1 {
		fmt.Println(1)
		return
	}
	n++
	mp := make(map[int]int)
	for i := 0; i < m; i++ {
		var tmp int
		fmt.Scan(&tmp)
		mp[tmp] = 1
	}
	dp := make([]int, n)
	if mp[1] == 0 {
		dp[1] = 1
	}
	if mp[2] == 0 {
		dp[2] = dp[1] + 1
	}
	for i := 3; i < n; i++ {
		if mp[i] == 1 {
			continue
		}
		dp[i] = dp[i - 1] % mod + dp[i - 2] % mod
	}
	fmt.Println(dp[n - 1] % mod)
}

Measured memory_bytes: 8064
n,p = map(int,input().split())
pr = [0 for _ in range(p)]
s = input()
if p == 2 or p == 5:
  ans = 0
  for i in range(n):
    if int(s[i]) % p == 0:
      ans += i+1
  print(ans)
  exit()
ten = [1]
for i in range(n-1):
  ten.append(ten[-1]*10%p)
ten.reverse()
#print(ten)
pr[0] = 1
now = 0
for i in range(n):
  now *= 10
  now += int(s[i])
  now %= p
  tmp = int(now)
  tmp *= ten[i]
  tmp %= p
  pr[tmp] += 1
#print(pr)
ans = 0
for x in pr:
  ans += x * (x-1)
ans //= 2
print(ans)

Measured memory_bytes: 54032
#include <iostream>

using namespace std;

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

	if((((date/100)<=12) && ((date%100)<=12)) && ((date/100)>0) && ((date%100)>0))
		cout<<"AMBIGUOUS";
	else if(((date/100)<=12)&&(date/100)>0)
		cout<<"MMYY";
	else if(((date%100)<=12) && (date%100)>0)
		cout<<"YYMM";
	else
		cout<<"NA";

		

        return 0;
}       



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    if S[2] == S[3] and S[4] == S[5]:
        print(YES)
        return
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>
#include<math.h>
using namespace std;

int main(){
	int a[4],b[4],work[10],hit,blow;
	while(scanf("%d %d %d %d\n%d %d %d %d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])!=EOF){
		hit = blow = 0;
		for(int i=0;i < 10;i++)work[i] = -1;
		for(int i=0;i<4;i++)work[a[i]]=i;
		for(int i=0;i<4;i++){
			if(work[b[i]] == i)hit++;
			else if(work[b[i]] != -1)blow++;
		}
		printf("%d %d\n",hit,blow);
	}

    return 0;
}

Measured memory_bytes: 2676
#include<bits/stdc++.h>
using namespace std ;
int main ()
{
    int  n ;
    cin >> n ;
    double arr[n];
    for(int  i= 0;i<n;i++)
    {
        cin >> arr[i];
    }
    sort(arr,arr+n);
    double pt=(double)arr[0];
    for(int i = 1;i<n;i++)
    {
        pt=pt+arr[i];
        pt=pt/2.0;
    }
    cout<<setprecision(12)<<pt;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

int f(int n) {
	if (n % 2 == 0) return n / 2;
	else return 3 * n + 1;
}

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, 0, n) cin >> p[i];

	SORT(p);
	int sum = -(p[n - 1] / 2);
	for (auto& x : p) {
		sum += x;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256