akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define Endl '\n'
#define cont continue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define mp make_pair
#define mem(x) memset(x, 0, sizeof(x))

const ll inf=1e18;
const int mod=1e9+7;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
const int mxn = 2e5+10;

//ll fact[mxn];
//ll in_fact[mxn];
//fact[0] = 1;
//for(ll i = 1; i < mxn; i++) {
	//fact[i] = (i*fact[i-1])%mod;
//}
//in_fact[mxn-1] = bigmod(fact[mxn-1],mod-2);
//for(ll i = mxn-2; i >= 0; i--) {
	//in_fact[i] = (in_fact[i+1] * (i+1))%mod;
//}
//ll c(ll n,ll r) {
	//ll ans = (fact[n] * (in_fact[r] * in_fact[n-r]%mod))%mod;
	//return ans;
//}


signed main(){
    fast;
	//freopen ("input.txt", "r", stdin);
	//freopen ("output.txt", "w", stdout);
    int tt = 1;
    //cin>>tt;
    for(int tc = 1; tc <= tt; tc++) {
        int n,ans = 0;
        cin>>n;
        int ip[n];
        
        for(int i = 0; i < n; i++) cin>>ip[i];
        int mx = ip[0];
        for(int i = 1; i < n; i++) {
			if(ip[i] < mx) {
				ans += (mx - ip[i]);
			}
			else mx = ip[i];
		}
		cout<<ans<<endl;
			
        
        
    }



return 0;
}


Measured memory_bytes: 5136
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

A,B = I()
if A+B > 9:
    print('error')
else:
    print(A+B)

Measured memory_bytes: 9940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
 
  if ((S.at(2) == S.at(3)) && (S.at(4) == S.at(5)))  {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		sc.close();

		var sum = 0L;
		for (var i = 1; i <= n; i++) {
			if (i % 3 != 0 && i % 5 != 0) {
				sum += i;
			}
		}

		System.out.println(sum);
	}
}

Measured memory_bytes: 35780
n=int(input())
m=0
l=0
for i in range(n):
  A,B=map(int,input().split())
  if (A==B):
    m+=1
  else:
    m=0
  if (m==3):
    print("Yes")
    l=1
    break

if (l==0):
  print("No")

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

int main() {
    ll n,k;
    cin >> n >> k;
    ll amari=n%k;
    cout << min(amari,k-amari) <<endl;
}

Measured memory_bytes: 3592
# ARC093c
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    from collections import Counter

    n = int(input())
    a = [0]
    a.extend(list(map(int, input().split())))
    a.append(0)
    # print(a)

    total = 0
    for i in range(1, n+2):
        total += abs(a[i]-a[i-1])
    # print(total)

    for j in range(1, n+1):
        if a[j-1] <= a[j] <= a[j+1] or a[j-1] >= a[j] >= a[j+1]:
            print(total)
            continue
        print(total-abs(a[j]-a[j-1])-abs(a[j+1]-a[j])+abs(a[j+1]-a[j-1]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14300
use std::collections::HashMap;
use std::f64;

#[allow(unused)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };
}
#[allow(unused)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused)]
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")
    };
}
#[allow(unused)]
fn round_to_integer(a: f64, digit: u8) -> i64 {
    let mut ai: i64;
    let mut d = digit;
    let mut p = 1;

    while d > 0 {
        p *= 10;
        d -= 1;
    }
    ai = (a * p as f64) as i64;

    while ai as f64 / p as f64 - a > 0.5 / p as f64 {
        ai -= 1;
    }
    while ai as f64 / p as f64 - a < -0.5 / p as f64 {
        ai += 1;
    }
    ai
}

fn main() {
    input! {
        N:u16,
    }

    //let mut counter = 0;

    let mut v = Vec::new();
    for i in 1..(N + 1) {
        v.push(0);
    }
    let di: f64 = N as f64;
    for x in 1..(di.sqrt().round() as u16 + 1) {
        //let mut found = false;
        for y in (1..(di.sqrt().round() as u16 + 1)).rev() {
            for z in (1..(di.sqrt().round() as u16 + 1)).rev() {
                let calc = x * x + y * y + z * z + x * y + y * z + z * x;
                if calc <= N {
                    let now = v.get((calc - 1) as usize).unwrap();
                    v.insert((calc - 1) as usize, now + 1);
                    v.remove(calc as usize);
                }
            }
        }
    }
    for i in 0..v.len() {
        println!("{}", v.get(i).unwrap());
    }
}

fn check(n: u16, x: u16, y: u16, z: u16) -> bool {
    n == x * x + y * y + z * z + x * y + y * z + z * x
}


Measured memory_bytes: 2608
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int32_t main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0),cin.tie(0);
    int n;
    cin >> n;
    string st;
    cin >> st;
    int r=0,b=0,g=0;
    for(int i=0;i<n;i++){
        if(st[i]=='R')r++;
        if(st[i]=='G')g++;
        if(st[i]=='B')b++;
    }
    int ans=r*g*b,c=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(st[i]==st[j])continue;
            int k=2*j-i;
            if(k>=n)break;
            if(st[i]!=st[k] and st[j]!=st[k])c++;
        }
    }
    cout << ans-c;
}

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


        int main()
        {
			
			string s;
			cin>>s;
			ll c=0;
			for(int i=0;i<s.length();i++){
				
				if(s[i]==s[i+1]){
					if(i<s.length()-2)
					
					c+=2;
					else 
					c+=1;
					
					i+=2;
					}
					else{
						c+=1;}
				}
				cout<<c;



        return 0;
    }


Measured memory_bytes: 640
def solve(string):
    s, x, y = string.split()
    x, y = int(x), int(y)
    s = s.split("T")
    move_all = [len(_s) for _s in s]
    pos_x = set([move_all[0]])
    pos_y = set([0])
    move_x = move_all[2::2] or None
    move_y = move_all[1::2] or None
    if move_x:
        for move in move_x:
            pos_x = {_x + move for _x in pos_x} | {_x - move for _x in pos_x}
    if move_y:
        for move in move_y:
            pos_y = {_y + move for _y in pos_y} | {_y - move for _y in pos_y}
    return "Yes" if x in pos_x and y in pos_y else "No"


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


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

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k,i,ans=0;
    cin>>n>>k;
    ll h[100001];
    for(i=0;i<n;i++){
    	cin>>h[i];
	}
	for(i=0;i<n;i++){
		if(h[i]>=k){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
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; }

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

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	vector<ll> A(5);
	for (ll i = 0; i < 5; ++i) cin >> A[i];

	ll ans = 0;

	for (ll i = 0; i < 5; ++i)
	{
		if (A[i] == 0) ans = i+1;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3612
#include<cstdio>
#define Fast register
inline char Getchar(){
	static char BUF[16384],*S=BUF,*T=BUF;
	return(S==T)&&(T=(S=BUF)+fread(BUF,1,16384,stdin),S==T)?EOF:*S++;
}
inline int Getint(){
	Fast int s=0;Fast char c=Getchar();
	while(c<48||c>57)c=Getchar();
	while(c>47&&c<58)s=s*10+c-48,c=Getchar();
	return s;
}
#define LL long long
int K;
int A[100001];
inline LL Play(LL v){
	for(Fast int i=1;i<=K;++i)v/=A[i],v*=A[i];
	return v;
}
int main(){
	K=Getint();
	for(Fast int i=1;i<=K;++i)A[i]=Getint();
	Fast LL L=1,R=1e16,Min=0,Max=0;
	while(L<R){
		Fast LL Mid=(L+R)>>1,PLAY=Play(Mid);
		if(PLAY==2){Min=Max=Mid;break;}
		else PLAY>2?R=Mid:L=Mid+1;
	}
	if(!Min&&!Max){puts("-1");return 0;}
	while(true){
		Fast LL PM=Play(Min),Move=1;
		if(PM==2&&Play(Min-1)!=2)break;
		while(Play(Min-Move)==2)Move<<=1;
		Min-=(Move>>1);
	}
	while(true){
		Fast LL PM=Play(Max),Move=1;
		if(PM==2&&Play(Max+1)!=2)break;
		while(Play(Max+Move)==2)Move<<=1;
		Max+=(Move>>1);
	}
	printf("%lld %lld",Min,Max);
	return 0;
}

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

int main()
{
    int n, k, t=0;
    cin >> n >> k;
    int a[n];
    for (int i=0; i<n; i++)
    {
        cin >> a[i];
    }
    sort (a, a+n);
    for (int i=0; i<k; i++)
    {
        t += a[i];
    }
    cout << t;
    return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = 1E9+7;
ll n;
map<ll,ll>a;
ll read(){
	char ch = getchar();
    ll x = 0,q = 1;
    while(ch>'9' || ch<'0')q = ch==45?-1:q,ch = getchar();
    while(ch>='0' && ch<='9')x = (x<<1)+(x<<3)+(ch^'0'),ch = getchar();
    return x*q;
}
ll f(ll x){
	if(a[x])return a[x];
	return a[x] = (f(x/2)+f((x-1)/2)+f((x-2)/2))%MOD;
}
int main(){
	a[0] = 1;
	a[1] = 2;
	n = read();
	printf("%lld",f(n));
    return 0;
}

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

using namespace std;

int main(void)
{
	int nam;
	int a,b,c;
	string str;
	cin >> nam;
	for(int i=0;i<nam;i++)
	{
		cin>>a>>b>>c;
		if( (a*a + b*b) == (c*c) || (a*a + c*c) == (b*b) || (b*b + c*c) == (a*a) )
		{
			str += "YES\n";
		}
		else
		{
			str += "NO\n";
		}
	}
	cout<<str;
	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  if (N%2==0) {
    cout << N << endl;
  }
  else {
    cout << 2*N << endl;
  }
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int res = pow(3, n);
    int t = 1;
    rep (i, n) {
        int a;
        cin >> a;
        if (!(a % 2)) t *= 2;
    }
    cout << res - t << endl;    
    
    return 0;
}



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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int n = in();
  vector<int64_t> a(n);
  cin >> a;

  sort(a);
  int ans = a[0], diff = inf;
  for (int i = 0; i < n; ++i) {
    if (diff > abs((a.back() + 1) / 2 - a[i])) {
      diff = abs((a.back() + 1) / 2 - a[i]);
      ans = a[i];
    }
  }

  cout << a.back() << " " << ans << endl;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    int a,b,k;
    cin >> k >> a >> b;
    for (int i = a; i <= b; ++i) {
        if (i % k == 0) {
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";
}


Measured memory_bytes: 3600
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>

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

using namespace std;

int main(void) {
	int c[8] = { 0,1,2,3,5,7,8,9 };
	int n;
	vector<int> v;
	while (cin >> n && n > 0) {
		v.clear();
		while (n > 0) {
			v.push_back(c[n % 8]);
			n /= 8;
		}
		for (int i = v.size() - 1; i >= 0; i--) {
			cout << v[i];
		}
		cout << endl;
	}
	
				  
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

vl get_modpow(ll m, ll n) {
  vl modpow(n);
  modpow[0] = 1;
  rep2(i, n-1) modpow[i] = (modpow[i-1] * 2) % m;
  return modpow;
}

vl get_f(ll n) {
  vl f(n);
  rep2(i, n-1) {
    ll num = i, ppi = 0;
    while(num>0) {
      if(num & 1) ppi++;
      num /= 2;
    }
    f[i] = f[i%ppi] + 1;
  }
  return f;
}

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

  ll n;
  string x;
  cin >> n >> x;
  
  ll ppx = count(all(x), '1');
  
  vl f = get_f(n);
  
  vl modpow1, modpow2;
  modpow1 = get_modpow(ppx+1, n);
  if(ppx>=2) modpow2 = get_modpow(ppx-1, n);
  
  ll r1=0, r2=0;
  rep(j, n) (r1 += modpow1[n-1-j] * (x[j]-'0')) %= ppx+1;
  if(ppx>=2) rep(j, n) (r2 += modpow2[n-1-j] * (x[j]-'0')) %= ppx-1;
  
  rep(i, n) {
    string x_i=x;
    if(x[i]=='0') {
      x_i[i]='1';
      ll r = r1;
      r += modpow1[n-1-i];
      r %= ppx+1;
      cout << f[r] + 1 << newl;
    }else if(x[i]=='1' and ppx==1) {
      cout << 0 << newl;
    }else if(x[i]=='1') {
      x_i[i]='0';
      ll r = r2;
      r -= modpow2[n-1-i];
      r %= ppx-1;
      r += ppx-1;
      r %= ppx-1;
      cout << f[r] + 1 << newl;
    }
  }
  return 0;
}

Measured memory_bytes: 8412
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int n, v[20],c[20], cnt = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> c[i];
	}
	for (int i = 0; i < n; ++i) {
		if (v[i] > c[i])cnt = cnt + v[i] - c[i];
	}
	cout << cnt << endl;

}

Measured memory_bytes: 256
h, w, k = map(int, input().split())
s = [input() for _ in range(h)]
a = [[0] * w for _ in range(h)]
flg = False
t = 1
for i, row in enumerate(s):
    if row == '.' * w:
        if flg:
            for j in range(w):
                a[i][j] = a[i - 1][j]
    else:
        flg2 = False
        for j in range(w):
            if row[j] == '#':
                if flg2:
                    t += 1
                flg2 = True
            a[i][j] = t
        if not flg:
            for j in range(w):
                for k in range(i):
                    a[k][j] = a[i][j]
            flg = True
        t += 1
for row in a:
    print(' '.join(map(str, row)))

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

using namespace std;
#define taskname "A"
#define pb	push_back
#define mp 	make_pair
#ifndef LOCAL
#define cerr if(0)cout
#endif
#define int ll

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 1e5 + 5;
const int logn = 20;

int n , q , x[maxn] , y[maxn] , u[maxn] , v[maxn];
ii cnt[maxn];
vector<int> adj[maxn];
map<int,ii> Q[maxn];

struct Edge{
    int u , v , c , d;
}e[maxn];

int h[maxn], h1[maxn] , P[maxn][logn];
int LCA(int u ,int v){
    if(h1[u] < h1[v])swap(u , v);
    for(int i = 0 ; i < logn ; ++i){
        if((h1[u] - h1[v]) & (1 << i)){
            u = P[u][i];
        }
    }
    if(u == v)return u;
    for(int i = logn - 1 ; i >= 0 ; --i){
        if(P[u][i] != P[v][i]){
            u = P[u][i];
            v = P[v][i];
        }
    }
    return P[u][0];
}

void DFS(int u , int v , int id){
//        cout << u << " " << h[u] << endl;

    for(int tmp : adj[u]){
        int c = e[tmp].u + e[tmp].v - u;
        if(c == v)continue;
        h[c] = h[u] + e[tmp].d;
        h1[c] = h1[u] + 1;
        if(id == 1){
            P[c][0] = u;
            for(int j = 1 ; j < logn ; ++j){
                P[c][j] = P[P[c][j - 1]][j - 1];
            }
        }
        DFS(c , u , id);
    }
}

void DFS1(int u , int par){
    for(auto & c : Q[u])c.second = cnt[c.first];
    for(int tmp : adj[u]){
        int c = e[tmp].u + e[tmp].v - u;
        if(c == par)continue;
        cnt[e[tmp].c].first++;
        cnt[e[tmp].c].second += e[tmp].d;
        DFS1(c , u);
        cnt[e[tmp].c].first--;
        cnt[e[tmp].c].second -= e[tmp].d;
    }
}

int res[maxn];

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n >> q;
    for(int i = 1 ; i < n ; ++i){
        cin >> e[i].u >> e[i].v >> e[i].c >> e[i].d;
        adj[e[i].u].pb(i);
        adj[e[i].v].pb(i);
    }
    DFS(1 , 0 , 1);
    for(int i = 1 ; i <= q ; ++i){
        cin >> x[i] >> y[i] >> u[i] >> v[i];
        int LCA = ::LCA(u[i] , v[i]);
        ii c = mp(x[i] , y[i]);
        Q[u[i]].insert(mp(c.first,mp(0,0)));
        Q[v[i]].insert(mp(c.first,mp(0,0)));
        Q[LCA].insert(mp(c.first,mp(0,0)));
    }
    DFS1(1 , 0);
    for(int i = 1 ; i <= q ; ++i){
        int LCA = ::LCA(u[i] , v[i]);
        res[i] = h[u[i]] + h[v[i]] - 2 * h[LCA];
//        cout << u[i] << " " << v[i] << " " << LCA << endl;
        ii c = mp(x[i] , y[i]);
//        cout << res[i] << " ";
        res[i] += Q[u[i]][c.first].first * c.second - Q[u[i]][c.first].second;
        res[i] += Q[v[i]][c.first].first * c.second - Q[v[i]][c.first].second;
        res[i] -= 2 * (Q[LCA][c.first].first * c.second - Q[LCA][c.first].second);
        cout << res[i] << '\n';
    }
}


Measured memory_bytes: 53624
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	double a;
	double s[12];
	while (cin >> a){
		s[1] = a;
		for (int i = 2; i != 11; i++){
			if (i % 2 == 0)s[i] = s[i - 1] * 2;
			else s[i] = s[i - 1] / 3;
		}
		printf("%.8f\n", s[1] + s[2] + s[3] + s[4] + s[5] + s[6] + s[7] + s[8] + s[9] + s[10]);
	}
}

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

int main() {
    int n;
    cin>>n;
    if (n<=999) cout<<"ABC"<<endl;
    else cout<<"ABD"<<endl;
}


Measured memory_bytes: 256
// get the graph diameter

#include <stdio.h>
#include <vector>
#include <string.h>

#define INFLL 0x3f3f3f3f3f3f3f3f

int t1,t2;
int n;

std::vector<int> g[105];
int dist[105][105];

int d,d1,d2;
std::vector<int> diameter;

int dist2[105];
int subchild[105];

void dfs(int u)
{
    int cnt=0;
    for (int v:g[u]) {
        if (dist2[v]) continue;
        dist2[v]=dist2[u]+1;
        dfs(v);
        cnt++;
    }
    if (subchild[dist2[u]]<cnt) {
        subchild[dist2[u]]=cnt;
    }
}

int ans1;
long long ans2,anst;

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    memset(dist,0x3f,sizeof dist);
    scanf("%d",&n);
    for (int i=1; i<=n; i++) dist[i][i]=0;
    for (int i=1; i<n; i++) {
        scanf("%d%d",&t1,&t2);
        g[t1].push_back(t2);
        g[t2].push_back(t1);
        dist[t1][t2]=dist[t2][t1]=1;
    }
    // stupid way of getting the diameter
    for (int k=1; k<=n; k++)
    for (int i=1; i<=n; i++)
    for (int j=1; j<=n; j++) {
        if (dist[i][j]>dist[i][k]+dist[k][j]) {
            dist[i][j]=dist[i][k]+dist[k][j];
        }
    }
    for (int i=1; i<=n; i++)
    for (int j=1; j<=n; j++) {
        if (d<dist[i][j]) {
            d=dist[i][j];
            d1=i;
            d2=j;
        }
    }
    while (d1!=d2) {
        diameter.push_back(d1);
        for (int i:g[d1]) {
            if (dist[d1][d2]>dist[i][d2]) {
                d1=i;
                break;
            }
        }
    }
    diameter.push_back(d2);
    //for (int i:diameter) printf("%d ",i); printf("is diameter\n");
    // do stuff with the diameter
    // not sure what this code is doing
    if (diameter.size()%2==1) {
        dist2[diameter[diameter.size()/2]]=1;
        dfs(diameter[diameter.size()/2]);
        ans1=diameter.size()/2+1;
        // if this was the center
        ans2=1;
        for (int i=1; i<ans1; i++) {
            ans2*=subchild[i];
            //printf("%d s %d\n",i,subchild[i]);
        }
        // if another vertex is also the center
        for (int v:g[diameter[diameter.size()/2]]) {
            memset(dist2,0,sizeof dist2);
            memset(subchild,0,sizeof subchild);
            dist2[diameter[diameter.size()/2]]=1;
            dist2[v]=1;
            dfs(diameter[diameter.size()/2]);
            dfs(v);
            anst=ans2;
            ans2=2;
            for (int i=1; i<ans1; i++) {
                ans2*=subchild[i];
                //printf("%d -> %d s %d\n",v,i,subchild[i]);
            }
            if (ans2>anst) {
                ans2=anst;
            }
        }
    }
    else {
        dist2[diameter[diameter.size()/2]]=1;
        dist2[diameter[diameter.size()/2-1]]=1;
        dfs(diameter[diameter.size()/2]);
        dfs(diameter[diameter.size()/2-1]);
        ans1=diameter.size()/2;
        ans2=2;
        for (int i=1; i<ans1; i++) {
            ans2*=subchild[i];
            //printf("%d s %d\n",i,subchild[i]);
        }
    }
    printf("%d %lld\n",ans1,ans2);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n;
	cin>>n;
	vector<int> u, m, l;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		u.push_back(x);
	}
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		m.push_back(x);
	}
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		l.push_back(x);
	}
	sort(u.begin(),u.end());
	sort(m.begin(),m.end());
	sort(l.begin(),l.end());
	ll count=0;
	for(int i=0;i<n;i++)
	{
		auto itr1 = lower_bound(u.begin(),u.end(),m[i]);
		auto itr2 = upper_bound(l.begin(),l.end(),m[i]);
		count += (itr1-u.begin())*(l.end()-itr2);
	}

	cout<<count<<"\n";
}

Measured memory_bytes: 4696
#include <iostream>
#include <string>
using namespace std;
int check(char a);
int main()
{
	string s;
	int n, cnt=0, max=0;
	cin>>s;
	n=s.length();
	for(int i=0;i<n;i++)
	{
		if(check(s[i]))
		{
			cnt++;
			if(cnt>max)max=cnt;
		}
		else
		{
			cnt=0;
		}
	}
	cout<<max;
	return 0;
}

int check(char a)
{
	int ret=0;
	if(a=='A'||a=='T'||a=='C'||a=='G')
	{
		ret=1;
	}
	return ret;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = (int(i) // 400 for i in input().split())

mi, d = 0, 0
for k, v in Counter(A).items():
    if k >= 8:
        d += v
    else:
        mi += 1

if mi == 0:
    print(1, N)
else:
    print(mi, mi + d)

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, t, a[200001];
  cin >> n >> t;
  rep(i, n) {
    cin >> a[i];
  }
  ll result = t;
  rep(i, n - 1) {
    result += min(t, a[i + 1] - a[i]);
  }
  cout << result << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;


namespace dfs6
{
	Graph graph;
	vector<int> colors;

	bool dfs(int v, int color)
	{
		colors[v] = color;
		//頂点vの連結先を探索する
		for (int nv : graph[v]) {
			//未探索か
			if (colors[nv] == -1) {
				if (!dfs(nv, 1 - color)) {
					return false;
				}
			}
			else {
				//二部グラフでないか
				if (color == colors[nv]) {
					return false;
				}
			}
		}
		return true;
	}
	void exec()
	{
		ll N, M; cin >> N >> M;
		graph.resize(N);
		for (int _ = 0; _ < M;++_) {
			int a, b;cin >> a >> b;--a;--b;
			graph[a].push_back(b);
			graph[b].push_back(a);
		}

		colors.resize(N, -1);
		if (dfs(0, 0)) {
			ll B, W;
			B = count(colors.begin(), colors.end(), 0);
			W = N - B;
			cout << B * W - M << endl;
		}
		else {
			cout << N * (N - 1) / 2 - M << endl;
		}
	}
}

int main()
{
	dfs6::exec();
	/*vector<int> anss;
	for (;;) {
		dfs2::exec();
		if (dfs2::W == 0 || dfs2::H == 0) break;
		anss.push_back(dfs2::ilands);
	}
	for (int i = 0; i < anss.size(); ++i) {
		cout << anss[i] << endl;
	}*/

	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1000010;
int n,len,s[MAXN],f[MAXN];
int main () {
    memset(f,0,sizeof(f));
    len=1;
    scanf("%d",&n);
    for (int i=1;i<=n;i++) {scanf("%d",&s[i]);s[i]*=-1;}
    f[1]=s[1];
    for (int i=2;i<=n;i++) {
        int pos=upper_bound(f+1,f+len+1,s[i])-f;
        f[pos]=s[i];
        len=max(len,pos);
    }
    printf("%d",len);
    return 0;
}

Measured memory_bytes: 6400
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int n, T, H, L;
    cin >> n >> T >> H >> L;

    vector<int> t(n), h(n);
    for(int i=0; i<n; ++i)
        cin >> t[i] >> h[i];

    int rest = 0;
    for(int i=0; ; (++i)%=n){
        if(t[i] > 0){
            -- t[i];
            ++ T;
            rest += 10;
            if(T > L){
                cout << (i+1) << endl;
                return 0;
            }
            if(rest == 90)
                rest = 0;
        }else if(h[i] > 0){
            -- h[i];
            ++ H;
            rest += 100;
            T -= (rest - 90) / 10;
            t[i] += (rest - 90) / 10;
            rest = 0;
            if(T < 0){
                cout << (i+1) << endl;
                return 0;
            }
        }else{
            cout << (i+1) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
using namespace std;
int main()
{
    vector<int> a(3);
    cin >> a.at(0) >> a.at(1) >> a.at(2);
    sort(a.begin(), a.end());
    cout << a.at(0) + a.at(1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <complex>
#include <fstream>
#include <cmath>

using namespace std;

int main(void){
    int a, b; cin >> a >> b;
    
    if(a==1){
        a += 13;
    }
    if(b==1){
        b += 13;
    }
    
    if(a==b){
        cout << "Draw" << endl;
    }else if(a<b){
        cout << "Bob" << endl;
    }else{
        cout << "Alice" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
package main
import "fmt"
func main() {
  var n,l,r int
  var s string
  fmt.Scan(&n,&s)
  for i:=0;i<n;i++ {
    if s[i:i+1] == "(" {
      l++
    } else {
      l--
      if l < 0 { l = 0 }
    }
    if s[n-1-i:n-i] == ")" {
      r++
    } else {
      r--
      if r < 0 { r = 0 }
    }
  }
  for i:=0;i<r;i++ { fmt.Print("(") }
  fmt.Print(s)
  for i:=0;i<l;i++ { fmt.Print(")") }
  fmt.Println()
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long n,x,a[2001],f[2001][2001],minn,ans=2e18;
int main(){
	cin>>n>>x;
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;++i){
		f[i][0]=a[i];
		for(int j=1;j<n;++j){
			long long p=i-j;
			if(p<=0)p=n-abs(p);
			f[i][j]=min(f[i][j-1],a[p]);
		}
	}
	for(int i=0;i<n;++i){
		minn=0;
		for(int j=1;j<=n;++j){
			minn+=f[j][i];
		}
		ans=min(ans,minn+i*x);
	}
	cout<<ans;
}

Measured memory_bytes: 31488
#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 1000000007
#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
int n,m,k;
int main()
{
    fastio;
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
int main(){
    int n, m, x; sc(n), sc(m);
    priority_queue<int> que;
    rep(i, 0, n) sc(x), que.push(x);
    rep(i, 0, m){
        x = que.top(), que.pop();
        que.push(x/2);
    }
    ll ans = 0;
    while(!que.empty()) ans += que.top(), que.pop();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#include <cstdio>

int read()
{
  int x=0,f=1;
  char ch=getchar();
  while((ch<'0')||(ch>'9'))
    {
      if(ch=='-')
        {
          f=-f;
        }
      ch=getchar();
    }
  while((ch>='0')&&(ch<='9'))
    {
      x=x*10+ch-'0';
      ch=getchar();
    }
  return x*f;
}

const int maxn=100000;
const int maxh=201;
const int maxv=401;

namespace dsu
{
  int fa[maxv+10];

  int find(int x)
  {
    return fa[x]?(fa[x]=find(fa[x])):x;
  }
}

int n,h,pre[maxn+10],now[maxv+10],son[maxn+10],tot,ru[maxv+10],chu[maxv+10],vis[maxn+10];

int ins(int a,int b)
{
  pre[++tot]=now[a];
  now[a]=tot;
  son[tot]=b;
  ++ru[b];
  ++chu[a];
  return 0;
}

int main()
{
  n=read();
  h=read();
  for(int i=1; i<=n; ++i)
    {
      int a=read(),b=read(),c=read(),d=read(),x,y;
      if(c==0)
        {
          x=maxh+a;
        }
      else
        {
          x=maxh-c;
        }
      if(d==0)
        {
          y=maxh-b;
        }
      else
        {
          y=maxh+d;
        }
      ins(x,y);
      int fx=dsu::find(x),fy=dsu::find(y);
      if(fx!=fy)
        {
          dsu::fa[fx]=fy;
        }
    }
  for(int i=1; i<=h; ++i)
    {
      if(ru[maxh+i]>chu[maxh+i])
        {
          puts("NO");
          return 0;
        }
    }
  for(int i=1; i<=h; ++i)
    {
      if(chu[maxh-i]>ru[maxh-i])
        {
          puts("NO");
          return 0;
        }
    }
  for(int i=1; i<=maxv; ++i)
    {
      if(((ru[i]==0)&&(chu[i]==0))||(ru[i]!=chu[i]))
        {
          vis[dsu::find(i)]=1;
        }
    }
  int flag=0;
  for(int i=1; i<=maxv; ++i)
    {
      if(!vis[dsu::find(i)])
        {
          flag=1;
          break;
        }
    }
  puts(flag?"NO":"YES");
  return 0;
}


Measured memory_bytes: 896
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int l = sc.nextInt();
        String[] array = new String[n];
        for (int i = 0; i < n; i++){
            array[i] = sc.next();
        }
        Arrays.sort(array, (x, y) -> x.compareTo(y));
        String str = String.join("", array);
        System.out.println(str);

    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}


Measured memory_bytes: 26068
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  ll N, Y; cin >> N >> Y;

  for (int a = 0; a <= N; ++a) {
    for (int b = 0; b <= N; ++b) {
      int c = N-a-b;
      if (c < 0 || a+b+c != N || 10000*a+5000*b+1000*c != Y) continue;
      printf("%d %d %d\n", a, b, c);
      return 0;
    }
  }

  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define S_MAX 100
#define N_MAX 100000
#define M_MAX 200000
#define INF 10000000
#define MOD 1000000007
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;
typedef   signed long long dll;

int n, m;
int h, w;
int i, j, k;

int a[N_MAX];
char s[S_MAX + 1];

typedef struct {
	int in;
	int out;
} twoway;

void deb(){
	return;
}

void solve(){
	int result = 0;
	int p = 0;

	for (i = 0; i < n; i++) {
		p += a[i];
	}

	if (p % n <= n / 2) {
		p = p / n;
	} else {
		p = p / n + 1;
	}

	for (i = 0; i < n; i++) {
		result += (a[i] - p) * (a[i] - p);
	}

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

	return;
}

int main (void) {
	char *t;
	bool x[26] = {0};
	scanf("%d", &n);
	
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	solve();
	return 0;
}




Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define END getchar();getchar();return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000007

signed main() {
	int n, r = 0, g = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		char c;
		cin >> c;
		if (c == 'R') {
			r++;
		}
		else g++;
	}
	if (r > g) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;

	END;
}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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; }



void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<ll> A(n);
    rep(i,n) cin >> A[i];
    
    ll ans = 0;
    for (int k = 0; k < 60; k++) {
        ll oneNum = 0;
        for (int i = 0; i < n; i++) {
            if(A[i]>>k & 1) oneNum += 1;
        }
        ll now = oneNum*(n-oneNum)%MOD;
        rep(j,k) now = now*2%MOD;
        ans += now;
        ans %= MOD;
    }
    
    cout << ans << endl;
    
    
}



signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 2560
import java.io.IOException;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws IOException {
        Scanner input = new Scanner(System.in);
        String deck = "";
        boolean flag = true;
        while (true) {
            // grab and convert the string to lowercase
            String line = input.nextLine();
            if (line.equals("-")) {
                System.out.println(deck);
                break;
            }
            // This line checks to see if a new deck has been introduced by looking at length, also grabs the case where the deck is just on card
            if (Character.isAlphabetic(line.charAt(0))) {
                if (!deck.equals("")) System.out.println(deck);
                deck = line;
                flag = true;
            } else if(flag){
                flag = false;
                // ignore this value, we approached this in a different way
            } else {
                int h = Integer.parseInt(line);
                deck = deck.substring(h) + deck.substring(0, h);
            }
        }
    }
}


Measured memory_bytes: 25944
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    ll h,w;cin>>h>>w;
    vector<vector<ll>> ab(h,vector<ll>(w,0));
    vector<vector<ll>> b(h,vector<ll>(w));
    REP(i,h)REP(j,w)cin>>ab[i][j];
    REP(i,h)REP(j,w){cin>>b[i][j];ab[i][j]-=b[i][j];}
    ll r=2*80*80+1;
    vector<vector<vector<bool>>> dp(h,vector<vector<bool>>(w,vector<bool>(r,false)));
    dp[0][0][abs(ab[0][0])]=true;
    REP(i,h-1){
        REP(j,w-1){
            REP(k,r){
                if(dp[i][j][k]){
                    dp[i+1][j][abs(k+ab[i+1][j])]=true;
                    dp[i+1][j][abs(k-ab[i+1][j])]=true;
                    dp[i][j+1][abs(k+ab[i][j+1])]=true;
                    dp[i][j+1][abs(k-ab[i][j+1])]=true;
                }
            }
        }
        REP(k,r){
            if(dp[i][w-1][k]){  
                dp[i+1][w-1][abs(k+ab[i+1][w-1])]=true;
                dp[i+1][w-1][abs(k-ab[i+1][w-1])]=true;
            }
        }
    }
    REP(j,w-1){
        REP(k,r){
            if(dp[h-1][j][k]){
                dp[h-1][j+1][abs(k+ab[h-1][j+1])]=true;
                dp[h-1][j+1][abs(k-ab[h-1][j+1])]=true;
            }
        }
    }
    REP(k,2*80*80)if(dp[h-1][w-1][k]){cout<<k<<endl;return 0;}
}


Measured memory_bytes: 14008
w,h,n=map(int,input().split())
wmax=w
wmin=0
hmax=h
hmin=0

for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        if wmin<=x:
            wmin=x
    elif a==2:
        if wmax>=x:
            wmax=x
    elif a==3:
        if hmin<=y:
            hmin=y
    else:
        if hmax>=y:
            hmax=y
if wmax>wmin and hmax>hmin:
    print((wmax-wmin)*(hmax-hmin) )
else:
    print(0)

Measured memory_bytes: 3064
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import combinations_with_replacement
def main():
    n, m, q = map(int, input().split())
    qs = []
    for _ in range(q):
        abcd = tuple(map(int, input().split()))
        qs.append(abcd)
    A = tuple(combinations_with_replacement(range(1, m+1), n))
    r = 0
    for Ae in A:
        t0 = 0
        for qe in qs:
            if Ae[qe[1]-1] - Ae[qe[0]-1] == qe[2]:
                t0 += qe[3]
        r = max(r, t0)
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 21812