akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

LL matches[10] = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};
map<LL,LL> num;

bool cmp(LL a, LL b) {
	return (num[a] > num[b]);
}

int main() {
	sll(n); sll(m);
	VLL digits(m);
	rep(i, 0, m)	digits[i] = scanLong();
	sort(digits.begin(), digits.end());
	rep(i, 0, m)	num[matches[digits[i]]] = digits[i];
	LL dp[n+1]; dp[0] = 0;
	rep(i, 1, n+1) {
		dp[i] = -1;
		srep(it, num.begin(), num.end()) {
			if(it->first <= i)
				dp[i] = max(dp[i], dp[i - it->first] + 1);
		}
	}
	
	VLL ms;
	srep(it, num.begin(), num.end())	ms.push_back(it->first);
	sort(ms.begin(), ms.end(), cmp);

	LL cnt[10]; clr(cnt);
	while(n > 0) {
		rep(it, ms.begin(), ms.end()) {
			if(dp[n-*it] == dp[n]-1) {
				cnt[num[*it]]++;
				n -= *it;
				break;
			}
		}
	}
	rep(i, 10, 0) {
		rep(k, 0, cnt[i])	cout << i;
	} nl;
}


Measured memory_bytes: 384
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
x2 = 0
x10, n = input().split()
x10 = int(x10)
n = int(n)
x2 = Base_10_to_n(x10, n)
print(len(x2))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    string ans = "Yes";
    rep(i, h) rep(j, w) {
        if (s[i][j]=='.') continue;
        bool ok = false;
        rep(k, 4) {
            int ni = i + dx[k];
            int nj = j + dy[k];
            if (ni<0 || ni>=h || nj<0 || nj>=w) continue;
            if (s[ni][nj]=='#') ok = true;
        }
        if (!ok) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    
    cout << ans << endl;
    return 0;
}


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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  
  ll n ,d,cnt=0;
  cin>>n>>d;
  for(ll i=0;i<n;i++){
    ll x,y; cin>>x>>y;
    if(x*x +y*y <= d*d)cnt++;
  }
  cout<<cnt;
  
}   

Measured memory_bytes: 3652
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
n = I()
l = LI()
l.sort()
ans = 0
for i in range(n):
    ans += l[2*i]
print(ans)
#B

#C

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 39024
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

int main(){

  int H, W, K; cin >> H >> W >> K;

  ll cnt[9];
  cnt[0] = 1; cnt[1] = 1;
  for (int i = 2; i < 9; i++){
    cnt[i] = cnt[i - 1] + cnt[i - 2];
  }
  /*
  for (int i = 0; i < 9; i++){
    cout << cnt[i] << endl;
  }
  */
  
  
  ll DP[H + 1][W];
  for (int i = 0; i < H + 1; i++){
    for (int j = 0; j < W; j++){
      DP[i][j] = 0;
    }
  }
  DP[0][0] = 1;

  for (int i = 1; i < H + 1; i++){
    for (int j = 0; j < W; j++){
      ll C = cnt[j] * cnt[W - 1 - j];
      DP[i][j] += DP[i - 1][j] * C;
      DP[i][j] %= nmax;

      if (j - 1 >= 0){
        DP[i][j - 1] += DP[i - 1][j] * cnt[W - 1 - j] * cnt[max(0, j - 1)];
        DP[i][j - 1] %= nmax;
      }
      
      if (j + 1 < W){
        DP[i][j + 1] += DP[i - 1][j] * cnt[j] * cnt[max(0, W - 2 - j)];
        DP[i][j + 1] %= nmax;
      }
    }
  }

  cout << DP[H][K - 1] << endl;

  return 0;
}

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

using namespace std;

long long N, A;

long long pw(long long b, long long e)
{
    long long ret=1;
    while(e--)
    {
        if((double)ret*b<=1e18)
            ret*=b;
    }
    return ret;
}

int main()
{
    cin>>N>>A;
    long long ans=N;
    for(int i=1; i<=100; i++)
    {
        long long rt=pow(N, 1.0/i)+100;
        while(pw(rt, i)>N)
            rt--;
        for(int j=0; j<=i; j++)
        {
            if(pw(rt, j)*pw(rt+1, i-j)>=N)
                ans=min(ans, (i-1)*A+rt*j+(rt+1)*(i-j));
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  int h,w;
  char c[100][100];
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>c[i][j];
    }
    for(int j=0;j<w;j++){
      cout<<c[i][j];
    }
    cout<<endl;
    for(int j=0;j<w;j++){
      cout<<c[i][j];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import Data.Char
import Control.Monad
import Data.Array.Unboxed
import Data.Array
import Data.Array.IO

solve :: IOUArray Int Int -> Int -> Int -> IO Int
solve arr n x
    | n == 2 = do
        a <- readArray arr 0
        b <- readArray arr 1
        return $ max (a+b-x) 0
    | otherwise = do
        res <- forM [0..n-2] $ \i -> do
                adjust arr (i,i+1) x
        return $ sum res
    where
        adjust :: IOUArray Int Int -> (Int, Int) -> Int -> IO Int
        adjust arr (i,j) x = do
            iv <- readArray arr i
            jv <- readArray arr j
            let diff = max (iv+jv-x) 0
            unless (diff == 0) $ do
                if (jv >= diff)
                    then do
                        writeArray arr j (jv-diff)
                    else do
                        writeArray arr j 0
                        writeArray arr i (iv + (jv-diff))
            return diff

main = do
    [n, x] <- map read . words <$> getLine :: IO [Int]
    as <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    (as' :: IOUArray Int Int) <- thaw $ Data.Array.listArray (0,n-1) $ VU.toList as
    solve as' n x >>= print

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

int main()
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    int res=0;
    while(n--)
    {
        double a,b;
        cin>>a>>b;
        double tres=0;
        tres=sqrt(a*a+b*b);
        if(tres<=k)
        ++res;
    }
    printf("%d",res);
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  int N;
  cin >> N;
  vector<vector<char>> s(N);
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < 10; ++j){
      char c;
      cin >> c;
      s.at(i).push_back(c);
    }
    sort(s.at(i).begin(), s.at(i).end());
  }
  sort(s.begin(), s.end());
  long long count = 1;
  long long ans = 0;
  for(int i = 0; i < N - 1; ++i){
    if(s.at(i) == s.at(i + 1)){
      count++;
    } else{
      ans += count * (count - 1) / 2;
      count = 1;
    }
  }
  ans += count * (count - 1) / 2;
  cout << ans <<endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <tuple>

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

void solve(){
  int s;
  cin >> s;
  int n,m;
  n = s/100;
  m = s%100;
  bool n1,m1;
  n1= 1<=n && n <=12;
  m1 = 1<=m && m<= 12;
  if(n1&&m1) cout << "AMBIGUOUS" << endl;
  else if(n1) cout << "MMYY" << endl;
  else if(m1) cout << "YYMM" << endl;
  else cout << "NA" << endl;
}

int main(){
  solve();
  return 0;
}


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

typedef long long ll;
const int mod=1000000007;

int n,cnt[70];
ll a;
__int128_t ans;

int main(){

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

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        for(int j=0;j<60;j++){
            if((a>>j)&1){
                ans+=(__int128_t(i-cnt[j]))<<j;
            }else{
                ans+=(__int128_t(cnt[j]))<<j;
            }
            cnt[j]+=(a>>j)&1;
            ans%=mod;
        }
    }
    cout<<(ll)ans<<endl;

    return 0;
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL N;
	VL A;
	cin >> N;
	FOR(i, 0, N)
		A.push_back(IN<LL>());

	LL alice = 0, bob = 0;
	sort(A.begin(), A.end(), greater<LL>());
	FOR(i, 0, A.size()) {
		if (i % 2 == 0) {
			alice += A[i];
		}
		else {
			bob += A[i];
		}
	}
	O((alice - bob));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
    int a,b,c,d;cin>>a>>b>>c>>d;
    if(a*b==c*d)cout<<a*b;
    else cout<<(a*b>c*d?a*b:c*d);
}



Measured memory_bytes: 256
///----------------------------------
/// 人生とは、人生以外のことを夢中で考えているときにあるんだよ。
/// 
/// - ジョン・レノン -
///----------------------------------
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
using namespace std;
using lint = long long;
template<class T> using grid = vector<vector<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
static const lint MOD = (lint)1e9+7;

int N, Q;
grid<int> graph;
map<int, int> mp;

void input()
{
    cin >> N >> Q;
    graph.resize(N);

    int a, b;
    rep (i, N - 1)
    {
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
    }

    int p, x;
    rep (i, Q)
    {
        cin >> p >> x;

        mp[p-1] += x;
    }
}

void solve()
{
    vector<int> cnt(N, 0);
    queue<lint> que;
    que.push(0);
    cnt[0] = mp[0];

    while (!que.empty())
    {
        int now = que.front(); que.pop();
        rep (i, SZ(graph[now]))
        {
            que.push(graph[now][i]);
            cnt[graph[now][i]] = cnt[now] + mp[graph[now][i]];
        }
    }

    rep (i, SZ(cnt))
    {
        if (i == SZ(cnt) - 1)
        {
            cout << cnt[i] << "\n";
        }
        else
        {
            cout << cnt[i] << " ";
        }
    }
}

int main()
{
    input();
    solve();

    return 0;
}


Measured memory_bytes: 23552
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		sc.close();
		int num = Integer.parseInt(N.substring(N.length() - 1));
		if (num == 2 || num == 4 || num == 5 || num == 7 || num == 9) {
			System.out.println("hon");
		} else if (num == 3) {
			System.out.println("bon");
		} else {
			System.out.println("pon");
		}
	}
}


Measured memory_bytes: 35716
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var num1 = Convert.ToInt32(input[0]);
        var num2 = Convert.ToInt32(input[1]);

        var group = new HashSet<int>[3];
        group[0]= new HashSet<int> { 1, 3, 5, 7, 8, 10, 12 };
        group[1] = new HashSet<int> { 4, 6, 9, 11 };
        group[2] = new HashSet<int> { 2 };

        var isSameGroup = false;
        foreach(var val in group)
        {
            if (val.Contains(num1) && val.Contains(num2))
            {
                isSameGroup = true;break;
            }
        }

        var result = isSameGroup ? "Yes" : "No";
        Console.WriteLine(result);
    }
}

Measured memory_bytes: 13408
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

void print_a(VI v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    LL n,k,x,y;
    cin>>n>>k>>x>>y;
    LL ans = (min(n,k) * x) + (max((LL)0,n - k) *y);

    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n) cin>>a[i];
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n) cin>>a[i];
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
using namespace std;
using ll = long long;
using Lf = long double;
using plong = pair<ll,ll>;


const long MOD = 1000000007;

int main(){
    ll N,M;
    cin>>N>>M;
    vector<ll> A(N);
    ll res=0;
    for(ll i=0;i<N;i++){
        cin>>A[i];
        // if(A[i]%M==0)res++;
    }
    map<ll,ll>mp;
    mp[0]++;
    ll sum = A[0]%M;
    mp[sum]++;
    for(ll i=1;i<N;i++){
        sum = (sum+A[i])%M;
        mp[sum]++;
    }
    
    for(auto p:mp){
        res+=(p.second-1)*(p.second)/2;
        // cout<<p.first<<":"<<p.second<<endl;
    }

    cout<<res<<endl;

}

Measured memory_bytes: 4992
A, B, C, D, E, F = map(int, input().split())

w = []
for i in range(F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        a = (A * i + B * j) * 100
        if a < F:
            w.append(a)

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    t = min(F - a, E * a // 100)
    for i in range(t // C + 1):
        for j in range(t // D + 1):
            b = C * i + D * j
            if a + b > F:
                continue
            if b > E * a // 100:
                continue
            if a + b == 0:
                continue
            concentration = 100 * b / (a + b)
            if concentration > best_concentration:
                best_concentration = concentration
                best_a = a
                best_b = b
print(best_a + best_b, best_b)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long int ll;
int main()
{
  ll n;
  cin>>n;
  vector<int> t(100001),x(100001),y(100001);
  for(int i=1;i<=n;i++) cin>>t.at(i)>>x.at(i)>>y.at(i);
  x.at(0)=0,y.at(0)=0,t.at(0)=0;

  bool ans=true;
  for(int i=1;i<=n;i++)
  {
    int time=t.at(i)-t.at(i-1);
    int det=abs(x.at(i)-x.at(i-1))+abs(y.at(i)-y.at(i-1));
    if(time-det<0 || (det-time)%2!=0)
    {
      ans=false;
      break;
    }
  }

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

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD (int)1e9 + 7
#define atoi(x) ((x)-'0')
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

int n, k, t;
vi v;

int main() {
	cin >> n >> k;
	FOR(i, n) {
		cin >> t;
		v.pb(t);
	}
	sort(all(v));
	cout << accumulate(v.begin(), v.begin() + k, 0);
}

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

using namespace std;
 
int main(void){
  bool findFlag = true;
  int N, M, k, input, switchSum = 0, ans = 0;
  cin >> N >> M;
  vector<vector<int>> S(M);
  vector<int> P, K(M);
  for(int i=0; i<M; i++){
    cin >> K[i];
    for(int j=0; j<K[i]; j++){
      cin >> input;
      S[i].emplace_back(input);
    }
  }
  for(int i=0; i<M; i++){
    cin >> input;
    P.push_back(input);
  }
  for(int i=0; i<(1<<N); i++){
    findFlag = true;
    for(int j=0; j<M; j++){
      switchSum = 0;
      for(int k=0; k<K[j]; k++){
        if(i & (1 << (S[j][k]-1))){
          switchSum++;
        }
      }
      if(switchSum%2 != P[j]){
        findFlag = false;
      }
    }
    if(findFlag){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
auto& errStream=cerr;
#ifdef LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%"  SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	int w=read(),h=read(),n=read();
	vector<pi> pos(n);
	set<pi> s;
	REP(i,n){
		int x=read()-1,y=read()-1;
		pos[i]=pi(y,x);
		s.insert(pos[i]);
	}
	vi mx(w,0);
	REP(i,w-1){
		if(s.count(pi(mx[i],i+1)))
			break;
		mx[i+1]=mx[i];
		if(mx[i+1]<h-1&&s.count(pi(mx[i+1]+1,i+1))==0)
			mx[i+1]++;
	}
	cerr<<mx<<endl;
	int ans=w;
	for(auto p:pos){
		int y=p.first,x=p.second;
		if(0<x){
			if(mx[x-1]>=y)
				chmin(ans,x);
		}
	}
	print(ans);
}


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

int main() {
  int A,B,C,D;
  
  cin >> A >> B >> C >> D;
  
  if(A+B > C+D) {
    cout << "Left" << endl;
  } else if(A+B == C+D) {
    cout << "Balanced"  << endl;
  } else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    double x1,y1,x2,y2;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    printf("%.8lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
     
    return 0;
}


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

using namespace std;

char a[100100],b[100100];

int main()
{
    int n,i,j=0,flag=0;
    cin >> n;
    scanf(" %s",a);
    a[n]=a[0];a[n+1]=a[1];
    while(!flag&&j<4)
    {
        if(j==0)
        {
            b[0]='S';
            b[1]='S';
        }
        else if(j==1)
        {
            b[0]='S';
            b[1]='W';
        }
        else if(j==2)
        {
            b[0]='W';
            b[1]='S';
        }
        else if(j==3)
        {
            b[0]='W';
            b[1]='W';
        }
        for(i=1; i<=n; i++)
        {
            if(b[i]=='S'&&a[i]=='o')
                b[i+1]=b[i-1];
            else if (b[i]=='S'&&a[i]=='x')
            {
                if(b[i-1]=='S') b[i+1]='W';
                else if(b[i-1]=='W') b[i+1]='S';
            }
            else if (b[i]=='W'&&a[i]=='o')
            {
                if(b[i-1]=='S') b[i+1]='W';
                else if(b[i-1]=='W') b[i+1]='S';
            }
            else if (b[i]=='W'&&a[i]=='x')
                b[i+1]=b[i-1];
        }
        if(b[n]==b[0]&&b[n+1]==b[1]) flag=1;
        j++;
    }
    if(flag==0)
    cout << "-1" << endl;
    else
    {
        for(i=0;i<n;i++)
        {
            cout << b[i];
        }
    }
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

typedef pair<long,long> P;
long  d[55][55];

int main(int argc, char* argv[])
{
    long a,b,c,x;
    scanf("%ld%ld%ld%ld", &a, &b, &c, &x);

    long count = 0;
    long i,j,k;
    for(i=0; i<=a; i++) {
        long xx = x - 500 * i;
        if(xx<0) continue;
        for(j=0; j<=b; j++) {
            long yy = xx - 100 * j;
            if(yy<0) continue;

            if(yy%50==0 && yy/50>=0 && yy/50<=c) count++;
        }
    }

    printf("%ld\n", count);

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> V(N), C(N);
  for (int i=0; i<N; i++) {
    cin >> V.at(i);
  }
  for (int i=0; i<N; i++) {
    cin >> C.at(i);
  }
  int X = 0, Y = 0;
  for (int i=0; i<N; i++) {
    if (V.at(i) > C.at(i)) {
      X += V.at(i);
      Y += C.at(i);
    }
  }
  cout << X-Y << endl;
}

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

using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    int c0 = 0;
    int c1 = 0;
    int c2 = 0;
    int c3 = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s == "AC") {
            c0++;
        } else if (s == "WA") {
            c1++;
        } else if (s == "TLE") {
            c2++;
        } else if (s == "RE") {
            c3++;
        }
    }
    cout << "AC x " << c0 << endl;
    cout << "WA x " << c1 << endl;
    cout << "TLE x " << c2 << endl;
    cout << "RE x " << c3 << endl;
    return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int N, L;
    cin >> N >> L;

    int ans = 0;
    int tmp = 101;

    rep(i, N) {
        ans += L;
        tmp = min(tmp, abs(0 - L));
        L++;
    }

    if (L <= 0) {
        tmp = -tmp;
    }

    cout << ans - tmp << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from itertools import permutations as perm

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

a = 0
b = 0

for Pi in sorted(perm(P)):
    if P != Pi:
        a += 1
    if P == Pi:
        a += 1
        break
    
for Qi in sorted(perm(Q)):
    if Q != Qi:
        b += 1
    if Q == Qi:
        b += 1
        break

print(abs(a-b))

Measured memory_bytes: 8052
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		String s = sc.next();
		String t = sc.next();

		// 出力
		System.out.println(s.equals(t.substring(0, s.length())) ? "Yes" : "No");
		sc.close();
	}
}


Measured memory_bytes: 35508
n, x, y = map(int, input().split())
x -= 1
y -= 1
cnt = [0] * (n-1)

def calc(i, j):
    return min(j-i, (abs(i-x)+abs(j-y)+1))

for i in range(n-1):
    for j in range(i+1, n):
        cnt[calc(i,j)-1] += 1

for c in cnt: print(c)


Measured memory_bytes: 3444
#include<stdio.h>
#include<map>
using namespace std;
map<int,map<int,int> >mp,vis;
int a[100010],b[100010];
bool ex(int x,int y){
	return mp.count(x)&&mp[x].count(y);
}
int main(){
	int n,i,j,s,las,now;
	scanf("%d",&n);
	#define wa {puts("-1");return 0;}
	for(i=1;i<=n;i++){
		scanf("%d%d",a+i,b+i);
		if(i!=1&&a[i]==0)wa
		if(i!=2&&b[i]==0)wa
		mp[a[i]][b[i]]++;
	}
	for(i=1;i<=n;i++){
		if(i!=2){
			if(!(ex(a[i]-1,b[i]-1)||ex(a[i],b[i]-1)||ex(a[i]+1,b[i]-1)))wa
		}
		if(i!=1){
			if(!(ex(a[i]-1,b[i]+1)||ex(a[i]-1,b[i])||ex(a[i]-1,b[i]-1)))wa
		}
	}
	s=0;
	for(i=1;i<=n;i++){
		if(!ex(a[i]-1,b[i]+1)&&!vis[a[i]][b[i]]){
			if(a[i]==3&&b[i]==5){
				i++;
				i--;
			}
			vis[a[i]][b[i]]=1;
			las=0;
			for(j=0;ex(a[i]+j,b[i]-j);j++){
				now=mp[a[i]+j][b[i]-j];
				s+=min(las,now);
				now-=min(las,now);
				if(ex(a[i]+j-1,b[i]-j-1)){
					s+=now;
					now=min(las,mp[a[i]+j][b[i]-j]);
				}else
					now=mp[a[i]+j][b[i]-j];
				las=now;
			}
		}
	}
	printf("%d",2*n-2-s);
}

Measured memory_bytes: 29184
#include <stdio.h>
#define SIZE 10000

int p[SIZE];

void init();
void show();
int isPrime(int n);
long prime_sum(int n);

int main(int argc, const char *argv[])
{
	int n;
	init();
	
	while(scanf("%d", &n)!=EOF){
		if(!n) break;
		printf("%ld\n", prime_sum(n));
	}
	return 0;
}

void init()
{
	int i, j;
	p[0] = 2;
	for(i=1, j=3; i<SIZE; j+=2){
		if(!isPrime(j)) continue;
		p[i++] = j;
	}
}

int isPrime(int n)
{
	int i;
	if(n<=1) return 0;
	else if(n==2) return 1;
	else if(n%2==0) return 0;
	else
		for(i=3; i*i<=n; i++)
			if(n%i==0) return 0;
	return 1;
}

long prime_sum(int n)
{
	int i;
	long s = 0;
	for(i=0; i<n; i++)
		s += p[i];
	return s;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 200000
#define mx 18
#define mdn 1000000007
#define ll long long
#define lowbit(x) (x&(-x))
using namespace std;

int f[mx][maxn],a[mx],jc[maxn],inv[maxn];
bool cmp(int x,int y){return x>y;}

int ksm(int bs,int mi)
{
	int ans=1;
	while(mi)
	{
		if(mi&1)	ans=(ll)ans*bs%mdn;
		bs=(ll)bs*bs%mdn;mi>>=1;
	}
	return ans;
}

int C(int n,int m)
{
	if(n>m)	return 0;
	return (ll)jc[m]*inv[m-n]%mdn*inv[n]%mdn;
}

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

int main()
{
	int n,m,i,j,ans=0,k;
	scanf("%d%d",&n,&m);jc[0]=inv[0]=1;
	for(i=1;i<(1<<n);i++)	jc[i]=(ll)jc[i-1]*i%mdn,inv[i]=ksm(jc[i],mdn-2);
	for(i=1;i<=m;i++)	scanf("%d",&a[i]);
	sort(a+1,a+m+1,cmp);
	f[0][0]=1;
	for(i=1;i<=m;i++)
	{
		for(j=0;j<(1<<n);j++)	f[i][j]=(f[i][j]+f[i-1][j])%mdn;
		for(j=0;j<(1<<n);j++)
			for(k=0;k<n;k++)
				if(j&(1<<k))
					f[i][j]=(f[i][j]+(ll)f[i-1][j^(1<<k)]*jc[(1<<k)]%mdn*C((1<<k)-1,(1<<n)-a[i]-j+(1<<k))%mdn)%mdn;
	}
	for(i=0;i<(1<<n);i++)
	{
		k=f[m][i];
		if(count(i)&1)	k=-k;
		ans+=(ll)k*jc[(1<<n)-1-i]%mdn;
		if(ans<0)	ans+=mdn;
		if(ans>=mdn)	ans-=mdn;
	}
	printf("%d\n",(ll)ans*(1<<n)%mdn);
	return 0;
}

Measured memory_bytes: 12928
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x, y):
    x, y = find(x), find(y)
    if x == y: return False
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x
    return True

def same(x, y):
    return find(x) == find(y)

def size(x):
    return -par[find(x)]

N, M = map(int, input().split())
par = [-1]*N

for _ in range(M):
    a, b = map(int, input().split())
    unite(a-1, b-1)
par.sort()
cnt = 0
for i in range(N):
    if par[i] < 0:
        cnt += 1
print(cnt-1)

Measured memory_bytes: 75008
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Network{
	private:
	int V;
	struct edge{
		int to,cap,rev;
	};
	vector<vector<edge> > g;
	int DFS(int v,int t,int f,vi& iter,vi level){
		if(v==t) return f;
		for(int &i=iter[v];i<g[v].size();i++){
			edge &e=g[v][i];
			if(e.cap>0&&level[v]<level[e.to]){
				int d=DFS(e.to,t,min(f,e.cap),iter,level);
				if(d>0){
					e.cap-=d;
					g[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	void BFS(int s,vi& level){
		level=vi(V,-1);
		queue<int> que;
		level[s]=0;
		que.push(s);
		while(!que.empty()){
			int v=que.front();
			que.pop();
			for(int i=0;i<g[v].size();i++){
				edge &e=g[v][i];
				if(e.cap>0&&level[e.to]<0){
					level[e.to]=level[v]+1;
					que.push(e.to);
				}
			}
		}
	}
	public:
	Network(int v){
		V=v;
		g=vector<vector<edge> >(v);
	}
	void add_edge(int s,int t,int c){
		g[s].push_back(edge{t,c,(int)g[t].size()});
		g[t].push_back(edge{s,0,(int)g[s].size()-1});
	}
	int Dinic(int s,int t){
		int res=0;
		while(1){
			vi iter(V),level;
			BFS(s,level);
			if(level[t]<0) return res;
			int f;
			while((f=DFS(s,t,inf,iter,level))>0) res+=f;
		}
	}
	void dfs(int v,int c,vi& a){
		a[v]=1;
		for(int i=0;i<g[v].size();i++){
			edge &e=g[v][i];
			if(!a[e.to]&&e.cap==c) dfs(e.to,c,a);
		}
	}
	vi f(int v,int c){
		vi a(V);
		dfs(v,c,a);
		return a;
	}
};

int n,m,s,t;

int main(){
	while(1){
		cin>>n>>m>>s>>t;
		s--;t--;
		if(!n) break;
		Network nt(n);
		vi u,v;
		u=v=vi(m);
		for(int i=0;i<m;i++){
			cin>>u[i]>>v[i];
			u[i]--;
			v[i]--;
			nt.add_edge(u[i],v[i],1);
		}
		int f=nt.Dinic(s,t);
		vi a=nt.f(s,1),b=nt.f(t,0);
		int cnt=0,F=1;
		for(int i=0;i<m;i++) if(a[v[i]]&&b[u[i]]){
			cnt++;
			f+=F;
			F=0;
		}
		cout<<f<<' '<<cnt<<endl;
	}
}

Measured memory_bytes: 3468
def main():
    """
    input:
        1 <= N <= 100

    output:
        N! の約数のうち、七五数 は何個
        七五数とは約数をちょうど 75個持つ正の整数
    """
    N = int(input())

    ans = f(N)
    print(ans)


def f(N):
    """素因数分解までは浮かんだ
    """
    factor_all = [[] for _ in range(N + 1)]
    factors = [0] * (N + 1)
    for i in range(2, N + 1):
        # N_max=100 より √i にしなくても高速なので簡易に実装
        x = i
        for div in range(2, x + 1):
            while x % div == 0:
                factors[div] += 1
                factor_all[i].append(div)
                x //= div

    # print(factors)
    # print(factor_all)
    ans1 = editorial(factors)
    ans2 = ref(factors)
    assert ans1 == ans2

    return ans1


def editorial(factors):
    factors = factors

    def a(x):
        n = 0
        for f in factors:
            if f >= x - 1:
                n += 1

        return n

    # どういうこと？
    # 75: 1つの素数で0~74乗なのでわかる
    # -1: => 0乗は1だから、他のパターンでも起こるので除外？
    # 75,
    ans = a(75)
    ans += a(25) * (a(3) - 1)
    ans += a(15) * (a(5) - 1)
    ans += a(5) * (a(5) - 1) * (a(3) - 2) // 2

    return ans


def ref(factors):
    """https://beta.atcoder.jp/contests/abc114/submissions/3704878
    """
    # 2以上の理由: n=1ではその数字は素数なので約数が1と自信しかないので意味がない
    # a^1 * b^2 * c^3: 1*2*3=6通り と使っても約数の数が変わらない
    nums = [n for n in factors if n >= 2]

    # 75 の約数
    divs = [i for i in range(1, 75+1) if 75 % i == 0]

    # dp[i][j]
    # i: 1-index baseで nums[1]...nums[n]までの n種類の素因数についてi番目まで利用
    # j: 約数の数0-75 まで
    # どんな数でも1では割れるので1, 1は素数に含めない
    n_nums = len(nums)
    dp = [[0] * (75 + 1) for _ in range(n_nums + 1)]
    dp[0][1] = 1

    # 75個なので,75の約数の組合せでしか割れないのは分かるが
    # 2重ループでよいのか？: [1, 3. 15, 25, 75]
    from itertools import product
    div_pairs = [(d1, d2)
                 for d1, d2 in product(divs, repeat=2)
                 if d1 * d2 <= 75]

    for i in range(n_nums):
        for d1, d2 in div_pairs:
            # TODO: 75 = 3^1 * 5^2, そもそも 3*15=3^2*5, 3*3, は必要なのか？
            if d1 * d2 in (45, 9):
                continue

            # 遷移
            # i−1 番目の素因数まででできた約数が d1 個で、
            # i 番目の素因数を d2−1 個選ぶ、という選び方
            # => editorial 内の a func の f >= x - 1 と同じ

            # nums[i] + 1 >= d2: より下記のほうが意味がわかりそう
            if nums[i] >= d2 - 1:
                # print(i, nums[i], (d1, d2), d1 * d2,
                #       dp[i][d1], dp[i+1][d1 * d2], sep="\t")
                dp[i+1][d1 * d2] += dp[i][d1]

    ans = dp[n_nums][75]
    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
    #include <set>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    //
    #define llong long long
    #define pb(a) push_back(a)

    #define INF 100000000
    #define MOD 100000007

    #define writeln(n) cout<<n<<endl

    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;
    //vector<tuple<long long, long long, long long>>vec;


    bool isprime(int p) {
        if (p == 1) return false;
        for (int i = 2; i < p; i++) {
            if (p%i == 0) return false;
        }
        return true;
    }

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

    const int inf=100000000;

    long long modpow(long long a, long long n, long long mod) //a^n
    {
        long long res = 1;
        while (n > 0) {
            if (n & 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }

    int gcd(int a, int b) {
        return b != 0 ? gcd(b, a % b) : a;
    }
    //setprecision(10);

    //素数判定
    bool isprime(llong p) {
        if (p == 1) return false;
        for (llong i = 2; i*i <= p; i++) {
            if (p%i == 0) return false;
        }
        return true;
    }


    int main() {
        ios::sync_with_stdio(false);
        cin.tie(0);
        int n; cin>>n;
        pair<int, int> cnt[n];

        int v[n];
        REP(i,n)
        {
            cin>>v[i];
        }
        for(int j=0; j<n; j++)
        {
            cnt[j].first=v[j];
            cnt[j].second=j+1;
        }
        sort(cnt,cnt+n);
        REP(i,n)
        {
            cout<<cnt[i].second<<" ";
        }
        cout<<endl;


        return  0;
    }


Measured memory_bytes: 2048
import java.util.*;

public class Main {
  private static final int MOD = 1_000_000_007;
  private static int[] fact;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    Arrays.sort(A);
    
    if (K == 1) {
      System.out.println(0);
      return;
    }
    
    long[] sum = new long[N+1];
    for (int i = 1; i <= N; i++) {
      sum[i] = sum[i-1]+A[i-1];
    }
    
    fact = new int[N+1];
    fact[0] = 1;
    for (int i = 1; i <= N; i++) {
      fact[i] = (int)((long)i*fact[i-1]%MOD);
    }
    
    long ans = 0;
    for (int n = K; n <= N; n++) {
      long tmp = sum[N]-sum[n-1]- sum[N-n+1];
      tmp %= MOD;
      
      tmp *= combMod(n-2,K-2);
      tmp %= MOD;
      
      ans += tmp;
      ans %= MOD;
    }
    
    System.out.println(ans);
  }
  
  private static long combMod(int n, int k) {
    return (long)fact[n]*pow((long)fact[k]*fact[n-k]%MOD,MOD-2)%MOD;
  }
  
  private static long pow(long a, int n) {
    if (n == 0) {
      return 1;
    }
    if (n%2 == 1) {
      return a*pow(a,n-1)%MOD;
    }
    long half = pow(a,n/2)%MOD;
    return half*half%MOD;
  }
}

Measured memory_bytes: 50820
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define fi first
#define se second
#define gc getchar
#define pc putchar
inline ll rd(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
inline void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);puts("");}
const int maxn = 1e5+233;
const int mod = 1e9+7;
void add(int &x,int v){
	x+=v;
	if(x>=mod) x-=mod;
}
char t[maxn]; 
int n,ans,s[maxn],dp[maxn],nxt[maxn][3];
int main() {
	scanf("%s",t+1);n=strlen(t+1);
	bool flag=0;
	Rep(i,1,n-1) if (t[i]==t[i+1]) flag=1;
	if (!flag) return puts("1"),0;
	Rep(i,1,n) s[i]=t[i]-'a'+1;
	Rep(i,1,n+1) s[i]=(s[i]+s[i-1])%3;
	Rep(i,0,2) nxt[n+1][i]=n+1;
	Dep(i,n,1){
		Rep(j,0,2) nxt[i][j]=nxt[i+1][j];
		nxt[i][s[i]]=i;
	}
	dp[1]=1;
	Rep(i,1,n+1){
		Rep(k,1,2)
			if(nxt[i][(s[i-1]+k)%3] != n+1)
				add(dp[nxt[i][(s[i-1]+k)%3]+1],dp[i]);
		if(s[i-1]==s[n]&&i!=1) add(ans,dp[i]);
	}
	writeln(ans);
}

//0 1 2 3 4 5 
//0 1 2 0 1 X


Measured memory_bytes: 2304
mod=10**9+7
h,w=map(int,input().split())
grid=[]
for  i in range(h):
	a=input()
	grid.append(list(a))

grid[0][0]=1
for i in range(1,h):
	if(grid[i-1][0]==0):
		grid[i][0]=0
	elif(grid[i][0]=='#'):
		grid[i][0]=0
	else:
		grid[i][0]=grid[i-1][0]
for i in range(1,w):
	if(grid[0][i-1]==0):
		grid[0][i]=0
	elif(grid[0][i]=='#'):
		grid[0][i]=0
	else:
		grid[0][i]=grid[0][i-1]

for i in range(1,h):
	for j in range(1,w):
		if(grid[i][j]=='#'):
			grid[i][j]=0
		else:
			grid[i][j]=(grid[i][j-1]+grid[i-1][j])%mod
print(grid[h-1][w-1])
# import pprint
# grid.insert(0,grid)
# pprint.pprint(grid)


Measured memory_bytes: 152844
#include<bits/stdc++.h>
#define int long long int
#define rep(a,b) for(int a=0;a<b;a++)
#define pb push_back
#define str string
#define INF 1<<64
#define sf(a) scanf("%d",&a)
using namespace std;
int n,k,m;
int memo[10]={1,1,1,1,1,1,1,1,1,1};
///moudame
signed main(){
  //  fill(memo,memo+10,1);
    cin >> n >>k;
    rep(i,k){
        cin >> m;
        memo[m]=0;
    }
    int y=0;

    for(int i=n;;i++){
        y=i;
        bool no=false;
        while(1){
            if((y/10)<=0){
               // cout << "a";
                if(memo[(int)(y%10)]){cout << i << endl;no=true;}
                break;
            }else{
                if(memo[y%10]){y/=10;}
                else break;
            }
        }
        if(no)break;
    }
return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
 
typedef long long  ll;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
string s,t;
int main(){
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    for(int i=n-m;i>=0;i--){
        int chk = 0;
        for(int j=0;j<m;j++){
            if(s[i+j]=='?' || s[i+j]==t[j]) continue;
            else {
                chk = 1;
                break;
            }
        }
        if(!chk){
            for(int j=0;j<m;j++)
                s[i+j] = t[j];
            for(int i=0;i<n;i++){
                if(s[i]=='?') s[i] = 'a';
            }
            cout << s << endl;
            return 0;
        }
    }
    printf("UNRESTORABLE\n");
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int A, B, C;

  std::cin >> A >> B >> C;

  std::swap(A, B);
  std::swap(A, C);

  std::cout << A << ' ' << B << ' ' << C << std::endl;

  return 0;
}


Measured memory_bytes: 256