akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* struct */
struct mint {
        ll x;
        mint(ll x = 0):x((x % mod + mod) % mod) {}
        mint operator-() const { return mint(-x); }
        mint& operator+=(const mint a) {
            if ((x += a.x) >= mod) x -= mod;
            return *this;
        }
        mint& operator-=(const mint a) {
            if ((x += mod - a.x) >= mod) x -= mod;
            return *this;
        }
        mint& operator*=(const mint a) {
            (x *= a.x) %= mod;
            return *this;
        }
        mint operator+(const mint a) const {
            mint res(*this);
            return res += a;
        }
        mint operator-(const mint a) const {
            mint res(*this);
            return res -= a;
        }
        mint operator*(const mint a) const {
            mint res(*this);
            return res *= a;
        }
        mint pow(ll t) const {
            if (!t) return 1;
            mint a = pow(t >> 1);
            a *= a;
            if (t & 1) a *= *this;
            return a;
        }
        // for prime mod
        mint inv() const {
            return pow(mod - 2);
        }
        mint& operator/=(const mint a) {
            return (*this) *= a.inv();
        }
        mint operator/(const mint a) const {
            mint res(*this);
            return res /= a;
        }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct combination {
        // vector size : n + 1
        vector<mint> fact, ifact;
        // precaliculation O(n)
        combination(int n):fact(n+1), ifact(n+1) {
            assert(n < mod);
            // 0! = 1;
            fact[0] = 1;
            // 1! = 0! * 1 ... n! = (n-1)! * n
            for (int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
            // 1/n! = n!^(-1)
            ifact[n] = fact[n].inv();
            // (n-1)!^(-1) = n!^(-1) * n ... 0!^(-1) = 1!^(-1) * 1
            for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i] * i;
        }
        // combination O(1)
        // nCk = n! / (k! * (n-k)!)
        //     = n! * k!^(-1) * (n-k)!^(-1)
        mint operator()(int n, int k) {
            if (k < 0 || k > n) return 0;
            return fact[n] * ifact[k] * ifact[n-k];
        }
};
/* global variables */
/* function */
/* main */
int main(){
    int S;
    cin >> S;
    mint ans = 0;
    combination c = combination(10000);
    for (int n = S / 3, r = S % 3; n >= 0; n--, r += 3) {
        ans += c(n + r - 1 , r);
    }
    cout << ans << '\n';
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int X , Y , Z;

int main(void) {
    cin >> X >> Y >> Z;

    swap(X, Y);
    swap(X, Z);

    cout << X << ' ' << Y  << ' ' << Z << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <list>
#include <cmath>
#include <cassert>
#include <deque>
#include <iostream>
#include <vector>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>

using namespace std;

typedef int64_t ll;
typedef long double ld;
typedef pair<int, int> pii;

const int SZ = 100 + 100;
const ll MOD = 1e9 + 7;

ll n, a, b;
ll ans;

ll sqr(ll val) {
    return (val * val) % MOD;
}

ll power(ll val, ll step) {
    if (step == 0) return 1ll;
    return (step % 2 == 0 ?  sqr(power(val, step / 2)) :
                             sqr(power(val, step / 2)) * val ) % MOD;
}

int solve() {
    cin >> n >> a >> b;
    ans = 1;
    ans = power(2ll, n);

    ll cur;

    cur = 1;
    for (ll i = n - a + 1; i <= n; ++i) {
        cur *= i;
        cur %= MOD;
    }
    for (ll i = 1; i <= a; ++i) {
        cur *= power(i, MOD - 2);
        cur %= MOD;
    }
    ans -= cur;

    cur = 1;
    for (ll i = n - b + 1; i <= n; ++i) {
        cur *= i;
        cur %= MOD;
    }
    for (ll i = 1; i <= b; ++i) {
        cur *= power(i, MOD - 2);
        cur %= MOD;
    }
    ans -= cur;
    ans--;

    while (ans < 0) ans += MOD;
    cout << ans << endl;
    return 0;
}

int main() {
    ios_base::sync_with_stdio(false);

    //freopen("input.txt", "r", stdin);

    solve();

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>

using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  double r,g;
  cin >> r >> g;
  for (double i = -10000; i < 10000; i++){
    if ((r + i) / 2 == g){
      cout << i << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		String s = scanner.next();
		System.out.println((s.length() == 6 && s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)) ? "Yes" : "No");
    
        scanner.close();
	}
}

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

int main(){
  int x; cin >> x;
  for(int a=1; a<1000; ++a){
    ll a5 = 1;
    rep(i, 5) a5 *= a;
    for(int b=-1000; b<1000; ++b){
      ll b5 = 1;
      rep(i, 5) b5 *= b;
      if(a5 - b5 == x){
        printf("%d %d", a, b);
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <unordered_map> //C++11
using namespace std;

typedef long long ll;

string alp = "abcdefghijklmnopqrstyvwxyz";

int func(string, char);

int main() {
	string s;
	cin >> s;
	int min = 1000;
	int n;
	for (int i = 0; i < s.length(); i++) {
		n = func(s, s.at(i));
		if (n < min) {
			min = n;
		}
	}
	cout << min << endl;
	return 0;
}

int func(string s, char c) {
	bool flag = true;
	for (int i = 0; i < s.length(); i++) {
		if (c != s.at(i)) {
			flag = false;
			break;
		}
	}
	if (flag) return 0;
	else {
		string next = s.substr(0, s.length() - 1);
		for (int i = 0; i < s.length() - 1; i++) {
			if (s.at(i) == c || s.at(i + 1) == c) {
				next.at(i) = c;
			}
		}
		return func(next, c) + 1;
	}
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]

ans = 'No'


def check(x, y):
    for i in range(M):
        for j in range(M):
            if A[x + i][y + j] != B[i][j]:
                return False
    return True


for i in range(N - M + 1):
    for j in range(N - M + 1):
        if check(i, j):
            ans = 'Yes'

print(ans)


Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
const int N=10005;
int G[N],to[N<<1],nxt[N<<1],sz=0,c[N],d[N],s[N];
bool vis[N];
struct node{
	int p,d;
	node(){}
	node(int p,int d):p(p),d(d){}
	inline bool operator <(const node &b)const{return d>b.d;}
};
priority_queue<node> Q;
inline void add(int u,int v){
	to[++sz]=v;nxt[sz]=G[u];G[u]=sz;
	to[++sz]=u;nxt[sz]=G[v];G[v]=sz;
}
int main(){
	int n,i,j,u,v,ans=0;
	node h;
	scanf("%d",&n);
	for(i=1;i<n;++i){
		scanf("%d%d",&u,&v);
		++d[u];++d[v];
		add(u,v);
	}
	for(i=1;i<=n;++i){
		scanf("%d",c+i);
		Q.push(node(i,d[i]));
	}
	sort(c+1,c+n+1);
	for(i=1;i<=n;++i){
		do{
			h=Q.top();u=h.p;
			Q.pop();
		}while(vis[u]);
		s[u]=c[i];vis[u]=1;
		for(j=G[u];j;j=nxt[j])if(!vis[v=to[j]]){
			ans+=c[i];
			--d[v];
			Q.push(node(v,d[v]));
		}
	}
	printf("%d\n",ans);
	for(i=1;i<=n;++i)printf("%d ",s[i]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define P pair<int,int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
#define int long long

const int INF = 1e12;

signed main(){
    int A,B,M;
    cin >> A >> B >> M;

    vector<int> a(A),b(B),d(M);
    int ans = INF;
    int mina = INF, minb = INF;
    rep(i,A) {
        cin >> a[i];
        mina = min(mina,a[i]);
    }
    rep(i,B) {
        cin >> b[i];
        minb = min(minb,b[i]);
    }
    ans = mina + minb;

    rep(i,M) {
        int x,y,c;
        cin >> x >> y >> c;
        x--, y--;
        int res = a[x] + b[y] - c;
        ans = min(ans,res);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
num = int(input())
str_in = [input() for i in range(num)]

sum = 0.0

for i in range(num):
  tmp   = str_in[i].split()
  value = float(tmp[0])
  unit  = tmp[1]
  
  if(unit == 'BTC'):
    sum += value * 380000.0
  else:
    sum += value
    
print (sum)

Measured memory_bytes: 3060
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

fn ans_query(x: &isize, aa: &Vec<isize>, bb: &Vec<isize>) -> isize {
    let mut ans = 1e11 as isize;
    for j in 0..2 {
        let aa_lower = aa.lower_bound(x);
        let aa_pos = if j == 0 || aa_lower == 0 { aa_lower } else { aa_lower - 1};
        let aa_x: isize; 
        if aa_pos < aa.len() { aa_x = aa[aa_pos] } else {continue;};
        
        for k in 0..2 {
            let bb_lower = bb.lower_bound(x);
            let bb_pos = if k == 0 || bb_lower == 0 { bb_lower } else { bb_lower - 1 };
            let bb_x: isize;
            if bb_pos < bb.len() { bb_x = bb[bb_pos] } else { continue; };

            ans = std::cmp::min(ans, (x - aa_x).abs() + (aa_x - bb_x).abs());
        }
    }
    
    ans
}


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        a: usize, b: usize, q: usize,
        mut s_vec: [isize; a],
        mut t_vec: [isize; b],
        x_vec: [isize; q],
    }
    s_vec.sort();
    t_vec.sort();

    for x in x_vec.iter() {
        let ans = std::cmp::min(ans_query(x, &s_vec, &t_vec), ans_query(x, &t_vec, &s_vec));
        println!("{}", ans)
    }


    println!("", );
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 7764
#include <bits/stdc++.h>
 
typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;
 
using namespace std;
 
/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const int MAXN = 1200;
int n;
int av[5100];
vector<int> eds[MAXN];
int p[MAXN];
int x[MAXN];
vector<int> vv;
pair<int, int> dp[MAXN];
 
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		scanf("%d", p + i);
		--p[i];
		eds[p[i]].push_back(i);
	}
	for (int i = 0; i < n; ++i)
		scanf("%d", x + i);
	for (int i = n - 1; i >= 0; --i) {
		int sum = 0;
		vv.clear();
		int nd = x[i];
		for (int u: eds[i]) {
			sum += dp[u].first + dp[u].second;
			nd -= min(dp[u].first, dp[u].second);
			vv.push_back(abs(dp[u].first - dp[u].second));
		}
		if (nd < 0) {
			cout << "IMPOSSIBLE\n";
			return 0;
		}
		memset(av, 0, sizeof(av[0]) * (nd + 1));
		av[0] = 1;
		for (int i: vv) {
			for (int j = nd; j >= i; --j)
				if (av[j - i])
					av[j] = 1;
		}
		for (int j = nd; j >= 0; --j) {
			if (av[j]) {
				sum += nd - j;
				break;
			}
		}
		dp[i] = make_pair(x[i], sum - x[i]);
	}
	cout << "POSSIBLE\n";
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N;
int val[10101010], f[10101010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 1, N + 1) val[i] = i, f[i] = 1;
	rep(p, 2, N + 1) for (int x = p; x <= N; x += p) {
		int c = 0;
		while (val[x] % p == 0) val[x] /= p, c++;
		f[x] *= c + 1;
	}

	ll ans = 0;
	rep(i, 1, N + 1) ans += 1LL * i * f[i];
	cout << ans << endl;
}







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

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

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

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

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

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

int di[] = {0,1,0,-1};
int dj[] = {1,0,-1,0};

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int h,w; cin >> h >> w;
    vector<string> a(h);
    rep(i,h) cin >> a[i];

    vvi d(h, vi(w, INF));
    queue<pii> Q;
    rep(i,h) rep(j,w) if(a[i][j] == '#'){
        Q.emplace(i, j);
        d[i][j] = 0;
    }
    while(!Q.empty()){
        int i = Q.front().fi;
        int j = Q.front().se;
        Q.pop();
        rep(k,4){
            int ni = i + di[k];
            int nj = j + dj[k];
            if(ni < 0 || h <= ni) continue;
            if(nj < 0 || w <= nj) continue;
            if(a[ni][nj] == '#') continue;
            if(d[ni][nj] == INF){
                d[ni][nj] = d[i][j] + 1;
                Q.emplace(ni, nj);
            }
        }
    }

    int ans = 0;
    rep(i,h) rep(j,w) ans = max(ans, d[i][j]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16240
/*********** Template Starts Here ***********/

/*************** Shadman Taqi ***************/
#include<bits/stdc++.h>
using namespace std;

#define MAX 500
#define ll long long
#define ull unsigned long long
#define ___   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define f(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = b; i >= a; i--)
#define debug(x) cout << #x << " " << x << endl;
#define in(x) cin>>x;
#define out(x) cout<<x;
#define gap cout<<" ";
#define nl cout<<endl;
#define cs(x) cout<<"Case "<<x<<": ";
/*********** Template Ends Here ***********/
/** ################################## Code starts here ################################### **/

int main()
{
    ___
    int n,k;
    in(n) in(k)
    ll hp[n],res=0;;
    for(int i=0;i<n;i++)
        cin>>hp[i];
    sort(hp,hp+n);
    for(int j=0;j<n-k;j++)
        res+=hp[j];
    out(res)
    return 0;
}
/** ################################## Happy Coding ################################### **/


Measured memory_bytes: 1792
S = input()
K = int(input())
if K <= len(S):
    is_all_one = 1
    num = 0
    for i in range(K):
        if S[i] != "1":
            is_all_one = 0
            num = S[i]
            break
    if is_all_one:
        print(1)
    else:
        print(num)
else:
    is_all_one = 1
    num = 0
    for i in range(len(S)):
        if S[i] != "1":
            is_all_one = 0
            num = S[i]
            break
    print(num)
        

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

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

int main(int argc, const char * argv[]) {
    int s;
    vector<int> results;
    
    cin >> s;
    results.push_back(s);
    for (int i = 0; i < 1000000; i++) {
        int tmp = func(results[i]);
        results.push_back(tmp);
    }
    
    for (int i = 0; i < 1000000; i++) {
        for (int j = i + 1; j < 1000000; j++) {
            if (results[i] == results[j]) {
                cout << (j + 1) << endl;
                return 0;
            }
        }
    }
    
    return 0;
}

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

using namespace std;

typedef long long int llint;

llint N;

int main() {
	cin >> N;
	vector<llint> X(N);
	for (int i = 0; i < N; i++) {
		cin >> X[i];
	}

	llint ans = 1000000;
	for (int i = 1; i <= 100; i++) {
		llint sum = 0;
		for (int j = 0; j < N; j++) {
			sum += (X[j] - i) * (X[j] - i);
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque

def get_input():
  return list(map(int, input().split(' ')))

(n, q) = get_input()

d = [] # [{i} for i in range(n)]

for _ in range(q):
  c = get_input()
  if c[0] == 0: # unite(x, y)
    i1 = None
    i2 = None
    for i in range(len(d)):
      s = d[i]
      if c[1] in s or c[2] in s:
        if i1 != None:
          i2 = i
          d[i1] = d[i1] | s
          d.pop(i2)
          break
        else:
          i1 = i
    if i1 == None:
      d.append({c[1],c[2]})
    elif i2 == None:
      d[i1] = d[i1] | {c[1],c[2]}
  elif c[0] == 1: # same(x, y)
    p = False
    for s in d:
      if c[1] in s or c[2] in s:
        if c[1] in s and c[2] in s:
          print(1)
        else:
          print(0)
        p = True
        break
    if not p:
      print(0)




Measured memory_bytes: 7624
using System;

namespace CS_Repo
{
    class Program1
    {
        static void Main(string [] args)
        {
            string input = Console.ReadLine();
            if(input[0]=='7' || input[1]=='7' || input[2]=='7')
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
            
        }
    }
}

Measured memory_bytes: 25884
#include<bits/stdc++.h>
using namespace std;
int f(int i,int *a,int* cost,int n,int k){
	//cout<<"SAD";
	if(cost[i]<INT_MAX/2){
	//	cout<<"me!";
		return cost[i];
	}
	if(i>=(n-(k+1))){
	//	cout<<"here";
		return abs(a[i]-a[n-1]);
	}
	for(int j=1;j<=k;j++){
	//	cout<<"EFWSW";
		cost[i] = min(f(i+j,a,cost,n,k)+abs(a[i]-a[i+j]),cost[i]);
	}
	//cost[i] = min(f(i+1,a,cost,n)+abs(a[i]-a[i+1]),f(i+2,a,cost,n)+abs(a[i]-a[i+2]));
	return cost[i];
}
int main(){
	int n;cin>>n;
	int k;cin>>k;
	int a[n]={0};
	int cost[n];
	for(int i=0;i<n;i++){
		cost[i]=INT_MAX/2;
		cin>>a[i];
	}
	//memset(cost,INT_MAX/2,sizeof(cost));
	cost[n-1]=0;
	cout<<f(0,a,cost,n,k);
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

int N,K;
double ans=0;

signed main(){
  cin >> N >> K;
  for(int x=1;x<=N;x++){
    int tmp=x;
    double i=0;
    while(x<K){
      x=x*2;
      i++;
    }
    x=tmp;
    //cout << i << endl;
    ans+=pow(0.5,i);
  }

printf("%.9f\n", ans/N);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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










pair<ull, ull> f(ull n){
    ull res = n % 10, cnt = 0;
    n /= 10;
    while(n > 0){
        res = res + (n % 10);
        cnt++;
        if(res >= 10){
            res = res / 10 + (res % 10);
            cnt++;
        }
        n /= 10;
    }
    return {res, cnt};
}

void f2(ll d, ll c, ull &ans, ull &pre){
    ll tmp = 0;
    while(c >= 10){
        ans += c / 10 * (9 + d);
        tmp += c % 10;
        c = c / 10;
        if(tmp >= 10){
            c += 10;
            tmp -= 10;
        }
    }
    tmp += c;
    REP(j, tmp){
        pre = pre * 10 + d;
    }
}


int main(){
    ll m;
    cin >> m;
    ull ans = 0, pre = 0;
    REP(i, m){
        ll d, c;
        cin >> d >> c;
        f2(d, c, ans, pre);
        auto res = f(pre);
        pre = res.first;
        ans += res.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first 
#define ss second  
typedef pair<int,int> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
} 
int N=1e5+9;
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0); 
	int n; 
	cin>>n; 
	map<string,int> mp;
	for(int i=0;i<n;i++){
	    string s;
	    cin>>s;
	    mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<"\n";
	cout<<"WA x "<<mp["WA"]<<"\n";
	cout<<"TLE x "<<mp["TLE"]<<"\n";
	cout<<"RE x "<<mp["RE"];
	return 0; 
	
}


Measured memory_bytes: 3664
num = int(input())

lst = [int(x) for x in input().split()]

def show():
    for i in range(len(lst)):
        print(lst[i], end="")
        if i < len(lst)-1:
            print(" ", end="")
        else:
            print()

count = 0
for i in range(len(lst)):
    minj = i
    for j in range(i,len(lst)):
        if lst[j] < lst[minj]:
            minj = j
    if i != minj:
        tmp = lst[i]
        lst[i] = lst[minj]
        lst[minj] = tmp
        count +=1

show()
print(count)



Measured memory_bytes: 5624
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k,i,s=0,x;
    cin>>n>>k;
    vii v;
    for(i=0;i<n;++i){
    	cin>>x;
    	v.pb(x);
	}
	sort(v.begin(),v.end());
	for(i=0;i<k;++i){
		s+=v[i];
	}
	cout<<s;
}

Measured memory_bytes: 3612
s=gets.chomp
puts "-1 -1" or exit if s.size <=1
0.upto(s.size-2){|i| (puts "#{i+1} #{i+2}"; exit)if s[i]==s[i+1]}
0.upto(s.size-3){|i| (puts "#{i+1} #{i+3}"; exit)if s[i]==s[i+2]}
puts "-1 -1"


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

int main(){
  std::string S;
  std::cin >> S;
  if(S[0] == S[1] and S[1] == S[2]){
    std::cout << "No" << std::endl;
  }
  else {
    std::cout << "Yes" << std::endl;
  }
  return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> vec(M*2);
  for(int i=0; i<M*2; i++){
    cin >> vec.at(i);
  }
  
  for(int j=1; j<N+1; j++){
    int count = 0;
    for(int k=0; k<M*2; k++){
      if(vec.at(k) == j){
        count++;
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  lli h, a;
  while (scanf("%lld %lld", &h, &a) != EOF)
    printf("%lld\n", h / a + (h % a != 0));
  return 0;
}

Measured memory_bytes: 256
use v5.18;
use warnings;
use List::Util;
use Data::Dumper;
sub read_line { chomp(my $s = <>); $s }
sub splited_read_line { split / /, read_line }
sub unique { my %u; $u{$_} = $_ for @_; values %u; }

my ($T, $X) = splited_read_line;
say $T / $X;


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 7;
const double pi = acos(-1);
const int mod = 100007;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
int vis[107];

int main(){
	memset(vis,0,sizeof(vis));
	int n,k;
	scanf("%d %d",&n,&k);
	while(k--){
		int d;
		scanf("%d",&d);
		while(d--){
			int x;
			scanf("%d",&x);
			vis[x] = 1;
		}
	}
	int sum = 0;
	for(int i = 1;i <= n;i++){
		if(!vis[i]) sum++;
	}
	printf("%d\n",sum);
    return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int dp[1010][1010];

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

    string s1, s2;
    cin >> s1 >> s2;

    int len1 = s1.size() + 1, len2 = s2.size() + 1;

    REP(i, len1) REP(j, len2) dp[i][j] = iINF;

    REP(i, len1) dp[i][0] = i;   
    REP(i, len2) dp[0][i] = i;

    FOR(i, 1, len1)
    {
        FOR(j, 1, len2)
        {
            int cost = s1[i - 1] == s2[j - 1] ? 0 : 1;

            dp[i][j] = min({dp[i - 1][j] + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + cost});
        }
    }

    cout << dp[len1 - 1][len2 - 1] << endl;

    return 0;
}


Measured memory_bytes: 7184
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<long long,int> P;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    ll s = 0;
    rep(i, n) {
        cin >> a[i];
        s += a[i];
    }

    sort(a.begin(), a.end(),greater<int>());

    bool flag = true;
    int i = 0;
    while(i < m){
        if (a[i] * 4 * m < s){
            flag = false;
            break;
        }
        i++;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main()
{
  int n;cin>>n;
  vector<vector<int>>d(n,vector<int>(n));
  for(int i=0;i<n;i++)for(int j=0;j<n;j++)d.at(i).at(j)=-1;
  int a,x,y;
  for(int i=0;i<n;i++){
    cin>>a;
    for(int j=0;j<a;j++){
      cin>>x>>y;
      x--;
      d.at(i).at(x)=y;
    }
  }
  int ans=0;
  for(int i=0;i<(1<<n);i++){
    vector<int>g(n);
    for(int j=0;j<n;j++)if(i>>j&1){
      g.at(j)=1;
    }
    bool ok=true;
    for(int j=0;j<n;j++){
      if(g.at(j)){
        for(int k=0;k<n;k++){
          if(d.at(j).at(k)==-1)continue;
          if(d.at(j).at(k)!=g.at(k))ok=false;
        }
      }
    }
    if(ok)ans=max(ans,__builtin_popcount(i));
  }
  cout<<ans<<endl;
}

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

using namespace std;

int main(void) {
    long double a, b, h, m;
    cin >> a >> b >> h >> m; 
    long double hang, mang, allmin, ang; 
    allmin = (long double)(h * 60 + m);
    hang = (long double)fmod((long double)(allmin / 2), 360);
    mang = (long double)fmod((long double)(6 * allmin), 360);

    if(abs(hang - mang) > 180){
        ang = (long double)(360 - abs(hang - mang));
    }
    else{
        ang = (long double)(abs(hang - mang));
    }

    //cout << a << b << h << m << allmin << hang << mang << ang << endl;

    cout << fixed << setprecision(13) << (long double)sqrt((long double)(a * a + b * b - 2 * a * b * (long double)cos((long double)(ang * M_PI / 180)))) << endl;

    return 0;
}


Measured memory_bytes: 4160
# C Forbidden List

x, n = map(int, input().split())
if n != 0:
  p = list(map(int, input().split()))

  for i in range(100):
    if x-i not in p:
      print(x-i)
      break
    elif x+i not in p:
      print(x+i)
      break
else:
  print(x)

Measured memory_bytes: 9160
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
ll in(){ll x; cin >> x; return x;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];

	sort(all(a));
	rep(i, n/2){
		if(a[i*2] >= 0) break;
		else if(a[i*2] < 0 && a[i*2+1] <= 0){
			a[i*2] *= -1;
			a[i*2+1] *= -1;
		}else{
			if(abs(a[i*2]) > abs(a[i*2+1])){
				a[i*2] *= -1;
				a[i*2+1] *= -1;
			}
			break;
		}
	}
	
	ll ans = 0;
	rep(i, n) ans += a[i];
	co(ans);

	return 0;
}


Measured memory_bytes: 1024
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

n = int(readline())
uv = list(map(int,read().split()))

it = iter(uv)
links = [[] for _ in range(n+1)]
for u,v in zip(it,it):
    links[v].append(u)
    links[u].append(v)

ans = 0
tmp = 0
for i in range(1,n+1):
    tmp += i
    for j in links[i]:
        if(j<i):
            tmp -= j
    ans += tmp

print(ans)

Measured memory_bytes: 133184
N = int(input())
a = list(map(int, input().split()))
b = [0] * 100002
m = 0
for i in range(N):
    for j in range(3):
        b[a[i] + j] += 1
        if b[a[i] + j] > m:
            m = b[a[i] + j]
print(m)


Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    Int P; cin >> P;
    vector<Int> A(P); for (auto &a : A) cin >> a;
    vector<Int> fac(P), inv(P), finv(P);
    fac[0] = finv[0] = fac[1] = inv[1] = finv[1] = 1;
    for (int i = 2; i < P; i++) {
        fac[i] = fac[i - 1] * i % P;
        inv[i] = (P - 1) * (P / i) * inv[P % i] % P;
        finv[i] = finv[i - 1] * inv[i] % P;
    }
    auto comb = [&](int n, int r) {
        if (n < r || n < 0 || r < 0) return 0LL;
        return fac[n] * finv[n - r] % P * finv[r] % P;
    };
    vector<Int> B(P);
    for (int i = 0; i < P; i++) if (A[i]) {
        Int a = P - i, aa = 1;
        for (int j = P-1; j >= 0; j--) {
            if (j == 0) B[j]++;
            B[j] += comb(P-1, j) * aa * (P-1);
            B[j] %= P;
            aa = aa * a % P;
        }
    }
    for (int i = 0; i < P; i++) {
        cout << B[i] << " \n"[i == P-1];
    }
    return 0;
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  ll X, Y;
  cin >> X >> Y;
  if (abs(X - Y) <= 1)
    cout << "Brown" << endl;
  else
    cout << "Alice" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] h=new int[n];
    for(int i=0;i<n;i++){
      h[i]=sc.nextInt();
    }
    int sum=0;
    boolean flag=true;
    while(flag){
      flag=false;
      boolean ed=false;
      for(int i=0;i<n;i++){
        if(h[i]!=0){
          h[i]=h[i]-1;
          if(!ed){
            ed=true;
            flag=true;
            sum++;
          }
        }else{
          ed=false;
        }
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

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

  vector<int> apples(210);
  vector<int> absApples(210);

  for (int i = 1; i <= n; i++) {
    apples[i] = l + i - 1; 
    absApples[i] = abs(apples[i]);
  }

  int absApplesMin = 9999;
  int minIndex = 0;

  for (int i = 1; i <= n; i++) {
    if (absApples[i] <= absApplesMin) {
      absApplesMin = absApples[i];
      minIndex = i;
    }
  }

  int taste = 0;
  for (int i = 1; i <= n; i++) {
    if (i == minIndex) continue;
    taste += apples[i];
  }

  cout << taste << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 2005
#define maxl 1000000000

using namespace std;

#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()

template <class T>
void mini(T& l, T r) {
  l = min(l, r);
}
template <class T>
void maxi(T& l, T r) {
  l = max(l, r);
}

using LL = long long;
using LD = long double;
using ULL = unsigned long long;
const int dx[] = {0, -1, 1, 0, -1, -1, 1, 1},
          dy[] = {-1, 0, 0, 1, -1, 1, -1, 1};
const int INF = 1e9;
const LL MOD = 1e9 + 7;

int t, T;

void Solve() {
  // TODO
  int n;
  string s;
  cin >> n;
  cin >> s;
  if (n < 3200) s = "red";
  cout << s << '\n';
}

void Prepare() {
  // TODO
  return;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  // Prepare();
  //cin >> T;
  //for (t = 1; t <= T; t++) {
    //   printf("Case #%d: ", t);
    Solve();
  //}
  return 0;
}

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

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

    string s;
    getline(cin, s);

    for (auto ch : s) {
        if ('a' <= ch && ch <= 'z') {
            cout << (char)((int)ch - 32);
        } else if ('A' <= ch && ch <= 'Z') {
            cout << (char)((int)ch + 32);
        } else {
            cout << ch;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3204
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_4_B
// Kahn's algorithm
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(int argc, char **argv)
{
        int V, E;
        cin >> V >> E;
        vector<vector<pair<int, int>>> A(V);
        vector<int> B(V);
        for (int i = 0; i < E; i++) {
                int s, t;
                cin >> s >> t;
                A[s].push_back({t, 0});
                B[t]++;
        }
        int edges = E;
        vector<int> L;
        queue<int> S;
        for (int i = 0; i < V; i++)
                if (!B[i])
                        S.push(i);
        while (!S.empty()) {
                auto c = S.front();
                S.pop();
                L.push_back(c);
                for (auto &a: A[c]) {
                        if (a.second)
                                continue;
                        a.second = 1;
                        edges--;
                        if (--B[a.first] == 0)
                                S.push(a.first);
                }
        }
        for (int i = 0; i < V; i++)
                cout << L[i] << endl;
        return 0;
}

Measured memory_bytes: 3888
import sys
input = sys.stdin.readline
from heapq import *
Q = int(input())
L, R = [], []
ans = 0
for _ in range(Q):
    a = [int(a) for a in input().split()]
    if a[0] == 1:
        ans += a[2]
        if len(L) == 0 or a[1] <= -L[0]:
            heappush(L, -a[1])
            ans += -L[0] - a[1]
        else:
            heappush(R, a[1])
            ans += a[1] + L[0]
        if len(R) > len(L):
            ans -= R[0] + L[0]
            heappush(L, -heappop(R))
        elif len(L) - len(R) >= 2:
            heappush(R, -heappop(L))
    else:
        print(-L[0], ans)


Measured memory_bytes: 11100
#include <iostream>
#include <algorithm>

static const long long TOTAL_NORMA = 1000000;
static const int MAX_WORKER_SIZE = 4000;
static long long m[MAX_WORKER_SIZE];
static bool isShow[MAX_WORKER_SIZE];


int main(void) {
    int n;

    while (std::cin >> n) {
        if (n == 0) {
            return 0;
        }

        // init
        bool f = true;
        std::fill(m, m + (sizeof m / sizeof m[0]), 0);
        std::fill(isShow, isShow + (sizeof isShow / sizeof isShow[0]), false);

        for (int i = 0; i < n; ++i) {
            long long number, price, quantity;
            std::cin >> number >> price >> quantity;

            m[number] += (price * quantity);

            if (isShow[number] == false && TOTAL_NORMA <= m[number]) {
                std::cout << number << std::endl;
                isShow[number] = true;
                f = false;
            }
        }

        if (f) {
            std::cout << "NA" << std::endl;
        }

    }

    return 0;
}

Measured memory_bytes: 1200
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

n, u, v = map(int, input().split())
u, v = u - 1, v - 1
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    graph[a].append(b)
    graph[b].append(a)


def dfs(v, d, count):
    count[v] = d
    for v_next in graph[v]:
        if count[v_next] >= 0:
            continue
        dfs(v_next, d + 1, count)


count_tak = [-1] * n
dfs(u, 0, count_tak)
count_aok = [-1] * n
dfs(v, 0, count_aok)

ans = 0
for i in range(n):
    if count_tak[i] < count_aok[i]:
        ans = max(ans, count_aok[i] - 1)

print(ans)


Measured memory_bytes: 101548
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int d;
	int r;
	double f;

	scanf("%d %d", &a, &b);

	d=a/b;
	r=a%b;
	f=1.0*a/b;

	printf("%d %d %.8lf\n", d, r, f);

	return 0;

}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> h(n);
  std::cin >> h;

  h[0]--;
  for (int64_t i = 1; i < n; i++) {
    if (h[i - 1] == h[i]) {
    } else if (h[i] - 1 < h[i - 1]) {
      std::cout << "No" << std::endl;
      return 0;
    } else {
      h[i]--;
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
#define MOD 1000000007
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


int main() {
    int A, B;
    cin >> A >> B;

    if(A > 9 || A < 1) cout << -1 << endl;
    else if(B > 9 || B < 1) cout << -1 << endl;
    else cout << A * B << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define print(a) cout<<(a)<<endl;
#define to_ll(b) stoll(b)
#define MOD 1000000007

int main(){
	int N,M; cin>>N>>M;
	ll point=0;
	vi vec(N);
	rep(i,0,N){
		int A; cin>>A;
		vec[i]=A;
		point+=A;
	}
	sort(all(vec));
	reverse(all(vec));
	string ok="Yes";
	rep(j,0,M){
		//cout<<vec[j]<<" ";
		if(4*vec[j]*M<point){
			ok="No";
			//cout<<endl;
		}
	}
	//cout<<point<<endl;
	cout<<ok;
	
}

Measured memory_bytes: 3608
#include <stdio.h>

int main(void) {
	while (1) {
		int n;
		scanf("%d", &n);
		
		if (n == 0) {
			break;
		}
		
		int a_score = 0;
		int b_score = 0;
		
		int i;
		for (i = 0; i < n; i++) {
			int a;
			int b;
			scanf("%d %d", &a, &b);
			
			*(a >= b ? &a_score : &b_score) += a;
			*(b >= a ? &b_score : &a_score) += b;
		}
		
		printf("%d %d\n", a_score, b_score);
	}
	
	return 0;
}

Measured memory_bytes: 2604
en = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-\'?"

de = {"101":" ","000000":"\'","000011":",","10010001":"-","010001":".","000001":"?",
          "100101":"A","10011010":"B","0101":"C","0001":"D","110":"E","01001":"F",
          "10011011":"G","010000":"H","0111":"I","10011000":"J","0110":"K","00100":"L",
          "10011001":"M","10011110":"N","00101":"O","111":"P","10011111":"Q","1000":"R",
          "00110":"S","00111":"T","10011100":"U","10011101":"V","000010":"W","10010010":"X",
          "10010011":"Y","10010000":"Z"}
while 1:
    try:
        s = input()
        c = ""
        for i in s:
            f = format(en.find(i), "05b")
            c += f
        ans = ""
        tmp = ""
        for i in c:
            tmp += i
            if tmp in de:
                ans += de[tmp]
                tmp = ""
        print(ans)
    except:
        break


Measured memory_bytes: 5596
n,m=map(int,input().split())
A,B=[0]*(n+1),[0]*(n+1)
for i in range(m):
  l,r=map(int,input().split())
  A[l-1]+=1
  A[r]-=1
B[0]=A[0]
for i in range(1,n):
  B[i]=B[i-1]+A[i]
print(B.count(m))

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n, sum = 0;
    cin >> n;
    int m[n][n];
    rep(i, n) rep(j, n) cin >> m[i][j];

    rep(i, n) rep(j, n) if (m[i][j] == -1) m[i][j] = 1e7;

    int d[n];
    rep(i, n) d[i] = 1e7;
    bool used[n] = {};
    d[0] = 0;
    while (1)
    {

        int minv = 1e7;
        int u = -1;
        rep(i, n)
        {
            if (!used[i] && d[i] < minv)
            {
                minv = d[i];
                u = i;
            }
        }
        if (u == -1)
            break;

        sum += minv;
        used[u] = true;

        rep(i, n)
        {

            if (!used[i] && m[u][i] != 1e7 && d[i] > m[u][i])
                d[i] = m[u][i];
        }
    }

    OP(sum);

    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    ll ans = 0;
    vector<bool> dp(n, false);
    rep(i, n) {
        ll bef = i - k;
        if ((bef < 0) || ((t[bef] != t[i]) || (!dp[bef]))) {
            if (t[i] == 'r') {
                ans += p;
            }
            else if (t[i] == 's') {
                ans += r;
            }
            else {
                ans += s;
            }
            dp[i] = true;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
using namespace std;

int main() {
	string A;
	cin >> A;
	int N = A.size();



	int ans = 0;
	int X = 0;
	for (int i = 2; i < N - 1; i++) {
		if (A[0] == 'A' && A[i] == 'C') {
			ans++;
			if (isupper(A[i + 1])) {
				ans++;
			}
		}
	}

	for (int i = 0; i < N; i++) {
		if (isupper(A[i])) {
			X = X + 1;
		}
	}

	if (ans == 1 && X == 2) {
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}
}

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

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

  long long ans = 0;
  for (int i=0; i<n; i++) {
    ans += a[i] / 2;
    if (i == n - 1) {
      break;
    }
    if (a[i] % 2 == 1 && a[i+1] > 0) {
      ++ans;
      --a[i+1];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640