akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

map<int,int> res;
ll n;
ll ans = 1;

void prime_facter(int n){
  for(int i = 2; i*i <= n; i++){
    while(n%i == 0){
      ++res[i];
      n /= i;
    }
  }
  if(n != 1) res[n]++;
}

int main(){
  cin >> n;
  rrep(i, n) prime_facter(i);
  for(auto it = res.begin(); it != res.end(); it++){
    ans *= (it->second + 1);
    ans = ans % DIV;
  }
  cout << ans << endl;
  return 0;
}


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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;


bool ok(long long x, long long N, long long M) {
    if (M % x != 0) {
        return false;
    }
    int a = M / x;
    return a >= N;
}

vector<LL> get_divisor_list(LL n) {
    vector<LL> ret = {n};
    for(int i = 1 ; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i != 1 and i * i != n) {
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

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

	long long N, M;
	cin >> N >> M;

	LL ans = 1;
    FOE(x, get_divisor_list(M)) {
        if (ok(x, N, M)) {
            ans = max(ans, x);
        }
    }

    print(ans);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    ll A,B,N;
    cin >> A >> B >> N;
    if(N<B){
        ll c=A*N;
      	ll e;
      	e=c/B;
       cout << e << endl;
    }else{
        ll c=A*(B-1);
      	ll e;
      	e=c/B;
       cout << e << endl;
    }
    return 0;
}

Measured memory_bytes: 3672
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  string S;
  cin>>S;
  int rnum = 0, wnum = 0;
  for(int i=0;i<N;++i) {
    if(S[i]=='R') rnum++;
    else wnum++;
  }
  int ans = 0;
  for(int i=0;i<rnum;++i) {
    if(S[i]=='W') ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

vector<ll> res = {1, 2, 3, 4, 5, 6, 7, 8, 9};

void dfs(int n, ll num) {
  if (!n) {
    res.push_back(num);
    return;
  }
  int prev = num%10;
  for (int i = -1; i <= 1; i++) {
    if (!prev && i == -1 || prev == 9 && i == 1)
      continue;
    dfs(n-1, num*10+prev+i);
  }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k;
  cin >> k;
  for (int i = 1; i < 63; i++) {
    if (res.size() > k)
      break;
    for (int j = 1; j <= 9; j++)
      dfs(i, j);
  }
  sort(res.begin(), res.end());
  cout << res[k-1] << endl;
  return 0;
}

Measured memory_bytes: 3700
def read_int():
    return int(input().strip())


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


def solve():
    H, W = read_ints()
    table = []
    for _ in range(H):
        table.append(list(input()))
    frontier = []
    whites = H*W
    for i in range(H):
        for j in range(W):
            if table[i][j] == '#':
                frontier.append((i, j))
                whites -= 1
    count = 0
    while whites != 0:
        new_frontier = []
        for i, j in frontier:
            for i0, j0 in [(i-1, j), (i+1, j), (i, j-1), (i, j+1)]:
                if 0 <= i0 < H and 0 <= j0 < W and table[i0][j0] == '.':
                    table[i0][j0] = '#'
                    whites -= 1
                    new_frontier.append((i0, j0))
        frontier = new_frontier
        count += 1
    return count


if __name__ == '__main__':
    print(solve())


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

using namespace std;

typedef long long int ll;

int A[200002], B[200002];

int main(){
    ll N, M, K;
    cin >> N >> M >> K;
    for(ll i=1; i<=N; i++){
        cin >> A[i];
    }
    for(ll j=1; j<=M; j++){
        cin >> B[j];
    }

    vector<ll> sumA_array, sumB_array;
    sumA_array.push_back(0); sumB_array.push_back(0);

    ll sumA = 0, sumB = 0, a, b;
    for(ll i=1; i<=N; i++){
        a = A[i];
        if (a > K) break;
        sumA += a;
        if (sumA > K) break;
        sumA_array.push_back(sumA);
    }
    for(ll j=1; j<=M; j++){
        b = B[j];
        if (b > K) break;
        sumB += b;
        if (sumB > K) break;
        sumB_array.push_back(sumB);
    }


    ll timeA, timeBmax;
    ll max_volume = 0;
    for(ll i=0; i<sumA_array.size(); i++){
        timeA = sumA_array[i];
        timeBmax = K - timeA;
        auto j = upper_bound(sumB_array.begin(), sumB_array.end(), timeBmax);
        max_volume = max(max_volume, i + (j - sumB_array.begin() - 1));
    }
    cout << max_volume << endl;
    return 0;
}

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

ll findNext(ll curr_idx, ll len, vector<ll> pos) {
    ll multiplier = curr_idx / len;
    curr_idx = curr_idx % len;
    ll next_pos = lower_bound(pos.begin(), pos.end(), curr_idx) - pos.begin();
    
    if(next_pos == pos.size())
        return len * (multiplier + 1) + pos[0];
    return len * multiplier + pos[next_pos];
}

bool ifPossible(string s, string t) {
    for(int i = 0; i < 26; ++i) {
        char ch = (char)(i + 'a');
        bool find_s = (s.find(ch) != string :: npos);
        bool find_t = (t.find(ch) != string :: npos);
        
        if(find_s == false && find_t == true)
            return false;
    }
    
    return true;
}

int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    string s, t;
    cin >> s >> t;
    
    if(!ifPossible(s, t)) {
        cout << -1;
        return 0;
    }
    
    vector<ll> pos[26];
    ll s_len = s.length(), t_len = t.length();
    
    for(int i = 0; i < s_len; ++i)
        pos[s[i] - 'a'].push_back(i);
        
    ll start = 0, t_pos = 0;
    while(t_pos < t_len) {
        ll len = s_len, curr_idx = start, multiplier = curr_idx / len;
        curr_idx = curr_idx % len;
        ll next_pos = lower_bound(pos[t[t_pos] - 'a'].begin(), pos[t[t_pos] - 'a'].end(), curr_idx) - pos[t[t_pos] - 'a'].begin();
    
        if(next_pos == pos[t[t_pos] - 'a'].size())
            start = len * (multiplier + 1) + pos[t[t_pos] - 'a'][0] + 1;
        else
            start = len * multiplier + pos[t[t_pos] - 'a'][next_pos] + 1;
        ++t_pos;
    }
    
    cout << start;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<int, pii> piii;
const ll INF = 9876543321987654321;
const int MAXN = 100000;

priority_queue<int> pq;

ll A[MAXN+1];

ll ab(ll p){if(p>=0)return p; return -p;}

int main()
{
    int n,k;
    scanf("%d%d",&n,&k);

    for(int i=0;i<n;i++)scanf("%lld",&A[i]);


    ll mn ;

    for(int i=0;i<=n-k;i++)
    {
        ll nw = A[i+k-1]-A[i];
        ll p = min(ab(A[i+k-1]),ab(A[i]));
        if(!i)mn = nw+p;
        else mn = min(nw+p,mn);
    }
    printf("%lld",mn);

    return 0;
}


Measured memory_bytes: 1024
#include<map>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
typedef long long ll;
using namespace std;

ll const MAX = 505;
bool grid[MAX][MAX];

int main() {
	ll n;
	cin >> n;
	bool flag1 = 1;

	REP(i, 1, n) {
		REP(j, 1, n) {
			char c;
			cin >> c;
			grid[i][j] = (c == '#');
			if (grid[i][j] == 1) {
				flag1 = 0;
			}
		}
	}
	if (flag1) {
		cout << -1 << endl;
		return 0;
	}
	ll tate = 0;
	REP(j, 1, n) {
		bool flag = 1;
		REP(i, 1, n) {
			if (grid[i][j] == 0) {
				flag = 0;
				break;
			}
		}
		if (flag) { tate++; }
	}
	ll max_s = 0;
	REP(i, 1, n) {
		ll cnt = 0;
		REP(j, 1, n) {
			cnt += (grid[i][j] == 1);
		}
		bool flag = 0;
		REP(j, 1, n) {
			if (grid[j][i] == 1) {
				flag = 1;
				break;
			}
		}
		if (flag == 0) {
			cnt--;
		}
		max_s = max(max_s, cnt);
	}
	cout << n - max_s + n - tate << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define sd(x) scanf("%d",&x)
#define sdl(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define pdl(x) printf("%lld\n",x)
#define MAXN 200009
using namespace std;
vector<int> v;
int main()
{
	int n;
	sd(n);
	for(int i=0;i<n;i++)
	{
		int x;
		sd(x);
		v.pb(x);
	}
	sort(v.begin(),v.end());
	int num=v[n-1];
	int minn=1e9+10;
	int ans=-1;
	int req1=(num/2);
	int req2=(num/2);
	if(num%2)
	{
		req2++;
	}
	for(int i=0;i<n-1;i++)
	{
		int val=min(abs(req1-v[i]),abs(req2-v[i]));
		if(minn>val)
		{
			minn=val;
			ans=v[i];
		}
	}
	printf("%d %d\n",v[n-1],ans);
	return 0;
}

Measured memory_bytes: 892
# coding: utf-8
N = int(input())
D = list(map(int, input().split()))
l = [0] * N
top = max(D)
mod = 998244353
for i in range(N):
    l[D[i]] += 1
ans = 1
for i in range(1, top+1):
    if l[i] != 0:
        ans *= l[i-1] ** l[i]
    if l[i] == 0:
        print(0)
        exit()
    ans = ans % mod
if D[0] != 0:
    ans = 0
if l[0] != 1:
    ans = 0
print(ans)

Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);

const ll mod = 1'000'000'007;
const ll mod1= 998244353;
const int N = 5e5, M = N;
//=======================

vi g[N];
int a[N];
int f[1000000];


void solve() {
    string  n;
    ll sum=0;
    cin>>n;
    for(int i=0;i<n.size();i++)
    {
        sum+=n[i]-'0';
    }
    if(sum%9==0) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
}


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
      solve();
    }
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}


void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}


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

using namespace std;

int main() {
	int H, W;
	cin >> H >> W;
	char A;
	int	B[1000][1000];
	int wcnt = 0;
	int wcnt2 = 0;
	int ans = 0;
	int i, j;
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			cin >> A;
			if (A == '#') B[i][j] = 0;
			else B[i][j] = 2000;
		}
	}
	for (i = 0; i< H; i++) {
		wcnt = B[i][0];
		wcnt2 = B[i][W - 1];
		for (j = 0; j < W; j++) {
			if (B[i][j] > wcnt) {
				B[i][j] = wcnt + 1;
			}
			wcnt = B[i][j];
			if (B[i][W - j - 1] > wcnt2) {
				B[i][W - j - 1] = wcnt2 + 1;
			}
			wcnt2 = B[i][W - j - 1];
		}
	}
	for (j = 0; j< W; j++) {
		wcnt = B[0][j];
		wcnt2 = B[H - 1][j];
		for (i = 0; i < H; i++) {
			if (B[i][j] > wcnt) {
				B[i][j] = wcnt + 1;
			}
			wcnt = B[i][j];
			if (B[H - i - 1][j] > wcnt2) {
				B[H - i - 1][j] = wcnt2 + 1;
			}
			wcnt2 = B[H - i - 1][j];
		}
	}
	for (i = 0; i< H; i++) {
		wcnt = B[i][0];
		wcnt2 = B[i][W - 1];
		for (j = 0; j < W; j++) {
			if (B[i][j] > wcnt) {
				B[i][j] = wcnt + 1;
			}
			wcnt = B[i][j];
			if (B[i][W - j - 1] > wcnt2) {
				B[i][W - j - 1] = wcnt2 + 1;
			}
			wcnt2 = B[i][W - j - 1];
		}
	}
	for (j = 0; j< W; j++) {
		wcnt = B[0][j];
		wcnt2 = B[H - 1][j];
		for (i = 0; i < H; i++) {
			if (B[i][j] > wcnt) {
				B[i][j] = wcnt + 1;
			}
			wcnt = B[i][j];
			if (B[H - i - 1][j] > wcnt2) {
				B[H - i - 1][j] = wcnt2 + 1;
			}
			wcnt2 = B[H - i - 1][j];
			if (ans < B[H - i - 1][j]) ans = B[H - i - 1][j];
		}
	}
	cout << ans;
	return 0;
}

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

int main (int argc,char **argv)
{
	int n = 0,i = 0;
	scanf("%d",&n);
	int L = 0;

	int l[n];
	for (i = 0; i < n; i++)
	{
		scanf("%d",&l[i]);
	}

	for (i = 0; i < n; i++)
	{
		L += l[i];
	}

	for (i = 0; i < n; i++)
	{
		if(l[i] > l[i+1])

			l[i+1] = l[i];
	}
	L = L - l[n-1];

	if(L > l[n-1])
		printf("Yes\n");

	else
		printf("No\n");

	return 0;
}

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

int main(){
	int alpha[26];	for(int i=0;i<26;i++)alpha[i]=0;

	string w;	cin>>w;

	for(int i=0;i<w.length();i++){
		alpha[w[i]-'a']++;	
	}

	string ans="Yes";
	for(int i=0;i<26;i++){
		if(alpha[i]%2){
			ans="No";
			break;
		}
	}

	cout<<ans<<endl;

	return 0;
}


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

vector<long long int> divisor(long long int n)
{
  vector<long long int> ret;
  for (long long int i = 1; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main()
{
  long long int N;
  cin >> N;
  vector<long long int> ans = divisor(N);
  long long int ans2 = 0;
  if (ans.size() == 2)
    cout << N - 1 << endl;
  else
  {
    if (ceil(sqrt(N)) != floor(sqrt(N)))
    {
      ans2 = ans[ans.size() / 2 - 1] - 1 + ans[ans.size() / 2] - 1;
    }
    else
    {
      ans2 = ans[ans.size() / 2] - 1 + ans[ans.size() / 2] - 1;
    }
    cout << ans2 << endl;
  }
}


Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)
typedef long long ll;

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);

int main() {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];

    auto max_idx = max_element(a.begin(), a.end());
    //a.erase(remove(a.begin(), a.end(), max_), a.end()); 
    int rtn = (*max_idx)*10;
    a.erase(max_idx);
    for(int i=0; i<a.size(); i++) {
        rtn += a[i];
    }
    cout << rtn << endl;
    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}
//int sum_digits(int num) {
//    int rtn = 0;
//    string num_str = to_string(num);
//    for(int i=0; i<num_str.size(); i++) {
//        rtn += num_str[i] - '0';
//    }   
//    return rtn;
//}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}



Measured memory_bytes: 256
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)

all_points = 0
for i in A:
  all_points += i

for i in range(M):
  if A[i] >= all_points/(4 * M):
    pass
  else:
    print('No')
    break
else:
  print('Yes')
  

Measured memory_bytes: 2940
def main():
    n,k=map(int,input().split())
    a=[int(i)-1 for i in input().split()]
    visit=[False]*n
    visit[0]=True
    loop, loopstart, loopout, cur=0, -1, False, 0
    i = 0
    while i < k:
        #print("{}->{}".format(cur+1, a[cur]+1))
        cur=a[cur]
        if not loopout and visit[cur]:
            #print("OnLoop", k)
            if loopstart == cur:
                k=(k-sum(visit))%loop
                loopout=True
                #print("OutLoop", k)
                i = 0
                continue
            elif loopstart == -1:
                #print("loop start with", cur+1)
                loopstart = cur
            loop+=1
        else:
            visit[cur]=True
        i += 1
    print(cur+1)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 33524
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    long long a[1000000],s[1000000];
    s[0]=0;
    for (int i = 0; i < n; i++)
    {
        /* code */
        cin>>a[i];
    }
    for (int i = 1; i <= n; i++)
    {
        /* code */
        s[i]=s[i-1]+a[i-1];
    }
    long long ans=0,ans2=1000000000000000000LL;
    for (int i = 1; i < n; i++)
    {
        /* code */
        ans=abs(s[i]-(s[n]-s[i]));
        ans2=min(ans,ans2);
    }
    cout<<ans2<<endl;
    
}

Measured memory_bytes: 7424
def main():
    n = int(input())
    A = [int(e) for e in input().split()]

    if A.count(0) > 0:
        print(0)
        exit()

    ans = A[0]
    for i in range(1, n):
        ans *= A[i]
        if ans > 10 ** 18:
            print(-1)
            exit()

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 84804
use std::io::{self, BufRead};

pub fn lower_bound<T: Ord>(vec: &[T], val: T) -> usize {
  let mut lo = 0;
  let mut hi = vec.len();
  while hi - lo > 0 {
    let p = (hi + lo) / 2;
    if vec[p] < val {
      lo = p + 1;
    } else {
      hi = p;
    }
  }
  return lo;
}

pub fn upper_bound<T: Ord>(vec: &[T], val: T) -> usize {
  let mut lo = 0;
  let mut hi = vec.len();
  while hi - lo > 0 {
    let p = (hi + lo) / 2;
    if vec[p] > val {
      hi = p;
    } else {
      lo = p + 1;
    }
  }
  return lo;
}

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let n: usize = lines.next().unwrap().unwrap().parse().unwrap();
  let mut ls: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
  ls.sort();
  let mut count = 0;
  for i in 0..(n-2) {
    for j in (i+1)..(n-1) {
      let x = ls[i];
      let y = ls[j];
      let min = y - x + 1;
      let max = x + y - 1;
      let lo = lower_bound(&ls[(j+1)..], min);
      let hi = upper_bound(&ls[(j+1)..], max);
      count += hi - lo;
    }
  }
  println!("{}", count);
}

Measured memory_bytes: 4476
#include<stdio.h>

int main()
{
    int N;
    scanf("%d", &N);
    int mod = N%1000;
    if(mod==0)
    {
        printf("0\n");
    }
    else
    {
        printf("%d\n", abs(mod-1000));
    }
    return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using namespace std;

int main() {
    long a, b;
    cin >> a >> b;
    if ((a + b) % 2) cout << "IMPOSSIBLE" << '\n';
    else
        cout << (a + b) / 2 << '\n';
    return 0;
}

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

int main(){
	int a, b, c;
	int res=0;

	// input
	cin >> a >> b >> c;	

	for(int i=a; i<=b; i++){
		if ((c % i) == 0) res++;
	}

	cout << res << endl;
	return 0;

}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

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

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

int main() {
    ll N, M, result = 1, MOD = 1000000000 + 7;
    cin >> N >> M;
    REP(i, N) {
        result = result * (i + 1) % MOD;
    }
    REP(i, M) {
        result = result * (i + 1) % MOD;
    }
    if (abs(N - M) > 1) {
        cout << 0 << endl;
    } else {
        if (N == M) {
            result = result * 2 % MOD;
        }
        cout << result << endl;
    }
}


Measured memory_bytes: 256
i;k;t;main(n){
        int c[501],f[500],s[500];
        for(scanf("%d",&n);k<n-1;k++)scanf("%d%d%d",&c[k],&s[k],&f[k]);
        
        for(;i<n-1;i++){
            t=0;
            for(int j=i;j<n-1;j++){
                if(t<=s[j]){
                    t=s[j]+c[j];
                }else{
                    t=s[j]+c[j]+ceil( (double)(t-s[j])/f[j] )*f[j];
                    
                }
            }
            printf("%d\n",t);
        }
        printf("0");
    }

Measured memory_bytes: 1708
/*
 * hoge.cpp
 *
 *  Created on: 2014/09/30
 *      Author: eiichi
 */
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<list>
using namespace std;

vector<int> split(string s,char c){
	vector<int> v;string tmp;
	for(int i=0;i<s.size();i++){
		if(s[i]==c){
			v.push_back(stoi(tmp));
			tmp ="";
		}
		else tmp += s[i];
	}
	if(tmp!="")v.push_back(stoi(tmp));
	return v;
}

int main(void){
	int r,c;
	cin >> r >> c;
	int table[101][101];
	for(int i=0;i<r;i++){
		int sum=0;
		for(int j=0;j<c;j++){
			cin >> table[i][j];
			sum += table[i][j];
			cout << table[i][j] << " ";
		}
		cout << sum << endl;
	}

	int all=0;
	for(int i=0;i<c;i++){
		int sum = 0;
		for(int j=0;j<r;j++){
			sum += table[j][i];
		}
		all += sum;
		cout << sum << " ";
	}
	cout << all << endl;
	return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;

    int sum = a+b;
    int sub = a-b;
    int mult = a*b;

    if(sum > sub && sum>mult){
        cout << sum << endl;
    }else if (sub>mult){
        cout << sub << endl;
    }else{
        cout << mult << endl;
    }

    return 0;
}


Measured memory_bytes: 256
// Problem : C - Step
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
const long long int  modu=1e9+7;
#define endl '\n'
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define inp(x)  for(auto &t:x) cin>>t;
#define itr     vector<int>::iterator
#define debug(a) cout << #a << "=" << a << ' '<<endl;
#define out(x)  for(auto &t:x) cout<<t<<" "; cout<<endl;
#define ff first
#define ss second
#define pb push_back
#define initialize(a,v)  for(int i=0;i<a.size();++i) a[i]=v;
#define all(x) x.begin(),x.end()
#define mpt(mp) for(auto it=mp.begin();it!=mp.end();it++)
#define trav(x) for(int i=0;i<(int)x.size();++i)
#define mkp(a,b) make_pair(a,b)
#define sz(x)  (int)x.size()

int noofdig(int N)
{
	return floor(log10(N))+1;
}


ll f(ll a)
{

return 0;

}



void pre()
{

}



void solve()
{
	
	ll n;
	cin>>n;
	
	vl a(n);
	inp(a)
	
	ll mx=-1;
	ll ans=0;
	
	for(int i=0;i<n;++i)
	{
		mx=max(mx,a[i]);
		ans+=abs(a[i]-mx);
	}
  
  cout<<ans<<endl;
  





}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 4768
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<vector>
#define INF 100000000

#define MAX_N 10000
#define MAX_M 100

typedef long long int ll;
using namespace std;



int main(){

	int a,b;

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

	printf("%d %d\n", a*b, a*2+b*2);

	return 0;

}

Measured memory_bytes: 1188
#include "bits/stdc++.h"

using namespace std;

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

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	vector<int> a(n);
	for (auto &v : a) {
		cin >> v;
	}
	sort(begin(a), end(a));

	int sum = 0;
	for (auto v : a) {
		sum += abs(v);
	}

	if (a.front() > 0) sum -= a.front() * 2;
	if (a.back() < 0) sum += a.back() * 2;
	cout << sum << endl;

	int acc = a.front();

	for (int i = 1; i < n - 1; i++) {
		if (a[i] >= 0) {
			cout << acc << " " << a[i] << endl;
			acc -= a[i];
		}
	}

	cout << a.back() << " " << acc << endl;
	acc = a.back() - acc;

	for (int i = 1; i < n - 1; i++) {
		if (a[i] < 0) {
			cout << acc << " " << a[i] << endl;
			acc -= a[i];
		}
	}
	return 0;
}


Measured memory_bytes: 2304
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)



def main():
    N, M = map(int, input().split())

    cnt = [0 for _ in range(N+1)]
    for _ in range(M):
        a, b = map(int, input().split())
        cnt[a] += 1
        cnt[b] += 1

    for i in range(1, N+1):
        print(cnt[i])

if __name__ == "__main__": main()


Measured memory_bytes: 3828
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int A = s.nextInt();
        int B = s.nextInt();

        if(A >= 13){
            System.out.println(B);
        }
        else if(A <= 12 && A >= 6){
            System.out.println(B/2);
        }
        else if(A <= 5){
            System.out.println("0");
        }
    }
}

Measured memory_bytes: 21716
// Problem : A - Don't be late
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int d,s,t;
	cin>>d>>s>>t;
	if(s*t>=d)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3652
//Littleboy123 Template 1.1

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

//pragmas
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
*/

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define FOR(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
#define COUT(a) cout << (a) << '\n'
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)

void init(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

//End of template

vi alp[26];

int main(){  
	init();

	//debug
	/*
	ifstream in("input.in");
	streambuf *cinbuf = std::cin.rdbuf();
	cin.rdbuf(in.rdbuf());

	ofstream out("out.txt");
	streambuf *coutbuf = std::cout.rdbuf();
	cout.rdbuf(out.rdbuf());
	*/
	//end debug

	string s, t;
	cin >> s >> t;
	ull len = s.length();
	FOR(i, 0, len){
		alp[s[i]-'a'].pb(i+1);
	}
	ull low = 0;
	ull panjang = len;
	len = t.length();
	ull ans = 0;
	ull tmp;
	ull sz[26];
	FOR(i, 0, 26){
		sz[i] = alp[i].size();
	}
	FOR(i, 0, len){
		if(sz[t[i]-'a'] == 0){
			cout << -1 << nl;
			return 0;
		}
		auto it = lower_bound(alp[t[i]-'a'].begin(), alp[t[i]-'a'].end(), low+1);
		tmp = *it;
		//cout << "TMP " << tmp << nl;
		if(it == alp[t[i]-'a'].end()){
			ans += panjang-low;
			ans += alp[t[i]-'a'][0];
			low = alp[t[i]-'a'][0];
		}
		else if(tmp > low){
			ans += tmp-low;
			low = tmp;
		}
		else if(tmp == low){
			ans += panjang-low;
			ans += alp[t[i]-'a'][0];
			low = alp[t[i]-'a'][0];
		}
		else{
			ans += panjang-low;
			ans += alp[t[i]-'a'][0];
			low = alp[t[i]-'a'][0];
		}
		//cout << ans << nl;
	}
	cout << ans << nl;
	return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  rep(i,a+1){
    rep(j,b+1){
      rep(k,c+1){
        if(500*i+100*j+50*k==x) ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static long MOD = 1000000007;
	public static void main(String[] args) {
		int i,j,k;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		char[] s = sc.next().toCharArray();
		sc.close();
		int[] l = new int[10];
		Arrays.fill(l, n);
		int[] r = new int[10];
		Arrays.fill(r, -1);
		for (i = 0; i < n; i++) {
			l[(int)(s[n-1-i]-'0')]=n-1-i;
			r[(int)(s[i]-'0')]=i;
		}
		HashSet<String> set = new HashSet<>();
		char[] tmp = new char[3];
		for (i = 1; i < n-1; i++) {
			for (j = 0; j < 10; j++) {
				if(l[j]<i) {
					for (k = 0; k < 10; k++) {
						if(r[k]>i) {
							tmp[0] =  (char)('0'+j);
							tmp[1] =  s[i];
							tmp[2] =  (char)('0'+k);
//							out.println(Arrays.toString(tmp));
							set.add(String.valueOf(tmp));
						}
					}
				}
			}
		}
		out.println(set.size());
	}
}


Measured memory_bytes: 75224
#include<stdio.h>
#include<string.h>
int main()
{
       int n,i,d;
       char str1[102],str2[102],str3[202];
       scanf("%d",&n);
       d = n * 2;
       scanf("%s",str1);
       scanf("%s",str2);
       for(i=0; i<n; i++)
       {
                 printf("%c",str1[i]);
                 printf("%c",str2[i]);
       }
       return 0;
}


Measured memory_bytes: 128
#include <unordered_map>
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

class Solution {
public:
    void solve() {
        int n;
        cin >> n;
        vector<string> songs(n);
        vector<int> durations(n);
        for (int i = 0; i < n; ++i)
            cin >> songs[i] >> durations[i];
        string that;
        cin >> that;
        int sum = 0;
        bool sleep = false;
        for (int i = 0; i < n; ++i) {
            if (sleep) sum += durations[i];
            if (that == songs[i]) sleep = true;
        }
        cout << sum;
    }
};

int main() {
    Solution solution = Solution();
    solution.solve();
}

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

int main(){
 int n,w;
  cin>>n>>w;
  int wt[100],val[100];
  for(int i=0;i<n;i++){ 
     cin>>wt[i]>>val[i];
  }
  long dp[100001];
  dp[0]=0;
  for(int i=1;i<=w;i++) dp[i]=0;
  
  for(int i=0;i<n;i++){
    for(int j=w;j>=wt[i];j--){
         dp[j]=max(dp[j],dp[j-wt[i]]+val[i]);
      }
     // for(int i=0;i<=w;i++) cout<<dp[i]<<" ";
      //cout<<endl;
  }
  cout<<dp[w]<<endl;
 }

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

int main() {
	int n,k;
	cin >> n >> k;
	vector<int> h(n);
	for(int i=0; i<n; i++){
		cin >> h.at(i);
	}
	int ans = 0;
	for(int i=0; i<n; i++){
		if(h.at(i)>=k) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  rep(i, ll(t.size())) {
    if (t[i] == '?')
      t[i] = 'D';
  }

  cout << t << endl;

  return 0;
}


Measured memory_bytes: 3752
#include <iostream>
using namespace std;
int main(void){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int L = A + B;
    int R = C + D;
    if(L > R)
        cout << "Left" << endl;
    else if(L == R)
        cout << "Balanced" << endl;
    else
        cout << "Right" << endl;
}


Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='9') s[i]='1';
    else if(s[i]=='1') s[i]='9';
  }
  cout<<s;
}

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

int main() {
  int A,B;
  cin >> A >> B;
  int big,small;
  big = max(A,B);
  small = min(A,B);
  if ( A == B ) {
    cout << 2*A << endl;
  }
  else {
    cout << big*2-1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}

int main(){
    ll n;;
    cin>>n;
    ll d[n+1];
    ll ans=0;
    for(int i=1;i<=n;i++) cin>>d[i];
        for(int i=1;i<=n;i++){
             for(int j=i+1;j<=n;j++){
                 ans = ans+(d[i]*d[j]);
             }
        }

        cout<<ans<<endl;
  
}




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

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

int N, M, K;
vector<int> G[100010], B[100010];
int id[100010];
int num[100010];

int DFS(int v, int c)
{
    if(id[v])return 0;
    id[v] = c;
    int ret = 1;
    for(auto e : G[v])
        ret += DFS(e, c);
    return ret;
}

signed main()
{
    cin >> N >> M >> K;
    rep(i, M)
    {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i, K)
    {
        int c, d;
        cin >> c >> d;
        B[c].push_back(d);
        B[d].push_back(c);
    }

    int cnt = 0;
    for(int i = 1; i <= N; i++)
    {
        cnt++;
        if(id[i] == 0)
            num[cnt] = DFS(i, cnt);
    }

    for(int i = 1; i <= N; i++)
    {
        if(i - 1)cout << " ";
        int ans = num[id[i]] - 1;
        for(auto e : G[i])if(id[e] == id[i])ans--;
        for(auto e : B[i])if(id[e] == id[i])ans--;
        cout << ans;
    }cout << endl;

    return 0;
}

Measured memory_bytes: 17784
S = input()
# N, K = [int(_) for _ in input().split()]
count = 1
S2 = []
for i in range(len(S)):
    if i < len(S)-1 and S[i] == S[i+1]:
        count += 1
    else:
        if S[i] == '<':
            S2.append(['<', count])
        else:
            S2.append(['>', count])
        count = 1
ans = 0
for i in range(len(S2)):
    if S2[i][0] == '<':
        if i < len(S2)-1:
            if S2[i][1] < S2[i+1][1]:
                ans += (S2[i][1] - 1) * (S2[i][1] - 0) // 2
            else:
                ans += S2[i][1] * (S2[i][1] + 1) // 2
        else:
            ans += S2[i][1] * (S2[i][1] + 1) // 2
    else:
        if i > 0:
            if S2[i-1][1] >= S2[i][1]:
                ans += (S2[i][1] - 1) * (S2[i][1] - 0) // 2
            else:
                ans += S2[i][1] * (S2[i][1] + 1) // 2
        else:
            ans += S2[i][1] * (S2[i][1] + 1) // 2
print(ans)




Measured memory_bytes: 29084
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define MININF -1e18L
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> intint;

int main(void)
{
    int a;
    cin >> a;
    if(a == 25){
        cout << "Christmas";
    }else if(a == 24){
        cout << "Christmas Eve";
    }else if(a == 23){
        cout << "Christmas Eve Eve";
    }else if(a == 22){
        cout << "Christmas Eve Eve Eve";
    }
    cout << endl;
}

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

#define DEBUG_MSG_off

int N,L;
vector<int> asi_list;

int main() {
  cin >> N >> L;
  asi_list.resize(N);
  int sum_asi    = 0;
  int sum_asi_m1 = 0;
  int min_abs_index = -1;
  int min_abs_asi   = -1;
  for (int i=1;i<N+1;i++){
    int asi = L + i -1;
    if (min_abs_asi==-1) {
      min_abs_asi = abs(asi);
    } else {
      min_abs_asi = min(min_abs_asi,abs(asi));
    }
    asi_list[i-1] = asi;
  }
#ifdef DEBUG_MSG
    cerr << "min_abs_asi=" << min_abs_asi << endl;
#endif
  for (auto asi: asi_list) {
#ifdef DEBUG_MSG
    cerr << asi << " ";
#endif
    if (min_abs_asi!=abs(asi)) {
      sum_asi_m1 += asi;
    } else {
#ifdef DEBUG_MSG
      cerr << "(min)";
#endif
    }
#ifdef DEBUG_MSG
    cerr << " ";
#endif
  }
#ifdef DEBUG_MSG
    cerr << endl;
#endif
  cout << sum_asi_m1 << "\n";

#ifdef DEBUG_MSG
  cerr << N << " " << L << "\n";
#endif
  return 0;
}

Measured memory_bytes: 256
n,x = map(int,input().split())
a = list(map(int,input().split()))

if sum(a) == x:
    print(n)
elif sum(a) < x:
    print(n - 1)
else:
    p = 0
    a.sort()
    for i in range(n):
        if a[i] > x:
            break
        else:
            x -= a[i]
            p += 1
    print(p)

Measured memory_bytes: 9208
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;

struct sushi{
    int t, d;
    bool operator<(const sushi other) const{
        return d < other.d;
    }
};

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

    vector<sushi> v(n);
    for(int i = 0; i < n; i++){
        cin >> t >> d;
        v[i] = sushi({t, d});
    }
    sort(v.rbegin(), v.rend());

    ll ans = 0;
    vector<int> ate(n+1, 0);
    ll kind = 0, sum = 0;
    priority_queue<pair<int,int>> pq;

    for(int i = 0; i < k; i++){
        sum += v[i].d;
        ate[v[i].t]++;
        if(ate[v[i].t] == 1)    kind++;
        pq.push({-v[i].d, v[i].t});
    }

    ans = kind*kind + sum;

    for(int i = k; i < n; i++){
        sushi now = v[i];
        if(ate[now.t] != 0)    continue;
        while(!pq.empty()){
            auto p = pq.top();  pq.pop();
            if(ate[p.second] == 1)  continue;
            ate[p.second]--;
            ate[now.t]++;
            sum += p.first;
            sum += now.d;
            kind++;
            break;
        }
        ans = max(ans, kind*kind+sum);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2552
// abc132_a
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	string S;
	cin >> S;
	vector<char> vc;
	for (int i = 0; i < S.length(); i++) {
		char key = S[i];
		vc.push_back(key);
	}
	sort(vc.begin(), vc.end());
	if (vc[0] == vc[1] && vc[1] != vc[2] && vc[2] == vc[3]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	/*
	map<char, int> mp{};
	for (int i = 0; i < S.length(); i++) {
		char key = S[i];
		mp[key]++;
	}
	if (mp.size() != 2) {
		cout << "No" << endl;
		exit(0);
	}
	for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
		char key = itr->first;
		int value = itr->second;
		cout << key << ":" << value << endl;
		if (value != 2) {
			cout << "No" << endl;
			exit(0);
		}
	}
	cout << "Yes" << endl;
	*/
	return 0;
}

Measured memory_bytes: 256
import math

X = int(input())
  
#素数判定
#Nが素数か True/False で返す
#O(√N)
def is_prime(N):
    if N == 1:
        return False
    for i in range(2,N+1):
        #調べるのはNの1/2乗まででよい
        if i * i > N:
            break
        #割り切れたら素数じゃない
        if N % i == 0:
            return False
    
    return True

for i in range(X,10**10):
    if is_prime(i):
        print(i)
        break


Measured memory_bytes: 38464
#include <bits/stdc++.h>
#define MAX 100005
using namespace std;

typedef long  long ll;

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll a, b, c, d;
    cin>>a>>b>>c>>d;

    ll g = __gcd(c, d);
    ll l = (c * d) / g;

    ll ans1 = b / c - a / c;
    if(a % c == 0)
        ans1++;
    ll ans2 = b / d - a / d;
    if(a % d == 0)
        ans2++;
    ll ans3 = b / l - a / l;
    if(a % l == 0)
        ans3++;

    ll ans = (b - a + 1) - ans1 - ans2 + ans3;

    cout<<ans<<endl;

    return  0;
}



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

void Cout( int A, int B )
{
int i;

	for( i = A; i <= B; i++ )
	{
		cout << i << endl;
	}
}

int main()
{
int i;
int A;
int B;
int K;

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

	cin >> A;
	cin >> B;
	cin >> K;

	K--;
	if( A + K < B - K )
	{
		Cout( A, A + K );
		Cout( B - K, B );
	}
	else
		Cout( A, B );

	return 0;
}



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



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

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

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












 
int main(){
    ll n;
    cin >> n;
    ll cnt = 0;
    for(ll i = 1; i <= n / 2; i++){
        if(i != n - i) cnt++;
    }
    cout << cnt << endl;
}

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

int sum[2][105];
int main(){
	int n;
	cin >> n;
	int a[2][105];
	rep(i,2){
		rep(j,n){
			cin >> a[i][j];
		}
	}
	
	sum[0][0] = a[0][0];
	
	rep(i,2){
		rep(j,n){
			if(i==0 && j == 0) {
				continue;
			} else if (i == 0){
				sum[i][j] = max(sum[i][j],  sum[i][j-1] + a[i][j]);
			} else if (j == 0){
				sum[i][j] = max(sum[i][j], sum[i-1][j] + a[i][j]);
			} else{
				sum[i][j] = max(sum[i][j], sum[i-1][j] + a[i][j]);
				sum[i][j] = max(sum[i][j], sum[i][j-1] + a[i][j]);
			}
		}
	}
	
	cout << sum[1][n-1] << endl;
    return 0;
}



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

int a[1000];

int main()
{
	int n, m;
	cin >> n >> m;
	int u = 0;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
		u = u + a[i];
	}
	int b = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (a[i]*4*m >= u)
			b = b + 1;
	}
	if (b >= m)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 256