akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  int n,k;
  cin >> n >> k;
  vector<ll>v(n);
  rep(i,n)cin >> v[i];
  ll tmp = 1;
  rep(i,k)tmp *= v[i];
  ll mae = 0,usi = k;
  REP(i,k,n){
    if(v[mae] < v[usi])cout << "Yes" << endl;
    else cout << "No" << endl;
    mae++,usi++;
  }
  return 0;
}


Measured memory_bytes: 4844
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n;
		int m;
		
		n = Integer.parseInt(scanner.next());
		m = Integer.parseInt(scanner.next());
		
		int a = m * 1900 + (n - m) * 100;
		int b = (int)Math.pow(2, m);
		
		System.out.println(a * b);
		
	}

}


Measured memory_bytes: 23764
N, K=map(int, input().split())
A=list(map(int, input().split()))

x=0
y=max(A)

def f(l):
  nums=0
  for a in A:
    if a%l==0:
      nums+=a//l-1
    else:
      nums+=a//l
  if nums>K:
    return False
  else:
    return True

while y-x>1:
  tmp=(x+y)//2
  if f(tmp)==True:
    y=tmp
  else:
    x=tmp
    
print(y)

Measured memory_bytes: 93932
#include <stdio.h>

int main(){
  int a,b,rem,tmp;
  scanf("%d%d",&a,&b);
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  while(b!=0){
    rem = a%b;
    a = b;
    b = rem;
  }
  printf("%d\n",a);

  return 0;
}



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

using namespace std;

int cnt[6000][6000];
int n, k, x, y;
char c;
int main(){
	cin >> n >> k;
	for(int i = 0;i < n;i++){
		cin >> x >> y >> c;
		if(c == 'B')y += k;
		x %= 2*k;
		y %= 2*k;
		for(int i = 0;i < 4;i++){
			for(int j = 0;j < 4;j++){
				if((i+j)%2==1)continue;
				cnt[x+i*k][y+j*k]++;
				cnt[x+i*k+k][y+j*k]--;
				cnt[x+i*k][y+j*k+k]--;
				cnt[x+i*k+k][y+j*k+k]++;
			}
		}
	}

	for(int i = 0;i < 6000;i++)
		for(int j = 1;j < 6000;j++)
			cnt[i][j] += cnt[i][j-1];

	for(int i = 1;i < 6000;i++)
		for(int j = 0;j < 6000;j++)
			cnt[i][j] += cnt[i-1][j];

	int res = 0;
	for(int i = 0;i < 6000;i++)
		for(int j = 0;j < 6000;j++)
			res = max(res, cnt[i][j]);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 140928
#include <stdio.h>

int main()
{
	int N, K;
	char S[100001];
	scanf("%d %d", &N, &K);
	scanf("%s", S);
	
	int i, count = 0;
	for (i = 0; S[i+1] != 0; i++) if (S[i] == S[i+1]) count++;
	if (K * 2 >= i - count) printf("%d\n", i);
	else printf("%d\n", count + K * 2);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define min(a, b) ((a)>(b) ? (b) : (a))

int main(){
  char s[100005];  scanf("%s", s);
  int red = 0, blue = 0;
  for(int i=0; i<strlen(s); i++)
    if(s[i] == '0')  red++;
    else  blue++;
  printf("%d\n", min(red, blue)*2);
  return 0;
}


Measured memory_bytes: 256
//Moh_K_Imar .......
//26/08/2020  ... 3,41.
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    string a,b;
    cin>>a>>b;
    ll counter=0;
    for(ll i=0;i<a.size();i++){
        if(a[i]==b[i])counter++;
    }
    cout<<counter<<endl;

    return 0;
}



Measured memory_bytes: 3572
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef long double ld;
int main()
{
    int r,d,x2000,val,ans;
    cin>>r>>d>>x2000;
    val = r*x2000 - d;
    cout<<val<<endl;
    for(int i=0;i<9;i++)
    {
        ans = r*val - d;
        val = ans;
        cout<<ans<<endl;
    }
}


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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;
#define ll  long long
#define PI  acos(-1)
#define pb  push_back
#define ins insert
#define INF 5000000000000000007 //1e18+7
#define mk  make_pair
#define ff  first
#define ss  second
#define endl "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a) (ll)a.size()
#define double long double
#define coud(a,b) cout << fixed << setprecision((b)) << (a)
#define mset(x,y)  memset(x,y,sizeof(x))
#define all(x)   (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bp(n)  __builtin_popcountll(n)
#define mxt(a)  *(max_element(a.begin(),a.end()))
#define mnt(a)  *(min_element(a.begin(),a.end()))
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define trav(a, x)    for(auto &a : x)

const double eps=1e-7;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int d8x[8]={+1, +1, +1, 0, 0, -1, -1, -1};
int d8y[8]={+1, 0, -1, +1, -1, +1, 0, -1};
int d4x[4]={1, 0, 0, -1};
int d4y[4]={0, -1, 1, 0};
ll power(ll x,ll y){ll ans=1;x=x;while(y>0){if(y&1)ans=(ans*x);y=y>>1;x=(x*x);}return ans;}
ll sqr(ll x) { return x * x;}

template <typename T> T gcd(T a,T b){ if(a==0) return b; return gcd(b%a,a); }
template <class T> inline void chmax(T &x,T y){ x = max((x), (y));}
template <class T> inline void chmin(T &x,T y){ x = min((x), (y));}
template <class T> T abs(T x) { return x>0 ? x : -x;}
template <typename T> T powm(T a,T b, ll m){T cnt=1; while(b>0) { if(b%2==1) cnt=(cnt*a)%m; b/=2; a=(a*a)%m; }return cnt%m;}
typedef pair<int,int>  pii;
typedef pair<ll,ll>  pll;
typedef vector<pll>  vpll;
typedef vector<pii>  vpii;
typedef vector<ll>   vll;
typedef vector<int>  vii;
#define minpq priority_queue<T,vector<T>,greater<T> >;
// #define T int
// #define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
//*X.find_by_order(k) returns the kth largest element (0-based).
//X.order_of_key(val) returns the no. of values less than val.
ll ncr(ll n,ll r) {ll ans=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){ans*=(n-i);ans/=(i+1);}return ans;}
const int MOD = 1000000007;   
const int N = 100010;

void run() {
  string s;
  cin >> s;
  int rem = 0;
  for(int i=0; i<sz(s); ++i) {
    rem += s[i]- '0';
    rem %= 9;
  }
  if(rem) cout << "No";
  else cout << "Yes";
}

int32_t main() {
  cin.sync_with_stdio(0);cin.tie(0);
  cin.exceptions(cin.failbit);
  int tc=1;
  //cin >> tc;
  for (int i=1; i<=tc; ++i) {
    run();
  }
  return 0; 
}
/* 
    stuff you shoulds look for
    * int overflow,array bounds.
    * special cases (n=1?).
    * N,MOD value.
*/

Measured memory_bytes: 3800
def main():
    n = int(input())
    m = [list(map(int, input().split())) for _ in range(n)]

    ans = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            d = m[i][j]
            for k in range(n):
                if k in (i, j):
                    continue
                t = m[i][k] + m[k][j]
                if t < d:
                    print(-1)
                    exit()
                if t == d:
                    break
            else:
                ans += d
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long double pi = acos(-1);
void start(){
std::ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
}
int main(){
   start();
    int n;
    cin>>n;
    vector<pair<double,double>>c(n);
    for(pair<double,double> &p :c )cin>>p.first>>p.second;
    sort(c.begin(),c.end());
   long double sum = 0 ;
    do{
        double area;
        for(int i=0;i<n-1;i++){
        area=sqrt(((c[i].first)-(c[i+1].first))*((c[i].first)-(c[i+1].first))+((c[i].second)-c[i+1].second)*((c[i].second)-c[i+1].second));
        sum+=area;
        }
    }
    while(next_permutation(c.begin(),c.end()));
    long double t = tgamma(n+1);
    cout<<fixed<<setprecision(9)<<sum / t<<endl;
    return 0 ;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>

using namespace std;

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

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

int w, h;
int c[50][50], d[50][50];

bool rec(int i, int j) {
  if (!c[i][j] || d[i][j])
    return false;
  d[i][j] = true;
  for (int y = -1; y <= 1; y++)
    for (int x = -1; x <= 1; x++)
      if ((x || y) && 0 <= i+y && i+y < h && 0 <= j+x && j+x < w)
        rec(i+y, j+x);
  return true;
};

signed main() {
  for (;;) {
    w = rint();
    h = rint();
    if (!w && !h)
      return 0;
    dotimes(i, h)
      dotimes(j, w) {
        c[i][j] = rint();
        d[i][j] = 0;
      }
    int r = 0;
    dotimes(i, h)
      dotimes(j, w)
        if (rec(i, j))
          r++;
    printf("%lld\n", r);
  }
}



Measured memory_bytes: 2724
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}


int main(){
    int N; cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; i++) cin >> d[i];
    int M; cin >> M;
    vector<int> t(M);
    for(int i = 0; i < M; i++) cin >> t[i];

    sort(d.begin(), d.end());
    sort(t.begin(), t.end());

    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(d[i] == t[cnt]) cnt++;
        
        if(cnt == M){
            cout << "YES" << endl;
            return 0;
        }
    }
    
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 4736
#include <cstdio>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;
using Data = pair<LL, vector<LL>>;

int main() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<LL> a(X), b(Y), c(Z);
    rep(i, X) {
        cin >> a[i];
    }
    rep(i, Y) {
        cin >> b[i];
    }
    rep(i, Z) {
        cin >> c[i];
    }
    sort(a.begin(), a.end(), greater<LL>());
    sort(b.begin(), b.end(), greater<LL>());
    sort(c.begin(), c.end(), greater<LL>());
    vector<LL> ab;
    rep(i, X) {
        rep(j, Y) {
            ab.push_back(a[i] + b[j]);
        }
    }
    sort(ab.begin(), ab.end(), greater<LL>());
    ab.resize(K);

    vector<LL> abc;
    rep(i, ab.size()) {
        rep(j, Z) {
            abc.push_back(ab[i] + c[j]);
        }
    }
    sort(abc.begin(), abc.end(), greater<LL>());

    rep(i, K) {
        cout << abc[i] << endl;
    }
    return 0;
}


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

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


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

void WF(ll N,  vector<vector<ll>> &g) {
	repn(k, N) {
		repn(i, N) {
			repn(j, N) {
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}
}


int main() {

    string S;
    cin >>S;
    bool x[26]={};

    rep(i,S.size()){
        x[S[i]-'a']=1;

    }

    

    rep(i,26){
        if(x[i]==0){char a='a'+i; cout <<a; break;}
        if(i==25){cout <<"None";}
    }


 
	

}


Measured memory_bytes: 512
n=int(input())
a=[0]*n
b=list(map(int,input().split()))
for i in range(n):
  if i==0:a[i]=b[i]
  elif i==n-1:a[i]=b[i-1]
  else:a[i]=min(b[i],b[i-1])
print(sum(a))

Measured memory_bytes: 3188
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;
#define PI = 3.14159265358979323846
/*------------------------------------------------------------------------------*/

int main(){
  int N, S;

  cin >> N >> S;

  S /= 1000;

  REP(i, 0, N+1){
    int tmp = S - i;
    REP(j, 0, N-i+1){
      if(tmp == (j * 10 + (N-i-j) * 5)){
        cout << j << " " << N-i-j << " " << i << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;

  return 0;
}


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

using namespace std;

const int MAXN = 100005;

typedef long long llint;

llint a, b, c, d, e, f, g;

llint ff (llint x, llint y, llint z) {
    return x/2*2 + y/2*2 + z/2*2;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> a >> b >> c >> d >> e >> f >> g;
    cout << max(ff(a, d, e), (a > 0 && d > 0 && e > 0 ? ff(a-1, d-1, e-1) + 3 : 0LL)) + b;
    return 0;
}


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

#define rp(i, k, n) for (ll i = k; i < n; i++)
#define ll  long long

ll mod = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    if (n == 1) {
        printf("Hello World");
        return 0;
    } else {
        int a, b;
        cin >> a >> b;
        cout << a + b;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
    int n,m;
    cin >> n>> m;
    VI x(m);
    VI y(m);
    rep(i,m){
        cin >> x.at(i) >> y.at(i);
    }
    map<int ,int > box;
    rep(i,n){
        box[i+1]=1;
    }
    set< int >  chk;
    chk.insert(1);
    rep(i,m){
        box.at(x.at(i))--;
        box.at(y.at(i))++;
        if(chk.count(x.at(i))){
            chk.insert(y.at(i));
            if(box.at(x.at(i))==0){
                chk.erase(x.at(i));
            }
           
        }

    }
    int ans=chk.size();
    cout << ans << endl;
}

Measured memory_bytes: 10368
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include"bits/stdc++.h"
using namespace std ;
#define ll unsigned long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define bug(x) cerr<< #x << '=' <<x <<endl ;

int n;
int main() {
   IOS
    cin >> n ;
     cout << n + (n*n) + (n*n*n) << endl;









}


Measured memory_bytes: 3664
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
M = lines[0][1]
Inf = 10 ** 10

price_num = []
for i in 1..N do
  price_num[i-1] = lines[i][0] * Inf + lines[i][1]
end
price_num.sort!

num_drink = 0
sum_price = 0
i = 1
while num_drink < M do
  price = price_num[i-1] / Inf
  num = price_num[i-1] % Inf
  if M - num_drink > num then
    num_drink += num
    sum_price += price * num
  else
    sum_price += price * (M - num_drink)
    num_drink += M - num_drink
  end
  i += 1
end
puts sum_price

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

int f(int n){
 if(n % 2 == 0) return n / 2;
  else return 3 * n + 1;
}

int main(void){
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N);
  vector<int> y(M);
  for(int i = 0; i < N; i++){
    cin >> x[i];
  }
  for(int j = 0; j < M; j++){
    cin >> y[j];
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  if(max(x[N - 1], X) + 1 <= min(y[0], Y)) cout << "No War";
  else cout << "War";
  
  return 0;
}

Measured memory_bytes: 256
//c problem
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+10;
const int mod=1e9+7;
ll n,m,a,b;
ll quick(ll a,ll b){
	ll res=1,t=a;
	while(b){
		if(b&1)res=(res*t)%mod;
		t=(t*t)%mod;
		b>>=1;
	}
	return res;
}
ll jie[N],inv[N];
void chu(){
	jie[0]=inv[0]=1;
	for(int i=1;i<N;i++)jie[i]=(jie[i-1]*i)%mod,inv[i]=quick(jie[i],mod-2);
}
ll c(ll a,ll b){
	return ((jie[b]*inv[a])%mod*inv[b-a])%mod;
}
int main()
{
	chu(); 
	ll a,b,n,m;
	cin>>n>>m>>a>>b; 
	ll ans=0;
	for(int i=1;i<=n-a;i++){
		ll ans1=c(b-1,b+i-2); 
		ll ans2=c(m-b-1,n-i+m-b-1);
		ans=(ans+ans1*ans2)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6784
n = int(input())
a_list = list(map(int, input().split()))
alice = 0
bob = 0

a_list.sort(reverse = True)
for i in range(0, n, 2):
    alice += a_list[i]
for i in range(1, n, 2):
    bob += a_list[i]
print(alice - bob)

Measured memory_bytes: 3060
package main

// Solution for https://atcoder.jp/contests/abc074/tasks/abc074_b

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var n, k int
	con.Scan(&n, &k)
	c := 0
	for i := 0; i < n; i++ {
		var x int
		con.Scan(&x)
		d := k - x
		if d < 0 {
			d = -d
		}
		if x < d {
			d = x
		}
		c += d + d
	}
	con.Println(c)
	return nil
}


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

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

int aray[10004], gcdForw[10004], gcdBack[10004];

int qpow(int base, int expo) {
	if(expo == 0) return 1;
	if(expo == 1) return base;
	ll v = qpow(base, expo>>1);
	v = (v * v % MOD);
	if(expo&1) v = (v * base % MOD);
	return v;
}

int modinv(ll val) {
	return qpow(val%MOD, MOD-2);
}

int mx[1000006];

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int N; cin >> N;
	ll lcm = 1;
	rep(i, N) {
		cin >> aray[i];
		int x = aray[i];
		for(int v=2; v*v<=x; v++) {
			if(x%v) continue;
			int cur = 0;
			while(x%v == 0) {
				cur++;
				x /= v;
			}
			mx[v] = max(mx[v], cur);
		}
		if(x != 1) mx[x] = max(mx[x], 1);
	}
	rep(i, 1000006) {
		if(mx[i]) lcm = (lcm * qpow(i, mx[i])) % MOD;
	}
	ll su = 0;
	rep(i, N) su = (su + lcm * modinv(aray[i])) % MOD;
	cout << su << endl;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<stdlib.h>
//#include<string.h>
//#include<algorithm>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)

#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pLL pair<long long,long long>
#define pDB pair<double,double>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
//#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
#define popcountL __builtin_popcountll
#define popcount __builtin_popcount
/// int other=mask^((1<<n)-1);
typedef long long ll;
typedef long long int lln;
typedef pair<int,int> pii;
ll INF=1<<28;
//typedef long long lld;
const double PI=acos(-1.0);
//int fx[]={1,-1,0,0}; //direction array
//int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
int knight[8][2]={1,2,1,-2,2,1,2,-1,-1,2,-1,-2,-2,1,-2,-1};
const long double EPS=1e-7;
//#define INF 10000

//struct compare
//{
//  bool operator()(const int& l, const int& r)
//  {
//      return l>r;
//  }
//};

/////////////////////////////////////template sesh/////////////////////////////////////////////////////
///code goes from here
const int mx=200100;
const ll MAXX=10000000000000000;
ll arr[mx];
ll dp[mx][3];
int n,e;
ll fun(int pos,int extra)
{
    if(pos>=n)
    {
        return 0;
    }
    int total=pos-(e-extra);
    int neya=total/2;
    if(neya==(n/2))
        return 0;
    ll &ret=dp[pos][extra];
    if(ret!=-1)
        return ret;
    ret=-MAXX;
    ret=arr[pos]+fun(pos+2,extra);
    if(extra)
    {
        ret=max(ret,fun(pos+1,extra-1));
    }
    return ret;

}

int main()
{
    mem(dp,-1);
    sf(n);
    for(int i=0;i<n;i++)
        sl(arr[i]);
    ll ans=0;
    if(n%2)
        e=2;
    else
        e=1;

    ans=fun(0,e);
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 14712
#include <stdio.h>

static const int MAXNUMOFINPUT = 100;

int selectionSort(int A[], int N);
int printArray(int A[], int N);

int main()
{
    int i;
    int N;
    int A[MAXNUMOFINPUT];
    int cnt = 0;

    scanf("%d", &N);
    for (i = 0; i < N; i++)
    {
        scanf("%d", &A[i]);
    }

    cnt = selectionSort(A, N);
    printArray(A, N);
    printf("%d\n", cnt);

    return 0;
}

int selectionSort(int A[], int N)
{
    int i, j;
    int minj;
    int tmp;
    int cnt = 0;

    for (i = 0; i < N - 1; i++)
    {
        minj = i;

        for (j = i; j < N; j++)
        {
            if(A[j] < A[minj])
            {
                minj = j;
            }
        }

        tmp = A[i];
        A[i] = A[minj];
        A[minj] = tmp;

        if (i != minj)
        {
            cnt++;
        }
    }

    return cnt;
}

int printArray(int A[], int N)
{
    int i;

    for (i = 0; i < N; i++)
    {
        printf("%d", A[i]);
        if (i < N - 1)
        {
            printf(" ");
        }
    }

    printf("\n");

    return 0;
}


Measured memory_bytes: 2112
#include<iostream>
using namespace std;
int main(void)
{
	int x=1,i,n,k;
	cin>>n>>k;
	for(i=1;i<=n;i++){
		if(x<k) x=x*2;
		else x=x+k;
	}
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 384
def resolve():
	a, b, c, x, y = map(int, input().split())
	opt1 = a*x + b*y
	v = a if x > y else b
	opt2 = min(x, y) * 2 * c + abs(x - y)*v
	opt3 = min(x, y)*2*c + abs(x-y)*2*c
	print(min([opt1, opt2, opt3]))
resolve()

Measured memory_bytes: 38256
using System;

class Program
{
    static void Main()
    {
        string[] s1 = Console.ReadLine().Split(' ');

        int n = int.Parse(s1[0]);
        int m = int.Parse(s1[1]);
        int l = int.Parse(s1[2]);

        long[,] A = new long[n, m];
        long[,] B = new long[m, l];
        long[,] C = new long[n, l];

        for(int i = 0; i < n; i++)
        {
            string[] s2 = Console.ReadLine().Split(' ');
            for(int j=0; j<m; j++)
            {
                A[i, j] = int.Parse(s2[j]);
            }
        }

        for(int i = 0; i < m; i++)
        {
            string[] s3 = Console.ReadLine().Split(' ');
            for(int j=0; j<l; j++)
            {
                B[i, j] = int.Parse(s3[j]);
            }
        }

        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                for (int k = 0; k < l; k++)
                {
                    C[i, k] += A[i, j] * B[j, k];
                }
            }
        }

        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < l; j++)
            {
                if (j == l - 1)
                    Console.WriteLine(C[i, j]);
                else
                    Console.Write(C[i, j] + " ");
            }
        }
    }
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int n, cnt = 0, ans = 0;
    int a, b, k;
    double r;
    cin >> r;
    cout << fixed << setprecision(20) << 2 * PI * r << endl;
    return 0;
}

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

using namespace std;

int main(void){
  string a,b;
  cin >> a >> b;
  if( a[0]==b[2] && b[0]==a[2] && a[1]==b[1] ){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
N,K=map(int,input().split())
R,S,P=map(int,input().split())
r=0
s=0
p=0
a=list(input())
A=[]
for i in range(K):
    if a[i]=="r": 
        A.append(P)
    elif a[i]=="s":
        A.append(R)
    else:
        A.append(S)
for i in range(K,N):
    if a[i]==a[i-K] and A[i-K]!=0:
        A.append(0)
    elif a[i]=="r": 
        A.append(P)
    elif a[i]=="s":
        A.append(R)
    else:
        A.append(S)
print(sum(A))

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

#define LL long long
#define MAXN 10000

int main(){
	int n;
	cin>>n;
	bool flag=false;
	while(n>0){
		if(n%10==9){
			flag=true;
			break;
		}
		n/=10;
	}
	if(flag==true){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
struct visitor{
	string str;
	int morning;
	int afternoon;
	long price;
};

int main(){
	struct visitor v[9];
	for(int i=0;i<9;i++){
		cin>>v[i].str>>v[i].morning>>v[i].afternoon;
		v[i].price = v[i].morning*200+v[i].afternoon*300;
	}
	for(int i=0;i<9;i++){
		cout<<v[i].str<<" "<<v[i].morning+v[i].afternoon<<" "<<v[i].price<<endl;
	}

	return 0;
}

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

using namespace std;

vector<int> permMul(const vector<int>& a, const vector<int>& b){
    vector<int> res(a.size());
    for(int i=0;i<a.size();i++) res[i] = a[b[i]];
    return res;
}

vector<int> permPow(const vector<int>& p, long long K){
    if(K == 0){
        vector<int> res = p;
        for(int i=0;i<res.size();i++) res[i] = i;
        return res;
    }
    vector<int> half = permPow(p, K/2);
    vector<int> res = permMul(half, half);
    if(K%2 == 1) res = permMul(res, p);
    return res;
}

int main(){
    int N;
    while(cin >> N){
        vector<long long> x(N);
        for(auto& t : x) cin >> t;
        vector<long long> d(N-1);
        for(int i=0;i<N-1;i++) d[i] = x[i+1] - x[i];
        int M; long long K;
        cin >> M >> K;
        vector<int> s(N-1);
        for(int i=0;i<N-1;i++) s[i] = i;
        for(int i=0;i<M;i++){
            int a; cin >> a;
            swap(s[a-2], s[a-1]);
        }
        cout << x[0] << endl;
        s = permPow(s, K);
        for(int i=1;i<N;i++){
            x[i] = x[i-1] + d[s[i-1]];
            cout << x[i] << endl;
        }
    }
}

Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll M;
    cin >> M;
    vector<pair<ll,ll>> A;
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        A.push_back(make_pair(a,b));
    }
    ll sum = 0;
    ll dig = 0;
    for (int i = 0; i < M; ++i) {
        sum += A[i].first * A[i].second;
        dig += A[i].second;
    }
    cout << (dig-1) + (sum-1)/9 << endl;
}


Measured memory_bytes: 6384
#include<iostream>
#include<math.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, x, n) for (int i = x; i < (n); ++i)
using namespace std;

// using ll = long long;
// using P = pair<int, int>;

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

    int T, A;
    cin >> T >> A;

    int H[1100];
    rep(i, N) cin >> H[i];

    // 標高ごとの平均気温
    double mt[1100];
    rep(i, N) mt[i] = (double) T - (double) H[i] * 0.006;

    double min_diff = 100000; // 最小の差
    int min_diff_index = 0; // 差が最小となる地点のインデックス
    rep(i, N) {
        double diff = fabs((double) A - mt[i]);
        if (diff < min_diff) {
            min_diff = diff;
            min_diff_index = i + 1;
        }
    }

    cout << min_diff_index << endl;
    return 0;
}


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

int main() {
  double N, T, A;
  cin >> N >> T >> A;
  vector<double> vec(N);
  for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
  vec.at(i) = T - vec.at(i) * 0.006;
  }

  double B = abs(A - vec.at(0));

  for (int i = 1; i < N; i++) {
    B = min(B, abs(A - vec.at(i)));
  }

  for (int i = 0; i < N; i++) {
    if (abs(A - vec.at(i)) == B) cout << i + 1 << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<cstdlib>
using namespace std;
typedef long long LL;
const int maxn=1e5+10;
bool vis[maxn];
char s[20];

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

	printf("0\n");
	fflush(stdout);
	scanf("%s",s);
	if(s[0]=='V')
	{
		return 0;
	}
	else if(s[0]=='M')
	{
		vis[0]=0;
	}
	else if(s[0]=='F')
	{
		vis[0]=1;
	}

	int ans;
	int from=0, to=n/2;
	printf("%d\n",n/2);
	fflush(stdout);
	scanf("%s",s);
	if(s[0]=='V')
	{
		return 0;
	}
	else if(s[0]=='M')
	{
		vis[to]=0;
	}
	else if(s[0]=='F')
	{
		vis[to]=1;
	}

	if(vis[from]==vis[to])
	{
		if((to-1)&1)
		{
			from=to,to=n;
		}
		else
		{
			from=0,to=n/2;
		}
	}
	else
	{
		if((to-1)&1)
		{
			from=0,to=n/2;
		}
		else
		{
			from=to,to=n;
		}
	}

	while(true)
	{
		int mid = (from+to)/2;
		printf("%d\n",mid);
		fflush(stdout);
		scanf("%s",s);
		if(s[0]=='V')
		{
			return 0;
		}
		else if(s[0]=='M')
		{
			vis[mid]=0;
		}
		else if(s[0]=='F')
		{
			vis[mid]=1;
		}

		int len=to-from-1;
		if(len&1)
		{
			int len2=(len-1)/2;
			if(len2&1)
			{
				if(vis[from]==vis[mid])
				{
					from=mid;
				}
				else
				{
					to=mid;
				}
			}
			else
			{
				if(vis[from]==vis[mid])
				{
					to=mid;
				}
				else
				{
					from=mid;
				}
			}
		}
		else
		{
			int len2=mid-from-1;
			if(len2&1)
			{
				if(vis[mid]==vis[from])
				{
					from=mid;
				}
				else
				{
					to=mid;
				}
			}
			else
			{
				if(vis[mid]==vis[from])
				{
					to=mid;
				}
				else
				{
					from=mid;
				}
			}
		}
	}

}


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

namespace ConsoleApp4
{
    class Program
    {
        static void Main()
        {
            var str = Console.ReadLine().Split(' ');
            var a = int.Parse(str[0]);
            var b = int.Parse(str[1]);
            var c = int.Parse(str[2]);

            var k = int.Parse(Console.ReadLine());

            var B = new List<int> { a, b, c };

            for (var i = 0; i < k; i++)
            {
                B = A(B);
            }

            Console.WriteLine(B.Sum());
        }


        private static List<int> A(List<int> ints)
        {
            var d = ints.OrderByDescending(x => x);

            var e = d.Skip(1).ToList();
            e.Add(d.First() * 2);

            return e;
        }
    }
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()

template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }

template<typename T>
struct BIT {
    vector<T> data;
    BIT(size_t n) {
        data.resize(n + 1, 0);
    }  
    //sum of [1, i]
    T sum(int i){
        assert(0 <= i);
        T s = 0;
        for(; i > 0; i -= i & -i) s += data[i];
        return s;
    }
    // sum of [i, j]
    T sum(int i,int j){
        assert(0 < i and i <= j);
        return sum(j) - sum(i - 1);
    }
    //add x to index i 
    void add(int i, T x){
        assert(0 < i);
        for(; i < data.size(); i += i & -i) data[i] += x;
    }
};

class Solver {
  public:
    bool solve() {
        int N, M; cin >> N >> M;
        vector<int> l(N), r(N);
        rep(i, N) cin >> l[i] >> r[i];
        vector<pii> len_idx(N);
        rep(i, N) len_idx[i] = make_pair(r[i] - l[i] + 1, i);
        sort(all(len_idx));

        vector<int> ans;
        ans.reserve(M);
        int pos = 0;
        BIT<int> num(M + 1);
        repeat(d, 1, M + 1) {
            while(pos < N and len_idx[pos].first < d) {                
                int i = len_idx[pos].second;
                num.add(l[i], 1);
                num.add(r[i] + 1, -1);
                pos++;
            }
            int sum = N - pos;
            for(int i = d; i <= M; i += d) sum += num.sum(1, i);
            ans.push_back(sum);
        }
        rep(i, M) cout << ans[i] << endl; 
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


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

using namespace std;
using ll = long long;


int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    int nax = 0;
    ll sum = 0;
    for(int i = 0; i < n; i++) {
        if(a[i] < nax)sum += nax - a[i];
        nax = max(nax, a[i]);
    }
    cout << sum << endl;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>//stayCalmNeverSettle
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define szof(x) ((int)x.size())
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii; 
int const INF = (int)1e9+1e3;
ll const INFL = (ll)1e18+1e6;

const int N = 1e5+5; 
double distance(pair<double,double>& p){
	double ans = p.ff*p.ff+p.ss*p.ss;
	ans = sqrt(ans);
	return ans;
}
int main(){
	int n;double d;
	cin >> n >> d;
	vector<pair<double,double>> coords(n);
	forn(i,n){
		cin >> coords[i].ff >> coords[i].ss;
	}
	int ans = 0;
	forn(i,n){
		if(distance(coords[i])<=d)
			ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 6556
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

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

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int N;


int main()
{
  cin>>N;
  int A[N];
  REP(i,0,N){
    cin>>A[i];
  }
  sort(A,A+N);
  int ans=1;
  bool flag=false;
  int tmp=1;
  int enu=0;
  REP(i,1,N){
    if(A[i]!=A[i-1]){
      ans++;
      if(tmp>0&&tmp%2==0){
        enu++;
      }
      tmp=1;
      
    }else{
      tmp++;
    }
    if(i==N-1){
      if(tmp>0&&tmp%2==0){
        enu++;
      }
    }
    
  }
  if(enu%2==1){
    cout<<ans-1<<endl;
    return 0;
  }
  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);
    Scanner nLine = new Scanner(reader.nextLine());
    int n = nLine.nextInt();
    int m = nLine.nextInt();
    int[] unique = new int[31];
    int count = 0;
    while(reader.hasNextLine()) {
      Scanner line = new Scanner(reader.nextLine());
      int base = line.nextInt();
      while(base > 0) {
        int i = line.nextInt();
        unique[i]++;
        base--;
      }
    }

    for(int i = 0; i <= m; ++i) {
      if(unique[i] == n) {
        count++;
      }
    }
    System.out.print(count);
  }
}


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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  t.pop_back();
  if (s == t) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;

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

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

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

    ll a,b; cin >> a >> b;
    cout << lcm(a,b)<<  endl;

    return 0;
}

Measured memory_bytes: 256
# frozen_string_literal: true

n = gets.to_i
v = gets.split.map(&:to_i)

first = Hash.new(0)
second = Hash.new(0)
n.times do |i|
  if i.odd?
    first[v[i]] += 1
  else
    second[v[i]] += 1
  end
end

f1, f2 = first.sort_by { |_, v| -v }[0..1]
s1, s2 = second.sort_by { |_, v| -v }[0..1]
f2 = [200000, 0] if f2.nil?
s2 = [200000, 0] if s2.nil?

ans = if f1[0] == s1[0]
  if f1[1] - f2[1] < s1[1] - s2[1]
    n - f2[1] - s1[1]
  else
    n - f1[1] - s2[1]
  end
else
  n - f1[1] - s1[1]
end

puts ans

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

using namespace std;

int main()
{
  int N,count =0;
  cin>>N;
  vector<int> V(N);
  for(int i=1;i<=N;i++){
    cin>>V[i];
    if(i%2 == 1){
      if(V[i]%2 ==1){
        count++;
      }
    }
  }
  cout<<count;
  
  return 0;
      
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	int h, w;
	cin >> h >> w;
	vector<vector<int>> ans(h, vector<int>(w, 1e9));
	vector<vector<char>> s(h, vector<char>(w));
	rep(i, h)rep(j, w)cin >> s[i][j];
	ans[0][0] = 0;
	if (s[0][0] == '#')ans[0][0] = 1;
	rep(i, h)rep(j, w) {
		int x;
		if (s[i][j]=='#') {
			if (i != 0) {
				x = 0;
				if (s[i - 1][j] == '.')x = 1;
				ans[i][j] = ans[i - 1][j] + x;
			}
			if (j != 0) {
				x = 0;
				if (s[i][j - 1] == '.')x = 1;
				ans[i][j] = min(ans[i][j], ans[i][j - 1] + x);
			}
		} else {
			if (i != 0) {				
				ans[i][j] = ans[i - 1][j];
			}
			if (j != 0) {				
				ans[i][j] = min(ans[i][j], ans[i][j - 1]);
			}
		}
	}
	/*rep(i, h) {
		rep(j, w) {
			cout << ans[i][j] << " ";
		}
		cout << "\n";
	}*/
	cout << ans[h - 1][w - 1];
	return 0;
}

Measured memory_bytes: 256
from math import sqrt
n,d=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    cnt=0
    for k in range(d):
      cnt+=(x[i][k]-x[j][k])**2
    if sqrt(cnt)==int(sqrt(cnt)):
      ans+=1
print(ans)

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = 998244353;
const int N = (int)2e5 + 5;



int used[4];

void solve(){
	int a,b;
	cin>>a>>b;
	used[a]=1;
	used[b]=1;
	for(int i=1;i<4;i++){
		if(!used[i]){
			cout<<i;
		}
	}

}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const ll INFL = (1LL << 62);
const ll MOD = 1000000007;
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
ll mod_pow(ll a, ll n, T mod) {
    mod = (ll)mod;
    ll res = 1, p = a % mod;
    while (n) {
        if (n & 1) res = res * p % mod;
        p = p * p % mod;
        n >>= 1;
    }
    return res;
}
void print() { std::cout << std::endl; }
template <typename T, typename... A>
void print(const T& first, const A&... rest) {
    cout << sizeof...(rest) << endl;
    std::cout << first;
    if (sizeof...(rest)) std::cout << " ";
    print(rest...);
}
template <typename... A>
void print(const A&... rest) {
    print(rest...);
}
template <typename A>
void print(const std::vector<A>& v) {
    std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; });
    std::cout << std::endl;
}
vector<ll> divisor(ll n) {
    vector<ll> res;
    ll i = 1;
    while (i * i <= n) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) {
                res.push_back(n / i);
            }
        }
        i++;
    }
    return res;
}

bool isp(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return true;  // n != 1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    vector<ll> da, db;
    da = divisor(a);
    db = divisor(b);
    ll ans = 0;
    map<ll, bool> hoge;
    for(auto &ai : da){
        hoge[ai] = true;
    }
    for (auto& d : db) {
        if (isp(d) && hoge[d]) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768