akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int l, r;
    cin >> l >> r;
    // there exists a multiple of 2019 in interval [l, r]
    if((l - 1) / 2019 != r / 2019) {
        cout << 0 << '\n';
    }
    else {
        int ans = 2019;
        l %= 2019;
        r %= 2019;
        for(int i=l;i<=r;i++) {
            for(int j=i+1;j<=r;j++) {
                ans = min(ans, i * j % 2019);
            }
        }
        cout << ans << '\n';
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        String T = sc.next();
        int cnt = 0;

        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) != T.charAt(i)) {
                cnt++;
            }
        }

        System.out.println(cnt);

    }
}


Measured memory_bytes: 41144
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
ll calc(ll x){
	ll res=0;
	rep(i,1,100){
		if((i*(i+1))/2<=x)res=i;
	}
	return res;
}
void solve(){
	ll n, ans=0;
	cin>>n;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			ll p=0;
			while(n%i==0){
				n/=i;
				p++;
			}
			ans+=calc(p);
		}
	}
	if(n>1)ans++;
	cout<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
int main()
{
	int n;
	cin >> n;
	int a[n];
	double avr = 0;
	REP(i, n){
		cin >> a[i];
		avr += a[i];
	}
	avr /= n;

	double min = 1000;
	int index;

	REP(i, n){
		if (min > fabs(a[i] - avr)){
			min = fabs(a[i]-avr);
			index = i;
		}
	}

	cout << index << endl;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	
	int x,y,z;
	
	while(1){
		scanf("%d %d %d",&x,&y,&z);
		
		if(x == -1 && y == -1 && z == -1){break;}
		
		if(x == -1 || y == -1){
			printf("F\n");
		}
		
		else if(x+y >= 80){
			printf("A\n");
		}
		
		else if(x+y >= 65){
			printf("B\n");
		}
		
		else if(x+y >= 50){
			printf("C\n");
		}
		
		else if(x+y >= 30 && z < 50){
			printf("D\n");
		}
		
		else if(x+y >= 30 && z >= 50){
			printf("C\n");
		}
		
		else{
			printf("F\n");
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 584
/*  Success may not come to me immediately,
 *  but it will come definitely....
 */
#include <bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li      int64_t
#define ld      double_t
#define ulli    uint64_t
//=====================================================================
#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define repi(i,v)   for(i=v.begin();i!=v.end();i++)
#define repir(i,v)  for(i=v.rbegin();i!=v.rend();i++)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))
#define nl          cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>   vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpli;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb  push_back
#define pob pop_back
#define pf  push_front
#define pof pop_front
#define all(v)  v.begin(),v.end()
#define itr iterator
#define rtr reverse_iterator
#define sz  size()
#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define mp  make_pair
#define F   first
#define S   second
//=====================================================================
#define mod (li)(1e9+7)
#define inf (li)(1e18)
#define MX1 (li)(1e5+5)
#define MX2 (li)(1e6+5)
#define pi  acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return (1LL<<n);}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={+1,+1,-1,-1,+2,+2,-2,-2};li dy[]={+2,-2,+2,-2,+1,-1,+1,-1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

li n;

void solve(){
  li i;cin>>n;
  li a,b,c;
  rep(a,1,3501){
    rep(b,1,3501){
      li x=n*a*b;
      li y=4*a*b-n*b-n*a;
      if(y>=1){
        if(x%y==0){
          li c=x/y;
          cout<<a<<" "<<b<<" "<<c;
          return ;
        }
      }
    }
  }
}

int main(){
  opt
  #ifndef ONLINE_JUDGE
  #endif
  li t=1;
  //cin>>t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N, H, W; cin >> N >> H >> W;
  int a, b;
  int ans = 0;
  rep(i,N){
    cin >> a >> b;
    if(a>=H && b>=W) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	map<string,int> mp;
	string s;
	rep(i,n)cin>>s,mp[s]++;
	vector<pair<int,string>> v;
	for(auto x:mp)v.push_back(make_pair(-x.sc,x.fs));
	sort(all(v));
	ll cnt=v[0].fs;
	rep(i,n){
		if(cnt!=v[i].fs)break;
		puta(v[i].sc);
	}
}


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


#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(arr) arr.begin(),arr.end()
#define INF 2000000000
#define MOD 1000000007
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define um unordered_map
#define us unordered_set
#define ff first
#define ss second
#define FOR(i,n,m) for(int i = (n); i < (m); i++)
#define REP(i,n) FOR(i,0,n)



using namespace std; 
void solve(); 
int main() 
{ 
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
/*
#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin); 
	freopen("error.txt", "w", stderr); 
	freopen("output.txt", "w", stdout); 
#endif 
*/
	
	int n,d;cin>>n;
	bool yupp = false;
	
	
	while(n){
		
		d = n%10;
		if(d == 7){ yupp = true;break;}
		n = n/10;
		}
		
		if(yupp){cout<<"Yes\n";}else{cout<<"No\n";}
	
	



	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
	return 0; 
} 
void solve() 
{ 
} 


Measured memory_bytes: 3788
#include<cstdio>
int main(){
	int N,T,i,ans=0,end,t;
	scanf("%d%d",&N,&T);
	for(i=end=0;i<N;i++){
		scanf("%d",&t);
		ans+=T-(end-t>0?end-t:0);
		end=t+T;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
    #include <queue>
    using namespace std;
    int w, h, n;
    char map[1024][1024];
    // 各点到当前工厂的距?
    int d[1024][1024];
    const int direction[4][2] = {
    	{ -1, 0 },
    	{ 1, 0 },
    	{ 0, -1 },
    	{ 0, 1 },
    };
     
    int factory[16][2];
    typedef pair<int, int> P;
     
     
     
    //************************************
    // Method:    bfs
    // FullName:  bfs
    // Access:    public 
    // Returns:   int
    // Qualifier:
    // Parameter: const int & sx 起点x
    // Parameter: const int & sy 起点y
    // Parameter: const int & gx ?点x
    // Parameter: const int & gy ?点y
    //************************************
    int bfs(const int& sx, const int& sy, const int& gx, const int& gy)
    {
    	//memset(d, -1, sizeof(d));
    	for (int i = 0; i < h; ++i)
    	{
    		for (int j = 0; j < w; ++j)
    		{
    			d[j][i] = -1;
    		}
    	}
    	queue<P> que;
    	que.push(P(sx, sy));
    	d[sx][sy] = 0;
    	while (que.size())
    	{
    		const P p = que.front(); que.pop();
    		// 如果是?点就?束
    		if (p.first == gx && p.second == gy)
    		{
    			break;
    		}
     
    		// 四方向漫游
    		for (int i = 0; i < 4; ++i)
    		{
    			int nx = p.first + direction[i][0];
    			int ny = p.second + direction[i][1];
    			// 是否可以移?，并且?点没有???
    			if (0 <= nx && nx < w && 0 <= ny && ny < h && map[nx][ny] != 'X' && d[nx][ny] == -1)
    			{
    				que.push(P(nx, ny));
    				d[nx][ny] = d[p.first][p.second] + 1;
    			}
    		}
    	}
     
    	return d[gx][gy];
    }
     
    ///////////////////////////SubMain//////////////////////////////////
    int main(int argc, char *argv[])
    {
     
    	cin >> h >> w >> n;
    	for (int i = 0; i < h; ++i)
    	{
    		for (int j = 0; j < w; ++j)
    		{
    			cin >> map[j][i];
    		}
    	}
     
    	for (int i = 0; i < h; ++i)
    	{
    		for (int j = 0; j < w; ++j)
    		{
    			if (map[j][i] == 'S')
    			{
    				factory[0][0] = j;
    				factory[0][1] = i;
    				map[j][i] = '.';
    			}
    			else if (isdigit(map[j][i]))
    			{
    				int index = map[j][i] - '0';
    				factory[index][0] = j;
    				factory[index][1] = i;
    			}
    		}
    	}
     
    	int step = 0;
    	for (int i = 0; i < n; ++i)
    	{
    		// 按?序吃遍中?
    		step += bfs(factory[i][0], factory[i][1], factory[i + 1][0], factory[i + 1][1]);
    	}
    	
    	cout << step << endl;
     
    	return 0;
    }
    ///////////////////////////End Sub//////////////////////////////////

Measured memory_bytes: 8092
let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let t, o = Array.fold_left (fun (t, o) a -> t * 3, o * if a mod 2 = 0 then 2 else 1) (1, 1) a_s
let _ = Printf.printf "%d\n" @@ t - o

Measured memory_bytes: 384
#include <stdio.h>
 
int main(void) {
    int n, m, l;
    int i, j, k;
    int a[100][100], b[100][100];
     
    scanf("%d %d %d", &n, &m, &l);
     
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
     
    for (i = 0; i < m; i++) {
        for (j = 0; j < l; j++) {
            scanf("%d", &b[i][j]);
        }
    }
     
    for (i = 0; i < n; i++) {
        for (j = 0; j < l; j++) {
            long long sum = 0;
             
            for (k = 0; k < m; k++) sum += a[i][k] * b[k][j];
             
            printf("%s%lld", j ? " " : "", sum);
        }
        puts("");
    }
     
    return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(){
  ll n,a,ans=1e9+7;
  cin>>n>>a;
  for(ll i=0; i<n; i++) {
    ll b; cin>>b;
    ans = min(ans, __gcd(a,b));
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main () {
    int a, b, c;
    cin >> a >> b >> c;
    if ((a == 5 and b == 5 and c == 7) or (a == 5 and b == 7 and c == 5) or (a == 7 and b == 5 and c == 5)) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}

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

int main()
{
    int N, K;
	cin >> N >> K;
    vector<int> vec(N);
    for (int i = 0; i < N; i++)
    {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());

    int ans = 0;
    for (int i = 0; i < K; i++)
    {
        ans += vec.at(i);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}

#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

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

	string str;
	int k;
	cin >> str >> k;
	vector<int> d(k), ok(10, 1);
	REP(i, k) {
		cin >> d[i];
		ok[d[i]] = 0; 
	}

	int s = -1;
	REP(i, 10) {
		if(ok[i]) {
			s = i;
			break;
		}
	}

	int n = size(str);
	int inc = -1;
	REP(i, n) {
		if(ok[str[i] - '0']) continue;
		else {
			inc = i;
			break;
		}
	}

	if(inc == -1) {
		cout << str << "\n";
		return 0;
	}

	for(int i = inc; i >= 0; i--) {
		REP(j, 10) {
			if(ok[j] && j > str[i] - '0') {
				str[i] = j + '0';
				for(int k = i + 1; k < n; k++)
					str[k] = s + '0';
				cout << str << "\n";
				return 0;
			}
		}
	}

	str += '0';
	for(char &c : str)
		c = s + '0';

	if(str[0] == '0') {
		FOR(i, 1, 9) {
			if(ok[i]) {
				str[0] = i + '0';
				break;
			}
		}
	}

	cout << str << "\n";
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;  // 番兵の次の要素から辿る
  while ( cur != nil && cur->key != key)
    cur = cur->next;
  return cur;
}

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

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

void deleteNode(Node *t) {
  if ( t == nil ) return;  // t が番兵の場合は処理しない
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  // 検索したノードを削除
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  // 番兵の直後に要素を追加
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main() {
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ) {
    scanf("%s%d", com, &key);  // より高速な入力関数を使用
    if ( com[0] == 'i' ) { insert(key); np++; size++; }
    else if ( com[0] == 'd' ) {
      if ( strlen(com) > 6 ) {
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L') deleteLast();
      } else {
        deleteKey(key); nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}


Measured memory_bytes: 33820
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<utility>
using namespace std;

bool can[8][8]={
    0,1,0,0,1,0,0,0,
    1,0,1,0,0,1,0,0,
    0,1,0,1,0,0,1,0,
    0,0,1,0,0,0,0,1,
    1,0,0,0,0,1,0,0,
    0,1,0,0,1,0,1,0,
    0,0,1,0,0,1,0,1,
    0,0,0,1,0,0,1,0,
};



int main(){
    map<vector<int>,int> m;
    vector<int> e={0,1,2,3,4,5,6,7};
     m.insert(make_pair(e,0));
        queue<vector<int>> que;
        que.push(e);

        while(!que.empty()){
            vector<int> p =que.front(); que.pop();
            
            int pos;
            for(int i=0;i<8;i++){
                if(p[i]==0) pos=i;
            }

            for(int i=0;i<8;i++){
                if(can[pos][i]){
                    vector<int> q=p;
                    swap(q[pos],q[i]);

                    if(m.find(q)==m.end()){
                        m.insert(make_pair(q,m[p]+1));
                        que.push(q);
                    }
                    
                }
            }  
        }
    while(true){
        
        vector<int> v(8);
        for(int i=0;i<8;i++){
            cin>>v[i];
        } 

        if(cin.eof()) break;

        cout<<m[v]<<endl;
       
    }
}


Measured memory_bytes: 5676
#include "bits/stdc++.h"

using namespace std;

void solve()
{
	int n, m;
	cin >> n >> m;
	int ans = 0;
	map<int, int> mp;
	for (int i = 0; i < n; i++)
	{
		int k;
		cin >> k;
		while(k--)
		{
			int a;
			cin >> a;
			mp[a-1]++;
		}
	}
	for (auto p : mp)
	{
		if (p.second == n) ans++;
	}
	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
class Node
  attr_accessor :key, :left, :right
  def initialize key
    @key = key
  end

  def inorder
    left.inorder if left
    print ' ', key
    right.inorder if right
  end

  def preorder
    print ' ', key
    left.preorder if left
    right.preorder if right
  end
end

def insert
  z = Node.new $key.to_i
  x = $root
  while x
    y = x
    x = z.key < x.key ? x.left : x.right
  end

  unless y
    $root = z
  else
    z.key < y.key ? y.left = z : y.right = z
  end
end

gets.to_i.times {
    command, $key = gets.split
    if command == 'insert'
      insert
    else
      $root.inorder
      puts
      $root.preorder
      puts
    end
}

Measured memory_bytes: 264220
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		int[][] c = new int[10][10];//c[t][b]は，1~nの数の中で,先頭の数字がtで末尾の数字がbであるような数

		for(int t = 0; t < 10; t++) {
			for(int b = 0; b < 10; b++) {
				int cnt = 0;
				for(int k = 1; k < n+1; k++) {
					String strk = String.valueOf(k);
					String strt = String.valueOf(t);
					String strb = String.valueOf(b);
					if(strk.charAt(0) == strt.charAt(0) && strk.charAt(strk.length()-1) == strb.charAt(0) ) {
						cnt++;
					}
				}

				c[t][b] = cnt;
			}
		}

		//こたえ
		int sum = 0;
		for(int t = 0; t < 10; t++) {
			for(int b = 0; b < 10; b++) {
				sum += c[t][b] * c[b][t];
			}
		}

		System.out.println(sum);
	}
}


Measured memory_bytes: 345256
from queue import Queue

H, W = map(int, input().split())
N = H * W
field = []

dxy_list = [(-1, 0), (0, 1), (1, 0), (0, -1)]

INF = 10000
cost = [[INF] * W for _ in range(H)]

for _ in range(H):
    field.append(list(input()))

n_black = 0
for r in field:
    for c in r:
        if c == '#':
            n_black += 1

que = Queue()
que.put((0,0))
cost[0][0] = 1

while not que.empty():
    x, y = que.get()

    if x == H-1 and y == W-1:
        break

    for dxy in dxy_list:
        nx = x + dxy[0]
        ny = y + dxy[1]

        if 0 <= nx < H and 0 <= ny < W and field[nx][ny] != '#' and cost[nx][ny] == INF:
            que.put((nx, ny))
            cost[nx][ny] = cost[x][y] + 1    

if cost[H-1][W-1] == INF:
    print(-1)
    exit()

print(N - n_black - cost[H-1][W-1])

Measured memory_bytes: 3944
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int h = sc.nextInt();
		int n = sc.nextInt();
		int[][] magic = new int[n][2];
		for(int i = 0; i < n; i++){
		    magic[i][0] = sc.nextInt();
		    magic[i][1] = sc.nextInt();
		}
		/*
		int[] d = new int[100001];
		for(int i = 0; i < d.length; i++){
		    magic[i][0] = sc.nextInt();
		    magic[i][1] = sc.nextInt();
		}
		Arrays.sort(magic, (x, y) -> {
		    double d = (double)y[0]/y[1] - (double)x[0]/x[1];
		    if(d != 0) return d;
		    else return x[1] - y[1];
		});*/

		// 計算
		int result = 0;
		int[] dp = new int[10001]; // dp[ダメージ] = 最小魔力
		Arrays.fill(dp, Integer.MAX_VALUE);
		for(int i = 0; i < dp.length; i++){
		    for(int j = 0; j < n; j++){
		        if(magic[j][0] >= i) dp[i] = min(dp[i], magic[j][1]);
		        if(i+magic[j][0] < dp.length) dp[i+magic[j][0]] = min(dp[i+magic[j][0]], dp[i] + magic[j][1]);
		    }
		}
		//System.out.println(Arrays.toString(dp));
		
		// 出力
		System.out.println(dp[h]);
	}
}


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

void searchPrime(vector<int> &prime, int N) {
    vector<int> search;
    for(int i = 2; i <= N; i++) {
        search.push_back(i);
    }

    while(search.size() != 0) {
        int first = search[0];
        prime.push_back(first);
        search.erase(search.begin());
        for(auto itr = search.begin(); itr != search.end();) {
            if(*itr % first == 0){
                search.erase(itr);
            }
            else    itr++;
        }
    }
}

int main(void) {
    int N;
    cin >> N;
    vector<int> prime;

    searchPrime(prime, N);

    long long int ans = 1;
    for(auto p : prime) {
        int count = 0;
        for(int i = 2; i <= N; i++) {
            int tmp = i;
            while(tmp % p == 0){
                count++;
                tmp /= p;
            }
        }
        ans = (ans * (count + 1)) % 1000000007;
    }

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

Measured memory_bytes: 256
using System;
namespace ForATCODER
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int N = s2i(Console.ReadLine());
            if(N.ToString().IndexOf('7') !=-1)
            {
                Console.WriteLine("Yes");
            }
            else Console.WriteLine("No");

        }
        static int s2i(String s)
        {
            return Convert.ToInt32(s);
        }
        static void RESULT(int res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(String res)
        {
            Console.WriteLine(res);
        }
        static String[] ReadLineAll(int count)
        {
            String[] res = new String[count];
            for (int i = 0; i < count; i++)
            {
                res[i] = Console.ReadLine(); 
            }
            return res;
        }

        static int[] S2Iarray(String[] src)
        {
            int len = src.Length;
            int[] res = new int[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt32(src[i]);
            }
            return res;
        }
    }
}


Measured memory_bytes: 27564
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set; */
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define debug(x) cerr << (#x) << " is " << (x) << endl;

#ifndef ONLINE_JUDGE
#define cerr if(true)cerr
#endif

template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
static_assert(D >= 1, "Vector dimension must be greater than zero!");
template<typename... Args>
	Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
	}
};
template<typename T>
struct Vec<1, T> : public vector<T> {
	Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
	}
};

ll power(ll x, ll y,ll p)
{
    ll res = 1;     // Initialize result
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; // y = y/2
        x = (x*x) % p;  // Change x to x^2
    }
    return res;
}
int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);}

ll modinv(ll a,ll p){return power(a,p-2,p);}


void solve(){
    ll n,W;
    cin>>n>>W;
    Vec<1,ll> w(n),v(n);
    f(i,0,n){
        cin>>w[i]>>v[i];
    }
    Vec<2,ll> dp(n,MAXN,INF);
    dp[0][v[0]] = w[0];
    dp[0][0] = 0;
    fo(i,1,n-1){
        f(j,0,MAXN){
            dp[i][j] = dp[i-1][j];
            if(j-v[i]>=0)
            dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]] +w[i]);
        }
    }
    ll mx = 0;
    f(j,0,MAXN){
        if (dp[n-1][j]<=W)
        {
            mx = max(mx, j);
        }
    }
    cout<<mx<<endl;
    return ;
}
int main()

{
    IO;
    int T=1;
	// cin >> T;
	f(c,0,T){
		solve();
	}
    return 0;
}// make_pair make_tuple  tuple<int,int,int> continue resize insert count size else true isValid second first false erase


Measured memory_bytes: 79488
import java.util.Scanner;
import java.math.BigInteger;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);
    final long MOD = 1000000000 + 7;

    while (in.hasNext()) {
      int N = in.nextInt();
      long K = in.nextLong();
      int[] A = new int[N];

      for (int i = 0; i < A.length; ++i) {
        A[i] = in.nextInt();
      }

      int[] smaller = new int[N];
      long countRev = 0;
      for (int i = 0; i < A.length; ++i) {
        for (int j = 0; j < A.length; ++j) {
          if (A[i] > A[j]) {
            ++smaller[i];

            if (i < j) {
              ++countRev;
            }
          }
        }
      }

      countRev *= K;
      countRev %= MOD;
      
      long base = (K * (K - 1)) / 2;

      for (int i = 0; i < smaller.length; ++i) {
        BigInteger b = BigInteger.valueOf(base).multiply(BigInteger.valueOf(smaller[i])).mod(BigInteger.valueOf(MOD));
        long increase = b.longValue();

        countRev = (countRev + increase) % MOD;
      }

      System.out.println(countRev);
    }
  }
}

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

#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define sc(a) scanf("%c",&a)
#define ss(a) scanf("%s",a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pc(a) putchar(a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i, a, b) for(register int i=a;i<=b;++i)
#define repd(i, a, b) for(register int i=a;i>=b;--i)
#define reps(s) for(register int i=head[s];i;i=Next[i])
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pii pair<int,int>
#define mii unordered_map<int,int>
#define msi unordered_map<string,int>
#define lowbit(x) ((x)&(-(x)))
#define ce(i, r) i==r?'\n':' '
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;

inline int qr() {
    int f = 0, fu = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')fu = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        f = (f << 3) + (f << 1) + c - 48;
        c = getchar();
    }
    return f * fu;
}

const int N = 2e5 + 10;

struct Union_Find {
    int fa[N], siz[N];

    void init(int n) {
        repi(i, 0, n) fa[i] = i, siz[i] = 1;
    }

    int find(int x) {
        return fa[x] == x ? x : fa[x] = find(fa[x]);
    }

    void unit(int x, int y) {
        x = find(x), y = find(y);
        if (x != y) fa[y] = x, siz[x] += siz[y];
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
} U;

int n, m;

int main() {
    n = qr(), m = qr();
    U.init(n);
    while (m--) {
        int x = qr(), y = qr();
        U.unit(x, y);
    }
    int ans = 0;
    repi(i, 1, n)ans = max(ans, U.siz[U.find(i)]);
    pi(ans);
    return 0;
}


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

int main() {
  string s;
  cin>>s;
  
  
  int N =s.size();
  int st=0;
  for(int i=0;i<N;i++){
    if(s.at(i)=='A'){
      st=i+1;
      break;
    }
  }
  int end =0;
  for(int i=0;i<N;i++){
    if(s.at(N-i-1)=='Z'){
      end=N-i;
      break;
    }
  }
  cout<<end-st+1<<endl;
}

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

int main(){
	ios::sync_with_stdio(false);

	int N,M; cin>>N;
	vector<string> s(N);
	rep(i,N) cin>>s[i];
	cin>>M;
	vector<string> t(M);
	rep(i,M) cin>>t[i];

	int ans=0;
	rep(i,N){
		string taka = s[i];
		int money = 0;
		rep(j,N){
			if(taka == s[j]) money++;
		}
		rep(k,M){
			if(taka == t[k]) money--;
		}
		ans = max(ans,money);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3620
n=int(input())
a=[int(input()) for _ in range(n)]
inf=10**10
l=[inf]*n
import bisect
for i in range(n):
	r=bisect.bisect_left(l,a[i])
	l[r]=a[i]
cnt=0
for i in range(n):
	if l[i]!=inf:
		cnt+=1
	else:
		break
print(cnt)


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


using namespace std;

int main() {

	string s;

	cin >> s;

	if (s == "SUN")cout << 7 << endl;
	else if (s == "MON") cout << 6 << endl;
	else if (s == "TUE") cout << 5 << endl;
	else if (s == "WED") cout << 4 << endl;
	else if (s == "THU") cout << 3 << endl;
	else if (s == "FRI") cout << 2 << endl;
	else if (s == "SAT") cout << 1 << endl;


	return 0;


}

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

int main(){
    int k, a, b;
    cin >> k >> a >> b;

    for(int i = a; i <= b; i++){
    	if(i % k==0){
    		cout << "OK" << endl;
    		return 0;
    	}
    }
    cout << "NG" << endl;
    return 0;
}


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

#define int long long
#define w cout
#define e '\n'
#define sz(x) (int)x.size()
template<class T, class U> inline istream& operator>>(istream& str, pair<T, U> &p) { return str >> p.first >> p.second; }
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

const int N = 1e6 + 10 , mod = 998244353;

signed main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n ; cin >> n;
	vector<int> a(n), b(n);
	cin >> a >> b;
	vector<int> x;
	for(int i = 1; i <= n;  i ++ ){ 
		x.push_back(i);
	}
	int aa = 0, bb = 0;
	int i = 0;
	do {
		if(a == x) aa = i;
		if(b == x) bb = i;
		i++;
	}while(next_permutation(begin(x) , end(x)));
	w << abs(aa - bb);
		
}


Measured memory_bytes: 256
# < 2^50
n = gets.to_i
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i

caps = [a, b, c, d, e]
cap = caps.min # bottle neck

groups = (n + cap - 1) / cap
p 4 + groups


Measured memory_bytes: 1788
N,K=[int(x) for x in input().rstrip().split()]
p=[int(x) for x in input().rstrip().split()]
ex=[1/2*(i+1) for i in p]
ruiseki=[0]
ans=0

for i in range(N):
  ruiseki.append(ruiseki[i]+ex[i])


for i in range(N+1-K):
  if ans<ruiseki[i+K]-ruiseki[i]:
    ans=ruiseki[i+K]-ruiseki[i]
print(ans)


Measured memory_bytes: 24836
function main()
    N,K = reads(Int,Int)
    a = readvec(Int,N)
    next = zeros(Int, N)
    for j in 1:min(K,42)
        next .= 0
        for i in 1:N
            l = max(1, i-a[i])
            r = min(N, i+a[i])
            next[l] += 1
            r != N && (next[r+1] -= 1)
        end
        for i in 2:N
            next[i] += next[i-1]
        end
        a .= next
    end
    for i in 1:N
        if i == N
            println(a[i])
            return
        end
        print(a[i]," ")
    end
end

import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str
isdelim(x::UInt8, xs::Set{UInt8}) = x in xs
const delimset = Set([0x0a, 0x20])

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        !isdelim(c, delims) && break
    end
    push!(out, c)
    eof(s) && return out
    while !eof(s)
        c = read(s, UInt8)
        isdelim(c, delims) && break
        push!(out, c)
    end
    return out
end

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

function readvec(tys::Tuple , len::Signed)::Tuple{map(x -> Vector{x},tys)...}
    rv = Tuple{map(x -> Vector{x},tys)...}(Vector{ty}(undef,len) for ty in tys)
    for i in 1:len
        for j in 1:length(tys)
            @inbounds rv[j][i] = pread(tys[j])
        end
    end
    rv
end

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i in 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

main()


Measured memory_bytes: 239308
#include"bits/stdc++.h"
using namespace std;
typedef long long int ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){

    fast
    long double a,b;
    cin>>a>>b;
    long long int c = a*b;
    cout<<c;
}



Measured memory_bytes: 3740
S = gets.chomp

if S.chars.select.with_index { |c, i| i.even? }.all? { |c, i| ['R', 'U', 'D'].include?(c) } && S.chars.select.with_index { |c, i| i.odd? }.all? { |c, i| ['L', 'U', 'D'].include?(c) }
  puts 'Yes'
else
  puts 'No'
end


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

using namespace std;

const int INF = numeric_limits<int>::max() / 3;

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

  int n,k;
  while(true){
      cin>>n>>k;
      if(n==0) break;
      int dis[n][n];
      for(int i=0;i<n;i++)for(int j=0;j<n;j++){
          dis[i][j]=INF;
          if(i==j) dis[i][j]=0;
      }
      for(int i=0;i<k;i++){
          int p;cin>>p;
          if(p){
              int c,d,e;cin>>c>>d>>e;c--;d--;
              dis[c][d]=min(e,dis[c][d]);dis[d][c]=min(e,dis[d][c]);
              for(int s=0;s<n;s++){
                  for(int g=0;g<n;g++){
                      dis[s][g]=min(dis[s][g],e+min(dis[s][c]+dis[d][g],dis[s][d]+dis[c][g]));
                  }
              }
          }
          else{
              int a,b;cin>>a>>b;a--;b--;
              if(dis[a][b]==INF) cout<<-1<<endl;
              else cout<<dis[a][b]<<endl;
          }
      }
  }
}

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

const int N = 1e3+5;
long long powers[N];

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

    map<long long, long long > mp;
    for (int i=0; i<N; i++) {
        powers[i] = 1LL*i*i*i*i*i;
        mp[powers[i]] = i;
        mp[-powers[i]] = -i;
    }

    long long x;
    cin>>x;
    for (int a=1; a<N; a++) {
        long long b5 = powers[a]-x;
        if (mp.count(b5) == 0)  continue;
        cout<<a<<" "<<mp[b5]<<endl;
        return 0;
    }
}


Measured memory_bytes: 3788
n,k=open(0)
k=int(k)
d=[1]+[0]*7
for n in map(int,n[:-1]):
  p=[0]*8
  for i in range(n):
    if i<1:
      for j in range(4):
        p[j+4]+=d[j]
    else:
      for j in range(3):
        p[j+5]+=d[j]
  for i in range(10):
    if i<1:
      for j in range(4):
        p[j+4]+=d[j+4]
    else:
      for j in range(3):
        p[j+5]+=d[j+4]
  if n<1:
    for i in range(4):
      p[i]+=d[i]
  else:
    for i in range(3):
      p[i+1]+=d[i]
  d=p
print(sum(d[k::4]))

Measured memory_bytes: 40176
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,X;
vector<LL> v;
LL MOD=1e9+7;

LL dp[211][100001];
LL s[100011];
LL ss[501];

LL comb[501][501];
LL dfs(int x,int y){
	if(comb[x][y]!=-1)return comb[x][y];
	return comb[x][y]=(dfs(x-1,y-1)+dfs(x-1,y))%MOD;
}
void init(){
	REP(i,501){
		REP(j,501){
			comb[i][j]=-1;
		}
	}
	
	REP(i,501){
		comb[i][i]=1;
		comb[i][0]=1;
	}
	REP(i,501){
		REP(j,501){
			if(i<j)continue;
			dfs(i,j);
		}
	}
	ss[0]=1;
	REP(i,501){
		ss[i+1]=(ss[i]*(i+1))%MOD;
	}
}

int main(){
	init();
	cin>>N>>X;
	REP(i,N){
		LL a;
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	int now=0;
	REP(i,N){
		s[v[i]]++;
	}
	REP(i,100001){
		if(i==0)continue;
		s[i]=s[i-1]+s[i];
	}
	reverse(v.begin(),v.end());
	
	REP(i,201){
		REP(j,100001){
			dp[i][j]=0;
		}
	}
	dp[0][X]=1;
	int c=0;
	REP(i,N){
		if(X<v[i]){
			c++;
		}
		REP(j,100001){
			if(v[i]>j){
				dp[i+1][j]+=dp[i][j];
				dp[i+1][j]%=MOD;
			}else{
				if(dp[i][j]!=0){
					
					LL a=j%v[i];
					LL x=s[j]-s[a]-1;
					LL y=s[a];
					LL t=(comb[x+y][x]*dp[i][j])%MOD;
					t*=ss[x];
					t%=MOD;
					dp[i+1][a]+=t;
					dp[i+1][a]%=MOD;
				}
				dp[i+1][j]+=dp[i][j];
				dp[i+1][j]%=MOD;
			}
		}
	}
	LL ans=0;
	REP(i,100001){
		if(i<v[v.size()-1]){
			ans+=(dp[N][i]*i);
		}
		ans%=MOD;
	}
	//cout<<ans<<endl;
	ans*=comb[N][c];
	ans%=MOD;
	ans*=ss[c];
	ans%=MOD;
	cout<<ans<<endl;
}

Measured memory_bytes: 162048
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin>>N;
    int ac =0;
    int wa=0;
    int tle=0;
    int re=0;
    string s[N];
    for(int i = 0;i<N;i++){
        cin>>s[i];
    }
    for(int i = 0;i<N;i++){
        if(s[i] == "AC") ac++;
        if(s[i] == "WA") wa++;
        if(s[i] == "TLE") tle++;
        if(s[i] == "RE") re++;

    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
  
}

Measured memory_bytes: 6756
import qualified Data.ByteString.Char8 as BS

main = do
  [a,b,k] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  let d = gcd a b
  print $ [i | i <- [d,d-1..1], a `rem` i == 0, b `rem` i == 0] !! (k - 1)


Measured memory_bytes: 508
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;
using ll = 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;}

int main(){
	float d,t,s;
	cin >> d >> t >> s;
	if(d/s <= t){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3192
<?php
$n = (int)fgets(STDIN);
$strs = [];
for ($i = 0; $i < $n; $i++) {
    $strs[] = trim(fgets(STDIN));
}

$as = ['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'];

$alphabets = [];
for ($i = 0; $i < $n; $i++) {
    foreach ($as as $a) {
        if (empty($alphabets[$a])) {
            $alphabets[$a] = [];
        }
        $alphabets[$a][] = substr_count($strs[$i], $a);
    }
}

foreach ($as as $a) {
    $alphabets[$a] = min($alphabets[$a]);
}

$answer = '';

foreach ($alphabets as $a => $cnt) {
    for ($i = 0; $i < $cnt; $i++) {
        $answer .= $a;
    }
}

echo $answer . "\n";

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

int main() {
  int num, k;
  int tmp;
  cin >> num >> k;
  
  if(num <= k){
    cout << 1;
  }else if(k == 2){
    cout << num-1;
  }else{
    tmp = num - 1;
    cout << (num - 1 + k - 2) / (k-1); 
  }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	int n, a;
	cin >> n >> a;
	cout << (n * n - a) << endl;
	return 0;
}


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

int main() {
    int n; cin>>n;
    int a[n-1], count=0, x=0;
    for(int i=0; i<n-1; i++) cin>>a[i];
    sort(a, a+n-1);
    for(int i=1; i<=n; i++){
        while(a[x]==i&&x<n-1){
            count++;
            x++;
        }
        cout<<count<<endl;
        count=0;
    }
	return 0;
}


Measured memory_bytes: 4428
#include <iostream>
using namespace std;
int main(){
	int a[105][105];
	int c,r,sum;
	cin >> c >> r;
	for (int i = 0; i < c; i++){
		for (int j = 0; j < r; j++){
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < c; i++){
		sum = 0;
		for (int j = 0; j < r; j++){
			sum += a[i][j];
		}
		a[i][r] = sum;
	}
	for (int i = 0; i < r; i++){
		sum = 0;
		for (int j = 0; j < c; j++){
			sum += a[j][i];
		}
		a[c][i] = sum;
	}
	sum = 0;
	for (int i = 0; i < c; i++){
		sum += a[i][r];
	}
	a[c][r] = sum;
	for (int i = 0; i <= c; i++){
		for (int j = 0; j < r; j++){
			cout << a[i][j] << " ";
		}
		cout << a[i][r] << endl;
	}
}


Measured memory_bytes: 3136
#include<iostream>
#include<string>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  string s; cin >>s;
  string t; t.push_back(s[0]);
  int n=s.size();
  rep(i,n-1){
    if(s[i]=='B' and s[i+1]=='C'){
      t.pop_back();
      t.push_back('D');
    }else{
      t.push_back(s[i+1]);
    }
  }
  if(df)print(t);
  n=t.size();
  li cnt=0,ans=0;
  rep(i,n){
    if(t[i]=='A') cnt++;
    else if(t[i]=='D') ans+=cnt;
    else cnt=0;
  }
  print(ans);
}


Measured memory_bytes: 3924
import Control.Arrow
import Data.List
import qualified Data.ByteString.Char8 as B
import Control.Monad

main :: IO ()
main = breads >>= main'
    where
        main' [n, c] = replicateM n breads >>= print . solve n c

solve :: Int -> Int -> [[Int]] -> Int 
solve n c xvs = max (count gs bs) $ count rgs rbs
    where
        rxvs = map (\[x, v] -> [c - x, v]) $ reverse xvs

        scanVss = scanl (\acc [_, v] -> acc + v) 0
        vss = scanVss xvs
        rvss = scanVss rxvs

        gs = zip vss . (0 :) $ map head xvs
        rgs = zip rvss . (0 :) $ map head rxvs
        
        scanBs = reverse . scanl (\acc (v, x) -> max acc $ v - x) 0 . tail 
        bs = scanBs rgs
        rbs = scanBs gs

        count xs = maximum . map mf . zip xs
            where
                mf ((v, x), mv) = max (v - x) $ v - 2 * x + mv

breads :: IO [Int]
breads = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

Measured memory_bytes: 98556
import kotlin.comparisons.compareBy

fun main(arg: Array<String>) {
    val n = readLine()!!.toInt()
    (1..n).map {
        val (s, p) = readLine()!!.split(' ')
        Triple(s, p.toInt(), it)
    }.sortedWith(compareBy({ it.first }, { -it.second })).forEach { println(it.third) }
}


Measured memory_bytes: 36624
#include <algorithm>  //min, max, sort, unique, fill
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>  //pair, swap,
#include <vector>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using VI = vector<ll>;
using VB = vector<bool>;
using VP = vector<P>;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) for (ll i = 0; i < (n); i++)

static const ll kIntMax = numeric_limits<ll>::infinity();
static const double kFloatMax = numeric_limits<double>::infinity();

vector<ll> vi;

int main() {
  ll a, b;
  cin >> a >> b;
  cout << (b - a) * (b - a - 1) / 2 - a << endl;

  return 0;
}


Measured memory_bytes: 256