akhauriyash/Code-Regression huggingface dataset:
use proconio::input;
//use itertools::Itertools;

fn main() {
    input!{x: i32, y:  i32};
    let y_ = y - 2 * x;
    let x_ = 4 * x - y;
    println!("{}", if y_ % 2 == 0 && y_ >= 0 && x_ % 2 == 0 && x_ >= 0 { "Yes" } else { "No" })
}

Measured memory_bytes: 2172
N,K,Q = [int(i) for i in input().split(' ')]
pointList = [K-Q for _ in range(N)]

for _ in range(Q):
    answer = int(input())
    pointList[answer-1] += 1
    
for point in pointList:
    if point <= 0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 7852
#include<bits/stdc++.h>
using namespace std;
char a[55][55];
int flag;
int main(){
	int n,h,m=0;
	cin>>n>>h;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=h;j++){
			cin>>a[i][j];
		}		
	}
//	cout<<endl;
/*	for(int i=1;i<=n;i++){
		for(int j=1;j<=h;j++){
			cout<<a[i][j];
		}
		cout<<endl;
		
	}*/
	for(int i=1;i<=n;i++){
		for(int j=1;j<=h;j++){
			m=1;
			if(a[i][j]=='#'){
				m=0;
//				cout<<i<<"  "<<j<<endl;
				if(a[i-1][j]=='#'){
					m++;
					continue;
				} 
				if(a[i+1][j]=='#'){
					m++;
					continue;
				} 
				if(a[i][j-1]=='#') {
					m++;
					continue;
				} 
				if(a[i][j+1]=='#'){
					m++;
					continue;
				} 
			}
			if(m==0){
				flag=1;
//				cout<<i<<j<<endl;
				break;
				
			}
		}		
	}
	if(flag) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	
	return 0;
} 

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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
//#define endl '\n'  
typedef long long ll; 
typedef unsigned long long ull; 
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1e9+7;
const ll inf=1e17+10;
const ll N=2000+50;
ll fact[N];
ll mod_expo(ll a,ll b, ll c)
{
	ll ans=1;
	while(b)
	{
		if(b & (ll)1) ans=(ans*a)%c;
		a=(a*a)%c;
		b=b>>1;
	}
	return ans;
}
ll invese(ll n)
{
	return mod_expo(n,mod-2,mod);
}

ll ncr(ll n, ll k)
{
	if(n<k) return (ll)0;
	ll ans=1;
	ans*=fact[n];
	ans%=mod;
	ans*=invese(fact[k]);
	ans%=mod;
	ans*=invese(fact[n-k]);
	ans%=mod;
	return ans;
}

int main()
{
	boost;
	fact[0]=1;
	for(ll i=1;i<N;i++) fact[i]=(i*fact[i-1])%mod;
	ll n,k;
	cin>>n>>k;
	for(ll i=1;i<=k;i++)
	{
		cout<<((ll)ncr(n-k+1,i)*(ll)ncr(k-1,i-1))%mod<<endl;
	}
  	return 0;
}

Measured memory_bytes: 256
/// In The Name Of God

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

int n;
int a[N], b[N];

vector <int> st;
ll ans;
int get(int l, int r) {
	return upper_bound(all(st), r) - lower_bound(all(st), l);
}
void solve(int k) {
	st.clear();
	int m1 = (1 << k), m2 = m1 << 1;
	for (int i = 1; i <= n; i++) {
		st.pb(a[i] % m2);
	}
	sort(all(st));
	ll cnt = 0;
	for (int i = 1; i <= n; i++) {
		int cur = b[i] % m2;
		cnt += get(m1 - cur, m2 - cur - 1);
		cnt += get(m1 + m2 - cur, m2 << 1);
	}
	if (cnt & 1) ans += m1;
}
int main() {
	#ifdef IOI2018
		freopen ("in.txt", "r", stdin);
	#endif
	Kazakhstan
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < 29; i++) {
		solve(i);
	}
	cout << ans;
	ioi
}


Measured memory_bytes: 2936
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))
N = int(input())
d_list = [int(input()) for k in range(N)]


for n in range(N):
    for p in range(3):
        if d_list[n] == a_list[p]:
            a_list[p] = 555
    for q in range(3):
        if d_list[n] == b_list[q]:
            b_list[q] = 555
    for r in range(3):
        if d_list[n] == c_list[r]:
            c_list[r] = 555

if a_list[0] == a_list[1] == a_list[2] == 555:
    print('Yes')

elif b_list[0] == b_list[1] == b_list[2] == 555:
    print('Yes')

elif c_list[0] == c_list[1] == c_list[2] == 555:
    print('Yes')

elif a_list[0] == b_list[0] == c_list[0] == 555:
        print('Yes')
elif a_list[1] == b_list[1] == c_list[1] == 555:
        print('Yes')
elif a_list[2] == b_list[2] == c_list[2] == 555:
    print('Yes')
elif a_list[0] == b_list[1] == c_list[2] == 555:
    print('Yes')

elif a_list[2] == b_list[1] == c_list[0] == 555:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll d[5555],f[5555];

int main(void){
	int k,q,i,j;
	ll n,x,m,ans;
	cin >> k >> q;
	for(i=0; i<k; ++i){
		cin >> d[i];
	}
	for(i=0; i<q; ++i){
		cin >> n >> x >> m; --n;
		x %= m; ans = n;
		for(j=0; j<k; ++j){
			f[j+1] = f[j]+d[j]%m;
			if(!(d[j]%m)){
				ans -= (n/k+(j<n%k));
			}
		}
		ans -= (x+f[k]*(n/k)+f[n%k])/m;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    string N;
    cin >> N;
    int K;
    cin >> K;

    vector<vector<vector<int>>> dp(N.size(), vector<vector<int>>(2, vector<int>(K+1)));

    int D = N[0] - '0';
    // (0 0 0), (0 1 0), ..., (0 0 K), (0 1 K) <- 2*(K+1) 個の初期条件
    dp[0][0][0] = 0;        // 存在しない
    dp[0][1][0] = 1;        // 0----- のとき
    dp[0][0][1] = 1;        // D----- のとき
    dp[0][1][1] = D - 1;    // A----- (A=1...D-1)のとき
    // これ以降は「０桁目まで決めた時、０でない数字がi(i>1)個ある」という条件なので、存在しない

    for (int i = 1; i < N.size(); i++)
    {
        D = N[i] - '0';
        for (int less = 0; less < 2; less++)
        {
            for (int d = 0; d < (less ? 10 : D + 1); d++)
            {
                for (int k = 0; k < K+1; k++)
                {
                    if (k == K && d != 0) continue;
                    dp[i][((less || d < D) ? 1 : 0)][(d ? k+1 : k)] += dp[i-1][less][k];
                }
            }
        }
    }

    cout << dp[N.size() - 1][0][K] + dp[N.size() - 1][1][K] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	string s;
	cin >> s;

	for (auto i = 0; i < s.length(); ++i)
	{
		if (i % 2 == 0)
		{
			cout << s[i];
		}
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, n, x);
	VEC(int, a, n);

	vector< int > tmp(a);
	int ans = LINF;
	REP(i, n) {
		int sm = 0;
		sm += x * i;
		REP(j, n) {
			tmp[j] = min(tmp[j], a[(j - i + n) % n]);
		}
		/*
		EACH(ti, tmp) {
			debug(ti);
		}
		*/
		REP(j, n) {
			sm += tmp[j];
		}
		
		ans = min(ans, sm);
	}
	OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 256
from math import factorial

def dictnumber(A):
    N=len(A)
    list=[i for i in range(1,N+1)]
    s=0
    for i in range(0,N):
        if i!=N-1:
            s=s+(list.index(A[i]))*factorial(N-i-1)
        else:
            s=s+1
        list.remove(A[i])
    return s

N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))

print(abs(dictnumber(P)-dictnumber(Q)))


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

int main() {
  
  int n;
  int a,b;
  cin >> n;
  cin >> a >> b;
  
  for (int i = a;i<b+1;i++){
    if(i%n==0){
      cout << "OK" << endl;
      break;
    }else if(i == b){
      cout << "NG" << endl;
    }
  }
  
}


Measured memory_bytes: 3624
#include <cstdio>
#include <queue>

static const size_t n_max = 100;

int main() {
  for (;;) {
    size_t n, m;
    std::vector<std::pair<int, size_t>> edges[n_max];
    bool visited[n_max] = {};
    scanf("%zu", &n);
    if (!n)
      break;
    scanf("%zu", &m);
    for (size_t i = 0; i < m; i++) {
      size_t a, b;
      int d;
      scanf("%zu,%zu,%d", &a, &b, &d);
      d = -(d / 100 - 1);
      edges[a].push_back(std::make_pair(d, b));
      edges[b].push_back(std::make_pair(d, a));
    }
    std::priority_queue<std::pair<int, size_t>> pq;
    visited[0] = true;
    for (auto&& p : edges[0])
      pq.push(p);
    int c = 0;
    for (size_t i = 1; i < n;) {
      auto p = pq.top();
      pq.pop();
      auto d = p.first;
      auto a = p.second;
      if (visited[a])
        continue;
      visited[a] = true;
      i++;
      c += d;
      for (auto&& p : edges[a])
        pq.push(p);
    }
    printf("%d\n", -c);
  }
}

Measured memory_bytes: 3004
def add(a, b):
    mod = 1e9+7
    c = a + b
    if c >= mod:
        c -= mod
    return c
def subtract(a, b):
    mod = 1e9+7
    c = a - b
    if c < 0:
        c += mod
    return c

K = input()

D = int(input())

# dp[sum][smaller_already] - no. of ways to have digits sum % D = sum, smaller_already means if it is already less than K

dp = [[0 for _ in range(2)] for _ in range(D)]

str_len = len(K)

dp[0][0] = 1

for where in range(str_len):
    new_dp = [[0 for _ in range(2)] for _ in range(D)]
    for sum_so_far in range(D):
        for smaller_already in [0, 1]:
            for digit in range(10):
                K_digit = ord(K[where]) - ord('0')
                if digit > K_digit and smaller_already == 0:
                    break
                new_sum = (sum_so_far + digit) % D
                new_smaller = 1 if smaller_already == 1 or digit < K_digit else 0
                new_dp[new_sum][new_smaller] = add(new_dp[new_sum][new_smaller], dp[sum_so_far][smaller_already])
    dp = new_dp
                
                
answer = add(dp[0][0], dp[0][1])

answer = int(subtract(answer, 1))

print(answer)


"""
#include <bits/stdc++.h>
using namespace std;

using ll = long long; 

/*
30
4

brute-force -> look one by one -> from 1 to 30 -> if the digit sum is multiple of 4, then add
O(K * log K)


dp[d] - how many ways to get to remainder is d

dp[0] is the ans

dp[d] - how many ways to get to digit_sum as d

*/


int add(int a, int b) {
    const int mod = 1e9+7;
    int c = a + b;
    if (c >= mod) {
        c -= mod;
    }
    return c;
}

int subtract(int a, int b) {
    const int mod = 1e9+7;
    int c = a - b;
    if (c < 0) {
        c += mod;
    }
    return c;
}

int main() {
    const int nax = 10123;
    char K[nax];
    int D;
    scanf("%s", K);
    scanf("%d", &D);
    int len = strlen(K);
    vector<vector<int>> dp(D, vector<int>(2));
    // dp[sum][smaller_already] - no. of ways to choose digits so far
    // such that digits sum % D = sum and smaller_already means if the number
    // is already less than K
    dp[0][0] = 1;
    
    for (int where = 0; where < len; where++) {
        vector<vector<int>> new_dp(D, vector<int>(2));
        for (int sum = 0; sum < D; sum++) {
            for (bool sm_already : {false, true}) {
                for (int digit = 0; digit < 10; digit++) {
                    if (digit > K[where] - '0' && !sm_already) {
                        break;
                    }
                    int new_sum = (sum + digit) % D;
                    bool smaller = sm_already || digit < (K[where] - '0');
                    new_dp[new_sum][smaller] = add(new_dp[new_sum][smaller], dp[sum][sm_already]);
                }
            }
        }
        dp = new_dp;
    }
    
    int answer = add(dp[0][false], dp[0][true]);
    
    answer = subtract(answer, 1);
    
    printf("%d", answer);
    /*
    int ans = 0;
    for (int i = 1; i <= K; i++) {
        if (digit_sum(i) % D == 0) {
            ans += 1;
        }
    }
    printf("%d", ans);
    */
    
}
"""

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

int main()
{
	int n;
	cin >> n;
	priority_queue<double, vector<double>, greater<double>> Q;
	double in;
	for (int i = 0; i < n; ++i)
	{
		cin >> in;
		Q.push(in);
	}
	double l, r;
	while (Q.size() != 1)
	{
		l = Q.top();
		Q.pop();
		r = Q.top();
		Q.pop();
		Q.push((l + r) / 2);
	}
	cout << Q.top() << endl;
	return 0;
}

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

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int  k = 0;
    while(a && b){
        if(k & 1){
            a -= d;
            if(a <= 0){
                puts("No");
                break;
            }
            ++k;
        }
        else{
            c -= b;
            if( c <= 0){
                puts("Yes");
                break;
            }
            ++k;
        }
    }
}


Measured memory_bytes: 3644
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

H,W = map(int, input().split())
s = [None for _ in range(H)]
for i in range(H):
    s[i] = input()

dp = [[0]*(W+1) for _ in range(H+1)]
if s[0][0] == '#':
    dp[1][1] += 1
for i in range(H):
    for j in range(W):
        if (i,j) == (0,0):
            continue
        tmp = []
        if i > 0:
            if s[i][j] == '#' and s[i-1][j] == '.':
                tmp.append(dp[i][j+1]+1)
            else:
                tmp.append(dp[i][j+1])
        if j > 0:
            if s[i][j] == '#' and s[i][j-1] == '.':
                tmp.append(dp[i+1][j]+1)
            else:
                tmp.append(dp[i+1][j])

        dp[i+1][j+1] = min(tmp)
print(dp[H][W])

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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




LL cnt[12][12];

int main()
{
    FAST();

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

    LL i,j,n,x,y,ans=0;
    cin >> n;
    for(i=1;i<=n;i++)
    {
        x=i%10;
        j=i;
        while(j > 0)y=j%10,j/=10;
        ++cnt[x][y];
    }
    for(i=0;i<10;i++)
    {
        for(j=0;j<10;j++)ans+=cnt[i][j]*cnt[j][i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int i, j;
    char turn = 0;
    char idx[3] = { 0 };
    char deck[3][101] = { 0 };
    char ch;

    for (i = 0; i < 3; i++) 
    {
        scanf("%s", deck[i]);
    }
    
    for (;;)
    {
        ch = deck[turn][idx[turn]++];
        if (ch == 0) break;
        turn = ch - 'a';
    }

    printf("%c\n", turn + 'A');
    return 0;
}

Measured memory_bytes: 128
// B - FizzBuzz Sum
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    long long sum = 0;
    for(int i=1; i<=n; i++){
        if(i%15 == 0) continue;
        else if(i%3 == 0) continue;
        else if(i%5 == 0) continue;
        else sum += i;
    }
    cout << sum << endl;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e15
typedef long long ll;

int N;
vector<ll> ans(16,LINF);

vector<vector<ll>> h_dist;
vector<vector<ll>> v_dist;

struct Coord{
    ll x,y,p;
};

void solve(vector<int> h, vector<int> v, int k){
    if(k == N){
        int bp = h.size() + v.size();
        
        if(bp > N) return;
        
        int x_num = 0;
        int y_num = 0;

        for(int hh: h) x_num += (1<<hh);
        for(int vv: v) y_num += (1<<vv);
        ll a = 0;
        REP(i,N){
            a += min(h_dist[x_num][i], v_dist[y_num][i]);
        }
        ans[bp] = min(ans[bp], a);


    }else{
        vector<int>h2(h);
        h2.push_back(k);
        vector<int>v2(v);
        v2.push_back(k);

        solve(h2,v,k+1);
        solve(h,v2,k+1);
        solve(h,v,k+1);

    }
    return;
}

int main() {
    cin >> N;
    vector<Coord> C(N);
    REP(i,N){
        ll x,y,p; cin >> x >> y >> p;
        C[i] = {x,y,p};
    }

    h_dist.assign(1<<N, vector<ll>(N,LINF));//縦のみ
    REP(bit,1<<N){
        vector<ll> s{0};
        REP(i,N){
            if(bit & (1<<i)) s.push_back(C[i].x);
        }
        REP(i,N){
            for(auto x: s){
                h_dist[bit][i] = min(h_dist[bit][i], C[i].p * abs(x-C[i].x));
            }
        }
    }

    v_dist.assign(1<<N, vector<ll>(N,LINF));//横のみ
    REP(bit,1<<N){
        vector<ll> s{0};
        REP(i,N){
            if(bit & (1<<i)) s.push_back(C[i].y);
        }
        REP(i,N){
            for(auto y: s){
                v_dist[bit][i] = min(v_dist[bit][i], C[i].p * abs(y-C[i].y));
            }
        }
    }

    solve({},{},0);

    REP(i,N+1){
        cout << ans[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 13036
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

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

int main() {
    init();

    ll n, k; cin >> n >> k;
    VL a(n); cin >> a;
    ll g = a[0];
    FOR(i, 1, n)g = gcd(g, a[i]);
    if (k % g == 0 && k <= *max_element(all(a)))cout << "POSSIBLE\n";
    else cout << "IMPOSSIBLE\n";
}

Measured memory_bytes: 1024
def main():
    H, W, N = map(int, input().split())
    sr, sc = map(int, input().split())
    S = input()
    T = input()
    f = True
    pL, pR, pU, pD = sc, sc, sr, sr
    for i in range(N):
        if S[i] == "L":
            pL -= 1
        elif S[i] == "R":
            pR += 1
        elif S[i] == "U":
            pU -= 1
        else:
            pD += 1
        if pL <= 0 or W < pR or pU <= 0 or H < pD:
            f = False
        if T[i] == "L":
            if 1 < pR:
                pR -= 1
        elif T[i] == "R":
            if pL < W:
                pL += 1
        elif T[i] == "U":
            if 1 < pD:
                pD -= 1
        else:
            if pU < H:
                pU += 1
    if f:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define SUM(n) ((n)+1)*(n)/2
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7;

using namespace std;
using pii = pair<int,int>;

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

  string s;
  cin >> s;
  lol sum = 0,strs = s.size() - 1;
  rep( bit , (1 << strs) ){

    lol d = 0;
    sum += (s[ strs ] - '0');
    rep(i , strs){
      d += (s[i] - '0');
      if( bit & (1 << i) ){
	sum += d;
	d = 0;
      } else {
	d *= 10;
      }
    }
    sum += d;
  }
  cout << sum << '\n';
  return 0;
}


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

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

} // namespace null_null



namespace null_null {

void main_() {
  i32 A,B;
  std::cin>>A>>B;

  i32 sum=1,ans=0;
  while(sum<B){
    sum+=A-1;
    ans++;
  }

  std::cout<<ans<<std::endl;
}

} // namespace null_null

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  null_null::main_();
  return 0;
}

Measured memory_bytes: 256
def main():
  sheet = []
  for _ in range(3):
    sheet.append(list(input_list()))
  n = int(input())
  numbers = []
  for _ in range(n):
    numbers.append(int(input()))
  
  ans = []
  for i, row in enumerate(sheet):
    a = []
    for j, num in enumerate(row):
      if num in numbers:
        a.append(True)
      else:
        a.append(False)
    ans.append(a)
  
  if ans[0][0] and ans[0][1] and ans[0][2]:
    print('Yes')
    exit()
  if ans[1][0] and ans[1][1] and ans[1][2]:
    print('Yes')
    exit()
  if ans[2][0] and ans[2][1] and ans[2][2]:
    print('Yes')
    exit()
  if ans[0][0] and ans[1][0] and ans[2][0]:
    print('Yes')
    exit()
  if ans[0][1] and ans[1][1] and ans[2][1]:
    print('Yes')
    exit()
  if ans[0][2] and ans[1][2] and ans[2][2]:
    print('Yes')
    exit()
  if ans[0][0] and ans[1][1] and ans[2][2]:
    print('Yes')
    exit()
  if ans[0][2] and ans[1][1] and ans[2][0]:
    print('Yes')
    exit()
  print('No')
  
def input_list():
  return map(int, input().split())

import math
import fractions
main()

Measured memory_bytes: 66156
public class Main {


  private static void solve() {
    int a = ni();
    int b = ni();
    int c = ni();
    
    System.out.println(Math.min(c,  b/a));
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 22356
#include <stdio.h>
#define MAX 99999
int head, tail;
typedef struct {
char name[10];
int time;} MISSION;

MISSION T[MAX];

void enqueue(MISSION x)
{
    T[tail] = x;
    tail = (tail + 1) % MAX;
}

MISSION dequeue()
{
    MISSION x;
    x = T[head];
    head = (head +1) % MAX;
    return x;
}

int main()
{
    int n, q;
    scanf("%d%d", &n, &q);
    for(int i = 0; i< n;i++)
        scanf(" %s %d", &T[i].name,&T[i].time);
    head = 0;
    tail = n;
    int ttime=0;
    while(head != tail)
   {
       MISSION  X = dequeue();
       if (X.time > q)
       {X.time -=q;
       ttime += q;
       enqueue(X);}
       else if(X.time <= q)
       {
           ttime += X.time;
            printf("%s %d\n", X.name, ttime);
       }
   }
    return 0;
}



Measured memory_bytes: 3252
from bisect import bisect_right as br
n,m,v,p=map(int,input().split())
a=sorted(list(map(int,input().split())))
l,r=n,-1
while l-r>1:
    t=(l+r)//2
    s=a[t]+m
    w=a[:]
    k=m*(v-1)
    for i in range(n):
        if i!=t:
            if i<t:
                c=min(k,m)
                k-=c
                w[i]+=c
            else:
                if w[i]>=s:
                    break
                else:
                    c=min(k,s-w[i])
                    k-=c
                    w[i]+=c
        if k==0:
            break
    if k>0:
        for j in range(n-1,-1,-1):
            if j!=t:
                g=min(k,m-w[j]+a[j])
                w[j]+=g
                k-=g
            if k==0:
                break
    w.pop(t)
    w=sorted(w)
    if n-br(w,s)<=p:
        l=t
    else:
        r=t
print(n-l)

Measured memory_bytes: 84760
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;

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

    for (int i = 0; i < s.size(); i++)
    {
        if (s[i]+n > 'Z') {
            s[i] = s[i]+n-'Z'+'A'-1;
        }
        else s[i] += n;
    }
    
    
    cout << s << endl;
    return 0;
}

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

int main (){
	int a,b=0,c;
	cin>>a;
	if(a==7){
	cout<<"Yes";return 0;}
	for(int i=0;i<25;i++){
		b+=4;
		c=b;
		for(int j=0;j<20;j++ ){
			if(c>a){
				break;
			}else if(c==a){
				cout<<"Yes"<<endl;
				return 0;
			}
			c+=7;
		}c=0;
		
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

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

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

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

	ll M = 62;

	vvmint dp(M+1, vmint(3, 0));
	dp[0][0] = 1;

	repn(i, M) {
		ll x = (N >> (M - i)) % 2;
		//cout << x << endl;

		if (x == 0) {
			dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
			dp[i][1] = dp[i - 1][1];
			dp[i][2] = dp[i - 1][1] + dp[i - 1][2] * 3;
		}
		else {
			dp[i][0] = dp[i - 1][0];
			dp[i][1] = dp[i - 1][0] + dp[i - 1][1];
			dp[i][2] = dp[i - 1][1] * 2 + dp[i - 1][2] * 3;
		}

		//cout << i << dp[i][0] << dp[i][1] << dp[i][2] << endl;
	}

	mint ans = dp[M][0] + dp[M][1] + dp[M][2];
	cout << ans << endl;
}

Measured memory_bytes: 3612
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
int a[MAXN], BIT[MAXN];
ll pre[MAXN];
vector<pair<ll,pii>> sweep;

void add(int idx) {
	idx++;
	while (idx < MAXN) {
		BIT[idx]++;
		idx += idx & -idx;
	}
}

int sum(int idx) {
	idx++;
	int ret = 0;
	while (idx > 0) {
		ret += BIT[idx];
		idx -= idx & -idx;
	}
	return ret;
}

int main() {
	int n, k; scanf("%d %d", &n, &k);
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		ni(a[i]);
		a[i] -= k;
		pre[i] = (ll)a[i] + pre[i-1];
		if (pre[i] >= 0) ans++;
		sweep.pb(mp(pre[i],mp(1,i)));
		sweep.pb(mp(pre[i],mp(-1,i)));
	}
	sort(sweep.begin(), sweep.end());
	for (int i = 0; i < sweep.size(); i++)
		if (sweep[i].se.fi == -1)
			add(sweep[i].se.se);
		else
			ans += (ll)sum(sweep[i].se.se-1);
	prl(ans);
	return 0;
}


Measured memory_bytes: 18280
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
string s;
bool check(){
	for(int i = 0;i < s.size();i++){
		if(i & 1){
			if(s[i] == 'R') return 0;
		}
		else{
			if(s[i] == 'L') return 0;
		}
	}
	return 1;
}
void solve(){
	if(check()) cout << "Yes" << endl;
	else cout << "No" << endl;
}
int main(){
//	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s;
	solve();
	return 0;
}
//do smt instead of nothing! never give up!


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

int main(){
    string s;
    int tmp = 0;
    int max = 0;
    cin >> s;
    
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
            tmp += 1;
            if(tmp > max) max = tmp;
        }
        else tmp = 0;
    }

    cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ft first
#define sd second
#define pb push_back
using ll = long long;
const int INF = 1e9+7;
const int EPS = -1e6;
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}
const int maxn = 100000+5;

int N, M;
int org[maxn], d[maxn];

int main(){
    //freopen("input.txt", "r", stdin);
    fastio();


    cin>>N>>M;
    for(int i =0 ; i < M; ++i)
        cin>>org[i];
    sort(org, org+M);
    for(int i = 0; i < M-1; ++i){
        d[i] = org[i+1] - org[i];
    }

    sort(d, d + M-1, greater<int>());
    int ans = 0;
    for(int i = N-1; i < M-1;++i)
        ans += d[i];
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 1024
N, K = map(int, input().split())
p = list(map(int, input().split()))

A = [(p[i]+1)/2 for i in range(N)]

B = [0]
for i in range(N):
  B.append(B[-1]+A[i])

ans = 0
for i in range(K, N+1):
  ans = max(ans, B[i]-B[i-K])

print(ans)

Measured memory_bytes: 25604
#include <stdio.h>
int main(void){
  int n;
  int x;
  int count = 0;

  while(1){
    scanf("%d %d\n",&n,&x);
    if(n == 0 && x == 0){
      break;
    }
    for(int i=1; i<=n; i++){
      for(int j=1; j<=n; j++){
        for(int k=1; k<=n; k++){
          if(i<j && j<k && i+j+k == x){
            count++;
          }
        }
      }
    }

    printf("%d\n",count);
    count = 0;
  }

  return 0;
}


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

int main(){
	string str;
	cin>>str;
	if (str.size()<4){
		cout<<"No"<<endl;
		return 0;
	}
	if (str[0]=='Y'&&str[1]=='A'&&str[2]=='K'&&str[3]=='I')
		cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	long long int a[200001];
	for(int i = 0; i < n; i++){
		cin >> a[i];
		a[i] -= i + 1;
	}
	sort(a, a + n);
	long long int b1 = a[n / 2];
	long long int ans1 = 0;
	for(int i = 0; i < n; i++){
		ans1 += abs(a[i] - b1);
	}
	if(n % 2 == 0){
		long long int b2 = a[n / 2 + 1];
		long long int ans2 = 0;
		for(int i = 0; i < n; i++){
			ans2 += abs(a[i] -b2);
		}
		cout << min(ans1, ans2) << endl;
	} else {
		cout << ans1 << endl;
	}
}

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

int selectionSort(vector<int>& A) {
    int cnt = 0;
    for (auto i = 0; i < A.size() - 1; i++) {
        int mini = i;
        for (auto j = i; j < A.size(); j++) {
            if (A[j] < A[mini]) {
                mini = j;
            }
        }

        if (i != mini) {
            swap(A[i], A[mini]);
            cnt++;
        }
    }
    return cnt;
}

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

    vector<int> ary(n);
    for (int i = 0; i < n; i++) {
        cin >> ary[i];
    }

    int ans = selectionSort(ary);

    for (int i = 0; i < n; i++) {
        cout << (i ? " " : "") << ary[i];
    }
    cout << endl;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1200
/*Author: Gautam*/
 
 
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define MOD 1000000007
#define ull unsigned long long int
#define newline cout<<endl
 
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<int,int>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
void solve()
{
    int n;
    cin>>n;
    int arr[n];
    forn(i,n)cin>>arr[i];
    ll ans=0;
    forn(i,n)
    {
        fora(j,i+1,n-1)
        {
            ans+=arr[i]*arr[j];
        }
    }
    cout<<ans<<endl;
}
int main()
{
 
   
    FastIO;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] ks = new int[m][n];
		for (int i = 0; i < m; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				ks[i][sc.nextInt() - 1] = 1;
			}
		}
		int[] p = new int[m];
		for (int i = 0; i < p.length; i++) {
			p[i] = sc.nextInt();
		}
		int sum = 0;
		for (int i = 0; i < (1 << n); i++) {
			boolean exist = true;
			for (int j2 = 0; j2 < ks.length; j2++) {
				int count = 0;
				for (int k = 0; k < ks[j2].length; k++) {
					if (ks[j2][k] == 1) {
						if ((1 & i >> k) == 1) {
							count++;
						}
					}
				}
				if (count % 2 != p[j2]) {
					exist = false;
					break;
				}
			}
			if (exist) {
				sum++;
			}
		}
		System.out.println(sum);
		sc.close();
	}
}


Measured memory_bytes: 36120
X,Y,A,B,C=map(int,input().split())
R=sorted(list(map(int,input().split())),reverse=True)
G=sorted(list(map(int,input().split())),reverse=True)
RG=sorted(list(map(int,input().split())),reverse=True)


d=R[:X]+G[:Y]+RG
d.sort(reverse=True)
 
print(sum(d[:X+Y]))

Measured memory_bytes: 22720
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
//提出するときC++に帰る
//--------------------------

int main() {

  int n, d;
  cin >> n >> d;

  int res = n/(d*2+1);

  if(n%(d*2+1)!=0) res += 1;

  cout << res << endl;

  return 0;
}


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

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

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{

#if !ONLINE_JUDGE

	freopen("in1.txt", "r", stdin);
	freopen("out1.txt", "w" , stdout);

#endif

	string s1;
	cin >> s1;

	for (int i = 0; i < s1.size(); i++)
	{
		if (s1[i] == ',')
		{
			s1[i] = ' ';
		}
	}

	cout << s1 << endl;



	return 0;
}

Measured memory_bytes: 3628
from collections import Counter

n,k = map(int,input().split())
lst = list(map(int,input().split()))
typ = list(set(lst))

ans = 0
NumList = Counter(lst)
num = sorted(NumList.items(),key=lambda x:x[1])
for l in range(len(typ)-k):
    ans += num[l][1]
print(ans)


Measured memory_bytes: 50088
#include<bits/stdc++.h>
using namespace std;
#define Maxn 100005
int n,x,temp,a[Maxn];
long long ans = 0;
int main(){
	cin >> n >> x;
	for(int i = 1;i <= n;i++)
		cin >> a[i];
	for(int i = 2;i <= n;i++)
		if (a[i] + a[i - 1] > x){
			temp = a[i] + a[i - 1] - x;			
			ans += temp;
			if (a[i] >= temp)
				a[i] -= temp;
			else {
				a[i - 1] = a[i - 1] - (temp - a[i]);
				a[i] = 0;
			}							
		}
	cout << ans << endl;
	return 0;
}
 

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

#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define debug(i) printf("\nDebug %d\n",i);
#define mod 1000000007
#define ll long long int

int main()
{	
	fast();


	long long int x,y;
	cin>>x>>y;
	if(x==1||y==1)
		cout<<1;
	else{
	if(!(x&1)||(!(y&1)))
	cout<<((x*y)/2);
	else
		cout<<((x*y)/2)+1;
}
return 0;
}

Measured memory_bytes: 256
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=(a);i<(b);i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}

int log(int x) {
    int i;
    for(i=0;(1<<i)<=x;i++);
    return i;
}

vector<int> osci(vector<int> v) {
	vector<int> v1;
	int n=v.size();
	int i=0,j=n-1;
	for(int k=0;k<n;k++) {
		if(k%2==0)
			v1.pb(v[i++]);
		else
			v1.pb(v[j--]);
	}
	reverse(all(v1));
	return v1;
} 
 
int32_t main() {
    fio
	cout << fixed << setprecision(15);
    
    int n;cin >> n;
    string s;cin>>s;
    
    int x=0,c=0;
    for(auto i:s) {
        if(i=='I')
        c++;
        else
        c--;
        x=max(x,c);
    }
    x=max(x,c);
    cout << x;
	return 0;
    
}

Measured memory_bytes: 8832