akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

//reference to isikado
public class Main{
	Scanner sc = new Scanner(System.in);
	double r = 6378.1;
	double PI = Math.PI;
	
	class P3D{
		double [] p;
		public P3D(double[] p) {
			this.p = new double[3];
			for(int i =0; i < 3; i++){
				this.p[i] = p[i];
			}
			this.p = p;
		}
	}
	
	private double distance3D(P3D p1, P3D p2) {
		double res = 0;
		for(int i = 0; i < 3; i++){
			res += (p1.p[i] - p2.p[i]) * (p1.p[i] - p2.p[i]);
		}
		return Math.sqrt(res);
	}
	
	private void doit() {
		while(true){
			double a = sc.nextDouble();
			double b = sc.nextDouble();
			double c = sc.nextDouble();
			double d = sc.nextDouble();
			if(a == -1 && b == -1 && c == -1 && d == -1) break;
			double [][] rad = new double[2][2];
			rad[0][0] = a / 180 * PI;
			rad[0][1] = b / 180 * PI;
			rad[1][0] = c / 180 * PI;
			rad[1][1] = d / 180 * PI;
			P3D [] p = new P3D[2];
			for(int i = 0; i < 2; i++){
				double x = r * Math.cos(rad[i][0]) * Math.cos(rad[i][1]);
				double y = r * Math.cos(rad[i][0]) * Math.sin(rad[i][1]);
				double z = r * Math.sin(rad[i][0]);
				p[i] = new P3D(new double[]{x,y,z});
			}
			double dis = distance3D(p[0], p[1]);
			double deg = calc(dis);
			double ans = deg / 180 * r * PI;
			System.out.printf("%.0f\n", ans);
		}
	}

	private double calc(double dis) {
		double rr = r * r;
		double cos = (rr + rr - dis * dis) / (2 * rr); 
		double res = Math.toDegrees(Math.acos(cos));
		return res;
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
}

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

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int N;
	
	cin >> N;
	
	if(N%10 == 9 || N/10 == 9)
		cout << "Yes";
	else
		cout << "No";
	
	return 0;
}

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

using namespace std;

int main() {
  int n;
  while (cin >> n, n) {
    vector<int> vec(n);

    for (auto &v : vec)
      cin >> v;

    int cnt = 0;
    while (true) {
      vector<int> stat(101, 0);
      for (auto &v : vec)
        ++stat[v];

      vector<int> vec2(n, 0);
      for (int i = 0; i < n; ++i)
        vec2[i] = stat[vec[i]];

      if (vec == vec2)
        break;
      vec = vec2;
      ++cnt;
    }

    cout << cnt << endl;
    cout << vec[0];
    for (auto itr = vec.begin() + 1; itr != vec.end(); ++itr)
      cout << " " << *itr;
    cout << endl;
  }
}


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

int main(void) {
	int N;
	scanf("%d", &N);
	double ans = 0;
	for (int i = 0; i < N; i++) {
		double u;
		scanf("%lf", &u);
		string x;
		cin >> x;
		if (x == "JPY") ans += u;
		else ans += u * 380000;
		// cout << ans << "\n";
	}
	printf("%lf\n", ans);
	return 0;
}


Measured memory_bytes: 3824
<?php

$n = trim(fgets(STDIN));
$arr = array_map('intval', explode(" ", trim(fgets(STDIN))));

$check = 1;
$cnt = 0;
foreach ($arr as $d) {
    if ($d == $check) {
        // 目的の数字を見つけたらそれ以降の値のチェック数字をインクリメント
        $check++;
    } else {
        // 目的の数字じゃないなら砕く
        $cnt++;
    }
}

// 全部砕いちゃったら条件達成できないので-1
if ($cnt == count($arr)) {
    $cnt = -1;
}

echo $cnt."\n";

Measured memory_bytes: 27120
#include<bits/stdc++.h>
using namespace std;
typedef long long lt;
typedef double dd;
#define eps 1e-6
#define sqr(x) ((x)*(x))
 
int read()
{
    int f=1,x=0;
    char ss=getchar();
    while(ss<'0'||ss>'9'){if(ss=='-')f=-1;ss=getchar();}
    while(ss>='0'&&ss<='9'){x=x*10+ss-'0';ss=getchar();}
    return f*x;
}
 
const int maxn=1000010;
int n;
struct point{dd x,y;}p[maxn],O;
dd R;
 
dd getd(point a,point b){ return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));}
point getO(point p1,point p2,point p3)
{
    point res;
    dd a=p2.x-p1.x,b=p2.y-p1.y,c=p3.x-p2.x,d=p3.y-p2.y;
    dd e=sqr(p2.x)+sqr(p2.y)-sqr(p1.x)-sqr(p1.y);
    dd f=sqr(p3.x)+sqr(p3.y)-sqr(p2.x)-sqr(p2.y);
    res.x=(f*b-e*d)/(c*b-a*d)/2.0; 
    res.y=(a*f-e*c)/(a*d-b*c)/2.0;
    return res;
}
 
void mincir()
{
    O=p[1]; R=0;
    for(int i=1;i<=n;++i)
    if(getd(p[i],O)-R>eps)
    {
        O=p[i]; R=0;
        for(int j=1;j<i;j++)
        if(getd(p[j],O)-R>eps)
        {
            O=(point){(p[i].x+p[j].x)/2.0,(p[i].y+p[j].y)/2.0};
            R=getd(p[i],p[j])/2.0;
    
            for(int k=1;k<j;++k)
            if(getd(p[k],O)-R>eps)
            {
                O=getO(p[i],p[j],p[k]);
                R=getd(p[i],O);
            }
        }
    }
} 
 
int main()
{
    n=read();
    for(int i=1;i<=n;++i)
    scanf("%lf%lf",&p[i].x,&p[i].y);
    
    random_shuffle(p+1,p+1+n);
    
    mincir();
    printf("%.7lf",R);
    return 0;
}


Measured memory_bytes: 384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <bitset>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef unsigned long long ull;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int INF = 1 << 27;
//////////////////////////////
// ?????£?????????????§£
void dfs(int v, int *used, vector< vector<int> > &G, vector<int> &vs){
  used[v] = true;
  REP(i, G[v].size()){
    int next = G[v][i];
    if(!used[next]) dfs(next, used, G, vs);
  }
  vs.push_back(v);
}
void rdfs(int v, int cnt, int *used, vector<int> &cmp, vector< vector<int> > &G){
  used[v] = true;
  cmp[v] = cnt;
  REP(i, G[v].size()){
    int next = G[v][i];
    if(!used[next]) rdfs(next, cnt, used, cmp, G);
  }
}
//G????????????????????°???????????£??\????????????RG????????????????????????????????£??\?????????
//?????????????????????????????????????????????????????£?????????????±?????????????cmp[a] == cmp[b]??????????????°a, b???????????????????±??????????
vector<int> scc(int V, vector< vector<int> > &G, vector< vector<int> > &RG){
  int used[V];
  memset(used, 0, sizeof(used));
  vector<int> vs, cmp(V);
  REP(i, V) if(!used[i]) dfs(i, used, G, vs);
  memset(used, 0, sizeof(used));
  int cnt = 0;
  reverse(vs.begin(), vs.end());
  REP(i, vs.size()) if(!used[vs[i]]) rdfs(vs[i], cnt++, used, cmp, RG);
  return cmp;
}

int main() {
	int v, e; cin >> v >> e;
	vector<vi> vvi(v), rvvi(v);
	REP(i, e) {
		int a,b; cin >> a >> b;
		vvi[a].pb(b);
		rvvi[b].pb(a);
	}
	vi ans = scc(v, vvi, rvvi);
	int q; cin >> q;
	while(q--) {
		int a, b; cin >> a >> b;
		cout << (ans[a] == ans[b]) << endl;
	}

	return 0;
}

Measured memory_bytes: 4896
#include<stdio.h>
#include<stdlib.h>
 
int main(int argc,char** argv)
{
	int N, A, B, x, y;
	scanf("%d%d%d", &N, &A, &B);
	A = A * N;
	if(A > B){
		printf("%d\n",B);
	}
	else if(B > A){
		printf("%d\n", A);
	}
	else if(A == B){
		printf("%d\n", A);
	}
	return(0);
 
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    int n,m,k; 
    while (cin >> n >> m >> k) {
        bool good = false;
        for (int i = 0; i < n+1; i++) {
            for (int j = 0; j < m+1; j++) {
                if (i*m + j*n - 2*i*j == k)
                    good = true;
            }
        }
        if (good)
            cout << "Yes" << endl;
        else 
            cout << "No" << endl;
    }
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);

int main()
{
	IOS;
    cout.precision(30);
    int n; cin >> n; vector<ll> A(n+1,0),B(n+1,0);
    for (int i=0;i<=n;i++)
    {
        cin >> A[i];
    }
    for (int i=0;i<n;i++)
    {
        cin >> B[i];
    }
    ll ans=0;
    for (int i=0;i<n;i++)
    {
        ll a=min(B[i],A[i]);
        B[i]-=a;
        ans+=a;
        a=min(B[i],A[i+1]);
        A[i+1]-=a;
        ans+=a;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1792
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias Pair = Tuple!(long, "number", long, "times");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

auto comb = new long[][](2019, 2019);

void calc_comb(long limit)
{
    long times;
    comb[times++][0] = 1;
    comb[times][0] = comb[times][1] = 1;
    while (++times < limit)
    {
        long row;
        while (row <= times)
        {
            if (row == 0)
            {
                comb[times][row] = 1;
                row++;
                continue;
            }

            comb[times][row] = (comb[times - 1][row] + comb[times - 1][row - 1]) % bignum;
            row++;
        }
    }

}

void main()
{
    long n, blue;
    scan(n, blue);
    auto red = n - blue;
    calc_comb(n + 1);
    foreach (i; 1.. blue + 1)
    {
        // comb[red + 1][i].write(" ");
        // comb[blue - 1][i - 1].writeln();
        auto ans = comb[red + 1][i] * comb[blue - 1][i - 1];
        ans %= bignum;
        ans.writeln();
    }
}


Measured memory_bytes: 22908
import sys
input=sys.stdin.readline
n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))
ans = 0
for i in range(q):
    a = T[i]
    for j in range(n):
        if S[j] == a:
            ans += 1
            break
print(ans)
    


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

template<typename T = int, class F = std::plus<T>, class F_INV = std::minus<T>, T E = 0>
struct BinaryIndexedTree {
    const F op = F(); const F_INV op_inv = F_INV();
    int n; vector<T> dat;
    void build(const vector<T>& v) {
        n = v.size(); dat.assign(n, E); for (int i = 0; i < n; ++i) add(i, v[i]);
    }
    void add(int k, T v) { for (int i = k; i < n; i |= i + 1) dat[i] = op(dat[i], v); }
    T query(int a, int b) const {
        T ret = E; if (a == b) return ret;
        for (int i = b - 1; i >= 0; i = (i & (i + 1)) - 1) ret = op(ret, dat[i]);
        return op_inv(ret, query(0, a));
    }
};

struct RangeAddRangeSumQuery {
    int n;
    BinaryIndexedTree<ll> bit0, bit1;
    void build(int n_) {
        n = n_;
        bit0.build(vector<ll>(n + 1));
        bit1.build(vector<ll>(n + 1));
    }
    void range_add(int l, int r, ll x) {
        bit0.add(l, -x * l);
        bit1.add(l, x);
        bit0.add(r, x * r);
        bit1.add(r, -x);
    }
    ll range_sum(int l, int r) {
        return bit0.query(l, r) + r * bit1.query(0, r) - l * bit1.query(0, l);
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> com(q), s(q), t(q), x(q);
    for (int i = 0; i < q; ++i) {
        cin >> com[i] >> s[i] >> t[i];
        if (com[i] == 0) cin >> x[i];
    }

    RangeAddRangeSumQuery rars;
    rars.build(n);

    for (int i = 0; i < q; ++i) {
        if (com[i] == 0) {
            rars.range_add(s[i] - 1, t[i], x[i]);
        }
        else {
            cout << rars.range_sum(s[i] - 1, t[i]) << endl;
        }
    }
}



Measured memory_bytes: 6612
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<cstdlib>
#include<ctime>
#include<climits>
#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 inf 0x3f3f3f3f
#define N 100010
#define M 
using namespace std;

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int n,a[N],f[N][2];

int main(){
  n=read();
  rep(i,1,n) a[i]=read();
  f[1][0]=1;f[1][1]=1;
  rep(i,2,n){
    f[i][0]=f[i][1]=inf;
    if(a[i]>=a[i-1]){
      f[i][0]=min(f[i][0],f[i-1][0]);
      f[i][1]=min(f[i][1],min(f[i-1][0],f[i-1][1])+1);
    }
    if(a[i]<=a[i-1]){
      f[i][0]=min(f[i][0],min(f[i-1][0],f[i-1][1])+1);
      f[i][1]=min(f[i][1],f[i-1][1]);
    }
  }
  printf("%d\n",min(f[n][0],f[n][1]));
  return 0;
}


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

int main(){
    string s;
    cin >> s;
    int ans = 1000 * (s[5] - '0') + 100*(s[6] - '0') + 10 *(s[8] - '0') + (s[9] - '0');
    if(ans <= 430){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }


    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int X = scan.nextInt();

		int []m = new int [N];
		for(int i = 0; i < N; i++) {
			m[i] = scan.nextInt();
		}
		scan.close();
		Arrays.sort(m);
		int res = X;
		for(int i = 0; i < N; i++) {
			res -= m[i];
		}
		int ans = N + res / m[0];
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
K = int(input())
S = input()
L = len(S)

MOD = 10 ** 9 + 7
modinv = lambda a, mod=MOD: pow(a, MOD - 2, mod)

# x: 26^k*25^(K-k)
x = pow(26, K, MOD)

# comb: C(L+K-i-1, L-1)
comb = 1

ans = 0
for i in range(K, -1, -1):
    ans = (ans + comb * x) % MOD
    x = x * 25 * modinv(26) % MOD
    comb = comb * (L + K - i) * modinv(K - i + 1) % MOD
print(ans)


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

int main(){
  
  string S;
  cin >>S;
  int n;
  n = S.size();
  vector<int> ans(n);
  int cnt = 0;
  rep(i,n){
    if(S[i] == 'R')cnt++;
    else{
      ans[i] += cnt/2;
      ans[i-1] += (cnt+1)/2;
      cnt = 0;
    }
  }
  cnt = 0;
  for(int i=n-1;i>=0;i--){
    if(S[i] == 'L')cnt++;
    else{
      ans[i] += cnt/2;
      ans[i+1] += (cnt+1)/2;
      cnt = 0;
    }
  }
  rep(i,n) cout << ans[i] << " ";
  cout << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define pb emplace_back
#define mp make_pair
#define MOD (int) 1e9+7
#define for0(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define endl "\n"
#define bits(n) __builtin_popcount(n)
#define ini(a, i) memset(a, i, sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		ll n;
		cin >> n;
		ll arr[n];
		ll p = 0;
		for (ll i = 0; i < n; i++)
		{
			cin >> arr[i];
			if (arr[i] == 0)
				p = 1;
		}
		if (p == 1)
		{
			cout << "0" << endl;
			return 0;
		}
		// sort(arr, arr + n);
		long double ans = 1;
		for (ll i = 0; i < n; i++)
		{
			// cout << arr[i] * ans << " " << (arr[i] * ans > (ll)1e18) << endl;
			if ((arr[i] * ans) > (ll)1e18)
			{
				cout << "-1" << endl;
				return 0;
			}
			else
				ans = ans * arr[i];
		}
		cout << (ll)ans << endl;
	}
	return 0;
}
//|| (arr[i] * ans) < 0


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

ll n;
int m,q;
int a[125252];

int mp[125252][7];
int dat[125252*7];
void init(){
  REP(i,125252*7)dat[i]=-1;
}
int root(int x){
  return dat[x]<0?x:dat[x]=root(dat[x]);
}
void unite(int a,int b){
  a=root(a);
  b=root(b);
  if(a!=b){
    if(dat[a]>dat[b])swap(a,b);
    dat[a]+=dat[b];
    dat[b]=a;
  }
}

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

int main(){
  scanf("%lld%d%d",&n,&m,&q);
  REP(i,q)scanf("%d",a+i);
  ll u = (m%7==0) ? (m/7) : m;
  ll k = n / u;
  // solve u,m,q
  REP(i,q){
    int v = a[i];
    while(v < 7*u){
      mp[v/7][v%7] = 1;
      v += m;
    }
  }
  init();
  REP(i,u)REP(j,7){
    if(mp[i][j])continue;
    int id = i*7 + j;
    REP(d,4){
      int ni = i+dy[d];
      int nj = j+dx[d];
      if(ni<0 || nj<0 || ni>=u || nj>=7)continue;
      if(mp[ni][nj])continue;
      unite(id,ni*7+nj);
    }
  }
  ll subans = 0;
  REP(i,u)REP(j,7)if(!mp[i][j] && root(7*i+j)==7*i+j)subans++;
  // merge
  set<pii> S;
  REP(i,7){
    if(mp[0][i] || mp[u-1][i])continue;
    int ida = root(i);
    int idb = root(7*(u-1) + i);
    pii P = pii(ida,idb);
    S.insert(P);
  }
  ll yo = S.size();
  ll ans = subans * k - yo * (k-1);
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] KX = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int K = KX[0];
            int X = KX[1];
            
            if(K == 1)
            {
                Console.WriteLine(X);
                return;
            }
            int t = (K - 1);
            int W = X - t;
            int Z = X + t;
            for (int i = W; i <= Z; i++)
            {
                Console.WriteLine(i + " ");
            }

        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
 
int main() {
  int c[3][3];
  rep(i,3){
    rep(j,3){
      cin>> c[i][j];
    }
  }
  int xa[3];
  rep(i,3) xa[i]=c[0][i]+c[1][i]-2*c[2][i];
  int xb[3];
  rep(i,3) xb[i]=c[i][0]+c[i][1]-2*c[i][2];
  if (xa[0]==xa[1]&& xa[1]==xa[2]&& xb[0]==xb[1] && xb[1]==xb[2]){
    cout <<"Yes"<<endl;
    return 0;
  }
  cout <<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>

#define PI 3.14159265359

#define INF 1000000;

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

typedef long long ll;

using namespace std;


/*
class ElectronicPetEasy
{
public:
	string isDifficult(int st1, int p1, int t1, int st2, int p2, int t2)
	{
		
	}
};
*/




int main()
{
	int price, num, item_num = 0, sum = 0, num_sum = 0, average;
	
	while (scanf("%d,%d", &price, &num) != EOF)
	{
		sum += price * num;
		num_sum += num;
		//cout << "num_sum = " << num_sum << endl;
		item_num++;
	}
	average = 1.0 * num_sum / item_num + 0.5;
	
	cout << sum << endl << average << endl;
	
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
long long N,Q;
cin>>N>>Q;
long long a,b;
vector<vector<long long>> v(N);
for(long long i=1;i<N;++i){
  cin>>a>>b;
  a--;
  b--;
  v[a].push_back(b);
  v[b].push_back(a);
}
long long X[N]={};
long long p,x;
for(int i=0;i<Q;++i){
  cin>>p>>x;
  p--;
  X[p]+=x;
}
//初期条件input
long long ans[N]={};
long long check[N]={};
ans[0]=X[0];
check[0]=1;
priority_queue<long long> que;
que.push(0);
long long num,target;
while(!que.empty()){
  num=que.top();
  que.pop();
  for(int j=0;j<v[num].size();++j){
    target=v[num][j];
    //すでに行ったことあればskip
    if(check[target]==1){
      continue;
    }
    else{
      check[target]=1;
    }
    ans[target]=ans[num]+X[target];
    que.push(target);
  }
}
for(int i=0;i<N;++i){
  cout<<ans[i]<<" ";
}
return 0;
}

Measured memory_bytes: 21104
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

unordered_map<ll,ll> m;

void soi(ll n){
    for (int i = 1; i <= (int)sqrt(n); i++) {
        if(n%i==0){
            if(i!=n/i){
                m[i]++;
                m[n/i]++;
            }else{
                m[i]++;
            }
        }
    }
    return;
}

int main() {
    ll n;
    ll a[200010];
    // 1-indexed!
    std::cin >> n;
    
    vector<ll> result;
    for (int i = 1; i <= n; i++) {
        std::cin >> a[i];
    }
    for (int i = n; i >=1; i--) {
        if( (a[i]==1 && m[i]%2==0) || (a[i]==0 && m[i]%2==1) ){
            // std::cout << i<<" "<<a[i]<<" "<<m[i] << std::endl;
            result.push_back(i);
            soi(i);
        }
    }
    std::cout << result.size() << std::endl;
    if(result.size()==0){
        return 0;
    }else if(result.size()==1){
        std::cout << result[0] << std::endl;
        return 0;
    }
    for (int i = 0; i < result.size()-1; i++) {
        std::cout << result[i]<<" ";
    }
    std::cout << result[result.size()-1] << std::endl;
    
}




Measured memory_bytes: 11720
import Control.Applicative
import Control.Monad
import Data.List

combine :: [Int] -> [[Int]] -> [[Int]]
combine x [] = [[a] | a <-x]
combine (x:xs) (y:ys) = [[x] ++ y] ++ combine xs ys

t :: [[Int]] -> [[Int]]
t [x]    = [[a] | a <-x]
t (x:xs) = combine x (t xs)

dot :: [Int] -> [Int] -> Int
dot [x] [y] = x * y
dot (x:xs) (y:ys) = x * y + dot xs ys


main = do
    n:m:_ <- map read.words <$> getLine
    a <- replicateM n (map read.words <$> getLine) ::IO[[Int]]
    b <- replicateM m (map read.words <$> getLine) ::IO[[Int]]
    let bt = t b
    let c = [[ ar `dot` bl| bl <- bt] |ar <- a]
    putStrLn $ intercalate "\n" (map(unwords.map show) c)
    

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

typedef long long ll;
//loop
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//STL
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

void Main() {
    int x,a,b;
    cin>>x>>a>>b;
    int dist = abs(x-a);
    int dist1 = abs(x-b);
    if (dist < dist1) cout << "A" << endl;
    else cout << "B" << endl;
}

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


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
 
class Program
{
    static void Solve()
    {
        var n = sc.Int();
        var a = sc.Int(n);

        var ansa = 0;
        var ansb = 0;

        var lis = a.OrderByDescending(x => x).ToList();
        var cnt = lis.Count();

        for (int i = 0; i < cnt; i++)
        {
            if (i % 2 == 0)
                ansa += lis[i];
            else
                ansb += lis[i];
        }

        pr.WriteLine(ansa - ansb);
    }
 
 
    static void Main(string[] args)
    {
        // pr.AutoFlush = true;
        Solve();
        pr.Flush();
    }
 
    static Scanner sc = new Scanner();
    static Printer pr = new Printer();
}
 
#region IO
class Scanner
{
    private int _i = 0; 
    private string[] line = new string[0];
 
    private T[] Enumerate<T>(int n, Func<T> f)
    {
        T[] ret = new T[n];
        for (int i = 0; i < n; i++)
            ret[i] = f();
        return ret;
    }
 
    public string Str()
    {
        if (line.Length <= _i)
        {
            line = Console.ReadLine().Split(' ');
            _i = 0;
        }
 
        return line[_i++];
    }
 
    public int Int() => int.Parse(Str());
    public long Long() => long.Parse(Str());
    public double Double() => double.Parse(Str());
    public int[] Int(int n) => Enumerate(n, Int);
    public long[] Long(int n) => Enumerate(n, Long);
    public double[] Double(int n) => Enumerate(n, Double);
    public string[] Str(int n) => Enumerate(n, Str);
}
 
class Printer : StreamWriter
{
    public Printer() : base(Console.OpenStandardOutput())
    {
        AutoFlush = false;
    }
}
#endregion

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int mat[1000][1000];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int r,c,a,b;
    cin>>r>>c>>a>>b;
    for(int i=1;i<=a;i++){
        for(int j=1;j<=c;j++)
            mat[i][j]=1;
    }
    for(int i=1;i<=b;i++){
        for(int j=1;j<=r;j++)
            mat[j][i]=1;
    }
    int cnt=0;
    for(int i=1;i<=r;i++)
        for(int j=1;j<=c;j++)
        if(!mat[i][j])
        cnt++;
        cout<<cnt<<endl;


    return 0;
}


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

int main() {
  int K,A,B;
  cin >> K >> A >> B;
  int sum=0;
  while(sum<A){
    sum+=K;
  }
  if (sum<=B){
    cout << "OK";
  }
  else {
    cout << "NG";
  }
  
return 0;
}

Measured memory_bytes: 3636
B1 = 97
B2 = 101
DIV = 1 << 32

def init(r)
  f = Array.new(r){ Array.new }
  r.times do |i|
    f[i] = gets.chomp.split("").map(&:ord)
  end
  f
end

def calc(f, r, c)
  t1 = 1
  $c.times{ t1 = t1 * B1 % DIV }
  r.times do |i|
    e = 0
    $c.times do |j|
      e = e*B1 + f[i][j]
    end
    (0..c-$c).each do |j|
      $tmp[i][j] = e
      e = (e*B1 - t1*f[i][j] + f[i][j+$c] + DIV) % DIV if j < c - $c
    end
  end

  t2 = 1
  $r.times{ t2 = t2 * B2 % DIV }
  (0..c-$c).each do |j|
    e = 0
    $r.times{ |i| e = e*B2 + $tmp[i][j] }
    (0..r-$r).each do |i|
      $hash[i][j] = e
      e = (e*B2 - t2*$tmp[i][j] + $tmp[i+$r][j] + DIV) % DIV if i < r - $r
    end
  end
end

def check
  $h.times do |i|
    $w.times do |j|
      puts "#{i} #{j}" if $hash[i][j] % DIV == $key % DIV
    end
  end
end

$h, $w = gets.split.map(&:to_i)
$f1 = init($h)
$r, $c = gets.split.map(&:to_i)
$f2 = init($r)
if $h >= $r && $w >= $c
  $hash = Array.new($h){ Array.new($w, 0) }
  $tmp = Array.new($h){ Array.new($w, 0) }
  calc($f2,$r,$c)
  $key = $hash[0][0]
  calc($f1,$h,$w)
  check
end

Measured memory_bytes: 49248
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
	int n;
	cin>>n;
	vi w(n);
	for(int i=0;i<n;i++)
		cin>>w[i];
	int min_val=10000000;
	for(int i=0;i<n-1;i++)
	{
		int sum1=0,sum2=0;
		for(int j=0;j<=i;j++)
			sum1+=w[j];
		for(int k=i+1;k<n;k++)
			sum2+=w[k];
		min_val=min(min_val,abs(sum1-sum2));
	}
	cout<<min_val;
}
int main()
{
//code
	
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


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

std::string to_bs(int i){
	std::string s = "";
	while(i > 0){
		s = static_cast<char>(i%2+'0') + s;
		i /= 2;
	}
	while(s.length() < 5){
		s = '0' + s;
	}
	return s;
}

int main(){
	std::map<char, std::string> input;
	std::map<std::string, char> output;
	output["101"] = ' ';
	output["000000"] = '\'';
	output["000011"] = ',';
	output["10010001"] = '-';
	output["010001"] = '.';
	output["000001"] = '?';
	output["100101"] = 'A';
	output["10011010"] = 'B';
	output["0101"] = 'C';
	output["0001"] = 'D';
	output["110"] = 'E';
	output["01001"] = 'F';
	output["10011011"] = 'G';
	output["010000"] = 'H';
	output["0111"] = 'I';
	output["10011000"] = 'J';
	output["0110"] = 'K';
	output["00100"] = 'L';
	output["10011001"] = 'M';
	output["10011110"] = 'N';
	output["00101"] = 'O';
	output["111"] = 'P';
	output["10011111"] = 'Q';
	output["1000"] = 'R';
	output["00110"] = 'S';
	output["00111"] = 'T';
	output["10011100"] = 'U';
	output["10011101"] = 'V';
	output["000010"] = 'W';
	output["10010010"] = 'X';
	output["10010011"] = 'Y';
	output["10010000"] = 'Z';
	
	for(int i=0;i<26;i++){
		input['A' + i] = to_bs(i);
	}
	input[' '] = "11010";
	input['.'] = "11011";
	input[','] = "11100";
	input['-'] = "11101";
	input['\''] = "11110";
	input['?'] = "11111";

	std::string s;
	while(std::getline(std::cin, s), !std::cin.eof()){
		std::string code;
		for(int i=0;i<s.size();i++){
			code += input[s[i]];
		}

		std::string res = "", temp_s = "";
		for(int i=0;i<code.size();i++){
			temp_s += code[i];
			if(output[temp_s]){
				res += output[temp_s];
				temp_s = "";
			}
		}
		
		std::cout << res << std::endl;
		std::cin.clear();
	}
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
  cin>>a>>b>>c;
  if(a==b && b!=c)cout<<"Yes"<<endl;
   
  else if(b==c && a!=c)cout<<"Yes"<<endl;
  else if(a==c && b!=c)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll      long long
#define pii     pair<int, int>
#define f       first
#define s       second
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d ", a)
#define pfl(a) printf("%lld\n", a)
#define Case(a) printf("Case %d: ", a)

using namespace std;
int main()
{
    int a, b, c;
    cin>>a>>b>>c;

    swap(a, b);
    swap(a, c);
    cout<<a<<" "<<b<<" "<<c;
}


Measured memory_bytes: 384
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

class memoization_t
{
	std::vector<int> flag;
	std::vector<int> longest;
	std::vector<std::set<index_t>>const& edge;
	boost::optional<int> run(int i)
	{
		if (flag[i])
		{
			return boost::none;
		}
		if (longest[i] != -1)
		{
			return longest[i];
		}
		flag[i] = true;
		longest[i] = 1;
		for (auto n : edge[i])
		{
			auto v = run(n);
			if (v)
			{
				longest[i] = std::max(longest[i], *v + 1);
			}
			else
			{
				return boost::none;
			}
		}
		flag[i] = false;
		return longest[i];
	}
public:
	memoization_t(std::size_t N, std::vector<std::set<index_t>>const& _edge) :flag(N), longest(N, -1), edge(_edge)
	{

	}
	memoization_t(memoization_t const&) = delete;
	memoization_t(memoization_t&&) = delete;

	auto operator()(int i)
	{
		return run(i);
	}
	int longest_path()const
	{
		return *boost::max_element(longest);
	}
};


int longest_path(std::vector<std::set<index_t>>const& edge, std::set<index_t> init)
{
	memoization_t unit(edge.size(), edge);
	for (auto i : init)
	{
		if (!unit(i))
		{
			return -1;
		}
	}
	return unit.longest_path();
}

int run(boost::multi_array<int, 2> ar, int N)
{
	std::map<std::pair<int, int>, index_t> index;
	auto code = [&](int i, int j)
	{
		return std::min(i, j) + N * std::max(i, j);
	};
	std::set<index_t> init;
	for (auto i : boost::irange(0, N))
	{
		for (auto j : boost::irange(i + 1, N))
		{
			init.emplace(code(i, j));
		}
	}
	std::vector<std::set<index_t>> edge(N * N);
	
	for (auto i : boost::irange(0, N))
	{
		for (auto j : boost::irange(1, N - 1))
		{
			auto prev = code(i, ar[i][j - 1]);
			auto now = code(i, ar[i][j]);
			edge[prev].emplace(now);
			init.erase(now);
		}
	}
	return longest_path(edge, init);
}

void Main()
{
	int N;
	std::cin >> N;
	boost::multi_array<int, 2> opponents(boost::extents[N][N - 1]);
	for (auto i : boost::irange(0, N))
	{
		for (auto j : boost::irange(0, N - 1))
		{
			int a;
			std::cin >> a;
			--a;
			opponents[i][j] = a;
		}
	}
	std::cout << run(std::move(opponents), N) << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 109568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 4e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time"<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//_______________________________________________________________________________
ll power(ll a,ll b,ll m)
{
   ll ans=1;
   while(b>0)
   {
       if(b%2)
       {
           ans=(ans*a)%m;
       }
       a=(a*a)%m;
       b=b/2;
   }
   return ans;
}
const int N = six;
ll fct[N];
ll invf[N];
ll inverse(ll a,ll m)
{
       return (power(a,m-2,m));
}

ll C(ll n,ll r)
{
       if(r>n){return 0;}
       ll xx = (invf[r]*invf[n-r])%mod;
       xx *= fct[n];
       xx %= mod;
       return xx;
}
void initialize()
{
       fct[0] = 1;
       invf[0] = 1;
       fri(i,1,N){
              fct[i] = (i*fct[i-1])%mod;
              invf[i] = inverse(fct[i],mod);
       }
}
int main()
{
       int n;
       cin>>n;
       initialize();
       ll ans = 0;
       fri(i,1,n)
       {
              ll xx = ((((power(9,n-i,mod)-power(8,n-i,mod))%mod)+mod))%mod;
              xx *= C(n,i);
              //cout<<xx<<endl;
              ans += xx;
              ans %= mod;
       }
       cout<<ans<<endl;
}


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

using namespace std;

bool calc(int i, int j);

int N, D;
vector<vector<int>>p_ary;

int main()
{

	int ans = 0;

	cin >> N;
	cin >> D;


	p_ary = vector<vector<int>>(N, vector<int>(D));

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < D; j++) {
			int p;
			cin >> p;
			p_ary.at(i).at(j) = p;
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			if (calc(i, j)) {
				ans++;
			}
		}
	}

	cout << ans << endl;


	return 0;
}


bool calc(int i, int j){

	int sum = 0;

	for (int d = 0; d < D; d++) {
		int tmp = p_ary.at(i).at(d) - p_ary.at(j).at(d);
		sum += tmp * tmp;
	}
	for (int k = 1;		; k++) {
		int pow = k * k;

		if (sum == pow) { return true; }
		if (sum < pow) { break; }

	}

	return false;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.random;

immutable inf = 10L^^16;
alias Edge = Tuple!(int, "from", int, "to", long, "cap", int, "rev");

void main() {
    int n, m;
    scan(n, m);

    auto adj = new Edge[][](n, 0);

    void addEdge(int u, int v, long cap) {
        adj[u] ~= Edge(u, v, cap, adj[v].length.to!int);
        adj[v] ~= Edge(v, u, 0, adj[u].length.to!int - 1);
    }

    foreach (i ; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        addEdge(u, v, c);
    }

    long ans = EdmondsKarp(adj, 0, n - 1);

    writeln(ans);
}



long EdmondsKarp(Edge[][] adj, int s, int t) {
    int n = adj.length.to!int;
    long F;

    while (true) {
        auto q = Queue!(int)(n);
        q.push(s);

        auto pred = new Edge*[](n);

        while (!q.empty && !pred[t]) {
            auto cur = q.front;
            q.pop();

            foreach (ref e ; adj[cur]) {
                if (!pred[e.to] && e.to != s && e.cap > 0) {
                    pred[e.to] = &e;
                    q.push(e.to);
                }
            }
        }

        if (pred[t]) {
            long df = inf;

            for (auto e = pred[t]; e; e = pred[e.from]) {
                df = min(df, e.cap);
            }

            for (auto e = pred[t]; e; e = pred[e.from]) {
                e.cap -= df;
                adj[e.to][e.rev].cap += df;
            }

            F += df;
        }
        else break;
    }

    return F;
}



struct Queue(T) {
    private {
        int N, head, tail;
        T[] data;
    }

    this (int n) {
        N = n + 1;
        data = new T[](N);
    }

    bool empty() {
        return head == tail;
    }

    bool full() {
        return (tail + 1) % N == head;
    }

    T front() {
        return data[head];
    }

    void push(T x) {
        assert(!full);
        data[tail++] = x;
        tail %= N;
    }

    void pop() {
        assert(!empty);
        head++;
        head %= N;
    }
}

void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 2636
import java.io.IOException;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {

		int n = nextInt();
		int m = nextInt();

		Treasure[] treasure = new Treasure[n];

		for (int i = 0; i < n; i++) {
			treasure[i] = new Treasure(nextInt(), nextInt());
		}

		Arrays.sort(treasure);

		for (int q = 0; q < m; q++) {
			int count = 0;
			int x1 = nextInt();
			int y1 = nextInt();
			int x2 = nextInt();
			int y2 = nextInt();

			for (int i = 0; i < treasure.length; i++) {
				if (treasure[i].x < x1) {
					continue;
				}
				for (int k = i; k < treasure.length; k++) {
					if (treasure[k].x > x2) {
						break;
					}
					if (treasure[k].y >= y1 && treasure[k].y <= y2) {
						count++;
					}
				}
				break;
			}
			System.out.println(count);
		}
	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return -1;
	}
}

class Treasure implements Comparable<Treasure> {
	int x = 0;
	int y = 0;

	public Treasure(int x, int y) {
		this.x = x;
		this.y = y;
	}

	public int compareTo(Treasure t1) {
		return this.x - t1.x;
	}
}

Measured memory_bytes: 68896
N = int(input())

ans = 0

for n in range(1, N+1):
    if n % 2 == 0:
        continue

    count = 0

    for i in range(1, n+1):
        if n % i == 0:
            count += 1

    if count == 8:
        ans += 1

print(ans)


Measured memory_bytes: 63844
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N, K;
    int snuke[200];
    MEMSET(snuke, 0);
    cin>>N>>K;
    ll d, A;
    rep(i, K){
        cin>>d;
        rep(j, d){
            cin>>A;
            snuke[A-1]=1;
        }
    }
    ll count=0;
    rep(i, N){
        if(snuke[i]==0) count++;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3572
import java.util.*;
public class Main{
	public static void main(String[] args){
      Scanner sc  = new Scanner(System.in);
      int p = sc.nextInt();
      int q = sc.nextInt();
      int r = sc.nextInt();
	  int pq = Math.max(p,q);
      int pqr = Math.max(pq,r);
      System.out.println(p+q+r-pqr);
      sc.close();
    }
}


Measured memory_bytes: 23508
use superslice::Ext;
fn main() {
    proconio::input! {
        n: usize,
        xyu: [(i32,i32,char);n],
    }
    let mut u=vec![];
    let mut r=vec![];
    let mut d=vec![];
    let mut l=vec![];
    for (x,y,a) in xyu {
        match a {
            'U' => &mut u,
            'R' => &mut r,
            'D' => &mut d,
            'L' => &mut l,
            _ => panic!("Input error"),
        }.push((x,y));
    }
    let mut t=INF;
    let fx=|p:&(i32,i32)|p.0;
    let fy=|p:&(i32,i32)|p.1;
    let fny=|p:&(i32,i32)|-p.1;
    let faxy=|p:&(i32,i32)|p.0+p.1;
    let fsxy=|p:&(i32,i32)|p.0-p.1;
    t=t.min(f(&mut d, &u, fx, fy)/2);
    t=t.min(f(&mut l, &r, fy, fx)/2);
    t=t.min(f(&mut l, &u, fsxy, fy));
    t=t.min(f(&mut r, &u, faxy, fy));
    t=t.min(f(&mut l, &d, faxy, fny));
    t=t.min(f(&mut r, &d, fsxy, fny));
    if t>=INF/2 {
        println!("SAFE");
    }
    else {
        println!("{}",t);
    }
}
const INF: i32=std::i32::MAX;
fn f<F1,F2>(a: &mut Vec<(i32,i32)>, b: &Vec<(i32,i32)>, f1: F1, f2: F2) -> i32 where
  F1: Fn(&(i32,i32))->i32, F2: Fn(&(i32,i32))->i32
{
    let mut t=INF;
    a.sort_by_key(|a|(f1(a),f2(a)));
    for b in b {
        let a=&a[a.equal_range_by_key(&f1(b), |a|f1(a))];
        let i=a.lower_bound_by_key(&f2(b),|a|f2(a));
        if i<a.len() {
            t=t.min((f2(&a[i])-f2(b))*10);
        }
    }
    t
}

Measured memory_bytes: 9040
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;

const int N = 3e5 + 123, MOD = 998244353;
ll n, a, b, k;
int fact[N], rev[N];

int binpow(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = (ll)res * x % MOD;
		}
		x = (ll)x * x % MOD;
		y /= 2;
	}
	return res;
}

int c(int x, int y) {
	if (y > x) {
		return 0;
	}
	return ((ll)fact[x] * rev[y] % MOD) * rev[x - y] % MOD;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n >> a >> b >> k;
	fact[0] = rev[0] = 1;
	for (int i = 1; i <= n; i++) {
		fact[i] = (ll)fact[i - 1] * i % MOD;
		rev[i] = (ll)rev[i - 1] * binpow(i, MOD - 2) % MOD;
	}
	int res = 0;
	for (int i = 0; i <= n; i++) {
		ll l = k - i * a;
		if (l < 0 || l % b) {
			continue;
		}
		l /= b;
		res += (ll)c(n, i) * c(n, l) % MOD;
		if (res >= MOD) {
			res -= MOD;
		}
	}
	cout << res;
}


Measured memory_bytes: 2560
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
    int n;
    vector<int> ki(100005,0), gu(100005,0);
    cin >> n;

    for (int i = 1; i <= n; i++) {
        int v;
        cin >> v;
        if (i % 2 == 0) {
            gu[v]++;
        }
        else {
            ki[v]++;
        }
    }
    int ans = 0;
    int maxki = 0;
    int maxki2 = 0;
    int kiind = 0;
    int kiind2 = 0;
    int maxgu = 0;
    int maxgu2 = 0;
    int guind = 0;
    int guind2 = 0;
    for (int i = 1; i <= 100000; i++) {
        if (ki[i] >= maxki) {
            maxki2 = maxki;
            maxki = ki[i];
            kiind2 = kiind;
            kiind = i;
        }
        else if (ki[i] > maxki2) {
            maxki2 = ki[i];
        }

        if (gu[i] >= maxgu) {
            maxgu2 = maxgu;
            maxgu = gu[i];
            guind2 = guind;
            guind = i;
        }
        else if (gu[i] > maxgu2) {
            maxgu2 = gu[i];
        }
    }
    if (kiind == guind) {
        //if (maxki >= maxgu) {
        //    ans = (n / 2) - maxki + (n / 2) - maxgu2;
        //}
        //else {
        //    ans = n - maxgu - maxki2;
        //}
        ans = min(n - maxki - maxgu2, n - maxgu - maxki2);
    }
    else {
        ans = n - maxgu - maxki;
    }

    cout << ans << endl;
}



Measured memory_bytes: 3848