akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main(){
    string s;
    cin >> s;
    bool ans = false;
    if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) ans = true;
    if (s[0] == s[3] && s[1] == s[2] && s[0] != s[1]) ans = true;
    if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) ans = true;
    cout << (ans?YES:NO) << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class CWelcomeToAtCoder {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N, M;
        in >> N >> M;
        vector<int> p(M);
        vector<string> S(M);
        REP(i,0,M) in >> p[i] >> S[i];
        vector<int> penalties(N+1, 0);
        vector<bool> ac(N+1, false);
        REP(i,0,M) {
            if (ac[p[i]]) continue;
            if (S[i] == "AC") {
                ac[p[i]] = true;
            } else {
                penalties[p[i]]++;
            }
        }
        int acnum = 0, penaltynum = 0;
        REP(i,1,N+1) {
            if (ac[i]) {
                acnum++;
                penaltynum += penalties[i];
            }
        }
        out << acnum << " " << penaltynum << "\n";
    }
};


signed main() {
    CWelcomeToAtCoder solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define repr(i, m, n) for (int i = m; i >= n; i--)
#define db(x) cout << #x << "=" << x << endl
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;
//--GLOBAL------------------------------------


//--MAIN------------------------------------
void Main(){
    double a,b,x; cin>>a>>b>>x;
    double ans;
    if(a*a*b/2>=x){
        ans=atan(b/(2*x/(a*b)));
    }
    else{
        x=a*a*b-x;
        ans=atan(2*x/(a*a*a));
    }
    ans*=(180/PI);
    cout<< ans<<"\n";
}

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


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

int m,mn,Mn,gap,ans;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> m >> mn >> Mn,m){
        vector<int> P(m);
        for (int i=0;i<m;++i) cin >> P[i];
        gap=0;
        for (int i=mn-1;i<Mn;++i){
            if (gap<=P[i]-P[i+1]){
                gap=P[i]-P[i+1],ans=i+1;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3116
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

ll a[50000];
ll b[50000];
ll ab[50000];

ll ma(ll x, ll y){
    if(x>y)return x;
    return y;
}

ll gcd(ll a, ll b){
    if(a < b){
        ll t = a;
        a = b;
        b = t;
    }
    if(a % b == 0)return b;
    else return gcd(b, a%b);
}
ll lcm(ll a, ll b){
    ll l = gcd(a, b);
    return a/l*b;
}
int main(void){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int c5 = 0;
    int c7 = 0;
    if(a == 5)c5++;
    if(a == 7)c7++;
    if(b == 5)c5++;
    if(b == 7)c7++;
    if(c == 5)c5++;
    if(c == 7)c7++;
    if(c5 == 2 && c7 == 1)printf("YES\n");
    else printf("NO\n");
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
# ブロック関係でないかつ同じグループ
class UnionFind():
    # nはノードの数
    def __init__(self, n):
        self.n = n
        self.parents = [-1]*n  # 根のノードは限らないので注意

    # xはノードの番号
    def find(self, x):  # あるノードの親を探すためのメソッド
        if self.parents[x] < 0:  # 親の場合、そのグラフの要素の個数を負の値で保持している
            return x
        else:
            # 再帰的に親を探しにいき、得られた値を格納する
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # x, yはノードの番号
    def union(self, x, y):
        x = self.find(x)  # 根の番号を取得
        y = self.find(y)  # 根の番号を取得
        if x == y:
            return  # 同じ親ならば合体させる必要はない

        # ※ それぞれ要素の個数が負の値で格納されている
        if self.parents[x] > self.parents[y]:
            # yのグループの方が要素の個数が多い場合 (yの方が値が小さいということは、負の世界では値が大きいため)
            # 必ずxの方が要素が多い状態にする
            x, y = y, x

        self.parents[x] += self.parents[y]  # 負の値同士だが、これで良い
        self.parents[y] = x  # yは親ではなくなったため、新しい親であるxの値を正でもつ

    # xはノードの番号
    def size(self, x):
        # 親まで辿ればグループの大きさが負の値で格納されているため、それにマイナスをつけてreturnする
        return -self.parents[self.find(x)]

    # x, yはノードの番号
    def same(self, x, y):
        # 親が同じ = 同じグループに属するならTrueがreturnされる
        return self.find(x) == self.find(y)

    # xはノードの番号
    def members(self, x):
        root = self.find(x)  # 親の値を取得する
        # findで再帰的に親の値が獲得できる
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        # 親となっているノードの番号をリストでreturnする
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_counts(self):
        # グループの数をreturnする
        return len(self.roots())

    def all_group_members(self):
        # 親のノードの番号をキーにして、子のノードの番号を対応させた辞書を返す
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        # printした時の表記
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M, K = map(int, input().split())  # N人の人, M人の友好関係, K個のブロック関係
uf = UnionFind(N)

# inはsetを使ってオーダー1
addjacent = defaultdict(set)
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    addjacent[a].add(b)
    addjacent[b].add(a)
    uf.union(a, b)
blocked = defaultdict(list)
for _ in range(K):
    c, d = map(lambda x: int(x)-1, input().split())
    blocked[c].append(d)
    blocked[d].append(c)

# # 親の数だけ行う
# # print(pearents)
# ans = defaultdict(int)
# for group in pearents.values():
#     for n in group:
#         ans[n] = len(group) - 1 - len(addjacent[n]) - len(set(group)&blocked[n])
#     # groupの中にブロックがいるかどうか
#
# ans = " ".join(map(str, ans.values()))
# print(ans)

for i in range(N):
    cnt = 0
    for b in blocked[i]:
        if uf.same(i, b):
            cnt += 1
    print(uf.size(i) - len(addjacent[i]) - cnt - 1)


Measured memory_bytes: 130392
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner inputs = new Scanner(System.in);
		int nums = inputs.nextInt();
		//stores value -> num of items
		HashMap<Long,Integer> vals = new HashMap<>();
		long sum = 0;
		for(int i=0;i<nums;i++) {
			long tem = inputs.nextLong();
			if(!vals.containsKey(tem)) {
				vals.put(tem, 0);
			}
			vals.put(tem, vals.get(tem)+1);
			sum+=tem;
		}
		long Q = inputs.nextLong();
		for(long i=0;i<Q;i++) {
			long C = inputs.nextLong();
			long A = inputs.nextLong();
			if(!vals.containsKey(C)) {
				System.out.println(sum);
				continue;
			}
			sum+=(A-C)*vals.get(C);
			if(!vals.containsKey(A)) {
				vals.put(A, 0);
			}
			vals.put(A, vals.get(A)+vals.get(C));
			vals.remove(C);
			
			System.out.println(sum);
		}
	}

}


Measured memory_bytes: 71756
#include <cstdio>
#include <vector>
using namespace std;

int main() {
	int n,min, s=0;
	vector<int> a;
	scanf("%d",&n);
	a.resize(n);
	for(int i=0; i<n; ++i) {
		scanf("%d",&a[i]);
	}
	for(int i=0; i<n; ++i) {
		min=i;
		for(int j=i+1; j<n; ++j) {
			if(a[j]<a[min]) {
				min=j;
			}
		}
		if(min!=i) {
			swap(a[i],a[min]);
			++s;
		}
	}
	for(int i=0; i<n-1; ++i) {
		printf("%d ",a[i]);
	}
	printf("%d\n%d\n",a[n-1],s);
	return 0;
}

Measured memory_bytes: 2744
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9

int dp[41][401][401]; // dp[i][a][b] : i番目までの溶液で、(a,b)となる最小のコスト
int a[41], b[41], c[41];

int main() {
	int N, Ma, Mb;
	scanf("%d%d%d", &N, &Ma, &Mb);
	for (int i = 1; i <= N; i++) scanf("%d%d%d", &a[i], &b[i], &c[i]);

	for (int A = 0; A <= 400; A++) {
		for (int B = 0; B <= 400; B++) {
			if (A == 0 && B == 0) dp[0][0][0] = 0;
			else dp[0][A][B] = INF; // 無理
		}
	}

	for (int i = 1; i <= N; i++) {
		for (int A = 0; A <= 400; A++) {
			for (int B = 0; B <= 400; B++) {

				if (A >= a[i] && B >= b[i]) dp[i][A][B] = min(dp[i - 1][A][B], dp[i - 1][A - a[i]][B - b[i]] + c[i]);
				else dp[i][A][B] = dp[i - 1][A][B];

			}
		}
	}

	int ans = INF;

	for (int A = 1; A <= 400; A++) {
		for (int B = 1; B <= 400; B++) {

			if (A*Mb == B * Ma) ans = min(ans, dp[N][A][B]);

		}
	}
	
	if (ans >= INF / 10) cout << -1 << endl;
	else  cout << ans << endl;

	
	return 0;
}

Measured memory_bytes: 25984
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

o = ns()
e = ns()

a = []
o_len = 0
e_len = 0
for i in range(50):
    if o_len != len(o):
        a.append(o[i])
        o_len += 1
    else:
        continue
    if e_len != len(e):
        a.append(e[i])
        e_len += 1
    else:
        continue
while "\n" in a:
    a.remove("\n")
a = "".join(a)
print(a)


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////

const int N = 1e5;
int n, k, a[N];

int main() {
    ios::sync_with_stdio(false);
    // cout << fixed << setprecision(7);
    cin >> n >> k;
    --k;
    REP(i, n) cin >> a[i];
    int idx = 0;
    REP(i, n) if(a[i] == 1) idx = i;
    int ans = INF;
    FOR(i, idx-k, idx) {
    	int l = i, r = i+k;
    	int nl = l, nr = n-r-1;
    	// DEBUG(i);
    	// DEBUG(1+(l+k-1)/k+(r+k-1)/k));
    	ans = min(ans, 1+(nl+k-1)/k+(nr+k-1)/k);
    }
    // int l = idx, r = n-idx-1;
    // int sub = (l%k + r%k == k ? 1 : 0);
    // int lans = (l+k-1)/k, rans = (r+k-1)/k;
    // cout << (n == k+1 ? 1 : lans+rans-sub) << endl;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
///////////////////////////////////////////////////////////////////////////////

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <typeinfo>

using namespace std;

///////////////////////////////////////////////////////////////////////////////

#define pb push_back

struct T2 {
        long t0;
        long t1;
};

struct T3 {
        long t0;
        long t1;
        long t2;
};

void longin(long &a)
{
        cin >> a;
}

void longinl1(auto &v, long count)
{
        for (long i = 0; i < count ; ++i) {
                long a;
                cin >> a;
                v.push_back(a);
        }
}

void longinl2(auto &v, long count)
{
        for (long i = 0; i < count ; ++i) {
                long a, b;
                cin >> a >> b;
                v.push_back({a, b});
        }
}

void longinl3(auto &v, long count)
{
        for (long i = 0; i < count ; ++i) {
                long a, b, c;
                cin >> a >> b >> c;
                v.push_back({a, b, c});
        }
}

void longina(auto &v, long count)
{
        longinl1(v, count);
}

long min(const vector<long> v)
{
        long ret = (long)numeric_limits<double>::infinity();
        for (auto i : v) ret = min(ret, i);
        return ret;
}

///////////////////////////////////////////////////////////////////////////////

static long nn;
static long mod = pow(10, 9) + 7;

bool ok(const string &last4)
{
        string last3 = string(last4, 1, 3);
        string last2 = string(last4, 2, 2);
        string first2 = string(last4, 0, 2);

        if (last3 == "AGC") return false;
        if (last3 == "ACG") return false;
        if (last3 == "GAC") return false;
        if (last4[0] == 'A' && last2 == "GC") return false;
        if (last4[3] == 'C' && first2 == "AG") return false;

        return true;
}

long dfs(long cur, const string & last3)
{
        static map<string, long> *memo = new map<string, long>[nn+1];
        if (memo[cur].count(last3) > 0) return memo[cur][last3];

        if (cur == nn) return 1;

        long ret = 0;
        for (const char &c : string("ACGT")) {
                string cs = string(1, c);
                if (ok(last3 + cs)) {
                        ret = (ret + dfs(cur + 1, string(last3, 1, 2) + cs)) % mod;
                }
        }

        memo[cur][last3] = ret;
        return ret;
}

int main()
{
        long n;
        longin(n);
        nn = n;

        cout << dfs(0, "TTT");

        return 0;
}

///////////////////////////////////////////////////////////////////////////////


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    string s; cin >> s;
    string ans;
    rep(i, s.size()) {
        if(s[i] == '0') ans += '0';
        else if(s[i] == '1') ans += '1';
        else if(ans.size()) ans.erase(ans.size()-1, 1);
        //cout << s[i] << ' ' << ans << endl;
    }
    cout << ans << endl;
}

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

int display(int n, int a[])
{
  for (int i = 0; i < n - 1; i++)
  {
    cout << a[i] << " ";
  }
  cout << a[n - 1] << endl;

  return 0;
}

int insertionSort (int n, int a[]) {
  int v, j;
  for (int i = 1; i < n; i++) {
    // 未整列部分の最初の値を v に保存
    v = a[i];
    // j は整列部分の最後の値のインデックス
    j = i - 1;
    // 整列部分を、v 以下の値が見つかるまで、右から左に見ていく
    // もし v 以下の値でなければ、その値をひとつ右にずらす
    while (j >= 0 && a[j] > v) {
      a[j + 1] = a[j];
      j--;
    }
    // 整列部分に v より小さい値が見つかれば、その値の次に v の値を挿入する
    // 左端まで見ても v より小さい値がなければ、先頭に v の値を挿入する
    a[j + 1] = v;
    display(n, a);
  }
}

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

  int a[1000];
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }

  display(n, a);

  insertionSort(n, a);

  return 0;
}



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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
static const ll INF = 1LL << 60;
//Write From this Line
bool graph[50][50];
bool visited[50];

queue<int> que;
void bfs(int v){
	while(!que.empty()){
		int node = que.front();
		que.pop();	
		for(int i = 0; i < 50; i++){
		//for(auto x:graph[node]){
			bool x = graph[node][i];
			if(x == false) continue;
			if(visited[i] == true) continue;
			visited[i] = true;
			que.push(i);
		}
	}

}
int main()
{
	int n, m;
	cin >> n >> m;
	int a[m], b[m];
	rep(i,m){
		cin >> a[i] >> b[i];
		--a[i], --b[i];
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}
	// 入力が終わったので i 番目の辺がなかったときに非連結かどうかを見ていく

	ll ans = 0;
	rep(i,m){
		// i 番目の辺を無かったことにする
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = false; 
		rep(j,n) visited[j] = false;

		que.push(0);
		visited[0] = true;
		bfs(0);
		bool bridge = false;
		rep(j,n){
			if(visited[j] == false) bridge = true;
		}
		if(bridge) ans++;

		//抜けるときに、i 番目の辺を復活させる
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main() {
  string s; cin >> s;
  string a = "";
  FOR(i,0,4){
    a += "hi";
    if(s==a) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;


}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<complex>
#include<iomanip>

using namespace std;

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

int main(void){

	int n,a;
	vector<int>G,J;
	cin >> n;
	rep(i,n){
	rep(j,9){
		cin >> a;
		G.push_back(a);
	}
	rep(j,9){
		cin >> a;
		J.push_back(a);
	}

	sort(G.begin(),G.end());
	sort(J.begin(),J.end());

	int Gx=0,Jx=0;

	do{
		int a=0,b=0;
		rep(k,9){
		if(G[k]>J[k]) a+=G[k]+J[k];
		else b+=G[k]+J[k];
		}

		if(a>b) Gx++;
		if(a<b) Jx++;

	}while(next_permutation(J.begin(),J.end()));

	double pg=Gx/362880.0;
	double pj=Jx/362880.0;

	printf("%.5f %.5f\n",pg,pj);

	G.clear(); J.clear();

	}

	return 0;
}

Measured memory_bytes: 1236
p = []
for i in range(2, 1000):
  pix = 0
  for j in range(len(p)):
    if i % p[j] == 0:
      pix = 1
  if pix == 0:
    p.append(i)

mod = int(1e+9 + 7)
N = int(input())
D = {i: 0 for i in p}
for i in range(1, N + 1):
  if i in p:
    D[i] += 1
  else:
    for j in p:
      z = 0
      while i % j == 0:
        i //= j
        z += 1
      D[j] += z
prod = 1
for i in D:
  prod *= D[i] + 1
  prod %= mod
print(prod)

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int Q=in();
	deque<int> V;
	REP(i,Q){
		int q=in();
		int d;
		switch(q){
		case 0:
			d=in();
			d ? V.push_back(in()) : V.push_front(in());
			break;
		case 1:
			out(V[in()]);
			break;
		default:
			d=in();
			d ? V.pop_back() : V.pop_front();
		}
	}

	return 0;
}


Measured memory_bytes: 4528
n=int(input())
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]

cnt=1

import itertools
for seq in itertools.permutations(range(1,n+1)):
    p_hantei=True
    q_hantei=True
    for i in range(n):
        if p[i]!=seq[i]:
            p_hantei=False
            break
    for i in range(n):
        if q[i]!=seq[i]:
            q_hantei=False
            break

    if p_hantei:
        p_num=cnt
    if q_hantei:
        q_num=cnt

    cnt+=1
print(abs(p_num-q_num))

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

#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*****************************************************START******************************************************************/



int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1;
	 //cin >> T;
	// cin.ignore(); must be there when using getline(cin, s)
	while (T--)
	{
		int n ; cin >> n; 
		ll ans = 1;
		vector<ll>arr(n);
		for(int i=0; i<n; i++){
			cin >> arr[i];
			if(arr[i] == 0){
				ans = 0; 
			}
		}
		if(ans == 0){
			cout << 0 << endl;
			return 0; 
		}
		
		for(int i=0; i<n; i++){
			if(arr[i] <= (1000000000000000000)/ans){
				ans *= arr[i]; 
			}else{
				ans = -1; 
				break;
			}
			//debug(ans);
		}
		cout << ans << endl;
	}
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main(void) {
    ll N;
    vector<ll> a;
    vector<ll> good;
    vector<ll> balls;
    cin >> N;
    a.resize(N);
    balls.resize(N, 0);
    for(ll i = 0;i < N;i++) cin >> a[i];
    for(ll i = N;i >= 1;i--) {
        ll count = 0;
        for(ll j = 1;j < N / i + 1;j++) {
            if(i * j <= N) count += balls[i * j - 1];
        }
        if(count % 2 != a[i - 1]) {
            balls[i - 1] = 1;
            good.push_back(i);
        }
    }
    cout << good.size() << endl;
    for(auto &i: good) cout << i << ' ';
    return 0;
}


Measured memory_bytes: 4980
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

const int MOD = 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	int n, k;
	cin >> n >> k;
	vector<double>	V(n);
	rep(i, n)
	{
		double	x;
		cin >> x;
		V.at(i) = (x + 1.0) / 2.0;
	}
	double maxv;
	double tempv;
	rep(i, k)
		tempv += V.at(i);
	maxv = tempv;
	for (int i = 1; i < n - k + 1; i++)
	{
		tempv = tempv - V.at(i - 1) + V.at(i + k - 1);
		// for (int j = i; j < i + k; j++)
		// 	sum += V.at(j);
		maxv = max(maxv, tempv);
	}
	cout << maxv << endl;
}
// END

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


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int a =s.nextInt(),b=s.nextInt();
        System.out.println(Math.max(a+b,Math.max(a-b,a*b)));
    }
}



class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25400
#include<iostream>
#include<stdio.h>

using namespace std;
int main(){
    char x;
    while(1){
        int sum=0;
        while((x=getchar())!='\n'){
            sum+=x-'0';
        }
        if(sum==0){
            break;
        }
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;

const long long DIV = 1e9 + 7;

int main(){

    int n, m; cin >> n >> m;

    int a[m];
    for(int i=0; i<m; i++){
        cin >> a[i];
    }

    long long exists[n+1];
    fill(exists, exists+n+1, 1);

    for(int i=0; i<m; i++){
        exists[a[i]] = 0;
    }

    long long f[n+1];
    f[0] = 1;
    f[1] = 1;

    bool isImpossible = false;
    for(int i=2; i<=n; i++){
        if(exists[i-2] == 0 && exists[i-1] == 0){
            isImpossible = true;
            break;
        }
        else{
            // cout << i - 1 << " " << exists[i-1] << " " << f[i-1] << " " << endl;
            f[i] = (exists[i-1]*f[i-1] + exists[i-2]*f[i-2]) % DIV;
        }
    }

    cout << (isImpossible ? 0 : f[n]) << endl;

    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=1000010;
int v[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') ch=='-'?o=-1:0,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return o*x;
}
int main() {
    int n,q,tp=0,la=0,pre;
    cin>>n,pre=gi()-gi();
    for(int i=3;i<n;i++) {
	int x=gi();
	for(int j=1;j<=x;j++) {
	    if(la-j<=0) v[++tp]=j-la;
	    else v[++tp]=v[la-j];
	}
	la+=x;
    }
    cin>>q;
    while(q--) {
	int x=gi()-la;
	if(x<-la) x=-la*2-x;
	printf("%d\n",(x>=0?x:v[-x])+pre);
    }
    return 0;
}

Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pll pair<long long, long long >
#define ll long long
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define maxn 100000
#define endl '\n'
#define trace(x) cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
int mod(int x,int y)
{
  int s;
  s = abs(x)/y;
  if(x<0)s--;
  return x-y*s;
}
int dir8[2][8] = {{1,-1,0,0,1,-1,1,-1},{0,0,1,-1,1,-1,-1,1}};
int dir4[2][4] = {{1,-1,0,0},{0,0,1,-1}};
int m,n,row,col,k;
int ara[105];
int deepee[100006];
void solve()
{
  scanf("%d%d",&n,&k);
  for(int w=0;w<n;w++)
  {
    scanf("%d",&ara[w]);
    m = (w==0)?ara[w]:min(m,ara[w]);
  }
  for(int q=0;q<m;q++)deepee[q] = 1;
  for(int w=m;w<=k;w++)
  {
    deepee[w] = 1;
    for(int q=0;q<n;q++)
    {
      if(w-ara[q]>=0)
      {
        if(deepee[w-ara[q]]==1)
        {
          deepee[w]=0;
        }
      }
    }
  }
  if(deepee[k] == 1)printf("Second\n");
  else printf("First\n");
}
void test()
{
  int t;
  t = 1;
  for(int test=1;test<=t;test++)
  {
    solve();
  }
}
int main()
{
  test();
  return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int N=sc.nextInt();
    for(int i=0;i<46300;i++){
      if((i*27>=25*N)&&(i*27<25*N+25)){System.out.println(i);System.exit(0);}}
    System.out.println(":(");
  }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

struct edge {
    ll to, cost;
};

ll N;
// vector<edge> G[1000000];
VV<edge> G(1000000);
V<ll> d(1000000);

void addedge(VV<edge>& G, int st, int ed, ll co) {
    edge e;
    e.to = ed;
    e.cost = co;
    G[st].push_back(e);
}

void dijkstra(int s) {
    d = V<ll>(N, llmax);
    priority_queue<plglg, vector<plglg>, greater<plglg> > que;
    // fill(d.begin(), d.end(), llmax);
    d[s] = 0;
    que.push(plglg(0, s));

    while (!que.empty()) {
        plglg p = que.top();
        que.pop();
        ll v = p.second;
        if (d[v] < p.first) {
            continue;
        }
        int len = G[v].size();
        for (int i = 0; i < len; i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(plglg(d[e.to], e.to));
            }
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X, Y;
    cin >> N >> X >> Y;
    V<ll> ans(N, 0);
    REP(i, 0, N - 1) {
        addedge(G, i, i + 1, 1);
        addedge(G, i + 1, i, 1);
    }
    addedge(G, X - 1, Y - 1, 1);
    addedge(G, Y - 1, X - 1, 1);
    REP(i, 0, N) {
        dijkstra(i);
        REP(j, 0, N) {
            ans[d[j]]++;
        }
    }
    REP(i, 1, N) {
        cout << ans[i] / 2 << endl;
    }
}


Measured memory_bytes: 31616
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
	bool f = true;
	vector <string>w;
	int n; cin >> n;
	w.push_back({});
	cin >> w.back();
	for (int i = 1; i < n; i++) {
		w.push_back({});
		cin >> w.back();
		if (f) {
			if (w[i - 1][w[i - 1].size() - 1] != w.back()[0]) {
				f = false;
				goto end;
			}
			for (int j = 0; j < i; j++) {
				if (w[j] == w.back()) {
					f = false;
					break;
				}
			}
		end:;
		}
	}
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
use v5.18;
use warnings;
use List::Util qw( sum );
use Data::Dumper;
sub read_line { chomp(my $s = <>); $s }
sub splited_read_line { split / /, read_line }

my $N = read_line;
my @lines = sort { $a <=> $b } splited_read_line;
my $max = pop @lines;
say sum(@lines) > $max ? 'Yes' : 'No';


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
 
int LevenshteinDistance(string s1, string s2){
    int d[s1.length() + 1][s2.length() + 1];
    for(int i = 0; i <= s1.length(); i++) d[i][0] = i;
    for(int i = 0; i <= s2.length(); i++) d[0][i] = i;
 
    for(int i = 1; i <= s1.length(); i++){
        for(int j = 1; j <= s2.length(); j++){
            int cost;
            if(s1[i - 1] == s2[j - 1]) cost = 0;
            else cost = 1;
            d[i][j] = min(d[i - 1][j] + 1, min(d[i][j - 1] + 1, d[i - 1][j - 1] + cost));
        }
    }
    return d[s1.length()][s2.length()];
}
 
int main(){
    string s1, s2;
    cin >> s1 >> s2;
    cout << LevenshteinDistance(s1, s2) << endl;
    return 0;
}

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

int main()
{
  string s; cin >> s;
  int c = -1;
  bool ans = true;
  rep(i, s.size())
  {
    if ((c == -1 && s[i] == 'h') || (c == 1 && s[i] == 'i'))
      c *= -1;
    else
    {
      ans = false;
    }
  }
  if (ans && c == -1)
    cout << "Yes" << endl;
  else
  {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  long long int n;
  cin>>n;
  long long int arr[n],i,ans=0;
  for(i=0;i<n;i++)
  	cin>>arr[i];
  for(i=0;i<n;i++)
  	ans=ans^arr[i];
  for(i=0;i<n;i++)
  	arr[i]=ans^arr[i];
  for(i=0;i<n;i++)
  	cout<<arr[i]<<" ";
}

Measured memory_bytes: 5140
"""
A - Subscribers
"""


def solve():
    N = int(input())
    A = input()
    B = input()
    C = input()
    change_count = 0
    for i in range(N):
        if A[i] == B[i] == C[i]:
            pass
        elif (A[i] == B[i] or
              A[i] == C[i] or
              B[i] == C[i]):
            change_count += 1
        else:
            change_count += 2
    print(change_count)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
import java.io.*;

public class Main {
	
	public static void main(String[] args)throws IOException{
		
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String str = in.readLine();
		
		String[] size = str.split(" ");
		int[] Num = new int[5];
		
		int W = Integer.parseInt(size[0]);
		int H = Integer.parseInt(size[1]);
		int x = Integer.parseInt(size[2]);
		int y = Integer.parseInt(size[3]);
		int r = Integer.parseInt(size[4]);
		
		if(x-r >= 0 && y-r >= 0 && x+r <= W && y+r <= H){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 24352
#include<cstdio>

using namespace std;

int n, m, a[1001][1001];
int dx[10] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy[10] = {1, 1, 1, 0, 0, -1, -1, -1};
char x;

int main() {
	scanf("%d %d", &n, &m);
	
	for (int i = 1; i <= n; i++) {
		getchar();
		for (int j = 1; j <= m; j++) {
			x = getchar();
			if (x == '#') a[i][j] = -1;
		}
	}
	
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			if (a[i][j] != -1)
				for (int k = 0; k < 8; k++) {
					if (a[i + dx[k]][j + dy[k]] == -1) {
						a[i][j]++;
					}
				}
	
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (a[i][j] == -1) printf("#");
				else printf("%d", a[i][j]);
		}
		putchar('\n');
	}
	
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

struct sieve {
  int n;
  vector<int> f, primes;
  sieve(int n) : n(n), f(n+1, 0) {
    /* O(n log log n) */
    f[0] = f[1] = -1;
    for(int i=2; i<=n; i++) {
      if(f[i]) continue;
      primes.push_back(i); f[i] = i;
      for(long long k=(long long)i*i; k<=n; k+=i) if(!f[k]) f[k] = i;
    }
  }
  bool is_prime(int x) {return f[x]==x;}
  template <typename T>
  vector<pair<T,int>> factors(T x) {
    assert((long long)n*n >= x);
    vector<pair<T,int>> fc;
    if( x>n ) {
      /* O(sqrt(x)) */
      for (int p : primes) {
        int c = 0;
        while (x%p == 0) x /= p, ++c;
        if (c != 0) fc.emplace_back(p,c);
      }
      if(x!=1) fc.emplace_back(x,1);
    } else {
      /* O(log x) */
      while (x != 1) {
        if (fc.size() && fc.back().first == f[x]) fc.back().second++;
        else fc.emplace_back(f[x], 1);
        x /= f[x];
      }
    }
    return fc;
  }
};

int main() {
  int n; cin >> n;
  sieve s(55555);
  for(auto p : s.primes) if(p%5==1) {
    cout << p;
    if(--n) cout << " ";
    else break;
  }
  cout << endl;
}


Measured memory_bytes: 3684
import itertools
import math
 
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

# ABC-150-Cの類題
# N!通りの経路を全探索し、各経路の長さを計算し、その平均値を出力する
# 順列組み合わせの生成には、Pythonならitertoolsが使える！
# O(N!N)だが、Nが十分小さいので間に合う
avg = 0
permutations = list(itertools.permutations(range(N)))
for l in permutations:
  for i in range(len(l)-1):
    avg += math.sqrt((xy[l[i+1]][0] - xy[l[i]][0])**2 + (xy[l[i+1]][1] - xy[l[i]][1])**2)

avg /= len(permutations)
print(avg)

Measured memory_bytes: 13976
//
//  main.cpp
//  at2201
//
//  Created by horse on 2019/4/6.
//  Copyright © 2019 horse. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>

using namespace std;
int main() {
    string a="";
    cin>>a;
    int len=a.length();
    char b[len+1];
    memset(b,0,sizeof (char)*(len+1));
    //cout<<len<<endl;
    for(int i=0;i<len;i++)
    {
        if(a[i]=='p')
        {
            b[len-1-i]='q';
        }
        else if(a[i]=='q')
        {
            b[len-1-i]='p';
        }
        else if(a[i]=='b')
        {
            b[len-1-i]='d';
        }
        else if(a[i]=='d')
        {
            b[len-1-i]='b';
        }
        else b[len-1-i]=a[i];
    }
    //cout<<b<<endl;
    if(a==b)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a, b, c, d;
  in(n);
  a = n;
  b = 0;
  if(n < 10){
    out(n);
    memi;
    return 0;
  }
  while(a / 10 != 0){
    a /= 10;
    b++;
  }
  a = 9;
  rep(i, b - 1){
    a = a * 10 + 9;
  }
  c = a + 1;
  b = b * 9;
  d = b;
  rep(i, 10){
    if((i + 1) * c + a <= n){
      d = b + i + 1;
    }
  }
  out(d);
  memi;
}


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

long long dp[110][5][5][5];

int main() {
    int n; cin >> n;
    dp[0][0][0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int a = 0; a < 5; a++) {
            for (int b = 0; b < 5; b++) {
                for (int c = 0; c < 5; c++) {
                    // dp[i][a][b][c]
                    for (int d = 1; d <= 4; d++) {
                        if (b == 1 && c == 3 && d == 2) continue;
                        if (a == 1 && c == 3 && d == 2) continue;
                        if (b == 3 && c == 1 && d == 2) continue;
                        if (b == 1 && c == 2 && d == 3) continue;
                        if (a == 1 && b == 3 && d == 2) continue;
                        dp[i+1][b][c][d] = (dp[i+1][b][c][d] + dp[i][a][b][c]) % mod;
                    }
                }
            }
        }
    }
    long long ans = 0;
    for (int a = 0; a < 5; a++) {
        for (int b = 0; b < 5; b++) {
            for (int c = 0; c < 5; c++) {
                ans = (ans + dp[n][a][b][c]) % mod;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			double q = sc.nextDouble();
			if(q==-1) break;
			double x = q/2;
			while(Math.abs(x*x*x-q)>=0.00001*q){
				x = x - (x*x*x-q)/(3*x*x);
			}
			System.out.printf("%.6f\n", x);
		}
	}	
}

Measured memory_bytes: 18932
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    a,b,h,m = inpm()
    e = (m/30)*math.pi
    f = (h/6)*math.pi + (math.pi/6)*(m/60)
    x1,y1 = b*math.cos(e),b*math.sin(e)
    x2,y2 = a*math.cos(f),a*math.sin(f)
    print(((x1-x2)**2+(y1-y2)**2)**(1/2))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 11176
#include <iostream>
using namespace std;
int main(){
    long long N=0,T=0,X=0,x,t;
    cin>>N>>X>>T;
    x=X;t=T;
    while(x < N)
    {
        x=X+x;
        t=T+t;
    }
    cout<<t<<endl;
    return 0;}

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

int main() {
  int m, n;
  cin >> m >> n;
  
  if(m < n) {
    for(int i = 0; i < n; i++) {
      cout << m;
    }
    }else{
      for(int i = 0; i < m; i++) {
      cout << n;
    }
    }
  } 

Measured memory_bytes: 256
/*
 _     _    ___  ___  __ __ 
| |   | |  |__ \|__ \/_ /_ |
| |__ | |__   ) |  ) || || |
| '_ \| '_ \ / /  / / | || |
| |_) | |_) / /_ / /_ | || |
|_.__/|_.__/____|____||_||_|
 
*/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;
 
#define N  100005
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll a,b;
		cin>>a>>b;
      	if(b==1)
        {
          cout<<0<<endl;
          exit(0);}
		ll ans=1,x=a;
		while(x<b)
		{
			x+=a-1;
			ans++;
		}
		cout<<ans<<endl;
 
	}
	return 0;
}

Measured memory_bytes: 256