akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

//デバッグ
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

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


ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}


//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

ll H, W;
char a[510][510];

void solve(){
  char R[H][W];
  char B[H][W];
  rep(i, H){
    R[i][0] = '#';
    for(ll j = 1; j < W-1; j++){
      if(i % 2){
        R[i][j] = '#';
      }else{
        R[i][j] = '.';
      }
    }
    R[i][W-1] = '.';
  }
  rep(i, H){
    B[i][0] = '.';
    for(ll j = 1; j < W-1; j++){
      if(i % 2){
        B[i][j] = '.';
      }else{
        B[i][j] = '#';
      }
    }
    B[i][W-1] = '#';
  }
  rep(i, H)rep(j, W)if(a[i][j] == '#'){
    R[i][j] = '#';
    B[i][j] = '#';
  }
  rep(i, H){
    rep(j, W){
      cout << R[i][j];
    }
    cout << endl;
  }
  rep(i, H){
    rep(j, W){
      cout << B[i][j];
    }
    cout << endl;
  }
}

int main(){
  cin >> H >> W;
  rep(i, H) rep(j, W) cin >> a[i][j];
  solve();



}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
  ll n,m;
  cin >> n >> m;
  set<ll> s;
  vll d(n,-inf);
  vector<vp> G(n);
  rep(i,0,m){
   ll l,r,ds;
    cin >> l >> r >> ds;
    l--;
    r--;
    G[l].eb(P(r,ds));
    G[r].eb(P(l,-ds));
    s.insert(l);
    s.insert(r);
    d[l]=inf;
    d[r]=inf;
  }
  
 
  queue<ll> q;
 
  q.push(*s.begin());
  d[*s.begin()]=0;
  s.erase(*s.begin());
  
  while(q.size()){
   ll x=q.front();
    q.pop();
    for(P v: G[x]){
     if(d[v.fi]!=inf&&d[v.fi]!=d[x]+v.se){
      cout << "No" << endl; 
      return;  
     }
     if(d[v.fi]!=inf) continue;
     d[v.fi]=d[x]+v.se;
     s.erase(v.fi);
     q.push(v.fi); 
    }
  
    if(q.empty()&&s.size()) {
      q.push(*s.begin());
      d[*s.begin()]=0;
       s.erase(*s.begin());
    }
  }
  
  cout << "Yes" << endl;
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 21692
#include <iostream>
#include <bitset>
#include <vector>
using namespace std;
typedef long long ll;

const int MAX_N = 100000;

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

		vector<int> lengh(n);
		int left, right = 0, before;
		lengh[right] = 1;

		for(int i = 0; i < n; i++){

			int buf;
			cin >> buf;

			if(i){

				if(before == buf){

					lengh[right]++;

				}else if((i+1) % 2 == 0){

					if(right == 0){

						lengh[right]++;
						left = buf;

					}else{

						lengh[right - 1] += lengh[right] + 1;
						lengh[right] = 0;
						right--;

					}
				}else{

					right++;
					lengh[right] = 1;

				}

			}else	left = before = buf;

			before = buf;
		}

		int res = 0;
		for(int i = 0; i < lengh.size(); i++){
			if(!left) res += lengh[i];
			left = !left;
		}

		cout << res << endl;
	}
}

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

#define ll long long
#define fast_in_out  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = 2e5;
int arr[N + 1];

int main()
{
    fast_in_out;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    ll stool = 0;
    for(int i = 1; i < n; i++)
    {
        if(arr[i] < arr[i - 1])
        {
            int x = arr[i - 1] - arr[i];
            stool += x;
            arr[i] += x;
        }
    }
    cout << stool;
}


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

using namespace std;

int main() {
  long long X, K, D;
  cin >> X >> K >> D;
  
  if (X < 0) X = -X;
  
  long long ans;
  long long tmp = X / D;
  if (K < tmp) {
    ans = X - K * D;
  } else {
    if (tmp % 2 == K % 2) {
      ans = X - tmp * D;
    } else {
      ans = -X + (tmp + 1) * D;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#define N 100000
int n;
int A[N];
int Partition(int, int);
int main(){
    int i;
    int p=0;
    int r;
    int ans;
    scanf("%d", &n);
    for( i=0; i<n; i++ ){
        scanf("%d", &A[i]);
    }
    r=n-1;
    ans=Partition(p, r);
    for( i=0; i<ans; i++ ) printf("%d ", A[i]);
    printf("[%d] ", A[ans]);
    for( i=ans+1; i<n; i++ ){
        printf("%d", A[i]);
        if( i+1 < n) printf(" ");
    }
    printf("\n");
    return 0;
}
 
int Partition(int p, int r){
    int i;
    int j;
    int tmp;
    int x;
    x=A[r];
    i=p-1;
    for( j=p; j<=r-1; j++ ){
        if( A[j] <= x ){
            i++;
            tmp=A[j];
            A[j]=A[i];
            A[i]=tmp;
        }
    }
    tmp=A[r];
    A[r]=A[i+1];
    A[i+1]=tmp;
    return i+1;
}

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

int main(){
  while(1){
    int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    int uruday[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
    int i,j,y1,m1,d1,y2,m2,d2;
  int total=0;
  cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;
  if(y1<0 || m1<0 || d1<0 || y2<0 || m2<0 || d2<0)break;
  for(i = y1; i < y2; i++){
    if(i%4==0){
      total += 366;
      if(i%100==0)total-=1;
      if(i%400==0)total+=1;
    }
    else total+=365;
  }
  
  for(i = 1; i < m2; i++){
    if(i==2 && (y2%4==0)){
      total+=uruday[i];
      if(y2%100==0)total-=1;
      if(y2%400==0)total+=1;
    }
    else total+=day[i];
  }

  for(i = 1; i < m1; i++){
  if(i==2 && (y1%4==0)){
      total-=uruday[i];
      if(y1%100==0)total+=1;
      if(y1%400==0)total-=1;
    }
    else total-=day[i];
  }
  
  total+=d2-d1;

  cout << total << endl;
  }
  return 0;
}

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

int main() {
	size_t N;
	cin >> N;
	vector<int> L(N);
	for (auto& x : L) cin >> x;
	sort(L.begin(), L.end());
	int sum = 0;
	for (size_t i = 0; i < N - 1; ++i) sum += L.at(i);
	if (L.at(N - 1) < sum) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 384
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  int ab, bc, ca;
  readf("%s %s %s\n", &ab, &bc, &ca);
  writeln(ab*bc/2);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a;
  cin>>a;
  int A[a];
  for(int i=0;i<a;i++){
    cin>>A[i]; 
  }
  int even=0;
  int count=0;
  for(int i=0;i<a;i++){
    if(A[i]%2==0){
      even++;
      if(A[i]%3==0||A[i]%5==0){
        count++;
      }
    }
  }
  if(even==count){
    cout<<"APPROVED"<<endl;
  }
  else{
    cout<<"DENIED"<<endl;
  }
 return 0; 
}

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

use itertools::Itertools;
use proconio::input;
use proconio::marker::*;

fn main() {
    input! {
        x: usize
    }
    println!("{}", 1 - x);
}


Measured memory_bytes: 2112
#include<cstdio>
#include<cstring>
#include<iostream>
const int P = 1e9 + 7;
using namespace std;

const int CN = 2e3 + 100;
int n, ans = 0, C[CN][CN], frac[CN];

void pcal(int n = CN - 10){
    C[0][0] = 1;
    for(int i = 1; i <= n; i++){
        C[i][0] = 1;
        for(int j = 1; j <= i; j++) C[i][j] = ( C[i - 1][j] +0ll+ C[i - 1][j - 1] ) % P;
    }
    frac[0] = 1;
    for(int i = 1; i <= n; i++) frac[i] = (1ll * frac[i - 1] * i) % P;
}
int Cnm(int x, int y) {return C[x - 1][y - 1];}

int main()
{
    ios :: sync_with_stdio(false);
    cin >> n, pcal();
    int ans = 0;
    for(int l = 1; n >= l * 3; l++) ans = (ans + Cnm(n - l * 2, l)) % P;
    cout << ans << endl;
}

Measured memory_bytes: 18544
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <ctime>
#include <string.h>
using namespace std;
const int N = 105;
int cnt[105];
int main() {
    int a[N], n;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) scanf("%d", a+i), cnt[a[i]]++;
    int mx = -1;
    for(int i = 1; i <= n; ++i) mx = max(mx, a[i]);
    if((mx+1)%2) {
        int mi = mx/2+1;
        for(int i = mx, cot = 0; cot < mx/2; ++cot) {
            cnt[i] -= 2;
            if(cnt[i] < 0) return 0*puts("Impossible");
            i--;
        }
        cnt[mx/2]--;
        if(cnt[mx/2] < 0) return 0*puts("Impossible");
        for(int i = 1; i < n; ++i) {
            if(cnt[i] && i < mi) return 0*puts("Impossible");
        }
    }
    else {
        int mi = (mx+1)/2+1;
        for(int i = mx, cot = 0; cot <= mx/2; ++cot) {
            cnt[i] -= 2;
            if(cnt[i] < 0) return 0*puts("Impossible");
            i--;
        }
        for(int i = 1; i < n; ++i) {
            if(cnt[i] && i < mi) return 0*puts("Impossible");
        }
    }
    puts("Possible");
}


Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
count = defaultdict(int)
for i in range(N):
    s = input()
    count[s] += 1

mx = 0
for k, v in count.items():
    if v > mx:
        mx = v

ans = []
for k, v in count.items():
    if v == mx:
        ans.append(k)


for s in sorted(ans):
    print(s)


Measured memory_bytes: 35900
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
#include "tuple"

#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 92233720368547758070
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int n,cnt=0,ans=0,c;
vector<int> a,b;
int main(){
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>c;
		a.push_back(c);
	}
	for(int i=0;i<n;++i){
		cin>>c;
		b.push_back(c);
	}
	for(int i=29;i!=-1;--i){
		for(int j=0;j<n;++j){
			a[j]%=(1<<i+1);
			b[j]%=(1<<i+1);
		}
		sort(b.begin(),b.end());
		cnt=0;
		for(int j=0;j<n;++j){
			cnt+=b.end()-lower_bound(b.begin(),b.end(),(1<<(i+1))+(1<<i)-a[j]);
			cnt%=2;
			cnt+=lower_bound(b.begin(),b.end(),(1<<(i+1))-a[j])-lower_bound(b.begin(),b.end(),(1<<i)-a[j]);
			cnt%=2;
		}
		if(cnt)
			ans+=(1<<i);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2548
import itertools
n,m,q = map(int,input().split())
num = [i for i in range(1,m+1)]
l = []
for i in range(q):
    r = list(map(int,input().split()))
    l.append(r)
l.sort()
stock = list(itertools.combinations_with_replacement(num, n))
ans = 0
for i in stock:
    s = 0
    for j in l:
        if i[j[1]-1] - i[j[0]-1] == j[2]:
            s += j[3]
            #print(s)
        #print(i[j[1]-1] - i[j[0]-1])
    if ans < s:
        ans = s
print(ans)


Measured memory_bytes: 84372
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl;
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}



int main()
{
	IOS;
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22)
	cout<<"bust";
	else
	cout<<"win";
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool check(int n)
{
    string str=to_string(n);
    set<char>v;
    for(int i=0;i<str.length();i++)
    {
        v.insert(str[i]);
    }
    if(v.size()==1)
      return true;
    else
      return false;
}
signed main()
{
   int n;
   cin>>n;
   for(int i=n;;i++)
   {
      if(check(i))
      {
         cout<<i;
         return 0;
      }
   }
 }

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

#define MAXY 7368792
bool ok[MAXY];

void init(){
    fill(ok,ok+MAXY,false);
}
ll solve(ll m,ll n){
    ll res = 0;
    for(ll x = m; x < MAXY; x++){
        if(ok[x]) continue;
        if(n == 0) { res = x; break; }
        n--;
        for(ll y = 1; x*y < MAXY;y++){
            ok[x*y] = true;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll m,n;
    while(cin >> m >> n,m|n){
        init();
        cout << solve(m,n) << endl;
    }
    return 0;
}



Measured memory_bytes: 10296
n = int(input())

output = ""

num = 1

if n == 0:
    print(0)

else:
    while n != 0:
        # print("===")
        # print(num)

        if n % (-2 * num) == 0:
            output = "0" + output
        else:
            output = "1" + output
            n -= num

        num = num * (-2)
        # print(output)

    print(output)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int n, m, q;
vector<int> a, b, c, d;
ll ans = 0;

void dfs(vector<int> v) {
  if ((int)v.size() == n + 1) {
    ll tmp = 0;
    for (int i = 0; i < q; i++) {
      if (v[b[i]] - v[a[i]] == c[i]) tmp += d[i];
    }
    ans = max(tmp, ans);
    return;
  }

  v.push_back(v.back());
  while (v.back() <= m) {
    dfs(v);
    v.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  dfs(vector<int>(1, 1));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <algorithm>
using namespace std;

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

    int ans = 0;
    int index;
    
    for (int i = 0; i < N; i++) {
        if (S.substr(i, 3) == "ABC") ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int a[n][m];
    int b[m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    int c;
    for(int i=0;i<n;i++){
        c=0;
        for(int j=0;j<m;j++){
            c+=a[i][j]*b[j];
        }
        cout<<c<<endl;
    }
}


Measured memory_bytes: 3092
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            string s = ReadLine();
            if (s == "SUN")
            {
                WriteLine(7);
            }
            else if (s == "SAT")
            {
                WriteLine(1);
            }
            else if (s == "FRI")
            {
                WriteLine(2);
            }
            else if (s == "THU")
            {
                WriteLine(3);
            }
            else if(s == "WED")
            {
                WriteLine(4);
            }
            else if (s == "TUE")
            {
                WriteLine(5);
            }
            else if (s == "MON")
            {
                WriteLine(6);
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define all(x) (x).begin(), (x).end()
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL
ll modPow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n-1, p)) % p;
  ll t = modPow(a, n/2, p);
  return (t * t) % p;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout << fixed << setprecision(15)

  ll n;
  cin >> n;
  vector<ll> a(n);
  ll temp = 0, sub = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    temp += a[i];
    temp %= MOD;
    sub += a[i] * a[i];
    sub %= MOD;
  }

  cout << ((((((temp * temp) % MOD) + MOD) - sub) % MOD) * modPow(2, MOD-2, MOD)) % MOD << endl;

}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin >> N;
    vector<tuple<string, int, int>> d(N);
    for (int i = 0; i < N; i++)
    {
        string s; cin >> s;
        int p; cin >> p;
        d[i] = make_tuple(s, 100 - p, i);
    }
    sort(d.begin(), d.end());
    for (int i = 0; i < N; i++)
    {
        string a; int b, c;
        tie(a, b, c) = d[i];
        cout << c+1 << endl;
    }

    return 0;
}

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

int main(){
  int d, t, s;
  cin >> d >> t >> s;
  if(t*s>=d)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>

using namespace std;
bool vis[200];
int que[100],sum[100];
int tot;
void get(){
    tot=0;
    for(int i=2;i<=100;i++){
        int tmp=i*i;
        if(!vis[i]){
            que[++tot]=i;
            //cout<<i<<endl;
        if(tmp>100) continue;
            while(tmp<=100){
                vis[tmp]=true;
                tmp+=i;
            }
        }
    }
}
int main(){
    int n;
    get();
    scanf("%d",&n);
    int res=0,ans=0;
    for(int i=1;i<=tot;i++){
        int pp=0;
        for(int j=que[i];j<=n;j+=que[i]){
            int tmp=j;
            while(!(tmp%que[i])){
                pp++;
                tmp/=que[i];
            }
        }
        sum[i]=pp;
    }
    int a=0,b=0,c=0,d=0,p=0;
    for(int i=1;i<=tot;i++){
        if(sum[i]>=74) p++;
        if(sum[i]>=24) a++;
        if(sum[i]>=14) b++;
        if(sum[i]>=4) c++;
        if(sum[i]>=2) d++;
    }
    int ANS=a*(d-1);
    ANS+=b*(c-1);
    ANS+=((c-1)*c/2)*(d-2);
    ANS+=p;
    printf("%d\n",ANS);
    return 0;
}


Measured memory_bytes: 384
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i
h = gets.chomp.split.map(&:to_i)

if n <= 2
  puts h.max
  exit
end

inc = true
hight = h.first
ans = h.first
(n-1).times do |i|
  if inc
    if h[i] <= h[i+1]
      # pass
    else
      ans += h[i] - hight
      hight = h[i+1]
      inc = false
    end
  else
    if h[i] >= h[i+1]
      hight = h[i+1]
    else
      inc = true
    end
  end
  # p [i,'',hight, inc, ans]
end

ans += h.last - hight
puts ans


Measured memory_bytes: 2300
yyyy, mm, dd = map(int, input().split('/'))
if yyyy < 2019:
  print('Heisei')
elif yyyy > 2019:
  print('TBD')
else:
  if mm < 4:
    print('Heisei')
  elif mm > 4:
    print('TBD')
  else:
    if dd <= 30:
      print('Heisei')
    elif dd > 30:
      print('TBD')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int n;
ll A[maxn],B[maxn];

int main()
{
    fastio();
    cin>>n;
    rep(i,1,n) {
        cin>>A[i]>>B[i];
    }
    sort(A+1,A+n+1);sort(B+1,B+n+1);
    if(n&1){
        cout<<B[(n+1)/2]-A[(n+1)/2]+1<<endl;
    }else {
        ll ans = B[n/2+1]+B[n/2] - A[n/2+1] - A[n/2] + 1;
        cout<<ans<<endl;
    }
    return 0;
}


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

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

int main(){
  int h, w;
  cin >> h >> w;

  vector<string> s(h);
  rep(i,h) cin >> s.at(i);

  vector<int> x = {-1, 0, 1};
  vector<int> y = {-1, 0, 1};

  vector<vector<int>> ans(h, vector<int>(w,-1));

  rep(i, h){
    rep(j,w){
      if(s.at(i).at(j)=='#') continue;
      int count=0;
      rep(dx, 3){
        rep(dy, 3){
          int nowx = i+x.at(dx);
          int nowy = j+x.at(dy);
          if(nowx>=0&&nowx<h&&nowy>=0&&nowy<w&&s.at(nowx).at(nowy)=='#')count++;
        }
      }
      ans.at(i).at(j) = count;
    }
  }

  rep(i,h){
    rep(j,w){
      if(ans.at(i).at(j)==-1)cout<<'#';
      else cout<<ans.at(i).at(j);
    }
    cout << endl;
  }
  
}

Measured memory_bytes: 3584
//q063.cpp
//Sat Aug 29 19:24:40 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

ll d[300][300];
int v;
int flag;
set<P> rem;
void warshall_floyd(){
	for (int k=0;k<v;k++){
		for (int i=0;i<v;i++){
			for (int j=0;j<v;j++){
				if (d[i][j]>d[i][k]+d[k][j]){
					flag = 0;
				}else if (d[i][j]==d[i][k]+d[k][j] && i!=k && j!=k){
					rem.insert(P(i,j));
					rem.insert(P(j,i));
				}
				d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
}

int main(){
	cin >> v;

	ll ans = 0;
	rep(i,v)rep(j,v){
		cin >> d[i][j];
		ans += d[i][j];
	}

	flag = 1;
	warshall_floyd();

	for (auto itr=rem.begin();itr!=rem.end();itr++){
		P tmp = *itr;
//		cout << "  " << tmp.first << " " << tmp.second << endl;
		ans = ans - d[tmp.first][tmp.second];
	}

	if (flag){
		cout << ans/2 << endl;
	}else {
		cout << -1 << endl;
	}
//	printf("%.4f\n",ans);
}

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



//defines...
#define ll unsigned long long
#define tata return;
#define pb push_back
#define mp make_pair
#define in insert
#define run ios_base::sync_with_stdio(false);cin.tie(NULL);
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define vec vector<ll>
#define setl set<ll>
#define mapl map<ll,ll>
#define shunno cout<<0<<endl;
#define ek cout<<1<<endl;
#define pi 2*acos(0.0)1
#define hobena cout<<-1<<endl;




//typedefs...
typedef pair<ll,ll>pll;

//const..
//const ll fx[]={0,1,0,-1};
//const ll fy[]={1,0,-1,0};
const ll mod=1e9+7;

/*ll ncr(ll n, ll k)
{
    ll res = 1;


    if (k > n - k)
        k = n - k;

    for (int i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
*/
//to remove suffix of a number from a set of string
/*
for(int k=1; k<j.size(); k++)
                if(temp.count(string(j.begin()+k,j.end())))
					temp.erase(string(j.begin()+k,j.end()));
 */

void oka()
{
    ll i,j,k,n;
    ll ans=0;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            for(k=j+1;k<n;k++)
            {
                if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[k]+a[j]>a[i]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k])
                    ans++;
            }
        }
    }
    cout<<ans<<endl;
}



/*I'll paint it on the walls
     cause I'm the one at fault
    I'll never fight again and
         this is how it ends .*/






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

    run
    ll t;
    t=1;
  //cin>>t;
    while(t--){

    oka();
    }



}



Measured memory_bytes: 3656
N, K = gets.chomp.split(' ').map { |aa| aa.to_f }

sum = []
(1..N).each do |n|
  x = 0
  while n * (2 ** x) < K
    x += 1
  end
  sum << (
    (1 / Rational(2) ** x)
    # x
  )
end


ssum = Rational(0)
sum.each do |ss|
  ssum += ss
end


printf('%.10f', ssum / N)


Measured memory_bytes: 9852
/*#### bits/stdc++.h */
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<iostream>
#include<string>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<deque>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
/*####*/

int N;
int main(){
	scanf("%d",&N);
	for(int A=1; A<=3500; A++)
		for(int B=A; B<=3500; B++){
			long long int num = (long long int)A * B * N;
			long long int den = (long long int)4 * A * B - (long long int)N*(A+B);
			if(den > 0 && num % den == 0){
				cout << A << " " << B <<" " << num/den << endl;
				return 0;
			}
		}
	return 0;
}

Measured memory_bytes: 256
//

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    ll k,s;cin>>k>>s;
    int ans =0;
    rep(i,0,k+1){
        ll g;
        rep(j,0,k+1){
            g=s-i-j;
            if(g>k)continue;
            if(0>g)break;
            ans++;
        }
    }
    cout<<ans<<nnn;
    return 0;
}

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

int main() {
    int n, x;
    cin >> n >> x;
    if (x == 1 || x == 2 * n - 1) {
        cout << "No";
    } else {
        cout << "Yes\n";
        if (x < n) {
            for (int i = n + x; i < 2 * n; i++) {
                cout << i << ' ';
            }
            for (int i = 1; i < n + x; i++) {
                cout << i << ' ';
            }
        } else {
            for (int i = x - n + 1; i < 2 * n; i++) {
                cout << i << ' ';
            }
            for (int i = 1; i < x - n + 1; i++) {
                cout << i << ' ';
            }
        }
    }
    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    string s;
    cin >>s;
    ll k;cin >>k;
    vector<string>ans;
    for (int i = 0; i <s.size(); ++i) {
        for (int j = 1; j <=k; ++j) {
            if(i+j>s.size())continue;
            string st=s.substr(i,j);
//            cout <<st<<endl;
            ans.push_back(st);
        }
    }
    sort(all(ans));
    ans.erase(unique(all(ans)),ans.end());
    k--;
    cout <<ans[k]<<endl;
    return 0;
}



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

#ifdef moskupols
    #define debug(...) fprintf(stderr, __VA_ARGS__)
    #define cdebug(...) cerr << __VA_ARGS__
#else
    #define debug(...) do {} while (false)
    #define cdebug(...) do {} while (false)
#endif

#define timestamp(x) debug("["#x"]: %.3f\n", (double)clock() / CLOCKS_PER_SEC)

#define hot(x) (x)
#define sweet(value) (value)
#define faceless

#define WHOLE(v) (v).begin(),(v).end()
#define RWHOLE(v) (v).rbegin(),(v).rend()
#define UNIQUE(v) (v).erase(unique(WHOLE(v)),(v).end())

typedef long long i64;
typedef unsigned long long ui64;
typedef long double TReal;

using namespace std;

class TSolver {
public:
    int n;
    vector<int> a;

    explicit TSolver(std::istream& in) {
        in >> n;
        a.resize(n);
        for (int i = 0; i < n; ++i) {
            in >> a[i];
        }
    }

    vector<int> srt;

    void Solve() {
        srt = a;
        sort(WHOLE(srt));
    }

    void PrintAnswer(std::ostream& out) const {
        for (int i = 0; i < n; ++i) {
            out << srt[n / 2 - (a[i] >= srt[n / 2])] << '\n';
        }
    }
};

int main() {
    std::ios_base::sync_with_stdio(false);

    {
        auto solver = std::make_shared<TSolver>(std::cin);
        solver->Solve();
        solver->PrintAnswer(std::cout);
    }

    timestamp(end);
    return 0;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  ll q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;

  vector<pair<ll, double>> p(4);
  p[0] = make_pair(q * 8, 0.25);
  p[1] = make_pair(h * 4, 0.50);
  p[2] = make_pair(s * 2, 1.00);
  p[3] = make_pair(d, 2.00);

  sort(p.begin(), p.end());

  ll result = 0;
  int index = 0;
  while (n > 0) {
    pair<int, double> current = p[index];
    if (current.second == 2.00) {
      if (n / 2 > 0) {
        result += (n / 2) * d;
        n %= 2;
      }
    } else if (current.second == 1.00) {
      result += n * s;
      n = 0;
    } else if (current.second == 0.50) {
      result += n * 2 * h;
      n = 0;
    } else if (current.second == 0.25) {
      result += n * 4 * q;
      n = 0;
    }
    index++;
  }
  cout << result << endl;

  return 0;
}


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

#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end();

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

ll sum(int n){
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}
using namespace std;


int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   int a,b; cin>>a>>b;
   double x = (double) (a+b)/2;

   cout << ceil(x);
   return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.map { it - '0' }
    val l = N.size
    val dp = Array(l + 1) { IntArray(2) {0} }

    dp[0][1] = 1

    for (i in 0 until l) {
        dp[i + 1][0] = Math.min(dp[i][0] + N[i], dp[i][1] + 10 - N[i])
        dp[i + 1][1] = dp[i][1] + 9 - N[i]
//        if (N[i] < 9) {
            dp[i + 1][1] = Math.min(dp[i + 1][1], dp[i][0] + N[i] + 1)
//        }
    }
    println(dp[l][0])
}


Measured memory_bytes: 84164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(c-a)<=d || (abs(b-a)<=d && abs(c-b)<=d)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" <<endl;
    }
    return 0;
}

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

const int MAXN = 100010;

typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1e18;

#define X first
#define Y second

struct edge
{
	int u, v, w;
};

vector<edge> E[MAXN];
vector<int> rg[MAXN];
queue<int> Q;
bool vis[MAXN];
ll d1[MAXN], d2[MAXN], cnt1[MAXN], cnt2[MAXN];

ll gao(int x, ll cnt[])
{
	//cout << "gao " << x << " " << rg[x].size() << " " << cnt[x] << endl;
	if (cnt[x] != -1) return cnt[x];
	
	ll &res = cnt[x]; res = 0;
	for (auto y: rg[x])
	{
	//	cout << x << " " << y << endl;
		res = (res + gao(y, cnt)) % mod;
	}
	return res;
}

void SPFA(int S, int n, ll d[], ll cnt[])
{
	Q.push(S); vis[S] = true;
	for (int i = 1; i <= n; ++i) d[i] = INF;
	d[S] = 0;
	
	int x, y, z;
	while (!Q.empty())
	{
		x = Q.front(); Q.pop();
		for (auto e: E[x])
		{
			y = e.v, z = e.w;
			if (d[x] + z < d[y])
			{
				d[y] = d[x] + z;
				if (!vis[y]) 
				{
					vis[y] = true;
					Q.push(y);
				}
			}
		} 
		vis[x] = false;
	}
	
	for (int i = 1; i <= n; ++i) rg[i].clear();
	for (int i = 1; i <= n; ++i)
	{
		for (auto e: E[i])
		{
			if (d[i] + e.w == d[e.v])
				rg[e.v].push_back(i);
		}
	}
	 
	for (int i = 1; i <= n; ++i)
		cnt[i] = -1;
	cnt[S] = 1;
	for (int i = 1; i <= n; ++i)
		gao(i, cnt);
	
} 

ll sqr(ll x){return x * x % mod;}

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

	int n, m, S, T, x, y, z;
	scanf("%d %d %d %d", &n, &m, &S, &T);
	
	for (int i = 1; i <= m; ++i)
	{
		scanf("%d %d %d", &x, &y, &z);
		E[x].push_back(edge{x, y, z});
		E[y].push_back(edge{y, x, z});
	}
	SPFA(S, n, d1, cnt1);
	SPFA(T, n, d2, cnt2);
	
	ll ans = cnt1[T] * cnt1[T] % mod;
	
	for (int i = 1; i <= n; ++i)
	{
		if (i == S || i == T) continue;
		if (d1[i] * 2 == d1[T])
			ans -= sqr(cnt1[i] * cnt2[i] % mod);
	}
	ans %= mod;
	
	for (int i = 1; i <= n; ++i)
	{
		//cout << i << " " << d1[i] << " " << cnt1[i] << " " << d2[i] << " " << cnt2[i] << endl;
		for (auto e: E[i])
		{
			x = e.u, y = e.v, z = e.w;
			if (d1[x] + z + d2[y] == d1[T] && d1[x] + z == d1[y] && d2[y] + z == d2[x])
			{
				if (abs(d1[x] - d2[y]) < z)
					ans -= sqr(cnt1[x] * cnt2[y] % mod);
			}
		}
	}
	ans %= mod;
	if (ans < 0) ans += mod; 
	cout << ans << endl;
	
    return 0;
}

Measured memory_bytes: 22600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const ll MAX = 1e7 + 20;
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#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,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              "\n"

template< class T > T gcd(T a, T b)
{
    return (b != 0 ? gcd<T>(b, a%b) : a);
}
template< class T > T lcm(T a, T b)
{
    return (a / gcd<T>(a, b) * b);
}
const int N = 200200;

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast

    ll v[3];
    cin>>v[0]>>v[1]>>v[2];
    sort(v,v+3);
    cout<<0+v[1]-v[0]+(v[2]-v[1])<<endl;
}


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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int A, B, C;
	cin >> A >> B >> C;
	cout << 10 * max(A, max(B, C)) + (A+B+C)-(max(A, max(B, C))) ;
}

Measured memory_bytes: 256
object Main extends App {
	val N = scala.io.StdIn.readInt
	val A = scala.io.StdIn.readLine.split(" ").map(_.toLong)

	val minus = A.count(_ < 0L) % 2

	val B = A.map(_.abs)

	val Asum = B.sum
	val Amin = B.toSet.min

	if(B.toSet.contains(0L) || minus == 0){
		println(Asum)
	}else{
		println(Asum - 2*Amin)
	}	
}

Measured memory_bytes: 91248
def main():
    a, b, c, k = list(map(int, input().split()))
    maxS = 0
    if k <= a:
        print(k)
    elif k > a and k <= b+a:
        print(a)
    elif k > a + b:
        print(a-(k-a-b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
#include "bits/stdc++.h"
using namespace std;
int main(){
    int d,g,i,j,k,a,b,score,num,ans = 1001;
    cin >> d >> g;
    g /= 100;
    vector<int> p(d),c(d);
    for(i=0;i<d;i++){
        cin >> a >> b;
        p.at(i) = a;
        c.at(i) = b/100;
    }
    for(i=0;i<(1<<d);i++){
        score=0;num=0;
        for(j=0;j<d;j++){
            if(i&(1<<j)){
                score += p.at(j)* (j+1) + c.at(j);
                num += p.at(j);
            }
        }
        for(j=d-1;j>-1;j--){
            if((i&(1<<j))==0){
                for(k=0;k<p.at(j)-1;k++){
                    if(score >= g) break;
                    score += j+1;
                    num++;
                }
                break;
            }
        }
        if(score>=g) ans = min(ans,num);
    }
    cout << ans << endl;
    return 0;
}

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

ll ar[100000005],br[100000005];
int main()
{
    ll a,c,i,cnt=0,k=1;

    cin>>a;
    c=a;
    for(i=0; i<a; i++)
    {
        cin>>ar[i];
    }
    sort(ar,ar+a);

 while(cnt!=c-1)
 {

    for(i=1;i<a;i++)
    {
    

        ar[i]=ar[i]%ar[0];
        if(ar[i]!=0)
        {
            ar[k++]=ar[i];
        }
        else
            cnt++;
    }

        sort(ar,ar+k);
        a=k;
        k=1;
        i=1;


 }

        cout<<ar[0]<<endl;



    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <deque>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)

#define rdi(i) ll i; scanf("%lld", &i)
#define rds(s) string s; cin >> s
#define rdc(c) char c; cin >> c

#define INF 10000000000
#define MOD 1000000007

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

int main()
{
    ll k, a, b;
    cin >> k >> a >> b;
    ll d = b / k * k;
    if (a <= d && d <= b) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3104
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a==0 && b==0) break;
			b -= a;
			int x, y, z;
			z = b/1000;
			b %= 1000;
			y = b/500;
			b %= 500;
			x = b/100;
			System.out.println(x + " " + y + " " + z);
		}
	}	
}

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

#define double long double

const int EPS = 1e-9;
int n;
vector<double> A;
double pd[3000][1500];
double ans=0.0;
double dp(int id,int q,double val){
	if(id==n) return 1.0;
	if(fabs(pd[id][q])>EPS)
		return pd[id][q];
	double n_esc = A[id]*dp(id+1,q,val*A[id]);
	if(q){
		double esc = (1.0-A[id])*dp(id+1,q-1,(1.0-A[id])*val);
		return pd[id][q]= esc+n_esc;
	}
	return pd[id][q]= n_esc;
}

int32_t main(){
	cin >> n;
	A = vector<double> (n);
	for(auto &a:A) cin >> a;
	int q = (n%2==0)?((n/2)-1):(n/2);
	cout << fixed << setprecision(10) << dp(0,q,1.0) << '\n';
	
}

Measured memory_bytes: 69248
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 0;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	int h = read(), w = read();
	int x = read(), y = read();
	cout << h * w - x * w - y * h + x * y << endl;
}

Measured memory_bytes: 256
import java.util.PriorityQueue;
import java.util.Scanner;

/**
 * Powerful Discount Tickets
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int M = sc.nextInt();

            PriorityQueue<Integer> queue = new PriorityQueue<>((o1, o2) -> Integer.compare(o2, o1));

            for (int i = 0; i < N; i++) {
                queue.add(sc.nextInt());
            }

            for (int i = 0; i < M; i++) {
                Integer poll = queue.poll();
                if (poll == 0) {
                    break;
                }

                queue.add(poll / 2);
            }

            long ans = 0;
            for (Integer p : queue) {
                ans += p;
            }

            System.out.println(ans);
        }
    }

}


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

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

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;

ll gcd(ll a, ll b) {
	ll temp;
	while (a % b != 0)
	{
		temp = b;
		b = a % b;
		a = temp;
	}
	return b;
}

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

	ll n, x;
	cin >> n >> x;
	vll a(n+1);
	rep(i, n)cin >> a[i];
	a[n] = x;


	if (n == 1) {
		cout << abs(a[0] - x) << endl;
		return 0;
	}

	vll b(n);
	rep(i, n) {
		b[i] = abs(a[i] - a[i + 1]);
	}


	ll ans = b[0];
	rep(i, n) {
		ans = gcd(ans, b[i]);
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 1792