akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

const int INF = 1e9;
const int MOD = 1e9+7;

int f(const vector<int>& a, int b){
    int x = 0;
    rep(i, (int)a.size()){
        x += abs(a[i] - (b+i+1));
    }
    return x;
}

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

    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }

    int l = -INF;
    int r = INF;
    while(r - l > 1){
        int m = (r + l) / 2;
        int x1 = f(a, m);
        int x2 = f(a, m - 1);
        if(x1 - x2 >= 0){
            r = m;
        }else{
            l = m;
        }
    }
    int ans = f(a, l);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(a * n, b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<cstdlib>
using namespace std;

int main() {
  int a, b, c, ans = 3;
  cin >> a >> b >> c;
  if(a == b) ans--;
  if(a == c) ans--;
  if(b == c) ans--;
  if(!ans) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
def dfs(fld, check, n, m, depth)
  ok = true
  n.times do |r|
    m.times do |c|
      if check[r][c] == depth && fld[r][c] == '*'
        q = []
        mem = n.times.map{ [] }
        check[r][c] = depth + 1
        cnt = 1
        q << [r, c]
        mem[r] << c
        until q.empty?
          r, c = q.shift
          (-1..1).each do |yy|
            (-1..1).each do |xx|
              next if yy == 0 && xx == 0
              y = r + yy; x = c + xx
              if check[y][x] != depth + 1 && fld[y][x] == '*'
                check[y][x] = depth + 1
                cnt += 1
                q << [y, x]
                mem[y] << x
              end
            end
          end
        end
        mem.each_with_index do |m, i|
          if m.size == 2
            m[0], m[1] = m[1], m[0] if m[0] > m[1]
            (m[0]+1...m[1]).each{ |k| check[i][k] = depth + 2 }
            cnt += m[1] - m[0] - 1
          end
        end
        $ret[cnt] ||= 0
        $ret[cnt] += 1
        ok = false
      end
    end
  end
  return true if ok
  return true if dfs(fld, check, n, m, depth + 2)
end

l = false
while n = gets.to_i
  break if n == 0
  if l
    10.times{ print '-' }
    puts
  end
  l = true
  fld = n.times.map{ gets.chomp.split('').unshift(' ').push(' ') }
  m = fld.map{ |f| f.size }.max
  fld.each{ |f| (m - f.size).times{ f.push(' ') } }
  fld = [ [' '] * m, *fld, [' '] * m ]
  $ret = {}
  check = (n+2).times.map{ [0] * m }
  dfs(fld, check, n+2, m, 0)
  $ret.sort.each{ |k, v| puts "#{k} #{v}" }
end

Measured memory_bytes: 10188
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int N;
int key(int a, int b) {
	if (a > b) { swap(a, b); }
	return a * N + b;
}

int main() {
	cin >> N;
	vector<vector<int>> a(N, vector<int>(N));
	vector<vector<int>> g(N*N);
	vector<int> indeg(N*N, 0);
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N - 1; ++j) {
			cin >> a[i][j];
			--a[i][j];
		}
		for (int j = 0; j + 1 < N - 1; ++j) {
			int u = key(i, a[i][j]);
			int v = key(i, a[i][j + 1]);
			g[u].push_back(v);
			++indeg[v];
		}
	}

	deque<int> que;
	vector<int> cost(N*N, -1);
	for (int i = 0; i < N*N; ++i) {
		if (indeg[i] > 0) { continue; }
		que.push_back(i);
		cost[i] = 1;
	}
	
	while (!que.empty()) {
		int u = que.front(); que.pop_front();
		for (auto v : g[u]) {
			cost[v] = max(cost[v], cost[u] + 1);
			--indeg[v];
			if (indeg[v] == 0) { que.push_back(v); }
		}
	}
	for (auto v : indeg) {
		if (v > 0) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << *max_element(cost.begin(), cost.end()) << endl;

	return 0;
}


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

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}

int main() {
double pi = 3.1415;
ll N;
cin>>N;
cout<<2*N*pi<<endl;

}

Measured memory_bytes: 3788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		FastScanner in= new FastScanner(System.in);
		PrintWriter out= new PrintWriter(System.out);
		
		int n= in.nextInt();
		int k= in.nextInt();
		
		int [] a= new int[n];
		int [] f= new int[(int) 3e5];
		
		for (int i = 0; i < a.length; i++) {
			a[i]= in.nextInt();
			f[a[i]]++;
		}
		Arrays.sort(f);
		int d=0;
		for (int i = 0; i < f.length; i++) {
			if(f[i]!=0) d++;
		}
		int res=0;
		for (int i = 0; i < f.length; i++) {
			if(d<=k) {
				break;
			}
			if(f[i]!=0) {
				res+= f[i];
				d--;
			}
		}
		System.out.println(res);
	}
	static class p{
		int x;
		int y;
		public p(int a, int b) {
			x=a;
			y=b;
		}
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

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

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}
/*
4 6
1 1 1
1 3 1
4 2 1
4 3 1
2 4 1
2 3 1
*/

Measured memory_bytes: 45836
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<int,int>;

int main(){

  string A, B;
  cin >> A >> B;

  if(A.size() > B.size()){
    cout << "GREATER" << endl;
    return 0;
  } else if (A.size() < B.size()){
    cout << "LESS" << endl;
    return 0;
  }

  // for (int i = 0; i < A.size(); i++) {
  //   if(A[i] > B[i]){
  //     cout << "GREATER" << endl;
  //     return 0;
  //   } else if (A[i] < B[i]){
  //     cout << "LESS" << endl;
  //     return 0;
  //   }
  // }

  if(A > B){
    cout << "GREATER" << endl;
    return 0;
  } else if (A < B){
    cout << "LESS" << endl;
    return 0;
  }

  cout << "EQUAL" << endl;
  return 0;

}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
// #include <utility>
// #include <queue>
#include <algorithm>
// #include <unordered_map>
#include <unordered_set>

using namespace std;

int main() {
  unordered_set<string> sset;
  int N, L;
  vector<string> pairs;
  cin >> N >> L;
  for (int i = 0; i < N; ++i) {
    string s;
    cin >> s;
    string srev(s);
    reverse(srev.begin(), srev.end());
    auto srev_it = sset.find(srev);
    if (srev_it != sset.end()) {
      sset.erase(srev_it);
      if (s.compare(srev) < 0) {
        pairs.emplace_back(s);
      } else {
        pairs.emplace_back(srev);
      }
    } else {
      sset.emplace(s);
    }
  }
  sort(pairs.begin(), pairs.end());
  vector<string> svec;
  for (string s : sset) {
    svec.emplace_back(s);
  }
  sort(svec.begin(), svec.end());
  string center = "";
  for (string s : svec) {
    string srev(s);
    reverse(srev.begin(), srev.end());
    if (s == srev) {
      center = s;
      break;
    }
  }
  for (string s : pairs) {
    cout << s;
  }
  cout << center;
  reverse(pairs.begin(), pairs.end());
  for (string s : pairs) {
    reverse(s.begin(), s.end());
    cout << s;
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3308
/*
???????????????????¨??????§??????????????°??????????????????
*/
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
const int LEN=100; //???????????§??????

class stack {
	int data[LEN]; 
	int top;
public:
	stack(): top(0){};
	void push(int);
	int pop();
	bool isEmpty();
	bool isFull();
};
void stack::push(int num){
	if( isFull() )
		return;
	
	data[top]=num;
	top++;
}
int stack::pop(){
	if( isEmpty() )
		return 0;

	top--;
	return data[top];
}
bool stack::isEmpty(){
	return top==0;
}
bool stack::isFull(){
	return	top==LEN;
}




int main(){

	
	stack s;

	char oper[110];

	int a, b; 

	while( scanf("%s", &oper) !=EOF ) {



		
		switch( oper[0] ){
			case '+':
				a=s.pop();
				b=s.pop();
				s.push( b+a );
				break;

			case '-':
				a=s.pop();
				b=s.pop();
				s.push( b-a );
				break;
				
			case '*':
				a=s.pop();
				b=s.pop();
				s.push( b*a );
				break;

			default:
				s.push(atoi(oper));
		}


			

		

	}

	cout<<s.pop()<<endl;



	

}

Measured memory_bytes: 1164
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node
{
  int key;
  struct node *next;
  struct node *prev;
};


typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key)
{
  NodePointer x;

  x = nil->next;

  while((x != nil) && (x->key != key))
    { 
      x = x->next;
    }
  return x;

}

void init()
{
  nil = malloc(sizeof(struct node));

  nil->next = nil;
  nil->prev = nil;
}

void printList()
{
  NodePointer cur = nil->next;
  int isf = 1;

  while(1)
  {
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t)
{
  if ((t->next->prev == nil) || (t->prev->next == nil)) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
}

void deleteFirst()
{
  NodePointer t = nil->next;
  if(t == nil) return;
  deleteNode(t);
}

void deleteLast()
{
  NodePointer t = nil->prev;
  if(t == nil) return;
  deleteNode(t);
}

void delete(int key)
{
  deleteNode(listSearch(key));
}


void insert(int key)
{
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;

}

int main()
{
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;

  scanf("%d", &n);
  init();

  for ( i = 0; i < n; i++ )
  {
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' )
    {
        insert(key); 
        np++; 
        size++;
    }
    else if ( com[0] == 'd' ) 
        {
          if (strlen(com) > 6)
          {
	       if ( com[6] == 'F' ) deleteFirst();
	       else if ( com[6] == 'L' ) deleteLast();
          }
      else 
      {
	   delete(key); nd++; 
      }
      size--;
        }
  }

  printList();

  return 0;

}



Measured memory_bytes: 36096
def resolve():
    import numpy as np
    import sys

    readline = sys.stdin.readline    # 1行だけ文字列にする

    H, W, K = map(int, readline().split())
    c = [list(readline().strip()) for _ in [0] * H]

    # matrixは文字列#とそれ以外でなる時，#を1に，それ以外を0にする
    c = np.array([[1 if c[i][j] == "#" else 0
                 for j in range(W)]
                 for i in range(H)], dtype=np.int64)

    ans = 0
    
    for bit_i in range(1 << H):
        lst_y = []
        for i in range(H):
            if bit_i & (1 << i):
                lst_y.append(i)
        for bit_j in range(1 << W):
            lst_x = []
            for j in range(W):
                if bit_j & (1 << j):
                    lst_x.append(j)
            fig = c[:]
            fig = np.delete(fig, lst_y, axis=0)
            fig = np.delete(fig, lst_x, axis=1)
            if np.count_nonzero(fig == 1) == K:
                ans += 1
    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 26820
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		int x;
		cin >> x;
		int ok = x/100;
		for (int i=0 ; i<=ok ; i++)
		{
			int y = x-100*i;
			if(i>=0 && y<=5*i) 
			{
				cout << 1 << endl; 
				return 0;
			}
		}
		cout << 0 << endl;
		return 0;  
}  


Measured memory_bytes: 3664
#include<stdio.h>
#define N 101
#define BLACK 2
#define GRAY 1
#define WHITE 0
int dfs(int);
int n,a[N][N],color[N],z,b[N],c[N];
int main(){
  int i,j,k,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      a[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    i++;
    i--;
    i++;
    scanf("%d%d",&i,&k);
    i--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      a[i][v]=1;
    }
  }
  z=0;
  for(i=0;i<n;i++)color[i]=WHITE;
  for(i=0;i<n;i++){
    if(color[i]==WHITE)dfs(i);
  }
  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,b[i],c[i]);
  }
  return 0;
}

int dfs(int i){
  int j;
 
  
  color[i]=GRAY;
   z++;
  b[i]=z;
  for(j=0;j<n;j++){
    if(a[i][j]==0)continue;
    else if(color[j]==WHITE)dfs(j);
  }
  color[i]=BLACK;
  z++;
  c[i]=z;
  
}




Measured memory_bytes: 2036
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
















template <typename T>
class Bellmanford {
private:
    struct edge {
        int to;
        T cost;
    };
    int n;
    vector<vector<edge>> g;
    vector<T> dist;
    
public:
    Bellmanford(int n) : n(n), g(n), dist(n, INF){}
    
    void add_edge(int v1, int v2, T cost){
        g[v1].push_back({ v2, cost });
    }
    
    // 負の閉路があるときfalseを返す
    bool run(int s){
        dist[s] = 0;    //開始点の距離は0
        
        for (int i = 0; i < 2 * n; i++) {
            for (int v = 0; v < n; v++) {
                for (auto& e : g[v]) {
                    if (dist[v] != INF && dist[e.to] > dist[v] + e.cost) {
                        dist[e.to] = dist[v] + e.cost;
                        if (i >= n - 1) {
                            // return false;
                            dist[e.to] = -INF;
                        }
                    }
                }
            }
        }
        return true;
    }
    
    T get_distance(int v){
        return dist[v];
    }
};


int main(){
    ll n, m, p;
    cin >> n >> m >> p;
    Bellmanford<ll> bell(n);
    REP(i, m){
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        bell.add_edge(a, b, -(c - p));
    }
    bell.run(0);
    ll ans = -bell.get_distance(n - 1);
    cout << ((ans < INF)? max(ans, 0LL) : -1) << endl;
}

Measured memory_bytes: 512
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

function compareFunc(a, b){
    return a-b;
}

const s: string[] = input[0].split('').sort();

if(s[0] === s[1] && s[1] !== s[2] && s[2] === s[3]){
    console.log('Yes');
}else{
    console.log('No');
}






Measured memory_bytes: 7372
#include<stdio.h>
#include<vector>
#include<algorithm>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
vector< pair<ll,ll> > block;
pair<ll,ll> p;
ll temp,tmp,r,f,a,b,c,n,m,k,ans,result,res,cnt[100000],factorial[1000005],fw[1000000];
ll inc(ll x){
	return x*x%MOD;
}
ll MI(ll x,ll y){
	if(y==0) return 1;
	else if(y%2==0) return inc(MI(x,y>>1));
	else return inc(MI(x,y>>1))*x%MOD;
}
ll C(ll x,ll y){
	if(x>y) return 0;
	return factorial[y]*fw[x]%MOD*fw[y-x]%MOD;
}
int main(){
	scanf("%lld %lld %lld", &n,&m,&k);
	for(ll i=1;i<=k;i++){
		scanf("%lld %lld", &p.first,&p.second);
		block.push_back(p);
	}
	factorial[0]=1;
	for(ll i=1;i<=200010;i++){
		factorial[i]=((factorial[i-1]%MOD)*i)%MOD;
	}
	for(ll i=0;i<=200010;i++){
		fw[i]=MI(factorial[i],MOD-2);
	}
	sort(block.begin(),block.end());
	ans=C(n-1,n+m-2);
	for(ll i=0;i<block.size();i++){
		result=C(n-block[i].first,n+m-block[i].first-block[i].second);
		res=C(block[i].first-1,block[i].first+block[i].second-2);
		for(ll j=0;j<i;j++){
			if(block[j].second<=block[i].second){
				res-=(cnt[j]*C(block[i].first-block[j].first,block[i].first+block[i].second-block[j].first-block[j].second)+MOD)%MOD;
			}
		}
		res=(res+MOD*MOD)%MOD;
		cnt[i]=res;
		ans=(ans-result*cnt[i]+MOD*MOD)%MOD;
	}
	printf("%lld", (ans+MOD*MOD)%MOD);
}


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

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

  bool res = false;
  for(int i=0; i<S.size(); i++){
    for(int j=0; j<S.size()-i; j++){
      string s(S);
      s.erase(i,j);
      if(s=="keyence"){ res=true; break; }
    }

  }  
  if(res){ cout << "YES" << endl; }
  else{ cout << "NO" << endl; }
}


Measured memory_bytes: 256
N = gets.to_i
As = gets.split.map(&:to_i)

mx = ->(a, b){a > b ? a : b}
es, os = [0], [0]
As.each_with_index do |a, i|
  if i.even?
    es << es.last + a
    os << os.last
  else
    es << es.last
    os << os.last + a
  end
end
esl, osl = es.last, os.last
if N.even?
  puts osl + 0.step(N, 2).map{|i| -os[i] + es[i]}.max
else
  x, ans = 0, es[-2]
  1.step(N, 2) do |i|
    ans = mx[ans, esl - es[i] + os[i] + x]
    x = mx[x, es[i + 1] - os[i +1]] if i < N
  end
  puts ans
end

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

int main() {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (S[i] == T[i]) {
      ans += 1;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static Scanner sc;

    public Main() {
    }

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        new Main().solve();

    }

    private void solve() {
        int a = sc.nextInt();
        int b = sc.nextInt();

        int ans = a + b;

        if (ans < 10) {
            System.out.println(ans);
        } else {
            System.out.println("error");
        }
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
using namespace std;
long long mod=1e9+7;
struct all{
	vector<long long> kai,gya,nck;
	all(long long n){
		kai.resize(n+1);
		gya.resize(n+1);
		nck.resize(n+1);
	}
	long long pow(long long x,long long n){
		long long ret=1;
		if(n>0){
			ret=pow(x,n/2);
			if(n%2==0){
				(ret=(ret*ret))%=mod;
			}else{
				(ret=((ret*ret)%mod)*x)%=mod;
			}
		}
		return ret;
	}
	long long inv(long long n){
		return pow(n,mod-2);
	}
	vector<long long> cul(long long n){
		kai[n]=n;
		for(int i=n-1;i>0;i--){
			(kai[i]=kai[i+1]*i)%=mod;
		}
		gya[1]=inv(1);
		for(int i=2;i<=n;i++){
			(gya[i]=gya[i-1]*inv(i))%=mod;
		}
		for(int i=1;i<=n;i++){
			(nck[i]=kai[n+1-i]*gya[i])%=mod;
		}
		nck[0]=1;
		nck[n]=1;
		return nck;
	}
};
int main(){
	long long n,k;
	cin>>n>>k;
	if(k>=n-1){
		all nii(2*n-1);
		vector<long long> hoge=nii.cul(2*n-1);
		cout<<hoge[n]<<endl;
	}else{
		long long ans=0;
		all nii(n);
		all mii(n-1);
		vector<long long> hogen=nii.cul(n);
		vector<long long> hogenn=mii.cul(n-1);
		for(int i=0;i<=k;i++){
			(ans+=(hogen[i]*hogenn[i]))%=mod;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

typedef long long ll;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    int n;
    cin>>n;
    
    pair<int,int>p;
    
    vector<pair<int,int> > v;
    
    for(int i=0;i<n;i++)
    {
    	cin>>p.second>>p.first;
    	v.push_back(p);
    }
    
    sort(v.begin(),v.end());
    
    int deadline=0;
    
    for(int i=0;i<n;i++)
    {
    	deadline+=v[i].second;
    	
    	if(deadline>v[i].first) return cout<<"No",0;
    }
    
    cout<<"Yes";
    	
        
    return 0;

}

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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

long long INF = 10000000000;

long long f(long long n){
  int ret = 0;
  while(n != 0) ret++, n /= 10;
  return ret;
}

int main() {

  long long N;
  cin>>N;

  vector<long long> v;
  for(long long  i = 1; i*i <= N; i++){
    if(N % i == 0) v.push_back(i);
  }

  long long ans = INF;
  REP(i,0,v.size()){
    ans = min( ans, f( max(v[i], N/v[i])) );
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;

public class Main
{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int x = in.nextInt();
		if (x>=30)
		{
		    System.out.println("Yes");
		}
		else
		{
		    System.out.println("No");
		}
	}
}

Measured memory_bytes: 35620
#include<bits/stdc++.h>
using namespace std;
#define int long long int

int fun(vector<int>&weight, vector<int>&value, int capacity) {
    int n = weight.size();
    
    vector<vector<int> > dp(n + 1, vector<int>(capacity + 1, 0));        
    
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= capacity; j++) {
            int include = 0;
            int exclude = 0;
            
            if(weight[i-1] <= j)
                include = dp[i-1][j-weight[i-1]] + value[i-1];
            exclude = dp[i-1][j];
            
            dp[i][j] = max(include, exclude);
        }
    }
    
    return dp[n][capacity];
}

int32_t main() {
    int n, w;
    cin >> n >> w;
    
    vector<int> weight(n), value(n);
    
    for(int i = 0; i < n; i++)
        cin >> weight[i] >> value[i];
    
    cout << fun(weight, value, w);
    return 0;
}

Measured memory_bytes: 83192
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int k,x,i;
	cin>>k>>x;
	for(i=x-k+1;i<k+x-1;i++)
		cout<<i<<' ';
	cout<<i<<'\n';
}


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

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

  int ans = 0;
  for ( int i = 0; i < s.size(); i++ ) {
    if ( s[i] == t[i] ) { ans++; }
  }

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


Measured memory_bytes: 3552
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
int main(){
    int n,d; cin >> n >> d;
    int q=1; int num=0;
    while(q <= n){
        q += 2*d+1;
        num++;
    }
    cout << num;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $n);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));

$cnt = 0;
for ($i = 0; $i < $n; ++$i) {
    $a = $A[$i];

    while ($a > 0) {
        if ($a % 2 == 0) {
            ++$cnt;
            $a /= 2;
        } else {
            break;
        }
    }
}

echo $cnt, PHP_EOL;


Measured memory_bytes: 6776
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll N, A, B; cin >> N >> A >> B;
    N %= 12;
    for(int i=1; i<=N; i++) {
        if(i % 2 == 1) A = A - B;
        else B = A + B;
    }
    printf("%lld %lld\n", A, B);
    return 0;
}



Measured memory_bytes: 3228
def main():
    N = int(input())
    S = input()
    cnt = 0
    for i in range(N):
        for j in range(i + 1, N):
            k = 2 * j - i
            if k >= N:
                continue
            if S[j] != S[i] and S[i] != S[k] and S[k] != S[j]:
                cnt += 1
    print(S.count("R") * S.count("B") * S.count("G") - cnt)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9124
import java.util.Scanner;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] nums = new int[3];
    String result;
    for (int cnt = 0; cnt < 3; cnt++) {
      nums[cnt] = sc.nextInt();
    }
    Arrays.sort(nums);
    result = (nums[0] == 5 && nums[1] == 5 && nums[2] == 7) ? "YES" : "NO";
    System.out.println(result);
    sc.close();
  }
}

Measured memory_bytes: 35796
text=input()
string=input()


#common_length[i]は、探索列がstring[i]で探索を終了したときに、
# string[i-common_lneght[i] + 1] 〜string[i]で構成される文字列が、探索価値を持つことを示す



len_string=len(string)
common_length=[0]*len_string
tmp=0
tmp_tmp=0
for i in range(1,len_string):
    if(string[i]==string[tmp]):
        tmp_tmp=tmp
        while(string[i]==string[tmp_tmp] and tmp_tmp >0):
            tmp_tmp=common_length[max([tmp_tmp-1,0])]
        common_length[i-1]=tmp_tmp
        tmp+=1
    else:
        common_length[i-1]=tmp
        while(string[i]!=string[tmp] and tmp>0):
            tmp=common_length[max([tmp-1,0])]
        if(string[i]==string[tmp]):
            tmp+=1

if(string[-1]==string[tmp-1]):
    common_length[-1]=tmp
common_length[0]=0


tmp=0

for i in range(len(text)):
    if(text[i]!=string[tmp]):
        while(text[i]!=string[tmp] and tmp>0):
            tmp=common_length[max([tmp-1,0])]
        if(text[i]==string[tmp]):
            tmp+=1
    else:
        tmp+=1
        if(tmp==len_string):
            print(i-tmp+1)
            tmp=common_length[-1]


Measured memory_bytes: 8372
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
  int n,k;
  cin >> n >> k;
  
  int result = 0;
  for (int i = 0; i < n; i++) {
    int h;
    cin >> h;
    if (h>=k) { result++; }
  }
  
  cout << result << endl;
}


Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<cctype>
using i64=long long;
const int N=200007;
int p[N],fa[N],vis[N];
struct node{int a,b,id;}a[N],t;
int operator<(const node&a,const node&b){return 1ll*a.a*b.b<1ll*a.b*b.a;}
int read(){int x=0,c=getchar();while(isspace(c))c=getchar();while(isdigit(c))(x*=10)+=c&15,c=getchar();return x;}
int find(int x){return x==fa[x]? x:fa[x]=find(fa[x]);}
std::priority_queue<node>q;
int main()
{
    int n=read();i64 ans=0;vis[1]=1;
    for(int i=2;i<=n;++i) p[i]=read();
    for(int i=1,x;i<=n;++i) x=read(),q.push(a[fa[i]=i]={!x,x,i});
    for(int x,y;q.size();)
	if(x=(t=q.top()).id,q.pop(),!vis[x]&&t.a==a[x].a&&t.b==a[x].b)
	    vis[x]=1,y=find(p[x]),ans+=1ll*a[y].b*t.a,fa[x]=y,a[y].a+=t.a,a[y].b+=t.b,q.push(a[y]);
    printf("%lld",ans);
}


Measured memory_bytes: 9076
//わからなかったので解説を見た
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <math.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n1,n2) for(int i=n1;i<n2;i++)
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    if(n<1000){
        cout << "ABC" << endl;
    }else{
        cout << "ABD" << endl;
    }
    /*vector<pair<int,int>> pair1(n);
    vector<pair<int,int>> pair2(n);
    REP(i,n){
        int a,b;
        cin >> a >> b;
        pair1[i] = make_pair(a,b);
    }
    REP(i,n){
        int c,d;
        cin >> c >> d;
        pair2[i] = make_pair(c,d);
    }
    
    sort(pair1.begin(),pair1.end());
    sort(pair2.begin(),pair2.end());
    REP(i, n){
        cout << pair1[i].first << pair1[i].second <<endl;
    }
    int maxn = -1;
    int cand = -1;
    REP(i,n){
        REP(j,n){
            if(pair1[i].first<pair2[j].first){
                if(pair1[i].second>maxn){
                    cand = i;
                }
            }
        }
    }
    /*REP(i, n){
     cout << pairs[i].first << pairs[i].second <<endl;
     }
     /*int n;
     int res = 100000;
     cin >> n;
     //vector<int> x(n);
     REP2(i,1,n/2+1){
     res = min(res,psum(i)+psum(n-i));
     if(psum(i)+psum(n-i)==1){
     cout << "i:" << i <<endl;
     }
     }
     cout << res << endl;*/
    return 0;
}



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

int main() {
  int N, Y;
  cin >> N >> Y;
  rep(i, N + 1) rep(j, N + 1 - i) {
    int k = N - i - j;
    int yen = 10000 * i + 5000 * j + 1000 * k;
    if(yen == Y) {
      cout << i << ' ' << j << ' ' << k << endl;
      return 0;
    }
  }
  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 384
n,m=map(int,input().split())
list=[]
for i in range(m):
    a,b=map(int,input().split())
    list.append([max(a,b),min(a,b)])
list.sort()
a=1
b=0
k=0
while list!=[]:
    j=list[0]
    if k>j[1]:
        list.remove(j)
    elif j[0]<a:
        list.remove(j)
    else:
        list.remove(j)
        b+=1
        a=j[0]+1
        k=j[0]
print(b)

Measured memory_bytes: 21884
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int n = sc.nextInt();
        if (n == 0) {
            System.out.println(0);
            return;
        }
        StringBuilder sb = new StringBuilder();
        while (n != 0) {
            if (n % 2 == 0) {
                sb.insert(0, 0);
                n /= -2;
            } else {
                sb.insert(0, 1);
                n = (n - 1) / -2;
            }
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 23252
#include<iostream>
#include<bits/stdc++.h>
#include<vector>
using namespace std;
#define fo(i,b,n) for(int i=b;i<n;i++)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sll(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define endl "\n"
#define PI 3.1415926535897932384626
const int mod = 1000000007;
/*===========================================================================*/


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin>>s;
  int ans = 0;
  fo(i,0,s.length()){
    if(s[i] == '+') ans++;
    else ans--;
    // cout<<s[i];
  }
  cout<<ans;





  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
const int SIZE=5+3*1e5;
const int INF=10+1e9;

int main(){
	int A,B;
	cin >> A >> B;
	A+=11;
	B+=11;
	A%=13;
	B%=13;
	if(A==B) cout << "Draw" << endl;
	else if(B>A) cout << "Bob" << endl;
	else cout << "Alice" << endl; 


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const ll MOD = 1e9 + 7;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

ll modpow(ll a, ll n) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return ret;
}

ll modinv(ll a) { return modpow(a, MOD - 2); }

ll comb(ll n, ll r) {
    ll ret = 1;
    for (ll i = 0; i < r; i++) ret = ret * (n - i) % MOD;
    for (ll i = 1; i <= r; i++) ret = ret * modinv(i) % MOD;
    return ret;
}

int main(){

    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = modpow(2, n);
    ans -= 1;
    if (ans < 0) ans += MOD;
    ans -= comb(n, a);
    if (ans < 0) ans += MOD;
    ans -= comb(n, b);
    if (ans < 0) ans += MOD;

    cout << ans;

}

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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

vi g[252525];
ll num[252525];
ll ans[252525];
bool used[252525];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, Q, a, b, p[252525], x[252525];
	cin>>n>>Q;
	REP(i, n-1){
		cin>>a>>b;
		--a;--b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	REP(i, Q){
		cin>>p[i]>>x[i];
		--p[i];
		num[p[i]]+=x[i];
	}
	queue<pll> q;
	q.push(pll(0ll, 0ll));
	used[0]=true;
	while(q.size()){
		pll y=q.front();
		q.pop();
		ans[y.first]=y.second+num[y.first];
		for(auto &z : g[y.first]){
			if(used[z]){
				continue;
			}
			used[z]=true;
			q.push(pll(z, ans[y.first]));
		}
	}
	REP(i, n){
		cout<<ans[i]<<" \n"[i==n-1];
	}
	return 0;
}


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

long long n, k, a[100005] = {0}, b[100005] = {0}, t = 0;
long long memo[35] = {0};

long long solve();

int main() {
  cin >> n >> k;
  for(long long i = 0; i < n; ++i) cin >> a[i] >> b[i];
  memo[0] = 1;
  for(long long i = 1; i < 32; ++i)
    memo[i] = 2 * memo[i - 1];
  while(memo[t] <= k) ++t;
  t = max(t - 1, 0LL);
  cout << solve() << endl;
  return 0;
}

// decided x ~ t
long long solve() {
  long long ans = 0, now = 0;
  for(long long x = t; x >= 0; --x) {
    now = 0;
    for(long long i = 0; i < n; ++i)
      if((k | a[i]) == k) now += b[i];
    ans = max(ans, now);
    now = 0;
    for(long long i = 0; i < n; ++i) {
      if(k >= memo[x] && memo[x] > a[i])
        now += b[i];
      else if(k >= memo[x] && a[i] >= memo[x])
        a[i] -= memo[x];
    }
    if(k >= memo[x]) k -= memo[x];
    ans = max(ans, now);
  }
  return ans;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
    int N, B, beforeB;
    int ans = 0;
    cin >> N;
    cin >> B;
    beforeB = B;
    ans += 2 * B;
    for (int i = 0; i < N - 2; i++) {
        cin >> B;
        if (B >= beforeB) {
            ans += B;
        } else {
            ans -= beforeB;
            ans += 2 * B;
        }
        beforeB = B;
    }
    cout << ans;
}


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

bool Find(const std::string& S, const std::string& t) {
  uint32_t s = 0;
  for (uint32_t i = 0; i < S.size(); i++) {
    if (S[i] == t[s]) {
      if (s++ == 2) {
        return true;
      }
    }
  }

  return false;
}

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

  uint32_t N;
  std::string S;

  std::cin >> N >> S;

  uint32_t f = 0;
  for (uint32_t i = 0; i < 1000; i++) {
    if (i < 10) {
      f += Find(S, std::string("00") + std::to_string(i))? 1: 0;
    } else if (i < 100) {
      f += Find(S, std::string("0") + std::to_string(i))? 1: 0;
    } else {
      f += Find(S, std::to_string(i))? 1: 0;
    }
  }

  std::cout << f << std::endl;

  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main(){
	double mauntain[50];
	int j=0;
	double n;
	double max_height = 0.0;
	double min_height = 1000000.0;
	while(cin >> n){
		mauntain[j] = n;
		j++;
	}

	for(int i=0;i<j;i++){
		if(max_height < mauntain[i])max_height = mauntain[i];
	}

	for(int i=0;i<j;i++){
		if(min_height > mauntain[i])min_height = mauntain[i];
	}

	cout << max_height - min_height << endl;
}

Measured memory_bytes: 3208
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[1000010];

//最小公倍数、最大公約数
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}

int lcm(int a,int b){
	return a/gcd(a,b)*b;
}

vector<int> dec2(int n){
	set<int> u;
	int a=2;
	while(n>=a*a){
		if(n%a==0){
			u.insert(a);
			n/=a;
		}
		else{
			a++;
		}
	}
	u.insert(n);
	vector<int> v(u.begin(),u.end());
	return v;
}

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	int G=A[0];
	for(int i=1;i<N;i++){
		G=gcd(G,A[i]);
	}
	if(G!=1){
		cout<<"not coprime"<<endl;
	}
	else{
		set<int> U;
		REP(i,N){
			if(A[i]==1)continue;
			vector<int> v=dec2(A[i]);
			DEB(v.size())END
			REP(j,v.size()){
				if(U.find(v[j])!=U.end()){
					cout<<"setwise coprime"<<endl;
					return 0;
				}
				else{
					U.insert(v[j]);
				}
			}
		}
		cout<<"pairwise coprime"<<endl;
	}
	return 0;
}


Measured memory_bytes: 11420
def calc_power(x,y):
    count = 0
    while(x%y==0):
        x=x/y
        count = count + 1
    return count


n  = input()
li = list(map(int,input().split()))
count = 0
for i in li:
    count = count + calc_power(i,2)
print (count)


Measured memory_bytes: 4148
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VMM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.ByteString.Char8 as B
import qualified Data.Set as S
import System.IO.Unsafe
import Debug.Trace

uread :: VU.Unbox a => Int -> VM.IOVector a -> a    
uread i v = unsafePerformIO $ VM.read v i

uwrite :: VU.Unbox a => Int -> a -> VM.IOVector a -> VM.IOVector a
uwrite i a v = unsafePerformIO $ VM.write v i a >> return v

umodify :: VU.Unbox a => Int -> (a -> a) -> VM.IOVector a -> VM.IOVector a
umodify i f v = unsafePerformIO $ VM.modify v f i >> return v

uthaw :: VU.Unbox a => VU.Vector a -> VM.IOVector a
uthaw = unsafePerformIO . VU.thaw

ufreeze :: VU.Unbox a => VM.IOVector a -> VU.Vector a
ufreeze = unsafePerformIO . VU.freeze

dijkstra
  :: Int  -- ^ nodes
  -> (Int -> VU.Vector (Int, Double))  -- ^ edges from i-th node: (end, cost)
  -> Int  -- ^ start node
  -> VU.Vector Double  -- ^ constructed graph
dijkstra n edges s =
  ufreeze $ snd $ fix (\f (nodes,costs) -> case S.minView nodes of
    Nothing -> (S.empty,costs)
    Just ((c,n), nodes) ->
      if c <= uread n costs
        then
          let es = edges n in
            f $ VU.foldl' (\(ns,cs) (e,ec) ->
              let c' = c + ec in if c' < uread e costs
                then (S.insert (c',e) ns, uwrite e c' cs)
                else (ns,cs)
              ) (nodes,costs) es
        else f (nodes,costs)) (nodes0,costs0)
  where
    costs0 :: VM.IOVector Double
    costs0 = uwrite s 0 (uthaw $ VU.replicate n $ fromIntegral (maxBound :: Int))

    nodes0 :: S.Set (Double,Int)
    nodes0 = S.singleton (0,s)

solve :: Int -> Int -> Int -> Int -> Int -> VU.Vector (Int,Int,Int) -> Double
solve xs ys xt yt n xyr = graph VU.! (n+1)
  where
    -- VU.filter (\(x,y,r) -> dist2 (xs,ys) (x,y) <= distMax) xyr
    dist2 (x1,y1) (x2,y2) = (x1-x2)^2 + (y1-y2)^2

    dist2C :: (Int,Int,Int) -> (Int,Int,Int) -> Double
    dist2C (x1,y1,r1) (x2,y2,r2) = (sqrt (fromIntegral $ (x1-x2)^2 + (y1-y2)^2) - fromIntegral (r1+r2)) `max` 0

    distMax = dist2 (xs,ys) (xt,yt)

    toIndex (i,j) = i * (n+2) + j

    distMemo = ufreeze $ foldl' (\acc (i,j) ->
      let c1 = if i == n then (xs,ys,0) else if i == n+1 then (xt,yt,0) else xyr VU.! i
          c2 = if j == n then (xs,ys,0) else if j == n+1 then (xt,yt,0) else xyr VU.! j in
        uwrite (toIndex (i,j)) (dist2C c1 c2) acc
      ) (uthaw $ VU.replicate ((n+2)*(n+2)) 0.0) [(i,j) | i <- [0..n+1], j <- [0..n+1], i /= j]
    graph = dijkstra (n+2) (\e -> VU.map (\i -> (i, distMemo VU.! toIndex (i,e))) $ VU.fromList [0..n+1]) n

main = do
  let readInt = fmap (second B.tail) . B.readInt

  (xs,ys,xt,yt) <- (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2, vec VU.! 3)) . VU.unfoldrN 4 readInt <$> B.getLine
  n <- (\vec -> (vec VU.! 0)) . VU.unfoldrN 1 readInt <$> B.getLine
  xyr <- VU.replicateM n $ (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2)) . VU.unfoldrN 3 readInt <$> B.getLine
  print $ solve xs ys xt yt n xyr


Measured memory_bytes: 89468
#include <iostream>
#include <stdint.h>

using namespace std;

int32_t main()
{
  int32_t K, S;
  cin >> K >> S;

  uint32_t count = 0;
  for (int32_t i = 0; i <= K; i++) {
    for (int32_t j = 0; j <= K; j++) {
      if ((0 <= (S - i - j)) && ((S - i - j) <= K)) {
        count++;
      }
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        heights: [i32; n],
    }
    let mut minimum_costs = vec![0; n];
    minimum_costs[0] = 0;
    for i in 1..=(n - 1) {
        let mut min = std::i32::MAX;
        for j in 1..=k {
            if (i as i32 - j as i32) < 0 {
                continue;
            }

            min = i32::min(
                min,
                minimum_costs[i - j] + (heights[i - j] - heights[i]).abs(),
            )
        }
        minimum_costs[i] = min;
    }
    println!("{}", minimum_costs[n - 1])
}


Measured memory_bytes: 3324
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
bool visi[N];
vector<int>adj[N];
int dis[N];
void dfs(int s)
{
   visi[s]=1;
for(int i=0;i<adj[s].size();i++)
{
if(visi[adj[s][i]]==0)
dfs(adj[s][i]);
dis[s]=max(dis[s],dis[adj[s][i]]+1);
}
}
int  main()
{
  int n,m;
cin>>n>>m;
for(int i=0;i<m;i++)
{
int x,y;
cin>>x>>y;
adj[x].push_back(y);
}
for(int i=1;i<=n;i++)
if(visi[i]==0)
dfs(i);
int ma=0;
for(int i=1;i<=n;i++)
ma=max(dis[i],ma);
cout<<ma<<endl;
}


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

  int N,K,t,sum = 0;
  cin >> N >> K;
  
  for (int i = 0;i < N;++i){
    cin >> t;
    int dist1,dist2;
    dist1 = std::abs(K-t);
    dist2 = std::abs(t);
    if (dist1 < dist2)
      sum += dist1;
    else
      sum += dist2;
  }
  cout << sum*2 << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <cmath>
#include <random>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define MK make_pair
#define PB push_back
#define MSI map<string,int>
#define VI vector<int>
#define VII vector<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define W1 while(1);
const int MOD = 1000000007;
int main()
{
	int a, b, c;
	int n5=0, n7=0;
	cin >> a;
	if (a == 5)n5++;
	if (a == 7)n7++;
	cin >> b;
	if (b == 5)n5++;
	if (b == 7)n7++;
	cin >> c;
	if (c == 5)n5++;
	if (c == 7)n7++;
	n5==2&&n7==1? cout << "YES" << endl : cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int rate = sc.nextInt();
        int deduction = sc.nextInt();
        int ans = sc.nextInt();
        for( int i = 0; i < 10; i++){
            ans = ans*rate - deduction;
            System.out.println(ans);
        }
    
    }
}


Measured memory_bytes: 22740
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
cnt = [0]*n
ans = 0
for i in range(100000):
  j = i%n
  if a[j]<n:
    continue
  x = a[j]//n
  y = a[j]%n
  a[j] = y
  ans += x
  for k in range(n):
    if j == k:
      continue
    a[k] += x
print(ans)


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

int main(){
    int n , k;
    cin >> n >> k;
    int64 now=1;
    int64 ans=0;
    rep(i ,n){
        if(now*2>=now+k) now+=k;
        else now*=2;
    }
    cout << now << endl;
}

Measured memory_bytes: 256