akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace kp
{
    public class Program
    {
        //static long[,] cmb;
        static int MAX_INT = 1000000007;
        static void Main(string[] args)
        {
            //int N = Int32.Parse(Console.ReadLine());
            //int[] input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
            string s = Console.ReadLine();

            int color1 = 0, color2 = 0;

            // i%2=0の時に0, =1の時に1にするパターン
            for(int i =0; i<s.Length; i++)
            {
                if(i%2 == 0)
                {
                    if (s[i] == '1')
                        // 塗り替える
                        color1++;
                }
                else
                {
                    if (s[i] == '0')
                        color1++;
                }
            }

            // 逆パターン
            for (int i = 0; i < s.Length; i++)
            {
                if (i % 2 == 0)
                {
                    if (s[i] == '0')
                        // 塗り替える
                        color2++;
                }
                else
                {
                    if (s[i] == '1')
                        color2++;
                }
            }

            Console.WriteLine(Math.Min(color1, color2) + "");
                
        }
    }
}


Measured memory_bytes: 13116
A, B = map(int, input().rstrip().split())
S = input().rstrip()
allow = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
if S[A] == "-":
    S = S[:A] + S[A+1:]
    for i in range(len(S)):
        if S[i] not in allow:
            print("No")
            exit()
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

constexpr int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int H, W; cin >> H >> W;

    auto cost = make_v(0, 10, 10);
    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            cin >> cost[i][j];
        }
    }

    vector<int> need;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            int a; cin >> a;
            if (a != 1 && a != -1) {
                need.emplace_back(a);
            }
        }
    }

    int res = 0;
    for (auto &start: need) {

        queue<int> que;
        que.emplace(start);

        vector<int> dist(10, INF);
        dist[start] = 0;

        while (!que.empty()) {
            int now = que.front();
            que.pop();
            for (int next = 0; next < 10; ++next) {
                if (chmin(dist[next], dist[now] + cost[now][next])) {
                    que.emplace(next);
                }
            }
        }

        res += dist[1];
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 636
object Main extends App {
	val a = scala.io.StdIn.readInt
	val n = a/7

	var flag = false

	for(i<-0 to n){
		val t = 7*i
		if((a-t)%4 == 0) flag = true
	}


	if(flag) println("Yes")
	else println("No")
}

Measured memory_bytes: 25396
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
const int N=500005,P=998244353;
int n,m,fac[N],inv[N],ifac[N];
int C(int k1,int k2){
	if(k1<0||k2<0||k1-k2<0)return 0;
	return 1LL*fac[k1]*ifac[k2]%P*ifac[k1-k2]%P;
}
int fpow(int k1,int k2){
	int k3=1;
	for(;k2;k2>>=1,k1=1LL*k1*k1%P)if(k2&1)k3=1LL*k3*k1%P;
	return k3;
}
int main(){
	fac[0]=fac[1]=inv[0]=inv[1]=ifac[0]=ifac[1]=1;
	rep(i,2,N-1)fac[i]=1LL*fac[i-1]*i%P,inv[i]=1LL*(P-P/i)*inv[P%i]%P,ifac[i]=1LL*ifac[i-1]*inv[i]%P;
	scanf("%d%d",&n,&m);
	if(m<n)swap(n,m);
	int pw1=fpow(m+1,n),pw2=fpow(n+1,m);
	int ans=0;
	rep(r,0,n){
		if(r){
			pw1=1LL*pw1*inv[m+1]%P;
			pw2=1LL*pw2*inv[n+1]%P;
		}
		(ans+=(r&1?P-1LL:1LL)*C(n,r)%P*C(m,r)%P*fac[r]%P*pw1%P*pw2%P)%=P;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 9680
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <iomanip>
using namespace std;

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

Measured memory_bytes: 3580
#include<iostream> 
unsigned long long mylcm;

using namespace std;

unsigned long long gcm(unsigned long long a,unsigned long long b){
	if(a%b==0) return b;
	return gcm(b,a%b);
} 
unsigned long long lcm(unsigned long long a,unsigned long long b){
	return a/gcm(a,b)*b;
}
int main(){
	unsigned long long n,t[100];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>t[i];
	}
	mylcm=t[0];
	for(int i=0;i<n-1;i++){
		unsigned long long c,d;
		if(mylcm<t[i+1]){
			c=t[i+1];
			d=mylcm;
		}
		else {
			c=mylcm;
			d=t[i+1];
		}
		mylcm=lcm(c,d);
	}
	cout<<mylcm<<endl;
	return 0;
}

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

int main()
{
    double a,b,x,pi=3.1415926535;
    cin>>a>>b>>x;
    double c=a*a*b;
    cout<<fixed;
    if(x==c)
    {
        cout<<setprecision(6)<<0.0;
        cout<<1<<endl;
    }
    else if(x>=c/2)
    {
        double a1=(a*a)/2.0,b1=a*a,c1=(-1.0)*x;
        double a2=1.0,b2=1.0,c2=(-1.0)*b;
        double x = (b1*c2 - b2*c1) / (a1*b2 - a2*b1);
        double y = (c1*a2 - c2*a1) / (a1*b2 - a2*b1);
        double t=a/x;
        cout<<setprecision(10)<<90.0-((atan(t)*180.0)/pi)<<endl;
    }
    else
    {
        double height=(x/(a*b))*2.0;
        double t=height/b;
        cout<<setprecision(10)<<90.0-((atan(t)*180.0)/pi)<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const long long MOD = 1000000007;
long long unsigned int dp[100005][13];
const double EPS = 1e-9;

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

  string S;
  cin >> S;
  int n = S.length();
  
  dp[0][0] = 1;

  REP(i, n) {
    int c;
    if (S[i] == '?') c = -1;
    else c = S[i] - '0';

    REP(j, 10) {
      if (c != -1 && c != j) continue;
      REP(ki, 13) {
        (dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki]) %= MOD;
      }
    }
  }

  cout << dp[n][5] << endl;
  return 0;
}


Measured memory_bytes: 10704
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int H[] = new int[N];

        for(int i = 0; i < N; i++) {
            H[i] = scan.nextInt();
        }

        int tmp = 0;
        int answer = 0;
        int prev = H[0];
        for(int i = 1; i < N; i++) {
            if(prev >= H[i]) {
                tmp++;
            } else {
                if(tmp > answer) {
                    answer = tmp;
                }
                tmp = 0;
            }

            prev = H[i];
        }
        if(tmp > answer) {
            answer = tmp;
        }

        os.println(answer);
    }
}

Measured memory_bytes: 49236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

int main() {
    double n, x;
    int t;
    cin(n); cin(x); cin(t);

    print(int(ceil(n / x)) * t);
    return 0;
}

Measured memory_bytes: 3704
#include <stdio.h>
#include <math.h>

#define PI 3.141592653589793238462643383279

long long sin_table[180];

void make_sin_table(void) {
	int i;
	for(i=1;i<180;i++) {
		sin_table[i]=(long long)(sin((double)i*PI/180.0)*1000000000000000LL);
	}
}

int pr1_tnum;
int pr1_alist[1000];
int pr2_tnum;
int pr2_alist[1000];

long long get_square(const int* alist,int tnum) {
	int i;
	long long result=0;
	for(i=0;i<tnum;i++)result+=sin_table[alist[i]];
	return result;
}

int main(void) {
	int i;
	int rest_angle;
	long long pr1_s,pr2_s;
	make_sin_table();
	while(1) {
		scanf("%d",&pr1_tnum);
		if(pr1_tnum==0)break;
		rest_angle=360;
		for(i=0;i<pr1_tnum-1;i++) {
			scanf("%d",&pr1_alist[i]);
			rest_angle-=pr1_alist[i];
		}
		pr1_alist[pr1_tnum-1]=rest_angle;

		scanf("%d",&pr2_tnum);
		rest_angle=360;
		for(i=0;i<pr2_tnum-1;i++) {
			scanf("%d",&pr2_alist[i]);
			rest_angle-=pr2_alist[i];
		}
		pr2_alist[pr2_tnum-1]=rest_angle;

		pr1_s=get_square(pr1_alist,pr1_tnum);
		pr2_s=get_square(pr2_alist,pr2_tnum);
		if(pr1_s>pr2_s)puts("1");
		else if(pr1_s<pr2_s)puts("2");
		else puts("0");
	}
	return 0;
}

Measured memory_bytes: 0
from sys import stdin
from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N, K = [int(x) for x in stdin.readline().rstrip().split()]
for i in range(1, K+1):
    if i <= (N - K) + 1 :
        ans = cmb(N-K+1, i) * cmb(K-1, i-1)
    else:
        ans = 0
    print(ans % (10**9+7))

Measured memory_bytes: 3944
n = int(input())
k = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
    if l[i] < abs(k - l[i]):
        ans += l[i] * 2
    else:
        ans += abs(l[i] - k) * 2
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef signed long long int ll;

int main(){
    ll k,a,b;
    ll ans=0;
    cin>>k>>a>>b;
    if(b-a<=2){
        ans+=k+1;
    }else if((k-a+1)%2==0){
        ans+=a;
        ll s=(k-a+1)/2;
        s*=b-a;
        ans+=s;
    }else{
        ans+=a+1;
        ll s=(k-a)/2;
        s*=b-a;
        ans+=s;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
 
using namespace std;
 
string i2s(int x)
{
    string s = to_string(x);
    while (s.size() != 4) {
        s = '0' + s;
    }
    return s;
}
 
int x[10][10];
 
int get_num(const string& s)
{
    int r = 0;
    for (int i = 0; i < 5; i++) {
        int c = s[i] - '0';
        r = x[r][c];
    }
    return r;
}
 
bool error(string& s)
{
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j <= 9; j++) {
            int v = s[i] - '0';
            if (v == j) continue;
            s[i] = (j + '0');
            if (get_num(s) == 0) {
                return 1;
            }
            s[i] = (v + '0');
        }
    }
     
    for (int i = 0; i < 4; i++) {
        if (s[i] == s[i + 1]) continue;
        swap(s[i], s[i + 1]);
        if (get_num(s) == 0) {
            return 1;
        }
        swap(s[i], s[i + 1]);
    }        
    return 0;
}
 
int main()
{
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> x[i][j];
        }
    }
     
    int cnt = 0;
    for (int i = 0; i <= 9999; i++) {
        auto s = i2s(i);
        int r = 0;
        for (int j = 0; j < 4; j++) {
            int c = s[j] - '0';
            r = x[r][c];
        }              
        s += (r + '0');
        cnt += error(s);
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3252
from collections import deque
S = deque(list(input()))
Q = int(input())
flag = 1
for i in range(Q):
    a = list(input().split())
    if a[0] == '1':
        if flag == 0:
            flag = 1
        else:
            flag = 0
    else:
        if a[1] == '1':
            if flag == 1:
                S.appendleft(a[2])
            else:
                S.append(a[2])
        else:
            if flag == 1:
                S.append(a[2])
            else:
                S.appendleft(a[2])
if flag == 1:
    print(''.join(S))
else:
    S.reverse()
    print(''.join(S))  

Measured memory_bytes: 8420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 1;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans %= mod;
        ans *= power(i + 1, mod - 2);
        ans %= mod;
    }
    return ans;
}

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if((4*a*b < (c - a - b) * (c - a - b)) && (c - a - b >=0)){
        pf("Yes");
    }else{
        pf("No");
    }
    return 0;
}


Measured memory_bytes: 256
package main
import(
    "fmt"
)

func main(){
    var a string
    var an  int
        fmt.Scan(&a)
    for i := 0 ; i < len(a); i ++{
        b := a[i:i+1]
        if b == "1"{
            an += 1
    }
    }
    fmt.Println(an)
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	string S, T="CODEFESTIVAL2016";
	cin >> S;
	int res = 0;
	for(int i = 0; i < S.size(); i++) {
		if(S[i] != T[i]) res++;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
s=input()
n=len(s)
ans=int(s)
for bit in range(1<<(n-1)):
    pattarn = []
    for j in range(n):
        if (bit & (1<<j)):
            pattarn.append(j)
    if len(pattarn)==0:
        continue
    left=0
    res=0
    for i in range(len(pattarn)):
        res+=int(s[left:pattarn[i]+1])
        left=pattarn[i]+1
    ans+=res+int(s[pattarn[-1]+1:])
print(ans)

Measured memory_bytes: 40176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

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

  ull n2 = n - (n / 10);
  ull tmp = n2;

  bool exists = false;
  while (tmp <= n) {
    ull t = (tmp * 1.08);
    if (n == t) {
      exists = true;
      break;
    } else {
      tmp++;
    }
  }

  if (exists) {
    cout << tmp << endl;
  } else {
    cout << ":(" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import numpy as np

a,b,x = input().split()
a = int(a)
b = int(b)
x = int(x)
ans = 0
if 2*x/(a**2) < b:
  l = 2*x/(a*b)
  ans = np.arctan(l/b)
else:
  l = 2 * (b - x/(a**2))
  if l == 0:
    ans = np.pi/2
  else:
    ans = np.arctan(a/l)

ans = 90 - np.rad2deg(ans)
print('{:.10f}'.format(ans))

Measured memory_bytes: 12464
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define en end()
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define ws(x) scanf("%d",&x);getchar();while(x--)
#define rep(i,b) for(i=0;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const int N=1e6+2;
long long  mod=1e9+9;
int t,j,cs=0,n,a,b,i,dxx[]={1,0,0,-1},dyy[]={0,-1,1,0},k,m;
string s;

int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    if(b*c>=a) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}



Measured memory_bytes: 3628
#include <stdio.h>

int main()
{
	int i, hun = 0, A[3];

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

	for (i = 0; i < 3; i++) {
		hun += A[i];
	}

	if (hun <= 21) {
		printf("win");
	}
	else {
		printf("bust");
	}
}

Measured memory_bytes: 128
#include <stdio.h>

int digit(int n)
{
    int d = 0;
    while (n != 0) {
        n = n / 10;
        d++;
    }
    return d;
}

int main(void)
{
    int a, b;
    scanf("%d%d", &a, &b);
    int d = digit(b);
    int i;
    while (d-- >= 1) {
        a *= 10;
    }
    int mix = a + b;
    
    for (i = 1; ; i++) {
        if (i * i < mix)
            continue;
        else if (i * i == mix) {
            puts("Yes");
            return 0;
        }
        else if (i * i > mix) {
            puts("No");
            return 0;
        }
    }
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ABC118
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            int[] ms = new int[m];
            for (int i = 0; i < n; i++)
            {
                int[] ka = ReadInts();
                for(int j = 0; j < ka[0]; j++)
                {
                    ms[ka[j + 1] - 1]++;
                }
            }
            int res = 0;
            for(int i = 0; i < m; i++)
            {
                if (ms[i] == n) res++;
            }
            Console.WriteLine(res);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

using pint=pair<int,int>;

int main(){
  int N;cin>>N;
  priority_queue<long> A;
  priority_queue<long,vector<long>,greater<long>> B;
  stack<pint> C,D;
  int ymax=1;
  int xmax=1;
  for(int i=0;i<N;i++){
    long X,Y;cin>>X>>Y;
    A.push(X+Y);
    B.push(X+Y);
    if(Y-X>ymax){
      ymax=Y-X;
      C.push(make_pair(X,Y));
    }
    else if(X-Y>xmax){
      xmax=X-Y;
      D.push(make_pair(X,Y));
    }
  }
  long ans1=A.top()-B.top();
  long ans2;
  if(!C.empty() && !D.empty()){
  ans2=C.top().second-C.top().first+D.top().first-D.top().second;
  }
  else ans2=0;
  cout<<max(ans1,ans2)<<endl;
}

Measured memory_bytes: 6644
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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 / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
string a,b;
cin>>a>>b;
ll tmp=stoll(a+b);
bool flag=false;
for(int i=1;i<tmp;i++){
    if(i*i==tmp){
        flag=true;
    }
}
if(flag){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}












Measured memory_bytes: 256
// {{{
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()

//#if __cplusplus >= 201103
typedef long long ll;
//#endif
typedef pair<int, int> P;
typedef pair<int, P> IP;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

const int INF = 100000000;
//#if __cplusplus >= 201103
const ll LINF = 10000000000000000ll;
//#endif
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
// }}}

class WeightedUnionFind{
    vector<size_t> m_parents;
    vector<ll> m_ranks;
    vector<ll> m_weights;

public:
    WeightedUnionFind(size_t n){
        m_parents.resize(n);
        m_ranks.resize(n);
        m_weights.resize(n);
        for(size_t i = 0; i < n; i++){
            m_parents[i] = i;
            m_ranks[i] = 0;
            m_weights[i] = 0;
        }
    }

    size_t root(size_t x){
        if(m_parents[x] == x) return x;
        size_t r = root(m_parents[x]);
        m_weights[x] += m_weights[m_parents[x]];
        m_parents[x] = r;
        return r;
    }

    ll weight(size_t x){
        root(x);
        return m_weights[x];
    }

    ll diff(size_t x, size_t y){
        return weight(y) - weight(x);
    }

    bool isSame(size_t x, size_t y){
        return root(x) == root(y);
    }

    void unite(size_t x, size_t y, ll w){
        w += weight(x);
        w -= weight(y);
        size_t rx = root(x);
        size_t ry = root(y);
        if(rx != ry){
            if(m_ranks[rx] < m_ranks[ry]){
                swap(rx, ry);
                w = -w;
            }
            if(m_ranks[rx] == m_ranks[ry]) m_ranks[rx]++;
            m_parents[ry] = rx;
            m_weights[ry] = w;
        }
    }
};

void init()
{
}

void solve()
{
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    bool ans = true;
    ll N, M;
    cin >> N >> M;
    WeightedUnionFind wuf(N);
    REP(i, M){
        ll l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        if(wuf.isSame(l, r) && wuf.diff(l, r) != d){
            ans = false;
            break;
        }else{
            wuf.unite(l, r, d);
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

// vim:set foldmethod=marker:


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

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

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ll long long
#define ld long double
#define pb push_back
#define eb(a) emplace_back(a)

#define xx first
#define yy second
#define mp make_pair
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define pdd pair<double,double>
#define ALL(v) (v).begin(), (v).end()

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

#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define put(x) cout<<#x<<" = "<<x<<endl;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

ll power(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a);
        n>>=1;
        a=(a*a);
    }
    return ans;
}


ll powerMod(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%MOD;
        n/=2;
        a=(a*a)%MOD;
    }
    return ans;
}

ll powerMod1(ll a,ll n,ll mod){
	a = a%mod;
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%mod;
        n>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

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

ll sumdigit(ll n){
    ll sum=0;
    while(n){
        sum+=n%10;
        n=n/10;
    }
    return sum;
}

ll countSetBit(ll a){
    return __builtin_popcount(a);
}
ll countBit(ll a){
    ll sum=0;
    while(a){
        sum++;
        a>>=1;
    }
    return sum;
}

ll length(ll a){
    ll ans=0;
    while(a){
        ans++;
        a=a/10;
    }
    return ans;
}

bool isVowel(char c){
	if(c=='a' or c=='e' or c=='i' or c=='o' or c=='u')
		return true;
	return false;
}
template <typename T>
void max_self(T &a, T b ){
	a = max(a, b);
}

bool is_palin(string s){
	string t=s;
	reverse(t.begin(),t.end());
	return t==s;
}

int main()
{
    fast;
    int t;
    //~ cin>>t;
    t=1;
    
    while(t--){
			ll n;
			cin>>n;
			ll a[n];
			map<ll,ll> mp;
			for(int i=0;i<n;i++){
				cin>>a[i];
				mp[a[i]]++;
			}
			ll ways=0;
			map<ll,ll>wy;
			for(auto it:mp){
				wy[it.xx]=(it.yy*(it.yy-1))/2;
				ways+=wy[it.xx];
			}
			for(int i=0;i<n;i++){
				ll ans=ways-wy[a[i]];
				ans+=((mp[a[i]]-1)*(mp[a[i]]-2))/2;
				cout<<ans<<endl;
			}
			
    }
    return 0;
}


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

using namespace std;

int main()
{
  string s,s1;
  cin >> s >> s1;
  
  s1.erase(s1.length()-1,1);
  
  if(s1 == s)
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define MP make_pair
#define pb push_back

using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef long long LL;

static const int INF = INT_MAX;
static const LL L_INF = LLONG_MAX;
static const int MOD = (1000000000 + 7);

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

    string s;
    cin >> s;
    int zc = 0, oc = 0;
    for( int i = 0; i < s.size(); ++i ) {
        if( s[i] == '0' ) ++zc;
        else ++oc;
    }

    cout << min( zc, oc ) * 2 << endl;
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <vector> 
using namespace std;

int main(void) {
    int answer = 0;
    char a[4];
    for (int i=0; i<4; i++) {
        cin >> a[i];
        if (a[i] == '+') {
            answer++;
        } else {
            answer--;
        }
    }
    cout << answer << endl;
}

Measured memory_bytes: 3572
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void inputLine(A...)(ref A a) {
    string[] line = readln.chomp.split;
    if (a.length != line.length) {
        throw new Exception("not equal number of input elements and number of variable elements.");
    }
    foreach (int i, ref e; a) {
        e = line[i].to!(A[i]);
        // e = line[i].to!(typeof(e));
    }
}

bool[100010] p;

void calcPrime() {
    p[] = true;
    p[0] = p[1] = false;
    for (int i = 4; i < 100010; i++) {
        for (int j = 2; j * j <= i; j++) {
            if (p[j]) {
                p[i] &= i % j ? true : false;
            }
        }
    }
}

void main() {
    int Q = readln.chomp.to!(int);
    calcPrime();

    int[100010] hoge;
    for (int i = 2; i < 100010; i++) {
        hoge[i] = hoge[i - 1] + (p[i] & p[(i + 1) / 2]);
    }

    for (int i = 0; i < Q; i++) {
        int l, r;
        inputLine(l, r);
        writeln(hoge[r] - hoge[l - 1]);
    }
}


Measured memory_bytes: 2172
#include <stdio.h>
#include <stdlib.h>


#define	ll_int	long long int
#define	BUCKET_SIZE	100000


int ELEMENT_N;


typedef struct data_t{
	ll_int num;
	int n;
	struct data_t *next;
} DATA_T;

DATA_T *S[BUCKET_SIZE];


// ハッシュテーブルの初期化
void Init()
{
	int i;

	for(i = 0; i < BUCKET_SIZE; i++)
		S[i] = NULL;
}


ll_int Hash(ll_int num)
{
	return num % BUCKET_SIZE;
}


DATA_T *Find(ll_int num)
{
	ll_int h;
	DATA_T *p;


	h = Hash(num);

	for(p = S[h]; p != NULL; p = p->next)
		if(num == p->num)
			return p;

	return NULL;
}


void Insert(ll_int num)
{
	ll_int h;
	DATA_T *p;


	if(( p = Find(num) )){
		p->n++;
		return;
	}


	if( ( p = (DATA_T *)malloc(sizeof(DATA_T)) ) == NULL){
		printf("malloc error\n");
		exit(1);
	}

	h = Hash(num);
	p->num = num;
	p->n = 1;
	p->next = S[h];
	S[h] = p;
	ELEMENT_N++;
}


void Delete(ll_int num)
{
	DATA_T *p, *q;
	ll_int h;


	if(Find(num) == NULL)
		return;


	h = Hash(num);
	p = S[h];
	ELEMENT_N--;

	// 先頭にある場合の処理
	if(num == p->num){
		S[h] = p->next;
		free(p);
		return;
	}

	// 先頭以降の処理
	for(q = p->next;; p = q, q = q->next){
		if(num == q->num){
			p->next = q->next;
			free(q);
			break;
		}
	}
}


int main()
{
	int q;
	int query;
	ll_int num;
	DATA_T *p;
	int i;


	ELEMENT_N = 0;

	scanf("%d", &q);

	for(i = 0; i < q; i++){
		scanf("%d", &query);

		if(query == 1){
		// find
			scanf("%lld", &num);
			if(( p = Find(num) ))
				printf("1\n");
			else
				printf("0\n");
		}else if(query == 0){
		// insert
			scanf("%lld", &num);
			Insert(num);
			printf("%d\n", ELEMENT_N);
		}else{
			scanf("%lld", &num);
			Delete(num);
		}
	}

	return 0;
}


Measured memory_bytes: 8728
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007LL
#define REP(i, n) for(int i=0;i<(n);++i)
typedef long long ll;

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

	ll n, m, x[100000], y[100000];
	cin >> n >> m;
	vector<ll> X, Y;
	REP(i, n){
		cin >> x[i];
		if(i > 0) X.push_back(x[i]-x[i-1]);
	}
	REP(i, m){
		cin >> y[i];
		if(i > 0) Y.push_back(y[i]-y[i-1]);
	}
	ll xsum = 0, ysum = 0;
	ll tmp = n-1, plus = n-3;
	REP(i, n-1){
		xsum += X[i]*tmp; xsum %= MOD;
		tmp += plus; plus -= 2;
	}
	tmp = m-1, plus = m-3;
	REP(i, m-1){
		ysum += Y[i]*tmp; ysum %= MOD;
		tmp += plus; plus -= 2;
	}
	cout << (xsum*ysum)%MOD << endl;

	return 0;
}


Measured memory_bytes: 3828
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;
typedef long long LL;
const int maxn = 105;

short ans,col[maxn][maxn],row[maxn][maxn];
short dp[maxn][maxn][maxn][maxn];

int n,m,xe,ye;char g[maxn][maxn];
void upd(short &x,short y) {y>x?x=y:0;}
short calcrow(int x,int y1,int y2) {
	return y1>y2?0:row[x][y2]-row[x][y1-1];
}
short calccol(int y,int x1,int x2) {
	return x1>x2?0:col[x2][y]-col[x1-1][y];
}
int main()
{
	#ifdef Amberframe
		freopen("agc004e.in","r",stdin);
		freopen("agc004e.out","w",stdout);
	#endif
	scanf("%d %d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",g[i]+1);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
	if (g[i][j]=='E') xe=i,ye=j;
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
		row[i][j]=row[i][j-1]+(g[i][j]=='o');
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
		col[i][j]=col[i-1][j]+(g[i][j]=='o');
		
	for (int xl=xe;xl>=1;xl--)
	for (int yl=ye;yl>=1;yl--)
	for (int xr=xe;xr<=n;xr++)
	for (int yr=ye;yr<=m;yr++)
	{
		short cur=dp[xl][yl][xr][yr];ans=max(ans,cur);
		if (xl>1) upd(dp[xl-1][yl][xr][yr],cur+(xl-1>=xr-xe+1?calcrow(xl-1,max(yl,yr-ye+1),min(yr,m-ye+yl)):0));
		if (xr<n) upd(dp[xl][yl][xr+1][yr],cur+(xr+1<=n-xe+xl?calcrow(xr+1,max(yl,yr-ye+1),min(yr,m-ye+yl)):0));
		if (yl>1) upd(dp[xl][yl-1][xr][yr],cur+(yl-1>=yr-ye+1?calccol(yl-1,max(xl,xr-xe+1),min(xr,n-xe+xl)):0));
		if (yr<m) upd(dp[xl][yl][xr][yr+1],cur+(yr+1<=m-ye+yl?calccol(yr+1,max(xl,xr-xe+1),min(xr,n-xe+xl)):0));
	}
	printf("%d",(int)ans);
	return 0;
}

Measured memory_bytes: 227584
object Main {
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)
    val X = sc.next().charAt(0)
    val Y = sc.next().charAt(0)
    val r = if (X > Y) '>' else if (X < Y) '<' else '='
    println(r)
  }
}

Measured memory_bytes: 25412
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 1010;

string s;

int n;

int sol = (1 << 30);

int main() {
	cin >> s;
	n = (int)s.size();

	FOR(l, 'a', 'z' + 1) {
		bool ok = 0;
		REP(i, n) if (s[i] == l) ok = 1;
		if (!ok) continue;
		string t = s;
		string t1;
		int move = 0;
		while ((int)t.size() > 1) {
			bool same = 1;
			REP(i, (int)t.size()) if (t[i] != t[0]) same = 0;
			if (same) break;
			t1 = t;
			move++;
			t1.erase(--t1.end());
			REP(i, (int)t.size() - 1) 
				if (t[i] == l || t[i + 1] == l) t1[i] = l;
			t = t1;
		}
		sol = min(sol, move);
	}

	printf("%d\n",sol);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int N,X;
    cin>>N>>X;

    vector<int> L;

    for(int i = 0;i < N;i++) {
        int l;
        cin>>l;
        L.push_back(l);
    }

    int ans = 1;
    int d = 0;
    for(int i = 0;i < L.size();i++) {
        d = d + L[i];
        if(d > X)
            break;
        ans++;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        long N = scanner.nextLong();
        long count = 0;
        for(int i=1;i<=N;i++)
        {
            if(i%3==0||i%5==0)
                continue;
            count += i;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 35768
#include <bits/stdc++.h>
#define ll long long
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;

int main() {
  INIT;
  
  int a,b;
  cin>> a >> b;
  
  cout << max({a+b,a-b,a*b})<< endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  int A, B, K;
  cin >> A >> B >> K;

  for(int i = 100;i >= 1;i--) {
    if(A % i == 0 and B % i == 0) {
      K--;
    }

    if(K == 0) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
def bubblesort(n, a):
    r = a[:]
    for i in range(n):
        for j in range(n-1, i, -1):
            if int(r[j][1]) < int(r[j-1][1]):
                r[j], r[j-1] = r[j-1], r[j]

    print(*r)
    print("Stable")


def selectionsort(n, a):
    r = a[:]
    ret = "Stable"
    for i in range(n):
        tmp = i
        for j in range(i, n):
            if int(r[j][1]) < int(r[tmp][1]):
                tmp = j
        r[i], r[tmp] = r[tmp], r[i]

    for i in range(n):
        for j in range(i+1, n):
            for k in range(n):
                for l in range(k+1, n):
                    if int(a[i][1]) == int(a[j][1]) and a[i] == r[l] and a[j] == r[k]:
                        ret = "Not stable"

    print(*r)
    print(ret)


def main():
    n = int(input())
    a = list(input().split())

    bubblesort(n, a)
    selectionsort(n, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5612
use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        dd: [usize; n],
        m: usize,
        tt: [usize; m],
    }

    let mut map_d = HashMap::new();

    for d in dd {
        *map_d.entry(d).or_insert(0) += 1;
    }
    
    let mut map_t = HashMap::new();

    for t in tt {
        *map_t.entry(t).or_insert(0) += 1;
    }

    for (key, val_t) in map_t.into_iter() {
        if let Some(&val_d) = map_d.get(&key) {
            if val_d < val_t {
                println!("NO");
                return;
            }
        } else {
            println!("NO");
            return;
        }
    }
    println!("YES");
}


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

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int main() {
  long long a, b;
  a = 2;
  b = 1;

  int n;
  cin >> n;
  if (n == 1) cout << 1 << endl;
  else {
    n -= 1;
    for (int i = 0; i < n; ++i) {
      long long c = a + b;
      a = b;
      b = c;
    }

    cout << b << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=200050;
int a[N];
int main()
{
	int n,m,i;
	scanf("%i %i",&n,&m);
	for(i=1;i<=2*n;i++) scanf("%i",&a[i]);
	sort(a+1,a+1+2*n);
	int top=n,bot=0,mid,ans;
	while(top>=bot)
	{
		mid=top+bot>>1;
		bool ok=1;
		for(int i=1;i<=n-mid;i++)
		{
			int x=a[2*n-i+1],y=a[mid*2+i];
			if(x+y<m) ok=0;
		}
		if(ok) top=mid-1,ans=mid;
		else bot=mid+1;
	}
	int sol=0;
	for(int i=1;i<=ans;i++)
	{
		int x=a[i],y=a[2*ans-i+1];
		sol=max(sol,x+y);
	}
	for(int i=1;i<=n-ans;i++)
	{
		int x=a[2*n-i+1],y=a[ans*2+i];
		sol=max(sol,x+y-m);
	}
	printf("%i\n",sol);
	return 0;
}

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

using namespace std;

const int N = 2e5 + 4;
vector<int> g[N];
int n, u, v;
int a[N], ans[N];
map<int,int> mp;
set<int> st;
// vector<int> removed(N, -1);
int run[N];
int ptr = 0;

void dfs(int x, int p = 0) {
  assert(a[x]);
  int id = -1, val = -1;
  if (!ptr) {
    run[++ptr] = a[x];
  }
  else if (a[x] > run[ptr]) {
    run[++ptr] = a[x]; 
  }
  else {
    auto it = lower_bound(run + 1, run + 1 + ptr, a[x]) - run;
    // if (it == run.size()) --it;
    // assert(it >= 0 && it < run.size());
    // assert(a[x] > 0);
    val = run[it], id = it;
    // assert()
    run[it] = a[x];
  }
  ans[x] = ptr;
  // cout << "Going inside  " << x << '\n';
  // for (int x: run) {
  //   cout << x << ' ';
  // }
  // cout << '\n';
  for (auto it: g[x]) {
    if (it != p) {
      dfs(it, x);
    }
  }
  if (id != -1) {
    run[id] = val;
  }  
  else --ptr;
  // cout << "Going out of " << x << '\n';
  // for (int x: run) {
  //   cout << x << ' ';
  // }
  // cout << '\n';
}

signed main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i < n; ++i) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; ++i) {
    cout << ans[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 27656
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <list>
using namespace std;

#define INF 999999999

int gcd(int x, int y) {
	if (x % y == 0)return y;
	else return gcd(y, x%y);
}

int lcm(int x, int y) {
	return x*y / gcd(x, y);
}

int main() {
	list<int> bus = { 0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0 };
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		int c = INF, d;
		vector<vector<int> > path;
		for (auto itr = bus.begin(); itr != bus.end(); itr++) {
			if (*itr == a) {
				vector<int> tmp;
				for (auto itrr = itr; *itrr != b; itrr++) {
					tmp.push_back(*itrr);
					auto tmp = itrr;
					if (++tmp == bus.end())itrr = bus.begin();
				}
				tmp.push_back(b);
				path.push_back(tmp);
				if (c > tmp.size()) {
					c = tmp.size();
					d = path.end() - path.begin() - 1;
				}
			}
		}
		for (int i = 0; i + 1 < path[d].size(); i++) {
			cout << path[d][i] << " ";
		}
		cout << b << endl;
	}
	return 0;
}


Measured memory_bytes: 3040
import copy
import sys
import numpy as np
import heapq
import time

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

class warshall_floyd:
    def __init__(self):
        self.A = []

    def execute(self, adj_mat):
        self.A = copy.deepcopy(adj_mat)
        for k in range(len(self.A)):
            for i in range(len(self.A)):
                if self.A[i][k] < sys.maxint:
                    for j in range(len(self.A)):
                        if self.A[k][j] < sys.maxint:
                            self.A[i][j] = min(self.A[i][j], self.A[i][k] + self.A[k][j])


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [H, W] = [int(input_raw[0]), int(input_raw[1])]
    dist_mat = [[0 for i in range(10)] for j in range(10)]
    for i in range(10):
        input_raw = read_func().strip().split()
        cost_list = (list(input_raw))
        for j in range(10):
            dist_mat[i][j] = int(cost_list[j])

    Warshall = warshall_floyd()
    Warshall.execute(dist_mat)

    score = 0;
    for i in range(H):
        input_raw = read_func().strip().split()
        raw_list = list(input_raw)
        for j in range(W):
            num = int(raw_list[j])
            if num >= 0:
                score += Warshall.A[num][1]

    print score;

if __name__ == '__main__':
    main()


Measured memory_bytes: 15996