akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n = sc.nextInt();
    static int a = sc.nextInt();
    static int b = sc.nextInt();
    static int c = sc.nextInt();
    static int[] l = new int[n];
    static int min = 100000000;
    public static void main(String[] args) {
        for (int i = 0 ; i < n ; i++) {
            l[i] = sc.nextInt();
        }
        List<Integer> list = new ArrayList<>();
        dfs(list);
        System.out.println(min);
    }

    static void dfs(List<Integer> list) {
        if (list.size() == n) {
            int sum = 0;
            int ac = 0; int bc = 0; int cc = 0;
            int as = 0; int bs = 0; int cs = 0;
            for (int i = 0 ; i < n ; i++) {
                if (list.get(i) == 0) {
                    ac++;
                    as += l[i];
                }
                if (list.get(i) == 1) {
                    bc++;
                    bs += l[i];
                }
                if (list.get(i) == 2) {
                    cc++;
                    cs += l[i];
                }
            }
            if (ac >= 1 && bc >= 1 && cc >= 1) {
                sum += 10 * (ac - 1);
                sum += 10 * (bc - 1);
                sum += 10 * (cc - 1);
                sum += Math.abs(as - a);
                sum += Math.abs(bs - b);
                sum += Math.abs(cs - c);
                min = Math.min(sum, min);
            }
            return;
        }
        for (int i = 0 ; i < 4 ; i++) {
            list.add(i);
            dfs(list);
            list.remove(list.size() - 1);
        }
    }

}

Measured memory_bytes: 26324
#include "bits/stdc++.h"
using namespace std;
#define F first
#define S second
#define show(x) cout<<#x<<" "<<x<<" ";
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define ll long long
#define all(A)  A.begin(),A.end()  
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
const int MSIZE = 3e3+5;
const int MOD = 1e9+7;

vector<vector<int>> g;

int dfs(int x, vector<int> & len) {
    len[x] = 0;
    for(int& y: g[x]) 
        len[x] = max(len[x], 1+(len[y]==-1?dfs(y,len):len[y]));
    return len[x];
}


int main(){
    FIO
    int n, m;   cin>>n>>m;
    g.resize(n+1);
    f(i,0,m-1) {
        int x,y; cin>>x>>y;
        g[x].push_back(y);
    }
    vector<int> len(n+1,-1);

    f(i,1,n)  if(len[i]==-1)  dfs(i,len);

    cout<<*max_element(all(len))<<endl;

    return 0;

}
    


Measured memory_bytes: 8192
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 1987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

int n;
int a[100001];
int main(){
	scanf("%d",&n);
	fup(i,0,n-1,1)scanf("%d",a+i);
	sort(a,a+n);reverse(a,a+n);
	fup(i,1,n,1)
	{
		if(a[i]<=i)
		{
			int k=0;
			while(a[i+k]==i)k++;
			if(k&1 || (a[i-1]-i)&1)puts("First");
			else puts("Second");
			return 0;
		}
	}
}

Measured memory_bytes: 640
module ABC101

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_A

  ! constants for this <module>
  integer, parameter, private :: len_given_string = 4

  ! variables for this <module>
  character(len=len_given_string, kind=1), private :: given_string
  integer,                                 private :: integer_target

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_A

    ! variables for this <subroutine>
    integer :: iter

    ! STEP.01
    ! initialize the integer which Mr.Takahashi remembers
    integer_target = 0

    ! STEP.02
    ! read out the given string
    read(unit=INPUT_UNIT, fmt='(A)') given_string

    ! STEP.03
    ! update the target integer
    do iter = 1, len_given_string, 1
      if (given_string(iter:iter) .eq. '+') integer_target = integer_target + 1
      if (given_string(iter:iter) .eq. '-') integer_target = integer_target - 1
    end do

    ! STEP.04
    ! output the target integer
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') integer_target

    ! STEP.END
    return

  end subroutine task_A

end module ABC101


program main

  ! <module>s to import
  use, non_intrinsic :: ABC101

  ! require all variables to be explicitly declared
  implicit none

  call task_A

end program main

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

void solve(long long a, long long b, long long x)
{
    double S = (double)x / a;
    double rad;
    if (S >= a * b / 2)
    {
        double h = (a * b - S) * 2 / a;
        rad = atan2(h, a);
    }
    else
    {
        double w = S * 2.0 / b;
        rad = atan2(b, w);
    }
    double deg = rad_to_deg(rad);
    printf("%.10f\n", deg);
}

int main()
{
    long long a;
    scanf("%lld", &a);
    long long b;
    scanf("%lld", &b);
    long long x;
    scanf("%lld", &x);
    solve(a, b, x);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

// 1_indexed
class BIT {
private:
    int n;
    vector<ll> a;
public:
    BIT(int _n);
    void add(int idx, ll v);
    ll sum(int i);
    ll sum(int i, int j);
    ~BIT();
};

BIT::BIT(int _n) {
    n = _n;
    a.assign(n+1, 0ll);
}

void BIT::add(int idx, ll x) {
    while (idx <= n) {
        a[idx] += x;
        idx += (idx & -idx);
    }
}

ll BIT::sum(int i) {
    ll ret = 0;
    while (i > 0) {
        ret += a[i];
        i -= (i & -i);
    }
    return ret;
}

ll BIT::sum(int i, int j) {
    ll l = sum(i-1);
    ll r = sum(j);
    return r-l;
}

BIT::~BIT() {
}

typedef tuple<int, int, int> T;

int main(int argc, char const *argv[]) {
    int n,Q; cin>>n>>Q;
    vector<int> a(n);
    vector<T> q;
    rep(i,n) cin>>a[i];
    rep(i,Q) {
        int l,r; cin>>l>>r;
        q.emplace_back(l,r,i);
    }

    sort(q.begin(), q.end(), greater<>());

    vector<int> ans(Q);
    vector<int> bucket(500500, -1);
    BIT ft(n);
    int L = n-1;
    for (auto&& [l, r, idx] : q) {
        l--;
        for (int i = L; i >= l; --i) {
            if (bucket[a[i]] == -1) {
                bucket[a[i]] = i+1;
            }
            else if (bucket[a[i]] != i+1) {
                ft.add(bucket[a[i]], 1ll);
                bucket[a[i]] = i+1;
            }
        }
        L = l;
        ll tmp = r-l;
        tmp -= ft.sum(l,r);
        ans[idx] = tmp;
    }

    for (auto &&e: ans) cout << e << '\n';
    return 0;
}

Measured memory_bytes: 19404
stringer = list("abcdefghijklmnopqrstuvwxyz")
strings = raw_input()

std = list(strings)

std.sort()
lister = {}

for j in range(len(stringer)):
    lister[stringer[j]]=0


for i in range(len(std)):
    count = lister[std[i]]
    lister[std[i]] = count + 1


hiter=0
for m in stringer:
    data = lister[m]
    if data == 0:
        hiter = m
        break

if hiter==0:
    print("None")
else:
    print(hiter)


Measured memory_bytes: 6608
w,b=map(int,input().split())
w-=1
b-=1
black_base=[["#"]*100 for _ in range(50)]
white_base=[["."]*100 for _ in range(50)]

for i in range(25):
	for j in range(25):
		if not w:
			break
		black_base[2*i][j*2]="."
		w-=1
	else:
		continue
	break

for i in range(25):
	for j in range(25):
		if not b:
			break
		white_base[2*i+1][2*j]="#"
		b-=1
	else:
		continue
	break

print(100,100)
print("\n".join(map("".join,black_base+white_base)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long LL;

template <typename T> inline T read(){
    T sum = 0;
    int fl = 1, ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') fl = -1;
    for(; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
    return sum * fl;
}

const int maxn = 100000 + 5;

int n;
LL h[maxn];
LL dp[maxn];

int main(){
	n = read<int>();
	for(int i = 1; i <= n; i++){
		h[i] = read<LL>();
	}
	dp[2] = abs(h[2] - h[1]);
	for(int i = 3; i <= n; i++){
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	printf("%lld\n",dp[n]);
    return 0;
}

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

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

    if (S == "zyxwvutsrqponmlkjihgfedcba") cout << "-1" << endl;
    else {
        if (S.size() < 26) {
            vector<int> cnt(26);
            for (int i = 0; i < S.size(); i++) cnt[S[i] - 'a']++;
            for (int i = 0; i < 26; i++) {
                if (cnt[i] == 0) {
                    char T = 'a' + i;
                    cout << S + T << endl;
                    break;
                }
            }
        }
        else {
            vector<char> tmp = {S[25]};
            int cnt = 0;
            for (int i = 24; i >= 0; i--) {
                if (S[i] < S[i + 1]) {
                    cnt = i;
                    break;
                }
                tmp.push_back(S[i]);
            }
            sort(tmp.begin(), tmp.end());
            auto itr = upper_bound(tmp.begin(), tmp.end(), S[cnt]);
            cout << S.substr(0, cnt) + tmp[itr - tmp.begin()] << endl;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int Partition(int *,int ,int );

int main() {
  int *A;
  int n;
  int i,j;
  int key; //r
  int x;

  scanf("%d",&n);
  A = (int *)malloc(n * sizeof(int));
  for(i=0;i<n;i++) scanf("%d",&A[i]);

  j=Partition(A,0,n-1);
  /*ここで返ってくるjはkeyの座標点*/
  
  for(i=0;i<n-1;i++) {
    if(i==j) printf("[%d] ",A[i]);
    else printf("%d ",A[i]);
  }
  printf("%d\n",A[n-1]);
  
  return 0;
}

int Partition(int *A,int p,int r) {
  int key; //x
  int i,j;
  int tmp;
  key = A[r];
  i=p-1;
  for(j=p;j<r;j++) {
    if(A[j] <= key) {
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;
  return i+1;
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, X; cin >> n >> X;
    vi a(n); for(auto& e : a) cin >> e, X -= e;
    sort(_all(a));

    cout << n + X / a[0] << endl;

    return 0;
}


Measured memory_bytes: 256
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)

if (a+b)>(b+c) and (c+a) >(b+c):
    print(b+c)
elif (b+c)>(a+b) and (c+a)>(a+b):
    print(a+b)
else:
    print(c+a)


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

#define endl '\n'

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
}
 
int main(int argc,char* argv[]) { 
    io() ;
    #ifndef ONLINE_JUDGE
        //freopen("inp.txt", "r", stdin) ;
        // freopen("out.txt", "w", stdout);
    #endif
    int co = 0 , ce = 0 ;
    int n ;
    cin >> n ;
    for(int i = 1 ; i <= n ; i++){
        int a ;
        cin >> a ;
        if(a&1) co++ ;
        else ce = 1 ;
    }
    if(co > 1) ce = 1 ;
    co = co&1  ;
    if(co) cout << "NO\n" ;
    else cout << "YES\n" ;
    return 0 ; 
}

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

int main(){
	ll n,p;
	cin >> n>>p;
	ll ans = 1;
	// factor
	ll a=2;

	if (n==1) {
		cout << p << endl;
		return 0;
	}
	while (p>=a*a) {
		if (p%a == 0) {
			ma[a]++;
			p/=a;
		} else {
			a++;
		}
	}
	if (p!=1) {
		ma[p]++;
	}

	for (auto &num : ma) {
		while (num.second >= n) {
			ans *= num.first;
			num.second -= n;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y, z; cin >> x >> y >> z; x -= z;
    cout << x/(y+z);
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

int calc(int[] xs) {
    int[int] d;
    for (int i = 0; i < xs.length; i++) {
        int x = xs[i];
        d[x - 1]++;
        d[x]++;
        d[x + 1]++;
    }

    int ans = 0;
    foreach (k, v; d) {
        ans = max(ans, v);
    }
    return ans;
}

void main() {
    readint;
    auto xs = readints;
    writeln(calc(xs));
}


Measured memory_bytes: 9276
n = int(input())
dic = {}
mod = 10**9 +7

def pf(x,dic):
    done = set()
    for i in range(2,x+1):
        if i in done:
            continue
        if x%i==0:
            count =1
            done.add(i)
            while (count+1)*i<=x:
                count +=1
                done.add(count*i)
            count = 1
            while x%(i**(count+1))==0:
                count +=1
                
            if i in dic:
                dic[i] +=count
            else:
                dic[i] =count

for j in range(2,n+1):
    pf(j,dic)
ans = 1
for value in dic.values():
    ans = ans*(1+value)%mod
print(ans)

Measured memory_bytes: 3064
from collections import defaultdict
N,P=map(int,input().split())
S=input()

if P==2 or P==5:
    ans=0
    for i in range(N):
        if int(S[i])%P==0:
            ans+=i+1
    print(ans)

else:
    d=defaultdict(int)
    a=0
    for i in range(N):
        a+=int(S[N-i-1])*pow(10,i,P)
        a%=P
        d[a]+=1
    ans=d[0]
    for v in d.values():
        ans+=v*(v-1)//2
    print(ans)
    


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

int main() {
  long long w, h, x, y;
  cin>>w>>h>>x>>y;

  double area = w * h / 2.0;
  if (w == 2 * x && h == 2 * y) {
    printf("%.9lf 1", area);
  } else {
    printf("%.9lf 0", area);
  }
}

Measured memory_bytes: 256
import math

n, m = map(int, input().split())
max_i = 1
for i in range(1, int(math.sqrt(m)) + 1):
    if m % i != 0:
        continue
    j = m // i
    if i * n <= m and i > max_i:
        max_i = i
    if j * n <= m and j > max_i:
        max_i = j
print(max_i)


Measured memory_bytes: 3060
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

a,b = imap()
amin,mod = divmod(a*100, 8)
if mod: amin += 1
amax,mod = divmod((a+1)*100, 8)
if mod: amax += 1
bmin,bmax = b*10, (b+1)*10
ran = set(range(amin,amax)) & set(range(bmin,bmax))
ans = min(ran) if ran else -1
print(ans)


Measured memory_bytes: 20236
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, D = mapint()
ans = 0
for _ in range(N):
    x, y = mapint()
    if x**2+y**2<=D**2:
        ans += 1

print(ans)

Measured memory_bytes: 68716
#include <stdio.h>

int main(void){
	char str[15];
	int i = 0;
	while((str[i] = getchar()) != '\n'){
		if(str[i] == 'B' && i != 0){
			i--;
			str[i] = '\0';
			continue;
		}else if(str[i] == 'B')continue;
		i++;
	}
	str[i] = '\0';
	printf("%s\n", str);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
#define MAX_N 200005
#define M 2019

int main() {
	string s;
	cin >> s;
	ll cnt=0;
	ll mod[M];
	rep(i,M)mod[i] = 0;
	for(int i=0;i<s.size();i++){
		ll mod2[M];
		rep(j,M)mod2[j] = 0;
		int d = stoi(s.substr(i,1));
		rep(j,M){
			if(mod[j]>0){
				int target = j*10 + d;
				mod2[target%M] = mod[j];
			}
		}
		mod2[d] += 1;
		cnt += mod2[0];
		rep(j,M)mod[j] = mod2[j];
	}
	cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);    
#define f(i,j,k)  for(int i=j;i<k;i++)
#define fr(i,j,k) for(int i<=k-1;i>=j;i--)
#define ll long long
#define ld long double

using namespace std;

int main()
{
	fio
	int TC;
	TC=1;
	while(TC--)
	{
		int n,r;
		cin>>n>>r;
		if(n>=10)
			cout<<r<<endl;
		else
		{
			int inner = r+100*(10-n);
			cout<<inner<<endl;
		}


	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN = 2e5 + 5;
const int mod = 1e9 + 7;

ll gcd(ll a,ll b){ return b? gcd(b,a%b): a;}

inline ll pw(ll a,int b)
{
	ll res=1;
	while(b)
	{
		if(b&1) res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}

map<pll,int> t;

int main(void)
{
	int n;
	scanf("%d",&n);
	int cnt=0;
	for(int i=1; i<=n; ++i)
	{
		ll a,b;
		scanf("%lld%lld",&a,&b);
		
		if(!a && !b){ ++cnt; continue;}
		if(a && !b) a=1;
		if(b && !a) b=1;
		if(a && b)
		{
			ll tmp = gcd(a,b);
			a/=tmp; b/=tmp;
		}
		
		if(a<0) a=-a, b=-b;
		
		++t[make_pair(a,b)];
	}
	
	ll ans = 1;
	for(map<pll,int>::iterator it = t.begin(); it!=t.end(); ++it)
	{
		ll a = it -> first.first;
		ll b = it -> first.second;
		int x = it -> second;
		
		ll aa=-b, bb=a;
		if(aa<0) aa=-aa, bb=-bb;
		
		if(aa==a && bb==b) ans = ans * (x + 1) %mod;
		else
		{
			int y = t[make_pair(aa,bb)];
			t.erase(make_pair(aa,bb));
			
			ans = ans * (pw(2,x) + pw(2,y) - 1 + mod) %mod;
		}
	}
	
	ans = (ans + cnt -1 + mod) %mod;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 15744
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int cnt=0;
        if(a==5) cnt++;
        if(b==5) cnt++;
        if(c==5) cnt++;
        if(a+b+c==17 && cnt==2)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 x;
  cin >> x;
  Yes(x >= 30);
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;


int main()
{
    int N;
    vector<int> A = {};

    cin >> N;


    for (int i = 0; i < N; i++)
    {
        int bufA;
        cin >> bufA;
        A.push_back(bufA);
    }

    bool flag = false;
    int a, b;
    
    sort(A.begin(), A.end(), greater<int>());

    for (int i = 0; i < N-1; i++)
    {
        a = A[i];
        b = A[i + 1];
        if (a == b)
            flag = true;
    }

    if (flag)
        cout << "NO";

    if (!flag)
        cout << "YES";

    system("pause");
    return 0;
}

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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int,int>;
using ppa = pair<pa,int>;
#define SORT(v, n) sort(v, v+n);
#define ALL(v) v.begin(),v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v),greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)),v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (b-1); i >= a; i--)
#define rrep(i,n) RFOR(i,0,n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a,b) a = min(a,b)
#define maxs(a,b) a = max(a,b)

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

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

const ll MOD = 1000000007;

ll pow_mod(ll a,ll b,ll mod){
    ll tmp = 1;
    a %= mod;
    if(b > 0){
        tmp = pow_mod(a, b/2, mod);
        if(b % 2) tmp = (((tmp*tmp)%mod)*a)%mod;
        else tmp = (tmp*tmp)%mod;
    }
    return tmp;
}

int mm = 1000000;
vector<bool> d(mm);

void hoge(){
    d[0] = d[1] = true;
    FOR(i,2,mm){
        if(d[i]) continue;
        for(int j = 2; i*j <= mm; j++){
            d[i*j] = true;
        }
    }
}

void solve() {
    vector<int> dp(mm,INF);
    int val;
    int m = 2;
    dp[0] = dp[1] = 0;
    hoge();
    while(cin >> val){
        if(dp[val] == INF){
            FOR(i,m,val+1){
                dp[i] = dp[i-1] + (!d[i] ? 1 : 0);
            }
            m = val;
        }
        cout << dp[val] << endl;
    }
}

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

    solve();

    return 0;
}

Measured memory_bytes: 6600
#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() {
	int N;
	cin >> N;
	if (N % 2)
		cout << N / 2 + 1 << endl;
	else
		cout << N / 2 << endl;
}


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

int main() {
	int H, W; cin >> H >> W;
	int n=1, l=0;
	string S;
	while(S!="snuke"){
	    cin >> S;
	    if(l<W) ++l;
	    else{
	        l=1;
	        ++n;
	    }
	}
	char p='A'+l-1;
	cout << p << n << endl;
	return 0;
}


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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  reverse(a,a+n);
  ll cmin = a[0];
  ll num = 1;
  ll ans = 0;
  rep1(i,n-1){
    if(cmin < n) break;
    ll dif = cmin - a[i];
    ll cnt_op = dif/(n+1);
    ll dec = (n - num + 1) * cnt_op;
    ll inc = num * cnt_op;
    rep(j,n){
      if(j<i) a[j] -= dec;
      else a[j] +=inc;
    }
    ans += cnt_op *num;
    // rep(j,n) cout << a[j] << " ";    
    // cout << endl;
    cmin = a[i];
    num++;
  }
  if(a[n-1]>=n){
    ans +=(a[n-1] - n)*n;
    rep(i,n){
      a[i] -= a[n-1] - n;
    }
  }
  // rep(j,n) cout << a[j] << " "; 
  // cout << endl;
  int idx_cmax = 0;
  while(a[idx_cmax]>=n){
    int nidx = idx_cmax;
    int nv = -1;
    rep(i,n){ 
      if(i==idx_cmax) a[i] -=n;
      else a[i]++;
      if(nv < a[i]){
        nidx = i;
        nv = a[i];
      }
    }
    idx_cmax = nidx;
    ans++;
  }
  cout << ans << endl;
  

  return 0;
    

}


Measured memory_bytes: 3616
"use strict";

function main(input) {
  input = input.split(/\s/).reduce((a, b) => a + b);
  const sqrt = Math.sqrt(input);
  let ans = sqrt == Math.round(sqrt) ? "Yes" : "No";
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 22084
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

int popcount(int x) {
  int a = 0;
  while (x > 0) {
    if (x & 1) a++;
    x >>= 1;
  }
  return a;
}

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

  int n;
  cin >> n;
  vector<int> a(n);
  vector<vector<int> > x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    x[i] = vector<int>(a[i]);
    y[i] = vector<int>(a[i]);
    for (int j = 0; j < a[i]; j++) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }

  int maximum = 0;
  for (int i = 0; i < (1 << n); i++) {
    int c = popcount(i);
    if (c <= maximum) continue;
    vector<bool> honest(n);
    int m = i;
    int p = 0;
    while (m > 0) {
      if (m & 1) honest[p] = true;
      m >>= 1;
      p++;
    }
    bool ok = true;
    for (int j = 0; j < n; j++) {
      if (honest[j]) {
        for (int k = 0; k < a[j]; k++) {
          bool isHonest = y[j][k];
          if (honest[x[j][k]] != isHonest) {
            ok = false;
            break;
          }
        }
      }
      if (!ok) break;
    }
    if (!ok) continue;
    else maximum = c;
  }

  cout << maximum << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    ll n;cin>>n;
    vector<ll> sq;
    for(ll i=1;i<=100000;i++) sq.push_back(i*i);
    auto itr=upper_bound(sq.begin(),sq.end(),n);
    itr--;
    cout<< *itr<<endl;
}


Measured memory_bytes: 1400
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n,hit;
    while(cin>>n,n){
        int sum=0;
        for(int i=0;i<n/4;i++){
                cin>>hit;
                sum+=hit;
        }
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a.at(i);
    }

    int cnt = 0;
    rep(i,n){
        if((i+1)%2!=0 && a.at(i)%2!=0) cnt++;
    }

    cout << cnt << endl;
    return 0;
}


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

int main(void){
    // Your code here!
   string s;
   cin >> s;
   int cnt = 0;
   if(s.at(0) == '1') cnt++;
   if(s.at(1) == '1') cnt++;
   if(s.at(2) == '1') cnt++;
   cout << cnt << endl;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {

	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	printyn(!(a xor b) + !(b xor c) + !(c xor a) == 1);
	
	Please AC;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner in= new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
	String s = "";

	if (a > b)
		s = "a > b";
	else if (a < b)
		s = "a < b";
	else
		s = "a == b";
        System.out.printf("%s%n", s);
    }   
}

Measured memory_bytes: 17296
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX1 100006
#define f first
#define s second
#define pi 2*acos(0.0)
void solve()
{
    ll n,last=0,ans=0,x;  cin>>n;
    rep(i,0,n) 
    {
        cin>>x;
        if(x>=last) last=x;
        else ans+=(last-x);
    }cout<<ans;
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt","r",stdin);
    //for getting error from error.txt
    freopen("error.txt", "w", stderr);
    // for writing output to output.txt
    freopen("output.txt","w",stdout);
    #endif
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<"\n";
    cerr<<"My CLOCKS_PER_SEC= "<<CLOCKS_PER_SEC<<"\n";
    return 0;
}


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

#define MAXINF 1000000005
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repc(it, x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rrepc(it, x) for(auto it = (x).rbegin(); it != (x).rend(); ++it)
#define all(x) (x).begin(), (x).end()
#define P pair<int, int>

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

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

	int s0 = 0, s1 = 0, s2 = 0, s3 = 0;
	string word;

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

		if (word == "AC") {
			s0 += 1;
		}
		else if (word == "WA") {
			s1 += 1;
		}
		else if (word == "TLE") {
			s2 += 1;
		}
		else {
			s3 += 1;
		}
	}
	cout << "AC x " << s0 << endl;
	cout << "WA x " << s1 << endl;
	cout << "TLE x " << s2 << endl;
	cout << "RE x " << s3 << endl;
}

Measured memory_bytes: 3540
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int j,s,i=1;
	char a,b[10001];
	while(1)
	{
		scanf("%c",&a);
		s=a;
		if(s==10)
			break;
		if(s>=68&&s<=90)
			b[i]=s-3;
		else
		{
			if(s==65)
			{
				s=88;
				b[i]=s;
			}
			if(s==66)
			{
				s=89;
				b[i]=s;
			}
                        if(s==67)
			{
				s=90;
				b[i]=s;
			}
		}
		i++;
	}
	for(j=1;j<=i-1;j++)
	{
		cout<<b[j];
	}
	cout<<endl;
	return 0;
} 

Measured memory_bytes: 3156
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextLine() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(nextLine())
	if e != nil {
		panic(e)
	}
	return i
}

// for large string > 64*1024
var reader = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func scanNums(len int) (nums []int) {
    var num int
    for i := 0; i < len; i++ {
        num = nextInt()
        nums = append(nums, num)
    }
    return
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func sumSlice(x[]int) int {
	sum := 0
	for _, n := range x{
		sum += n
	}
	return sum
}

func main() {
	scanner.Split(bufio.ScanWords) // switch to separating by space
	N := nextInt()
	nums := scanNums(N)

	sum := sumSlice(nums)
	total := 0

	for _, n := range nums{
		total += (sum-n)*n
	}
	total /= 2

	fmt.Println(total)
}


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

ww = [input() for _ in range(n)]
# print(ww)

for i,w in enumerate(ww[:-1]):
    if ww[i][-1] != ww[i+1][0] or ww.count(w)>1:
        print('No')
        # print(w)
        break
else:
    print('Yes')

Measured memory_bytes: 3060
debt = 100000

n = STDIN.gets.chomp!.to_i

n.times do
  debt *= 1.05
  if debt % 1000 != 0 then
    debt = ((debt / 1000).to_i+1) * 1000
  else
    debt = debt.to_i
  end
end

puts debt.to_i

Measured memory_bytes: 8680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);



int main(){
	set<ll> se;
	ll n;
	cin >> n;
	FOR(i,0,n){
		ll a;
		cin >> a;
		se.insert(a);
	}
	if(se.size()==n){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}



Measured memory_bytes: 9600
#include<iostream>
using namespace std;
int main(void){
    int n,m,l,i,j,k;
    long a[100][100],b[100][100],c[100][100];
    for (i=0;i<100;i++){
        for (j=0;j<100;j++){
            a[i][j]=0;
            b[i][j]=0;
            c[i][j]=0;
        }
    }
     
    cin >> n >> m >> l;
     
    for (i=0;i<n;i++){
        for (j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
     
    for (i=0;i<m;i++){
        for (j=0;j<l;j++){
            cin >> b[i][j];
        }
    }
     
    for (i=0;i<n;i++){
        for (j=0;j<l;j++){
            for (k=0;k<m;k++){
                c[i][j] = c[i][j]  + (a[i][k] * b[k][j]);
            }
        }
    }
     
    for (i=0;i<n;i++){
        for (j=0;j<l;j++){
            if(j==l-1){
                cout << c[i][j] << endl;
            }else{
                cout << c[i][j] << " ";
            }
        }
    }
}


Measured memory_bytes: 3352
import collections

# 素因数分解の結果を返す
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())
res = collections.Counter(prime_factorize(N)) # Counter({2: 4, 3: 1})
keys = list(res.keys()) # [2, 3]
length = len(keys)
ans = 0

# 因数に関する処理
for i in range(length):
    num = keys[i] # 因数
    beki = res[num] # 因数numの個数
    temp = 1
    while(beki >= temp):
        beki -= temp
        ans += 1
        temp += 1
print(ans)

Measured memory_bytes: 65908
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int pay=sc.nextInt();
		int num=sc.nextInt();
		
		if(num>=pay%500) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 22100
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    string s;
    int k;
    cin >> s >> k;
    vector<int> n;
    for (auto a : s) n.push_back(a - '0');
    int l = n.size();

    vector<vector<vector<int64>>> dp(l+1, vector<vector<int64>>(2, vector<int64>(5,0)));

    dp[0][0][0] = 1;  //初期条件。他は0で初期化されている
    for(int64 i = 0; i < l; i++){
        for(int64 smaller = 0; smaller < 2; smaller++){
            for(int64 j = 0; j <= 3; j++){
                for(int64 x = 0; x<= (smaller ? 9 : n[i]); x++){
                    dp[i + 1][smaller || x < n[i]][j + (x!=0? 1 : 0)] += dp[i][smaller][j];
                }
            }
        }
    }

//    for (int64 i=0; i<=l; i++) {
//        cerr << i << " " ;
//        debug(dp[i]);
//    }

    cout << dp[l][0][k] + dp[l][1][k] << endl;
}

Measured memory_bytes: 256
import sys
from collections import deque

if __name__ == "__main__":
    k = int(input())

    d = deque()

    for i in range(1, 10):
        d.appendleft(i)
    
    ans = 0

    for _ in range(k):
        ans = d.pop()

        if ans % 10 != 0:
            d.appendleft(10 * ans + ans % 10 - 1)
        d.appendleft(10 * ans + ans % 10)
        if ans % 10 != 9:
            d.appendleft(10 * ans + ans % 10 + 1)
    print(ans)

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

using ll=long long;

int main(){
    int A, B, C, D; cin >> A >> B >> C >> D;
    int cnt=0;
    bool ans1=false, ans2=false;
    while(1){
        if(cnt%2 == 0) C-=B;
        else A-=D;
        cnt++;
        if(C <= 0) ans1=true;
        if(A <= 0) ans2=true;
        if(ans1 || ans2) break;
    }
    if(ans1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
local sub = string.sub
s = io.read()

local function solve()
	local n = 0
	local left = 0
	for i = 1, #s do
		local c = sub(s, i, i)
		if c == "S" then
			left = left + 1
		elseif left > 0 then
			left = left - 1
			n = n + 2
		end
	end
	return #s - n
end
print(solve())

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


int main()
{
  int H,W;
  cin >> H >> W;

  vector<int> black;
  vector<int> black_new;
  vector<int> cell;

  string s;

  int n_black=0;
  
  for(int irow=0; irow<H; ++irow){
    cin >> s;
    for(int icol=0; icol<W; ++icol){      
      if (s[icol]=='#'){
        black.push_back(icol);
        black.push_back(irow);
        cell.push_back(1);
        n_black+=1;
      }else{
        cell.push_back(0);
      }
    }
  }

  int n_operation=0;
  while(n_black!=H*W){
    n_operation++;
    
    for(int ib=0; ib<black.size()/2; ++ib){
      int bx = black[ib*2];
      int by = black[ib*2+1];

      if(bx-1>=0 && cell[W*by+bx-1]==0){ 
        black_new.push_back(bx-1);
        black_new.push_back(by);
        cell[W*by+bx-1]=1;
        n_black+=1;
      }
      if(bx+1<W && cell[W*by+bx+1]==0){ 
        black_new.push_back(bx+1);
        black_new.push_back(by);
        cell[W*by+bx+1]=1;
        n_black+=1;
      }
      if(by-1>=0 && cell[W*(by-1)+bx]==0){ 
        black_new.push_back(bx);
        black_new.push_back(by-1);
        cell[W*(by-1)+bx]=1;
        n_black+=1;
      }
      if(by+1<H && cell[W*(by+1)+bx]==0){ 
        black_new.push_back(bx);
        black_new.push_back(by+1);
        cell[W*(by+1)+bx]=1;
        n_black+=1;
      }
    }

    black.clear();
    for(int i=0; i<black_new.size(); ++i)
      black.push_back(black_new[i]);
    black_new.clear();
  }
    

  cout << n_operation << endl;
  
  return 0;
}


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

using namespace std;

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

int main(void){
    bool isOk = false;
    int N = 0;
    int M = 0;
    int points = 0;

    cin >> N >> M;

    int A[N];

    rep(i, N){
        cin >> A[i];
        points += A[i];
    }

    /* 閾値をつくる */
    int check = points / (4 * M);
    if(points % (4 * M) != 0){
        check++;
    }

    /* 選べる商品の数をかぞえる */
    int ok = 0;
    for(int cnt = 0; cnt < N; cnt++){
        if(A[cnt] >= check){
            ok++;
        }
    }

    if(ok >= M){
        isOk = true;
    }else{
        isOk = false;
    }

    if(isOk){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256