akhauriyash/Code-Regression huggingface dataset:
// Ver19.02
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

ll collatz(ll x)
{
  if (x % 2 == 0)
  {
    return x / 2;
  }
  else
  {
    return 3 * x + 1;
  }
}

int main()
{
  int n, a;
  scanf("%d%d", &n, &a);
  puts(n % 500 <= a ? "Yes" : "No");
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<double> r(n+1);
    for(int i=0;i<n;i++){
        cin >> r[i+1];
    }
    vector<double> l(n+1);
    l[0]=0;r[0]=0;
    for(int i=1;i<=n;i++){
        l[i]=r[i];
        for(int j=0;j<i;j++){
            l[i]=max(l[i],l[j]+2*sqrt(r[i]*r[j]));
        }
    }
    double ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,l[i]+r[i]);
    }
    cout <<fixed << setprecision(10) << ans << endl;
    return 0;
}


    



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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	set<char> st;
	rep(i,4) st.insert(s[i]);
	cout << (sz(st)==2? "Yes":"No") <<"\n";
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    string s; cin >> s; reverse(s.begin(), s.end());
    int n = s.length();
    
    std::vector<std::vector<ll>> dp(n+1, std::vector<ll>(13,0));
    
    dp[0][0] = 1;
    
    ll keta = 1;

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

        if(s[i]=='?'){

            rep(d, 10){
                int x = d * keta;
                rep(j,13){
                    if(dp[i][j] != 0) dp[i+1][(j+x)%13] = (dp[i+1][(j+x)%13] + dp[i][j]) % MOD;
                }
            }

        } else {
            int x = (s[i]-'0') * keta;
            rep(j,13){
                if(dp[i][j] != 0) dp[i+1][(j+x)%13] = (dp[i+1][(j+x)%13] + dp[i][j]) % MOD;
            }

        }
        keta = keta*10;
        keta %= 13;
    }

    cout << dp[n][5] << endl;

    return 0;
}

Measured memory_bytes: 13648
#include<stdio.h>
#include<string.h>

int LCS(char X[],char Y[])
{
	int x,y,i,j,z[1001][1001];
	x = strlen(X);
	y = strlen(Y);

	for(i = 0; i < x; i++) {
		z[i][0] = 0;
	}
	for(j = 0; j < y; j++) {
		z[0][j] = 0;
	}
	for(i = 1; i <= x; i++) {
		for(j = 1; j <= y; j++){
			if (X[i-1] == Y[j-1]) {
				z[i][j] = z[i-1][j-1]+1;
			} else if (z[i-1][j] >= z[i][j-1]) {
				z[i][j] = z[i-1][j];
			}else {
				z[i][j] = z[i][j-1];
			}
		}
	}
	return z[x][y];
}

int main()
{
	int i,q;
	char X[1001],Y[1001];

	scanf("%d",&q);
	for(i = 0; i < q; i++) {
		scanf("%s",X);
		scanf("%s",Y);
		printf("%d\n",LCS(X,Y));
	}
	return 0;
}

Measured memory_bytes: 4524
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();
        for(int i = 0; i <= x; i++){
            if(i * 2 + (x - i) * 4 == y){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 26996
//-------------------------------------------
//-               Train Fare                -
//-                                         -
//-       autumn_eel niha katemasen!        -
//-------------------------------------------
#include<iostream>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
#pragma warning(disable:4996)
int n, m, q, a[200001], b[200001], c[200001], d[200001], e[100001], dist[100001], E[200001];
vector<pair<int, int>>x[100001], z[100001];
vector<int>D[100001];
void reader(int *x) {
	int k = getchar(); *x = k - '0';
	while (true) {
		k = getchar();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) reader(&a[i]), reader(&b[i]);
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= m; i++) {
		x[a[i]].push_back(make_pair(b[i], d[i]));
		x[b[i]].push_back(make_pair(a[i], d[i]));
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	queue<int> Q1; Q1.push(1);
	while (!Q1.empty()) {
		int a1 = Q1.front(); Q1.pop();
		for (pair<int, int> i : x[a1]) {
			if (dist[i.first] == -1) {
				dist[i.first] = dist[a1] + 1;
				Q1.push(i.first);
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		D[dist[i]].push_back(i);
		for (pair<int, int> j : x[i]) {
			if (dist[i] > dist[j.first]) z[i].push_back(j);
		}
	}
	e[1] = (1 << 30);
	for (int i = 1; i < n; i++) {
		for (int j : D[i]) {
			for (pair<int, int>k : z[j]) {
				e[j] = max(e[j], min(e[k.first], k.second));
			}
		}
	}
	for (int i = 2; i <= n; i++) { if (e[i] < 300000)E[e[i]]++; }
	for (int i = 1; i <= q; i++)E[i] += E[i - 1];
	for (int i = 1; i <= q; i++) {
		printf("%d\n", E[i]);
	}
	return 0;
}

Measured memory_bytes: 25336
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		char[] s = sc.next().toCharArray();
		int[] a = new int[n];
		for (int i = 1; i < n; i++) {
			if(s[i-1]=='A'&&s[i]=='C') a[i] += 1;
			a[i] += a[i-1];
		}
		int l = 0, r = 0;
		for (int i = 0; i < q; i++) {
			l = Integer.parseInt(sc.next())-1;
			r = Integer.parseInt(sc.next())-1;
			if(l == 0) {
				System.out.println(a[r]);
			}else {
				n = (s[l]=='C'&&s[l-1]=='A')?1:0;
				System.out.println(a[r]-a[l-1]-n);
			}
		}
		sc.close();
	}
}

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

a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0

for i in range(len(b)-1, -1, -1):

	taosu = min(b[i], a[i+1])
	ans += taosu
	a[i+1] -= taosu
	b[i] -= taosu

	taosu = min(b[i], a[i])
	ans += taosu
	a[i] -= taosu
	b[i] -= taosu

print(ans)

Measured memory_bytes: 82148
def main():
    L, R = map(int, input().split())
    # 60 の相異なる素因数は 3, 673 の 2つ
    if L + 672 <= R:
        print(0)
        return
    lst = []
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            lst.append(i * j % 2019)
            if i * j % 2019 <= 1:
                break
        if i * j % 2019 <= 1:
            break
    print(min(lst))
    return


main()


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

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var mod = (int)1e9 + 7;
            var inputs = Console.ReadLine().Split(" ");
            var n = int.Parse(inputs[0]);
            var m = int.Parse(inputs[1]);

            var ok = new bool[n + 1];
            for (var i = 0; i < n + 1; i++)
            {
                ok[i] = true;
            }

            for (var i = 0; i < m; i++)
            {
                var a = int.Parse(Console.ReadLine());
                ok[a] = false;
            }

            var dp = new int[n + 1];
            dp[0] = 1;
            for (var i = 0; i < n; i++)
            {
                for (var j = i + 1; j <= Math.Min(n, i + 2); j++)
                {
                    if (ok[j])
                    {
                        dp[j] += dp[i];
                        dp[j] %= mod;
                    }
                }
            }

            Console.WriteLine(dp[n]);
        }
    }
}


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

int main()
{
    //ios_base::sync_with_stdio(false); cin.tie(0);
    int n,lo,hi,l,r,m,len1,len2;
    string s;
    cin >> n;
    // First
    cout << 0 << '\n'; cout.flush();
    cin >> s; 
    if(s[0] == 'V')
        return 0;
    l = (s[0] == 'M');
    // Last
    cout << n-1 << '\n'; cout.flush();
    cin >> s; 
    if(s[0] == 'V')
        return 0;
    r = (s[0] == 'M');
    // Binary search
    lo = 0; hi = n - 1;
    while(lo <= hi)
    {
        int mid = lo + (hi-lo)/2;
        cout << mid << '\n'; cout.flush();
        cin >> s;
        if(s[0] == 'V')
            return 0;
        m = (s[0] == 'M');
        len1 = mid - lo + 1;
        len2 = hi - mid + 1;
        if((l == m && len1 % 2 == 0) || (l != m && len1 % 2 != 0))
        {
            hi = mid;
            r = m;
        }
        else if((r == m && len2 % 2 == 0) || (r != m && len2 % 2 != 0))
        {
            lo = mid;
            l = m;
        }
    }
    return 0;
}

Measured memory_bytes: 852
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

struct UnionFind {
    int n, cnt;
    vector<ll> par, rank, sz;

    UnionFind(ll n) : n(n), cnt(n), par(n), rank(n), sz(n, 1) { iota(par.begin(), par.end(), 0); }

    ll find(ll x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }

    bool same(ll x, ll y) { return find(x) == find(y); }

    ll size(ll x) { return sz[find(x)]; }

    void unite(ll x, ll y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
            sz[y] += sz[x];
        } else {
            par[y] = x;
            sz[x] += sz[y];
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
        cnt--;
    }
};

int main() {
    int N,M,A,B,C; cin >> N;
    string S; cin >> S;
    if(N%2){
        cout << "No" << endl;
        return 0;
    }

    for(int i=0; i<N/2; i++){
        if(S[i]!=S[N/2+i]){
            cout << "No"<< endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>

int main(void)
{
	int a;
	int count[101] = {0};
	int max_count;
	int i;
	
	while (scanf("%d", &a) != EOF){
		count[a]++;
	}
	
	for (i = 1; i <= 100; i++){
		if (max_count < count[i]){
			max_count = count[i];
		}
	}
	
	for (i = 1; i <= 100; i++){
		if (count[i] == max_count){
			printf("%d\n", i);
		}
	}
	
	return (0);
}

Measured memory_bytes: 592
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_i32_vec() -> Vec<i32> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let _: usize = input();
    let h_vec: Vec<i32> = input_i32_vec();
    let mut diff = 0;
    for i in 1..h_vec.len() {
        if h_vec[i] - h_vec[i-1] <= 0 {
            diff += h_vec[i] - h_vec[i-1];
            if diff < -1 {
                println!("No");
                return;
            }   
        } else {
            diff = 0;
        }
    }
    println!("Yes");
}


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

int k, n, res;

int main(){
	
	cin >> k >> n;
	int a[n], a2[n], r[n];
	for(int i = 0; i < n; i ++){
		cin >> a[i];
		a2[i] = min(a[i], k-a[i]);
	}
	
	sort(a, a+n);
	
	for(int i = 0; i < n-1; i ++){
		r[i] = min( (a2[i]+a2[i+1]), (a[i+1] - a[i]));
	}
	
	r[n-1] = min( (a2[0]+a2[n-1]), (a[n-1] - a[0]));
	
	sort(r, r+n);
	
	for(int i = 0; i < n-1; i ++){
		res += r[i];
	}
	
	cout << res;
	
	return 0;
}


Measured memory_bytes: 5976
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	ll r,D,x;
	cin>>r>>D>>x;
	rep(i,10){
		x=r*x-D;
		cout<<x<<endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, K;
vector<int> divs;

i64 modpow(i64 a, int p)
{
	if (p == 0) return 1;
	i64 ret = modpow(a, p / 2);
	ret = ret * ret % MOD;
	if (p % 2 == 1) ret = ret * a % MOD;
	return ret;
}

int mebius(int v)
{
	int ret = 1;
	for (int p : divs) if (p > 1 && v % p == 0) {
		v /= p;
		if (v % p == 0) return 0;
		ret *= -1;
	}
	return ret;
}

map<int, int> meb;
map<int, i64> ori;

int main()
{
	scanf("%d%d", &N, &K);

	for (int i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			divs.push_back(i);
			if (N != i * i) divs.push_back(N / i);
		}
	}
	sort(divs.begin(), divs.end());
	for (int a : divs) meb[a] = mebius(a);

	if (N % 2 == 0) {
		for (int a : divs) if ((N / a) % 2 == 0) {
			ori[a] = modpow(K, a);
		}
		i64 ret = 0;
		for (int a : divs) if ((N / a) % 2 == 0) {
			i64 tmp = 0;
			for (int b : divs) if (a % b == 0) {
				ADD(tmp, MOD + ori[b] * meb[a / b]);
			}
			ADD(ret, tmp * a);
		}
		printf("%lld\n", ret);
	} else {
		for (int a : divs) {
			ori[a] = modpow(K, (a + 1) / 2);
		}
		i64 ret = 0;
		for (int a : divs) {
			i64 tmp = 0;
			for (int b : divs) if (a % b == 0) {
				ADD(tmp, MOD + ori[b] * meb[a / b]);
			}
			ADD(ret, tmp * a);
		}
		printf("%lld\n", ret);
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(void){
  string s,t,u;
  int a,b;

  cin>>s>>t;
  cin>>a>>b;
  cin>>u;

  if(s==u){
    a--;
  }
  else{
    b--;
  }

  printf("%d %d\n",a,b);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
typedef double dd;
#define pb push_back
#define mp make_pair
#define endl "\n"
ll const M = 1000000007;
dd const pi = acos(-1);
ll const inf = 2e18;
ll const N = 200001;
vector<ll> a(N),freq(1e6 + 1,0);
vector<bool> m(1e6 + 1,false);
int main()
{
    fast;
    ll i,j,t,n,cnt = 0;
    cin >> n;
    for(i = 0; i < n; i++)
    {
    	cin >> a[i];
    	m[a[i]] = true;
    	freq[a[i]]++;
    }
    for(i = 0; i < n; i++)
    {
    	bool ok = false;
    	if(freq[a[i]] > 1)
    	{
    		a[i] = 0;
    		continue;
    	}
    	for(j = 2; j*j <= a[i]; j++)
    	{
    		if(a[i] % j == 0 && (m[j] || m[a[i] / j]))
    		{
    			ok = true;
    			break;
    		}
    	}
    	if(ok)
    		a[i] = 0;
    	if(m[1] && a[i] != 1)
    		a[i] = 0;
    }
    for(i = 0; i < n; i++)
    	if(a[i] != 0)
    		cnt++;
    cout<<cnt<<endl;
    return 0;
}    

Measured memory_bytes: 12588
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mod 1000000007  
#define fi first
#define se second
vector<int> adj[100002];
int main()
{  
	ll x;
	ll i;
	cin>>x;
	for(i=-3980;i<=3980;i++)
	{
		ll r = x+pow(i,5);
		ll t = pow(r,0.2);
		if(pow(t,5)-pow(i,5)==x){
			cout<<t<<" "<<i;
			return 0;
		}
	}
}

Measured memory_bytes: 6592
N = int(input())
xy = []
for i in range(N):
    xy.append(list(map(int, input().split())))
d = []
for i in range(N):
    for j in range(N):
        if i != j:
            d.append(((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2)**0.5)
print(sum(d) / N)

Measured memory_bytes: 3060
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.rmi.server.UnicastRemoteObject;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        char c[]=sc.nextString().toCharArray();
        long ans=0;
        if(c[0]=='W' || c[c.length-1]=='W') {
            out.println(0);
         	out.flush(); 
         	return;
        }
        
        int d[]=new int[c.length];
        for (int i = 0; i+1 < c.length; i++) {
        	if(c[i+1]==c[i])d[i+1]=(d[i]+1)%2;
        	else d[i+1]=d[i];
		}
//        d[c.length-1]=1;
        
        long l=1,a=1;
        for (int i = 1; i < d.length; i++) {
			if(d[i]==1) {
				a*=l;
				a%=mod;
				l--;
			}else l++;
		}
        if(l!=0)a=0;
        db(d);
        for (int i = 1; i <= n; i++) {
			a*=i;
			a%=mod;
		}

        out.println(a);
     	out.flush();
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x, y;
//	P(int  x, int y) {
//	  this.x=x;
//	  this.y=y;
//	}
//}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//    	if(a==p.a) return b-p.b;
//        return -p.a+a;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

using namespace std;

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

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

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl

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

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,k;
    cin>>n>>k;
    vl h(n);
    VIN(h);
    sort(ALL(h));
    vl cs(n+1);

    ll ans = LINF;
    FOR(i,k-1,n){
        //DEBUG2(i,i-(k-1));
        //DEBUG2(h[i],h[i-(k-1)]);
        ans = min(ans,h[i]-h[i-(k-1)]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int i,n,j,ans=0;
	cin >> n;
	for(i=1; i<n; ++i){
		j = n - i;
		if(i && j && i<j){
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include "iostream"
using namespace std;

int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int count = 0;
  for (int i = 0; i < a + 1; i++) {
    for (int j = 0; j < b + 1; j++) {
      for (int k = 0; k < c + 1; k++) {
        if (500 * i + 100 * j + 50 * k == x) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
program test

implicit none
integer :: i,j
integer :: n, a(2,100)=0, amax=0 

read(*,*) n
do i = 1,2
 read(*,*) (a(i,j),j=1,n)
enddo

do i =1, n
  amax = max(amax, sum(a(1,1:i))+sum(a(2,i:n)))
enddo

write(*,*) amax

end program

Measured memory_bytes: 256
#include "stdio.h"
#include <iostream>

using namespace std;

static int MAX_N = 100;

int selectionSort(int n, int* num) {
	int count = 0;
	for(int i = 0; i < n - 1; i ++) {
		int minIndex = i;
		for(int j = i + 1; j < n; j ++) {
			if(num[j] < num[minIndex]) {
				minIndex = j;
			}
		}
		if(minIndex != i) {
			int temp = num[i];
			num[i] = num[minIndex];
			num[minIndex] = temp;
			count ++;
		}
	}
	return count;
}

int main() {
	int n, num[MAX_N];
	scanf("%d", &n);
	for(int i = 0; i < n; i ++) {
		scanf("%d", &num[i]);
	}
	int count = selectionSort(n, num);
	
	for(int i = 0; i < n - 1; i ++) {
		printf("%d ", num[i]);
	}
	printf("%d\n", num[n - 1]);
	printf("%d\n", count);
}

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

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  char A,B,C;
  A=a[0];
  B=b[0];
  C=c[0];
  char d='A'-'a';
  A+=d; B+=d; C+=d;
  cout << A << B << C << endl;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(Number);
var n = input.shift();
var m = 0;
var g = [1];
var count = 0;

function insertionSort(array, n, g) {
  for (var i = g; i < array.length; i++) {
    var v = array[i];
    var j = i - g;
    while (j >= 0 && array[j] > v) {
      var tmp = array[j + g];
      array[j + g] = array[j];
      array[j] = tmp;
      j -= g;
      count++;
    }
  }
}

function shellSort(array, n) {
  for (var i = 1; i < n; i++) {
    g[i] = g[i - 1] * 3 + 1;
  }
  g = g.filter(function(j) {
    return (j <= n);
  });
  m = g.length;
  g.reverse();

  for (var i = 0; i < m; i++) {
    insertionSort(array, n, g[i]);
  }

  return array;
}

var sorted = shellSort(input, n);
console.log(m);
console.log(g.join(' '));
console.log(count);
console.log(sorted.join('\n'));

Measured memory_bytes: 137148
N = int(input())
s = list(map(lambda x: x == 'o', input()))

# try all 4 cases

from itertools import product
for a,b in product((True,False), repeat=2):
  x,y = a,b
  for p in s:
    a,b = b, a^b^p

  if x == a and y == b:
    temp = [None]*N
    for i,p in enumerate(s):
      temp[i] = b
      a,b = b, a^b^p
    print(''.join('S' if t else 'W' for t in temp))
    exit()

print(-1)


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

#define debug(x) cerr << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 2e5 + 10;
ll fat[maxn], inv[maxn];

ll C(int n, int k)
{
  if(n < k) 
    return 0;
  if(n < 0 || k < 0) 
    return 0;
  return (((fat[n] * inv[k]) % mod) * inv[n - k]) % mod;
}

void initFactorials()
{
  fat[0] = 1;
  inv[0] = 1;
  for(int i = 1; i < maxn; i++)
  {
    fat[i] = (i * fat[i-1]) % mod;
    inv[i] = exp(fat[i], mod - 2);
  }
}

int a[maxn];

int main()
{
  ios::sync_with_stdio(0);
  int n,k;
  string s;
  cin >> n >> k;
  cin >> s;

  int ans = 0;
  for(int i = 0; i < n - 1; i++)
  {
    ans += s[i] == s[i+1];
  }
  cout << min(n - 1, ans + 2 * k) << endl;
  return 0;
}

Measured memory_bytes: 3556
N, M = map(int, input().split())
L = []
for _ in range(N):
    A,B = map(int, input().split())
    L.append((A,B))
L.sort()
ans = 0
for i in range(N):
    if M-L[i][1] >= 0:
        ans += L[i][0]*L[i][1]
        M-=L[i][1] 
    else:
        ans += M*L[i][0]
        break
print(ans)

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

int main () {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool flag = true;
    while (a > 0 && c > 0) {
        if (flag) {
            c -= b;
            // cout << c << endl;
            flag = false;
        }
        else {
            a -= d;
            // cout << a << endl;
            flag = true;
        }
    }
    if (a <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(void) {
	int num_player;
	int player[50] = { 0 };
	int stone;
	int owner;
	int i=0;

	while(1) {
		player[i] = 0;
		i = -1;
		owner = 0;
		scanf("%d", &num_player);
		scanf("%d", &stone);
		if ((num_player == 0) && (stone == 0))
			break;
		while ((stone != 0) || (owner != 1)) {
			i++;
			if (i == num_player) {
				i = 0;
			}
			if (stone != 0) {
				player[i] += 1;
				stone -= 1;
				if (player[i] == 1) {
					owner += 1;
				}
			}
			else {
				if (player[i] != 0) {
					stone = player[i];
					player[i] = 0;
					owner -= 1;
				}
			}
		}
	printf("%d\n", i);
	}
	return 0;
}


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

int main(){

    while(true){
        int H, W;
        cin >> H >> W;
        if(H == 0 && W == 0){
            break;
        }
        for(int i = 0; i < H; ++i){
            for(int j = 0; j < W; ++j){
                if(i == 0 || i == H-1 || j == 0 || j == W-1){
                    cout << '#';
                }
                else{
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include <bits/stdc++.h>
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<22,stdin),p1 == p2)?EOF:*p1++)
using namespace std ;
//char buf[(1 << 22)] , *p1 = buf , *p2 = buf ;
inline int read ()
{
    char c = getchar () ; int x = 0 , f = 1 ;
    while (c < '0' || c > '9') { if (c == '-') f = -1 ; c = getchar () ; }
    while (c >= '0' && c <= '9'){ x = x * 10 + c - '0' ; c = getchar () ; }
    return x * f ;
}
int n , ans ;
string s ;
int main ()
{
//    freopen (".in" , "r" , stdin) ; freopen (".out" , "w" , stdout) ;
	cin >> n ;
	cin >> s ;
	for (int i = 0 ; i < n ; i ++) if (s[i] != s[i + 1]) ans ++ ;
	cout << ans ;
}




Measured memory_bytes: 512
#include<string>
#include<cstdio>
#include<cstring>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<iostream>

using namespace std;
int main(){
	int M,D;
	cin >> M >> D;
	int cnt=0,a,b;
	for(int i=22;i<=D;i++){
		a=i/10; //十位 
		
		b=i%10;//各位 
		if(b<2) continue;
		if(a*b <= M && a*b>=4) cnt++;
	}
	cout<< cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
// D - Five, Five Everywhere
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)
using VB = vector<bool>;

// 素数列挙 (エラトステネスの篩)
VB primes_create(int n){
	VB p(n+1, true);
	p[0] = p[1] = false;
	for(int i=2; i*i<=n; ++i)
		if(p[i]) for(int j=i+i; j<=n; j+=i) p[j] = false;
	return p;
}

int main(){
	int N; cin>>N;
	VB P = primes_create(55555);
	vi ans;
	for(int p=11; p<P.size() && ans.size()<N; p+=10)
		if(P[p] && p%5 == 1) ans.push_back(p);
	for(auto a:ans) cout<<a<<" ";
}

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

int main(){
	int k,s;
	cin >> k >> s;

	int ans = 0;
	for(int x = 0; x <= k; x++){
		for(int y = 0; y <= k; y++){
			int z = s-x-y;
			if(0 <= z && z <= k)
				ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで標準include

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>data(n);
	int M = 0;
	for (int i = 0; i < n; i++) {
		cin >> data.at(i);
		M = max(M, data.at(i));
	}
	int check = 1;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (check == data.at(i)) {
			ans++;
			check++;
		}
	}
	if (ans == 0) {
		for (int i = 0; i < n; i++) {
			if (i == data.at(i)) {

			}
			else {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	cout << n - ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int n, s, cnt;
int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

void dfs(int i, int sum, int k) {
    if (k == n && sum == s) { cnt++; }

    if (i == 10 || k == n || sum > s) { return; }
    // a[i]???????????´???
    dfs(i + 1, sum + a[i], k + 1);
    // a[i]?????????????????´???
    dfs(i + 1, sum, k);
}

int main() {
    while (cin >> n >> s) {
        if (n == 0 && s == 0) { break; }
        cnt = 0;
        dfs(0, 0, 0);
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3100
N = int(input())
mod = 10**9+7
A = [1]+(N+3)*[0]
G = [1]+(N+3)*[0]
C = [1]+(N+3)*[0]

for n in range(1,N):
  T = (2*A[n-1]+G[n-1]+C[n-1])%mod
  A[n] = T
  G[n] = (T-A[n-2]+G[n-3])%mod
  C[n] = (T-A[n-2]-G[n-2]-3*A[n-3])%mod

print((2*A[N-1]+G[N-1]+C[N-1])%mod)

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

int main(){
    int a,b,k;
    cin >> a >> b >> k;
    int cnt=0,ans;
    for(int i=max(a,b);i>0;i--){
        if(a%i==0 && b%i==0){
            cnt++;
        }
        if(cnt==k){
            ans=i;
            break;
        }
    }
    cout << ans;
}

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

int main(){
    int L, N;
    cin >> N >> L;
    vector<string> S(N);
    rep(i,N){
        cin >> S.at(i);
    }
    string ans = "";
    sort(S.begin(), S.end());
    rep(i,N){
        ans += S.at(i);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int now=0;
    while(a>=b){
        now++;
        b*=2;
    }
    while(b>=c){
        now++;
        c*=2;
    }
    if(now<=k){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>
 
 
int main()
{
    long long int a, b;
    std::cin >> a >> b;

    std::cout << a * b / std::__gcd(a, b) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define il inline
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define rep0(i, n) for(int i = 0; i < (n); i ++)
#define per0(i, n) for(int i = (n) - 1; i >= 0; i --)
#define ept 1e-9
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
#define All(x) (x).begin(), (x).end()
#define lowbit(x) ((x) & -(x))
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const ll mod = 1e9 + 7;
const int N = 4e6 + 10;
const db pi = acos(-1);
//int a[N];
int main()
{
	int n = read();
	vi a(n);
	rep0(i, n) a[i] = read();
	int m = read();
	vi b(m);
	rep0(i, m) b[i] = read();
	cout << (a < b) << endl;
	return 0;
}



Measured memory_bytes: 3116
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#include <cmath>
#define INF 10000000000
#define MOD 10000000007
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef pair<int, int> i_i;

int n;
int A[105][105];
vector<int> D(105,-1);

void bfs(int src){
    queue<int> Q;
    Q.push(src);
    D[src] = 0;
    while (!Q.empty()) {
        int cur = Q.front();
        Q.pop();
        for (int dst=0; dst<n; dst++) {
            if (A[cur][dst]==1 and D[dst]==-1) {
                D[dst] = D[cur]+1;
                Q.push(dst);
            }
        }
    }
}

int main(){
    memset(A, 0, sizeof(A));
    cin >> n;
    for (int i=0; i<n; i++) {
        int u,k;
        cin >> u >> k;
        u--;
        for (int j=0; j<k; j++) {
            int num;
            cin >> num;
            A[u][num-1]=1;
        }
    }
    bfs(0);
    for (int i=0; i<n; i++) {
        cout << i+1 <<" "<<D[i]<<endl;
    }/*
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            cout << A[i][j]<<" ";
        }
        cout << endl;
    }*/
}

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

int main() {
  int64_t X, K, D;
  cin >> X >> K >> D;
  
  int64_t ans = 1000000000000000;
  int64_t mv_cnt = 0;
  
  if (X > 0) {
    if (X >= D) {
      mv_cnt = X / D;
      if (mv_cnt > K) mv_cnt = K;
      X -= mv_cnt * D;
    }
  } else if (X < 0) {
    if (abs(X) >= D) {
      mv_cnt = abs(X) / D;
      if (mv_cnt > K) mv_cnt = K;
      X += mv_cnt * D;
    }
  }
  
  K -= mv_cnt;
  if (X == 0) {
    if (K % 2 == 0) {
      X = 0;
    } else {
      X = D;
    }
  } else {
    if (K % 2 != 0) {
      if (X > 0) {
        X = X - D;
      } else {
        X = X + D;
      }
    }
  }
  ans = min(ans, abs(X));
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <array>
#include <map>

using tile = std::array<int, 4>;
constexpr int coeff[] = { 1, 2, 4 };

tile rotate(const tile &t, int r) {
  tile res{};
  for (int i = 0; i < 4; ++i) {
    res[i] = t[(i + r) & 3];
  }
  return res;
}

tile normalize(const tile &t) {
  std::array<tile, 4> tmp{};
  for (int i = 0; i < 4; ++i) {
    tmp[i] = rotate(t, i);
  }
  std::sort(tmp.begin(), tmp.end());
  return tmp.front();
}

int type(const tile &t) {
  if (t[0] == t[1] && t[1] == t[2] && t[2] == t[3]) return 2;
  if (t[0] == t[2] && t[1] == t[3]) return 1;
  return 0;
}

int main() {
  int N;
  std::cin >> N;
  std::vector<tile> C(N);
  std::map<tile, int> memo;
  for (int i = 0; i < N; ++i) {
    for (auto &x: C[i]) {
      std::cin >> x;
    }
    C[i] = normalize(C[i]);
    memo[C[i]]++;
  }
  int64_t ans = 0;
  for (int i = 0; i < N; ++i) {
    memo[C[i]]--;
    const auto &up = C[i];
    for (int j = i + 1; j < N; ++j) {
      memo[C[j]]--;
      for (int k = 0; k < 4; ++k) {
        auto down = rotate(C[j], k);
        std::map<tile, int> query;
        query[normalize(tile{ up[0], up[3], down[2], down[1] })]++;
        query[normalize(tile{ up[1], up[0], down[1], down[0] })]++;
        query[normalize(tile{ up[2], up[1], down[0], down[3] })]++;
        query[normalize(tile{ up[3], up[2], down[3], down[2] })]++;
        int64_t add = 1;
        for (auto &q: query) {
          auto itr = memo.find(q.first);
          if (itr == memo.end()) {
            add = 0;
            break;
          }
          int s = itr -> second, t = type(q.first);
          for (int i = 0; i < q.second; ++i) {
            add *= (s - i) * coeff[t];
          }
        }
        ans += add;
      }
      memo[C[j]]++;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


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

int main() {
  unsigned long N;
  std::cin >> N;
  std::vector<long long> x(N);
  for (unsigned i = 0; i < N; ++i) {
    std::cin >> x[i];
  }
  std::vector<long long> y(x);
  std::sort(x.begin(), x.end());
  auto med0 = x[N / 2 - 1];
  auto med1 = x[N / 2];
  for (unsigned i = 0; i < N; ++i) {
    std::cout << (y[i] <= med0 ? med1 : med0) << std::endl;
  }
  return 0;
}

Measured memory_bytes: 5376
import sys
input = sys.stdin.readline

N, K, Q = map(int, input().split())
A = [int(input())-1 for _ in range(Q)]
answered_list = [0] * N
for a in A:
    answered_list[a] += 1

for answered in answered_list:
    if K-Q+answered > 0:
        print('Yes')
    else:
        print('No')



Measured memory_bytes: 49372
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,ans=0;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++)
            for(int k=j+1;k<n;k++)
                ans+=(v[i]!=v[j]&&v[j]!=v[k]&&v[k]!=v[i]&&v[i]+v[j]>v[k]&&v[i]+v[k]>v[j]&&v[j]+v[k]>v[i]);
    cout<<ans;
    return 0;
}


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

#define N 100

/** 砂時計の個数 */
static int n;
/** 理想時間 */
static int t;
/** 許容誤差 */
static int e;
/** 各砂時計の計測時間 */
static int x[ N ];

int
main (
  int   argc,
  char *argv[ ]
  )
{
  /** 答え */
  int res = -1;
  int i;

  /* 読み込み */
  scanf ( "%d%d%d", &n, &t, &e );
  for ( i = 0; i < n; ++i )
    scanf ( "%d", &x[ i ] );

  /* 各砂時計を検査 */
  for ( i = 0; i < n; ++i )
  {
    /** 0 の方向への誤差 */
    const int em = t % x[ i ];
    /** 無限大の方向への誤差 */
    const int ep = x[ i ] - em;

    /* 誤差em またはep が許容誤差e で抑えられれば採用 */
    if ( em <= e
      || ep <= e )
    {
      res = i + 1;
      break ;
    }
  }

  /* 結果出力 */
  printf ( "%d\n", res );

  return ( EXIT_SUCCESS );
}

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

int f(int k){
  int c = 0
  rep(i,k){
    if(k%i == 0) ++c;
  }
  return c;
}

int main(){
  int n;
  cin >> n;
  int count = 0;
  rep(i,n){
    if(i%2 == 1 && f(i) == 8) ++count;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
b=l[0]
c=l[1]
ans=0
for i in range(2,n):
  a=b
  b=c
  c=l[i]
  ab=b>a
  bc=c>b
  if (ab==True and bc==True) or (ab==False and bc==False):ans+=1
print(ans)

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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

int sub[N];

int32_t main() {
    //ios::sync_with_stdio(false); cin.tie(nullptr);

    int n;
    cin >> n;

    for (int i = 2; i <= n; i++) {
        int p;
        cin >> p;
        sub[p]++;
    }

    for (int i = 1; i <= n; i++) {
        cout << sub[i] << "\n";
    }
}


Measured memory_bytes: 5124
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head, const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int h,w;
    while(1){
        scanf("%d %d",&h,&w);
        if(h==0&&w==0)break;
        rep(y,h){
            rep(x,w){
                if(y==0||x==0||y==h-1||x==w-1)putchar('#');
                else putchar('.');
            }
            putchar('\n');
        }
        putchar('\n');
    }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;


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

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  vector<ll> dp1(n + 1), dp2(n + 1);

  dp1[0] = a[0];
  for (int i = 0; i < n - 1; i++){
    dp1[i + 1] = gcd(dp1[i], a[i + 1]);
  }
  dp2[n-1] = a[n-1];
  for (int i = n - 1; i > 0; i--){
    dp2[i - 1] = gcd(dp2[i], a[i-1]);
  }

  ll ans = 0;
  for (int i = 0; i < n; i++){
    if (i == 0)
      ans = max(ans, dp2[1]);
    else if (i == n - 1)
      ans = max(ans, dp1[n - 2]);
    else
      ans = max(ans, gcd(dp1[i - 1], dp2[i + 1]));
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <random>
#include <map>

using namespace std;

constexpr auto DIV = 1000000007ull;

int main() {
  int N, K, X, Y, sum = 0;
  cin >> N >> K >> X >> Y;
  for (int i = 0; i < N; ++i) {
    sum += (i < K ? X : Y);
  }
  cout << sum << endl;


  return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int x = min(a, b);
    a -= x, b -= x;
    cout << ((16 - 2 * x - 1) / 2 >= max(a, b) ? "Yay!" : ":(") << endl;
}


Measured memory_bytes: 256