akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

import numpy as np

def is_prime(d):
    # O(d ** 0.5)
    assert d >= 1
    if d == 1:
        flag = False
    else:
        flag = True
        for t in range(2, d):
            if d % t == 0:
                flag = False
                break
            if t ** 2 > d:
                break
    return flag

def miller_rabin(n, k=20):
    # Mistake probability < 0.25 ** k
    # http://hamukichi.hatenablog.jp/entry/2016/02/17/215948
    assert n >= 1
    if n == 2:
        return True
    elif n == 1 or n % 2 == 0:
        return False
    # 2 ** s * d = n - 1
    d = n - 1
    s = 0
    while d % 2 == 0:
        d //= 2
        s += 1
    rng = np.random.RandomState(seed=0)
    for i in range(k):
        a = rng.randint(1, n - 1)
        if pow(a, d, n) != 1:
            for r in range(s):
                if pow(a, d * 2 ** r, n) == n - 1:
                    break
            else:
                return False
    return True

def pow(n, p, mod):
    if p == 0:
        return 1
    elif p % 2 == 0:
        x = pow(n, p // 2, mod)
        return (x * x) % mod
    else:
        x = pow(n, p - 1, mod)
        return (x * n) % mod

def get_list():
    res = [i * 5 + 6 for i in range(12000)]
    res = [x for x in res if miller_rabin(x)]
    return res[:55]

def main():
    n = int(input())
    res = get_list()
    print(*res[:n])

main()


Measured memory_bytes: 12548
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
ll mod = 1e9 + 7;

using namespace std;
using Graph = vector<vector<int>>;
Graph G;

int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


int main()
{
	ll n;
	cin >> n;
	vector<string> S(n);
	for (int i = 0; i < n; i++)
	{
		cin >> S[i];
	}

	string ans;
	for (char c = 'a'; c <= 'z'; c++)
	{
		int small = 100000;
		for (int i = 0; i < n; i++)
		{
			int cnt = 0;
			for (int j = 0; j < S[i].length(); j++)
			{
				if (S[i][j] == c)
				{
					cnt++;
				}
			}
			small = min(small, cnt);
		}
		for (int i = 0;i < small;i++)
		{
			ans += c;
		}
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
tmp = input().split()
tmp = list(map(int, tmp))

takahashi_iter = 0
while 1:
  tmp[2] -= tmp[1]
  takahashi_iter += 1
  if tmp[2] <= 0:
    break
  
aoki_iter = 0
while 1:
  tmp[0] -= tmp[3]
  aoki_iter += 1
  if tmp[0] <= 0:
    break
    
if takahashi_iter <= aoki_iter:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9192
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,a,b) = get!(usize, usize, usize);
    println!("{}", n/(a+b)*a+min!(n%(a+b),a));
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

int     main()
{
	int x, y;
	cin >> x >> y;
	y -= x * 2;
	if (y < 0)
	{
		cout << "No" << endl;
		return (0);
}
	if (y % 2 == 0 && y / 2 <= x)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

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

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int[] num = new int[n];
		int sum = 0;
		int max = 0;
		for (int i = 0; i < n; i++) {
			num[i] = scanner.nextInt();
			sum += num[i];
			max = Math.max(max, num[i]);
		}
		int r = sum;
		int l = Math.max(max, r / m);
		while (l < r) {
			int mid = (r + l) / 2;
			if (isTrue(mid, num, m, sum)) {
				r = mid - 1;
			} else {
				l = mid + 1;
			}
		}
		System.out.println(isTrue(l, num, m, sum) ? l : l + 1);
	}

	private boolean isTrue(int mid, int[] num, int m, int sum) {
		int i = 0;
		int k = mid;
		while (true) {
			if (m == 0)
				return false;
			if (i == num.length)
				return true;
			if (k - num[i] >= 0) {
				k -= num[i];
				i++;
			} else {
				m--;
				k = mid;
			}
		}
	}
}

Measured memory_bytes: 64224
#include <bits/stdc++.h> 
#include <cstring>
using namespace std;
//typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
//define
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

int main(){
    int n;
    cin >> n;
    int count = 0,a = n/10;
    if(a == 0) {
        cout << n << endl;
    }else if(a > 0 && a < 10){
        cout << 9 << endl;        
    }else if(a < 100 && a > 9){
        cout << n-90 << endl;
    }else if(a<1000 && a>99){
        cout << 909 << endl;
    }else if(a<10000 && a>999){
        cout << n+909-9999 << endl;
    }else{
        cout << 90000+900+9 << endl;
    }
      

 return 0;
}

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

using namespace std;

bool linearSearch(int *A, int length, int key){
  for(int i = 0;i < length;i++){
    if(A[i] == key) return true;
  }
  return false;
}

int main(){

  int n, q, cnt = 0;
  int s[10000], t[500];

  cin >> n;
  for(int i = 0;i < n;i++) cin >> s[i];
  cin >> q;
  for(int i = 0;i < q;i++) cin >> t[i];

  for(int i = 0;i < q;i++){
    if(linearSearch(s, n, t[i])) cnt++;
  }

  cout << cnt << endl;

  return 0;
}



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

using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int t,t1,t2;
    t=a-c;
    t1=a-b;
    t2=b-c;
    if(t<0) t=-t;
    if(t1<0)t1=-t1;
    if(t2<0)t2=-t2;
    if(t<=d || t1<=d && t2<=d)
        cout<<"Yes"<<endl;
    else
    {
            cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	int height[n];
	for (int i = 0; i < n; i++)
		cin >> height[i];

	int solucoes[n];
	solucoes[0] = 0;
	for (int i = 1; i < n; i++) {
		int aux = -1;
		for (int j = 1; j <= k; j++) {
			if (i - j >= 0 && (aux == -1 || solucoes[i- j] + abs(height[i - j] - height[i]) < aux))
				aux = solucoes[i- j] + abs(height[i - j] - height[i]);
		}
		solucoes[i] = aux;
	}

	cout << solucoes[n-1] << endl;
}

Measured memory_bytes: 1024
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextLong()
    val p = sc.nextLong()
    var m = p
    var d = 2L
    val pf = mutableMapOf<Long, Int>()
    while (d * d <= m) {
        var count = 0
        while (m % d == 0L) {
            m /= d
            count++
        }
        if (count > 0) {
            pf[d] = count
        }
        d++
    }
    if (m > 1) pf[m] = 1
    var ans = 1L
    for ((p, e) in pf) {
        val f = e / n
        for (i in 0 until f) {
            ans *= p
        }
    }
    println(ans)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34420
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL read()
{
    LL x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

struct Node{
    int a, b, c;
    Node(int _a=0, int _b=0, int _c=0):a(_a), b(_b), c(_c) {}
};

vector<Node> vc;

int main()
{
    int L=read();
    int tmp=L;
    int cnt=0;
    while(tmp){
        tmp>>=1;
        cnt++;
    }
    for(int i=1;i<cnt;i++){
        vc.push_back(Node(i,i+1,0));
        vc.push_back(Node(i,i+1,(1<<i-1)));
    }
    tmp=L;
    int tmp2=0;
    bool ok=true;
    for(int i=cnt-1;i>=0;i--){
        if((tmp>>i)&1){
            tmp-=(1<<i);
            if(!ok){
                vc.push_back(Node(i+1,cnt,tmp2));
            }
            tmp2+=1<<i;ok=false;
        }
    }
    printf("%d %d\n", cnt, (int)vc.size());
    for(int i = 0; i < (int)vc.size(); ++i) {
        printf("%d %d %d\n", vc[i].a, vc[i].b, vc[i].c);
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np
s = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
        if len(str(divisors[-1]))<=9:
            break
    return divisors

if s != 1000000000000000000:
    tmp = int(np.ceil(np.sqrt(s)))
    tmp2 = tmp*(tmp) - s
    if tmp2<=1:
        tmp2 = tmp*(tmp+1) - s
        y3 = tmp +1
    else:
        y3 = tmp
    div = make_divisors(tmp2)[-2:]

    x1 = 0
    y1 = 0
    x2 = tmp
    y2 = div[0]
    try:
        x3 = div[1]
    except:
        x3 = div[0]
    if x2==x3 and y2==y3:
        dummy = y2
        y2 = x3
        x3 = dummy
else:
    x1, y1, x2, y2, x3, y3 = 0, 0, 0, 1000000000, 1000000000, 0
    
print(x1, y1, x2, y2, x3, y3)

Measured memory_bytes: 12504
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	int n;
	while (1) {
		cin >> n;
		if (n == 0) {
			break;
		}
		int mahoujin[17][17] = {0};
		int count = 1;
		int x,y;
		x = n/2+1;
		y = n/2+2;
		int limit;
		limit = n * n;
		mahoujin[x][y] = 1;
		count++;
		while (count <= limit) {
			x++;
			y++;
			bool hantei = true;
			while (hantei) {
				if (x > n) {
					x = 1;
				} else if (x < 1) {
					x = n;
				} else if (y > n) {
					y = 1;
				} else if (mahoujin[x][y] != 0) {
					x--;
					y++;
				}
				if (x < 1 || n < x || n < y || mahoujin[x][y] != 0) {
				} else {
					mahoujin[x][y] = count;
					count++;
					hantei = false;
				}
			}
		}
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				printf("%4d", mahoujin[j][i]);
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
int main(){

    int n,i,t;
    cin>>n;
    multiset<int>a,b;

    for(i=0;i<n-1;i++){
            cin>>t;
            a.insert(t);
    }
    for(int i=1;i<=n;i++){
       cout<<a.count(i)<<endl;
    }
}


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

string N;

int main() {
    cin >> N;
    if (N[0] == N[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,l,a[100005];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin >> n >> l;
	for(int i=0;i<n;i++)
		cin >> a[i];
	for(int i=0;i<n-1;i++)
		if(a[i]+a[i+1]>=l){
			cout << "Possible\n";
			for(int j=0;j<i;j++)
				cout << j+1 << endl;
			for(int j=n-1;j>i+1;j--)
				cout << j << endl;
			cout << i+1 << endl;
			return 0;
		}
	cout << "Impossible";
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define y1 wzpakking
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
using namespace std;
char s[105];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1),fl=0;
	for (int i=1;i<=n;i+=2) if (s[i]=='L') fl=1;
	for (int i=2;i<=n;i+=2) if (s[i]=='R') fl=1;
	puts(fl?"No":"Yes");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k,a,b;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++)
  {
    if(i%k==0)
    {
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vpii = vector<pii>;

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double am = m * 6;
    double ah = (h * 60 + m) / 2.0;

    cout << fixed << sqrt(a * a + b * b - 2 * a * b * cos(abs(am - ah) * M_PI / 180)) << endl;
    
    return 0;
}

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

using namespace std;


int main()
{
	int n;
	cin >> n;
	int p[3] = { 0,0 };
	int answer = 0;

	for (int i = 0; i < n; i++) {
		p[0] = p[1];
		p[1] = p[2];
		cin >> p[2];
		if (i < 2) continue;

		if (((p[0] < p[1]) && (p[1] < p[2])) || ((p[0] > p[1]) && (p[1] > p[2]))) {
			answer++;
		}
	}

	cout << answer << endl;

}

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

#define INF 2147483647

int get_min(int *m,int size){
    int i,min = INF;
    for(i=0;i<size;i++){
        if(min>m[i]){
            min = m[i];
        }
    }
    return min;
}

int main(void){
    int N,X,sum = 0;
    scanf("%d %d",&N,&X);
    int i,min,m[N];
    for(i=0;i<N;i++){
        scanf("%d",&m[i]);
        sum += m[i];
    }
    int num;
    min = get_min(m,N);
    num = N+(X-sum)/min;
    printf("%d\n",num);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int a, b, x;
      cin >> a >> b;
      x = a * b % 2;
        if(x == 0){
         cout << "Even" << endl;
        }
            else{
              cout << "Odd" << endl;
            }
    }
      

Measured memory_bytes: 256
MOD = 1000000007


S = int(input())

#dp[i]:=i桁の数列で条件を満たすものの数
dp = [0]*(S+1)

for i in range(3,S+1):
    #dp[i]=sum(dp[0],..,dp[i-3])+1
    for j in range(i-3+1):
        dp[i] = (dp[i]+dp[j])%MOD
    dp[i] = (dp[i]+1)%MOD

print(dp[S])

Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
    ll N;
    cin >> N;
    vl A(N);
    FOR(i,0,N)cin >> A[i];
    ll ans = INF;
    FOR(i,0,N){
        ll tmp = 0;
        while(A[i]%2 == 0){
            tmp++;
            A[i] /= 2;
        }
        chmin(ans,tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

const MOD: i64 = 1_000_000_007;

fn main() {
    let n = scan!(usize);

    let mut ans = 1;
    for i in 1..n + 1 {
        ans *= i as i64;
        ans %= MOD
    }
    println!("{}", ans)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)

vector<vector<int>> e;
int dfs(int now, int prv)
{
    int g = 0;
    for (auto nxt : e[now]) if (nxt != prv) g ^= dfs(nxt, now);
    return g + 1;
}

int main()
{
    int N;
    cin >> N;
    e.resize(N + 1);
    REP(_, N - 1)
    {
        int u, v;
        cin >> u >> v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    cout << (dfs(1, 0) - 1 ? "Alice" : "Bob") << endl;
}


Measured memory_bytes: 10368
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int n,dy[]={0,1,0,-1},dx[]={1,0,-1,0};
char s,b,j;
map<pair<int,char>,double> M;

char code(int y,int x){
	return 'A'+y*3+x;
}

pi dec(char c){
	return pi((c-'A')/3,(c-'A')%3);
}

double f(int n,char c){
	if(n==0)return c==b;
	if(M.find(pi(n,c))!=M.end())return M[pi(n,c)];
	double& res=M[pi(n,c)]=0;
	pi p=dec(c);
	int y=p.fir,x=p.sec;
	rep(i,4){
		int ny=y+dy[i],nx=x+dx[i];
		if(ny<0||2<ny||nx<0||2<nx||code(ny,nx)==j)res+=f(n-1,c)/4;
		else res+=f(n-1,code(ny,nx))/4;
	}
	return res;
}

int main(){
	while(cin>>n&&n){
		M.clear();
		cin>>s>>b>>j;
		cout<<f(n,s)<<endl;
	}
}

Measured memory_bytes: 0
/*Author : Yuvraj Singh
 * Patience is Power
 * 
 * */
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const long long mod = 1e9 + 7;
#define ar array
/*
ll power(ll x,ll y) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return ((temp%mod)*(temp%mod))%mod; 
    else
        return (((x%mod)*(temp%mod))%mod*(temp%mod))%mod; 
}

int gcd(int x,int y){
	return y==0?x:gcd(y,x%y);
}

bool cmp(pair<int,int>a,pair<int,int>b){
	return a.second<b.second;
}
*/
void solve(){
	ll n; cin>>n;
	vector<ll>a(n),b(n);
	for(ll i=0;i<n;i++) cin>>a[i];
	for(ll i=0;i<n;i++) cin>>b[i];
	reverse(b.begin(),b.end());
	
	ll st=0,end=n-1;
	for(ll i=0;i<n;i++){
		if(a[i]==b[i]){
			if(b[i]!=b[st]&&a[st]!=b[i]) swap(b[i],b[st]),st++;
			else if(b[i]!=b[end]&&a[end]!=b[i]){
				swap(b[i],b[end]),end--;
			}
			else{
				cout<<"No"<<"\n"; return;
			}
		}
	}
	for(ll i=0;i<n;i++){
		if(a[i]==b[i]){
			cout<<"No"<<"\n"; return;
		}
	}
	cout<<"Yes"<<"\n";
	for(ll x:b) cout<<x<<" ";
	cout<<"\n";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	//int t; cin>>t;
	//while(t--)
		solve();
		
    return 0;
}



Measured memory_bytes: 6368
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;
ll dp[ohara][4];

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

  cin >> n;
  rep(i, n) cin >> a[i];

  rep(i, n) rep(j, 3) dp[i][j] = -LINF;

  if (n % 2 == 0) {
    for (ll i = n - 2; i >= 0; i -= 2) {
      //そのまま
      dp[i][0] = max(dp[i + 2][0], dp[i + 2][1]) + a[i];
      //
      dp[i][1] = dp[i + 2][1] + a[i + 1];
      // debug(dp[i][0]);
    }
    ans = max(dp[0][0], dp[0][1]);
    Cout(ans);
  } else {
    rep(i, n) {
      if (i % 2 == 1) continue;
      ans += a[i];
    }
    for (ll i = n - 2; i >= 0; i -= 2) {
      //そのまま
      dp[i][0] = max(dp[i + 2][0], dp[i + 2][1]) + a[i];
      //
      dp[i][1] = dp[i + 2][1] + a[i + 1];
      //
      dp[i][2] = max({dp[i + 2][0], dp[i + 2][1], dp[i + 2][2]}) + a[i - 1];
      // debug(dp[i][0]);
    }
    ans = max({ans, dp[1][0], dp[1][1], dp[1][2]});
    Cout(ans);
  }
  return 0;
}

Measured memory_bytes: 11476
n,a,b=map(int,input().split())
MOD=10**9+7
def inv(a):
  return pow(a,MOD-2,MOD)

def choose(n,r):
  if r==0 or r==n:
    return 1
  else:
    A=B=1
    ls_A=[1]
    ls_B=[1]
    for i in range(r):
      A=ls_A[i]*(n-i)%MOD
      ls_A.append(A)
      B=ls_B[i]*(i+1)%MOD
      ls_B.append(B)
    return ls_A[r]*inv(ls_B[r])%MOD

def pow_k(x,n):
    if n==0:
        return 1
    K=1
    while n>1:
        if n%2 != 0:
            K=K*x%MOD
            x=x**2%MOD
            n=(n-1)//2
        else:
            x=x**2%MOD
            n=n//2%MOD
    return K*x%MOD 

print((pow_k(2,n)-1-choose(n,a)-choose(n,b))%MOD)

Measured memory_bytes: 21500
/* Bismillahir Rahmanir Rahim */

#include <bits/stdc++.h>

#define rep(i, n)	for(int i=0;i<n;i++)
#define repn(i, n)	for(int i=1;i<=n;i++)
#define set(i, n)	memset(i, n, sizeof(i))

#define mx		1000007
#define pb		push_back
#define inf 	(1 << 30)

#define f	first
#define s 	second

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

string str;

int main(){
	cin >> str;
	int ret = 0;
	for(int i=1;i<str.size();i++){
		if(str[i] != str[i-1]) ret++;
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 512
import sys
import bisect

def I(): return int(sys.stdin.readline().rstrip())
def LI():return list(map(int,sys.stdin.readline().rstrip().split()))
def LS():return list(sys.stdin.readline().rstrip().split())


def main():
  X,N = LI()[:]
  if N > 0:
    P = LI()
    P.sort()
  else:
    print(X)
    exit()
  
  #print(X,N)
  #print(P)
  
  index = bisect.bisect_left(P, X)
  #print("index=",index)
  if index >= N :
    print(X)
    exit()
    
  l = index
  r = index
  for i in range(0,200):
    up = X + i
    down = X - i
    
    #print("l=",l,"r=",r)
     
    # Left優先
    if l < 0 or P[l] != down:
      print(down)
      break

    if r >= N or P[r] != up:
      print(up)
      break
    
    l -= 1
    r += 1
    
if __name__ == '__main__':
	main()


Measured memory_bytes: 9236
#include <iostream>
#include <cctype>
#include <string>
#include <string.h>
using namespace std;
int main(){
    string a,b = "";
    while(cin >> a){
        for(int i = 0; i < a.length(); i++){
            if(a[i] >= 'a' && a[i] <= 'z' ){
                a[i] += 'A' - 'a';
            } else if(a[i] >= 'A' && a[i] <= 'Z' ) {
                a[i] -= 'A' - 'a';
            }
        }
    b += a +  " " ;
        
    }
    for(int i = 0; i < b.length() - 1; i ++){
        cout << b[i] ;
    }
    cout << endl;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  for(int i=0;i<2*n;i++){
    if(i%2 == 0) cout << s.at(i/2);
    else cout << t.at(i/2);
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define X first
#define Y second
#define WIDTH 8
#define HEIGHT 8

using namespace std;

struct point{
	point(int x = 0, int y = 0, char dir = 'R'):x(x), y(y), dir(dir){}
	int x;
	int y;
	char dir;
};

char moveMap(vector<string> &map, point &player){
	switch(player.dir){
	case 'R':
		if(player.y != 0 && map[player.y - 1][player.x + 1] == '1'){
			player.y -= 1;
			player.x += 1;
			player.dir = 'U';
		}
		else if(player.x != map[player.y].size() - 1 && map[player.y][player.x + 1] == '1'){
			player.x += 1;
		}
		else if(player.y != 8 && map[player.y + 1][player.x + 1] == '1'){
			player.y += 1;
			player.x += 1;
			player.dir = 'D';
		}
		else player.dir = 'L';
		break;
	case 'L':
		if(player.y != 8 && map[player.y + 1][player.x] == '1'){
			player.y += 1;
			player.dir = 'D';
		}
		else if(player.x != 0 && map[player.y][player.x - 1] == '1'){
			player.x -= 1;
		}
		else if(player.y != 0 && map[player.y - 1][player.x] == '1'){
			player.y -= 1;
			player.dir = 'U';
		}
		else player.dir = 'R';
		break;
	case 'U':
		if(player.x != 0 && map[player.y - 1][player.x - 1] == '1'){
			player.y -= 1;
			player.x -= 1;
			player.dir = 'L';
		}
		else if(player.y != 1 && map[player.y - 2][player.x] == '1'){
			player.y -= 2;
		}
		else if(player.x != map[player.y].size() - 1 && map[player.y - 1][player.x] == '1'){
			player.y -= 1;
			player.dir = 'R';
		}
		else player.dir = 'D';
		break;
	case 'D':
		if(player.x != map[player.y].size() - 1 && map[player.y + 1][player.x] == '1'){
			player.y += 1;
			player.dir = 'R';
		}
		else if(player.y != 7 && map[player.y + 2][player.x] == '1'){
			player.y += 2;
		}
		else if(player.x != 0 && map[player.y + 1][player.x - 1] == '1'){
			player.y += 1;
			player.x -= 1;
			player.dir = 'L';
		}
		else player.dir = 'U';
		break;
	default:
		break;
	}
	return player.dir;
}

int main(){
	string tmp;
	while(cin >> tmp){
		if(cin.eof()) break;
		
		vector<string> map;
		map.push_back(tmp);
		for(int i = 1; i < 9; i++){
			cin >> tmp;
			map.push_back(tmp);
		}

		point player(0, 0, 'R');
		string root;
		root.push_back('R');
		
		while(1){
			root.push_back(moveMap(map, player));
			if(player.x == 0 && player.y == 0) break;
		}

		for(int i = 0; i < root.size(); i++){
			cout << root[i];
		}
		cout << endl;
	}
	return 0;
}

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

bool is_prime(int n) {
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) return false;
  }
  return true;
}

int main() {
  int n; { cin >> n; }
  vector<int> a(n); { for (int i = 0; i < n; ++i) cin >> a[i]; }
  int ans = accumulate(begin(a), end(a), 0, [](int acc, int x) { return acc + is_prime(x); });
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3056
import sys
from pprint import pprint

def solve(n, info):
    ans = 0
    for i in range(2 ** n):
        true_info = {}
        p_info = [0] * n
        for j in range(n):
            if (i >> j) & 1:
                true_info[j] = info[j]
                # pprint(info[j])
                p_info[j] = 1
        # print("p_info")
        # pprint(p_info)
        # print("true_info")
        # pprint(true_info)
        flag = True
        for _, info_list in true_info.items():
            for x, y in info_list:
                if p_info[x-1] != y:
                    flag = False
                    break
            if not flag:
                break

        if flag:
            # pprint(true_info)
            ans = max(ans, sum(p_info))

    print(ans)

if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    info = []
    for i in range(n):
        a = int(sys.stdin.readline().strip())
        info.append([])
        for _ in range(a):
            x, y = map(int, sys.stdin.readline().strip().split(" "))
            info[i].append((x, y))
    
    # pprint(info)
    solve(n, info)

Measured memory_bytes: 44140
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

    public static void main(String[] args) throws IOException {
        try (InputReader reader = new InputReader(System.in)) {
            solve(reader);
        }
    }

    private static void solve(InputReader reader) throws IOException {
        int[] inputs = reader.readIntsSplitBy(" ");
        int a = inputs[0];
        int b = inputs[1];
        int k = inputs[2];

        for (int i = 0; i < k; i++) {
            if (a % 2 == 1) {
                a--;
            }

            a /= 2;
            b += a;

            i++;
            if (i >= k) break;

            if (b % 2 == 1) {
                b--;
            }

            b /= 2;
            a += b;
        }

        System.out.println(a + " " + b);
    }
}

class Util {
    static int gcd(int m, int n) {
        int min = Math.min(m, n);
        int max = Math.max(m, n);
        while (min != 0) {
            int tmp = min;
            min = max % tmp;
            max = tmp;
        }

        return max;
    }

    static int lcm(int m, int n) {
        return m / gcd(m, n) * n;
    }
}

class InputReader implements Closeable, AutoCloseable {
    private final BufferedReader br;

    InputReader(InputStream inputStream) {
        this.br = new BufferedReader(new InputStreamReader(inputStream));
    }

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

    int readInt() throws IOException {
        return Integer.parseInt(this.readLine());
    }

    long readLong() throws IOException {
        return Long.parseLong(this.readLine());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(this.readLine());
    }

    String[] readStringsSplitBy(String delimiter) throws IOException {
        return this.readLine().split(delimiter);
    }

    int[] readIntsSplitBy(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitBy(delimiter);

        int[] ints = new int[strings.length];
        for (int i = 0; i < strings.length; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }

        return ints;
    }

    long[] readLongsSplitBy(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitBy(delimiter);

        long[] longs = new long[strings.length];
        for (int i = 0; i < strings.length; i++) {
            longs[i] = Long.parseLong(strings[i]);
        }

        return longs;
    }

    double[] readDoublesSplitBy(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitBy(delimiter);

        double[] doubles = new double[strings.length];
        for (int i = 0; i < strings.length; i++) {
            doubles[i] = Double.parseDouble(strings[i]);
        }

        return doubles;
    }

    @Override
    public void close() throws IOException {
        this.br.close();
    }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

string S; cin >> S;
VS you{"SUN","MON","TUE","WED","THU","FRI","SAT" };

cout << 7 - distance(you.begin(), find(ALL(you), S)) << "\n";

}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
using namespace std;

const int T = 24 * 60 * 60;

int main(){
  istringstream ss;
  while(1){
    int n;
    cin >> n;
    if (n == 0) break;
    vector<int> sum(T+1, 0);
    rep(i, n){
      vector<string> s(2);
      cin >> s[0] >> s[1];
      rep(k, 2){
        int t = 0;
        rep(j, 3){
          ss = istringstream(s[k].substr(j*3, 2));
          int num; ss >> num;
          t += num * pow(60, 2-j);
        }
        if (k == 0) sum[t]++;
        else sum[t]--;
      }
    }
    
    int ans = sum[0];
    rep(i, T){
      sum[i+1] += sum[i];
      ans = max(ans, sum[i+1]);
    }
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3580
N = int(input())
A = list(map(int,input().split()))
C = {i:0 for i in range(9)}
for j in range(N):
    a = A[j]
    if a<400:
        C[0] += 1
    elif a<800:
        C[1] += 1
    elif a<1200:
        C[2] += 1
    elif a<1600:
        C[3] += 1
    elif a<2000:
        C[4] += 1
    elif a<2400:
        C[5] += 1
    elif a<2800:
        C[6] += 1
    elif a<3200:
        C[7] += 1
    else:
        C[8] += 1
cmin = 0
for i in range(8):
    if C[i]>0:
        cmin += 1
cmax = cmin+C[8]
if cmin ==0:
    cmin = 1
print(cmin,cmax)

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <queue>

typedef std::vector<int> vi;
typedef std::vector<vi> vvi;

int main()
{
  int N, M, K;
  std::cin >> N >> M >> K;
  vvi direct_friend(N);
  for (int i = 0; i < M; i++)
  {
    int A, B;
    std::cin >> A >> B;
    direct_friend.at(A-1).push_back(B-1);
    direct_friend.at(B-1).push_back(A-1);
  }
  vvi block(N);
  for (int i = 0; i < K; i++)
  {
    int C, D;
    std::cin >> C >> D;
    block.at(C-1).push_back(D-1);
    block.at(D-1).push_back(C-1);
  }
  vi groups, affiliation(N, -1);
  std::queue<int> que;
  int index = 0;
  for (int i = 0; i < N; i++)
  {
    if (affiliation.at(i) != -1) continue;
    que.push(i);
    int num = 1;
    while(!que.empty())
    {
      int now = que.front();
      que.pop();
      affiliation.at(now) = index;
      for (auto x : direct_friend.at(now))
      {
        if (affiliation.at(x) != -1) continue;
        affiliation.at(x) = index;
        num++;
        que.push(x);
      }
    }
    index++;
    groups.push_back(num);
  }

  for (int i = 0; i < N; i++)
  {
    // std::cout << "af: " << affiliation.at(i);
    // std::cout << ", gr: " << groups.at(affiliation.at(i));
    // std::cout << ", di: " << direct_friend.at(i).size();
    // std::cout << ", bl: " << block.at(i).size() << std::endl;
    int ans = 0;
    ans += groups.at(affiliation.at(i)) - direct_friend.at(i).size() - 1;
    for (auto x : block.at(i))
    {
      if (affiliation.at(x) == affiliation.at(i)) ans--;
    }
    std::cout << ans;
    if (i != N-1) std::cout << " ";
    else std::cout << std::endl;
  }
}


Measured memory_bytes: 12664
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,d = map(int,readline().split())
xy = list(map(int,read().split()))

d2 = d*d
ans = 0
it = iter(xy)
for x,y in zip(it,it):
    if(x**2+y**2 <= d2):
        ans += 1

print(ans)

Measured memory_bytes: 107608
import math

def sieve(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if is_prime[i]:
            j = 2 * i
            while j <= n:
                is_prime[j] = False
                j += i
    return is_prime

Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]

primes = sieve(100000 + 1)
c = [0] * (100000 + 2)

for i, v in enumerate(primes):
    if v and i > 1 and i % 2 == 1 and primes[(i + 1) // 2]:
        c[i] = c[i-1] + 1
    else:
        c[i] = c[i-1]

for l, r in LR:
    print(c[r]-c[l-1])


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

int main() {
    int N, M, a, b;
    cin >> N >> M;
    vector<int> ans(N, 0);
    rep(i, M) {
        cin >> a >> b;
        ans[a - 1]++;
        ans[b - 1]++;
    }
    rep(i, N) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
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 cnt[110];

int main(void){
	int n,k,i,d,j,a,ans=0;
	std::cin >> n >> k;
	for(i=0; i<k; ++i){
		std::cin >> d;
		for(j=0; j<d; ++j){
			std::cin >> a;
  			--a; ++cnt[a];
		}
	}
	for(i=0; i<n; ++i){
		if(!cnt[i]){
			++ans;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;
int main() {
  //
  ll a,b,c;
  cin >> a >> b >>c;
  cout << min(b/a, c) << endl;
  return 0;
}

Measured memory_bytes: 256
// Try CADDi 2018 for Beginners
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let mut p = get!();
    if n== 1 {
    	println!("{}", p);
        return;
    }
    
    let mut ans = 1_i64;
    let mut i = 2;
    while i * i <= p {
    	if p % i == 0 {
        	let mut c = 0;
            while p % i == 0 {
            	p /= i;
                c += 1;
            }
            let x = c / n;
            for _ in 0..x {
            	ans *= i;
            }
        }
        i += 1;
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<algorithm>
#include<string>
#include<iostream>
#define ll long long
using namespace std;
int main(){
  ll N;
  cin >> N;
  string str[N];
  ll i;
  for(i=0;i<N;i++){
    cin >> str[i];
    sort(str[i].begin(),str[i].end());
  }
  sort(str,str+N);
  ll tmp=1;
  ll ans=0;
  for(i=1;i<N;i++){
    if(str[i-1]==str[i]){
      ans+=tmp;
      tmp++;
    }else tmp=1;
  }
  		cout << ans;
       return 0;
}

Measured memory_bytes: 7296
#!/usr/bin/env python
# coding: utf-8

# In[6]:


N = int(input())
A = list(map(int, input().split()))


# In[7]:


ans = 0
while 1:
    mylist = [x%2**(ans+1) for x in A]
    if sum(mylist) > 0:
        break
    else:
        ans += 1
print(ans)


# In[ ]:






Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
    unsigned long int A[3][3], B[10], bingo[3][3], N = 0, count = 0;
    for(int i = 0 ; i < 3 ; i++){
        for(int j = 0 ; j < 3 ; j++){
            cin >> A[i][j];
            bingo[i][j] = 0;
        }
    }
    cin >> N;
    for(int i = 0 ; i < N ; i++){
        cin >> B[i];
    }
    for(int i = 0 ; i < 3 ; i++){
        for(int j = 0 ; j < 3 ; j++){
            for(int k = 0 ; k < N ; k++){
                if(A[i][j] == B[k]){
                    bingo[i][j] = 1;
                }
            }
        }
    }
    for(int i = 0 ; i < 3 ; i++){
        if(bingo[i][0] * bingo[i][1] * bingo[i][2] == 1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    for(int i = 0 ; i < 3 ; i++){
        if(bingo[0][i] * bingo[1][i] * bingo[2][i] == 1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(bingo[0][0] * bingo[1][1] * bingo[2][2] == 1){
        cout << "Yes" << endl;
        return 0;
    }
    if(bingo[2][0] * bingo[1][1] * bingo[0][2] == 1){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<bits/stdc++.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[5];
int main()
{
    for(int i=1; i<=3; i++)
        scanf("%d",&a[i]);
    sort(a+1,a+4);
    printf("%d\n",a[1]+a[2]);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int count = 0;
        boolean flg = false;
        for(int i = 0; i < N; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a == b){
                count++;
            }else{
                count = 0;
            } 
            if(count >= 3){
                flg = true;
                break;
            }
        } 
        if(flg == true){
            System.out.print("Yes");
        }else{
            System.out.print("No");
        }
    }
}



Measured memory_bytes: 35988