akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define boolsize 1000001
#define pi pair<ll,ll>
#define vi vector<ll>
#define vii vector<pi>
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showvector1(vector <T> v)
{
    ll n=v.size();
    fo1(i,n-1)
        cout<<v[i]<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{   if(x<=1)
     return false;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
/// check for test case before submitting
void vfun()
{
    ll n,k;
    cin>>n;
    vector <ll> v(n);
    fo(i,n)
    cin>>v[i];

}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
    //cin>>test;
    while(test--)
    {

        ll n;
        cin>>n;
        ll ans=n/11;
        ans=2*ans;
        if(n%11>=7)
            ans+=2;
        else if(n%11>0)
            ans+=1;
        cout<<ans<<endl;

//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not




Measured memory_bytes: 3632
#!/usr/bin/env python3
#ABC142 E

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()
cost = []
key = []
for _ in range(m):
    a,b = LI()
    cost.append(a)
    c = LI()
    tmp = 0
    for i in c:
        tmp |= 1 << (i-1)
    key.append(tmp)
dp = [[inf]*(m+1) for _ in range(2**n)]
dp[0][0] = 0
for i in range(2**n):
    M = min(dp[i])
    for j in range(1,m+1):
        s = key[j-1]
        if i|s > i:
            dp[i|s][j] = min(dp[i|s][j],M + cost[j-1])
if min(dp[-1]) == inf:
    print(-1)
else:
    print(min(dp[-1]))

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

typedef long long ll;

int main() {
    string s; cin >> s;
    vector<char> cs(s.begin(), s.end());
    int ans=1e7;
    for (int i=0; i<26; ++i) {
        char c='a'+i;
        if (find(cs.begin(), cs.end(), c)==cs.end()) {
            continue;
        }
        vector<char> target=cs;
        while (1) {
            bool all_same=true;
            for (auto cc : target) {
                if (cc!=c) {
                    all_same=false;
                    break;
                }
            }
            if (all_same) {
                ans=min((int)s.size()-(int)target.size(), ans);
                break;
            }
            for (int k=0; k<(int)target.size()-1; ++k) {
                if (target[k]==c||target[k+1]==c) {
                    target[k]=c;
                }
            }
            target.pop_back();
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
// -*- mode: cpp; coding=utf-8-unix; -*-
// vim: filetype=cpp fileencoding=utf-8 fileformat=unix
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define INTMAX  99999999

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

#define MAXN (1000*100)
int N;
int A[MAXN];

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> N;
	int neg_count = 0;
	int min_abs = INTMAX;
	long long sum_abs = 0;
	for(int n=0; n<N; n++) {
		cin >> A[n];
		if (0>A[n]) {
			neg_count++;
		}
		A[n] = abs(A[n]);
		sum_abs += A[n];
		if (min_abs>A[n]) {
			min_abs = A[n];
		}
	}
	// cout << "neg_count="<<neg_count<<endl;
	// cout << "sum_abs="<<sum_abs<<endl;
	// cout << "min_abs="<<min_abs<<endl;
	if (neg_count%2==0) {
		cout << sum_abs << endl;
	}
	else {
		cout << sum_abs - 2*min_abs << endl;
	}


	return 0;
}



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

int main() {
    int n;
    cin >> n;
    int t, a; 
    cin >> t >> a;
    int H;
    double h[100000];
    double tmp = 100000000;
    int count = 0;
    for ( int i = 0; i < n; i++ ) {
        cin >> H;
        h[i] = (double)t - (double)H * 0.006;
        if ( abs(h[i]-(double)a) < tmp ) {
            tmp = abs(h[i]-(double)a);
            count = i+1;
        }
    }
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	lint A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;

	set<lint> wat, sug;
	for (int i = 0; i <= 3000; i++) {
		for (int j = 0; j <= 3000; j++) {
			if ((A * i + B * j) * 100 <= F) wat.emplace(A * i + B * j);
			if (C * i + D * j <= F) sug.emplace(C * i + D * j);
		}
	}

	double maxC = 0.0;
	pair<lint, lint> ans{ 100 * A, 0LL };
	for (const auto &w : wat) {
		for (const auto &s : sug) {
			if (s <= w * E && w * 100 + s <= F) {
				if (maxC < 1.0 * s / w) {
					maxC = 1.0 * s / w;
					ans = { 100 * w + s, s };
				}
			}
		}
	}

	cout << ans.first << " " << ans.second << "\n";

	return 0;
}


Measured memory_bytes: 384
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
SA = sum(A)
SB = sum(B)
if SA < SB:
  print(-1)
else:
  under = []
  over = []
  cnt = 0
  for i in range(N):
    if A[i] < B[i]:
      under.append(abs(A[i]-B[i]))
      cnt += 1
    elif A[i] > B[i]:
      over.append(abs(A[i]-B[i]))
  over.sort()
  over.reverse()
  un_cnt = 0
  ov_cnt = 0
  if len(under) != 0:
    cnt += 1
    while un_cnt < len(under):
      if over[ov_cnt] > under[un_cnt]:
        over[ov_cnt] -= under[un_cnt]
        un_cnt += 1
      else:
        while under[un_cnt] > over[ov_cnt]:
          under[un_cnt] = under[un_cnt]-over[ov_cnt]
          ov_cnt += 1
          cnt += 1
        if under[un_cnt] == over[ov_cnt]:
          un_cnt += 1
          ov_cnt += 1
        else:
          over[ov_cnt] -= under[un_cnt]
          un_cnt += 1
  print(cnt)

Measured memory_bytes: 18360
n, m = map(int, raw_input().split())
import sys
edges = []
dist = [sys.maxint]*(n+1)
dist[1] = 0
dist
for _ in range(m):
    a, b, c = map(int, raw_input().split())
    edges.append((a, b, -c))

for i in range(n-1):
    for a, b, c in edges:
        if dist[b] > dist[a] + c:
            dist[b] = dist[a] + c
negative = [False] *(n+1)
for i in range(n):
    for a, b, c in edges:
        if dist[a] + c < dist[b] or negative[a]:
            negative[b] = True
if negative[n]:
    print "inf"
else:
    print -dist[n]

Measured memory_bytes: 2936
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int long long i=0;i<n;i++)
using namespace std;

int main(){
   int long long n,k;
   cin>>n>>k;
   int long long c=0,d=0;

   for(int i=1;i<=n;i++){
       if(i%k==0)++c;
       if(k%2==0&&i%k==k/2)d++;

   }

   cout<<c*c*c+d*d*d<<endl;

    return 0;
}


Measured memory_bytes: 256
N,M = map(int, input().split())
cost = [0,2,5,5,4,5,6,3,7,6]
A = list(map(int, input().split()))

costp = sorted([ (cost[a] ,a) for a in A], key=lambda x:x[1], reverse=True)
costX = [ z[0] for z in costp]
A = [ z[1] for z in costp]
# print(A,costX)

dp = [-1] * (N+1)
dp[N] = 0

for i in range(N, 1, -1):
    if (dp[i]) == -1:
        continue

    for c,a in zip(costX,A):
        if i-c >= 0:
            dp[i-c] = dp[i] + 1


ans = ""

i = 0
while i<N:
    # print(i)
    for c,a in zip(costX,A):
        # print(c,a,i)
        # if i+c <= N:
        #     print("i: {}, dp[i]=".format(i), dp[i], ", dp[i+c]: ", dp[i+c], "c=",c, "a=",a)
        # else: print("i: {}, dp[i]=".format(i), dp[i], ",c=",c, "a=",a)
        
        if i+c <= N:
            if dp[i]-1 == dp[i+c]:
                ans += str(a)
                i = i+c
                break

print(ans)
# print(dp)



Measured memory_bytes: 41836
#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#endif
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<char> Vc;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;
typedef vector<vector<char>> VVc;
typedef vector<vector<vector<ll>>> VVV;
typedef vector<vector<vector<vector<ll>>>> VVVV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define rEach(i, mp) for (auto i = mp.rbegin(); i != mp.rend(); ++i)
#ifdef LOCAL
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgset(st) cerr << #st << ":"<<endl; for (auto i = st.begin(); i != st.end(); ++i) { cerr << *i <<" ";}cerr<<endl;
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#else
#define dbg(...)
#define dbgmap(...)
#define dbgset(...)
#define dbgarr(...)
#define dbgdp(...)
#endif
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int solve(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll k;cin>>k;
    ll cnt = 0;
    while(a>=b){
        b *= 2;
        cnt++;
    }
    while(b>=c){
        c *= 2;
        cnt++;
    }
    Yes(cnt<=k);
    return  0;
}

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


Measured memory_bytes: 3648
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;


int main()
{


	ll n, w;
	cin >> n >> w;

	ll V = 0;
	ll u[n + 1];
	ll v[n + 1];
	for (ll i = 1; i <= n; i++)
	{
		cin >> u[i] >> v[i];
		V += v[i];
	}
	ll arr[V + 1];
	for (ll i = 1; i <= V; i++)
	{
		arr[i] = INT_MAX;
	}
	arr[0] = 0;
	for (ll i = 1; i <= n; i++)
	{

		for (ll j = V; j >= v[i]; j--)
		{
			arr[j] = min(arr[j], arr[j - v[i]] + u[i]);
		}
	}


	for (ll i = V; i >= 0; i--)
	{
		if (arr[i] <= w)
		{
			cout << i << endl;
			break;
		}
	}




}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end(), greater<int>());
	int sum = accumulate(a.begin(), a.end(), 0);

	int count = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] < (double)(sum / (4.0 * m))) continue;
		else count++;
	}
	cout << (m <= count ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import sys
from itertools import accumulate
N,*L = map(int, open(0).read().split())
ls = [0]*N
ml = -1
nr = -1
li = -1
mr = 10**9
nl = -1
ri = -1
for i,(a,b) in enumerate(zip(*[iter(L)]*2)):
  ls[i] = a,b
  if ml<a:
    ml = a
    nr = b
    li = i
  if b<mr:
    mr = b
    nl = a
    ri = i

if ri!=li:
  a,b = min(li,ri),max(li,ri)
  ls.pop(b)
  ls.pop(a)
  N -= 2
else:
  ls.pop(li)
  N -= 1
if N==0:
  ans = max(mr-nl+1,0)+max(nr-ml+1,0)
  print(ans)
  sys.exit()
ls.sort()
length = max(c[1]-c[0]+1 for c in ls)
ans = max(mr-ml+1,0)+length
r = list(accumulate((c[1] for c in ls[::-1]), min))[::-1]
l = list(c[0] for c in ls)
ans = max(ans, max(mr-nl+1,0)+max(r[0]-ml+1,0))
for i in range(N-1):
  xl = max(nl,l[i])
  xr = min(nr,r[i+1])
  ans = max(ans, max(mr-xl+1,0)+max(xr-ml+1,0))
xl = max(nl,l[N-1])
ans = max(ans, max(mr-xl+1,0)+nr-ml+1)
print(ans)

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

int main(void){
    long long int n,sum = 0;
    cin >> n;
    for(long long int i = n;i > 0;i /= 10)sum += i % 10; 
    if(n % sum == 0)cout << "Yes" << endl;
    else cout << "No"<< endl;
}

Measured memory_bytes: 256
a, b, c, x = map(int, [input() for _ in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

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

int h, w;
char c[101][101];

int dijkstra()
{
  pqg<pair<int,pii>> que;
  que.em(0, mp(0, 0));

  int dis[101][101];
  rep(i, 101) rep(j, 101) dis[i][j] = inf;
  dis[0][0] = 0;

  while (!que.empty()) {
    auto p = que.top(); que.pop();
    int x = p.se.fi, y = p.se.se, d = p.fi;

    if (dis[y][x] < d) continue;

    rep(i, 2) {
      int nx = x + dx[i], ny = y + dy[i];
      if (nx < 0 || ny < 0 || nx >= w || ny >= h) continue;

      int nd = d + (c[y][x] == '.' && c[ny][nx] == '#');
      if (dis[ny][nx] > nd) {
        dis[ny][nx] = nd;
        que.em(nd, mp(nx, ny));
      }
    }
  }

  int ret = dis[h-1][w-1];
  if (c[0][0] == '#') ++ret;

  return ret;
}

signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  cin >> h >> w;
  rep(i, h) rep(j, w) cin >> c[i][j];

  cout << dijkstra() << endl;
}


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

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

    string x, y;
    while (n--)
    {
        cin >> x >> y;
        int c[x.size() + 1][y.size() + 1];
        for (int i = 0; i <= x.size(); i++)
            c[i][0] = 0;
        for (int i = 0; i <= y.size(); i++)
            c[0][i] = 0;

        for (int i = 1; i <= x.size(); i++)
        {
            for (int j = 1; j <= y.size(); j++)
            {
                if (x[i - 1] == y[j - 1])
                    c[i][j] = c[i - 1][j - 1] + 1;
                else
                    c[i][j] = max(c[i - 1][j], c[i][j - 1]);
            }
        }
        cout << c[x.size()][y.size()] << endl;
    }
}


Measured memory_bytes: 7068
import sys
# from math import sqrt, gcd, ceil, log
# from bisect import bisect
from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	n = int(input()); arr = read()
	ans= 0
	for i in range(n):
		for j in range(i+1, n):
			ans += arr[i]*arr[j]
	print(ans)


		

if __name__ == "__main__":
	solve()

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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

int K;
ll C[2222][2222];
ll pw[2222];
ll f[2222][2222];
ll sum[2222][2222];

void solve(int casi){
	cin>>n>>K;
	C[0][0] = C[1][0] = C[1][1] = 1;
	for(int i = 2; i <= 2000; i++){
		C[i][0] = C[i][i] = 1;
		for(int j = 1; j < i; j++)
			C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MM;
	}
	pw[0] = 1;
	for(int i = 1; i <= 2000; i++){
		pw[i] = (2 * pw[i-1]) % MM;
	}
	ll ans = 0;//pw[n-K-1];
	f[0][0] = 1;
	for(int i = 0; i <= n; i++)
		sum[0][i] = 1;
	for(int i = 1; i < K; i++){
		for(int j = 0; j <= n - i; j++){
			f[i][j] = sum[i-1][j+1];
		}
		sum[i][0] = f[i][0];
		for(int j = 1; j <= n - i; j++)
			sum[i][j] = (sum[i][j-1] + f[i][j]) % MM;
	}
	for(int i = 0; i <= n - K; i++)
		ans = (ans + f[K-1][i]) % MM;
	cout<<((K!=n)?(ans * pw[n-K-1] % MM):ans)<<endl;
}

void printans(){
	/*?????????*/
}


int main(){
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}
// ??????????



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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    // dp state is dp[i][j] = min cost to combine interval from i -> j
    // common idea to do with dp on interval is to start with smaller intervals
    // base case is that combining intervals of length 1 => 0
    // otherwise, to combine interval of [left, right], we look for "partition" points for the interval
    // and combine them, and actually the cost is equivalent to the cost of combining before the partition + after + the whole interval

    int n;
    cin >> n;

    vll sum(n + 2);
    rep(i,0,n) {
        cin >> sum[i];
    }
    rep(i,0,n) sum[i+1] += sum[i];

    vector<vll> dp(n + 1, vll(n + 1, 1LL << 60));

    for(int i = n - 1; i >= 0; i--) { // left point of interval
        for(int j = i; j < n; j++) { // right point of interval
            if(i == j) {
                dp[i][j] = 0;
            } else {
                ll x = sum[j] - (i == 0 ? 0 : sum[i - 1]); // sum of the interval is the cost to combine two subintervals
                for(int k = i; k < j; k++) { // we look for the optimal partition point
                    dp[i][j] = min(dp[i][j], x + dp[i][k] + dp[k + 1][j]);
                }
            }
        }
    }
    cout << dp[0][n-1] << endl;

    return 0;
}


Measured memory_bytes: 1536
A, = [s.split() for s in open(0)]
if len(A) == 0:
    A = [""]
else:
    A = A[0]
acgt = []
for i in range(len(A)):
    for j in range(len(A), 0, -1):
        sub_string = A[i:j]
        for s in sub_string:
            if s not in ["A", "C", "G", "T"]:
                break 
        else:
            acgt.append(sub_string)
if len(acgt) == 0:
    print(0)
else:
    print(max([len(s) for s in acgt]))

Measured memory_bytes: 3064
#include<iostream>
#include<stack>
#include<vector>
#define reep(a,s,d) for(int a=d;a<s;a++)
#define rep(a,s) reep(a,s,0)
using namespace std;
stack<int> B;
stack<int> W;
int main(){
    int n;
    while(cin>>n,n){
        int w=0,b=0;
        reep(i,n+1,1){
            bool c;
            cin>>c;
            if(c){
                if(i%2){
                    if(b>0)b++;
                    else{
                        W.push(w);
                        w=0;
                        b++;
                    }
                }else{
                    if(b>0)b++;
                    else{
                        b=w+1;
                        if(!B.empty()){
                            b+=B.top();
                            B.pop();
                        }
                        w=0;
                    }
                }
            }else{
                if(i%2){
                    if(w>0)w++;
                    else{
                        B.push(b);
                        b=0;
                        w++;
                    }
                }else{
                    if(w>0)w++;
                    else{
                        w=b+1;
                        if(!W.empty()){
                            w+=W.top();
                            W.pop();
                        }
                        b=0;
                    }
                }
            }
        }
        while(!W.empty()){
            w+=W.top();W.pop();
        }
        cout<<w<<endl;
        while(!B.empty())B.pop();
    }
}

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

using ll = long long;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, ll> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        m[a[i]]++;
    }
    ll base = 0;
    map<int, ll> diff;
    for (auto e: m) {
        ll s = e.second;
        if (s >= 2) {
            base += s * (s - 1) / 2;
        }
        if (s <= 1) {
            diff[e.first] = 0;
        } else {
            diff[e.first] = (ll)s - 1;
        }
    }
    for (auto aa: a) {
        cout << base - diff[aa] << endl;
    }
    return 0;
}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m, a[(1LL << 20)], dp[(1LL << 20)][2], ans[(1LL << 20)];

void setv(ll x, ll at){
	if(a[at] > a[dp[x][0]]){
		dp[x][1] = dp[x][0];
		dp[x][0] = at;
	}
	else{
		if(at != dp[x][0] && a[at] > a[dp[x][1]]){
			dp[x][1] = at;
		}
	}
}

void setp(ll x, ll u){
	setv(x, dp[u][0]);
	setv(x, dp[u][1]);
}

ll aa(ll x){
	return a[dp[x][0]]+a[dp[x][1]];
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	m = (1LL << n);
	zep(i, 0, m){cin >> a[i];}
	a[m] = -INF;
	zep(i, 0, m){
		dp[i][0] = i;
		dp[i][1] = m;
	}
	ans[0] = -INF;
	
	zep(i, 0, m){
		zep(j, 0, 20){
			if(i & (1LL << j)){
				setp(i, (i & ~(1LL << j)));
			}
		}
	}
	
	zep(i, 1, m){
		ans[i] = max(ans[i-1], aa(i));
		print(ans[i])
	}
	return 0;
}

Measured memory_bytes: 17408
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
const int N=105;
int a,b,f[N][N],d[N][N],s[N][N];
int main()
{
    scanf("%d%d",&a,&b);
    for(int x=1;x<=a;x++)
        for(int y=1;y<=b;y++)
        scanf("%d",&d[x][y]);
    for(int i=1;i<=101;i++)
        for(int j=1;j<=101;j++)
        for(int x=1;x<=a;x++)
        for(int y=1;y<=b;y++)
        f[i][j]=max(f[i][j],d[x][y]-(i-1)*x-(101-j)*y);
    memset(s,inf,sizeof(s));
    for(int i=1;i<=101;i++)
        for(int j=1;j<=101;j++)
            for(int x=1;x<=a;x++)
            for(int y=1;y<=b;y++)
            s[x][y]=min(s[x][y],f[i][j]+(i-1)*x+(101-j)*y);
    for(int x=1;x<=a;x++)
        for(int y=1;y<=b;y++)
        if(d[x][y]!=s[x][y])
    {
        printf("Impossible\n");
        return 0;
    }
    printf("Possible\n");
    printf("202 %d\n",100+100+101*101);
    for(int i=1;i<101;i++)
        printf("%d %d X\n",i,i+1);
    for(int i=1;i<101;i++)
        printf("%d %d Y\n",101+i,101+i+1);
    for(int i=1;i<=101;i++)
        for(int j=1;j<=101;j++)
        printf("%d %d %d\n",i,j+101,f[i][j]);
    printf("%d %d\n",1,202);
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
    int x1,x2,y1,y2;
    cin>>x1>>y1>>x2>>y2;
    int x=x2-x1,y=y2-y1;
    cout<<x2-y<<" "<<y2+x<<" "<<x1-y<<" "<<y1+x<<endl;    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	while(cin>>n,n){
		string s;
		int ans=0;
		bool pre=false,r=false,l=false;
		rep(i,n){
			cin>>s;
			if(s=="lu")l=true;
			if(s=="ru")r=true;
			if(s=="ld")l=false;
			if(s=="rd")r=false;
			if(pre==false && r==true && l==true){
				ans++;
				pre=true;
			}
			if(pre==true && r==false && l==false){
				ans++;
				pre=false;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n, cur, p[N], aa[N], bb[N], w[N], at[N], lab[N], num[N];
vector <int> g[N];
long long siz[N], fath[N];
long long find (int a);
void uni (int a, int b);
pair <int, pair<int, int> > edge[N];
void dfs (int a, int b, long long c);
int main() {
	int a, b;
	cin >> a >> b;
	n = a;
	for (int i = 0; i < a; i ++)
		cin >> p[i];
	for (int i = 0; i < b; i ++) {
		cin >> aa[i] >> bb[i] >> w[i];
		aa[i] --;
		bb[i] --;
		edge[i] = make_pair (w[i], make_pair(aa[i], bb[i]));
	}
	sort (edge, edge + b);
	for (int i = 0; i < a; i ++)
		fath[i] = -p[i];
	for (int i = 0; i < a; i ++)
		at[i] = i;
	int sz = a;
	for (int i = 0; i < a; i ++)
		siz[i] = p[i];
	for (int i = 0; i < b; i ++) {
		if (find(edge[i].second.first) == find(edge[i].second.second))
			continue;
		int lf = find (edge[i].second.first);
		int rt = find (edge[i].second.second);
		g[sz].push_back(at[lf]);
		g[sz].push_back(at[rt]);
		uni (lf, rt);
		at[lf] = sz;
		siz[sz] = -fath[lf];
		if (-fath[lf] >= edge[i].first) {
			lab[sz] = 1;
		}
		sz ++;
	}
	dfs (sz - 1, -1, -1);
	int ret = b;
	for (int i = 0; i < b; i ++) {
		if (num[aa[i]] == num[bb[i]] && w[i] <= siz[aa[i]])
			ret --;
	}
	cout << ret;
	return 0;
}
long long find (int a) {
	if (fath[a] < 0)
		return a;
	return fath[a] = find(fath[a]);
}
void uni (int a, int b) {
	a = find(a);
	b = find(b);
	if (a == b)
		return ;
	fath[a] += fath[b];
	fath[b] = a;
	return ;
}
void dfs (int a, int b, long long c){
	if (a < n) {
		num[a] = b;
		if (c != -1)
			siz[a] = c;
	}
	if (b == -1 && lab[a]) {
		b = a;
		c = siz[a];
	}
	for (int i = 0; i < g[a].size(); i ++) {
		dfs (g[a][i], b, c);
	}
}

Measured memory_bytes: 29824
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();

		int taroP = 0;
		int hanaP = 0;
		for (int i = 0; i < n; i++) {
			String taro = sc.next();
			String hana = sc.next();
			int result = taro.compareTo(hana);
			if (result < 0) {
				hanaP += 3;
			} else if (result > 0) {
				taroP += 3;
			} else {
				taroP++;
				hanaP++;
			}
		}
		System.out.println(taroP + " " + hanaP);
		
		sc.close();
	}
}

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




int main()
{
	std::string n;

	std::cin >> n;

	std::string nn = n;

	std::reverse(n.begin(), n.end());

	if (n == nn) {
		std::cout << "Yes" << std::endl;
	} else {
		std::cout << "No" << std::endl;
	}
	


	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/arc083/tasks/arc083_b

package main

import "fmt"
import "bufio"
import "os"
import "strconv"

func main() {
	var N int
	fmt.Scanf("%d", &N)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	var A = make([][]int, N)

	sum := 0
	for i := 0; i < N; i++ {
		A[i] = make([]int, N)

		for j := 0; j < N; j++ {
			sc.Scan()
			a, _ := strconv.Atoi(sc.Text())
			A[i][j] = a
			sum += a
		}
	}

	dupes := 0
	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			if i == k || A[i][k] == 0 {
				continue
			}
			for j := i + 1; j < N; j++ {
				if k == j || A[k][j] == 0 {
					continue
				}
				if A[i][j] > A[i][k]+A[k][j] {
					fmt.Println(-1)
					return
				} else if A[i][j] == A[i][k]+A[k][j] {
					dupes += A[i][j]
					A[i][j] = 0
					A[j][i] = 0
				}
			}
		}
	}

	fmt.Println((sum/2 - dupes))
}


Measured memory_bytes: 2816
parseInt(x) = parse(Int, x)
parseFloat(x) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function dfs(s,n)
    if s!="" && parseInt(s)>n
        return 0
    end
    s_i=join(sort(collect(Set(s))))
    if s_i=="357"
        res=1
    else
        res=0
    end
    for i in "357"
        res+=dfs(join([s,i]),n)
    end
    return res
end

function main()
    println(dfs("",parseInt(readline())))
end
main()

Measured memory_bytes: 155828
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int K = s.nextInt();
		int S = s.nextInt();
		
		int count = 0;
		for(int i = 0; i < K + 1; i++) {
			if(i > S)
				break;
			for(int j = 0; j < K + 1; j++) {
				if(0 <= S - i - j && S - i - j <= K)
					count++;
			}
		}
		
		System.out.println(count);
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip> 
#include <cstring>
#include <queue>
#include <stack> 
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
ll n,k;
ll res;
const ll mod = 1e9+7;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	ll t = k * n - (k - 2 + (k - 1) * (k - 1));
	ll a = k;
	for(int i = k;i <= n + 1;i++){
		res = (res +  t) % mod;
		a++;
		t = (a * n - (a - 2 + (a - 1) * (a - 1))) % mod;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3160
s = input()

first = int(s[:2])
second = int(s[2:])

if first == 0 and second == 0:
    print("NA")
else:
    if first > 12 and second <= 12 and second != 0:
        print("YYMM")
    elif first <= 12 and second <= 12:
        if first != 0 and second == 0:
            print("MMYY")
        elif second !=0 and first == 0:
            print("YYMM")
        else:
            print("AMBIGUOUS")
    elif first <= 12:
        print("MMYY")
    else:
        print("NA")


Measured memory_bytes: 3064
n, m = map(int, input().split())
l = [tuple(map(int, input().split())) for _ in range(n)]
l.sort()
tot = 0
i = 0
while m > 0:
    c = min(l[i][1], m)
    m -= c
    tot += l[i][0] * c
    i += 1
print(tot)

Measured memory_bytes: 16988
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	h := scanInt()
	w := scanInt()

	mi := 1 << 63 -1
	for i := 1; i < h; i++ {
		val := max(i*w,max((w+1)/2*(h-i),w/2*(h-i)))
		val -= min(i*w,min((w+1)/2*(h-i),w/2*(h-i)))
		mi = min(mi, val)
		val = max(i*w,max((h-i+1)/2*w,(h-i)/2*w))
		val -= min(i*w,min((h-i+1)/2*w,(h-i)/2*w))
		mi = min(mi, val)
	}

	for i := 1; i < w; i++ {
		val := max(i*h,max((h+1)/2*(w-i),h/2*(w-i)))
		val -= min(i*h,min((h+1)/2*(w-i),h/2*(w-i)))
		mi = min(mi, val)
		val = max(i*h,max((w-i+1)/2*h,(w-i)/2*h))
		val -= min(i*h,min((w-i+1)/2*h,(w-i)/2*h))
		mi = min(mi, val)
	}

	fmt.Println(mi)
}

Measured memory_bytes: 640
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, X, Y) = read!(usize, usize, usize);
    let (X, Y) = (X - 1, Y - 1);

    let mut G = vec![vec![]; N];
    for i in 0..N - 1 {
        G[i].push(i + 1);
        G[i + 1].push(i);
    }

    G[X].push(Y);
    G[Y].push(X);

    let mut q = VecDeque::new();
    let mut dist = vec![];
    let mut ans = vec![0; N];

    for s in 0..N {
        dist.clear();
        dist.resize(N, N);

        // BFS
        q.push_back((s, 0));
        dist[s] = 0;

        while let Some((u, d)) = q.pop_front() {
            let d = d + 1;

            for i in 0..G[u].len() {
                let v = G[u][i];

                if dist[v] > d {
                    dist[v] = d;
                    q.push_back((v, d));
                }
            }
        }

        for t in s + 1..N {
            // s-t 間の最短経路が k=dist[t] であるペアを1つ見つけた。
            ans[dist[t]] += 1;
        }
    }

    for k in 1..N {
        println!("{}", ans[k]);
    }
}


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

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

const int mod = 1000000007;
const int inf = 1000000007;

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


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

int main(){
	int A, a = 0;
	cin >> A;
	for(int i = 0; i < 3; i++){
		if(A % 2 != 0){
			a++;
		}
		A >>= 1;
	}
	cout << a << endl;
}


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

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const int inf = 1e9 + 7;
const int N = 3005;
const double esp = 1e-12;

typedef long long ll;

int a, b, c, d, e, f, a1, a2, u[N][N];
double res;

void dfs(int x, int y)
{
      u[x][y] = 1;
      if(x + a * 100 + y <= f && !u[x + a * 100][y])
            dfs(x + a * 100, y);
      if(x + b * 100 + y <= f && !u[x + b * 100][y])
            dfs(x + b * 100, y);
      if(x + y + c <= f &&  e * (x / 100) >= y + c && !u[x][y + c])
            dfs(x, y + c);
      if(x + y + d <= f && e * (x / 100) >= y + d &&!u[x][y + d])
            dfs(x, y + d);
}

int main()
{
      cin >> a >> b >> c >> d >> e >> f;

      dfs(0, 0);

      for(int i = 0; i <= 3000; i += 100)
      {
            for(int j = 0; j <= 3000; j ++)
            {
                  double x = i, y = j;
                  if(u[i][j] && (x + y) / x - res > esp)
                  {
                        res = (x + y) / x;
                        a1 = i, a2 = j;
                  }
            }
      }

      cout << a1 + a2 << " " << a2 << endl;
}



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

vector<pair<int,int> > v[6005];
map<string,int> mp;
int mpn;
bool c[6005];
unsigned dis[6005][2005],ans;
char a[20];
queue<pair<int,int> > q;

inline int s2i(string x)
{
    if(!mp.count(x))
        return mp[x]=mpn++;
    return mp[x];
}

int main()
{
    int n,m,k,st,ed,i,j,x,y,w,ww,kk;
    while(~scanf("%d%d%d",&n,&m,&k)&&(n+m+k))
    {
        memset(c,0,sizeof(c));
        memset(dis,-1,sizeof(dis));
        mpn=0;k*=10;
        scanf("%s",a);st=s2i(a);
        scanf("%s",a);ed=s2i(a);
        for(i=0;i<n;i++)
        {
            scanf("%s",a);x=s2i(a);
            scanf("%s",a);y=s2i(a);
            scanf("%d",&w);
            v[x].push_back(make_pair(y,w));
            v[y].push_back(make_pair(x,w));
        }
        for(i=0;i<m;i++)
        {
            scanf("%s",a);
            c[s2i(a)]=1;
        }
        dis[st][k]=0,ans=-1;
        q.push(make_pair(st,k));
        while(!q.empty())
        {
            x=q.front().first;
            w=q.front().second;
            kk=dis[x][w];
            q.pop();
            for(i=0,j=v[x].size();i<j;i++)
            {
                y=v[x][i].first;ww=w;
                if(ww<v[x][i].second)
                    continue;
                ww-=v[x][i].second;
                if(c[y])
                    ww=k;
                if((unsigned)kk+v[x][i].second<dis[y][ww])
                {
                    dis[y][ww]=kk+v[x][i].second;
                    q.push(make_pair(y,ww));
                    if(y==ed)
                        ans=min(ans,dis[y][ww]);
                }
            }
        }
        printf("%d\n",ans);
        for(i=0;i<mpn;i++)
            v[i].clear();
        mp.clear();
    }
	return 0;
}

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

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

using namespace std;

int main(){
	int x; cin>>x;
	int t;
	for(t=0;t*(t+1)/2<x;t++);
	cout<<t<<'\n';
	return 0;
}


Measured memory_bytes: 256
using System;

class ITP1_3_C {
    public static void Main() {

        int[,] Input = new int[3000, 2];
        int Count;

        for (Count = 1; Count <= 3000; Count++)
        {
            string[] s = Console.ReadLine().Split(' ');
            int x = int.Parse(s[0]);
            int y = int.Parse(s[1]);

            if (x == 0 && y == 0) break;

            if (x > y) {
                int tmp = x;
                x = y;
                y = tmp;
            }

            Input[Count - 1, 0] = x;
            Input[Count - 1, 1] = y;
        }

        for (int i = 0; i < Count - 1; i++)
        {
            Console.WriteLine("{0} {1}", Input[i, 0], Input[i, 1]);
        }
    }
}

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int N,K;
string S[20];
string dp[(1<<16)][20][6];
bool used[(1<<16)][20][6];
string mt[20][6];
string nstr[20][6][20];
unordered_map<string,P> sc;

void init(){
  for(int i=0;i<N;i++){
    string ns = S[i];
    reverse( ns.begin(), ns.end() );
    string ks = "";
    for(int j=0;j<N;j++)
      if( ns.find( 'A'+j ) == string::npos ) ks += (char)('A'+j);
    
    vector<string> vs;
    do {
      vs.push_back( ks );
    } while( next_permutation( ks.begin(), ks.end() ) );

    for(int j=0;j<(int)vs.size();j++) {
      string xs = ns + vs[j];
      mt[i][j] = xs;    
      sc[ xs ] = P( i, j );
      for(int k=0;k<N;k++){
        int l,m;
        string as="",bs="";
        for(l=0,m=0;l<N;l++)
          if( m < K && S[k][m] == xs[l] ) {
            as += xs[l]; m++;
          } else {
            bs += xs[l];
          }     
        if( m == K ){
          reverse( as.begin(), as.end() );
          nstr[i][j][k] = as + bs;
          //cout << i<<" " <<j << " "<< k << " " << nstr[i][j][k] << endl;
        } else
          nstr[i][j][k] = "";
      }
    }
  }
}


string solve(int st,int pr,int pt){
  string &ret = dp[st][pr][pt];
  if( used[st][pr][pt] ) 
    return ret;  
  used[st][pr][pt] = true;
  ret = "z";
  if( st == (1<<N)-1 ) 
    return ret = "";    

  for(int i=0;i<N;i++){
    if( st & (1<<i) ) continue;
    if( nstr[pr][pt][i] == "" ) continue;
    P np = sc[ nstr[pr][pt][i] ];
    string rs = solve( st | (1<<i), np.first, np.second );
    if( rs == "z" ) continue;
    ret = min( ret, (char)('A'+i) + rs );
  }
  return ret;
}

int main(){
  cin >> N >> K;
  for(int i=0;i<N;i++)
    cin >> S[i];
  init();
  memset( used,0,sizeof( used ) );
  string res = "z";
  for(int i=0;i<N;i++){
    int n = 6;
    if( N-K == 2 ) n=2;
    if( N-K == 1 ) n=1;
    for(int j=0;j<n;j++){ 
      string rs = solve( (1<<i), i, j );
      if( rs == "z" ) continue;
      res = min( res, (char)('A'+i) + rs  );
    }
  }
  cout << res << endl;
}

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

int main() {
    int R;
    cin >>R;
    if(R < 1200) {
        cout << "ABC" << endl;
    } else if( R < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 256
import re
S = input()
y, m, d = map(int, re.sub("/", " ", S).split())
ans = "Heisei"
if y > 2019:
  ans = "TBD"
elif y == 2019:
  if m > 4:
    ans = "TBD"
  elif m == 4:
    if d > 30:
      abs = "TBD"
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+100;
int a[N],b[N]; 
int main()
{
	ios::sync_with_stdio(false);
	int n,m;
    cin>>n;
    for(int i=1;i<=n;i++) 
	{
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	for(int i=1;i<=n;i++)
	{
		if(a[i]==b[n]) cout<<b[n-1]<<endl;
		else cout<<b[n]<<endl; 
	}
    return 0;
}

Measured memory_bytes: 3200
# @author 

import sys

class QFlowers:
    def solve(self):
        n = int(input())
        h = [int(_) for _ in input().split()]
        a = [int(_) for _ in input().split()]

        # h = [(h[i], i) for i in range(n)]
        # h.sort()

        def update(i, x):
            while i < n + 1:
                if x > dp[i]:
                    dp[i] = x
                i += i & -i

        def get(i):
            mx = 0
            while i > 0:
                if dp[i] > mx:
                    mx = dp[i]
                i -= i & -i
            return mx

        dp = [0] * (n + 1)
        for i, he in enumerate(h):
            update(he, get(he - 1) + a[i])

        # print(dp)
        print(max(dp))

solver = QFlowers()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 107856
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int sisuu(int n, int m, int l)
{
  if (m == 0) return 0;
  if ((l * pow(2., (double)m - 1)) >= n) return m - 1;
  return m;
}

int first(int k)
{
  int t = 0;
  int s = 1;
  while (s < k) {
    ++t;
    s *= 2;
  }
  return t;
}
    
int main() 
{
  int n, k;
  cin >> n >> k;
  int a[n];
  a[0] = first(k);
  for (int i = 1; i < n; ++i) {
    a[i] = sisuu(k, a[i-1], i+1);
  }
  
  double p = 0.;
  for (int i = 0; i < n; ++i) {
    p += pow(0.5, (double)a[i]) / n ;
  }
  
  cout << setprecision(9) << p << endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

main()
{
int ai,am,as,ae,bi,bm,bs,be,s,t;
scanf("%d %d %d %d %d %d %d %d",&ai,&am,&as,&ae,&bi,&bm,&bs,&be);
s = ai+am+as+ae;
t = bi+bm+bs+be;
if (s>t)	printf("%d\n",s);
else		printf("%d\n",t);
}

Measured memory_bytes: 1020