akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;

bool judge(string S){
    bool flag = true;
    if(S.find("AGC") != string::npos) flag = false;
    else if(S.find("GAC") != string::npos) flag = false;
    else if(S.find("ACG") != string::npos) flag = false;
    else if(S == "ATGC") flag = false;
    else if(S == "AGGC") flag = false;
    else if(S == "AGTC") flag = false;
    return flag;
}


string SS = "ATGC";

int main(){
    ll N; cin >> N;
    if(N == 3){ cout << 61 << endl; return 0;}
    //if(N == 4){ cout << 230 << endl; return 0;}
    map<string, vector<ll>> M;
    for(auto c1 : SS){
        for(auto c2 : SS){
            for(auto c3 : SS){
                for(auto c4 : SS){
                    string tmp = "";
                    tmp+=c1; tmp+=c2; tmp+=c3; tmp+=c4;
                    M[tmp].resize(101);
                    M[tmp][4] = 1;
                }
            }
        }
    }
    for(int i = 5; i <= N; i++){
        for(auto c1 : SS){
            for(auto c2 : SS){
                for(auto c3 : SS){
                    for(auto c4 : SS){
                        string tmp = "";
                        tmp+=c1; tmp+=c2; tmp+=c3; tmp+=c4;
                        for(auto c5 : SS){
                            string tmp2 = "";
                            tmp2+=c2; tmp2+=c3; tmp2+=c4; tmp2+=c5;
                            if(judge(tmp))M[tmp2][i] += (M[tmp][i-1])%MOD;
                            M[tmp2][i] %= MOD;

                        }
                    }
                }
            }
        }
    }
    ll ans = 0;
    for(auto c1 : SS){
        for(auto c2 : SS){
            for(auto c3 : SS){
                for(auto c4 : SS){
                    string tmp = "";
                    tmp+=c1; tmp+=c2; tmp+=c3; tmp+=c4;
                    if(judge(tmp)) { ans+= M[tmp][N]; ans %= MOD;}
                }
            }
        }
    }
    cout << ans << endl;


    
}


Measured memory_bytes: 512
#include <cmath>
#include <iostream>

void koch(int n, double p1x, double p1y, double p2x, double p2y)
{
    if (n == 0) return;

    double sx = 2.0 * p1x / 3.0 + p2x / 3.0;
    double sy = 2.0 * p1y / 3.0 + p2y / 3.0;

    double tx = p1x / 3.0 + 2.0 * p2x / 3.0;
    double ty = p1y / 3.0 + 2.0 * p2y / 3.0;

    double ux = (tx + sx) / 2.0 + sqrt(3.0) * (sy - ty) / 2.0;
    double uy = sqrt(3.0) * (tx - sx) / 2.0 + (ty + sy) / 2.0;

    koch(n-1, p1x, p1y, sx, sy);
    std::cout << sx << " " << sy << std::endl;
    koch(n-1, sx, sy, ux, uy);
    std::cout << ux << " " << uy << std::endl;
    koch(n-1, ux, uy, tx, ty);
    std::cout << tx << " " << ty << std::endl;
    koch(n-1, tx, ty, p2x, p2y);
}

int main(int argc, char const *argv[])
{
    int n;
    std::cin >> n;

    double p1x = 0.0;
    double p1y = 0.0;
    double p2x = 100.0;
    double p2y = 0.0;

    std::cout << p1x << " " << p1y << std::endl;
    koch(n, p1x, p1y, p2x, p2y);
    std::cout << p2x << " " << p2y << std::endl;

    return 0;
}

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

int main() {
	int X;
	cin >> X;
	// 1 origin
	vector<bool> expo(X+1);
	expo[1] = true;

	for (int b=2; b<=sqrt(X); ++b) {
		// p=2
		int v = b * b;
		while (v <= X) {
			expo[v] = true;
			// b^p, p=3,4,...
			v *= b;
		}
	}
	int result = 1;
	for (int i=X; i>=1; --i) {
		if (expo[i]) {
			cout << i << endl;
			return 0;
		}
	}
}
	


Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	m := scanInt()
	q := scanInt()
	
	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, n)
	}

	for i := 0; i < m; i++ {
		l := scanInt()-1
		r := scanInt()-1
		a[r][l]++
	}

	sum := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		sum[i] = make([]int, n+1)
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			sum[i+1][j+1] = sum[i+1][j] + a[i][j]
		}
		for j := 0; j < n; j++ {
			sum[i+1][j+1] += sum[i][j+1]
		}
		// fmt.Fprintln(os.Stderr, sum[i+1])
	}

	for i := 0; i < q; i++ {
		p := scanInt()
		q := scanInt()

		fmt.Fprintln(wr, sum[q][q]-sum[q][p-1]-sum[p-1][q]+sum[p-1][p-1])
	}

	wr.Flush()
}




Measured memory_bytes: 7168
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
using namespace std;
using ll=long long;
constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
 
int main() {
ll Q,H,S,D;
ll N;

ll ans=0;
  cin >> Q>>H>>S>>D;
  cin >> N;

ll saiyasu;

 saiyasu =Q*4;
 if(Q*4>H*2){ saiyasu =H*2;};
 if(saiyasu>S){ saiyasu =S;};

ans= (N/2)*D+(N%2)*saiyasu;

if(ans>N*saiyasu){ans=N*saiyasu;}


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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector <int> npr(n);
    vector<int> p(n);
    vector<int> q(n);
    FOR(i,0,n){
        npr[i]=i+1;
        cin >> p[i];
    }
    FOR(i,0,n){
        cin >> q[i];
    }
    int a=0;
    int b=0;
    int ans = 0;
    int c=0;
    do{
        c++;
        if (p==npr)a=c;
        if (q==npr)b=c;
    }while(next_permutation(npr.begin(),npr.end()));
    ans =abs(a-b);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int in(){
    int x=0;bool f=0;char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
int l[62],r[62],v[62],L,d,tot,res;
int main()
{
	L=in();
	for (d=1;(1<<d)<=L;++d);
	for (int i=1;i<d;++i){
		l[++tot]=i;r[tot]=i+1;v[tot]=(1<<(i-1));
		l[++tot]=i;r[tot]=i+1;v[tot]=0;
	}
	res=(1<<(d-1));
	for (int i=d;i>=2;--i){
		if (L&(1<<(i-2))){
			l[++tot]=i-1;r[tot]=d;v[tot]=res;
			res+=(1<<(i-2));
		}
	}
	printf("%d %d\n",d,tot);
	for (int i=1;i<=tot;++i)
	printf("%d %d %d\n",l[i],r[i],v[i]);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    string ans;
    while(N)
    {
        if(N%2==0) ans='0'+ans;
        else{
            ans='1'+ans; N-=1;
        }
        N/=-2;
    }
    if(ans=="") ans="0";
    cout<<ans<<endl;
}


Measured memory_bytes: 256
def selectionSort(A, N):
    cnt = 0
    for i in range(0, N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        cnt = cnt + int(i != minj)
        A[i], A[minj] = A[minj], A[i]
    return cnt
N = int(input())
A = [int(i) for i in input().split()]
cnt = selectionSort(A, N)
  
for i in range(N):
    if i != 0:
        print(" ", end = "")
    print(A[i], end = "")
      
print()
print(cnt)


Measured memory_bytes: 5628
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int next() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextStr() {
            int c = next();
            while (isSpaceChar(c)) {
                c = next();
            }
            StringBuffer str = new StringBuffer();
            do {
                str.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return str.toString();
        }

        public int nextInt() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

    public static void main(String[] args) throws IOException {

        InputReader sc = new InputReader(System.in);
        int n1 = sc.nextInt();
        int sp1[] = new int[n1];
        for (int i = 0; i < n1; i++) {
            sp1[i] = sc.nextInt();
        }
        int n2 = sc.nextInt();
        int sp2[] = new int[n1];
        for (int i = 0; i < n2; i++) {
            sp2[i] = sc.nextInt();
        }
        int sum = 0;
        for (int j = 0; j < n2; j++) {
            if (Arrays.binarySearch(sp1, sp2[j]) > 0) {
                sum++;
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 27136
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

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

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    vector<int> l(n), r(n);
    for(int i=0; i<n; i++) cin>>l[i]>>r[i];
    sort(l.begin(), l.end(), greater<int>());
    sort(r.begin(), r.end());

    ll ans = 0;

    // start from left
    ll sum = 0;
    for(int i=0; i<n; i++){
        sum += l[i];
        chmax(ans, sum);
        sum -= r[i];
        chmax(ans, sum);
    }

    // start from right
    sum = 0;
    for(int i=0; i<n; i++){
        sum -= r[i];
        chmax(ans, sum);
        sum += l[i];
        chmax(ans, sum);
    }

    cout << ans * 2 << endl;

    return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
b = 2

counter = 0
while True:
    flag = True
    for i in range(n):
        if a[i] % b != 0:
            flag = False
            break
    
    if flag == False:
        break
    counter = counter + 1
    b = b * 2
print(counter)



Measured memory_bytes: 3060
MOD = 10**9 + 7

def make_fac_tables_mod_p(n, p):
  fac = [0] * (n+1)
  fac_inv = [0] * (n+1)
  mod_inv = [0] * (n+1)
  fac[0] = fac[1] = 1
  fac_inv[0] = fac_inv[1] = 1
  mod_inv[1] = 1
  for i in range(2, n+1):
    fac[i] = (fac[i-1] * i) % p
    mod_inv[i] = p - mod_inv[p % i] * (p // i) % p
    fac_inv[i] = fac_inv[i-1] * mod_inv[i] % p
  return fac, fac_inv

def nCk_mod_p(fac, fac_inv, n, k, p):
  return ((fac[n] * fac_inv[n-k]) % p) * fac_inv[k] % p

X, Y = map(int, input().split())

ans = 0
q, r = divmod(X+Y, 3)
if r == 0 and (q <= X <= 2*q) and (q <= Y <= 2*q):
  n = q
  k = X - q
  fac, fac_inv = make_fac_tables_mod_p(n, MOD)
  ans = nCk_mod_p(fac, fac_inv, n, k, MOD)

print(ans)


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

int main() {
	int time=0;
	int A, B, C, D, E;
	cin >> A >> B >> C >> D >> E;
	int N=5;
	
	vector <int> Time={A, B, C, D, E};
	vector <int> index={0, 1, 2, 3, 4};
	
	int bestTime=(int)1e9;
	do{
	    int Nowtime=0;
	    for (int i=0; i<N; i++){
	        while (Nowtime%10!=0) Nowtime++;
	        Nowtime+=Time[index[i]];
	    }
	    bestTime=min(bestTime, Nowtime);
	} while (next_permutation(index.begin(), index.end()));
	cout << bestTime << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <vector>
#include <cmath>
#include <bitset>
#include <set>
#include <complex>
#include <queue>
#include <stack>


#define mp make_pair
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const ld pi = acos(-1.0);
const ld e  = exp(1.0);

int n, m;
const int maxn = 200010;
bool from1[maxn], ton[maxn];

int main(){
	
	scanf("%d %d", &n, &m);
	for(int i=0; i<m; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		if(a==1) from1[b] = true;
		if(b==n) ton[a] = true;
	}
	bool can = false;
	for(int mid = 2; mid < n; mid++ ) can |= (from1[mid] && ton[mid]);
	printf(can?"POSSIBLE\n":"IMPOSSIBLE\n");
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int a[4];
    for(int i=0;i<s.size();i++) a[i]=s[i]-'0';
    cout<<a[0];
    int sum=a[0];
    int bum=a[0]+a[1]+a[2]+a[3];
    if(bum==7)
    {
        printf("+%d+%d+%d=7\n",a[1],a[2],a[3]);
        return 0;
    }
    int b=a[0],h;
    bool e=0;
    for(int i=1;i<4 && !e;i++)
    {
        b=bum;
        b-=a[i];
        if(b==7+a[i])
        {
            a[i]=-a[i];
            e=1;
            break;
        }
    }
    b=a[0];
    if(e==0)
    for(int i=1;i<4 && !e;i++)
    {
        b=bum;
        b-=a[i];
            for(int j=1;j<4;j++)
            {
                if(j!=i)
                {
                    h=b;
                    h-=a[j];
                    if(h==7+a[i]+a[j]) {a[i]=-a[i];a[j]=-a[j];e=1;break;}
                }
            }
    }
    for(int i=1;i<4;i++) 
    {
        if(a[i]<0) cout<<a[i];
        else cout<<"+"<<a[i];
    }
    cout<<"=7"<<endl;
    return 0;
}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    ll N;
    cin >> N;
    ll A[85];
    rep(i,0,N) cin >> A[i];
    ll dp[85] = {};
    dp[0] = 1000;
    rep(i,0,N){
        rep(j,i+1,N){
            dp[j] = max(dp[j], dp[i]);
            if(A[i] >= A[j]) continue;
            ll n = dp[i] / A[i];
            ll money = dp[i] % A[i] + n * A[j];
            dp[j] = max(dp[j], money);
        }
    }
    print(dp[N-1]);
    

}

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

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define x first
#define y second
#define sz(a) ((int)(a.size()))

const int MAX = 500005;
const int mod = 998244353;
int x[1005] , y[1005] , r[1005] , used[1005];
ll sq(int x)
{
	return x * (ll)x;
}
double d(int x1, int y1, int x2, int y2)
{
	return sqrt(sq(x1 - x2) + sq(y1 - y2));
}
double dist[1005][1005];
double res[1005];
int main()
{
	cin >> x[0] >> y[0] >> x[1] >> y[1];
	int n;
	cin >> n;
	n += 2;
	for(int i = 2; i < n; i++)
	{
		cin >> x[i] >> y[i] >> r[i];
	}
	for(int i = 1; i < n; i++)	
		res[i] = 1e12;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			dist[i][j] = max(0. , d(x[i] , y[i] , x[j] , y[j]) - r[i] - r[j]);
	for(int i = 0; i < n; i++)
	{
		int best = -1;
		for(int j = 0; j < n; j++)
			if(!used[j])
			if(res[j] < (best == -1 ? 1e13 : res[best]))
			{
				best = j;
			}
		used[best] = 1;
		for(int j = 0; j < n; j++)
			if(res[best] + dist[best][j] < res[j])
				res[j] = res[best] + dist[best][j];
				
	}
	cout << fixed << setprecision(11) << res[1] << endl;
			
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
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; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll n;
        cin >> n;
        vll a(n);
        rep(i, 0, n) cin >> a[i];

        ll mx = *max_element(all(a));
        sort(all(a));
        ll pos = lower_bound(all(a), mx/2.0) - a.begin();
        ll cand1 = a[pos];
        ll cand2 = a[pos-1];
        ll mn;
        if (abs(mx/2.0-cand1) < abs(mx/2.0-cand2)) {
                mn = cand1;
        } else {
                mn = cand2;
        }
        cout << mx << ' ' << mn << endl;
}

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

int main () {
	int sn, tn, t, l, r, m, c = 0;
	cin >> sn;
	int *s = new int[sn];
	for (int i = 0; i < sn; i++)
		cin >> s[i];
	cin >> tn;
	for (int i = 0; i < tn; i++) {
		cin >> t;
		l = 0;
		r = sn - 1;
		while(l <= r) {
			m = (l + r) / 2;
			if (s[m] == t) {
				c++;
				break;
			}
			else if (t < s[m])
				r = m - 1;
			else
				l = m + 1;
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 3448
#pragma warning (disable :4996)
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
const double PI = cos(-1.0);
const double eps = 1e-12;
#define For(i,n,m) for(int i=n;i<=m;++i)
#define clr(a,b) memset(a,b,sizeof(a))

ll maxn;
int n, m, q;
struct Node {
	int a, b, c, d;
}A[100];

vector<int> v;
void dfs(int cur) {
	if (cur == n + 1) {
		ll ans(0);
		For(i, 1, q) {
			if (v[A[i].b] - v[A[i].a] == A[i].c) ans += A[i].d;
		}
		if (maxn <= ans) {
			maxn = ans;
		}
		return;
	}
	int k = v[cur - 1]; //v[i]
	while (k<= m) {
		v.push_back(k);
		dfs(cur + 1);
		v.erase(v.begin() + cur);
		++k;		
	}
}
int main() {
	ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	cin >> n >> m >> q;
	For(i, 1, q) cin >> A[i].a >> A[i].b >> A[i].c >> A[i].d;
	v.push_back(1);
	dfs(1);
	cout << maxn << "\n";
}

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

int main(void){
    int k, n;
    cin >> k >> n;
    vector<int> a(n), dist(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    for(int i = 0; i < n-1; i++){
        dist.push_back(a[i+1] - a[i]);
    }
    dist.push_back(a[0] + (k - a[n-1]));
    sort(dist.begin(), dist.end());
    cout << k - dist.back() << endl;
    return 0;
}


Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1e18;
int main() {
    int n,m;
    cin >> n >> m;
    vector<set<int>> v(m);
    for(int i=0;i<m;i++){
        int k;
        cin >> k;
        for(int j=0;j<k;j++){
            int x;
            cin >> x;
            v[i].insert(x-1);
        }
    }
    vector<int> p(m);
    for(auto &x:p){
        cin >> x;
    }
    int ret = 0;
    for(int i=0;i<1<<n;i++){
        vector<int> ch(m,0);
        for(int j=0;j<n;j++){
            if(i>>j & 1){
                for(int k=0;k<m;k++){
                    if(v[k].find(j)!=v[k].end())ch[k]^=1;
                }
            }
        }
        if(ch==p)ret++;
    }
    cout << ret << endl;
    return 0;
}


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

int main(){
  int H,W;
  int i,j;
  int map[50][50];
  int memo[50][50];
  char c;
  scanf("%d%d",&H,&W);
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      cin>>c;
      //scanf("%c",&c);
      map[i][j]=c-'0';
    }
  }
  for(i=1;i<H;i++){
    memo[i][0]=memo[i-1][0]+map[i][0];
  }
  for(j=1;j<W;j++){
    memo[0][j]=memo[0][j-1]+map[0][j];
  }
  for(i=1;i<H;i++){
    for(j=1;j<W;j++){
      int n1=memo[i-1][j]+map[i][j];
      int n2=memo[i][j-1]+map[i][j];
      memo[i][j]=min(n1,n2);
    }
  }
  printf("%d\n",memo[H-1][W-1]);

  return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;


int main() {
  int N, Y; cin >> N >> Y;
  int result[3] = {-1, -1, -1};
  rep(x, N+1) rep(y, N+1-x) {
    int z = N-x-y;
    if (10000*x+5000*y+1000*z==Y) {
      result[0] = x;
      result[1] = y;
      result[2] = z;
    }
  }

  rep(i, 3) { if (i!=0) cout << " "; cout << result[i]; } cout << endl;
  return 0;
}

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

void main()
{
  long n = readln.chomp.to!long;
  long ans = 0;
  foreach (i; 0 .. n + 1)
  {
    if (i * i > n)
    {
      break;
    }
    ans = i * i;
  }
  ans.writeln;
}


Measured memory_bytes: 256
s = input()

f = 0
for i in s:
    if f == 0:
        if not i in ['R', 'U', 'D']:
            print("No")
            exit()
    else:
        if not i in ['L', 'U', 'D']:
            print("No")
            exit()


    f = 1 - f
print("Yes")



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

int main(){
	int x, t, y;
	cin >> x >> y;
	for(int i = 0; i <= x; i++){
		t = x - i;
		int asi = 2*i + 4*t;
		if(asi == y){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
const int N = 303;
int n, k, Mod, C[N][N], dp[N][N];
int main()
{
    scanf("%d%d%d", &n, &k, &Mod); n ++;
    for (int i = 0; i <= n; i ++)
        for (int j = C[i][0] = C[i][i] = 1; j < i; j ++)
            C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % Mod;
    for (int i = 0; i <= n; i ++)
        dp[1][i] = 1;
    for (int l = 2; l <= k; l ++)
        for (int i = dp[l][0] = 1; i <= n; i ++)
            for (int j = 1; j <= i; j ++)
                dp[l][i] = (dp[l][i] + 1LL * C[i - 1][j - 1] * dp[l - 1][j] % Mod * dp[l][i - j]) % Mod;
    return !printf("%d\n", dp[k][n]);
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

N = int(input())

yaku = 0

for i in range(1,N+1):
    y = 0
    if i % 2 == 1:
        for j in range(1,i+1):
            if i % j == 0:
                y = y + 1
        if y == 8:
            yaku = yaku + 1

print(yaku)

Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(void){
    int a[4],b[4];
    while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
    int hit=0,blow=0;
    for(int i=0; i<4; i++){
        for(int j=0; j<4; j++){
            if(a[i] == b[j]){
                if(i == j) hit++;
                else blow++;
            }
        }
    }
    cout << hit << " " << blow << endl; 
  }
}


Measured memory_bytes: 3048
N=int(input())
l=list()
a=0
for i in range(N):
    l.append(list(map(int,input().split())))
    for _ in l:
        a+=((_[0]-l[-1][0])**2+(_[1]-l[-1][1])**2)**(1/2)
print(2*a/N)

Measured memory_bytes: 3060
n = int(input())
a_list = list(map(int, input().split()))

ans = 0
u_d = -1
for i, a in enumerate(a_list):
    if i == 0:
        tmp = a
        continue
    
    if a-tmp == 0:
        tmp = a
        continue

    if u_d == -1 and a > tmp:
        u_d = 1 # 上の時1
        tmp = a
        continue
    elif u_d == -1 and a < tmp:
        u_d = 0 # 下の時0
        tmp = a
        continue
    #print(a, u_d, ans)
     
    if a > tmp:
        if u_d == 1:
            tmp = a
            #print('############################33')
            continue
        elif u_d == 0:
            ans += 1
            u_d = -1
            tmp = a

    elif a < tmp:
        if u_d == 0:
            tmp = a
            #print('############################33')
            continue
        elif u_d == 1:
            ans += 1
            u_d = -1
            tmp = a

    #print(a, u_d, ans)
    #print('############################33')

print(ans+1)

Measured memory_bytes: 62704
#include <stdio.h>
#include <string.h>
#include <queue>
#include <utility>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)

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

int H, W, wall[32][32][4], ds[32][32];

int solve() {
    typedef pair<int, int> P;
    memset(ds, -1, sizeof(ds));
    queue<P> q;
    q.push(P(0, 0));
    ds[0][0] = 1;
    while(!q.empty()) {
        pair<int, int> vv(q.front());
        q.pop();
        const int x = vv.first;
        const int y = vv.second;
        if(x==H-1 && y==W-1) return ds[x][y];
        rep(d, 4) if(wall[x][y][d]==0) {
            const int nx = x+dx[d], ny = y+dy[d];
            if(ds[nx][ny]==-1) {
                ds[nx][ny] = ds[x][y]+1;
                q.push(P(nx, ny));
            }
        }
    }
    return 0;
}

int main() {
    for(;;) {
        scanf("%d%d", &W, &H);
        if(W==0 && H==0) return 0;
        memset(wall, -1, sizeof(wall));
        rep(i, 2*H-1) {
            const int x = i/2;
            if(i%2==0) {
                rep(j, W-1) {
                    int a;
                    scanf("%d", &a);
                    wall[x][j][1] = wall[x][j+1][3] = a;
                }
            }
            else {
                rep(j, W) {
                    int a;
                    scanf("%d", &a);
                    wall[x][j][0] = wall[x+1][j][2] = a;
                }
            }
        }
        printf("%d\n", solve());
    }
}

Measured memory_bytes: 0
N,X,Y = map(int, input().split())

k = [0]*N
for p1 in range(1,N):
  for p2 in range(p1+1,N+1):
    d = [0]*3
    d[0] = p2-p1
    d[1] = abs(X-p1)+1+abs(Y-p2)
    d[2] = abs(X-p2)+1+abs(Y-p1)
    k[min(d)] += 1
k = list(map(str, k))
print('\n'.join(k[1:N]))

Measured memory_bytes: 44508
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();

		int MAX = str.length();
		int sum = 0;
		for(int i = 0; i < MAX; i++) {
			int s = Integer.parseInt(str.substring(i,i+1));
			sum = sum + s;
		}

		if(sum%9==0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
      
	}
}


Measured memory_bytes: 38808
var main = (input: string) => {
    let a: string[] = input.split("\n");
    let template: string = a[0];
    let target: string = a[1];

    let minCount = target.length;
    for (let i: number = 0; i <= template.length - target.length; i++) {
        let hollowed = template.substring(i, i + target.length);
        let count = 0;
        for (let j: number = 0; j < target.length; j++) {
            if (hollowed.charAt(j) !== target.charAt(j)) {
                count++;
            }
        }
        if (count < minCount) {
            minCount = count;
        }
    }
    console.log(minCount);
}

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

Measured memory_bytes: 32448
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int A,B;
	scanf("%d %d",&A,&B);

	if((A%3 ==0) || (B%3 ==0) || ((A+B)%3 == 0)){

		printf("Possible\n");

	}else{

		printf("Impossible\n");
	}

	return 0;
}


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

long long a, b, cnt = 0;

int main() {
  long long now = 1;
  cin >> a >> b;
  while(now < b) {
    now += a - 1;
    ++cnt;
  }
  cout << cnt << endl;
  return 0;
}

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

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

    if (s == "SSS")
        cout << 0;
    else if (s == "SSR")
        cout << 1;
    else if (s == "SRS")
        cout << 1;
    else if (s == "SRR")
        cout << 2;
    else if (s == "RSS")
        cout << 1;
    else if (s == "RSR")
        cout << 1;
    else if (s == "RRS")
        cout << 2;
    else if (s == "RRR")
        cout << 3;
    cout << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
using namespace std;
// HATI HATI klo A[i] == 1
const int MAX_N = 1e6 + 5;
int main(){
    int frek[MAX_N] = {0};
    vector<int> prime = {2};
    bool computed[1001] = {0};
    for (int i = 3 ; i <= 1000 ; i += 2){
        if (!computed[i]){
            prime.push_back(i);
            for (int j = i * i ; j <= 1000 ; j += 2 * i)
                computed[j] = 1;
        }
    }
    int N;
    cin >> N;
    for (int i = 0 , a  ; i < N ; i++){
        cin >> a;
        for (int it : prime){
            if (it * it > a)
                break;
            if (!(a % it)){
                ++frek[it];
                //cout << "i : " << it << endl;
                while(!(a % it))
                    a /= it;
            }
        }
        if (a > 1)
            ++frek[a];
    }

    bool all_one = 1 , setwise = 1;
    for (int i = 1 ; i <= 1e6 ; i++){
       // cout << "frek[" << i << "] : " << frek[i] << endl;
        if (frek[i] > 1)
            all_one = 0;
        if (frek[i] == N)
            setwise = 0;
    }
    if (all_one)
        cout << "pairwise coprime\n";
    else if (setwise)
        cout << "setwise coprime\n";
    else
        cout << "not coprime\n";

}


Measured memory_bytes: 7540
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x,cnt = 0;
  cin >> a >> b >> c >> x;
  for(int i=0;i<=a;i++){
	for(int j=0;j<=b;j++){
  	  for(int k=0;k<=c;k++){
        if(i*500 + j*100 + k*50 == x) cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize,
        s: String,
    }
    let chars = s.chars().collect::<Vec<char>>();
    let cnt = |c| s.chars().filter(|&x| x == c).count();
    let mut ans = cnt('R') * cnt('G') * cnt('B');
    for j in 0..n {
        for d in 1..j + 1 {
            let i = j - d;
            let k = j + d;
            if k < n {
                if chars[i] != chars[j] && chars[i] != chars[k] && chars[j] != chars[k] {
                    ans -= 1;
                }
            }
        }
    }
    println!("{}", ans);
}


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORE(i, a, b) for (int i = (a); i <= (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(v) (v).begin(), (v).end()
#define sp cout << fixed << setprecision(10)
typedef pair<int, int> P;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

    ll h;
    cin >> h;

    if (h == 1) {
        cout << 1 << endl;
        return 0;
    }

    ll num = log2(h);
    cout << (ll)pow(2, num) * 2 - 1 << endl;

    return 0;
}

Measured memory_bytes: 384
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    *A, d = nm()
    a = A[0]
    c = A[2]
    A = sorted(A)
    D = [A[i + 1] - A[i] for i in range(2)]
    if all([dd <= d for dd in D]) or abs(a - c) <= d:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9144
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

constexpr ll INF = 1LL << 62;

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

    ll N, A, B;
    cin >> N >> A >> B;

    vector<ll> H(N);
    for (ll i = 0; i < N; i++) {
        cin >> H[i];
    }

    ll ok = 1e9;
    ll ng = 0;

    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        vector<ll> G = H;
        bool enough = true;
        for (ll i = 0; i < N; i++) {
            G[i] -= B * mid;
        }

        ll count = 0;
        for (ll i = 0; i < N; i++) {
            if (G[i] > 0) {
                count += (G[i] + (A - B) - 1) / (A - B);
            }
        }

        if (count <= mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    cout << ok << endl;

    return 0;
}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int INF=1e5;
int n;
int a[2*INF+5];
bool f[2*INF+5];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		f[i]=false;
	}
	int m=0;
	for(int i=n-1;i>=n/2;i--)
	{
		if(a[i])
		f[i]=true;
		else
		f[i]=false;
	}
	for(int i=n/2;i>1;i--)
	{
		int b=0;
		for(int j=i+i;j<=n;j+=i)
		b+=f[j-1];
		if(b%2!=a[i-1])
		f[i-1]=true;
	}
	for(int i=0;i<n;i++)
	if(f[i])
	m++;
	if(m%2!=a[0])
	{
		f[0]=true;
		m++;
	}
	cout<<m<<endl;
	for(int i=0;i<n;i++)
	if(f[i])
	cout<<i+1<<" ";
	return 0;
}

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

const int MAX = 60;
int n;

bool graph[MAX][MAX] ;
bool visited[MAX];
int ans = 0;

void dfs(int now){
  if(visited[now]) return;
  visited[now] = true;
  rep(i, n){
    if(graph[now][i] && !visited[i]) dfs(i);
  }
}

int main(void){
  int m, a[MAX], b[MAX];
  cin >> n >> m;

  rep(i, m){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }

  rep(i, m){
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
    rep(j, n) visited[j] = false;
    dfs(0);
    bool ok = false;
    rep(i, n) if(!visited[i]) ok = true;
    if(ok) ans++;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

class B {
	int N;
public:
	void solve()
	{
		if (!(N % 111)) cout << N << endl;
		else cout << ((1 + N / 111) * 111) << endl;
	}

	B()
	{
		cin >> N;
	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
int n,m,u[210000],v[210000],tmp[1100][2];
bool ans1[1100][1100],ans2[1100][1100];
vector<int> vec[1100];
void dfs(int u,int rt){
    ans1[rt][u]=true;
    for(int i=0;i<vec[u].size();i++)
        if (!ans1[rt][vec[u][i]]) dfs(vec[u][i],rt);
}
void dfs2(int u,int num,int f){
    tmp[u][f]=num;
    for(int i=0;i<vec[u].size();i++)
        if (!tmp[vec[u][i]][f]) dfs2(vec[u][i],num,f);
}
int main(){
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++){
        scanf("%d%d",&u[i],&v[i]);
        vec[u[i]].push_back(v[i]);
    }
    for (int i=1;i<=n;i++) dfs(i,i);
    for (int i=1;i<=n;i++){
        memset(tmp,0,sizeof(tmp));
        tmp[i][0]=-1; tmp[i][1]=-1;
        for (int j=0;j<vec[i].size();j++)
            if (!tmp[vec[i][j]][0]) dfs2(vec[i][j],j+1,0);
        for (int j=vec[i].size()-1;j>=0;j--)
            if (!tmp[vec[i][j]][1]) dfs2(vec[i][j],j+1,1);
        for (int j=0;j<vec[i].size();j++)
            if (tmp[vec[i][j]][0]!=j+1||tmp[vec[i][j]][1]!=j+1) ans2[i][vec[i][j]]=true;
    }
    for (int i=1;i<=m;i++)
        if (ans1[v[i]][u[i]]==ans2[u[i]][v[i]]) puts("same");
        else puts("diff");
    
    return 0;
}

Measured memory_bytes: 6528
fun main(args: Array<String>) {
    val inf = 1000000000
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val keys = (0 until m).map {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        val c = readLine()!!.split(' ')
                .map { 1 shl (it.toInt() - 1) }
                .reduce { acc, i -> acc or i }
        a to c
    }

    val dp = Array(m + 1) { IntArray(4096) { inf } }
    dp[0][0] = 0

    for (i in 0 until m) {
        for (j in 0 until 4096) {
            dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j])
            val j2 = j or keys[i].second
            dp[i + 1][j2] = Math.min(dp[i + 1][j2], dp[i][j] + keys[i].first)
        }
    }

    dp[m][(1 shl n) - 1].let { println(if (it < inf) it else -1) }
}


Measured memory_bytes: 67364
#include <iostream>
#include <climits>
#include <vector>
#include <algorithm>

using namespace std;

static const int MAX = 200000;

int main(){
    int R[MAX];
    int num;

    cin >> num;
    for (int i = 0; i < num; i++) cin >> R[i];

    int maxv = INT_MIN;
    int minv = R[0];

    for (int i = 1; i < num; i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 3868
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,ans=100000000;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        int b=0;
        while(a[i]%2 == 0){
            b++;
            a[i]/=2;
        }
        ans = min(ans,b);
    }
    cout << ans << endl;
    return 0;
    
}

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

int main()
{
  int N, l, r=0, sum;
  cin>> N;
  for(int i=0;i<N;i++)
  {
    cin>>l>>r;
    sum+=r-l+1;
  }
  cout<< sum<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define EPS (1e-14)
#define _PA(x,N) rep(i,N){cout<<x[i]<<" ";}cout<<endl;
#define _PA2(x,H,W) rep(i,(H)){rep(j,(W)){cout<<x[i][j]<<" ";}cout<<endl;}

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;

ll H, W, N;
ll a[100005], b[100005];

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

map<PLL, ll> freq;
ll ans[10];

void solve() {
	for (int i = 0; i < N; i++) {
		for (int k = 0; k < 9; k++) {
			int ny = a[i] + dy[k];
			int nx = b[i] + dx[k];
			if (ny <= 0 || ny >= H-1) continue;
			if (nx <= 0 || nx >= W-1) continue;
			PLL p(ny, nx);
			freq[p]++;
		}
	}
	for (map<PLL, ll>::iterator itr = freq.begin(); itr != freq.end(); itr++) {
		ans[itr->second]++;
	}
	ans[0] = (W - 2) * (H - 2);
	for (int i = 1; i < 10; i++) {
		ans[0] -= ans[i];
	}
	for (int i = 0; i < 10; i++) {
		cout << ans[i] << endl;
	}
}

int main() {
	cin >> H >> W >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
	}
	solve();
	return 0;
}




Measured memory_bytes: 58112
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
bool sortbysec(const pair<int,int> &a,
               const pair<int,int> &b)
{
    return (a.second < b.second);
}


int main()
{
    ll t=1,i,j,k=0,n,z,a,b,d,x,y,m;
    //cin>>t;
    while(t--)
    {
        double d;
       cin>>n>>d;
       ll cnt=0;
       double x1,y1,tot;

       while(n--)
       {
           cin>>x1>>y1;
           tot=sqrt(x1*x1+y1*y1);
           if(tot<=d)
            cnt++;
       }
       cout<<cnt<<endl;


    }
    return 0;
}


Measured memory_bytes: 3828
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int X, A;

int main()
{
  scanf( "%d%d", &X, &A );

  puts( X<A ? "0" : "10" );

  return 0;
}

Measured memory_bytes: 128
import java.util.*;

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

Measured memory_bytes: 21204
use proconio::input;

fn main() {
    input!{
        n:usize,
        k:usize,
        mut p:[i32;n]
    };
    

    p.sort();

    let mut ans = 0;
    for i in 0..k {
        ans+=p[i];
    }

    println!("{}",ans);




}


Measured memory_bytes: 2176
import java.util.Scanner;
public class Main{
    
    public static int cost(int a,int b,int c){
        int cost = 0;
        cost = cost + Math.abs(b-a) + Math.abs(c-b);
        
        return(cost);   
    }

     public static void main(String []args){
         int A=0; int B=0;int C=0;
         Scanner in = new Scanner(System.in);
         A = Integer.parseInt(in.next());
         B = Integer.parseInt(in.next());
         C = Integer.parseInt(in.next());
         in.close();
        
        int[] costSum = new int[6];
        costSum[0] = cost(A,B,C);
        costSum[1] = cost(A,C,B);
        costSum[2] = cost(B,A,C);
        costSum[3] = cost(B,C,A);
        costSum[4] = cost(C,A,B);
        costSum[5] = cost(C,B,A);
         int min = costSum[0];
         for (int i=0;i<costSum.length;i++){
             if(min > costSum[i]){
                 min = costSum[i];
             }
         }
         System.out.println(min);
     }
}

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

int main() {
    int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	set<int> s;
	for (int i = 0; i < n; i++) {
		s.insert(a[i]);
	}
	cout << s.size() << endl;
}


Measured memory_bytes: 7756
#include<stdio.h>

int main(){

  int a,b,c,i,z,count;

  scanf("%d %d %d",&a,&b,&c);
  for(i = a,count = 0; i <= b; i++){
    
    if(c%i == 0) count++;
  }
    printf("%d\n",count);

    return 0;
}

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

int main() {
  int a,b,c;
  cin >>a>>b >>c;
  int total=0;
   total=a+b;
    if(total >=a+c){
   total=a+c;
  }
    if(total >=c+b){
   total=c+b;
  }
  cout << total <<endl;
  
  
}


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

int max(int x, int y)
{
    if (x > y)
    {
        return x;
    }
    return y;
}

int main(void)
{
    int x, y, s;
    while (true)
    {
        scanf("%d %d %d", &x, &y, &s);
        if (x == 0 && y == 0 && s == 0)
        {
            break;
        }
        // int zeinuki = s * 100 / (100 + x);
        // printf("zeinuki: %d\n", zeinuki);
        int ans = 0;
        int item1;
        for (item1 = 1; item1 < s; item1++)
        {
            int item2 = s - item1;
            int first = item1 * 100 / (100 + x) + 1;
            int second = item2 * 100 / (100 + x) + 1;
            if (first * (100 + x) / 100 > item1)
                first--;
            if (second * (100 + x) / 100 > item2)
                second--;
            if (first * (100 + x) / 100 + second * (100 + x) / 100 != s)
                continue;
            int zeikomi = first * (100 + y) / 100 + second * (100 + y) / 100;
            ans = max(ans, zeikomi);
        }
        printf("%d\n", ans);
    }
    return 0;
}


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

int main(){
  int N; cin >> N;
  long long A[100000];
  long long B[100000];
  long long Asum=0,Bsum=0;
  for(int i=0; i<N; i++){
    cin >> A[i];
    Asum+=A[i];
  }
  for(int i=0; i<N; i++){
    cin >> B[i];
    Bsum+=B[i];
  }
  if(Asum<Bsum){
    cout << -1 << endl;
  }else{
    long long C[100000];
    for(int i=0; i<N; i++){
      C[i]=A[i]-B[i];
    }
    sort(C,C+N);
    long long Cplussum=0, Cminussum=0;
    long long Cplus=0, Cminus=0;
    for(int i=0; i<N; i++){
      if(C[i]>0){
        Cplussum+=C[i];
        Cplus++;
      }else if(C[i]<0){
        Cminussum+=C[i];
        Cminus++;
      }
    }
    if(Cminus==0){
      cout << 0 << endl;
    }else{
      int count=0;
      for(int i=N-1; i>=0; i--){
        count++;
        Cminussum+=C[i];
        if(Cminussum>=0){
          cout << count+Cminus << endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 2560
double o(double*a,double*b,double*c){
	return a[1]*(*c-*b)+c[1]*(*b-*a)+b[1]*(*a-*c);
}
double x,p[8];
i;
main(){
	for(;~scanf("%lf,",p+i++%8);)
		i%8||puts(x*o(p+2,p+4,p+6)>0&x*o(p+4,p+6,p)>0&x*o(p+6,p,p+2)>0?"YES":"NO",x=o(p,p+2,p+4));
	return 0;
}

Measured memory_bytes: 0