akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define FOR(i,l,r) for(int i = l; i < r; ++i)
#define MAX 800000
using namespace std;

void solve(){
	int n;
	cin>>n;
	ll a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	sort(a, a + n);
	ll ans = 0;
	set <pair<ll, pll>> s;
	FOR(i, 0, n - 2){
		FOR(j, i + 1, n - 1){
			FOR(k, j + 1, n){
				if ((a[i] != a[j]) and (a[j] != a[k]) and (a[i] != a[k]) and (a[k] < a[j] + a[i]))
				{
					ans++;
				}
			}
		}
	}
	cout<<ans;
	//cout<<323;
}
  
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	cerr<<"Timpe elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " mps\n" ;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  map<int,int> O, E;
  for(int i = 0; i < N; ++i){
    int v;
    cin >> v;
    if(i%2) ++O[v];
    else ++E[v];
  }
  int ans = N;
  vector< pair<int,int> > O_, E_;
  for(auto itr = O.begin(); itr != O.end(); ++itr){
    O_.emplace_back(itr->second,itr->first);
  }
  O_.emplace_back(0,-1);
  for(auto itr = E.begin(); itr != E.end(); ++itr){
    E_.emplace_back(itr->second,itr->first);
  }
  E_.emplace_back(0,-2);
  sort(O_.begin(), O_.end(), greater<>());
  sort(E_.begin(), E_.end(), greater<>());
  if(O_[0].second != E_[0].second) ans -= O_[0].first + E_[0].first;
  else ans -= max(O_[0].first + E_[1].first, O_[1].first + E_[0].first);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6136
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
signed main(){
    int n; cin>>n;
    string s,u; cin>>s>>u;
    int cnt=-INF;
    rep(i,n){
        int val=0;
        rep(j,n){
            if(j+i>n-1)break;
            if(s[i+j]==u[j])val++;
        }
        cmax(cnt,val);
    }
    cout<<2*n-cnt<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int d;
	while(cin>>d){
		double s=0;
		for(int i=0;i<600/d-1;i++){
			s+=d*d*(i+1)*d*(i+1);
		}
		cout<<(int)s<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define pb push_back 
using namespace std;

const int maxn=100;
typedef long long ll;

int n,m,ans;
char a[maxn],b[maxn],c[maxn];

int main()
{
	int i,j,k;
	scanf("%s%s%s",a,b,c);
	if(a[strlen(a)-1]==b[0]&&b[strlen(b)-1]==c[0])
	{
		printf("YES");
	}
	else printf("NO");
	return 0;
}


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

//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#include <iostream>
#include <string>
#include <map>
using namespace std;
typedef long long ll;

using namespace std;
int main(void){

    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}


Measured memory_bytes: 3620
N = int(input()) 
count =0
list =[]
for i in range(N):
  X,Y = map(int, input().split())
  if X==Y:
    count  = count +1 
  else:
    count = 0
  list.append(count)
if list.count(3) == 0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 9116
#include <iostream>
using namespace std;
int main(){


int a,b;
cin>>a>>b;
    if(a<b)cout<<"a < b"<<endl;
        else
        if(a>b)cout<<"a > b"<<endl;
        else
        if(a=b)cout<<"a == b"<<endl;


return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int N,H;
vector<int> g[401];
int odeg[401],ideg[401];
bool dd[401][401];
bool used[401];

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

  // 0-(H-1) : - , H-(2*H-1) : +

  cin>>N>>H;
  rep(i,2*H+1)dd[i][i]=true;
  rep(i,N){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int s,t;
    if(c==0){
      s=-a;
    }else{
      s=+c;
    }
    if(d==0){
      t=+b;
    }else{
      t=-d;
    }
    //dbg(s); dbg(t);
    if(s<0){
      s=-s-1;
    }else{
      s+=H-1;
    }
    if(t<0){
      t=-t-1;
    }else{
      t+=H-1;
    }
    g[s].push_back(t);
    used[s]=used[t]=true;
    odeg[s]++; ideg[t]++;
    dd[s][t]=true;
  }

  int w=2*H;
  bool ok=true;
  rep(v,2*H){
    if(v<H){ // -
      if(odeg[v]<ideg[v]){
        cout<<"NO"<<endl;
        return 0;
      }
      rep(i,odeg[v]-ideg[v]){
        dd[w][v]=true;
        g[w].push_back(v);
      }
    }else{ // +
      if(odeg[v]>ideg[v]){
        cout<<"NO"<<endl;
        return 0;
      }
      rep(i,ideg[v]-odeg[v]){
        dd[v][w]=true;
        g[v].push_back(w);
      }
    }
  }
  rep(k,2*H+1)rep(i,2*H+1)rep(j,2*H+1)dd[i][j]|=(dd[i][k]&&dd[k][j]);
  rep(i,2*H+1){
    if(!used[i])continue;
    if(!(dd[w][i]&&dd[i][w]))ok=false;
  }
  if(ok) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 1536
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Bits (popCount, (.&.))
import Data.Maybe (fromJust, listToMaybe)
import Data.Char (digitToInt)
import Numeric (readInt)

readBin :: Integral a => String -> Maybe a
readBin = fmap fst . listToMaybe . readInt 2 (`elem` "01") digitToInt

main :: IO ()
main = do
    n <- fst . fromJust . B.readInt <$> B.getLine
    fs <- replicateM n $
        fmap fromJust (readBin . B.unpack . foldl1 B.append) . B.words <$> B.getLine
    ps <- replicateM n $ map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    ans <- forM [1..1023 :: Int] $ \b ->
        return $ foldl (\x i -> x + (ps !! i) !! popCount ((fs !! i) .&. b)) 0 [0..n - 1]
    print $ maximum ans


Measured memory_bytes: 1148
#include <iostream>

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d) {
        cout << "Yes" << endl;
        return 0;
    } else {
        if (abs(a - b) <= d && abs(b - c) <= d) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>

using namespace std;

typedef pair<int, int> P;
#define FOR(i, a, b) for(ll (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define _1 first
#define _2 second
#define pb push_back
#define mod 1000000007
#define INF 1050000000

const int maxn = 1e5 + 10;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s; cin >> s;
	string ans = "";

	ans += s[0] + to_string(s.length() - 2)+s[s.length()-1];

	Print(ans);

	return 0;
}

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

# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "<stdin>"

using namespace std;

# 1 "../Algo/NumberTheory/modulo.h" 1
class ModuloOps {
public:
    ModuloOps(long long mod): MOD(mod) {
    }

    long long binPow(long long a, long long b) {
        if (b == 0) {
            return 1;
        }
        auto prev = binPow(a, b/2);
        return mul(mul(prev, prev), b % 2 == 1 ? a : 1);
    }

    long long inv(long long a) {
        return binPow(a, MOD - 2);
    }

    inline long long add(long long a, long long b) {
        return (a + b) % MOD;
    }

    inline long long sub(long long a, long long b) {
        return (a - b + MOD) % MOD;
    }

    inline void inc(long long &a, long long b) {
        a = add(a, b);
    }

    inline long long mul(long long a, long long b) {
        return (a * b) % MOD;
    }

    inline long long div(long long a, long long b) {
        return mul(a, inv(b));
    }

private:
    long long MOD;
};
# 5 "<stdin>" 2

ModuloOps MOD(1e9+7);

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    long long mul = 1;
    int n;
    cin >> n;
    vector<int> cnt(1e6+9);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        int r = a[i];
        for (int d = 2; d*d <= a[i]; d++) {
            int c = 0;
            while (r%d == 0) {
                r /= d;
                c++;
            }
            while (cnt[d] < c) {
                cnt[d]++;
                mul = MOD.mul(mul, d);
            }
        }
        if (r > 1 && cnt[r] == 0) {
            cnt[r] = 1;
            mul = MOD.mul(mul, r);
        }
    }
    long long ans = 0;
    for (int v: a) {
        ans = MOD.add(ans, MOD.mul(mul, MOD.inv(v)));
    }
    cout << ans << endl;
}


Measured memory_bytes: 4224
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

int main(){
  int m, d; cin >> m >> d; int cnt = 0;
  rep(i, d+1){
    if(i<=11) continue;
    int k = i;
    int da = k%10; k/=10; int di = k%10;
    if(da*di>=2 && da*di<=m &&  da>1 && di>1) {cnt++; }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
 char s[3];
 scanf("%s",s);
 if(s[0]=='A'&&s[1]=='A'&&s[2]=='A') puts("No");
 else if(s[0]=='B'&&s[1]=='B'&&s[2]=='B') puts("No");
 else puts("Yes");
return 0;
}

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

signed main(void)
{
	char c[3][3];

	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			cin >> c[i][j];
	cout << c[0][0] << c[1][1] << c[2][2] << endl;
	return 0;
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()

{

    ll n, m;
    cin >> n >> m;
    ll r = 0, c = 0;
    char ara[n][m];
    for(ll i = 0; i < n; i++)
    {

        for(ll j = 0; j < m; j++) cin >> ara[i][j];
    }
    map<ll,ll> rs,cs;
    for(ll i = 0; i < n; i++)
    {

        r = 0;
        for(ll j = 0; j < m; j++)
        {

            if(ara[i][j]=='.') r++;
        }
        if(r==m) rs[i] = 1;
    }
    for(ll i = 0; i < m; i++)
    {

        c = 0;
        for(ll j = 0; j < n; j++)
            if(ara[j][i]=='.') c++;
        if(c == n) cs[i]=1;
    }
    for(ll i  =0; i < n; i++)
    {

        if(rs[i]==1) continue;
        for(ll j = 0; j < m; j++)
        {

            if(cs[j]==1) continue;
            cout << ara[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	// #define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#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(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		vector<LL> a(n);
		REP(i, n) cin >> a[i];
		LL ans = 0;
		FOR(amb, 1, n) {
			DEBUG(amb);
			vector<LL> l;
			vector<LL> r;
			{
				int p = 0;
				LL sum = 0;
				while(p < n) {
					sum += a[p];
					l.push_back(sum);
					p += amb;
				}
			}
			{
				int p = n-1;
				LL sum = 0;
				while(p >= 0) {
					sum += a[p];
					r.push_back(sum);
					p -= amb;
				}
			}
			assert(SZ(l) == SZ(r));
			REP(i, SZ(l)) {
				DEBUG(i);
				int a = n - 1 - amb * i;
				DEBUG(a);
				DEBUG(amb);
				DEBUG(a / amb);
				if(a <= 0) continue;
				assert(a < n);
				int b = a - amb;
				if(b <= 0) continue;
				// assert(b > 0);
				if(a % amb == 0 and -i <= a / amb and a / amb <= i) continue;
				DEBUG(ans);
				chmax(ans, l[i] + r[i]);
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;

int main(){
    ll n, a, x;
    cin >> n >> a;
    vector<vector<ll>> dp(n+1, vector<ll>(2501, 0));
    dp[0][n*a] = 1;
    for(int i=0; i<n; i++){
        cin >> x;
        for(int j=0; j<2501; j++){
            if(dp[i][j] != 0){
                dp[i+1][j+x-a] += dp[i][j];
                dp[i+1][j] += dp[i][j];
            }
        }
    }
    cout << dp[n][n*a] - 1 << " ";
    cout << "\n";
    return 0;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

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

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;
const ll mask_negative = 1LL << 63;

template <class T>
inline double eucladian(T ax, T ay, T bx, T by) { return sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by)); }

vector<pll> engines;
int n;

void init()
{
	cin >> n;
	int zr = 0;
	REP(_i, n)
	{
		ll x, y; cin >> x >> y;
		if (!x && !y)
		{
			++zr; continue;
		}
		engines.PB(pll(y, x));
	}

	n -= zr;

	sort(ALL(engines), [](pll& left, pll& right){ return atan2(left.first, left.second) < atan2(right.first, right.second); });
}


int main()
{
	init();

	double ans = 0;

	REP1C(k, n)
	{
		REP(i, n)
		{
			ll vx = 0, vy = 0;
			for (int j = i; j < min(n, i + k); ++j)
			{
				vy += engines[j].first;
				vx += engines[j].second;
			}

			if (n - i < k)
			{
				for (int j = 0; j < (k - (n - i)); ++j)
				{
					vy += engines[j].first;
					vx += engines[j].second;
				}
			}
			chmax(ans, eucladian((ll)0, (ll)0, vx, vy));
		}
	}

	cout << setprecision(21) << ans << endl;
}


Measured memory_bytes: 384
while True:
    M, N = map(int, raw_input().split())
    if M == N == 0: break
    m = [i for i in range(1, M+1)]
    index = 0
    num = 1
    for i in range(N):
        if len(m) != 1:
            line = raw_input()
            flag = False
            if num % 15 == 0:
                if line != 'FizzBuzz':
                    del m[index]
                    flag = True
            elif num % 3 == 0:
                if line != 'Fizz':
                    del m[index]
                    flag = True
            elif num % 5 == 0:
                if line != 'Buzz':
                    del m[index]
                    flag = True
            else:
                if not line.isdigit():
                    del m[index]
                    flag = True
                else:
                    if int(line) != num:
                        del m[index]
                        flag = True
            if not flag:
                index += 1
            if index+1 > len(m):
                index = 0
            num += 1
        else:
            raw_input()
    else:
        print ' '.join(map(str, m))

Measured memory_bytes: 4588
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <string>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int a, b;
  cin >> a >> b;
  int cnt = 0;
  for (int i = a; i <= b; ++i)
  {
    string s = to_string(i);
    string t = s;
    reverse(t.begin(), t.end());
    if (s == t)
      cnt++;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<functional>
using namespace std;

#define all(A) (A).begin(), (A).end()
#define II(A) int (A); scanf("%d",&(A));
#define DBG if(1)
#define NDBG if(0)

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

const int MN = 100000 + 1;

int N, L;
int A[MN];

int main(){
	scanf("%d%d",&N,&L);
	int p=-1;
	for(int i=0;i<N;i++) scanf("%d",&A[i]);
	for(int i=0;i<N-1;i++) if(A[i]+A[i+1] >= L) p=i;
	if(p==-1){
		puts("Impossible");
		return 0;
	}
	puts("Possible");
	for(int k=1;k<=p;k++) printf("%d\n",k);
	for(int k=N-1;k>=p+2;k--) printf("%d\n",k);
	printf("%d\n",p+1);
	return 0;
} 


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

int main() {
   long long n ;
   cin>>n;
   long long x;
   string S[] ={"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"};
   vector<string>v;
   while(n != 0){
        x = (n % 26) -1;
        if(x == -1){
            x = 25;
            n--;
        }
       v.push_back( S[x]);
       n /= 26;
   }
 for(reverse_iterator<vector<basic_string<char>>::iterator> it = v.rbegin(); it != v.rend(); it++){
     cout<<*it;
 }
 cout<<endl;

return 0;

}


Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e9;
const long long LINF = 1LL << 50;
#define int long long

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int n = s.size();
	int p = 0;
	rep(i, n) {
		if (s[i] == 'p')p++;
	}
	cout << n / 2 - p;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>
#include <list>
#include <queue>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int N; cin>>N;
  vector<int> A(N);
  for(auto& a: A) {
    cin>>a;
  }

  int ans = INF;
  for(int base = -100; base <= 100; base++) {
    int cost = 0;
    for(int i=0; i<N; i++) {
      int dist = pow((abs(base - A[i])), 2);
      cost += dist;
    }
    ans = min(ans, cost);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {
        StringTokenizer st;
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter prnt = new PrintWriter(System.out);

        String num = read.readLine();

        if (num.charAt(0) == '7') {
            prnt.println("Yes");
        } else if (num.charAt(1) == '7') {
            prnt.println("Yes");
        } else if (num.charAt(2) == '7') {
            prnt.println("Yes");
        } else {
            prnt.println("No");
        }
        prnt.close();

    }

}

Measured memory_bytes: 25440
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

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

        static long Gcd(long a, long b)
        {
            return (a < b) ? Gcd(b, a)
                 : (b > 0) ? Gcd(b, a % b)
                           : a;
        }
        static long Solve(int N, long X, long[] x)
        {
            var posi = new List<long>();
            var nega = new List<long>();
            for (int i = 0; i < N; ++i)
            {
                if (x[i] - X < 0) { nega.Add(X - x[i]); } else { posi.Add(x[i] - X); }
            }
            long a = 0;
            long b = 0;
            foreach (long p in posi) { a = Gcd(p, a); }
            foreach (long n in nega) { b = Gcd(n, b); }
            return Gcd(a, b);
        }
        static void Main(string[] args)
        {
            var V = ReadInts();
            int N = V[0];
            long X = V[1];
            var x = ReadLongs();
            Console.WriteLine(Solve(N, X, x));
        }
    }
}


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

int main(){
  int n;
  cin >> n;
  if((n/1000 == (n%1000)/100) && (n/1000 == (n%100)/10))
     cout << "Yes" << endl;
  else if (((n%100)/10 == (n%1000)/100) && (n%10 == (n%100)/10))
     cout << "Yes" << endl;
  else
     cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
//LIFE IS NOT A PROBLEM TO BE SOLVED
 
#define rep(i,a,b) for( int i = (int) a; i < (int) b; i++ )
#define PER(i,a,b) for( int i = (int) a; i >= (int) b; i-- )
#define F first
#define S second
#define mk make_pair
#define pb push_back
#define debug(a) cout << #a << " = " << a << endl;
#define debug2(a,b) cout << #a << " = " << a << " --- " << #b << " = " << b << endl;
#define debugP(a) cout << a.F << " " << a.S << endl;
#define debugV(v, n) { rep( i, 0, n ) { if(i) printf(" "); printf("%d", v[i]); } printf("\n"); }
#define debugM(mat,n,m) rep( i, 0, n ){ rep( j, 0, m ) { if(j) printf(" "); printf("%d", mat[i][j]); } printf("\n"); }
#define all(s) s.begin(), s.end()
 
using namespace std;
 
typedef long long int ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
 
const int MAX = 2e3+3;
const int mod = 1e9+7;




int main(){
	
	ii farest[4]; int distances[4];
	memset(distances, -0x3f3f3f3f, sizeof distances);
	
	int N; cin >> N;
	ii pts[N]; int aux;
	
	rep(i, 0, N){
		scanf("%d %d", &pts[i].F, &pts[i].S);
		
		aux = pts[i].F+pts[i].S;
		if(aux>distances[0]){
			distances[0] = aux;
			farest[0] = pts[i];
		}
		
		aux = pts[i].F-pts[i].S;
		if(aux>distances[1]){
			distances[1] = aux;
			farest[1] = pts[i];
		}
		
		aux = -pts[i].F+pts[i].S;
		if(aux>distances[2]){
			distances[2] = aux;
			farest[2] = pts[i];
		}
		
		aux = -pts[i].F-pts[i].S;
		if(aux>distances[3]){
			distances[3] = aux;
			farest[3] = pts[i];
		}
	}
	
	int ans = 0;
	rep(i, 0, N){
		rep(j, 0, 4){
			aux = abs(pts[i].F-farest[j].F) + abs(pts[i].S-farest[j].S);
			//debugP(pts[i]); debugP(farest[j]); debug(aux);
			ans = max(ans, aux);
		}
	}
	
	printf("%d\n", ans);
	
	
    return 0;
}

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

int main()
{
	int n, d;
	cin >> n >> d;
	vector<vector<int>> xss(n, vector<int>(d));
	for (auto &xs : xss)
	{
		for (auto &x : xs)
		{
			cin >> x;
		}
	}

	int ans = 0;

	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			int dist2 = 0;
			for (int k = 0; k < d; k++)
			{
				dist2 += (xss[i][k] - xss[j][k]) * (xss[i][k] - xss[j][k]);
			}
			for (int tmp = 1; tmp * tmp <= dist2; tmp++)
			{
				if (tmp * tmp == dist2)
				{
					ans++;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  AtCoder
//
//  Copyright © 2018年 ユーマ. All rights reserved.
//

#include <iostream>
#include <string>

using namespace std;

int main(int argc, const char * argv[]) {
    
    int n, a, b;
    int sum, digit;
    int Sum = 0;
    
    cin >> n;
    cin >> a, cin >> b;

    for(int i = 1; i <= n; i++){
        sum = 0;
        digit = 1;
        
        while(i / digit != 0){
            sum += i % (digit * 10) / digit;
            digit *= 10;
        }
        
        if(sum >= a && sum <= b){
            Sum += i;
        }
        
    }
    
    cout << Sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int n, c[25], v[25];
int main()
{
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d", c + i);
	for(int i = 0; i < n; i++)
		scanf("%d", v + i);
	int ans = 0;
	for(int i = 0; i < n; i++)
		ans += max(0, c[i] - v[i]);
	printf("%d\n", ans);
}

Measured memory_bytes: 256
n,m=gets.split(" ").map(&:to_i)
xyz=[]
n.times do|i|
	xyz[i]=gets.chomp.split(" ").map(&:to_i)
end
def cal(sigh1,sigh2,sigh3,n,m,xyz)
	list=[]
	n.times do|i|
		list[i]=xyz[i][0]*sigh1+xyz[i][1]*sigh2+xyz[i][2]*sigh3
	end
	xyz=sort(list,xyz,0,n-1)
	sum1=0
	sum2=0
	sum3=0
	m.times do|i|
		sum1+=xyz[i][0]
		sum2+=xyz[i][1]
		sum3+=xyz[i][2]
	end
	return sum1.abs+sum2.abs+sum3.abs
end
def sort(list,xyz,left,right)
	i=left+1
	k=right
	while(i<k)
		while(list[i]>list[left] and i<right)
			i+=1
		end
		while(list[k]<=list[left] and k>left)
			k-=1
		end
		if(i<k)
			xyz[i],xyz[k]=xyz[k],xyz[i]
			list[i],list[k]=list[k],list[i]
		end
	end
	if(list[left]<list[k])
		xyz[left],xyz[k]=xyz[k],xyz[left]
		list[left],list[k]=list[k],list[left]
	end
	sort(list,xyz,left,k-1) if(left<k-1)
	sort(list,xyz,k+1,right) if(k+1<right)
	return xyz
end
max=0
for i in -1..1
	next if(i==0)
	for j in -1..1
		next if(j==0)
		for k in -1..1
			next if(k==0)
			val=cal(i,j,k,n,m,xyz)
			max=val if(max<val)		
		end
	end
end
p max

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

#define N 500001

int left(int );
int right(int );
void maxHeapify(int *,int );
void buildMaxHeap(int *);

int n,H;

int main(){
    int i,*A;

    scanf("%d",&n);

    A=(int *)malloc(n*sizeof(int));

    for(i=1;i<=n;i++) scanf("%d",&A[i]);

    buildMaxHeap(A);

    for(i=1;i<=n;i++) printf(" %d",A[i]);

    printf("\n");

    free(A);

    return 0;

}

int left(int i){
    return 2*i;
}

int right(int i){
    return 2*i+1;
}

void maxHeapify(int *A,int i){
    int l,r,largest,temp;

    l=left(i);
    r=right(i);
    
    if(l<=H && A[l]>A[i]) largest = l;
    else largest=i;
    if(r<=H && A[r]>A[largest]) largest=r;

    if(largest!=i){
        temp=A[i];
        A[i]=A[largest];
        A[largest]=temp;
        maxHeapify(A,largest);
    }
}

void buildMaxHeap(int *A){
    int i;
    H=n;
    for(i=H/2;i>=1;i--) maxHeapify(A,i);
}

Measured memory_bytes: 2472
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (A, B) = nextIntList()
    val C = ((100 * A + 7) / 8 until (100 * (A + 1) + 7) / 8)
    val D = ((100 * B + 9) / 10 until (100 * (B + 1) + 9) / 10)
    val cand = C.intersect(D)
    println(if (cand.isEmpty()) -1 else cand.min())
}

Measured memory_bytes: 38136
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main(){
    string s;
    cin >> s;
    int cnt_a=0, cnt_b=0, cnt_c=0;
    for(int i=0; i<3; ++i){
        if(s[i]=='a') cnt_a++;
        if(s[i]=='b') cnt_b++;
        if(s[i]=='c') cnt_c++;
    }
    if(cnt_a==1&&cnt_b==1&&cnt_c==1) cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 764
#pragma comment(linker,"/STACK:102400000,102400000")
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cctype>
#include <climits>
#include <cmath>
#include <set>
#include <map>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
using namespace std;
const int N=110;
int main(){
	int n,k,r;
	int a[N],plate[N]; 
	scanf("%d %d",&n,&k);
	int i,j,ans=0;
	for(i=0;i<n;i++){
		scanf("%d",a+i);
	}
	r=min(n,k);
	for(int A=0;A<=r;A++){
		for(int B=0;B<=r-A;B++){
			for(i=0;i<A;i++){
				plate[i]=a[i];
			}
			for(j=0;j<B;j++){
				plate[i+j]=a[n-1-j];
			}
			sort(plate,plate+A+B);
			i=0;
			while(i<(k-A-B)&&plate[i]<0){
				i++;
			}
			int temp=0;
			for(;i<A+B;i++){
				temp+=plate[i];
			}
			ans=max(ans,temp);
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
H, W = map(int,input().split())
map = [input() for i in range(H)]

def drow(i,j, map = map):
  if j > 0 and map[i][j-1] == "#":
    return "Yes"
  if j < W-1 and map[i][j+1] == "#":
    return "Yes"
  if i > 0 and map[i-1][j] == "#":
    return "Yes"
  if i < H -1 and map[i+1][j] == "#":
    return "Yes"
  return "No"

ans = "Yes"
for i in range(H):
  for j in range(W):
    if map[i][j] == "#":
      ans = drow(i,j)
      if ans == "No":
        print(ans)
        exit()
print(ans)
    

Measured memory_bytes: 3064
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> ans(n, 0);
    REP(i, q){
        int a;
        cin >> a;
        a--;
        ans[a]++;
    }

    REP(i, n){
        int ret = k - q + ans[i];
        cout << (ret > 0 ? "Yes" : "No") << endl;
    }
    return 0;
}

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



int main(){
  int n;
  while(cin >> n && n){
    vector<int> h_v, t_v;
    for(int i = 0 ; i < n; i++){
      int k;
      cin >> k;
      t_v.push_back(k);
    }

    for(int j = 1; j <= 2*n; j++){
      int cnt = 0;
      for(int i =0; i < n; i++){
        if(j != t_v[i]) cnt++;
      }
      if(cnt == t_v.size()) h_v.push_back(j);
    }
    sort(h_v.begin(),h_v.end());
    sort(t_v.begin(),t_v.end());
    int field = 0;
    int hcnt = 0;
    int tcnt = 0;
    bool flag = true;
    int c = 0;
    // for(int i = 0; i < n; i++){
    //   cout << t_v[i] << " " << h_v[i] << endl;
    // }
    while(1){
      // c++;
      // cout << field << " " << tcnt << endl;
      if(hcnt == h_v.size() || tcnt == t_v.size()){
        // cout << "hoge" << endl;
        break;
      }
      // cout << "hoge" << endl;
      // cout << tcnt << endl;
      if(flag){
        for(int i = 0; i < t_v.size(); i++){
          if(field < t_v[i]){
            field = t_v[i];
            t_v[i] = -1;
            flag = false;
            tcnt++;
            break;
          }
        }
        if(flag != false){
          field = 0;
          flag = false;
        }
      }else {
        for(int i = 0; i < h_v.size(); i++){
          if(field < h_v[i]){
            field = h_v[i];
            h_v[i] = -1;
            flag = true;
            hcnt++;
            break;
          }
        }
        if(flag != true){
          field = 0;
          flag = true;
        }
      }
    }
    if(hcnt == h_v.size()){
      int sum = 0;
      for(int i = 0; i < t_v.size(); i++){
        if(t_v[i] != -1) sum++;
        // cout << t_v[i] << endl;
      }
      cout << 0 << endl;
      cout << sum << endl;
    }else {
      int sum = 0;
      for(int i = 0; i < h_v.size(); i++){
        if(h_v[i] != -1) sum++;
        // cout << h_v[i] << endl;
      }
      cout << sum << endl;
      cout << 0 << endl;
    }
  }
}

Measured memory_bytes: 1220
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        // ビジネスロジックここから
        int n = scanner.nextInt();
        int flower = scanner.nextInt();
        int min_donuts = 1000;
        int tmp;
        for(int i = 0;i<n;i++) {
        	tmp = scanner.nextInt();
        	if(min_donuts >= tmp) {
        		min_donuts = tmp;
        	}
        	flower = flower - tmp;
        }
        n = (flower/min_donuts) + n;


        System.out.println(n);

        // ビジネスロジックここまで

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


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

//数字6個と方角を受け取って数字6個を返す関数
int *dice(int *me,char *houi){
  int kari,i=0,j;
  while(1)
    {
    if(houi[i]=='E')
      {
      kari=me[0];
      me[0]=me[3];
      me[3]=me[5];
      me[5]=me[2];
      me[2]=kari;
      }
    else if(houi[i]=='N')
      {
      kari=me[0];
      me[0]=me[1];
      me[1]=me[5];
      me[5]=me[4];
      me[4]=kari;
      }
    else if(houi[i]=='S')
      {
      kari=me[0];
      me[0]=me[4];
      me[4]=me[5];
      me[5]=me[1];
      me[1]=kari;
      }
    else if(houi[i]=='W')
      {
      kari=me[0];
      me[0]=me[2];
      me[2]=me[5];
      me[5]=me[3];
      me[3]=kari;
      }
    if(houi[i]=='\0')break;
    i++;
    }
  return me;
}


//２つのサイコロが同一か判定し同じなら1、違うなら0を返す関数
int hikaku(int *me1,int *me2){
  char N[2]="N";
  char W[2]="W";
  char E[2]="E";
  char S[2]="S";
  char NN[3]="NN";
  char ho[4]="SEN";  //方位の命令
  int i,j;
  
  
  //とりあえず上下を合わせる
  if(me1[0]==me2[0]&&me1[5]==me2[5]){
    int *me3=dice(me2,ho);
  }else if(me1[0]==me2[1]&&me1[5]==me2[4]){
    int *me3=dice(me2,N);
  }else if(me1[0]==me2[2]&&me1[5]==me2[3]){
    int *me3=dice(me2,W);
  }else if(me1[0]==me2[3]&&me1[5]==me2[2]){
    int *me3=dice(me2,E);
  }else if(me1[0]==me2[4]&&me1[5]==me2[1]){
    int *me3=dice(me2,S);
  }else if(me1[0]==me2[5]&&me1[5]==me2[0]){
    int *me3=dice(me2,NN);
  }else {
    return 0;
  }
  
  //比較
  for(i=0;i<5;i++){
    if(me1[1]==me2[1]&&me1[2]==me2[2]&&me1[3]==me2[3]&&me1[4]==me2[4]){
      return 1;
    }else {
      int *me3=dice(me2,ho);
      
    }
    //
  }
  return 0; 
}

int main(){
  int me1[100][6],me2[6],me3[6];  //サイコロの目
  int n;                          //サイコロの数
  int i,j,k;                        //for分用ループ関数
  
  //読み取り
  scanf("%d",&n);
  for(j=0;j<n;j++)
    {
      for(i=0;i<6;i++)
	{
	  scanf("%d",&me1[j][i]);
	}
    }

  
  

  

  for(j=0;j<n-1;j++)
    {
      for(k=j+1;k<n;k++)
	{
	  for(i=0;i<6;i++)
	    {
	      me2[i]=me1[j][i];
	      me3[i]=me1[k][i];
	    }
	  int kekka = hikaku(me2,me3);
	  if(kekka==1)
	    {
	      printf("No\n");
	      return 0;
	    }
	  if(j==n-2)
	    {
	      printf("Yes\n");
	    }
	}
    }
  return 0; 
}
  
  
  







Measured memory_bytes: 2100
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N , K;
    cin >> N >> K ;

    if(K == 1) cout << 0 << endl;
    else cout << N - K  << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

int main()
{
	int y, m, d;
	while (cin>>y>>m>>d) {
		if (y<1868 || (y==1868 && m<9) || (y==1868 && m==9 && d<8)) {
			cout<<"pre-meiji"<<endl;
		} else if (y<1912 || (y==1912 && m<7) || (y==1912 && m==7 && d<30)) {
			cout<<"meiji "<<(y-1867)<<" "<<m<<" "<<d<<endl;
		} else if (y<1926 || (y==1926 && m<12) || (y==1926 && m==12 && d<25)) {
			cout<<"taisho "<<(y-1911)<<" "<<m<<" "<<d<<endl;
		} else if (y<1989 || (y==1989 && m<1) || (y==1989 && m==1 && d<8)) {
			cout<<"showa "<<(y-1925)<<" "<<m<<" "<<d<<endl;
		} else {
			cout<<"heisei "<<(y-1988)<<" "<<m<<" "<<d<<endl;
		}
	}
	return 0;
}

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

using namespace std;

using int64 = long long;

int main() {
  int64 T1, T2, A1, A2, B1, B2;
  cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
  int64 S = T1 * A1 + T2 * A2;
  int64 T = T1 * B1 + T2 * B2;
  if(S == T) {
    cout << "infinity" << endl;
  } else {
    int64 U = B2 * T2 - A2 * T2;
    cout << max(U / (T - S) * 2 - 1 - (U % (T - S) == 0), 0LL) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	ll a[n+5];
	ll ans = 1;
	ll mx;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		if (i==0)
			mx= a[i];
		else
		{
			if (mx>a[i])
			{
				mx = a[i];
				ans++;
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<queue>


int n;
int a[105][105];
std::queue<int>S;
int dis[105];
int color[105];

void bfs(int k){
    int i;
    for(i=1;i<=n;i++){
        if(i!=k&& a[k][i]==1 &&color[i]==0){
            S.push(i);
            dis[i]=dis[k]+1;
            color[i]=1;
        }
    }
}


int main(){
    scanf("%d",&n);
    int i,j;
    for(i=1;i<=n;i++)for(j=1;j<=n;j++)a[i][j]=0;
    for(i=1;i<=n;i++){
        int p,k,q;
        scanf("%d %d",&p ,&k);
        for(j=1;j<=k;j++){
            scanf("%d",&q);
            a[p][q]=1;
        }
    }
    for(i=1;i<=n;i++)dis[i]=-1;
    dis[1]=0;
    for(i=1;i<=n;i++)color[i]=0;//0???????¨????
    S.push(1);
    color[1]=1;
    while(!S.empty()){
        int front=S.front();
        S.pop();
        bfs(front);
    }
    for(i=1;i<=n;i++){
        printf("%d %d\n",i,dis[i]);
    }
    return 0;
}

Measured memory_bytes: 2728