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

int main(void){
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        ll ans = 0;
        for(int x=1;x*x<i;x++){
            for(int y=1;y*y<i;y++){
                int d = 4*i-3*x*x-3*y*y-2*x*y;
                        if(d<0) continue;
                        int z = (-1*(x+y)+sqrt(d));
                        if(z<1) continue;
                        else{
                            z/=2;
                            if(x*x+y*y+z*z+x*y+y*z+z*x==i){
                                ans++;
                                //cout << x << ", " << y << ", " << z << endl;
                            }
                        }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3676
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=200005;
int a[MAXN],b[MAXN],s[MAXN],n;
struct line
{
	int l,r;
	line(){}
	line(int _l,int _r){l=_l;r=_r;}
}sta[MAXN];int tp;
bool check(int u)
{
	for(int i=1;i<=2*n-1;i++)b[i]=(a[i]>=u?1:0);b[0]=b[1];
	for(int i=2*n-1;i>=1;i--)b[i]^=b[i-1];tp=0;
	memset(s,0,sizeof(s));
	for(int i=1,nxt;i<=2*n-1;i=nxt+1)
	{
		if(!b[i]){nxt=i;continue;}
		nxt=i;while(nxt+1<=2*n-1&&b[nxt+1])++nxt;
		if(nxt-i+1>=2)sta[++tp]=line(i,nxt);
		else s[i]^=1;
	}
	for(int i=1;i<n;i++)
	{
		int tp1=0;
		for(int j=1;j<=tp;j++)
		{
			int u1=sta[j].l,u2=sta[j].r;
			++u1;--u2;
			if(u2-u1+1>=2)sta[++tp1]=line(u1,u2);
			else if(u2-u1+1)s[u2]^=1;
		}tp=tp1;
	}int o=b[0],mi=n;
	for(int i=1;i<=mi;i++)o^=s[i];
	for(int i=1;i<=tp;i++)
	{
		if(sta[i].r<n)o^=((sta[i].r-sta[i].l+1)&1);
		else if(sta[i].l>n)break;
		else {o^=((mi-sta[i].l+1)&1);break;}
	}return o;
}
int main()
{
	n=read();
	for(int i=1;i<=2*n-1;i++)a[i]=read();
	int l=1,r=2*n-1,ans;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid))ans=mid,l=mid+1;
		else r=mid-1;
	}pr2(ans);
	return 0;
}


Measured memory_bytes: 2688
#include <stdio.h>

 
int main()
{
    long long int a[200],n,i,flag=0,sum=0;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
        scanf("%lld",&a[i]);
    while(flag==0)
    {
        for(i=0;i<n;i++)
        {
            if(a[i]%2!=0)
            {
                printf("%lld",sum);
                exit(0);
            }
        }
        for(i=0;i<n;i++)
        {
            a[i]=a[i]/2;
        }
        sum++;
    }
    printf("%lld",sum);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
  long long N , T;
  cin >> N >> T;
  vector<long long> t(N);
  for(auto &&it:t){
    cin >> it;
  }

  long long before = 0;
  long long count =T;
  for(int i=1;i<t.size();i++){
    if(t[i]-before>=T){
      count+=T;
    }else{
      count+=t[i]-before;
    }
    before = t[i];
  }
  cout << count <<endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if (n % 2 != 0)
      System.out.println("No");
    else {
      String s = sc.next();
      System.out.println(s.substring(0, s.length() / 2).equals(s.substring(s.length() / 2, s.length())) ? "Yes" : "No");
    }
  }
}

Measured memory_bytes: 21972
import sys
import math

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]


def main():
    n, m = na()
    a = na()

    vs = {}

    b = [0] * n
    b[0] = a[0]
    for i in range(1, n):
        b[i] = b[i-1] + a[i]

    for i in range(n):
        k = b[i] % m
        if k in vs:
            vs[k] += 1
        else:
            vs[k] = 1
            

    cnt = 0
    for k, v in vs.items():
        if v >= 2:
            cnt += math.factorial(v) // 2 // math.factorial(v-2)
        if k == 0:
            cnt += v


    print(cnt)


main()


Measured memory_bytes: 62576
import java.util.Scanner;

public class Main {
    static int n;
    static int[] dp;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        dp = new int[9]; //0:灰色～7:赤 8:それ以上
        int ans = 0;

        for (int i = 0; i < n; i++) {
            int color = Math.min(8, sc.nextInt()/400);
            dp[color]++;
        }
        for (int i = 0; i < 8; i++) {
            if (dp[i] != 0) {
                ans++;
            }
        }
        System.out.println(Math.max(1, ans) + " " + (ans + dp[8]));
    }
}


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

temp_set=set()

l = []

for a in A:
  if a in temp_set:
    l.append(a)
    temp_set.remove(a)
  else:
    temp_set.add(a)
    
l.sort()
if len(l)>=2:
  print(l[-2]*l[-1])
else:
  print(0)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d=0;
	cin>>a>>b>>c;
	 for (int x=a;x<=b;x++){
		 if (c%x==0){
			 d++;
		 }
	 }
	 cout<<d<<endl;
	 return 0;
 }



Measured memory_bytes: 3092
import sys
input = sys.stdin.readline

x, y  = map(int, input().split())
li =[]
for i in range(x):
    l = list(map(int, input().split()))
    li.append(l)
dp = [[0]*(y+1) for _ in range(x+1)]
for i in range(x):
    for j in range(1, y+1):
        if j - li[i][0] >= 0:
            dp[i+1][j] = max(dp[i][j],dp[i][j - li[i][0] ]+ li[i][1])
        else:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
print(dp[x][y])

Measured memory_bytes: 121180
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	int a, b, c;
	cin >> a >> b >> c;

	int v[100100];
	rep(i, 100000) v[i] = 0;

	for (int i = 0; i < 10000; i += (a + b)){
		reps(j, i, i + a) v[j] = 1;
	}

	int cnt = 0;
	for (int i = c - 1; i <= 10000; i += 60){
		cnt++;
		if(v[i] == 1){
			printf("%d\n", c + ((cnt - 1) * 60));
			return 0;
		}
	}

	printf("-1\n");
	return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>

int main()
{
    unsigned long long int n, k;
    long long int tmp;
    int end;

    scanf("%llu%llu", &n, &k);

    if (k == 1)
        n = 0;
    else {
        do {
            end = 0;
            if (n > 1000000000 * k) {
                n = n - 1000000000 * k;
                end = 1;
            }
        } while (end == 1);
        
        do {
            end = 0;
            tmp = (long long int)(n - k);
            if (tmp < 0)
                tmp *= -1;
            if (tmp < n) {
                n = (unsigned long long)tmp;
                end = 1;
            }
        } while (end == 1);
    }

    printf("%llu\n", n);

    return 0;
}

Measured memory_bytes: 1704
N=int(input())
p=list(map(int,input().split()))

li=[i for i in range(1,N+1)]

for j in range(N):
    for k in range(N):
        p[j],p[k]=p[k],p[j]
        if p==li:
            print("YES")
            exit()
        else:
            p[j],p[k]=p[k],p[j]

print("NO")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,a,b;
    cin >> n >> a >> b;
    if ((a-b)%2==0)
    {
        cout << abs(a-b) / 2 << endl;
    }
    else
    {
        // cout << min(max(a,b)-1, n-min(a, b)) << endl;
        cout << min((a+b-1)/2, n-(a+b-1)/2) << endl;
    }
    
    
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
   vector<int> dp(3,0);

    for(int i=0;i<n;i++){
        vector<int> arr(3);
        vector<int> new_dp(3,0);
        
        for(int j=0;j<3;j++)cin>>arr[j];
        
        for(int a=0;a<3;a++){
            for(int b=0;b<3;b++){
                if(a!=b){
                new_dp[b]=max(new_dp[b],dp[a]+arr[b]);
                }

            }
        }

    dp=new_dp;
    }
    cout<<max({dp[0],dp[1],dp[2]})<<"\n";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int N, D, X, A[100];

int main(void){
	//IO("test.in", "test.out");
	scanf("%d%d%d", &N, &D, &X);
	for(int i = 0; i < N; i++) scanf("%d", &A[i]);
	for(int i = 0; i < N; i++){
		int j = 1;
		while(j <= D) X++, j += A[i];
	}
	printf("%d\n", X);
}

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

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

int main() {
  char x;
  cin >> x;
  cout << (char)(x + 1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for (int i=(a); i<=(b); i++)
using namespace std;

inline int read() {
	char ch = getchar(); int x = 0, op = 1;
	while (ch < '0' || '9' < ch) { if (ch == '-') op = -1; ch = getchar(); }
	while ('0' <= ch && ch <= '9') { x = x*10 + ch-'0'; ch = getchar(); }
	return op * x;
}

const int maxn = 509;
int a[maxn][maxn], b[maxn][maxn];
char s[maxn];
int n, m;

int main() {
	n = read(); m = read();
	rep (i, 1, n) {
		a[i][1] = 1; b[i][m] = 1;
		rep (j, 2, m-1)
			if (i&1) a[i][j] = 1;
			else b[i][j] = 1;
	}
	rep (i, 1, n) {
		scanf("%s", s+1);
		rep (j, 1, m)
			if (s[j] == '#') 
				a[i][j] = b[i][j] = 1;
	}
	rep (i, 1, n) {
		rep (j, 1, m)
			if (a[i][j]) putchar('#');
			else putchar('.');
		puts("");
	}
	puts("");
	rep (i, 1, n) {
		rep (j, 1, m)
			if (b[i][j]) putchar('#');
			else putchar('.');
		puts("");
	}
	return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){ 
	string S; 
	cin >> S; 
	int N = S.size(); 
	if(N % 2 == 0 && S.at(0) == S.at(N-1)){cout << "First" << endl;}
	if(N % 2 == 0 && S.at(0) != S.at(N-1)){cout << "Second" << endl;}
	if(N % 2 == 1 && S.at(0) == S.at(N-1)){cout << "Second" << endl;}
	if(N % 2 == 1 && S.at(0) != S.at(N-1)){cout << "First" << endl;}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int i,n,k;
    cin>>n;
    k=0;
    int a[n+1];
    int ans[n+1];
    for(i=1;i<=n;i++){
        cin>>a[i];
        k=k^a[i];
    }
    for(i=1;i<=n;i++){
        ans[i]=a[i]^k;
        cout<<ans[i]<<" ";
    }
    return 0;
}

Measured memory_bytes: 5128
N, M = map(int, input().split())
E = [tuple(map(int, input().split())) for _ in range(M)]

graph = [[0 for j in range(N)] for i in range(N)]

for e in E:
    graph[e[0] - 1][e[1] - 1] = 1
    graph[e[1] - 1][e[0] - 1] = 1

res = 0

dp = [[0 for j in range(N)] for i in range(2**N)]
dp[1][0] = 1

for i in range(2**N):
    for j in range(N):
        for k in range(N):
            if not (i >> k & 1) and graph[j][k]:
                dp[(i)|(1 << k)][k] += dp[i][j]

print(sum(dp[-1]))

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
	int a=0;
	int b=0;
	int c=0;
	int tmp=0;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	while(a>b || b>c ){
	if(a>b){
	tmp=a;
		a=b;
		b=tmp;
	}
	if(b>c){
	tmp=b;
		b=c;
		c=tmp;
		
		
	}
	}
	printf("%d %d %d\n",a,b,c);
	
		return 0;
	
}

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

int main()
{
	double r;
	double pi = 3.14159265358979;

	cin >> r;

	double area = pi * r * r;
	double circumference = 2 * r * pi;

	cout << fixed << setprecision(6);
	cout << area << " " << circumference << endl;

	return 0;
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
 
#define mod             1000000007
#define rep(i,n)        for (int i = 0; i < n; ++i)
#define REP(i,k,n)      for (int i = k; i < n; ++i)
#define REPR(i,k,n)     for (int i = k; i >= n; --i)
#define w(x)            int x; cin>>x; while(x--)
#define mk(arr,n,type)  type *arr=new type[n];
#define pii             pair<int,int>
#define mp              make_pair
#define inrange(i, a, b) ((i >= min(a, b)) && (i <= max(a, b)))
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll              long long
#define w(x)            int x; cin>>x; while(x--)
#define mem(a, b)       memset(a, (b), sizeof(a))

void solve() {
    int x, ans = 0;
    cin >> x;
    ans+= (x/500) * 1000;
    x = x % 500;
    ans+= (x/5) * 5;
    cout << ans <<endl;
} 
int main() {
    fast
    solve();
    return 0;
}

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

const int INF = 0x3f3f3f3f;
const int kN = 300 + 5;
int n, m, cost[kN][kN], dp[kN][kN];
char str[kN][kN];

int calc(int l, int r)
{
    for (int i = 1; i <= n; ++ i) {
        for (int j = 1; j <= n; ++ j) {
            cost[i][j] = cost[i - 1][j - 1] + (str[i - 1][l] == str[j - 1][r]);
        }
    }
    memset(dp, INF, sizeof(dp));
    dp[n][n] = 0;
    for (int i = n; i >= 0; -- i) {
        for (int j = n; j >= 0; -- j) {
            if (i) dp[i - 1][j] = std::min(dp[i - 1][j], dp[i][j] + cost[i][j]);
            if (j) dp[i][j - 1] = std::min(dp[i][j - 1], dp[i][j] + cost[i][j]);
        }
    }
    return dp[0][0];
}

int main()
{
    scanf("%d%d",&n, &m);
    for (int i = 0; i < n; ++ i) {
        scanf("%s", str[i]);
    }
    int result = 0;
    for (int i = 0; i + 1 < m; ++ i) {
        result += calc(i, i + 1);
    }
    printf("%d\n", result);
}

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

typedef long long ll;

ll n,t;
ll last, Now;
ll Out;

int main(){
    scanf("%lld%lld", &n, &t);
    for(int i = 1; i <= n; i++){
       scanf("%lld", &Now) ;
       if(last + t > Now) Out += (Now - last);
       else Out += t;
       last = Now ;
    }
    printf("%lld", Out + t);
    return 0;

}


Measured memory_bytes: 256
import math
n = int(input())
a = list(map(int, input().split()))
mod = int(1e+9+7)
max_val = int(1e+6+1)

def make_kago(x):
    kago = [0 for _ in range(x+1)]
    sosuu = []
    for i in range(2,x+1):
        if kago[i] != 0:
            continue
        sosuu.append(i)
        for j in range(i, x+1, i):
            if kago[j] == 0:
                kago[j] = i
    return kago, sosuu

kago, sosuu = make_kago(max_val)

def prime_factorization(x):
    if x==0 or x==1:
        return None
    soinsuu = []
    while x!=1:
        soinsuu.append(kago[int(x)])
        x = x/kago[int(x)]
    
    soinsuu_dict = dict()
    for i in range(len(soinsuu)):
        if soinsuu[i] not in soinsuu_dict:
            soinsuu_dict[soinsuu[i]] = 1
        else:
            soinsuu_dict[soinsuu[i]]+=1
    return soinsuu_dict
#%%
max_soinsuu = [0 for _ in range(int(1e+6+1))]

#%%

for i in range(n):
    soinsuu_dict = prime_factorization(a[i])
    if soinsuu_dict == None:
        continue
    for k, v in soinsuu_dict.items():
        if max_soinsuu[k] < v:
            max_soinsuu[k] = v

lcm = 1
for i in range(max_val):
    if max_soinsuu[i] != 0:
        lcm = (lcm*i**max_soinsuu[i])%mod

answer = 0
for i in range(n):
    answer = (answer + lcm*pow(a[i],mod-2,mod))%mod
    
print(answer)

Measured memory_bytes: 118348
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n,a,b;cin>>n>>a>>b;
    ll k=n/(a+b);
    cout<<(k*a+min(a,n%(a+b)))<<endl;
    return 0;
}


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

#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define mp make_pair
#define pb push_back
priority_queue<pll,vector<pll>,greater<pll> >pq;

int h,w;
vector<vector<int> >dp(1001,vector<int>(1001,0));
vector<vector<char> >grid(1001,vector<char>(1001));

int solve(int i,int j){
    if(i==h || j==w)
        return 1;
    if(dp[i][j]!=1)
        return dp[i][j];
    if(i+1<=h && j<=w && dp[i+1][j]!='#')
        dp[i][j]=(dp[i][j]*solve(i+1,j))%mod;
    if(i<=h && j+1<=w && dp[i][j+1]!='#')
        dp[i][j]=(dp[i][j]*solve(i,j+1))%mod;
    return dp[i][j];
}

int main(){
    cin>>h>>w;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>grid[i][j];
        }
    }
    //solve(1,1);
    dp[1][1]=1;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(grid[i][j]=='#')
                continue;
            if(i>=2)
                dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
            if(j>=2)
                dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
        }
    }
    cout<<dp[h][w];

    return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int

using namespace __gnu_pbds;

typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;


#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
#define mod 1000000007
/* Precode Start Here *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
  string s,t;
  cin>>s>>t;
  cout<<t+s<<endl;


return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define F(i, n) for(int i = 0; i < n; ++i)
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX =2*100000 + 47;

VI G[MAX];
int C[MAX];
int cnt[MAX];
bool b;

void dfs(int v, int c)
{
    C[v] = c;
    cnt[c]++;
    FOR(i, 0, SZ(G[v]))
    {
        int to = G[v][i];
        if (C[to] != -1)
        {
            if (C[to] == C[v])
                b =  false;
            continue;
        }
        
        dfs(to, c ^ 1);
        
    }
}


int main()
{
    //freopen("in.txt", "r", stdin);
    int n, m;
    scanf("%d%d", &n, &m);
    FOR(i, 0, m)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        --x, --y;
        G[x].PB(y);
        G[y].PB(x);
    }
    FILL(C, -1);
    
    LL NB = 0;
    LL C1 = 0, CC = 0;
    
    FOR(i, 0, n)
        if (C[i] == -1)
        {
            cnt[0] = cnt[1] = 0;
            b = 1;
            dfs(i, 0);
            if (!b)++NB;
            else
            {
                if (!cnt[1])++C1;
                else ++CC;
            }
        }
    
    LL res = NB * NB;
    res += 2 * CC * CC;
    res += 2 * CC * NB;
    res += 2 * C1 * n  - C1 * C1;
    cout << res << endl;
    
    
}



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

using namespace std;

int n;
int a[202];
int main() {
  cin >> n;
  for(int i = 0; i < 2 * n; i++) cin >> a[i];

  sort(a,a+2*n);

  int ans = 0;

  for(int i = 0; i < 2 * n; i += 2) ans += a[i];

  cout << ans << endl;
}


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

int main()
{
    int N;
    long long x;
    cin>>N>>x;
    vector<long long> a(N);
    for (long long &t: a)
        cin>>t;

    vector<long long> T = a;
    long long s = 0;
    for (long long t: T)
        s += t;
    long long ans = s;
    for (int i=1; i<N; i++)
    {
        vector<long long> P(N, 1000000000000000LL);
        P.swap(T);
        for (int j=0; j<N; j++)
            T[j] = min(P[j], P[(j+N-1)%N]);
        s = 0;
        for (long long t: T)
            s += t;
        ans = min(ans, s+i*x);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;
#include <atcoder/all>
using namespace atcoder;


int main(){
  int n, m;
  cin >> n >> m;
  dsu d(n);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    d.merge(a, b);
  }
  auto ans = d.groups();
  cout << ans.size()-1 << endl;
  return 0;
}

Measured memory_bytes: 8976
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;
int main() {
	int n;
	cin >> n;
	cout << 180 * (n - 2) << endl;
}


Measured memory_bytes: 256
c = input()
alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
print(alpha[alpha.index(c)+1])


Measured memory_bytes: 2940
N    = int(input())
A    = [int(x) for x in input().split()]
Pro  = 1
PrF  = 1
PrFF = 1

if 0 in A:
    print('0')
    PrF = 0
    
if PrF:
    for T in range(0,len(A)):
        Pro = Pro*A[T]
        if Pro > pow(10,18):
            PrFF = 0
            print('-1')
            break

if PrF & PrFF:
    print(Pro)

Measured memory_bytes: 21752
N = int(input())
h = list(map(int, input().split()))

mincost = [float("inf") for _ in range(N)]
mincost[0] = 0
mincost[1] = abs(h[1] - h[0])

for i in range(2, N):
    mincost[i] = min(mincost[i - 2] + abs(h[i] - h[i - 2]), mincost[i - 1] + abs(h[i] - h[i - 1]))

print(mincost[N - 1])

Measured memory_bytes: 13980
#include <cmath>
#include <cstdio>
typedef long long lld;
lld N;

lld solve() {
    int S = sqrt(N);
    for (int i = S; i >= 1; --i) {
        if ((N % i) != 0) {
            continue;
        }
        lld j = N / i;
        return (i + j - 2);
    }
    return -1;
}

int main() {
    scanf("%lld", &N);
    printf("%lld\n", solve());
    return 0;
}

Measured memory_bytes: 128
N = int(input())
A = [(int(input()), 0) for i in range(N)]
B = [(int(input()), 1) for i in range(N)]
mod = 10 ** 9 + 7


X = A + B
X.sort()


ans = 1
Ar, Br = 0, 0

for x, i in X:
    if i == 0:
        if Br > 0:
            ans *= Br
            ans %= mod
            Br -= 1
        else:
            Ar += 1

    else:
        if Ar > 0:
            ans *= Ar
            ans %= mod
            Ar -= 1
        else:
            Br += 1

print(ans)


Measured memory_bytes: 26096
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <math.h>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <numeric>
#include <bits/stdc++.h>

#define int long long

struct edge {
    int to;
    int cost;
};

using namespace std;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vb = vector<bool>;
using qi = queue<int>;
using P = pair<int, int>;
using graph = vector<vector<edge>>;
// using graph = vector<vector<int>>;


#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define delim(i, n) cout << (i == n-1 ? "\n" : " ");

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

const int inf = 1LL << 60;
// const int inf = 100000000;
const int mod = 1000000007;

const int maxn = 2e5+2;
int n, m, k;
vi dp(maxn);
vii num(10, vi(2));
vi nsum(10);

vi dx = {-1, 0, 0, 1};
vi dy = {0, -1, 1, 0};

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

    cin >> n >> k;
    REP(i, k) {
        cin >> num[i][0] >> num[i][1];
    }

    dp[0] = 1;

    REP(i, n) {
        REP(j, k) {
            if (num[j][1] < i) {
                nsum[j] = nsum[j] - dp[i-num[j][1]-1] + dp[i-num[j][0]] + 998244353;
                nsum[j] %= 998244353;
                dp[i] += nsum[j];
                dp[i] %= 998244353;
            } else if (num[j][0] <= i) {
                nsum[j] += dp[i-num[j][0]];
                nsum[j] %= 998244353;
                dp[i] += nsum[j];
                dp[i] %= 998244353;
            }
        }
    }

    cout << std::fixed << std::setprecision(10) << dp[n-1] << "\n";
}

Measured memory_bytes: 4636
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <time.h>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll X;

int main(void)
{
	ll i; cin>>X;
	for(i=1 ;  ; i++)
	{
		if(i*(i+1)/2>=X)
		{
			cout<<i; return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#define N 100007
using namespace std;
int n,p[N],siz[N];
vector <int> to[N];
void dfs(int x){
	siz[x]=1;
	for(int i=0;i<to[x].size();++i){
		if(to[x][i]==p[x])continue;
		p[to[x][i]]=x;
		dfs(to[x][i]);
		siz[x]+=siz[to[x][i]];
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1,x,y;i<n;++i){
		scanf("%d%d",&x,&y);
		to[x].push_back(y);
		to[y].push_back(x);
	}
	dfs(1);
	int cur=n,cnt=0;
	while(cur!=1)cur=p[cur],++cnt;
	cur=n;
	for(int i=1;i<=(cnt-1)/2;++i)cur=p[cur];
	if(siz[1]-siz[cur]>siz[cur])printf("Fennec");
	else printf("Snuke");
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  string S;
  cin>>S;
  int A[26];
  rep(i,26)A[i]=0;
  rep(i,S.size())A[S[i]-'a']+=1;
  for(int j:A){
    if(j>=2){
      cout<<"no"<<endl;
      return 0;
    }
  }
  cout<<"yes"<<endl;
  return 0;
}

Measured memory_bytes: 3628
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Multiplication3 solver = new Multiplication3();
        solver.solve(1, in, out);
        out.close();
    }

    static class Multiplication3 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            String[] inputs = in.nextLine().split(" ");
            long a = Long.parseLong(inputs[0]);
            long b = Long.parseLong(inputs[1].replaceAll("\\.", ""));

            out.append(String.valueOf(a * b / 100));


        }

    }
}



Measured memory_bytes: 35676
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int a, b; cin >> a >> b;
	cout << (a + b) % 24 << endl;
	return 0;
}

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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int n, p[1000 * 1000], d[1000][1000], di[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
bool c[1000][1000];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n;
  for (int i = 0; i < n * n; i++)
    cin >> p[i], p[i]--;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      c[i][j] = true, d[i][j] = min(min(i + 1, n - i), min(j + 1, n - j));
  int r = 0;
  for (int k = 0; k < n * n; k++) {
    int i = p[k] / n, j = p[k] % n;
    r += d[i][j] - 1;
    c[i][j] = false;
    d[i][j]--;
    deque<pair<int, int>> q;
    q.push_front({i, j});
    while (!q.empty()) {
      tie(i, j) = q.front();
      q.pop_front();
      for (int dir = 0; dir < 4; dir++) {
        int ni = i + di[dir][0], nj = j + di[dir][1];
        if (ni < 0 || nj < 0 || ni >= n || nj >= n)
          continue;
        if (d[i][j] + c[ni][nj] < d[ni][nj]) {
          d[ni][nj] = d[i][j] + c[ni][nj];
          if (c[ni][nj])
            q.push_back({ni, nj});
          else
            q.push_front({ni, nj});
        }
      }
    }
  }
  cout << r << "\n";
}


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

int main()
{
    int n, m, e, a[101] = {0}, b[101] = {0}, c[101] = {0}, d[101] = {0};

    cin >> n;

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

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

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

    for( int i = 1; i <= n; i++ ){
        if( a[i] == 0 && c[i] == 1 || b[i] == 1 && c[i] == 1 )
            d[i]++;
    }
    
    int cnt = 0;
    
    for( int i = 1; i <= n; i++ ){
        if( d[i] == 1 )
            cnt++;
    }
    
    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int d[1004][1004];
string str[1004];
bool mrk[1004][1004];
priority_queue<pii,vector<pii >,greater<pii > > q;

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

	int n,m,x,y,i,j,sx,sy,tx,ty;

	cin >> n >> m;
	cin >> sx >> sy;
	cin >> tx >> ty;
	sx--;
	sy--;
	tx--;
	ty--;

	for(i=0;i<n;++i)
		cin >> str[i];

	for(i=0;i<n;++i)
		for(j=0;j<m;++j)
			d[i][j] = 1e9;

	d[sx][sy] = 0;
	q.push(pii(0,pi(sx,sy)));

	while(!(q.empty()))
	{
		pii ed = q.top();
		x = ed.ss.ff;
		y = ed.ss.ss;
		q.pop();
		if(mrk[x][y] == 1)
			continue;
		// cout << x << " " << y << " " << d[x][y] << endl;
		mrk[x][y] = 1;

		for(i=-1;i<=1;++i)
		{
			for(j=-1;j<=1;++j)
			{
				if(abs(i)==abs(j))
					continue;
				sx = x+i;
				sy = y+j;
				if(sx<0 || sx>=n || sy<0 || sy>=m)
					continue;
				if(str[sx][sy] == '#')
					continue;
				if(d[sx][sy]>d[x][y])
				{
					d[sx][sy] = d[x][y];
					q.push(pii(d[sx][sy],pi(sx,sy)));
				}
			}
		}


		for(i=-2;i<=2;++i)
		{
			for(j=-2;j<=2;++j)
			{
				sx = x+i;
				sy = y+j;
				if(sx<0 || sx>=n || sy<0 || sy>=m)
					continue;
				// cout << sx << " " << sy << endl;
				if(str[sx][sy] == '#')
					continue;
				if(d[sx][sy]>d[x][y]+1)
				{
					d[sx][sy] = d[x][y]+1;
					q.push(pii(d[sx][sy],pi(sx,sy)));
				}
			}
		}
	}

	if(d[tx][ty] > 1e8)
		cout << -1 << "\n";
	else
		cout << d[tx][ty] << "\n";
}
	

Measured memory_bytes: 9692
n, t = gets.split(" ").map{|n| n.to_i}
candidates = n.times.map{
  gets.split(" ").map{|n| n.to_i}
}.select{|ci, ti| ti <= t }
if candidates.empty?
  puts "TLE"
else
  puts candidates.min_by{|ci, ti| ci}[0]
end


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

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> l(n);
    int wa=0;
    for(int i=0;i<n;i++){
        cin>>l.at(i);
    }
    sort(l.begin(),l.end());
    reverse(l.begin(),l.end());
    for(int i=0;i<k;i++){
        wa+=l.at(i);
    }
    cout<<wa<<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N=int(input().rstrip('\n'))
A=[int(x) for x in input().rstrip('\n').split()]
res = 0
t=1
for _ in range(60):
  n = sum(x%2 for x in A)
  A = [x//2 for x in A]
  res += n*(N-n)*t
  t = t*2
  res = res%(7+10**9)
  if all(x==0 for x in A):
    break
print(res)

Measured memory_bytes: 183812
N, M = list(map(int, input().split()))
KA = [list(map(int, input().split())) for i in range(N)]
for KAi in KA:
    del KAi[0]
# print(KA)

favorites = set(KA[0])
for KAi in KA:
    favorites = favorites & set(KAi)

number_of_common_favorites = len(favorites)

print(number_of_common_favorites)



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

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> edges(N);
    map<pair<int, int>, int> posToIndex;
    rep(i, N - 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
        posToIndex[make_pair(a, b)] = i;
        posToIndex[make_pair(b, a)] = i;
    }

    set<int> default_set;
    rep(i, N - 1)
    {
        default_set.insert(i + 1);
    }

    vector<int> colors(N - 1, 0);
    vector<priority_queue<int, vector<int>, greater<int>>> next_colors(N);

    int K = 0;
    rep(i, N)
    {
        int next_color = 0;
        rep(j, edges[i].size())
        {
            int next_pos = edges[i][j];
            int next_index = posToIndex[make_pair(i, next_pos)];
            if (colors[next_index] == 0)
            {
                next_color++;
                while (next_colors[i].size())
                {
                    if (next_colors[i].top() != next_color)
                        break;
                    next_color = next_colors[i].top() + 1;
                    next_colors[i].pop();
                }

                colors[next_index] = next_color;
                next_colors[next_pos].push(next_color);
                K = max(K, next_color);
                //cout << i << "->" << next_pos << ":" << next_color << endl;
            }
        }
    }

    cout << K << endl;
    rep(i, N - 1)
    {
        cout << colors[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 29824
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 
#include <climits>
using namespace std;
long double eps = 1e-9;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n;
	while(cin >> n){
		if(n == 0)break;
		int a[n];
		int sum = 0, ans = INT_MIN;
		for(int i = 0; i < n; i++){
			cin >> a[i];
			sum += a[i];
			ans = max(ans, sum);
			if(sum < 0)sum = 0;
		}
		cout << ans << '\n';
	}
	return 0;
}
// Write Here



Measured memory_bytes: 3136
#include<iostream>
using namespace std;
#define mod 1000000007
long long H, W, A, B, K, ret, res, fact[300000], inv[300000], factinv[300000];
long long ncr(int n, int r) { return (n - r >= 0 && r >= 0) ? 1LL * fact[n] * factinv[r] % mod * factinv[n - r] % mod : 0; }
int main() {
	fact[0] = 1; for (int i = 1; i < 300000; i++) fact[i] = 1LL * fact[i - 1] * i % mod;
	inv[1] = 1; for (int i = 2; i < 300000; i++) inv[i] = 1LL * inv[mod % i] * (mod - mod / i) % mod;
	factinv[0] = 1; for (int i = 1; i < 300000; i++) factinv[i] = 1LL * factinv[i - 1] * inv[i] % mod;
	cin >> H >> W >> A >> B; long long sum = 0;
	for (int i = 0; i < H - A; i++) {
		sum += ncr(B + i - 1, B - 1)*ncr((W - B - 1) + (H - i - 1), W - B - 1); sum %= mod;
	}
	cout << sum << endl;
	return 0;
}

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

long gcd(long a, long b);
long lcm(long a, long b);

int main() {
    long a, b, c, d, e, ans;
    cin >> a >> b >> c >> d;
    e = lcm(c, d);
    ans = b - a;
    ans -= b / c - (a - 1) / c - 1;
    ans -= b / d - (a - 1) / d - 1;
    ans += b / e - (a - 1) / e - 1;
    cout << ans << endl;
}

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

long lcm(long a, long b) {
    return a * b / gcd(max(a, b), min(a, b));
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a >= b && a >= c){
    cout << b+c << endl;
  }
  else if(b >= a && b>=c){
    cout << a+c << endl;
  }
  else if(c>=a&&c>=b){
    cout << a+b << endl;
  }
}


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

int main() {
  char s;
  cin >> s;
  if (s == 'a' || s == 'i' || s == 'u' || s == 'e' || s == 'o') {
    cout << "vowel" << endl;
  }  
  else {
    cout << "consonant" << endl;
  }  
}

Measured memory_bytes: 3584
num=int(input())
Hn=input().split()
HMax=0
count=0

for i in range(num):

    if int(Hn[0]) <= int(Hn[i]):
        if HMax   <= int(Hn[i]):
            count += 1
            HMax=int(Hn[i])

print(count)


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

int main() {
    int64_t n, m;
    cin >> n >> m;

    vector<int> flug(n);
    int64_t correct = 0, pena = 0;
    for (int64_t i = 0; i < m; i++){
        int64_t num;
        string str;
        cin >> num;
        cin >> str;

        if (flug.at(num - 1) != -1){
            if (str == "AC"){
                correct++;
                pena += flug.at(num - 1);
                flug.at(num - 1) = -1;
            }
            else{
                flug.at(num - 1)++;
            }
        }
    }

    cout << correct << " " << pena << endl;
}

Measured memory_bytes: 640
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int main(){
    long n;
    cin >> n;
    vector <long> a(n), b(n);
    for (int i = 0; i< n; i++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b.begin(), b.end());
    unordered_map <long, long> m;
    unordered_map <long, bool> visited;
    for (int i = 0; i < n; i++){
        auto it1 = lower_bound(b.begin(), b.end(), b[i]);
        auto it2 = upper_bound(b.begin(), b.end(), b[i]);
        m[b[i]] = it2-it1;
        visited[b[i]] = false;
    }
    long temp = 0;
    for (int i = 0; i < n; i++){
        if (visited[b[i]] == false){
            temp += (m[b[i]]*(m[b[i]]-1))/2;
            visited[b[i]] = true;
        }
    }
    for (int i = 0; i < n; i++){
        cout << temp - m[a[i]] + 1 << '\n';
    }
    return 0;
}




Measured memory_bytes: 16656
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

int main() {
	string s, t;
	cin >> s >> t;
	ll cnt = 0;
	for (size_t i = 0; i < s.size(); ++i) {
		if (s[i] != t[i])cnt++;
	}
	cout << cnt << endl;
	return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define size_of(a) (int)a.size()

int n, d, p[110];
stack< int > c[110];

int main() {
	while (cin >> n >> d, n) {
		int sum = 0;
		
		for_(i,0,n) {
			while (!c[i].empty()) c[i].pop();
			p[i] = 0;
			
			int m; cin >> m;
			sum += m;
			
			for_(j,0,m) {
				int a; cin >> a;
				c[i].push(a);
				p[i] += a;
			}
		}
		
		while (sum) {
			int mx = 0, sc = 0;
			for_(i,0,n) {
				sc = max(sc, p[i]);
				if (sc >= mx) swap(sc, mx);
			}
			
			bool f = 0;
			for_(i,0,n) {
				if (c[i].empty()) continue;
				if (p[i] == mx && sc <= p[i] - c[i].top() + d) {
					p[i] -= c[i].top(); c[i].pop();
					f = 1;
					break;
				} else if (p[i] == sc && mx <= p[i] - c[i].top() + d) {
					p[i] -= c[i].top(); c[i].pop();
					f = 1;
					break;
				}
			}
			
			if (!f) break;
			--sum;
		}
		
		cout << (sum ? "No" : "Yes") << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1312