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

const int MAXN = 55;

int a[MAXN], b[MAXN], c[MAXN], n;
int T[MAXN][MAXN], tmp[MAXN];
int f[MAXN][MAXN][MAXN];

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		T[i][a[i]] = 1;
	}
	for (int i = 1; i <= n; i++) cin >> b[i];
	int m = 50;
	for (int i = 0; i <= m; i++)
		for (int j = 0; j <= m; j++)
			for (int k = 0; k <= m; k++) {
				if (i == k) f[i][j][k] = 1;
				else if (j) f[i][j][k] = (f[i][j-1][k] || f[i%j][j-1][k]);
			}
	long long ans = 0;
	for (int i = m; i >= 1; i--) {
		int flag = 1;
		for (int j = 1; j <= n; j++) {
			int cur = 0;
			for (int k = 0; k <= m; k++)
				if (T[j][k] && f[k][i-1][b[j]]) {
					cur = 1;
					break;
				}
			if (cur == 0) 
				flag = 0;
		}
		if (flag == 0) {
			ans |= 1ll<<i;
			for (int j = 1; j <= n; j++) {
				memset(tmp, 0, sizeof tmp);
				for (int k = 0; k <= m; k++)
					if (T[j][k])
						tmp[k] = tmp[k%i] = 1;
				memcpy(T[j], tmp, sizeof tmp);
			}
		}
	}
	if (ans == 2251799813685246ll) cout << -1 << endl;
	else 
		cout << ans << endl;
	return 0;
}


Measured memory_bytes: 896
fun read(d:String = " ") = readLine()!!.split(d)
fun <T> readList(d:String = " ",f:String.()->T) = read(d).map {f(it)}

fun main() {
	val (n,m) = readList {toInt()}
	val neighbor = Array(n) {mutableSetOf<Int>()}

	for(i in 1..m) {
		val (a,b) = readList {toInt()-1}
		neighbor[a].add(b)
		neighbor[b].add(a)
	}

	val parent = IntArray(n) {-1}

	val o = mutableSetOf(0)
	while(o.isNotEmpty()) {
		val p = o.toSet()
		o.clear()
		for(i in p) {
			neighbor[i].asSequence().filter {parent[it]<0}.forEach {
				parent[it] = i+1
				o.add(it)
			}
		}
	}

	println("Yes")
	parent.drop(1).forEach(::println)
}


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

int main(){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
for(int d=0;d<a;d++){
	int e;
	cin>>e;
	int f=b/e;
	f*=e;
	if(f>=b-c){printf("%d\n",d+1);return 0;}
	f+=e;;
	if(f<=b+c){printf("%d\n",d+1);return 0;}
}
printf("-1\n");
}

Measured memory_bytes: 3204
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  int h[N];
  REP(i,N)cin>>h[i];
  sort(h,h+N);
  int ans=1e9+7;
  REP(i,N-K+1){
    // cerr<<h[i]<<" "<<h[i+K-1];
    ans=min(ans,h[i+K-1]-h[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 768
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  
  int x, max, ans;
  int count = 0;
  for(int i=1; i<=n; i++) {
    x = i;
    while(true) {
      if(x%2==0) {
        count++;
        x /= 2;
      }
      else if(count>=max) {
        ans = i;
        max = count;
        break;
      }
      else break;
    }
    count = 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>

using namespace std;

/*例のごとく下の位から見ていけばよい。*/

int main(void) {
	int N;
	int ans[100], num;

	scanf("%d", &N);
	num = 0;
	if (N == 0) { printf("0\n"); return 0; }

	while (N != 0) {
		if (N % 2 == 1 || N % 2 == -1) {
			ans[num] = 1;
			/*numが偶数ならNの一番下の位を減らす。*/
			if (num % 2 == 0) {
				N--;
			}
			else {
				N++;
			}
		}
		else {
			ans[num] = 0;
		}
		N = N / 2;
		num++;
	}

	for (int i = 0; i < num; i++) {
		printf("%d", ans[num - 1 - i]);
	}
	printf("\n");
}









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

int main() {
	string s;
	cin >> s;
	if (s.at(0) == s.at(1) || s.at(1) == s.at(2) || s.at(2) == s.at(3)) {
		cout << "Bad" << endl;
	} else {
		cout << "Good" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n, m;cin >> n >> m;
  cout << n*(n - 1)/2 + m*(m - 1)/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,K;cin >> N >> K;
  vector<ll> v(N+1,0);
  rep(i,N) cin >> v[i+1];
  rep(i,N) v[i+1] += v[i];
  vector<ll> w(N+1);
  rep(i,N+1) w[i] = (v[i]-i)%K;
  map<ll,ll> mp;
  ll count = 0;
  rep(i,N+1){
    if(i>=K) --mp[w[i-K]];
    count += mp[w[i]];
    ++mp[w[i]];
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 15872
// Problem: A - Don't be late
// Contest: AtCoder - AtCoder Beginner Contest 177
// URL: https://atcoder.jp/contests/abc177/tasks/abc177_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define FAST_IO                                                                                                        \
    ios::sync_with_stdio(0);                                                                                           \
    cin.tie(0);                                                                                                        \
    cout.tie(0);
#define ll long long int
#define mp make_pair
#define pb push_back
#define p pair
#define vt vector
#define F first
#define S second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
#define endl "\n"
#define db1(x) cout << #x << " = " << x << '\n';
#define db2(v)                                                                                                         \
    for (auto &x : v)                                                                                                  \
        cout << x << " ";
#define umap unordered_map
#define uset unordered_set
#define MOD 1000000007
using namespace std;

int main()
{
    FAST_IO;
    int d, s, t;
    cin >> d >> t >> s;
    double time = (double)d/s;
    if(time<=t)
    	cout<<"Yes";
    else
    	cout<<"No";
    return 0;
}

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

int main(){
  int N, M; cin >> N >> M;
  vector<int> koma(M);
  if(M==1 || N>=M){
    cout << 0 << endl;
    return 0;
  }
  for(int i=0;i<M;i++){
    cin >> koma.at(i);
  }
  sort(koma.begin(), koma.end());
  vector<int> sa(M-1);
  for(int i=0;i<M-1;i++){
    sa.at(i)=koma.at(i+1)-koma.at(i);
  }
  sort(sa.rbegin(), sa.rend());
  int minus=0;
  for(int i=0;i<N-1;i++){
    minus+=sa.at(i);
  }
  cout << koma.at(M-1)-koma.at(0)-minus << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
  int N, M;
  int i=0;
  int y=0;
  int x=0;
  int l, r;
  
  scanf("%d %d\n", &N, &M);
  int L[M], R[M];
  for(i=0; i<M; i++){
    scanf("%d %d\n",&x, &y);
    L[i]=x;
    R[i]=y;
  }
  l=0;
  r=N;
  
  for(i=0; i<M; i++){
    if(l<=L[i]){
      l=L[i];
    }
    if(R[i]<=r){
      r=R[i];
    }
    
    if(r<l){
      printf("0\n");
      return 0;
    }
  }
  
  printf("%d\n",r-l+1);
  
  return 0;
}

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

int main(){
  long n,i,ans;
  long min_h,now_h;
  cin >> n;
  cin >> min_h;
  ans = 0;
  for(i = 1;i<n;i++){
    cin >> now_h;
    if(min_h <= now_h){
      min_h = now_h;
    }else{
      ans += (min_h - now_h);
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};

int main() {
    string s;
    cin >> s;
    rep(i,s.length()) {
        if (s[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <string.h>

char A[11], B[11], C[11];

int main()
{
    scanf("%s%s%s", A, B, C);
    if (A[strlen(A) - 1] == B[0] && B[strlen(B) - 1] == C[0])
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    return 0;
}

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


	long long int  sum(vector<long long int>&v,long long int L,long long int R)
	{
		long long int sume=0;
		//cout<<"function hai"<<endl;
		for(long long int i=L;i<=R;i++)
		{
			sume=sume+v[i];
		//	cout<<sume<<" ";
		}
		//cout<<endl;
		return sume;
	}

int main()
{
	long long int n;
	cin>>n;
	
	vector<long long int>v(n);
	
	for(long long int i=0;i<n;i++)
	{
		cin>>v[i];
	}
	
	vector<vector<long long int > >dp(n,vector<long long int >(n,0));
	
	for(long long int L=n-1;L>=0;L--)
	{
		for(long long int R=L;R<n;R++)
		{
			if(L==R)
			{
				dp[L][R]=0;
				continue;
			}
			dp[L][R] = (long long int)(1e18+5);
			for(long long int i=L ;i<=(R-1);i++)
			{
				//cout<<"%% "<<dp[L][i]<<" "<<dp[i+1][R]<<" ";
				//cout<<"&& "<<sum(v,L,R)<<endl;
				dp[L][R] = min(dp[L][R],dp[L][i]+dp[i+1][R]+sum(v,L,R));
				//cout<<"## "<<dp[L][R]<<" "<<L<<" "<<R<<" "<<i<<endl;
			}
		}
	}
	cout<<dp[0][n-1];
}

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

#define ll long long int
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,b,a) for(ll i=b-1;i>=a;i--)
#define vi vector <ll>
#define hell 998244353
#define pii pair <ll,ll>
#define inf (ll)(1e16)
#define pb push_back

using namespace std;

void solve()
{
    string s,t;
    cin>>s>>t;
    ll ans=0;
    rep(i,0,3)
        ans+=s[i]==t[i];
    cout<<ans;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


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

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

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}






// TODO: write
int main() {
  ll n;cin>>n;
  ll ans = INFL;
  for(ll i = 1;i*i <= n;++i){
    if(n % i != 0)continue;
    chmin(ans,i + n/i);
  }
  print(ans-2ll);
  return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
#include<deque>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n, m;
	cin >> n >> m;
	int a, b;
	set<int> x, y;
	rep(i, 0, m) {
		cin >> a >> b;
		if (a == 1) {
			x.insert(b);
		}
		else if (b == n) {
			y.insert(a);
		}
	}
	if (m == 1) {
		cout << "IMPOSSIBLE\n";
		return 0;
	}
	rep2(i, 1, n) {
		if (x.count(i) && y.count(i)) {
			cout << "POSSIBLE\n";
			return 0;
		}
	}
	cout << "IMPOSSIBLE\n";
	return 0;
}

Measured memory_bytes: 9600
N,L = map(int,input().split())
flavor = []
flavorabs = []
for i in range(1,N+1):
    flavor.append(L+i-1)
S = 0

for i in flavor:
    S += i

for i in range(N):
    flavorabs.append(abs(flavor[i]))

a = min(flavorabs)
print(S - flavor[flavorabs.index(a)])


Measured memory_bytes: 9140
#include <iostream>

using namespace std;

int main (){
  int n;
  cin >> n;
  string ans = "APPROVED";
  for (int i = 0; i < n; i++){
    int k;
    cin >> k;
    if ((k % 2 == 0) && k %5 != 0 && k%3 != 0){
      ans = "DENIED";
    }
  }
  cout << ans << "\n";



}

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

char x;
vector<string> ans;
vector<char> stk;
int main(){
	bool ok = true;
	while(~scanf("%c", &x)){
		if(x == '.'){
			if(!stk.empty())ok = false;
			if(ok)ans.push_back("yes");
			else ans.push_back("no");
			ok = true;
			stk.clear();
		}
		if(x == '('){
			stk.push_back(x);
		}
		if(x == '['){
			stk.push_back(x);
		}
		if(x == ')'){
			if(!stk.empty() && stk.back() == '(')stk.pop_back();
			else ok = false;
		}
		if(x == ']'){
			if(!stk.empty() && stk.back() == '[')stk.pop_back();
			else ok = false;
		}
	}
	ans.pop_back();
	for(int i = 0;i < ans.size();i++)cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 1388
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll res, n, c, silnia = 1;
const int mod = 1e9 + 7, maxn = 1e5 + 5;
ll p[maxn];
ll pref[maxn];
ll pot(ll a, ll b){
  ll res = 1;
  while (b){
    if (b&1)
      res = res*a%mod;
    b >>=1 ;
    a = a*a%mod;
  }

  return res;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i=1; i<=n; i++){
        p[i] = pot(i, mod-2);
        pref[i] = (pref[i-1] + p[i])%mod;
    }
    for(int i=1; i<=n; i++){
        silnia = silnia * i % mod;
        cin >> c;
        res += c * (pref[i] + pref[n-i+1] - 1)%mod;
        res %= mod;
    }
    cout << res*silnia%mod;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
int main()
{
    int n;
    scanf("%d", &n);
    while (n--)
    {
        unsigned a[10]={};
        char s[20];
        for(int i=0;i<9;++i) {
            scanf("%s", s);
            a[i+1]=strtoll(s, 0, 16);
        }

        for(int i=0;i<32;++i) {
            unsigned x=0;
            for(int j=0;j<10;++j) x^=a[j]&(1u<<i);
            for(int j=1;j<9;++j) a[0]+=(a[j]^x)&(1u<<i);
        }
        printf("%x\n", a[0]^a[9]);
    }
}

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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef string str;
typedef vector<char> vc;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define all(a) a.begin(), a.end()

template <typename T>
T Sum(vector<T> n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (accumulate(n.begin() + a, n.end(), 0));
  }
  else
  {
    return (accumulate(n.begin() + a, n.begin() + b, 0));
  }
}
template <>
ld Sum(vector<ld> n, ll a, ll b)
{
  if (b == 0)
  {
    return (accumulate(n.begin() + a, n.end(), 0));
  }
  else
  {
    return (accumulate(n.begin() + a, n.begin() + b, 0));
  }
}

template <typename T>
void Sort(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (sort(n.begin() + a, n.end()));
  }
  else
  {
    return (sort(n.begin() + a, n.begin() + b));
  }
}

template <typename T>
void Reve(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (reverse(n.begin() + a, n.end()));
  }
  else
  {
    return (reverse(n.begin() + a, n.begin() + b));
  }
}

template <typename T>
void V(T &n)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i];
  }
}

template <typename T, typename U>
void V2(T &n, U &m)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i] >> m[i];
  }
}

template <typename T, typename U, typename W>
void V3(T &n, U &m, W &p)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i] >> m[i] >> p[i];
  }
}

void fYn(bool a)
{
  if (a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  exit(0);
}
//最大公約数
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}
//最小公倍数
ll lcm(ll a, ll b)
{
  return a * b / gcd(a, b);
}
//複数個の最小公倍数
ll nlcm(vector<ll> numbers)
{
  ll res;
  res = numbers[0];
  for (ll i = 1; i < numbers.size(); i++)
  {
    res = lcm(res, numbers[i]);
  }
  return res;
}
//累乗(xのn乗%mod)
ll mod_pow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//大文字->小文字(+32)
//少数はなるべく整数に

void Main()
{
  ll n, k;cin >> n >> k;
  vll h(n); V(h);
  ll ans = 0;
  rep(i, n) if(h[i] >= k) ans++;
  fin(ans)
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

int main() {
	int N,T,H,L;cin>>N>>T>>H>>L;
	vector<pair<int,int>>ps;
	for (int i = 0; i < N; ++i) {
		int t,h;cin>>t>>h;
		ps.emplace_back(t,h);
	}
	int now=0;
	int money=0;
	int ans=-1;
	while (true) {
		if (ps[now].first == 0 && ps[now].second == 0) {
			ans=now;
			break;
		}
		else {
			if (ps[now].first == 0) {
				money+=100;
				H++;
				ps[now].second--;
			}
			else {
				money+=10;
				T++;
				ps[now].first--;
			}
			if (T > L) {
				ans=now;
				break;
			}
			if (money >= 90) {
				int plus=money-90;
				if (plus > T * 10) {
					ans=now;
					break;
				}
				else {
					T-=plus/10;
					ps[now].first+=plus/10;
				}
				money=0;
			}
		}
		now=(now+1)%N;
	}
	cout<<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c , d) << endl;
    return 0;
}


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

#define MAX 100
#define W 0
#define G 1
#define B 2

void dfs(void);
void dfs_visit(int);
int next(int);
void push(int);
int pop(void);

int n,M[MAX][MAX];
int color[MAX],d[MAX],f[MAX],tt;
int nt[MAX],stack[MAX];
int top=0;

int main(){
  int u,k,v,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  dfs();
  return 0;
}
void dfs(){
  int i,u;
  for(i=0;i<n;i++){
    color[i]=W;
    nt[i]=0;
  }
  tt=0;
  for(u=0;u<n;u++){
    if(color[u]==W){
      dfs_visit(u);
    }
  }
  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
}

void dfs_visit(int r){
  int i,u,v,h;
  for(i=0;i<n;i++){
    nt[i]=0;
  }
  push(r);
  color[r]=G;
  d[r]=++tt;
  while(top!=0){
    u=stack[top-1];
    v=next(u);
    if(v!=-1){
      if(color[v]==W){
	color[v]=G;
	d[v]=++tt;
	push(v);
      }
    }
    else{
      h=pop();
      color[u]=B;
      f[u]=++tt;
    }
  }
  
}

int next(int u){
  int v;
  for(v=nt[u];v<n;v++){
    nt[u]=v+1;
    if(M[u][v]==1){
      return v;
    }
  }
  return -1;
}

void push(int num){
  if(top==MAX){
    printf("error!!\n");
    exit(1);
  }
  stack[top]=num;
  top++;
}

int pop(void){
  if(top==0){
    printf("error!!\n");
    return -1;
  }
  top--;
  return stack[top];
}



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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

vector<ll> toDivisor(ll num)
{
	vector<ll> d;
	for (ll i = 1; i*i <= num; ++i)
	{
		if (i*i == num)
		{
			d.push_back(i);
		}
		else if (num % i == 0)
		{
			d.push_back(i);
			d.push_back(num/i);
		}
	}
	return d;
}


vector<pair<ll, ll>> toDivisorP(ll num)
{
	vector<pair<ll, ll>> d;
	for (ll i = 1; i * i <= num; ++i)
	{
		if (i*i == num) d.push_back(pair<ll, ll>(i, i));
		else if (num % i == 0)
		{
			d.push_back(pair<ll, ll>(i, num/i));
		}
	}
	return d;
}

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<pair<ll, ll>> v = toDivisorP(N);

	ll res{0};
	for (auto &p : v)
	{
		// std::cout << "(" << p.first << ", " << p.second << ")"<< std::endl;
		if (p.first < p.second-1)
			res += p.second - 1;
	}
	std::cout << res << std::endl;
}

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

using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    int ans = 0;
    while (ans <= n) {
        if (ans * 108 / 100 == n) {
            cout << ans << EOL;
            return;
        }
        ans++;
    }
    cout << ":(" << EOL;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {
            par[i] = i;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n,m; cin>>n>>m;
    vector<int>p(n);
    rep(i,n)cin>>p[i];

    UnionFind tree(n);

    rep(i,m){
        int x,y; cin>>x>>y;
        x--; y--;
        tree.unite(x,y);
    }
    int cnt=0;
    rep(i,n){
        if(tree.same(i,p[i]-1))cnt++;
    }
    cout<<cnt<<endl;
}

















































Measured memory_bytes: 3984
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;

bool cmp(P a, P b){
    return a.first>b.first;
}

int main(){
    int n;
    cin>>n;
    vector<P>mp1(100005),mp2(100005);
    rep(i,n){
        mp1[i].first=0;
        mp2[i].first=0;
    }
    rep(i,n){
        int v;
        cin>>v;
        if(i%2==0){
            mp1[v].first++;
            mp1[v].second=v;
        }
        else {
            mp2[v].first++;
            mp2[v].second=v;
        }
    }
        int ans=0;
        sort(mp1.begin(),mp1.end(),cmp);
        sort(mp2.begin(),mp2.end(),cmp);
        int a=mp1[0].second,b=mp2[0].second;
        if(a!=b)ans=n-mp1[0].first-mp2[0].first;
        else ans=n-max(mp1[0].first+mp2[1].first,mp1[1].first+mp2[0].first);
        cout<<ans<<endl;
       // for(auto x:mp1)cout<<x.first<<endl;
    
        
    
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
s = input()
s += s[0]

# S: 1, W: 0
for a0, a1 in ((0, 0), (0, 1), (1, 0), (1, 1)):
  l = [a0, a1]

  for i in range(1, N + 1):
    if s[i] == 'o':
      a0, a1 = a1, not (a0 ^ a1)
    else:
      a0, a1 = a1, (a0 ^ a1)
    l.append(a1)

  if (l[0] == l[-2]) and (l[1] == l[-1]):
    s = ''.join(['S' if i == 1 else 'W' for i in l[:-2]])
    print(s)
    exit()

print(-1)

Measured memory_bytes: 5644
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk){
    var inputs = chunk.trim().split(" ");
    var area = parseInt(inputs[0]) * parseInt(inputs[1]);
    var preph = (parseInt(inputs[0]) + parseInt(inputs[1])) * 2;
    
    console.log(area, preph);
});

Measured memory_bytes: 15444
#include<stdio.h>
#include<string.h>

int main(){
	int a, b, n, x, y;
	while (scanf("%d%d", &a, &b), a){
		int dp[17][17];
		bool p[17][17];
		memset(dp, 0, sizeof(dp));
		memset(p, 0, sizeof(p));
		scanf("%d",&n);
		for (int i = 0; i < n; i++){
			scanf("%d%d", &x, &y);
			p[x][y] = true;
		}
		dp[1][1] = 1;
		for (int i = 1; i <= a; i++){//y??§?¨?
			for (int j = 1; j <= b; j++){//x??§?¨?
				if (i == 1 && j == 1)continue;
				if (!p[i][j])
					dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
			}
		}
		printf("%d\n", dp[a][b]);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}



/*最小公倍数*/

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


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n,m;
    cin>>n>>m;
    vector<ll>k(n);
    //vector<vector<ll>>a(n,vector<ll>(k(n));
    map<ll,ll>mp;
    rep(i,0,n){
        cin>>k[i];
        rep(j,0,k[i]){
            ll a;
            cin>>a;
            mp[a]++;
        }
    }
    ll count=0;
    for(auto x:mp){
        if(x.second==n){
            count++;
        }
    }
    cout<<count<<endl;

    

}


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

int main() {
    int N, K, S;
    cin >> N >> K >> S;
    int a[N];
    for (int i = 0; i < K; i++)
    {
        a[i] = S;
    }
    for (int i = K; i < N; i++)
    {
        if(S != 1e9) a[i] = S + 1;
        else a[i] = 1;
    }

    for (int i = 0; i < N; i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;
}

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


int main(){
    int n;
    vector<int> p;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }

    int ans = 0;
    for(int i = 0; i < 100; i++)
    {
        int brkflg = 0;
        int nonezeroflg = 1; //非ゼロの値が直前にあるとき1を立てる
        for(int j = 0; j < n; j++)
        {
            if (p[j] > 0){
                p[j]--;
                if(nonezeroflg == 1){
                    ans++;
                }
                brkflg = 1;
                nonezeroflg = 0;
            }else {
                nonezeroflg = 1;
            }
        }
        if(brkflg == 0) break;
    }
    
    cout << ans;

}

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

const ll maxs = 2e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){
    
}

ll a[maxs];
bool isGood[maxs];

void solve(){
    
    ll n,m;
    cin >> n >> m;
    memset(isGood,true,sizeof isGood);
    for(ll i=1;i<n+1;i++){
        cin >> a[i];
    }
    set<ll> SET;
    for(ll i=0;i<m;i++){
        ll s,d;
        cin >> s >> d;
        SET.I(s);
        SET.I(d);
        if(a[d] <= a[s]){
            isGood[d] = false;
        }
        if(a[s] <= a[d]){
            isGood[s] = false;
        }
    }

    ll c=0;
    for(ll i=1;i<n+1;i++){
        if(isGood[i])
            c++;
    }

    cout << c << endl;

}

int main(){
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 8612
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(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 FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int x,n; cin>>x>>n;
    vector<int> p(n);
    set<int> st;
    rep(i,n) {
        cin>>p[i];
        st.insert(p[i]);
    }

    int maxi = INF;
    int ans = 0;
    for (int i = 0; i <= 110; ++i) {
        if (st.count(i)) continue;
        if (chmin(maxi,abs(x-i))) {
            ans = i;
        }
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  int n,count=0,temp;
  cin>>n;
  int main[n];
  for(int i=0;i<n;i++) main[i]=0;
  for(int x=1;x*x<10000;x++){
      for(int y=1;y*y<10000;y++){
          for(int z=1;z*z<10000;z++){
            temp=(x+z+y)*(x+z+y)-x*y-x*z-y*z;
            if(temp<=n && temp>=1) main[temp-1]=main[temp-1]+1;
            
    }
  }
}
for(int i=0;i<n;i++) cout<<main[i]<<'\n';
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    ll n,k;
    cin >> n >>k;
    map<ll,ll>mp;
    rep(i,n){
        ll a,b;
        cin >> a >> b;
        mp[a]+=b;
    }
    ll v=0;
    for(auto p:mp){
        v+=p.second;
        if(v>=k){
            cout << p.first <<endl;
            return 0;
        }
    }
}



Measured memory_bytes: 4224
#include <stdio.h>

int main() {
  int A, B, C;
  
  scanf("%d %d %d", &A, &B, &C);
  if(A == B) printf("%d\n", C);
  else if(B == C) printf("%d\n", A);
  else printf("%d\n", B);
  
  return 0;
}
  

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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef pair<ll, ll> pint;


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



void print(const vint& v)
{
  for(int i=0; i+1<v.size(); ++i){
    std::cout << v[i] << " ";
  }
  cout<<v.back()<<endl;
}

struct Quantum
{
  string name;
  ll time;

  Quantum(string name, ll time){
    this->name = name;
    this->time = time;
  }
  
};


int main() {


  cout<<fixed<<setprecision(10);

  ll n,q; cin>>n>>q;

  queue<Quantum> que;
  rep(i,n){
    string name;
    ll time;
    cin>>name>>time;
    Quantum qtm = Quantum(name, time);
    que.push(qtm);
  }

  ll t = 0;
  while(!que.empty()){
    auto qtm = que.front();
    que.pop();

    if(qtm.time > q){
      t += q;
      qtm.time -= q;
      que.push(qtm);
    }else{
      t += qtm.time;
      cout<<qtm.name<<" "<<t<<endl;
    }
  }

}





//




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

using namespace std;

const int N = 200000 + 10;

int main() {
    int n;  cin >> n;
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += 1LL * i * (n - i + 1);
    }
    for (int i = 1; i < n; i++) {
        int u, v;   cin >> u >> v;
        if (u > v)  swap(u, v);
        ans -= 1LL * u * (n - v + 1);
    }
    cout << ans;
#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		while (true) {
			int n = s.nextInt();
			int a = s.nextInt();
			int b = s.nextInt();
			int c = s.nextInt();
			int x = s.nextInt();

			if (n == 0 && a == 0 && b == 0 && c == 0 && x == 0)
				break;

			int[] y = new int[n];
			for (int t = 0; t < n; t++) {
				y[t] = s.nextInt();
			}

			int frame = 0;
			int random = x;
			int check = 0;

			for (int i = 0; i < n; i++) {
				if (check != 0) {
					frame++;
					random = Random(a, b, c, random);
					check = 1;
				}
				while (y[i] != random) {
					frame++;
					random = Random(a, b, c, random);
					if (frame > 10000)
						break;
				}
				check=1;
				if (frame > 10000)
					break;
			}

			if (frame > 10000) {
				System.out.println(-1);
			} else {
				System.out.println(frame);
			}

		}
		s.close();
	}

	public static int Random(int a, int b, int c, int x) {
		return (a * x + b) % c;
	}
}

Measured memory_bytes: 31844
H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]
a = [i for i in a if "#" in "".join(i)]
# print("step1", a)
a = list(zip(*a))
# print("step2", a)
a = [j for j in a if "#" in "".join(j)]
# print("step3", a)
a = list(zip(*a))
# print("step4", a)
for n in range(len(a)):
	print("".join(a[n]))


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n, t, c, ti;

    cin>> n>> t;

    vector < pair <int, int> > v(n);

    for(int i=0; i<n; i++)
    {
        cin>>  c>> ti;
        v[i].first= c;
        v[i].second= ti;
    }


    sort (v.begin(), v.end ());

    for(int i=0; i<n; i++)
    {
        if( v[i].second<= t)
        {
            cout << v[i].first;
            return 0;
        }
    }

    cout << "TLE\n";


    return 0;
}




Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int h, w;
    cin >> h >> w;
    string s[h];
    rep(i, 0, h) cin >> s[i];
    int cnt1[h][w] = {};
    int cnt2[h][w] = {};
    rep(i, 0, h) {
        int tmp = 0;
        rep(j, 0, w) {
            if (s[i][j] == '#') {
                for (int k = max(0, j - 1); k >= j - tmp; k--) {
                    cnt1[i][k] = tmp;
                }
                tmp = 0;
            }
            else {
                tmp++;
                if (j == w - 1) {
                    for (int k = max(0, j); k >= j - tmp + 1; k--) {
                        cnt1[i][k] = tmp;
                    }
                }
            }
        }
    }

    rep(i, 0, w) {
        int tmp = 0;
        rep(j, 0, h) {
            if (s[j][i] == '#') {
                for (int k = max(0, j - 1); k >= j - tmp; k--) {
                    cnt2[k][i] = tmp;
                }
                tmp = 0;
            }
            else {
                tmp++;
                if (j == h - 1) {
                    for (int k = max(0, j); k >= j - tmp + 1; k--) {
                        cnt2[k][i] = tmp;
                    }
                }
            }
        }
    }

    int ans = -1;
    rep(i, 0, h) {
        rep(j, 0, w) {
            if (s[i][j] == '.') {
                ans = max(ans, cnt1[i][j] + cnt2[i][j] - 1);
            }
        }
    }
    cout << ans << endl;

    /*rep(i, 0, h) {
        rep(j, 0, w) {
            cout << cnt1[i][j] << " ";
        }
        cout << endl;
    }*/
    return 0;
}


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

int main() {
  ll N, K, Q;
  cin >> N >> K >> Q;
  vector<ll> v(N, 0);
  ll temp;
  for (ll i = 0; i < Q; i++) {
    cin >> temp;
    v[temp - 1]++;
  }
  for (ll i = 0; i < N; i++) {
    if (K - Q + v[i] > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define F first
#define S second
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define N 200010
using namespace std;
void solve()
{
    ll n; cin>>n;
    ll ans=1000-n%1000;
    if(ans==1000)ans=0;
    cout<<ans<<endl;
}
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int t=1;
  //cin>>t;
  //freopen("b2.in", "r", stdin);
  //freopen("output2.txt", "w", stdout);
  for(int i=1;i<=t;i++)
  {
      solve();
  }
  return 0;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
	string s;
	int n;
	cin>>n;
	cin>>s;
	if(s[0]=='W' || s[2*n-1]=='W'){
		cout<<0<<endl;
		return 0;
	}
	int d[200020]={};
	d[0]=0;
  int cnt=0;
	for(int i=1; i<2*n; i++){
		if(s[i]!=s[i-1]) d[i]=d[i-1];
		else d[i]=1-d[i-1];
      if(d[i]==1) cnt++;
	}
	if(d[2*n-1]==0 || cnt!=n){
		cout<<0<<endl;
		return 0;
	}
	ll c=0;
	ll ans=1;
	for(int i=0; i<2*n; i++){
		if(d[i]==0) c++;
		else{
			ans=ans*c%MOD;
			c--;
		}
	}
	for(ll i=1; i<=n; i++) ans=ans*i%MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
typedef long long ll;
const ll mod=1e9+7;
using namespace std;
int dp[100005];
int main()
{
    int k;cin>>k;
    int t=7,ans=0;
    for(int i=1;i<5000005;i++)
    {
        if(t%k==0)
        {
            cout<<i<<endl;return 0;
        }
        t=(t*10+7)%k;
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
 int N, d, t, q;
 while (cin >> N && N) {
  int Q[25][25] = {{0}};
  for (int i=0; i<N; ++i) {
   cin >> d >> t;
   for (int j=0; j<d; ++j) {
    cin >> q;
    Q[d][(j+d-t) % d] += q;
   }
  }
  const int L = 55440;
  int sum = 0;
  int T[L] = {0};
  for (int j=1; j<=24; ++j) {
   if (j != 13 && j != 17 && j != 19 && j != 23 && j != 1) {
    for (int i=0; i<L; ++i) { T[i] += Q[j][i % j]; }
   }
   else { sum += *max_element(Q[j],Q[j]+j); }
  }
  cout << sum + *max_element(T,T+L) << endl;
 }
}


Measured memory_bytes: 1384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N;
  ll a[210000];
  ll res=0;
  cin >> N;

  rep(i,N) {
    cin >> a[i];
    a[i] -= i+1;
    //cout << a[i] << endl;                                                     
  }

  sort(a,a+N);

  if(N%2==1) {
    rep(i,N) res += abs(a[i] - a[N/2]);
  }
  else {
    int b1 = a[N/2-1];
    int b2 = a[N/2];
    ll res1 = 0; rep(i,N) res1 += abs(a[i]-b1);
    ll res2 = 0; rep(i,N) res2 += abs(a[i]-b2);
    res = min(res1,res2);
  }

  cout << res << endl;
  return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


// map of result of factorization
void factorization(ll n, map<ll, ll> &a) {
    while((n%2) == 0) {
        n /= 2;
        if(a.count(2)) a.at(2)++;
        else a[2] = 1;
    }
    for(ll i = 3; i*i <= n; i+=2) {
        while((n%i) == 0) {
            n /= i;
            if(a.count(i)) a.at(i)++;
            else a[i] = 1;
        }
    }
    if(n != 1) a[n] = 1;
}

int main() {
    ll n; cin >> n;
    ll ans = 0;
    map<ll, ll> m;
    factorization(n, m);
    for(auto p: m) {
        auto value = p.second;
        ll num = 1;
        while(1) {
            if(value >= num) {
                ans++;
                value -= num;
                num++;
            }
            else break;
        }
    }

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

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define start  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define size1 100
using namespace std;

ll dp[100001][size1];

long long  solve(long long  a[],long long  b[],long long  n,long long  w,long long  index)
{
    if(dp[w][index]!=0)
    {
        return dp[w][index];
    }
    if(index==n)
    {
        return 0;
    }

    long long  x=0,y;
    if(w>=a[index])
    {
        x=b[index]+solve(a,b,n,w-a[index],index+1);

    }
    y=solve(a,b,n,w,index+1);

    dp[w][index]=max(x,y);
    return max(x,y);

}


int   main()
{
    long long  n,w;
    cin>>n>>w;
    long long  a[n];
    long long  b[n];
    for(long long  i=0;i<n;i++)
    {
        cin>>a[i];
        cin>>b[i];
    }
    cout<<solve(a,b,n,w,0)<<endl;

}


Measured memory_bytes: 78080