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


using namespace std;

using ll   = long long;
using ii   = pair < int , int >;
using i3   = pair < int , ii >;
using li   = pair < ll , int >;
using lii  = pair <  ll,  ii >;
using vi   = vector < int >;
using vl   = vector < ll >;
using vli  = vector < li >;
using vii  = vector < ii >;
using vi3  = vector < i3 >;
using vlii = vector < lii >;

const int N = 15 , M = 1010;
const ll INF = 1e15;
const double eps = 1e-12 , PI = acos(-1);

int n , m;

vi keys[M];
ll cost[M];

ll mem[M][(1 << N)];

ll dp(int i , int mask){
    if(i == m){
            if(mask == (1 << n)-1)return 0ll;
            return INF;
    }

    ll &ret = mem[i][mask];

    if(ret != -1)return ret;

    int mask2 = mask;
    for(int dx : keys[i]){
            mask2 |= (1 << dx);
    }

    return ret = min(dp(i + 1 , mask) , cost[i] + dp(i + 1 , mask2));
}

void solve(int cs){

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

    for(int i = 0 ; i < m ; i ++){
            int b;
            scanf("%lld %d" , &cost[i] , &b);

            for(int j = 0 ; j < b ; j ++){
                int x;
                scanf("%d" , &x);
                keys[i].push_back(x-1);
            }
    }

    memset(mem , -1 , sizeof mem);
    ll ans = dp(0 , 0);

    if(ans >= INF){
            printf("-1\n");
    }
    else {
            printf("%lld\n" , ans);
    }
}

main(){
    int t = 1;
    //scanf("%d" , &t);

    for(int cs = 1 ; t -- ; cs ++){
        solve(cs);
    }

    return 0;
}



Measured memory_bytes: 258944
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define all(v)    ((v.begin()),(v.end()))
#define sz(v)     ((int)(v.size()))
#define forv(i, v) for(int i = 0; i < sz(v); ++i)
#define forn(i,n)   for(int i = 0; i < (int)(n); i++)
using namespace std;

typedef long long       ll;
typedef long double     ld;
typedef vector<int>     vi;
typedef vector<double>  vd;
typedef vector< vi >    vii;
typedef vector< vd >    vdd;
typedef vector<string>  vs;

const int M = 400;
int n, a[M];
ll ps[M + 1], dp[M + 2][M + 2];

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++) {
		ps[i + 1] = ps[i] + a[i];
	}
	for (int i = n - 1; i >= 0; --i) {
		for (int j = i + 2; j <= n; j++) {
			dp[i][j] = LLONG_MAX;
			for (int k = i + 1; k < j; k++) {
				dp[i][j] = min((dp[i][k] + dp[k][j] + ps[j] - ps[i]), dp[i][j]);
			}
		}
	}

	printf("%lld\n", dp[0][n]);
	return 0;
}


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

ll n, x;

int main() {

cin >> n >> x;

ll ans = n;
ll a = n - x;
ll b = x;

if (a < b) swap(a, b);
while (b > 0){
    ans += (2 * (a / b)) * b;
    ll c = a % b;
    a = b;
    b = c;
}

ans -= a;

cout << ans << "\n";

while(true) return 0;

}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
using Graph = vector<vector<int>>;
queue<int> quex,quey;

int main(){
   int n,k,cnt=0,all=0; cin >> n ;
   ll min=INF;
   vector<int> v(n);
   for(int i=0;i<n;i++){
       cin >> v.at(i);
   }
   for(int i=0;i<110;i++){
       
       for(int j=0;j<n;j++){
           all+=(i-v.at(j))*(i-v.at(j));
       }
       if(min>=all) min=all;
       all=0;
   }
   cout << min << endl;
}


Measured memory_bytes: 256
from collections import defaultdict

n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]

d=defaultdict(int)
for x in s:
  d[x]+=1
for y in t:
  d[y]-=1

print(max(0,max(d.values())))

Measured memory_bytes: 9380
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int t[25];
int n,k,s;
int dfs(int hukasa,int now,int used){//深さ、now
	//cout<<now<<endl;
	int ret=0;
	if(hukasa>=n){
	if(now==s&&used==k){ret=1;}
	return ret;
	}
	if(now)ret++;
	int a1=dfs(hukasa+1,now+t[hukasa],used+1);
	int a2=ret=dfs(hukasa+1,now,used);
	//cout<<"ret"<<ret<<endl;
	return a1+a2;
}
int main(){
	for(int i=0;i<25;i++)t[i]=i+1;

	while(true){
	cin>>n>>k>>s;
	if(n==0&&k==0&&s==0)break;
	cout<<dfs(0,0,0)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>

using namespace std;
const int MAX = 2e5+5;

vector<int> G[MAX];
bool visit[MAX];

void dfs(int node, int &cnt) {
    if(visit[node])
        return;
    visit[node] = 1;
    cnt++;
    for(auto v : G[node]) {
        dfs(v, cnt);
    }
}

int main() {
    int N, M; cin >> N >> M;
    for(int i = 0; i < M; i++) {
        int x, y; cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    memset(visit, 0, sizeof(visit));

    int answer = 0, cnt = 0;
    for(int i = 1; i <= N; i++) {
        if(!visit[i]) {
            cnt = 0;
            dfs(i, cnt);
            answer = max(answer, cnt);
        }
    }
    
    cout << answer << "\n";

    return 0;
}

Measured memory_bytes: 20480
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int H = sc.nextInt();
		int W = sc.nextInt();

		long[][] c = new long[10][10];
		long INF = 10000000;
		WF wf = new WF(c, INF);
		for(int i=0; i<10; i++) {
			for(int j=0; j<10; j++) {
				c[i][j] = sc.nextLong();
			}
		}
		long[][] min_c = wf.getAllDis();

		long min_maryoku = 0;
		int[][] A = new int[H][W];
		for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++) {
				A[i][j] = sc.nextInt();

				if(A[i][j] != -1 && A[i][j] != 1) {
					min_maryoku += min_c[A[i][j]][1];
				}
			}
		}

		System.out.println(min_maryoku);

	}

	//ワーシャルフロイド法
	public static class WF{
		long[][] d;
		long INF;

		public WF(long[][] d, long INF) {
			this.d = d;
			this.INF = INF;

			//初期化
			for(int i=0; i<d.length; i++) {
				Arrays.fill(d[i], INF);
			}

			//自分自身との距離を0に設定
			for(int i=0; i<d.length; i++) {
				d[i][i] = 0;
			}
		}

		//全頂点間の最短距離(重みに負の値あり)(ワーシャルフロイド法)(O(V^3))
		public long[][] getAllDis(){

			long[][] new_d = new long[d.length][d.length];
			System.arraycopy(d, 0, new_d, 0, d.length);
			for(int k=0; k<new_d.length; k++) {
				for(int i=0; i<new_d.length; i++) {
					for(int j=0; j<new_d.length; j++) {
						if(new_d[i][k] != INF && new_d[k][j] != INF) {
							new_d[i][j] = Math.min(new_d[i][j], new_d[i][k]+new_d[k][j]);
						}
					}
				}
			}

			return new_d;
		}

		//負の閉路検出(O(V))
		public boolean isNegativeCycle() {
			for(int i=0; i<d.length; i++) {
				if(d[i][i] < 0) {
					return true;
				}
			}

			return false;
		}
	}
}


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

int main()
{
    int c[9];
    for(int i =0; i<9; i++){
        cin >> c[i]; 
    }
    int x1 = c[1] - c[0];
    int x2 = c[2] - c[0];
    int y1 = c[3] - c[0];
    int y2 = c[6] - c[0];
    if(c[4] - c[0] == x1 + y1 && 
       c[5] - c[0] == x2 + y1 &&
       c[7] - c[0] == x1 + y2 && 
       c[8] - c[0] == x2 + y2)
    {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
 
int main(){
    int n;
    cin >> n;
     
	for(int i=1; i<=n; i++) {
		if(i%3==0) {
			cout << " " << i;
			continue;
		}
		int x=i;
		while(x!=0) {
			if(x%10 == 3) {
				cout << " " << i;
				break;
			}
			x/=10;
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3128
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
typedef vector<int> VI;
#define pb push_back
inline char gc() {
	static char now[1<<16], *S, *T;
	if(S == T) {T = (S = now) + fread(now, 1, 1<<16, stdin); if(S == T) return EOF;}
	return *S++;
}
#define gc getchar
inline int read() {
	int x = 0, f = 1; char c = gc();
	while(c < '0' || c > '9') {(c ^ '-') ? 0 : (f = 0); c = gc();}
	while(c >= '0' && c <= '9') {x = (x << 3) + (x << 1) + (c ^ 48); c = gc();}
	return f ? x : ((~x) + 1);
}
#define N 100010
int n, fa[2][N], odd[2][N];

struct adj {int to, nxt;} e[N];
int hd[N], cnt;
inline void addedge(int x, int y) {
	e[++ cnt] = (adj) {y, hd[x]};
	hd[x] = cnt;
}
VI son[N], con[N];
int rt1, rt2, ans[N];
int dfs(int x) {
	son[x].clear();
	int num = 0;
	for (int i = hd[x]; i; i = e[i].nxt) {
		son[x].pb(dfs(e[i].to));
		++ num;
	}
	if (!(num & 1)) son[x].pb(x); else ans[x] = 0;
	for (int i = 0; i + 1 < (int)son[x].size(); i += 2) {
		int u = son[x][i], v = son[x][i + 1];
		con[u].pb(v); con[v].pb(u);
	}
	return (*(son[x].end() - 1));
}
bool vis[N];
void DFS(int x, int v) {
	ans[x] = v; vis[x] = 1;
	for (int i = 0; i < (int)con[x].size(); ++ i) {
		int y = con[x][i];
		if (!vis[y]) DFS(y, (v == 1) ? (-1) : (1));
	}
}
int main() {
	n = read();
	for (int i = 1; i <= n; ++ i) {
		fa[0][i] = read();
		if (fa[0][i] != -1) odd[0][fa[0][i]] ^= 1;
	}
	for (int i = 1; i <= n; ++ i) {
		fa[1][i] = read();
		if (fa[1][i] != -1) odd[1][fa[1][i]] ^= 1;
	}
	for (int i = 1; i <= n; ++ i) {
		if (odd[0][i] ^ odd[1][i]) {
			puts("IMPOSSIBLE");
			return 0;
		}
	}
	puts("POSSIBLE");
	cnt = 1; memset(hd, 0, sizeof(hd));
	for (int i = 1; i <= n; ++ i)
		if (fa[0][i] != -1) addedge(fa[0][i], i); else rt1 = i;
	dfs(rt1);
	cnt = 1; memset(hd, 0, sizeof(hd));
	for (int i = 1; i <= n; ++ i)
		if (fa[1][i] != -1) addedge(fa[1][i], i); else rt2 = i;
	dfs(rt2);
	for (int i = 1; i <= n; ++ i) {
		if (!odd[0][i] && !vis[i]) {
			if (con[i].size()) DFS(i, 1);
			else ans[i] = 1;
		}
	}
	for (int i = 1; i <= n; ++ i) printf("%d ", ans[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 18296
#include<iostream>
#include<cstdlib>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int a,b,d;
	while(cin>>a>>b>>d,a){
		int x0,y0,g=__gcd(__gcd(a,b),d);a/=g,b/=g,d/=g;
		rep(i,a)if((d-b*i)%a==0){
			y0=i,x0=(d-b*i)/a;break;
		}
		int ax,ay,mnxy=1<<20,mnw=1<<20;
		for(int sgn=1;sgn>-2;sgn-=2)for(int x=x0,y=y0;abs(x)<=b+d;){
			if(mnxy>abs(x)+abs(y)||mnxy==abs(x)+abs(y)&&mnw>abs(x)*a+abs(y)*b)
			ax=abs(x),ay=abs(y),mnxy=abs(x)+abs(y),mnw=abs(x)*a+abs(y)*b;
			x+=sgn*b,y-=sgn*a;
		}
		cout<<ax<<" "<<ay<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

// int cans(bool f){
//   if(f) cout << "Yes" << endl;
//   else cout << "No" << endl;
//   return 0;
// }









const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  string s[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string sl;
  cin >> sl;
  rep(i,7) if(sl == s[i]) cout <<7-i<< endl;
  return 0;
}




// int main(){
//   ll X,Y,ans=0;
//   cin >> X >> Y;
//   if((X+Y)%3 == 0){
//     ans = combination((X+Y)/3,(2*X-Y)/3);
//   }
//   else ans = 0;
//   cout << ans << endl;
// }










Measured memory_bytes: 256
H,W = map(int,input().split())
A = [input() for i in range(H)]
X = []
for i in range(H+2):
    if i == 0 or i == H + 1:
        X.append("#"*(W+2))
    else:
        X.append("#" + A[i-1] + "#")
for x in X:
    print(x)

Measured memory_bytes: 3060
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;
typedef long long ll;
int t[17][17];
int dp[64 * 1024];
int main() {
	int n;
	while (cin >> n,n) {
		fill(dp, dp + (1<<n), 1 << 30);
		dp[0] = 0;
		for (int i = 1; i <= n; i++)
			for (int j = 0; j <= n; j++)
				cin >> t[i][j];
		for (int i = 1; i < (1<<n); i++) {
			for (int k = 0; k < 16; k++) {
				int m = -1 & ~(1 << k);
				if ((i&m) == i)continue;
				int s = t[k + 1][0];
				for (int j = 0; j < 16; j++) {
					int m2 = (1 << j);
					if (i&m&m2)s = min(s, t[k + 1][j + 1]);
				}
				dp[i] = min(dp[i], dp[i&m] + s);
			}
		}
		cout << dp[(1 << n) - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3348
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
int H;
int W;
int a;
int i;
int c;

scanf("%d %d",&H,&W);

while(1){
  for(i=1;i<=H;i++){
    for(c=1;c<=W;c++){
      printf("#");}
    printf("\n");}
  scanf("%d %d",&H,&W);
  printf("\n");
  if(H==0 && W==0){
  break;}
}
return 0;
}


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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) (in).begin(),(in).end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
  ll n;
  cin >> n;
  ll now=0;
  int ans=0,cnt=0;
  REP(i,n){
    int a;
    cin >> a;
    if(now<a)cnt=0;
    else cnt++;
    ans = max(ans,cnt);
    now = a;
  }
  cout << max(ans,cnt) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;

template<typename T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template<typename... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

long long GCD(long long a, long long b) {
    return ((b == 0) ? a : GCD(b, a % b));
}

int main() {
	int N; cin >> N;
	V<ll> a(N); REP(i,N) cin >> a[i];
	int M = 400;
	V<ll> b(400,0);
	for(int i = 0; i < N; i += M){
		ll cnt = 0;
		for(int j = i; j < i + M && j < N; ++j){
			cnt = GCD(cnt,a[j]);
		}
		b[i/M] = cnt;
	}
	ll ans = 0;
	for(int i = 0; i < N; ++i){
		ll cnt = 0;
		for(int j = 0; j < M; ++j) if(j != (i/M)) cnt = GCD(cnt,b[j]);
		for(int j = i/M; j < (i/M) + M && j < N; ++j) if(j != i) cnt = GCD(cnt,a[j]); 
		chmax(ans,cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
//2こだけWAなる
#include<math.h>
#include<iostream>
typedef long long ll;
using namespace std;

ll power(int, int);

int main(){
    ll N, plus, ans=0;
    cin >> N;
    if(N%2 != 0){
        cout << 0 << endl;
    }else{
        for(int i=1; i<=(log(N/2)/log(5)); i++){
            plus = N/(2*power(5,i));
            ans += plus;
            /*
            cout << "2*power(5,i) = " << 2*power(5,i) << endl;
            cout << "i = " << i << endl;
            cout << "plus = " << plus << endl;
            cout << "ans = " << ans << endl << endl;
            */
        }
        cout << ans << endl;
    }
}

ll power(int a, int b){
    ll p = 1;
    for(int i=0; i<b ;i++){
        p *= a;
    }
    return p;
}

Measured memory_bytes: 512
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		BigDecimal a = sc.nextBigDecimal();
		BigDecimal b = sc.nextBigDecimal();

		long ans = a.multiply(b).setScale(0, RoundingMode.FLOOR).longValue();
		System.out.println(ans);


	}

}

Measured memory_bytes: 37412
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

void solve(){
	while (true) {
		int n;
		cin >> n;
		if (n == 0) return;
		list<pair<int, int>> inputs;
		inputs.push_back(mp(-1, 2e9));
		REP(i, n) {
			string a;
			cin >> a;
			if (a == "W") {
				auto x = inputs.begin();
				int b, c;
				cin >> b >> c;
				while (c != 0) {
					if ((*x).first == -1) {
						if ((*x).second <= c) {
							(*x).first = b;
							c -= (*x).second;
						}
						else {
							x = inputs.insert(x, mp(b, c));
							x++;
							(*x).second -= c;
							c = 0;
						}
					}
					x++;
				}
			}
			else if (a == "D") {
				auto x = inputs.begin();
				int b;
				cin >> b;
				while (x != inputs.end()) {
					if ((*x).first == b) {
						(*x).first = -1;
					}
					x++;
				}
			}
			else if (a == "R") {
				auto x = inputs.begin();
				int b;
				cin >> b;
				b++;
				while (true) {
					if ((*x).second >= b) {
						cout << (*x).first << endl;
						break;
					}
					b -= (*x).second;
					x++;
				}
			}
		}

		cout << endl;
	}
}

#undef int

int main() {
	init();
	solve();
}


Measured memory_bytes: 3444
#include<iostream>
using namespace std;
int main(){
	int dp[102]={0};
	int N;
	cin>>N;
	for(int i=0;i<N;++i){
		int place;
		cin>>place;
		++dp[place];
	}
	for(int i=100;i>0;--i){
		dp[i]+=dp[i+1];
		if(dp[i]>=i){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3100
N,M = map(int,input().split(' '))
L = []
R = []

for i in range(M):
  l,r = map(int,input().split(' '))
  L.append(l)
  R.append(r)
L.sort()
R.sort()
A = R[0] - L[-1] +1
print(max(A,0))

Measured memory_bytes: 11440
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 998244353//1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000000
#define N 1000001
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int x,y;
   cin>>x>>y;
   for(int i=0;i<=x;i++)
   {
       if(2*i + 4*(x - i) == y)
       {
           cout<<"Yes"<<endl;
           return 0;
       }
   }
   cout<<"No"<<endl;



}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  multiset<int> w;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    w.insert(x);
  }
  int res = 0;
  while (!w.empty()) {
    auto it = w.end();
    --it;
    int x = *it;
    w.erase(it);
    int pw = 1;
    while (pw <= x) pw *= 2;
    if (w.count(pw - x)) {
      ++res;
      w.erase(w.find(pw - x));
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <map>
#include <climits>
#include <iomanip>
#include <cmath>
#include <algorithm>

using namespace std;

#define eb emplace_back
#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define ll long long

const int N = 2e6 + 123;
const int NN = 2e3 + 500;
const int INF = 1e9;

bool check(int x) {
	int res = 0;
	for (int i = 1; i <= sqrt(x); ++ i) {
		if (i * i != x and x % i == 0)
			res += 2;
		if (i * i == x)
			++res;
	}
	return res == 2;
}

int main () {
	cerr << "Ready";
	
	int n;
	cin >> n;
	
	for (int i = n; i <= INF; ++ i)
		if (check(i))
			return cout << i, 0;
	cerr << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>

using namespace std;

#define REP(i,n) for(int (i)=(0);(i)<(n);++i)
#define ll long long
#define INF 100000000

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

	vector<pair<int,int> > p(n);

	REP(i,n){
		cin >> p[i].first >> p[i].second;
	}

	sort(p.begin(),p.end());
	
	pair<int,int> ans=make_pair(INF,INF);

	REP(i,n){
		if(p[i].second <= t){
			ans = p[i];
			break;
		}
	}

	if(ans.first == INF && ans.second == INF)cout << "TLE" << endl;
	else cout << ans.first << endl;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <climits>
#include <ctime>
#include <random>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;
typedef unsigned char byte;

int main() {
    speed;
    int h, a;
    cin >> h >> a;
    cout << h / a + bool(h % a);
}

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




typedef long long ll;
ll N; int M, Q; int A[101010];
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { -1, 0, 1, 0 };
//-----------------------------------------------------------------------------------
int B[1010101][7];
int simulate(int loop) {
    rep(i, 0, M * loop) {
        int y = i / 7;
        int x = i % 7;
        if(!A[i % M]) B[y][x] = 0;
        else B[y][x] = -1;
    }

    rep(i, M * loop, M * loop + 10) {
        int y = i / 7;
        int x = i % 7;
        B[y][x] = -1;
    }

    int cnt = 0;
    rep(i, 0, M * loop) {
        int y = i / 7;
        int x = i % 7;
        if (B[y][x] == 0) {
            cnt++;
            queue<int> que;
            que.push(i);
            while (!que.empty()) {
                int ii = que.front(); que.pop();
                int y = ii / 7;
                int x = ii % 7;
                if (B[y][x] != 0) continue;
                B[y][x] = cnt;
                rep(j, 0, 4) {
                    int yy = y + dy[j];
                    int xx = x + dx[j];
                    if (yy < 0) continue;
                    if (xx < 0 || 7 <= xx) continue;
                    if (B[yy][xx] == 0) {
                        que.push(yy * 7 + xx);
                    }
                }
            }
        }
    }

    return cnt;
}
//-----------------------------------------------------------------------------------
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> M >> Q;
    rep(i, 0, Q) {
        int a; cin >> a; A[a] = 1;
    }

    int loop = 1;
    if (M % 7) loop = 7;
    ll num = simulate(loop);
    
    ll k = N * 7 / (1LL * M * loop);
    if (k == 1) {
        cout << num << endl;
        return 0;
    }

    ll num2 = simulate(loop * 2);
    ll ans = num + (k - 1) * (num2 - num);
    cout << ans << endl;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

ll n;
ll sqn;
int k;

//up 上限
ll func(int place,ll up){
	static int cnt = 0;
	++cnt;
	//cout << cnt << endl;
	if(place==k)return 1;

	if(up*up<=n){
		static vvector<ll> memo(k,vector<ll>(sqn,-1));
		if(memo[place][up]>=0)return memo[place][up];
		ll res = 0;
		if(up>=2){
			res = func(place,up-1);
		}
		res += func(place+1,n/up);
		res %= MOD;
		--cnt;
		return memo[place][up] = res;
	}else{
		ll upr = n / up;
		static vvector<ll> memo(k,vector<ll>(sqn,-1));
		if(memo[place][upr]>=0)return memo[place][upr];
		ll res = 0;
		res += func(place,n/(n/up+1));
		res += (up-n/(n/up+1)) * func(place+1,upr);
		res %= MOD;
		--cnt;
		return memo[place][upr] = res;
	}
}

int main(){
	cin >> n >> k;
	sqn = sqrt(n) + 2;
	for(int i=k-1;i>=0;--i){
		func(i,n);
	}
	cout << func(0,n) << endl;
	return 0;
}


Measured memory_bytes: 55944
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC091A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if (a + b >= c)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>
#include <set>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <iomanip>
#include <list>
#include <limits>

using namespace std;

class cDivedeAndConquer
{
	int mn;
	long long m_count;
	vector<long long> m_va;
	numeric_limits<long long> lll;

	void mSort(vector<long long> &va, int left, int right);
	void merge(vector<long long> &va, int left, int mid, int right);

public:
	cDivedeAndConquer(int n, vector<long long>& va)
		:mn(n), m_count(0)
	{
		m_va = va;
		mSort(m_va, 0, m_va.size());
		cout << m_count << endl;
	}
};

void cDivedeAndConquer::mSort(vector<long long> &va, int left, int right)
{
	if (left + 1 < right)
	{
		int mid = (left + right) / 2;
		mSort(va, left, mid);
		mSort(va, mid, right);
		merge(va, left, mid, right);
	}
}

void cDivedeAndConquer::merge(vector<long long> &va, int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	vector<long long> vL(n1 + 1), vR(n2 + 1);

	for (int i = 0; i < n1; ++i)
	{
		vL[i] = va[left + i];
	}
	for (int i = 0; i < n2; ++i)
	{
		vR[i] = va[mid + i];
	}

	vL[n1] = lll.max();
	vR[n2] = lll.max();

	int i = 0;
	int j = 0;

	for (int k = left; k < right; ++k)
	{
		if (vL.at(i) <= vR.at(j))
		{
			va.at(k) = vL.at(i++);
		}
		else
		{
			va.at(k) = vR.at(j++);
			m_count += (right - left) / 2 - i;
		}
	}
}

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

	int n;
	cin >> n;
	cin.ignore();

	long long a;
	vector<long long> va;
	for (int i = 0; i < n; ++i)
	{
		cin >> a;
		va.push_back(a);
	}

	cDivedeAndConquer cdc(n, va);

	return 0;
}

Measured memory_bytes: 7600
/* Dynamic Programming implementation of LCS problem */
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 
  
/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( char *X, char *Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
  
   /* Following steps build L[m+1][n+1] in bottom up fashion. Note 
      that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
  
   // Following code is used to print LCS 
   int index = L[m][n]; 
  
   // Create a character array to store the lcs string 
   char lcs[index+1]; 
   lcs[index] = '\0'; // Set the terminating character 
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  
   // Print the lcs 
   cout <<lcs<<"\n"; 
} 
  
/* Driver program to test above function */
int main() 
{ 
  char X[3001]; 
  char Y[3001];
  cin>>X;
  cin>>Y; 
  int m = strlen(X); 
  int n = strlen(Y); 
  lcs(X, Y, m, n); 
  return 0; 
} 


Measured memory_bytes: 35456
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

if N == 0:
    if A[0] == 1:
        print(1)
    else:
        print(-1)
    exit(0)

cnt = [0 for _ in range(N + 1)]
cnt[0] = 1
prev = 1
pow_num = 2
for i in range(1, N + 1):
    cnt[i] = min(prev * 2, pow_num)
    if cnt[i] < A[i]:
        print(-1)
        exit(0)
    prev = cnt[i] - A[i]
    pow_num *= 2

ans = 0
sum_num = 0
for i in range(N, -1, -1):
    if (sum_num + 1) // 2 + A[i] > cnt[i]:
        print(-1)
        exit(0)
    sum_num = min(sum_num + A[i], cnt[i])
    ans += sum_num

print(ans)

Measured memory_bytes: 679740
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int a;
  cin >> a;
  REP(i, a/4 + 1){
    int j = a - 4*i;
    if(j%7 == 0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<string> vec(N);
  for(int i = 0; i<N;i++){
    cin >> vec.at(i); 
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      if(vec.at(i).at(j)=='.'){
        int count=0;
        if(i>0&&vec.at(i-1).at(j)=='#'){
          count+=1;
        }
        if(i<(N-1)&&vec.at(i+1).at(j)=='#'){
          count+=1;
        }
        if(j>0&&vec.at(i).at(j-1)=='#'){
          count+=1;
        }
        if(j<M-1&&vec.at(i).at(j+1)=='#'){
          count+=1;
        }
        if(i>0&&j>0&&vec.at(i-1).at(j-1)=='#'){
          count+=1;
        }
        if(i>0&&j<M-1 &&vec.at(i-1).at(j+1)=='#'){
          count+=1;
        }
        if(i<N-1&&j>0&&vec.at(i+1).at(j-1)=='#'){
          count+=1;
        }
        if(i<N-1&&j<M-1 &&vec.at(i+1).at(j+1)=='#'){
          count+=1;
        }
        char s='0'+count;
        vec.at(i).at(j) = s;
      }
    }
  }
  for(int i = 0;i<N;i++){
  cout << vec.at(i) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <stdlib.h>
 using namespace std;
 int main()
 {
   double w,h,x,y;
   cin>>w>>h>>x>>y;
   std::cout<<std::setprecision (9)<<fixed<<(w*h/2)<<' ';
   if(abs((w/2)-x)<1e-8 && abs((h/2)-y)<1e-8)
    cout<<1<<endl;
    else cout<<0<<endl;
     return 0;
 }


Measured memory_bytes: 384
#include<iostream>
#include <stdio.h>

using namespace std;
int n;
int main(){
	scanf("%d",&n);
	int ans;
	if (n >= 1800) {
		ans = 1;
	}
	else if (n >= 1600) {
		ans = 2;
	}
	else if (n >= 1400)
		ans = 3;
	else if (n >= 1200)
		ans = 4;
	else if (n >= 1000)
		ans = 5;
	else if (n >= 800)
		ans = 6;
	else if (n >= 600)
		ans = 7;
	else
	ans = 8;
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3236
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 10000007;
const int inf = 1001001001;



int main(void) {
  string s;
  cin >> s;
  string a = s.substr(0,2);
  string b = s.substr(2,2);
  int p = stoi(a);
  int q = stoi(b);
  if(p>0 && p<13 && q>0 && q<13) cout << "AMBIGUOUS" << endl;
  else if(p>0 && p<13) cout << "MMYY" << endl;
  else if(q>0 && q<13) cout << "YYMM" << endl;
  else cout << "NA" << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi d(n);
    rep(i,n)cin>>d[i];
    int s=0;
    rep(i,n)Rep(j,i+1,n)s+=d[i]*d[j];
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return (ans.x+m)%m;
}
int fact[N];
void calfac(int n ){
fact[0] = 1;
for(int i = 1 ; i <= n+2; i++){
 fact[i] = (((fact[i-1]%mod)*(i%mod))%mod + mod)%mod;
}
 }
int calc(int n , int r){
 if(r > n)return 0;
 if(r == n)return 1;
 int ans = 1;
 ans = ((ans%mod)*(fact[n])%mod + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[n-r] , mod)%mod) + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[r] , mod)%mod) + mod)%mod;
 return (ans+mod)%mod;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
  int a , b , n;
  cin>>a>>b>>n;
  int i = min(b-1 , n);
   //int  i = n;
   while(i%b == 0 && b != 1)i--;
    cout<<(a*i)/b - a*(i/b)<<endl;
   //}

 
}


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

int main() {
  int n,n1,n2,n3,n4;
  cin >> n;
   
  n4 = n / 1000;
  n3 = ((n - (n/1000) * 1000) / 100);
  n2 = ((n - (n/100) * 100) / 10);
  n1 = ((n - (n/10) * 10) / 1);
    
  if ( (n3 == n2) && ((n4 == n2)||(n1 == n2))){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
struct node{
	node* nxt[26];
	int ct;
	int ch;
	int num;
	int ad;
	int dep;
	node* par;
	node():ct(0), ch(0), num(-1), ad(0), dep(0), par(nullptr){
		fill(nxt, nxt+26, nullptr);
	}
};
node* sn[100000];
void add(node* t, string p, int k){
	node* t0=t;
	t0->ct++;
	for(int i=0; i<p.size(); i++){
		if(!t0->nxt[p[i]-'a']){
			t0->nxt[p[i]-'a']=new node();
			t0->nxt[p[i]-'a']->par=t0;
			t0->nxt[p[i]-'a']->dep=t0->dep+1;
			t0->ch++;
		}
		t0=t0->nxt[p[i]-'a'];
		t0->ct++;
	}
	t0->num=k;
	sn[k]=t0;
}
void skip(node* t, node* pr, int c){
	for(int i=0; i<26; i++){
		if(!t->nxt[i]) continue;
		if(t->nxt[i]->ch>1){
			t->nxt[i]->par=pr;
			if(t->num>=0 && t->ch==1) t->nxt[i]->ad=c+1;
          else t->nxt[i]->ad=c;
			skip(t->nxt[i], t->nxt[i], 0);
		}else{
			if(t->num>=0 && t->ch==1){
				t->nxt[i]->par=pr;
				t->nxt[i]->ad=c+1;
				skip(t->nxt[i], pr, c+1);
			}else{
				t->nxt[i]->par=pr;
				t->nxt[i]->ad=c;
				skip(t->nxt[i], pr, c);
			}
		}
	}
}
string s[100000];
void solve(node* t, int k, string p, int& ans){
	ans+=t->ad;
	t=t->par;
	if(!t) return;
	if(t->num>=0) ans++;
	for(int i=0; i<26; i++){
		if(p[i]==s[k][t->dep]) break;
		if(t->nxt[p[i]-'a']) ans+=(t->nxt[p[i]-'a']->ct);
	}
	solve(t, k, p, ans);
}
int main()
{
	int n, q;
	cin>>n;
	node t;
	for(int i=0; i<n; i++){
		cin>>s[i];
		add(&t, s[i], i);
	}
	skip(&t, &t, 0);
	cin>>q;
	for(int i=0; i<q; i++){
		int k; string p;
		cin>>k>>p; k--;
		int ans=1; solve(sn[k], k, p, ans);
		cout<<ans<<endl;
	}
	return 0;
}

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

int main(void){
    int n,m;
    cin >> n >> m;
    vector<int> height(n);
    for(int i=0;i<n;i++) cin >> height[i];
    vector<vector<int>> G(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int count = 0;
    for(int i=0;i<n;i++){
        bool ok = true;
        for(int j=0;j<G[i].size();j++){
            if(height[i]<=height[G[i][j]]) ok = false;
        }
        if(ok) count++;
    }
    cout << count << endl;

}

Measured memory_bytes: 8792
S=input()
k=int(input())
flag=0
if S[0]==S[-1]:
    flag=1

ss=S[0]
seq=[]
count=1

for s in S[1:]:
    if ss==s:
        count+=1
    else:
        seq.append(count)
        count=1
    ss=s
seq.append(count)
    
sousa=0
for i in seq:
    sousa+=i//2
    
sousa=sousa*k
if flag==1:
    if len(seq)==1:
        if seq[0]%2==1:
            sousa+=k//2
    elif seq[0]%2==1 and seq[-1]%2==1:
        sousa+=k-1
        
print(sousa)

Measured memory_bytes: 38384
#include <stdio.h>
#include <math.h>

typedef struct Point{
  double x;
  double y;
}Point1;

void Koch(int,Point1,Point1);

int main(){
  Point1 a,b;
  int n;

  scanf("%d",&n);

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n",a.x,a.y);

  Koch(n,a,b);

  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}

void Koch(int n,Point1 a,Point1 b){
  Point1 s,t,u;
  double rad = M_PI*60.0/180.0;

  if(n==0) return;

  s.x = (2.0*a.x+1.0*b.x)/3.0;
  s.y = (2.0*a.y+1.0*b.y)/3.0;
  t.x = (1.0*a.x+2.0*b.x)/3.0;
  t.y = (1.0*a.y+2.0*b.y)/3.0;
  u.x = (t.x-s.x)*cos(rad)-(t.y-s.y)*sin(rad)+s.x;
  u.y = (t.x-s.x)*sin(rad)+(t.y-s.y)*cos(rad)+s.y;

  Koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  Koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  Koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  Koch(n-1,t,b); 
    
  
}



Measured memory_bytes: 2052
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	char s[1000],t[1000],f[1000];
	scanf("%s %s",s,t);
	for(int i=0;i<n;i++)
	{
		f[2*i]=s[i];
		f[2*i+1]=t[i];
	}
	for(int i=0;i<2*n;i++)
	{
		printf("%c",f[i]);
	}
	printf("\n");
	return 0;
}



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

using namespace std;

int n;
int co[100005];

int main()
{
	cin >> n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin >> x;
		co[x]++;
	}
	int ev=0,dis=0;
	for(int i=1;i<=1e5;i++)
	{

		if(co[i]){dis++;
		ev+=(co[i]-1);}
	}
	if(ev%2) dis--;
	cout << dis << endl;
}

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

int main() {
	ll a, b, c, d; cin >> a >> b >> c >> d;
	ll res = LONG_MIN;
	res = max(res, a * c);
	res = max(res, a * d);
	res = max(res, b * c);
	res = max(res, b * d);
	cout << res << '\n';
    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>

int main(void)
{
	char card[201], tmp[201];
	int m, h, l;
	for (int i = 0; i < 10; i++) {
		scanf("%s", card);
		if (card[0] == '-') {
			break;
		}
		l = strlen(card);
		scanf("%d", &m);
		for (int j = 0; j < m; j++) {
			scanf("%d", &h);
			for (int k = 0; k < l; k++) {
				tmp[k] = card[h];
				if (++h == l) {
					h = 0;
				}
			}
			memcpy(card, tmp, l);
		}
		printf("%s\n", card);
	}
	return 0;
}



Measured memory_bytes: 2124
N = int(input())
S = input()

strMap = {}
for i in range(0,N):
    if S[i] not in strMap.keys():
        strMap[S[i]] = [i]
    else:
        if len(strMap[S[i]]) == 1:
            strMap[S[i]].append(i)
        else:
            strMap[S[i]][1] = i

max = -10

for i in range(len(S)):
    thisSum = 0
    for key in strMap.keys():
        if len(strMap[key]) > 1:
            if strMap[key][0] <= i and i <= strMap[key][1]:
                thisSum += 1
    if thisSum > max:
        max = thisSum

print(max)

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

int main() {
  int N,i,count=-1,t=1;
  cin >> N;
  
  int A[N];
  for(i=0;i<N;i++) cin >> A[i];
  
  while(t==1) {
    for(i=0;i<N;i++) {
      if(A[i]%2 == 0) A[i] /= 2;
      else t = 0;
    }
    count++;
  }
  
  cout << count << endl;
  
  return 0;
}

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

int main(){
    int A,B,C;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);

    int R = C - (A-B);
    if(R > 0){
         printf("%d\n",C - (A -B));
    }else{
        printf("%d\n",0);
    }

   
    
    return 0;
}

Measured memory_bytes: 128