akhauriyash/Code-Regression huggingface dataset:
//#include "stdc++.h"
#include<bits/stdc++.h>
#include<iostream>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define pb push_back
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0) return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p; }
#define flush fflush(stdout)
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
int main()
{
    int n;IOS;int k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++)
        cin>>h[i];
    int dp[n];
    for(int i=0;i<n;i++)
        dp[i]=INF;
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
        for(int j=i-1;j>=max(0,i-k);j--)
        dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


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

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

const int N=1e5+5,Mo=1e9+7;

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

void inc(int &x,int y) {x=x+y>=Mo?x+y-Mo:x+y;}

int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	bool ok=0;
	fo(i,1,n-1) if (s[i]==s[i+1]) {ok=1;break;}
	if (!ok) {puts("1");return 0;}
	sum[0]=0;fo(i,1,n) sum[i]=(sum[i-1]+((s[i]=='a')?1:2))%3;
	fo(i,0,2) nxt[n][i]=n+1;
	fd(i,n-1,0)
	{
		fo(j,0,2) nxt[i][j]=nxt[i+1][j];
		nxt[i][sum[i+1]]=i+1;
	}
	f[0]=1;int ans=0;
	fo(i,0,n)
	{
		fo(j,1,2) inc(f[nxt[i][(sum[i]+j)%3]],f[i]);
		if (i&&sum[i]==sum[n]) inc(ans,f[i]);
	}
	printf("%d\n",ans);
	return 0;
}



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

int main()
{
  int a,b,max;
  cin>>a;
  cin>>b;
  
  max = a+b;

  if(max < a-b)
  {
    max = a-b;
  }

  if(max < a*b)
  {
    max = a*b;
  }

  cout<<max<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    
    int N; cin >> N;
    ves s(N); vi t(N); int ans = 0;
    string X;
    rep(i,N) cin >> s[i] >> t[i];
    cin >> X;
    int i = 0;
    while(X!=s[i]) {
        i++;
    }
    i++;
    while(i < N) {
        ans += t[i];
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// Payment 
// https://atcoder.jp/contests/abc173/tasks/abc173_a
// date: 2020-08-09T18:11:33.316424

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

#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--)

#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

template<typename T, typename ...Args>
void IN(T& first, Args&... args) {
    ((cin >> first), ..., (cin >> args));
}

template<char Sep, typename T, typename ...Args>
void print_sep(const T& first, const Args&... args) {
    ((cout << first), ..., (cout << Sep << args));
}

template<typename... Words>
void OUT(Words... words) {
    print_sep<' '>(words...);
    cout << endl;
    return;
}

#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange

int main(void){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N;
    IN(N);
    OUT((1000 - N % 1000) % 1000);
}


Measured memory_bytes: 3648
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}


#define MAXN (1 << 20)

mod dp[MAXN][3];

int main() {
	cout << fixed << setprecision(12);	
	int n;
	cin >> n;
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i][0] = dp[i - 1][0] * 8;
		dp[i][1] = dp[i - 1][0] + dp[i - 1][1] * 9;
		dp[i][2] = dp[i - 1][1] * 2 + dp[i - 1][2] * 10;
	}
	cout << dp[n][2] << endl;
	return 0;
}




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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) FOR(i,0,a)
#define RREP(i,a) RFOR(i,a,0)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) sort(ALL(a))
#define UNIQUE(a) SORT(a), a.erase(std::unique(ALL(a)), a.end());

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector< VC > VCC;
typedef std::vector<int>  VI;
typedef std::vector< VI > VII;
typedef std::vector<long> VL;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::pair<int,int> PII;

std::string S;

LL solve(LL p) {
    LL rest = 0;
    LL ans = 0;
    int len = S.length();

    REP(i, len) {
        rest *= 10;
        rest += (S[i] - '0');
        if( ((p >> i) & 0x01) == 0x01 ) {
            ans += rest;
            rest = 0;
        }
    }
    ans += rest;
    return ans;
}

int main() {
    std::cin >> S;
    int len = S.length();
    LL sum = 0ll;
    REP(i, (1ll << (len-1))) {
        LL res = solve(i);
        sum += res;
    }
    std::cout << sum << std::endl;
}

Measured memory_bytes: 256
mf = 0
while True:
    m,f,r = [int(i) for i in input().strip().split()]
    if m==f==r==-1 : break
    mf = m+f
 
    if m*f<0 or mf<30 : print("F")
    elif mf<50 and r<50 : print("D")
    elif mf<65 : print("C")
    elif mf<80 : print("B")
    elif mf>=80 : print("A")
    else: print("F")

Measured memory_bytes: 7700
N, M, X = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(N)]

s = float('inf')

for i in range(2 ** N):
    rikai = [0] * M
    total = 0
    is_rikai = True
    for j in range(N):
        if ((i >> j) & 1):
            total += (ca[j][0])
            for k in range(1, M + 1):
                rikai[k - 1] += ca[j][k]
    for l in rikai:
        if l < X:
            is_rikai = False
    if is_rikai:
        s = min(s, total)

if s == float('inf'):
    print(-1)
else:
    print(s)


Measured memory_bytes: 9216
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	ss := strings.Split(s, "")
	for i, f := range ss {
		if ((i + 1) % 2) == 0 {
			if !(f == "L" || f == "U" || f == "D") {
				fmt.Print("No")
				return
			}
		} else {
			if !(f == "R" || f == "U" || f == "D") {
				fmt.Print("No")
				return
			}
		}
	}

	fmt.Print("Yes")
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
ll n;
vll G;
/******* define variable end *******/
int solve() {
	cin >> n;
	G.resize(n);
	vector<pair<ll, ll>> vp;
	for(ll i = 1; i < n; i++){
		ll a, b;
		cin >> a >> b;
		a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
		vp.push_back(make_pair(a,b));
	}
	ll k = 0;
	map<pair<ll, ll>, ll> I;
	vl cs(n, 0);

	vl used(n, 0);
	queue<ll> que;
	used[0] = 1;
	que.push(0);
	while(!que.empty()){
		ll v = que.front(); que.pop();
		if(k < (ll)G[v].size()) k = G[v].size();
		ll cur = 1;
		for(int u:G[v]){
			if(used[u]) continue;
			if(cur == cs[v]) cur++;
			cs[u] = I[make_pair(u, v)] = I[make_pair(v, u)] = cur++;
			used[u] = 1;
			que.push(u);
		}
	}
	cout << k << endl;
	for(auto p : vp) cout << I[p] << endl;
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


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

static const int MAX = 100000;
vector<int> Graph[MAX];
int N;
bool visited[MAX];
int prenum[MAX], parent[MAX], lowest[MAX], timer;

void dfs(int current, int prev){
  // for current pos
  prenum[current] = lowest[current] = timer;
  timer++;
  visited[current] = true;
  int next;
  for(int i = 0; i< Graph[current].size(); i++){
    next = Graph[current][i];
    if(!visited[next]){
      parent[next] = current;
      dfs(next, current);
      // on end search next node
      lowest[current] = min(lowest[current], lowest[next]);
    }else if(next != prev){
      lowest[current] = min(lowest[current], prenum[next]);
    }
  }
}

void art_point(){
  rep(i,N) visited[i] = false;
  timer = 1;
  dfs(0,-1); // preset root = 0
  set<int> ap;
  int np = 0;
  for(int i=1; i<N; i++){
    int p = parent[i];
    if(p==0) np++;
    else if (prenum[p] <= lowest[i]) ap.insert(p);
  }
  if(np > 1) ap.insert(0);
  for(auto itr = ap.begin(); itr != ap.end(); itr++){
    cout << *itr << endl;
  }
}

int main(){

  int m;
  cin >> N >> m;

  rep(i,m){
    int s,t;
    cin >> s >> t;
    Graph[s].push_back(t);
    Graph[t].push_back(s);
  }
  art_point();
  return 0;
}


Measured memory_bytes: 6916
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

template <class T>
using vec = vector<T>;
template <class T>
using vec2 = vector<vec<T>>;
template <class T>
using vec3 = vector<vec2<T>>;

constexpr int INF = numeric_limits<int>::max();
constexpr ll INFL = numeric_limits<ll>::max();
constexpr ll MOD = 1000000007; // 10^9+7

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

int N;
int K;
vec<ll> A;

ll solve()
{
    ll ok = *max_element(A.begin(), A.end()) + 2;
    ll ng = 0;
    while (abs(ok - ng) > 1)
    {
        int mid = (ok + ng) / 2;

        int cnt = 0;
        rep(i, N)
        {
            cnt += (A[i] + mid - 1) / mid - 1;
        }

        if (cnt <= K)
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

int main()
{
    cin >> N >> K;
    A.resize(N);
    rep(i, N) cin >> A[i];
    cout << solve() << endl;
    return 0;
}


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

#ifdef local
template <class T> void _E(T x) { cerr << x; } void _E(double x) { cerr << fixed << setprecision(6) << x; } void _E(string s) { cerr << "\"" << s << "\""; } template <class A, class B> void _E(pair<A, B> x) { cerr << '('; _E(x.first); cerr << ", "; _E(x.second); cerr << ")"; } template <class T> void _E(vector<T> x) { cerr << "["; for (auto it = x.begin(); it != x.end(); ++it) { if (it != x.begin()) cerr << ", "; _E(*it); } cerr << "]"; }
void ERR() {} template <class A, class... B> void ERR(A x, B... y) { _E(x); cerr << (sizeof...(y) ? ", " : " "); ERR(y...); }
#define debug(x...) do { cerr << "{ "#x" } -> { "; ERR(x); cerr << "}" << endl; } while(false)
#else
#define debug(...) 114514.1919810
#endif

using ll = long long;


int main(int argc, char *argv[]) {
  cin.sync_with_stdio(false), cin.tie(nullptr);

  int n, k;
  cin >> n >> k;
  map<int, int> Map;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    Map[x]++;
  }
  vector<pair<int, int>> a(Map.begin(), Map.end());

  int low = 1, high = 1000000000;
  while (low < high) {
    int mid = (low + high) / 2;
    int remain = k;
    for (int i = 0; i < (int) a.size(); i++) {
      int need = (a[i].first - 1) / mid;
      if (1ll * need * a[i].second > remain) {
        remain = -1;
        break;
      } else {
        remain -= need * a[i].second;
      }
    }
    if (remain >= 0) {
      high = mid;
    } else {
      low = mid + 1;
    }
  }
  cout << low << "\n";
}



Measured memory_bytes: 14132
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <set>
#include <sstream>
#include <string>
#include <queue>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

//MOD//
const ll MOD = 1000000007;
struct big;
big ex(big a, ll tms);
typedef struct big{
  ll val;
  big():val(0){}
  big(ll val):val((val%MOD+MOD)%MOD){}
  big& operator += (const big& obj){ (val+=obj.val)%=MOD; return *this;}
  big& operator -= (const big& obj){ (val+=MOD-obj.val)%=MOD; return *this;}
  big& operator *= (const big& obj){ (val*=obj.val)%=MOD; return *this;}
  big& operator /= (const big& obj){ (val*=ex(obj,MOD-2).val)%=MOD; return *this;}
  big operator + (const big& obj)const{ return big(*this) += obj;}
  big operator - (const big& obj)const{ return big(*this) -= obj;}
  big operator * (const big& obj)const{ return big(*this) *= obj;}
  big operator / (const big& obj)const{ return big(*this) /= obj;}
  bool operator < (const big& obj)const{ return val < obj.val;}
  bool operator == (const big& obj)const{ return val == obj.val;}
} big;
istream& operator >> (istream& i, big& obj){ i>>obj.val; return i;}
ostream& operator << (ostream& o, const big& obj){ o<<obj.val; return o;}
big ex(big obj, ll tms){
  if(!tms) return 1;
  big ret = ex(obj, tms/2);
  ret *= ret;
  return (tms&1) ? ret*obj : ret;
}
//MOD//

ll pow(ll n, int m){
  if(!m) return 1;
  ll ret = pow(n, m/2);
  ret *= ret;
  return (m&1) ? ret*n : ret;
}

template <class F, class T>
void convert(const F &f, T &t){
  stringstream ss;
  ss << f;
  ss >> t;
}

int  N;

typedef struct pref {
  int a;
  int b;
  int s;
  bool operator<(const pref &another) const
    {
        return s < another.s;
    };
} pref;

pref x[100005];

int main(){
  scanf("%d",&N);
  rep(i,N) {
    scanf("%d%d", &(x[i].a), &(x[i].b));
    x[i].s = x[i].a + x[i].b;
  }
  sort(x, &x[N]);
  long int ans = 0;
  rep(i, N) ans += (i+N) % 2 ? x[i].a : -x[i].b;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    int x, a;
    cin >> x >> a;

    if(x < a)cout << 0;
    else cout << 10;
}


Measured memory_bytes: 256
s = input()
t = input()
ans = []
if len(s) < len(t):
    print("UNRESTORABLE")
    exit()

for i in range(len(s) - len(t) + 1):
    prot = list(s)
    flag = True
    for j in range(len(t)):
        if prot[i + j] != t[j] and prot[i + j] != "?":
            flag = False
            break
        prot[i + j] = t[j]


    if flag == True:
        prot = "".join(prot).replace("?", "a")
        ans.append(prot)

if ans == []:
    print("UNRESTORABLE")
else:
    ans = sorted(ans)
    print(ans[0])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
   int N;
   cin>>N;
   vector<float> v(N);
   for(int i=0;i<N;i++){
      cin>>v.at(i);
   }

   sort(v.begin(),v.end());
   for(int i=1;i<N;i++){
      v.at(i)=(v.at(i-1)+v.at(i))/2;
   }
   cout<<v.at(N-1)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long dp[401][401] = {0};
long long n, i, j, k, a[401] = {0}, pref[401] = {0};
int main()
{
	cin >> n;
	for(i = 0; i < n; i++)
	{
		cin >> a[i];
		if(i == 0)
			pref[i] = a[i];
		else
			pref[i] = pref[i - 1] + a[i];
	}
	for(i = 2; i <= n; i++)
	{
		for(j = 0; j + i - 1 < n; j++)
		{
			long long mn = 1e18;
			for(k = j; k < j + i - 1; k++)
			{
				if(j > 0)
					mn = min(mn, dp[j][k] + dp[k + 1][j + i - 1] + pref[k] - pref[j - 1] + pref[j + i - 1] - pref[k]);
				else
					mn = min(mn, dp[j][k] + dp[k + 1][j + i - 1] + pref[k] + pref[j + i - 1] - pref[k]);
			}
			dp[j][i + j - 1] = mn;
		}
	}
	cout << dp[0][n - 1];
	return 0;
}

Measured memory_bytes: 4856
n,h,w = map(int,input().split())
a = []
b = []
for i in range(n):
    tmp1,tmp2 = map(int,input().split())
    a.append(tmp1)
    b.append(tmp2)
counter = 0
for i in range(n):
    if a[i] >= h and b[i] >= w:
        counter +=1
print(counter)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);

        int p = sc.nextInt();
        int q = sc.nextInt();
        int r = sc.nextInt();

        int a = Math.min((p+q), (q+r));

        System.out.print(Math.min(a, (r+p)));

        }
}




Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;

int main() {
   int n; cin>>n;
   if(n==1)cout<<1<<endl;
   else{
      ll a=2;
      ll ans=1;
      rep(i,2,n+1){
         ll aa=ans;
         ans+=a;
         a=aa;
      }  
      cout<<ans<<endl;
   }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 string s;
  cin>>s;
  sort(s.begin(),s.end());
  if(s[0]==s[1] and s[2]==s[3] and s[1]!=s[2]){
      cout<<"Yes";
  }  else cout<<"No";
}

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

int n;
std::vector<int> freq[100100];
int ans[100100];

int main()
{
	std::cin >> n;
	for(int i=1;i<=n;i++)
	{
		int temp;
		std::cin >> temp;
		freq[temp].push_back(i);
	}
	int parity;
	if(n%2==1)
		parity=1;
	else
		parity=0;
	bool valid=true;
	if(n%2==1)
	{
		if(freq[0].size()!=1)
			valid=false;
		else
		{
			ans[n/2]=freq[0][0];
		}
	}
	long long int cur_ans=1;
	long long int MOD=int(1e9)+7;
	for(int i=0;i<n/2 && valid;i++)
	{
		int dist=n-2*i-1;
		if(freq[dist].size()!=2)
			valid=false;
		else
		{
			ans[i]=freq[dist][0];
			ans[n/2+parity+i]=freq[dist][1];
		}
		cur_ans=(cur_ans+cur_ans)%MOD;
	}
	if(!valid)
		std::cout << 0;
	else
	{
		/*for(int i=0;i<n;i++)
		{
			if(i)
				std::cout << ' ';
			std::cout << ans[i];
		}*/
		std::cout << cur_ans;
	}
	std::cout << '\n';
}

Measured memory_bytes: 4608
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;



void solve() {
    int a, b;
    cin >> a >> b;
    if ((a * b) & 1) {
        cout << "Yes\n";
    }
    else 
        cout << "No\n";
}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};


int main() {
    string s, t; cin >> s >> t;
    int n = sz(s);
    int m = sz(t);
    bool ok = false;
    rrep(i,n-m+1) {
        bool check = true;
        int cnt = 0;
        for (auto a : t) {
            if (a != s[i+cnt] && s[i+cnt] != '?') {
                check = false;
                break;
            }
            cnt++;
        }
        if (check) {
            cnt = 0;
            for (auto a : t) {
                s[i+cnt] = a;
                cnt++;
            }
            rep(i,n) {
                if (s[i] == '?') s[i] = 'a';
            }
            ok = true;
        }
    }
    if (!ok) cout << "UNRESTORABLE" << endl;
    else {
        rep(i,n) {
            cout << s[i];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3576
#include <iostream>
#include <cstring>

using namespace std;

int main()
{

	string a,b,aa="",bb="";

	int j=0;

	cin >> a;

	int i,k,l;

	k = a.size();

	string str,rts;

	for (i = 0; i < k; ++i) {
		char p = toupper(a[i]);
		str += p;
	}

	while (true) {

		cin >> b;

		if (b == "END_OF_TEXT") { break; }

		l = b.size();

		rts = "";

		for (i = 0; i < l; ++i) {
			char q = toupper(b[i]);
			rts += q;
		}

		if (str == rts) { ++j; }

	}

	cout << j << endl;

}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mod 1000000007
int main() {
    fio;
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k){
     cout<<k;
    }
    else if(a<k and (a+b)>=k){
        cout<<a;
    }
    else if(a<k and (a+b+c)>=k){
        ll no=k-a-b;
       cout<<a-no;
    }
}



Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static int createNumber(int x){
        int n = (x*10 + x) * 10 + x;
        return n;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = in.nextInt();
        if (n > 999){
            System.out.println(1111);
        }
        else {
            int first = (n /10) /10;
            if (n <= createNumber(first))
                System.out.println(createNumber(first));
            else System.out.println(createNumber(first+1));
        }
    }
    
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int main(){
	int n,d;
	cin>>n>>d;
	vector<vector<int>> x(n,vector<int>(d));
	rep(i,n){
		rep(j,d)cin>>x[i][j];
	}
	int ans=0;
	rep(i,n)rep(j,i){
		int sq=0;
		rep(k,d){
			int s=x[i][k]-x[j][k];
			sq+=s*s;
		}
		int s=sqrt(sq)+0.5;
		if(s*s==sq)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let a: usize = iter.next().unwrap().parse().unwrap();
    let b: usize = iter.next().unwrap().parse().unwrap();
    let n: usize = iter.next().unwrap().parse().unwrap();

    for _ in 0..n {
        let aa: usize = iter.next().unwrap().parse().unwrap();
        let bb: usize = iter.next().unwrap().parse().unwrap();
        if !(a >= bb || b <= aa) {
            println!("{}", 1);
            return;
        }
    }

    println!("{}", 0);
}



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

int main() {
  int N; cin >> N;
  vector<int> a(3*N);
  for(int i = 0; i < 3*N; i++) cin >> a[i];
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int64_t sum = 0;
  int count = N;
  for(int i = 1; i<3*N-1; i+=2){
    
    sum += a[i];
    
    count--;
    if(count==0)break;
    
  }
  cout << sum << endl;
}


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

int main()
{
    int n,i,j;
    string s;
    cin>>s;
    n = s.length();
    long ans = 0;
    j = -1;
    for(i=0;i<=n-2;i++)
    {
        if(s[i]=='A' && j==-1)
        {
            j = i;
            while(i<n && s[i]=='A')
                i++;
            i--;
        }
        else if(s[i]=='B' && s[i+1]=='C' && j!=-1)
        {
            // cout<<i<<" "<<j<<endl;
            ans += i-j;
            s[j] = 'B';
            s[j+1] = 'C';
            if(s[i]!='C')
                s[i] = 'A';
            s[i+1] = 'A';
            j += 2;
            i++;
        }
        else
        {
            if(s[i]!='A')
                j = -1;
        }
    }
    // cout<<s<<" ";
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func arrayToStr(l []int) (s string) {
	for _, v := range l {
		s += fmt.Sprintf("%d ", v)
	}
	s = strings.TrimRight(s, " ")
	return
}

func stringListToInt(strList []string) (intList []int) {
	for _, v := range strList {
		x, _ := strconv.Atoi(v)
		intList = append(intList, x)
	}
	return
}

func main() {
	N, _ := strconv.Atoi(nextLine())
	s := nextLine()
	ltmp := strings.Split(s, " ")
	l := stringListToInt(ltmp)
	c := 0

	for i := 0; i < N; i++ {
		minj := i
		for j := i; j < N; j++ {
			if l[j] < l[minj] {
				minj = j
			}
		}
		if i != minj {
			tmp := l[i]
			l[i] = l[minj]
			l[minj] = tmp
			c++
		}
	}
	fmt.Println(arrayToStr(l))
	fmt.Println(c)
}



Measured memory_bytes: 1180
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, K int
	fmt.Scan(&N)
	fmt.Scan(&K)
	n := make([]int, N)
	for i := range n {
		fmt.Scan(&n[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(n)))
	if K > N {
		K = N
	}
	for i := 0; i < K; i++ {
		n[i] = 0
	}
	var r int
	for _, x := range n {
		r += x
	}

	fmt.Println(r)
}


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

int main() {
  int N; cin >> N;
  int a;
  int answer = 0;
  for (int i = 0; i < N; i++) {
    cin >> a;
    if (a%2 == 0) {
      while (a%2 == 0) {
        a/=2; answer++;
      }
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 * ????????????:
 * 	????????¶??´?????????:O(n^2)
 * ????????????????????¢?¬???°?§°???????????°??????????????°,?????\?????°??°???????????±?¨????
 */

#include <bits/stdc++.h>

using namespace std;

// ????????????,?????????????????¢????¬???°
int bubbleSort(int A[], int N){
	int sw = 0; // ?????¢?¬???°
	bool flag = true; // ???????????¨?????\?????¢???????´?
	for(int i = 0; flag; i++){
		flag = false;
		for(int j = N-1; j >= i+1; j--){ // ????????\.????¬??????¢?????????????????¨???????¢??????????????´?
			if(A[j-1] > A[j]){ // ???????????¢???????´??????????????´???§,?°±?????¢
				swap(A[j-1], A[j]);
				flag = true;
				sw++;
			} 
		}
	}
	return sw;
}

int main(){
	//freopen("in.txt", "r", stdin);
	int N,A[100],sw;
	while(cin >> N) {
	    for(int i = 0; i < N; i++) cin >> A[i];
	    sw = bubbleSort(A, N);
	    for(int i = 0; i < N; i++){
	    	if(i) cout << " ";
	    	cout << A[i];
	    }
	    cout << endl;
	    cout << sw << endl;
	}
}

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

using namespace std;
using ll = long long;

#define INF (1LL << 60)

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    string S;
    ll Q;
    cin >> S;
    cin >> Q;
    vector<string> query(Q+1);
    REP(i,0,Q+1) {
        getline(cin, query[i]);
    }

    vector<ll> T(Q, 0), F(Q, 0), C(Q, 0);
    REP(i,1,Q+1) {
        T[i-1] = query[i][0];
        if(T[i-1] == '2') {
            F[i-1] = query[i][2];
            C[i-1] = query[i][4];
        }
    }

    string left, right;
    ll rev = 0;

    REP(i,0,Q){
        if(T[i] == '1') {
            rev++;
        }
        else {
            if(rev % 2 == 0) {
                if(F[i] == '1') left += C[i];
                else right += C[i];
            }
            else {
                if(F[i] == '1') right += C[i];
                else left += C[i];
            }
        }
    }

    if(rev % 2 == 0) {
        reverse(ALL(left));
        _PR(left+S+right);
    }
    else {
        reverse(ALL(right));
        reverse(ALL(S));  
        _PR(right+S+left);
    }    

    return 0;
}

/*



*/

Measured memory_bytes: 16964
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'

int n, m;
vector<vi> adjList;
vi dp;

int solve(int p) {
	if (dp[p] != -1) return dp[p];
	int ans = 0;
	for (int i: adjList[p]) ans = max(ans, 1+solve(i));
	
	return dp[p] = ans;
}

int main() {
	#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	#endif
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> m;
	adjList.resize(n); dp.resize(n, -1);
	
	for_(i, 0, m) {
		int a, b; cin >> a >> b;
		adjList[b-1].push_back(a-1);
	}
	
	for_(i, 0, n) solve(i);
	
	cout << *max_element(dp.begin(), dp.end()) << endl;
	

	return 0;
}


Measured memory_bytes: 13348
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main(){
    int n, tmp;
    cin >> n;
    vector<int> buka(n, 0);
    rep(i,n - 1){
        cin >> tmp;
        tmp--;
        buka[tmp]++;
    }
    rep(i,n) {
        cout << buka[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4028
#include<stdio.h> 
#include<stdlib.h>
#include<cstring>
#include<string> 
#include<iostream>
using namespace std;

int main()
{
	int a,b,c,x,y,cost=0;
	cin>>a>>b>>c>>x>>y;
	if(x<y)
	{
		 swap(x,y);
		 swap(a,b);
	}
	if((a+b)> 2*c)
	{
		int p1 = x*2*c;
		int p2 = y*2*c + (x-y)*a;
		cost = min(p1,p2);
	}
	else 
	{
		cost = cost + a*x+b*y;
		x=0;
		y=0;
	}
	cout<<cost<<endl;
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, raw_input().split())
IPY = [[i]+map(int, raw_input().split()) for i in range(M)]
IPY_y_sorted = sorted(IPY, key=lambda x:x[2])
ans = [long(0)]*M
P_count = [0]*N
for ipy in IPY_y_sorted:
  P_count[ipy[1]-1] += 1
  ans[ipy[0]] = long(ipy[1]*1e6)+P_count[ipy[1]-1]
for a in ans:
  print "%012d"%a



Measured memory_bytes: 29200
#include<stdio.h>

int main(void)
{
    long int n;
    long int m;
    long int ans=0;
    // char str[100];
    
    // fgets(str,sizeof(str),stdin);
    // sscanf(str,"%d %d",&n,&m);
    scanf("%ld",&n);
    scanf("%ld",&m);
    // printf("%ld\n",n);
    // printf("%d\n",m);

    ans=n;
    long int a[m];
    for (int i=0;i<m;i++){
        scanf("%ld",&a[i]);
        // printf("%ld\n",a[i]);
        ans=ans-a[i];
        // printf("%ld\n",ans);
    }

    if (ans<0)
        printf("-1\n");
    else
        printf("%ld\n",ans);

    // if (ans<0){
    //     ans=0;
    // }else{
    //     ans=ans+0;
    // }

    // printf("%ld\n",ans);

    return 0;

}

Measured memory_bytes: 1756
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    cin >> a >> b;
    if(a/10==0&&b/10==0) cout << a*b;
    else cout << -1;

    return 0;
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll n; cin >> n;
  ll odd = n / 2, ki = n / 2;
  if(n % 2 != 0) ki++;
  fin(odd * ki)
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define Graph vector<vector<int>>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }


void func(long long a){

}

int main(){

    long long a;
    scanf("%lld",&a);
    cout << a+a*a+a*a*a
    
     << endl;
    return 0;
}


Measured memory_bytes: 3764
from __future__ import print_function
import numpy as np
import sys
import math,string,itertools,fractions,heapq,collections,re,array,bisect,copy,functools
# from itertools import accumulate
# from collections import deque
import random

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

n = int(input())
if n==25:
    print("Christmas")
elif n==24:
    print("Christmas Eve")
elif n==23:
    print("Christmas Eve Eve")
else:
    print("Christmas Eve Eve Eve")



Measured memory_bytes: 19508
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	int DP(int sai[],int road[],int X,int Y){
		double result = 0;
		double all[][] = new double [Y+1][5000]; 
		all[0][0] = 1;
		for(int i = 0;i < Y;i++){
			for(int j = 0;j < X;j++){
				for(int k = 0;k < 5000;k++){
					if(i + sai[j] < Y){
						if(road[i+sai[j]] > 100){
							if(i + sai[j] + road[i+sai[j]] - 100 > Y){
								all[Y][k] = all[Y][k] + (all[i][k]/X);
							}else{
								all[i+sai[j]+road[i+sai[j]]-100][k] = all[i+sai[j]+road[i+sai[j]]-100][k]+(all[i][k]/X);
							}
						}else{
							if(k + road[i+sai[j]]>0 && k + road[i+sai[j]] < 5000){
								all[i+sai[j]][k+road[i+sai[j]]] = all[i+sai[j]][k+road[i+sai[j]]] + (all[i][k]/X);
							}else{
								all[i+sai[j]][0] = all[i+sai[j]][0] + (all[i][k]/X);
							}
						}
					}else{
						all[Y][k] = all[Y][k] + (all[i][k]/X);
					}
				}
			}
		}
		for(int i = 0;i < 5000;i++){
			result = result + all[Y][i]*i;
		}
		return (int) result;
	}
	void doIt() {
		while(true){
			int X = sc.nextInt();
			int Y = sc.nextInt();
			int Z = sc.nextInt();
			if(X+Y+Z == 0)break;
			int sai[] = new int [X];
			int road[] = new int [Y+1];
			for(int i = 0;i < X;i++){
				sai[i] = sc.nextInt();
			}
			for(int i = 0;i < Z;i++){
				int N = sc.nextInt();
				int E = sc.nextInt();
				int A = sc.nextInt();
				if(E == 1){
					road[N] = A+100;
				}else if(E == 2){
					road[N] = A;
				}else if(E == 3){
					road[N] = -A;
				}
			}
			System.out.println(DP(sai,road,X,Y));
		}
     }
    public static void main(String[] args) {
    	// TODO Auto-generated method stub
    	new Main().doIt();
    }
}

Measured memory_bytes: 62908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
ll h, w, ans = INF;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> h >> w;
    
    // Either two horiz cuts, two vert cuts, or one each
    if (!(h % 3)) ans = 0;
    else ans = min(ans, w);
    
    if (!(w % 3)) ans = 0;
    else ans = min(ans, h);
    
    for (int i = 1; i < w; i++) {
		ans = min(ans, max(h * i, (ll)ceil((long double)h / 2) * (w - i)) - min(h * i, h / 2 * (w - i)));
		// cout << h * i << " " << (ll)ceil((long double)h / 2) * (w - i) << " " << h / 2 * (w - i) << "\n";
		// cout << max(h * i, (ll)ceil(h / 2) * (w - i)) - min(h * i, h / 2 * (w - i)) << "\n";
	}
	
	for (int i = 1; i < h; i++) {
		ans = min(ans, max(w * i, (ll)ceil((long double)w / 2) * (h - i)) - min(w * i, w / 2 * (h - i)));
	}
    
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import collections

ab=[[i for i in input().split()] for i in range(3)]
aball=ab[0]+ab[1]+ab[2]
cn=collections.Counter(aball)
cnv=list(cn.values())
cnv.sort(reverse=True)
print('YES'if cnv[0]==2 and cnv[1]==2 else 'NO')

Measured memory_bytes: 3316
import sys

input = sys.stdin.readline


def check_format(num):
    if not num:
        return 0
    if num <= 12:
        return 1
    return 2


def main():
    s = input()
    f = int(s[:2])
    b = int(s[2:])
    f_format = check_format(f)
    b_format = check_format(b)
    format_ = "AMBIGUOUS"
    if set([f_format, b_format]) == {2}:
        format_ = "NA"
    if set([f_format, b_format]) == {0}:
        format_ = "NA"
    if [f_format, b_format] == [0, 2] or [f_format, b_format] == [2, 0]:
        format_ = "NA"
    if f_format == 1 and b_format in (0, 2):
        format_ = "MMYY"
    if f_format in (0, 2) and b_format == 1:
        format_ = "YYMM"
    print(format_)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

int main(){
	
	double xa,ya,xb,yb,xc,yc,xd,yd;
	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)!=EOF){
		double EPS = 1e-12;
		if(fabs((xb-xa)*(xd-xc)+(yb-ya)*(yd-yc))<EPS)puts("YES");
		else puts("NO");
	}
}

Measured memory_bytes: 1192
#include <cstdio>
#include <vector>
#include <map>
#include <queue>

#define INFL 1000000000000000LL

using namespace std;

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

vector<ll> dijkstra(ll s, vector< vector<pl> > e) {
    ll n = e.size();
    vector<ll> minD(n, INFL);
    minD.at(s) = 0;
    priority_queue< pl, vector<pl>, greater<pl> > q;
    q.push(pl(0, s));
    while (!q.empty()) {
        pl now = q.top();
        q.pop();
        ll c = now.first, v = now.second;
        if (minD.at(v) < c) continue;
        for (ll i = 0; i < e.at(v).size(); ++i) {
            pl p = e.at(v).at(i);
            if (minD.at(p.first) > minD.at(v) + p.second) {
                minD.at(p.first) = minD.at(v) + p.second;
                q.push(pl(minD.at(p.first), p.first));
            }
        }
    }
    return minD;
}

int main() {
    int h, w;
    ll c, a, ans = 0;
    scanf("%d%d", &h, &w);
    vector< vector<pl> > e(10, vector<pl>(9));
    for (int i = 0; i < 10; ++i) for (int j = 0; j < 10; ++j) {
        scanf("%lld", &c);
        if (i != j) e.at(i).at(j - (i < j)) = {j, c};
    }
    vector< vector<ll> > d(10, vector<ll>(10));
    for (int i = 0; i < 10; ++i) d.at(i) = dijkstra(i, e);
    for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) {
        scanf("%lld", &a);
        if (a >= 0) ans += d.at(a).at(1);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
//ABC085-C
#include<iostream>
using namespace std;

int N,Y;

int main(){
    
    cin>>N>>Y;
    //合計N枚なので10000円x,5000円yを決めれば自動的に1000円zは定まる
    //O(n^2)でN<=2000より間に合う
    for(int x=0; x<=N; x++){
        for(int y=0; y<=N-x; y++){
            int z=N-x-y;
            if(10*x+5*y+z==Y/1000){//Yは1000の倍数なので割っても問題ない
                cout<<x<<" "<<y<<" "<<z<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	llint i,n,p,ans=1;cin>>n>>p;
	if(n==1){cout<<p<<endl;return 0;}
	for(i=2;pow(i,n)<p+5;i++){
		llint wa=1;
		for(int j=0;j<n;j++){wa*=i;}
		if(p%wa==0){p/=wa;ans*=i;i--;continue;}
	}
	cout<<ans<<endl;
	return 0;
}



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

using namespace std;

int main(){
    string s;
    cin >> s;
    sort(s.begin(), s.end());

    string t;
    cin >> t;
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  int n;
  cin >> n;
  double ans=0.0;
  for(int i=0; i<n; i++){
    double x;
    string s;
    cin >> x >> s;
    if(s=="JPY") ans += x;
    else ans += x*380000.0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3736