akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

const int N = 100000;
int q;
bool a[N + 5];
bool b[N + 5];
int c[N + 5];

int main()
{
    scanf("%d", &q);
    a[0] = a[1] = true;
//    for(int i = 2; i <= N; i++)
//    {
//        if(a[i]) continue;
//        for(int j = i * 2; j <= N; j += i)
//        {
//            a[j] = true;
//        }
//    }
    for(int i = 2; i * i <= N; i++)
    {
        if(a[i]) continue;
        for(int j = i * i; j <= N; j += i)
        {
            a[j] = true;
        }
    }

    for(int i = 2; i <= N; i++)
    {
        if(!a[i] && !a[(i + 1) / 2]) b[i] = true;
        c[i] = b[i] + c[i - 1];
        //printf("%d\n", c[i]);
    }

    for(int i = 0; i < q; i++)
    {
        int l, r;
        scanf("%d%d", &l, &r);
        printf("%d\n", c[r] - c[l - 1]);
    }
    return 0;
}


Measured memory_bytes: 1280
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

signed main() {
	tezz
 

	string s;
	cin >> s;
	if(s[s.length()-1] == 's'){
		s+="es";
	}
	else{
		s+='s';
	}
	cout << s << endl;
 
	return 0;
}  

Measured memory_bytes: 3624
s = input()
op = ["+","-"]
ans = ""
for i in range(1 << len(s) - 1):
    tmp = s[0]
    for j in range(len(s) - 1):
        if ((i >> j) & 1):
            tmp += op[0]
        else:
            tmp += op[1]
        tmp += s[j+1]
    ans_ = eval(tmp)
    if ans_ == 7:
        ans = tmp+"=7"
print(ans)


Measured memory_bytes: 3060
#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 ans = 700;
  if(s[0]=='o') ans += 100;
  if(s[1]=='o') ans += 100;
  if(s[2]=='o') ans += 100;
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	var arr []int
	sum:= 0

	for i:=0; i<=N; i++ {
		if i % 3 == 0 || i % 5 == 0 {
			continue
		} else {
			arr = append(arr, i)
		}
	}
	for _,v := range arr {
		sum = sum + v
	}

	fmt.Println(sum)
}

Measured memory_bytes: 15572
#coding:utf-8
def main():
    N,C=map(int,raw_input().split())
    D=[None]
    for _ in range(C):
        D.append([None]+map(int,raw_input().split()))
    c=[]
    for _ in range(N):
        c.append(map(int,raw_input().split()))
    # F[C][mod]
    F=[[0,0,0] for _ in range(31)]
    # m[mod] = [c[mod]]
    m=[[] for i in range(3)]
    for i in range(N):
        for j in range(N):
            m[(i+j)%3].append(c[i][j])

    for mod in range(3):
        for color in range(1,C+1):
            val=0
            for mm in m[mod]:
                F[color][mod]+=D[mm][color]

    ans=1145141919810
    if N==1:
        for c0 in range(1,C+1):
            print(0)
            return

    for c0 in range(1,C+1):
        for c1 in range(1,C+1):
            for c2 in range(1,C+1):
                if c0==c1 or c1==c2 or c2==c0:continue  
                ans=min(ans,F[c0][0]+F[c1][1]+F[c2][2])
    print(ans)





main()






Measured memory_bytes: 6732
#include<stdio.h>
#include<ctype.h>

int main(void)
{
	char s1[100], s2[100], s3[100];
	scanf("%s %s %s", s1, s2, s3);
	s1[0] = toupper(s1[0]);
	s2[0] = toupper(s2[0]);
	s3[0] = toupper(s3[0]);
	printf("%c%c%c\n", s1[0], s2[0], s3[0]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

// C

bool alpha[13];

bool NOT(bool x){
    return !x;
}

bool AND(bool x, bool y){
    return (x && y);
}

bool OR(bool x, bool y){
    return (x || y);
}

bool IMP(bool x, bool y){
    if( x == true && y == false ) return false;
    return true;
}


bool formula(const string& str, int s, int t){ // [s,t)
    int i;

    //cout << "debug : " << str << " , " << s << " , " << t << endl;
    if( s == t ) return false;

    if( t - s == 1 ){ // alpha or T or F
        if( str[s] == 'T' ) return true;
        if( str[s] == 'F' ) return false;
        return alpha[str[s] - 'a'];
    }

    // *,+,->
    int x = 0;
    //string tmp;
    for(i=s; i<t; i++){
        //tmp += str[i];
        if( str[i] == '(' ) x++;
        if( str[i] == ')' ) x--;
        if( x == 0 && (str[i] == '*' || str[i] == '+' ||
                       (i+1<t && str[i] == '-' && str[i+1] == '>')) ){
            
            break;
        }
    }
    //cout << "debug_tmp : " << tmp << endl;

    if( i < t ){ // "*" or "+" or "->"
        if( str[i] == '*' ){
            return AND(formula(str, s, i), formula(str, i+1, t));
        }
        else if( str[i] == '+' ){
            return OR(formula(str, s, i), formula(str, i+1, t));
        }
        else{
            return IMP(formula(str, s, i), formula(str, i+2, t));
        }
    }

    // NOT
    if( str[s] == '-' ){
        //puts("NOT");
        return NOT(formula(str, s+1, t));
    }

    // 単純に括弧があるだけ
    if( str[s] == '(' && str[t-1] == ')' ){
        //cout << "debug2 : " << str << " , " << str.substr(1,str.length()-2) << endl;
        return formula(str, s + 1, t - 1);
    }
    
    exit(-1);
}


bool equation(const string& in){
    int i,j;
    int p = in.find("=");

    for(i=0; i<(1<<11); i++){
        memset(alpha, false, sizeof(alpha));
        for(j=0; j<11; j++){
            if( i & (1<<j) ){
                alpha[j] = true;
            }
        }
        if( formula(in, 0, p) != formula(in, p + 1, in.length()) ){
            return false;
        }
    }
    return true;
}


int main(){
    string in;

    while( cin >> in, in != "#" ){
        cout << (equation(in) ? "YES" : "NO") << endl;
    }

    return 0;
}

Measured memory_bytes: 940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
int main(){
int h,a,cnt;
cin>>h>>a;
while (true)
{
    /* code */
    h=h-a;
    cnt++;
    if (h<=0)
    {
        /* code */
        cout<<cnt<<endl;
        break;

    }
    
}

}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	//0215 start

	private void doit(){
		Scanner sc =new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			ArrayList<ArrayList<Integer>> xlist = new ArrayList<ArrayList<Integer>>();
			ArrayList<ArrayList<Integer>> ylist = new ArrayList<ArrayList<Integer>>();
			for(int i = 0; i <= n; i++){
				int m = sc.nextInt();
				ArrayList<Integer> xl = new ArrayList<Integer>();
				ArrayList<Integer> yl = new ArrayList<Integer>();
				for(int j = 0; j < m; j++){
					int x = sc.nextInt();
					int y = sc.nextInt();
					xl.add(x);
					yl.add(y);
				}
				xlist.add(xl);
				ylist.add(yl);
			}
			for(int i = 1; i < xlist.size(); i++){
				boolean f = match(xlist.get(0), ylist.get(0), xlist.get(i), ylist.get(i));
				Collections.reverse(xlist.get(0));
				Collections.reverse(ylist.get(0));
				f = f || match(xlist.get(0), ylist.get(0), xlist.get(i), ylist.get(i));
				Collections.reverse(xlist.get(0));
				Collections.reverse(ylist.get(0));
				Collections.reverse(xlist.get(i));
				Collections.reverse(ylist.get(i));
				f = f || match(xlist.get(0), ylist.get(0), xlist.get(i), ylist.get(i));
				if(f){
					System.out.println(i);
				}
			}
			System.out.println("+++++");
		}
	}


	private boolean match(ArrayList<Integer> x1,ArrayList<Integer> y1, ArrayList<Integer> x2,ArrayList<Integer> y2) {
		if(x1.size() != x2.size()) return false;
		boolean flg = true;
		for(int i= 1; i < x1.size(); i++){
			int xx = x1.get(i) - x1.get(i-1);
			int yy = y1.get(i) - y1.get(i-1);
			int xxx = x2.get(i) - x2.get(i-1);
			int yyy = y2.get(i) - y2.get(i-1);
			if(xx == xxx && yy == yyy){

			}
			else{
				flg = false;
				break;
			}
		}
		if(flg) return true;

		flg = true;
		for(int i= 1; i < x1.size(); i++){
			int xx = x1.get(i) - x1.get(i-1);
			int yy = y1.get(i) - y1.get(i-1);
			int xxx = x2.get(i) - x2.get(i-1);
			int yyy = y2.get(i) - y2.get(i-1);
			if(xx == -1 * yyy && yy == xxx){

			}
			else{
				flg = false;
				break;
			}
		}
		if(flg) return true;

		flg = true;
		for(int i= 1; i < x1.size(); i++){
			int xx = x1.get(i) - x1.get(i-1);
			int yy = y1.get(i) - y1.get(i-1);
			int xxx = x2.get(i) - x2.get(i-1);
			int yyy = y2.get(i) - y2.get(i-1);
			if(xx == -xxx && yy == -yyy){
			}
			else{
				flg = false;
				break;
			}
		}

		if(flg) return true;

		flg = true;
		for(int i= 1; i < x1.size(); i++){
			int xx = x1.get(i) - x1.get(i-1);
			int yy = y1.get(i) - y1.get(i-1);
			int xxx = x2.get(i) - x2.get(i-1);
			int yyy = y2.get(i) - y2.get(i-1);
			if(xx == yyy && yy == -1 * xxx){

			}
			else{
				flg = false;
				break;
			}
		}
		if(flg) return true;

		return false;
	}


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

Measured memory_bytes: 12000
n,q = map(int,input().split())
s = input()
c = [0]
l = 0
for i in range(1,len(s)):
    if(s[i]=='C' and s[i-1]=='A'):
        l+=1
        c.append(l)
    else:
        c.append(l)
for i in range(q):
    l,r = map(int,input().split())
    print(c[r-1]-c[l-1])


Measured memory_bytes: 6100
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
#define int long long
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k; cin >> n >> k;
	int ans = 0;
	for (int ch = k; ch <= n; ++ch) {
		int low = ch * (ch-1) / 2;
		int hi = n * (n+1) / 2;
		// Remove till n - k - 1
		hi -= (n-ch+1)*(n-ch) / 2;
		// cerr << low << ' ' << hi << '\n';
		if (low <= hi) ans += hi-low+1;
		ans %= MOD;
	}
	ans = (ans + 1) % MOD;
	if (ans < 0) ans += MOD;
	cout << ans;
}

Measured memory_bytes: 3656
#include <stdio.h>

typedef struct {
	int key, id;
} data;

typedef struct {
	data obj[400001];
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = ++(h->size), j = i >> 1;
	data tmp;
	h->obj[i] = x;
	while (j > 0) {
		if (h->obj[i].key < h->obj[j].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j >>= 1;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j <<= 1;
		} else break;
	}
	return output;
}

void add_BIT(int N, int BIT[], int i, int k)
{
	while (i <= N) {
		BIT[i] += k;
		i += (i & -i);
	}
}

int sum_BIT(int BIT[], int r)
{
	int sum = 0;
	while (r > 0) {
		sum += BIT[r];
		r -= (r & -r);
	}
	return sum;
}

int main()
{
	int i, H, W, A, B;
	scanf("%d %d", &H, &W);
	
	int j, k, s[200002], left[200002], right[200002], BIT[200001] = {}, L, R, M, tmp;
	data d;
	min_heap h;
	h.size = 0;
	for (i = 0; i <= W + 1; i++) {
		s[i] = i;
		left[i] = i - 1;
		right[i] = i + 1;
	}
	for (i = 1, d.key = 0; i <= W; i++) {
		d.id = i;
		push(d, &h);
		add_BIT(W, BIT, i, 1);
	}
	for (i = 1; i <= H; i++) {
		scanf("%d %d", &A, &B);
		tmp = sum_BIT(BIT, B);
		if (sum_BIT(BIT, A - 1) == tmp) {
			printf("%d\n", h.obj[1].key + i);
			continue;
		}
		
		if (s[B+1] < 0) {
			if (W - B < B - A) {
				L = B + 2;
				R = W + 1;
				while (L < R) {
					M = (L + R) / 2;
					if (sum_BIT(BIT, M) <= tmp) L = M + 1;
					else R = M;
				}
				L = left[L];
			} else {
				L = A;
				R = B;
				while (L < R) {
					M = (L + R) / 2;
					if (sum_BIT(BIT, M) < tmp) L = M + 1;
					else R = M;
				}
			}
			s[B+1] = s[L];
			left[B+1] = L;
			right[B+1] = right[L];
			left[right[L]] = B + 1;
			
			if (B + 1 <= W) {
				d.key = B + 1 - s[B+1];
				d.id = B + 1;
				push(d, &h);
				add_BIT(W, BIT, B + 1, 1);
			}
		}
		
		for (j = left[B+1]; j >= A; j = left[j]) {
			s[j] = -1;
			add_BIT(W, BIT, j, -1);
		}
		left[B+1] = j;
		right[j] = B + 1;
		
		while (h.size > 0 && s[h.obj[1].id] < h.obj[1].id - h.obj[1].key) pop(&h);
		if (h.size > 0) printf("%d\n", h.obj[1].key + i);
		else break;
	}
	for (; i <= H; i++) printf("-1\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    string s, t; cin >> s >> t;
    ll a, b; cin >> a >> b;
    string u; cin >> u;
    if(s == u) --a;
    else --b;
    cout << a << " " << b << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  int n,a,b;cin>>n>>a>>b;
  int ret = 0;
  for(int i = 1; n >= i; i++){
    string s = to_string(i);
    int sm = 0;
    for(int j = 0; s.size() > j; j++){
      sm += s[j]-'0';
    }
    if(a <= sm && sm <= b)ret += i;
  }
  cout << ret << endl;
}

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

import numpy as np

N = int(readline())

U = 10**6 + 100
div = np.arange(1,U,dtype=np.int64)
div = div[N%div==0]
answer = (div + (N//div)).min() - 2
print(answer)


Measured memory_bytes: 30068
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template<typename T>
struct BinaryIndexedTree{
    vector<T> data;
    int sz;

    BinaryIndexedTree(int n){
        sz = n + 2;
        data.assign(sz, 0);
    }

    void add(int i, T x){
        ++i;
        while(i < sz){
            data[i] += x;
            i += i & -i;
        }
    }

    // [0, i] の区間和
    T sum(int i){
        T res = 0;
        ++i;
        while(i > 0){
            res += data[i];
            i -= i & -i;
        }
        return res;
    }

    // [l, r) の区間和
    T sum(int l, int r){
        return sum(r - 1) - sum(l - 1);
    }

    // val 以上を満たす 0-indexed の位置を返す
    int lower_bound(T val){
        // if(val <= 0)    return -1;
        int res = 0;
        int n = 1;
        while(n < sz)   n <<= 1;
        for(int k = n >> 1; k > 0; k >>= 1){
            if(res + k < sz && data[res + k] < val){
                val -= data[res + k];
                res += k;
            }
        }
        return res;     // 1-indexed であれば、res + 1 を返す
    }
};

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

    int n, q;
    cin >> n >> q;
    vector<int> c(n + 1, 0);
    for(int i = 1; i <= n; ++i) cin >> c[i];
    vector<vector<int>> table(n + 1), idx(n + 1);
    for(int i = 0; i < q; ++i){
        int l, r;
        cin >> l >> r;
        table[r].emplace_back(l);
        idx[r].emplace_back(i);
    }
    vector<int> prev(n + 1, 0);
    BinaryIndexedTree<int> bit(n + 3);
    vector<int> ans(q);
    for(int i = 1; i <= n; ++i){
        if(prev[c[i]] > 0)  bit.add(prev[c[i]], -1);
        bit.add(i, 1);
        prev[c[i]] = i;
        for(int j = 0; j < (int)table[i].size(); ++j){
            ans[idx[i][j]] = bit.sum(table[i][j], i + 1);
        }
    }
    for(int x : ans)    cout << x << '\n';
}

Measured memory_bytes: 52988
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, s[5];
int P[10] = {0,0,0,0,0,0,1,1,1,2};
int Q[10] = {1,1,1,2,2,3,2,2,3,3};
int R[10] = {2,3,4,3,4,4,3,4,4,4};
int main(){
  cin >> n;
  for(int i=0;i<5;i++) s[i] = 0;
  for(int i=0;i<n;i++){
    string str;
    cin >> str;
    if(str[0] == 'M') s[0]++;
    else if(str[0] == 'A') s[1]++;
    else if(str[0] == 'R') s[2]++;
    else if(str[0] == 'C') s[3]++;
    else if(str[0] == 'H') s[4]++;
  }

  ll ans=0;
  for(int i=0;i<10;i++){
    ans += s[P[i]]*s[Q[i]]*s[R[i]];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const ll MOD = 1000000007;
//const long double PI = (acos(-1));
//const long double EPS = 0.0000000001;
int dy[4] = {-1, 0, 1, 0};
int dx[4] = {0, 1, 0, -1};

int n;
vl a;

int main(void) {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	cout.tie(NULL);
	//freopen("in.txt", "r", stdin);
	
	cin >> n;
	a.resize(n);
	ll total = 0;
	rep(i,0,n) {
		cin >> a[i];
		total += a[i];
	}
	ll ret = total;
	ll psum = 0;
	rep(i,0,n) {
		psum += a[i];
		ret = min(ret, abs(total - 2 * psum));
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  string t;
  cin>>t;
  for (int i=0;i<t.size();i++){
    if (t.at(i)=='?'){
      t.at(i)='D';}
 cout<<t.at(i);
  }
  cout<<endl;}

Measured memory_bytes: 3752
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL<<62;
constexpr auto mod = 1000000007;
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; }

int main() {
	int a, b;
	cin >> a >> b;
	if (a < 6)cout << 0 << endl;
	else if (a < 13)cout << b / 2 << endl;
	else cout << b << endl;
}


Measured memory_bytes: 256
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed ios::sync_with_stdio(0);cin.tie(0);
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define all(v)   v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define pi acos(-1)
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>m;
typedef map<char,ll>mc;
typedef set<ll>st;
typedef set<char>sc;
const ll mx = 1e5+123;
int main()
{
    speed;
    ll t,i,j,a,b,d=0,e=0,ans=0;
    cin>>a>>b;
    ll c[a];
    rep(i,a)
        cin>>c[i];
    sort(c,c+a);
    rep(i,b)
        ans+=c[i];
    cout<<ans<<endl;

}


Measured memory_bytes: 3616
#include <iostream>
using namespace std;
int euler_phi(int n)
{
	int ans=n;
	if(n%2==0)
	{
		while(n%2==0)n/=2;
		ans/=2;
	}
	for(int i=3;i*i<=n;i++)
	{
		if(n%i==0)
		{
			while(n%i==0)n/=i;
			ans/=i;
			ans*=i-1;
		}
	}
	if(n>1)
	{
		ans/=n;
		ans*=n-1;
	}
	return ans;
}

int main() {
	int n;cin>>n;
	cout<<euler_phi(n)<<endl;
	return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<set>
typedef long long int ll;
using namespace std;

int main(){
    string str;
    cin >> str;
    int ans1=-1;
    int ans2=-1;
    for(int i=1;i<str.size();i++){
        if(str[i-1]==str[i]){
            ans1=i;
            ans2=i+1;
            break;
        }
        if(i>=2 && str[i-2] == str[i]){
            ans1=i-1;
            ans2=i+1;
            break;
        }
    }
    cout << ans1 << ' ' << ans2 << endl;
    
    return 0;
}

Measured memory_bytes: 512
import math  # noqa
import bisect  # noqa
import queue  # noqa


if __name__ == '__main__':
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    S = sum(A)
    if N - S < 0:
        print(-1)
    else:
        print(N - S)


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll << 60;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

ll n, a, b;
vll h;

bool ok(ll k) {
  ll cnt = 0;
  // cout << "k:" << k << endl;
  REP(i, n) {
    if(h[i] > b * k) cnt += (h[i] - b * k + (a-b) - 1) / (a-b);
  }
  return cnt <= k;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  cin >> n >> a >> b;
  h.resize(n);
  REP(i, n) {
    cin >> h[i];
  }
  if(n == 1) {
    cout << (h[0] + a - 1) / a << endl;
    return 0;
  }

  ll l = -1, r = 1e9+1;
  while(l != r) {
    ll mid = (l + r) / 2;
    if(ok(mid)) r = mid;
    else l = mid+1;
  }

  cout << l << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

template<typename T>
T gcd(T x, T y){
    if (x == 0 || y == 0) {
        return 0;
    }

    while (x != y){
        if (x > y) {
            x -= y;
        }else{
            y -= x;
        }
    }
    return x;
}

// }}}
/* vim:set foldmethod=marker: */

void solve(){
    ll n,m;
    cin >> n >> m;

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

    map<int, int> mp;
    vi sum(n+1);
    sum[0] = 0;
    for (int i = 0; i < n; i++) {
        sum[i+1] = (sum[i] + A[i]) % m;
    }

    ll ans=0;
    for (int i = 0; i < n+1; i++) {
        ans += mp[sum[i]];
        mp[sum[i]]++;
    }

    cout << ans << endl;



    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


// map の key, value を全て抜き出す。
// for (auto itr = mp.begin(); itr != mp.end(); itr++) {
//     cout << "key" << itr->first << " value" << itr->second << endl;
// }

// 文字列の検索
// string s="abc";
// if (s.find('d') == string::npos){
//     cout << "find" << endl;
// }else{
//     cout << "not find" << endl;
// }


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

int main() {
    int a, b;
    cin >> a >> b;
    if (a >= 13)
        cout << b << endl;
    else if (a >= 6 && a <= 12)
        cout << b/2 << endl;
    else
        cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y,z; cin>>x>>y>>z; int tt = 0; int co  = 0;
  if(x == 5) co++;
  else if (x == 7) tt++;
   if(y == 5) co++;
  else if (y == 7) tt++;
   if(z == 5) co++;
  else if (z == 7) tt++;
	if(co == 2 && tt == 1) cout<<"YES"<<"\n";
  else cout<<"NO"<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;



int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  ll a[3010];
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  ll dp[3010][3010];
  for(int i=0;i<N;i++){
    dp[i][i]=0;
  }
  for(int len=1;len<=N;len++){
    for(int i=0;i+len<=N;i++){
      int j=i+len;
      if((N-len)%2==0){
        dp[i][j]=max(dp[i+1][j]+a[i],dp[i][j-1]+a[j-1]);
      }else{
        dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j-1]);
      }
    }
  }
  cout << dp[0][N] << endl;
  return 0;
}


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

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i,l,n) for(int (i)=(int)(l);(i)<(int)(n);(i)++)
#define d_arr(arr, h, w) rep(i,(h) ){ cout << "["; rep(j,(w) ) { cout << (arr)[i][j] << ", "; } cout << "]" << endl;}
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x);

typedef pair<int ,int> P;


int V,d;
int N=1001;

int par[1001];
int height[1001];
int fibo[1001] = {0};

void init(int v)
{
    par[v] = v;
    height[v] = 0;
}
int find(int v)
{
    if(par[v] == v) {return v;}
    else
    {
        return par[v] = find(par[v]);
    }
}
bool same(int a, int b)
{
    return find(a) == find(b);
}

void unite(int a, int b)
{
    if( height[a] > height[b] ) {
        par[find(b)] = find(a);        
    }
    else{
        par[find(a)] = find(b); 
    }
}
int F(int n) {
    if( n == 0 || n == -1 ) { return 1;}
    if( n == 1 ) { return 2;}

    //if( fibo[n-2] == -2 ) { fibo[n-2] = F(n-2) % N; }
    //if( fibo[n-1] == -2 ) { fibo[n-1] = F(n-1) % N; }

    return fibo[n] =  (fibo[n-1] + fibo[n-2]) % N ; 
}
//int F(int n) { return f(n)%N; }

int main()
{
    rep(i,1001) { fibo[i] = -2; }
    fibo[0] = 1;
    fibo[1] = 2;
    while(cin >> V >> d){
        set<int> s;
        repi(i,1,V+1){ init(i); }
        repi(i,1,V){
            repi(j,i+1,V+1)
            {
                if(abs( F(i)-F(j) ) < d) { unite(i,j); }
            }
        }
        repi(i,1,V+1){ 
             s.insert(find(i));
        } 
        cout << s.size() << endl;
    }
}

Measured memory_bytes: 1212
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#define FAST ios::sync_with_stdio(false);
#define pb push_back
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 5;
const int maxn = (int)1e6 + 5;
using namespace std;

char s1[300], s2[300];

int main()
{
	scanf("%s %s", s1, s2);
	int len = strlen(s1);
	for(int i = len; i < len + len; i++){
		s1[i] = s1[i-len];
	}
	for(int i = 0; i < len; i++){
		bool flag = true;
		for(int j = 0; j < len; j++){
			if(s2[j] != s1[j+i]) flag = false;
		}
		if(flag){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

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

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )

using namespace std;

const int inf = (int)1e9 + 7;
const int N = (int)2e6 + 7;

int n;
int x,y,mx,cur;
int pr[N],u[N];
int cn = 0;
vector <int> g[N],vec,ans,res;

void dfs (int v,int p = -1,int d = 1) {
      pr[v] = p;
      if (d > mx) {
            mx = d;
            cur = v;
      }
      for (auto to : g[v]) {
            if (to != p)
                  dfs(to,v,d + 1);
      }
}
main () {
      cin >> n;

      for (int i = 1; i < n; i ++) {
            cin >> x >> y;
            g[x].pb(y);
            g[y].pb(x);
      }
      dfs(1);
      mx = 0;
      dfs(cur);

      while (cur != -1) {
            vec.pb(cur);
            u[cur] = 1;
            cur = pr[cur];
      }
      for (int i = 0; i < vec.size(); i ++) {
            for (auto to : g[vec[i]]) {
                  if (!u[to] && g[to].size() > 1) {
                        puts("-1");
                        return 0;
                  }
            }
      }
      for (int i = 0; i < vec.size(); i ++) {
            int o = cn + 1;
            for (auto to : g[vec[i]]) {
                  if (!u[to])
                        ans.pb(++o);
            }
            ans.pb(++cn);
            cn = o;
      }
      reverse(vec.begin(),vec.end());
      cn = 0;
      for (int i = 0; i < vec.size(); i ++) {
            int o = cn + 1;
            for (auto to : g[vec[i]]) {
                  if (!u[to])
                        res.pb(++o);
            }
            res.pb(++cn);
            cn = o;
      }
      if (ans > res) {
            for (auto to : res)
                  cout << to << " ";
      }
      else {
            for (auto to : ans)
                  cout << to << " ";
      }
}


Measured memory_bytes: 61176
def main2():
    n,x,y = map(int,input().split(" "))
    cnts = [0]*n
    for i in range(n):
        for j in range(i+1,n):
            dis = min(j-i,abs(x-1-i)+1+abs(y-1-j))
            cnts[dis]+=1
    
    for i in range(1,n):
        print(cnts[i])
main2()

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

typedef unsigned int U;
#define L 1<<21
char HA[L], T[256];

int main() {
    U n, s, t;
    char c;
    T['A'] = 4;
    T['C'] = 3;
    T['G'] = 2;
    T['T'] = 1;
    scanf("%d", &n);
    getchar();
    while (n--) {
        s = 0;
        t = 1;
        int flag = ( c = getchar() ) == 'i';
        getchar();
        getchar();
        getchar();
        while ( ( c = getchar() ) != ' ' );
        while ( ( c = T[getchar()] ) != 0 ) {
            s += c * t;
            t *= 4;
        }
        if ( flag ) {
            HA[s] = 1;
        } else {
            puts( HA[s] ? "yes" : "no" );
        }
    }
    return 0;
}

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

#define tt template<typename T> ostream& operator <<(ostream& os, const
#define tuv template<typename U, typename V> ostream& operator<<(ostream& os, const
tt vector<T>& v)            { os << "["; for(auto & x : v) os << " " << x; os << " ]"; return os; }
tt vector<vector<T> >& m)   { for(auto & x : m) { for(auto & y : x) os << y << " "; os << "\n"; } return os; }
tt set<T>& s)               { os << "{"; for(auto & x : s) os << " " << x; os << " }"; return os; }
tt unordered_set<T>& s)     { os << "{"; for(auto & x : s) os << " " << x; os << " }"; return os; }
tt queue<T>& q)             { queue<T> q2(q); while(!q2.empty()) { os << q2.front() << " "; q2.pop(); } return os; }
tt stack<T>& s)             { stack<T> s2(s); while(!s2.empty()) { os << s2.top() << " "; s2.pop(); } return os; }
tuv pair<U,V>& p)           { os << "(" << p.first << "," << p.second << ")"; return os; }
tuv map<U,V>& m)            { os << "{ "; for(auto & x : m) os << x.first << ":" << x.second << " "; os << "}"; return os; }
tuv unordered_map<U,V>& um) { os << "{ "; for(auto & x : um) os << x.first << ":" << x.second << " "; os << "}"; return os; }


int main(int argc, char * argv[])
{
    std::ios_base::sync_with_stdio(false);    
    std::cin.tie(NULL);

    int k, n;
    std::cin >> k >> n;

    std::vector<int> A(n);
    for(int i = 0; i < n; ++i) std::cin >> A[i];

    sort(A.begin(), A.end());

    int smallest = INT_MAX;
    for(int i = 0; i < n-1; ++i)
    {
	// find smallest other-way distance
	int otherway = k - (A[i+1] - A[i]);
	if(otherway < smallest) smallest = otherway;	
    }

    int last_dist = k - (A[0] + (k - A[n-1]));
    if(last_dist < smallest) smallest = last_dist;

    std::cout << smallest << std::endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;




int main(void) {
    ll N, M;
    cin >> N >> M;
    ll i;
    ll a[MAX];
    ll s[MAX];
    Map mp;
    s[0]=0;
    mp[s[0]]++;
    for(i=0; i<N; i++) {
        cin >> a[i];
        s[i+1]=s[i]+a[i];
        mp[s[i+1]%M]++;
    }
    
    ll ans=0;
    for(auto it=mp.begin(); it!=mp.end(); it++) {
        ll t=it->sc;
        ans+=t*(t-1)/2;
    }
    pt(ans);
}



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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

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

template <uint MD> struct ModInt {
    using M = ModInt;
    uint v;
    ModInt() : v(0) {}
    ModInt(ll _v) { set_v(_v % MD + MD); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(ull(v) * r.v % MD); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<TEN(9) + 7>;

const int MF = TEN(6) + TEN(5);
V<Mint> fact(MF + 1), iFac(MF + 1);
void first() {
    fact[0] = 1;
    for (int i = 1; i <= MF; i++) fact[i] = fact[i-1] * Mint(i);
    iFac[MF] = fact[MF].inv();
    for (int i = MF; i >= 1; i--) iFac[i-1] = iFac[i] * Mint(i);
    assert((fact[114] * iFac[114]).v == 1);
}

Mint C(int n, int k) {
    if (n < k || n < 0) return Mint(0);
    return fact[n] * iFac[k] * iFac[n - k];
}

const int MN = 21;
int n;
int g[MN][MN];
Mint dp[MN][1<<MN];
bool vis[MN][1<<MN];
Mint solve(int p, int f) {
    if (p == n) return Mint(1);
    if (vis[p][f]) return dp[p][f];
    vis[p][f] = true;
    Mint sm = 0;
    for (int a = 0; a < n; a++) {
        if (f & (1<<a)) continue;
        if (!g[p][a]) continue;
        sm += solve(p + 1, f | (1<<a));
    }
    return dp[p][f] = sm;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> g[i][j];
        }
    }

    cout << solve(0, 0) << endl;

    return 0;
}


Measured memory_bytes: 221824
while True:
  n = int(input())
  if not n:
    break
  m = int(input())
  edge = [[0 for i in range(n + 1)] for j in range(n + 1)]
  for i in range(m):
    a,b = map(int,input().split())
    edge[a][b] = 1
    edge[b][a] = 1
  friends1 = [i for i in range(n + 1) if edge[1][i]]
  friends2 = []
  for friend in friends1:
    friends_lst = [i for i in range(n + 1) if edge[friend][i]]
    friends2.extend(friends_lst)
  ans = len(set(friends1 + friends2))
  if ans:
    ans -= 1
  print(ans)



Measured memory_bytes: 8056
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<ctime>
const long long MOD = 1000003;

long long fac[MOD + 10];
long long ifac[MOD + 10];
long long inv[MOD + 10];

long long exp(int x, int k) {
    if(k == 0) return 1;
    long long tmp = exp(x, k/2);
    if(k % 2 == 1) return x * tmp % MOD * tmp % MOD;
    return tmp * tmp % MOD;
}

long long solve(int x, int d, int n) {
    if (d == 0) return exp(x, n);

    // pre-check
    long long v = MOD - x;
    long long tt = v * inv[d] % MOD;
    if (tt < n) return 0;

    long long xd = (long long)x * inv[d] % MOD;
    long long tp = (xd + n - 1) % MOD;
    long long bt = ((xd - 1) % MOD + MOD) % MOD;
    return fac[tp] * ifac[bt] % MOD * exp(d, n) % MOD;
}

long long brute(int x, int d, int n) {
    long long tmp = 1;
    long long nn = x;
    while(n--) {
        tmp *= nn;
        tmp %= MOD;
        nn += d;
    }
    return tmp;
}

void test() {
    int cnt = 100;
    while(cnt--) {
        int x, d, n;
        x = rand() % MOD;
        d = rand() % MOD;
        n = rand() % 1000000000 + 1;
        long long a = solve(x, d, n);
        long long b = brute(x, d, n);
        if(a != b) {
            printf("::%d %d %d || %lld %lld\n", x, d, n, a, b);
        }
    }
}

int main() {
    srand(time(0));

    fac[0] = 1;
    ifac[0] = 1;
    for(int i = 1 ; i < MOD ; i++) {
        fac[i] = fac[i-1] * i % MOD;
        ifac[i] = exp(fac[i], MOD-2);
        inv[i] = exp(i, MOD-2);
    }

    int T;
    scanf("%d", &T);
    while(T--) {
        int n, m, k;
        scanf("%d %d %d", &n, &m, &k);
        printf("%lld\n", (solve(n, m, k) % MOD + MOD) % MOD);
    }

    // test();

    return 0;
}

Measured memory_bytes: 24192
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		long[] ary = new long[87];
		ary[0] = 2;
		ary[1] = 1;
		
		for ( int i = 2; i < n+1; i++ ) {
			ary[i] = ary[i-1] + ary[i-2];
		}
	
		System.out.print(ary[n]);
		
	}
}

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

using namespace std;

typedef long long int lli;

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

    int a, b, c;

    cin >> a >> b >> c;

    cout << max(c-(a-b), 0) << endl;

    return 0;
}


Measured memory_bytes: 256
import math

N = int(input())
list_1 = []
for i in range(N):
    list_1.append(list(map(int, input().split())))

m = 0
for list_i in list_1:
    for list_j in list_1:
        if list_i != list_j:
            d = math.sqrt((list_j[0]-list_i[0])**2 + (list_j[1]-list_i[1])**2)
            m += d

average = m / N
print(average)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();
		long buff=0,c=0,d=0;

		buff = a-k;
		if(buff<0) {
			c=b+buff;
			if(c<0) {
				c=0;
			}
			System.out.println(0+" "+c);
		}else {
			System.out.println(buff+" "+b);
		}

	}
}




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

int main(){
  while(1){
    int n;
    cin>>n;
    if(n==0)break;
    vector<int> a(n);
    for(int i=0;i<n;i++){
      string s;
      cin>>s;
      a[i]=s.size();
      //cout<<a[i]<<endl;
    }
    int ok=0;
    for(int i=0;i<n;i++){
      if(ok==1)break;
      int sum=0;
      int sta=0;
      int j=i;
      while(1){
        //cout<<sta<<" "<<sum<<endl;
        if(sta==0||sta==2){
          if(sum+a[j]==5){
            sta++;
            sum=0;
          }else{
            sum+=a[j];
            if(sum>5)break;
          }
        }else{
          if(sum+a[j]==7){
            sta++;
            if(sta==5){
              cout<<i+1<<endl;
              ok=1;
              break;
            }
            sum=0;
          }else{
            sum+=a[j];
            if(sum>7)break;
          }
        }
        j++;
      }
    }
  }
}

Measured memory_bytes: 3192
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <unordered_set>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; ++i)

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

const int GCM(const int a, const int b)
{
	if (b == 0) return a;
	if (a < b) return GCM(b, a);
	return GCM(b, a % b);
}

int main()
{
	int N, K; cin >> N >> K;
	vector<int> balls(N); REP(i, N) cin >> balls[i];
	int max = *max_element(balls.begin(), balls.end());
	if (max < K)
	{
		cout << "IMPOSSIBLE\n";
	}
	else
	{
		int gcm = balls[0];
		REP(i, N) gcm = GCM(gcm, balls[i]);
		cout << (K % gcm == 0 ? "POSSIBLE\n" : "IMPOSSIBLE\n");
	}
}

Measured memory_bytes: 3760
using System;
using System.Linq;
class A{
  static void Main(){
    var sum = 0;
    var s = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse).OrderBy(x => x).ToArray();
    for (int i = 0; i < s.Count() - 1; i++)
      sum += s[i + 1] - s[i];
    Console.Write(sum);
  }
}

Measured memory_bytes: 13396
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
	long long n,sum=0,min,bmin;
	scanf("%d",&n);
	long long *a=new long long [n];
	long long *b=new long long [n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
		b[i]=sum;
	}
	min=abs(2*b[0]-sum);
	for(int i=1;i<n-1;i++)
	{
		bmin=abs(2*b[i]-sum);
		if(bmin<min)
		{
			min=bmin;
		}
	 } 
	 cout<<min;
	 return 0;
}

Measured memory_bytes: 3328
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

#define NMAX 500010

struct QUARR{
    int l;
    int r;
    int index;
    int type;
    int ans;
    bool operator<(QUARR q) const{
        if(type==1){
            if(q.r==r) return q.l>l;
            return q.r>r;
        }
        else{
            return q.index>index;
        }
    }
};

int ft_bit[NMAX];
void ft_add(int a,int w,int N){
    for(int x=a;x<=N;x+=x&-x){
        ft_bit[x]+=w;
    }
}

int ft_sum(int a){
    int ret=0;
    for(int x=a;x>0;x-=x&-x){
        ret+=ft_bit[x];
    }
    return ret;
}

signed main(){
    QUARR qu[NMAX];
    int last[NMAX];
    int c[NMAX];
    int N,Q;

    cin>>N>>Q;
    for(int i=1;i<=N;i++){
        cin>>c[i];
        last[i]=-1;
    }

    for(int i=1;i<=Q;i++){
        int l,r;
        cin>>l>>r;
        qu[i].l=l;
        qu[i].r=r;
        qu[i].index=i;
        qu[i].type=1;
        qu[i].ans=0;
    }

    sort(qu+1,qu+Q+1);

    for(int i=1;i<=qu[1].r;i++){
        if(last[c[i]]==-1){
            ft_add(i,1,N);
            last[c[i]]=i;
        }
        else{
            ft_add(last[c[i]],-1,N);
            ft_add(i,1,N);
            last[c[i]]=i;
        }
    }

    qu[1].ans=ft_sum(qu[1].r)-ft_sum(qu[1].l-1);
    qu[1].type=2;
    for(int i=2;i<=Q;i++){
        for(int j=qu[i-1].r+1;j<=qu[i].r;j++){
            if(last[c[j]]==-1){
                ft_add(j,1,N);
                last[c[j]]=j;
            }
            else{
                ft_add(last[c[j]],-1,N);
                ft_add(j,1,N);
                last[c[j]]=j;
            }
        }
        qu[i].ans=ft_sum(qu[i].r)-ft_sum(qu[i].l-1);
        qu[i].type=2;
    }

    sort(qu+1,qu+Q+1);

    for(int i=1;i<=Q;i++){
        cout<<qu[i].ans<<endl;
    }
}


Measured memory_bytes: 35012