akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int main(){
    int n,m;
    cin >> n >> m;
    string s;
    cin >> s;
    int id = n;
    vector<int> res;
    while(id!=0){
        int k = -1;
        for(int i = id-1;i>=max(0,id-m);i--){
            if(s[i]=='0'){
                k = i;
            }
        }
        if(k==-1){
            cout << -1 << endl;
            return 0;
        }
        res.push_back(id-k);
        id = k;
        //cerr << id << endl;
    }
    reverse(res.begin(),res.end());
    for(auto x:res){
        cout << x << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1080
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cassert>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <queue>
#define PIE 3.14159265358979
#define MAX_N 3005
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N;
ll dp[2][MAX_N];

int main(){
    string str;
    cin >> N;
    cin >> str;
    int now = 0,prev = 1;
    dp[now][0]=1;
    /*
    i番目の符号を見る時,それまでの数字は0..i
    */
    for(int i = 0; i < N-1; i++){
        now = 1-now,prev = 1-prev;
        for(int j = 0;j <= i+1;j++){
            dp[now][j]=0;
        }
        for(int j = 0;j <= i;j++){
            if(str[i]=='>'){
                dp[now][0]+=dp[prev][j];
                dp[now][0]%=MOD;
                dp[now][j+1]+=MOD-dp[prev][j];
                dp[now][j+1]%=MOD;
            }else{
                dp[now][j+1]+=dp[prev][j];
                dp[now][j+1]%=MOD;
                dp[now][i+2]+=MOD-dp[prev][j];
                dp[now][i+2]%=MOD;

            }
        }
        for(int j = 0;j <= i;j++){
            dp[now][j+1]=(dp[now][j+1]+dp[now][j])%MOD;
        }
//        for(int j = 0;j <= i+1;j++){
//            cout<<dp[now][j]<<" ";
//        }
//        cout<<endl;
    }
    ll ans = 0;
    for(int i = 0; i < N;i++){
        ans += dp[now][i];
        ans %= MOD;
    }
    cout<<ans<<endl;
}


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

int main(){
     ll n,k;
     while(cin>>n>>k){
         int cnt=0;
         while(n)
         {
             cnt++;

             n=n/k;
         }
         cout<<cnt<<endl;
     }
     
    return 0;
}


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

#define MIN(a,b) ((a < b) ? a : b)

int main(void) {
  int N = 0;
  scanf("%d", &N);
  int headB = 0;
  int tailA = 0;
  int bothBA = 0;
  int midAB = 0;
  for(int i = 0; i < N; i++) {
    char s[11];
    scanf("%s", s);
    int len = strlen(s);
    if(s[0] == 'B' && s[len-1] == 'A') {
      bothBA++;
    }
    if(s[0] == 'B') {
      headB++;
    }
    if(s[len-1] == 'A') {
      tailA++;
    }
    for(int i = 1; i < len; i++) {
      if(s[i-1] == 'A' && s[i] == 'B') {
	midAB++;
      }
    }
  }

  //printf("midAB=%d, headB=%d, tailA=%d, bothBA=%d\n",
  //midAB, headB, tailA, bothBA);
  int X = midAB;
  int onlyA = tailA - bothBA;
  int onlyB = headB - bothBA;
  if(bothBA == 0) {
    X += MIN(onlyB, onlyA);
  } else {
    if(onlyB == 0 && onlyA == 0) {
      X += (bothBA - 1);
    } else {
      X += bothBA + MIN(onlyB, onlyA);
    }
  }
  printf("%d\n", X);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define length(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, length(a))cin >> a[i]
#define ccin(i, j, a) rep(i, length(a))rep(j, length(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl a;
    cin >> a;
    intl x[n + 1];
    rep(i, n){
        cin >> x[i];
    }
    x[n] = a;
    sort(x, x + n + 1);
    intl max = 1;
    intl y[n];
    rep(i,n){
        y[i] = x[i + 1] - x[i];
    }
    sort(y, y + n);
    intl idx = 0;
    rep(i,n){
        if(y[i]){
            idx = i;
            break;
        }
    }
    intl b = y[idx];
    intl rb = (intl)(sqrt(b));
    map<intl,intl> m;
    repi(i,2,rb + 1){
        if(!(b%i)){
            m[i] = 1;
            b /= i;
            while(!(b%i)){
                m[i]++;
                b /= i;
            }
        }
    }
    if(b != 1)m[b] = 1;
    for(auto i :m){
        //cout << i.fi << ":" << i.se << endl;
        intl m = 1;
        while(i.second){
            bool f = true;
            rep(j,n){
                if(y[j]%i.first){
                    f = false;
                    break;
                }
            }
            if(!f)break;
            i.second--;
            m *= i.first;
            rep(j,n){
                y[j] /= i.first;
            }
        }
        //debug(m);
        max *= m;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#include <iostream>

template<typename T> inline void chmax(T &a, T b){if (a < b) a = b; return;}

template<typename T> inline void fastin(T &num) {
  T c;
  num = 0;
  c = getchar_unlocked();
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
}

template<typename T> void fastout(T &n) {
  T N = n, rev, count = 0;
  rev = N;
  if (N == 0) { 
    putchar_unlocked('0');
    putchar_unlocked('\n');
    return;
  }
  while ((rev % 10) == 0) { 
    ++count; rev /= 10;
  }
  rev = 0;
  while (N != 0) { 
    rev = (rev << 3) + (rev << 1) + N % 10;
    N /= 10;
  }
  while (rev != 0) { 
    putchar(rev % 10 + '0');
    rev /= 10;
  }
  while (count--) putchar_unlocked('0');
  putchar_unlocked('\n');
}

int main(){
  int n; fastin(n);
  int count[100005] = {};
  for (int i = 0; i < n; ++i) {
    int a; fastin(a);
    ++count[a];
  }

  int ans = 1;
  for (int i = 0; i < n; ++i) {
    chmax(ans, count[i] + count[i + 1] + count[i + 2]);
  }
  
  fastout(ans);

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  ll t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  ll c1 = t1*(a1-b1), c2=t2*(a2-b2), ba = c1+c2;
  //cout << c1 << " " << c2 << " " << ba << endl;
  if (c1 == 0 || c2 == 0) return puts("0") * 0;
  if (c1 > 0 && ba > 0) return puts("0") * 0;
  if (c1 < 0 && ba < 0) return puts("0") * 0;
  if (ba == 0) return puts("infinity") * 0;
  if (c1 > 0) {c1*=-1; c2*=-1; ba*=-1;}
  if (c1 < 0) {
    ll ans = -c1 / (c1 + c2);
    if (c1 % (c1 + c2) == 0) cout << 2*ans << endl;
    else cout << 2*ans+1 << endl;
    /*
    ll down = c1 + c2, up = t1 + t2;
    ll an = up / down
    cout << up << " " << down << endl;
    if (up % down == 0) cout << -up / down * 2 << endl;
    else cout << -up / down * 2 + 1 << endl;*/
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int const MOD = 1e9+7;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int M, N; std::cin >> N >> M;
  std::vector<bool> a(N+1, false);
  for(int i = 0; i < M; ++i) {
    int aa; std::cin >> aa;
    a[aa] = true;
  }
  std::vector<int> dp(N+1, -1);
  auto dfs = [&](auto&& f, int n)->int {
    if(dp[n] >= 0) return dp[n];
    if(n <= 1) return 1;
    int res = 0;
    if(!a[n-1]) res += f(f, n-1);
    if(!a[n-2]) res += f(f, n-2);
    return dp[n] = res%MOD;
  };
  fin(dfs(dfs, N));

  return 0;
}


Measured memory_bytes: 5376
def is_prime(target, p_list):
    for p in p_list:
        if target%p == 0:
            return False, p_list
    if target <= 55555:
        p_list.append(target)
    return True, p_list

            

if __name__ == '__main__':
    N = int(input())
    p_list = [2, 3, 5, 7]
    answer = []
    for new in range(max(p_list)+1, 55555):
        is_p, p_list = is_prime(new, p_list)
        if is_p and new%5 == 1:
            answer.append(new)
            if len(answer) == N:
                break
    print(' '.join(map(str, answer)))

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

#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define ll long long
#define mkp make_pair
#define eb emplace_back

const int N = 1e6 + 9;
const int INF = 1e9 + 9;
const int mod = 1e9;
const int K = 25;
const int SZ = (1 << 17) - 1;

#define int ll

void solve() {
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string r;
	cin >> r;
	if (r == s)
		--a;
	else
		--b;
	cout << a << " " << b;
}

main() {
	ios_base::sync_with_stdio(false);
	solve();
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    public static void Main()
    {
        int N = IntRead();
        int[] box = SpIntRead(' ');
        Console.WriteLine(box.Max() - box.Min());
    }
}

public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = StrReverce(ret);
        return ret;
    }
}


Measured memory_bytes: 13396
using System;
using System.Linq;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine();
            var str = Console.ReadLine()
                             .Split(' ')
                             .Select(s => int.Parse(s));
            var count = 0;

            while (true)
            {
                var hasOdd = false;

                foreach (var i in str)
                {
                    if (i % 2 != 0)
                    {
                        hasOdd = true;
                    }
                }

                if (hasOdd)
                {
                    break;
                }

                count++;
                str = str.Select(n => n / 2);
            }

            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 28476
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();
            int ans = 0;
            if (S[0] == T[0]) ans++;
            if (S[1] == T[1]) ans++;
            if (S[2] == T[2]) ans++;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define ll long long
#define INF 10000000000000000
int n;
ll a[300005] = { 0 };
ll lb = 0;
ll ub = INF;
ll bsum = 0;


bool solve(ll len){
	ll b1 = 0;
	ll b2 = 0;
	int now1 = n;
	while (b1 < len&&now1<3 * n){
		b1 += a[now1];
		now1++;
	}
	if (b1 < len) return false;
	int now2 = n - 1;
	while (b2 < b1&&now2>0){
		b2 += a[now2];
		now2--;
	}
	now2++;
	if (b2 < b1) return false;
	for (int i = n+1; i < 2*n; i++){
		b1 -= a[i - 1];
		b2 += a[i - 1];
		while (b1 < len&&now1 < 3 * n){
			b1 += a[now1];
			now1++;
		}
		if (b1<len) continue;
		while (b2>=b1&&now2<3*n&&now2>0){
			b2 -= a[now2];
			now2++;
		}
		now2--;
		b2 += a[now2];
		if (b2 < b1) continue;
		if (bsum - (b1 + b2) >= b1){
			return true;
		}
	}
	return false;
}

int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		bsum += a[i];
		a[i + n] = a[i];
		a[i + 2 * n] = a[i];
	}
	for (int i = 0; i < 100; i++){
		ll mb = (ub + lb) / 2;
		if (solve(mb)){
			lb = mb;
		}
		else{
			ub = mb;
		}
	}
	cout << (ll)lb << endl;
}


Measured memory_bytes: 5436
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

int was[2010];
ll dp[4010][2010];
int n, k;
const ll MOD = 924844033;


int main() {
	cin >> n >> k;
	ll ans = 1;
	dp[0][0] = ans;
	for (int i = 1; i <= n; ++i) {
		ans = (ans * i) % MOD;
		dp[0][i] = ans;
	}
	int now = 0;
	for (int i = 1; i <= n; ++i) {
		if (!was[i]) {
			int cnt = 0;
			for (int j = i; j <= n; j += k) {
				++cnt;
				was[j] = 1;
			}
			++now;
			for (int j = 0; j <= n; ++j)
				dp[now][j] = dp[now - 1][j + 1];

			for (int i = 1; i < cnt; ++i) {
				++now;
				if (i % 2 == 1) {
					for (int j = 0; j <= n; ++j)
						dp[now][j] = (dp[now - 1][j] - dp[now - 2][j] + MOD) % MOD;
				}
				else {
					for (int j = 0; j <= n; ++j)
						dp[now][j] = (dp[now - 1][j + 1] - dp[now - 2][j] + MOD) % MOD;
				}
			}

			++now;
			for (int j = 0; j <= n; ++j)
				dp[now][j] = dp[now - 1][j];

			for (int i = 1; i < cnt; ++i) {
				++now;
				if (i % 2 == 0) {
					for (int j = 0; j <= n; ++j)
						dp[now][j] = (dp[now - 1][j] - dp[now - 2][j] + MOD) % MOD;
				}
				else {
					for (int j = 0; j <= n; ++j)
						dp[now][j] = (dp[now - 1][j + 1] - dp[now - 2][j] + MOD) % MOD;
				}
			}
		}
	}
	cout << dp[now][0] << "\n";
	return 0;
}




Measured memory_bytes: 63104
#include <bits/stdc++.h>
using namespace std;
int N;
string S;
int freq[300];
const int MOD = 1e9 + 7;
int main(){
    cin >> N;
    cin >> S;
    for(int i = 0; i < N; i++)freq[S[i]]++;
    long long int result = 1;
    for(int c = 'a'; c <= 'z'; c++){
        if(freq[c] > 0)
            result = (result * (freq[c] + 1)) % MOD;
    }
    cout << (result - 1 + MOD)%MOD<<endl;
}


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

int main() {
  int a ,b,c,k;
  int i =0;
  cin >>a>>b>>c>>k;
  while(a>0 && k>0){
    i++;
    a--;
    k--;
  }
  while(b>0 && k>0){
    k--;
    b--;
  }
  while(a==0 && b==0 && c>0 && k>0){
    i--;
    k--;
    c--;
  }
  cout << i << endl;
}


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

int cmp(const void *a, const void *b){
    return *(int *)a - *(int *)b;
}

int min(int a, int b){
    if(a > b) return b;
    return a;
}

int max(int a, int b){
    if(a < b) return b;
    return a;
}

int negadd(int n, int a[n], int k){
    int i, sum = 0, b[n];
    if(n ==0 || k == 0) return 0;
    for(i = 0; i < n; ++i) b[i] = a[i];
    qsort(b, n, sizeof(int), cmp);
    for(i = 0; i < k; ++i){
        sum += b[i];
    }
    return sum;
}

int main(void){
    int n, k, i, j, ans;
    scanf("%d %d", &n, &k);
    int v[n+2];
    for(i = 1; i <= n; ++i){
        scanf("%d", &v[i]);
    }
    v[0] = 0; v[n+1] = 0;

    int minnk = min(n, k);
    int suml = 0, sumr = 0, negsum = 0, neg[minnk], negln = 0, negrn = 0, maxsum = 0;
    neg[0] = 0;
    for(i = 0, suml = 0; i <= minnk; ++i){
        suml += v[i];
        if(v[i] < 0){neg[negln++] = v[i];}
        for(j = 0, negrn = 0, sumr = 0; j <= minnk - i; ++j){
            sumr += v[n-j+1];
            if(v[n-j+1] < 0){neg[negln+negrn] = v[n-j+1]; negrn++;}
            //printf("%d %d\n", i, j);
            negsum = negadd(negln+negrn, neg, min(negln+negrn, k-j-i));
            maxsum = max(maxsum, suml+sumr-negsum);
            //printf("%d\n", suml + sumr - negsum);
        }
    }
    printf("%d\n", maxsum);
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextLong()
    val a = sc.nextLong()
    val b = sc.nextLong()
    if (b < a || (n == 1L && a != b)) println(0)
    else println((n - 2) * (b - a) + 1)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 31644
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <set>
#include <vector>
#include <queue>
using namespace std;
#define loop(i,n) for(int i=0;i<n;i++)

int main(){
    
    string s;
    cin>>s;
    int c=0,f=0;
    
    loop(i,s.size()){
        if (s[i] == 'C')c=1;
        if(c && s[i]=='F'){f=1;break;}
    }
    cout<<(f?"Yes":"No")<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  char s[100];
  int i = 0;
  
  scanf("%s",s);
  for(i = 0; i < 100; i++){
  	if(s[i] == ','){
  		s[i] = ' ';
  	}
  }
  printf("%s\n",s);
}

Measured memory_bytes: 128
N,M = map(int,input().split())
lss = []
for i in range(N):
    ls = list(map(int,input().split()))
    lss.append(ls[1:])
s = set(range(1,M+1))
for i in range(N):
    s = s.intersection(set(lss[i]))
print(len(s))

Measured memory_bytes: 3064
#include<iostream>

int n;
int cards[201];

void cut(int k){

	int bufa[201];
	int bufb[201];

	int i = 0;
	for (; i < k; i++)bufa[i] = cards[i];
	for (; i < n; i++)bufb[i - k] = cards[i];

	i = 0;
	for (; i < n - k; i++)cards[i] = bufb[i];
	for (; i < n; i++)cards[i] = bufa[i - (n - k)];

	return;
}

void lifl(){

	int bufa[201];
	int bufb[201];

	int i = 0;
	for (; i < (n / 2); i++)bufa[i] = cards[i];
	for (; i < n; i++)bufb[i - (n / 2)] = cards[i];

	for (int i = 0, j = 0; i < n; i += 2, j++){
		cards[i] = bufa[j];
		cards[i + 1] = bufb[j];
	}

	return;
}

int main(){

	int m;
	std::cin >> n >> m;
	n *= 2;
	for (int i = 0; i < n; i++)cards[i] = i + 1;

	for (int i = 0, a; i < m; i++){
		std::cin >> a;
		if (a != 0)cut(a);
		else lifl();
	}


	for (int i = 0; i < n; i++)std::cout << cards[i] << std::endl;

	return 0;
}

Measured memory_bytes: 1160
let n = read_int ()
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let rec f m i = if i >= n then -1 else if a_s.(i) = m then i else f m (i + 1)
let rec g i j = let j = f i j in if j = -1 then i - 1 else g (i + 1) (j + 1)
let k = g 1 0
let _ = Printf.printf "%d\n" @@ if k = 0 then -1 else n - k

Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int N,D;
    cin >>  N >> D;
    map<int,vector<int>> data;
    for(int i=0;i<N;i++){
        vector<int> X(D);
        for(int j=0;j<D;j++){
            cin >> X[j];
        }
        data[i]=X;
    }
    int cnt=0;
    int num = N*(N-1)/2;
    vector<int> dist(num);
    int cn=-1;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            int distance=0;
            for(int k=0;k<D;k++){
                distance = distance + (data[i][k] - data[j][k])*(data[i][k] - data[j][k]);
            }
            cn++;
            dist[cn]=distance;
        }
    }
    for(int i=0;i<num;i++){
        for(int j=0;j<160;j++){
            if(dist[i] == j*j){
                cnt++;
            }
        }
    }
    cout << cnt<< endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    long long a[10000010];
    for (int i = 1; i <= 10000000; i++)
    {
        a[i] = 0;
    }
    for (int i = 1; i <= 10000000; i++)
    {
        for (int j = 1; j <= 10000000; j++)
        {
            if (i * j > 10000000)
            {
                break;
            }
            else
            {
                a[i * j]++;
            }
        }
    }
    long long result = 0;
    for (int i = 1; i <= N; i++)
    {
        result += i * a[i];
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 81740
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;

const int INF = 1e18;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
const double pi = acos(-1);

double ang2radian(double ang)
{
    return ang / 180 * pi;
}

double dist(double xa, double ya, double xb, double yb)
{
    double dx = xa - xb;
    double dy = ya - yb;

    return pow(dx * dx + dy * dy, 0.5);
}

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double hx, hy;
    double mx, my;

    double cosM = cos(ang2radian(6 * m));
    double sinM = sin(ang2radian(6 * m));
    double cosH = cos(ang2radian(30 * h + m / 2));
    double sinH = sin(ang2radian(30 * h + m / 2));

    cout << setprecision(10) << dist(a * cosH, a * sinH, b * cosM, b * sinM) << endl;
}

signed main()
{
    solve();
    return 0;
}


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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  int N;
  cin >> N;
  vector<ll> A(N);
  FOR(i, N) cin >> A[i];
  ll ans = (1LL << 60);
  ll l = 0;
  ll r = accumulate(ALL(A), 0LL);
  FOR(i, N - 1) {
    l += A[i];
    r -= A[i];
    ans = min(ans, abs(l - r));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
int main(){
   
    int x,y;
    cin >> x >> y;
    rep(i,x){
        if(2*i+4*(x-i)==y){
            cout << "Yes  ";
            return 0;

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

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

int main(){
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;

    string s;
    cin >> s;

    for(int i = a+1;i < c-1;i++){
        if(s[i] == '#' && s[i+1] == '#'){
            cout << "No" << endl;
            return 0;
        }
    }

    for(int i = b+1;i < d-1;i++){
        if(s[i] == '#' && s[i+1] == '#'){
            cout << "No" << endl;
            return 0;
        }
    }

    if(c < d){
        cout << "Yes" << endl;
        return 0;
    }

    bool f = false;
    for(int i = b; i <= d;i++){
        if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.'){
            f = true;
            break;
        }
    }

    if(f){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}


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

int main() {
  int n;
 cin >> n;
 vector<int> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end());
  int ans = 0;
 
  for(int i = 0; i < n-2; i++){
   for(int j = i + 1; j < n-1; j++){
     if(l[i] == l[j]) continue;
	    for(int k = j + 1; k < n; k++){
          if(l[j] == l[k]) continue;
          if(l[i] + l[j] > l[k]) ans ++;
        }
    }
  }
    
  cout << ans << endl;
      return 0;
}


Measured memory_bytes: 3628
#B - Similar Arrays
N = int(input())
A = list(map(int,input().split()))

all_odd = 1
for i in A:
    if i%2 == 0:
        all_odd *= 2
    else:
        all_odd *= 1
tot_cnt = 3**N

ans = tot_cnt - all_odd
print(ans)

Measured memory_bytes: 8924
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
using namespace std;

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

const long long INF = 1LL << 60;
char s[4];
int main()
{
	int a,b,c,d;
	int res = 0;
	cin >> s;
	a = s[0] - '0';b = s[1] - '0';c = s[2] - '0';d = s[3] - '0';
	if		(a + b + c + d == 7)cout << a << '+' << b << '+' << c << '+' << d << "=7" << endl;
	else if (a + b + c - d == 7)cout << a << '+' << b << '+' << c << '-' <<d<<"=7" <<endl;
	else if (a + b - c - d == 7)cout << a << '+' << b << '-' << c << '-' << d << "=7" << endl;
	else if (a - b - c - d == 7)cout << a << '-' << b << '-' << c << '-' << d << "=7" << endl;
	else if (a + b - c + d == 7)cout << a << '+' << b << '-' << c << '+' << d << "=7" << endl;
	else if (a - b + c + d == 7)cout << a << '-' << b << '+' << c << '+' << d << "=7" << endl;
	else if (a - b - c + d == 7)cout << a << '-' << b << '-' << c << '+' << d << "=7" << endl;
	else if (a - b + c - d == 7)cout << a << '-' << b << '+' << c << '-' << d << "=7" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    V<ll> a(2019,0);
    a[0]=1;
    string s;
    cin>>s;
    reverse(all(s));
    ll now=0;
    ll ans=0;
    ll d=1;
    for(int i=0;i<s.size();i++){
        now+=(ll(s[i]-'0')*d)%2019;
        now%=2019;
        a[now]++;
        ans+=(a[now]-1);
        d*=10;
        d%=2019;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3764
#include <iostream>
#include <vector>

int n_fac(int n){
    int c = 2;
    if((n % 2) == 0){
        c++;
    }
    int k = 3;
    while(k < n){
        if((n % k) == 0){
            c++;
        }
        k += 2;
    }
    return c;
}
int main(){
    int N;
    std::cin>>N;

    int c = 0;
    for(int i = 1;i <= N;i+=2){
        if(n_fac(i) == 8){
            c++;
        }
    }
    std::cout<<c<<std::endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int m,n;
  cin>>m>>n;
  int a[n];
  int ans=0;
  rep(i,n){
    cin>>a[i];
  }
  if(m==2){
    int num1=0,num2=0;
    rep(i,n){
      if(a[i]==1 && i%2==0) num1++;
      if(a[i]==2 && i%2==1) num1++;
      if(a[i]==1 && i%2==1) num2++;
      if(a[i]==2 && i%2==0) num2++;
    }
    ans=min(num1,num2);
  }
  else{
    rep(i,n){
      if(i!=0 && a[i]==a[i-1]){
	a[i]=-1;
	ans++;
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}



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

int main(){

  int n;
  string s;
  cin >> n;
  cin >> s;

  int count = 1;
  for (int i = 1; i < n; ++i) {
    if (s[i] != s[i-1]){
      count++;
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 512
s = set()
l = [0]*4
for i in range(3):
  a, b = map(int, input().split())
  l[a-1] += 1
  l[b-1] += 1
  s.add(a)
  s.add(b)
if len(s) == 4 and max(l) < 3:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
map<LL,LL>u,x,y;
V<pair<LL,LL> >v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
   string a;
   cin>>n;
   k=0;
   for(i=1;i<=n;i++)
   {
       if(i%5!=0 && i%3!=0)
       {
           k+=i;
       }
   }
   cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 3644
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

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

    private void solve(Scanner in, PrintWriter out) {
        int n = in.nextInt(), k = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = in.nextInt();
        }
        Arrays.sort(a);
        ArrayList<Integer> segs = new ArrayList<>();
        int size = 1;
        for (int i = 1; i < n; ++i) {
            if (a[i] == a[i - 1]) {
                ++size;
            } else {
                segs.add(size);
                size = 1;
            }
        }
        segs.add(size);
        segs.sort(new Comparator<Integer>() {
            @Override
            public int compare(Integer a, Integer b) {
                return a - b;
            }
        });
        int ans = 0;
        for (int i = 0; i < segs.size() - k; ++i) {
            ans += segs.get(i);
        }
        System.out.println(ans);
    }
}


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

int main(){
  int a = 0;
  cin >> a;
  int n = a;
  int sum = 0;
  for (int i = 10;i<=n;i *= 10){
    sum += (a % 10);
    a /= 10;
  }
  sum += a;
  if ( (n % sum) == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int h, a;
    cin >> h >> a;

    int t = h/a;
    if(h%a) t++;

    cout << t << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
int n, a[N], b[N], cnt = 0;
set< pair<int, int> > st;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i ++) {
		scanf("%d", &b[i]);
		st.insert(make_pair(b[i], i));
		if (a[i] == b[i]) cnt ++;
	}
	long long ans = 0;
	while (st.size()) {
		pair<int, int> now = (*st.rbegin());
		int val = now.first;
		int pos = now.second;
		if (b[pos] == a[pos]) {
			st.erase(now);
			continue;
		}
		//printf("pos=%d, val=%d\n", pos,val);
		int to = a[pos];
		int lef = pos - 1; if (lef == 0) lef = n;
		int rig = pos + 1; if (rig == n + 1) rig = 1;
		//printf("to = %d , lef + rig = %d\n", to, b[lef] + b[rig]);
		if (to < b[lef] + b[rig]) {
			ans = ans + val / (b[lef] + b[rig]);
			if (b[pos] < b[lef] + b[rig]) {
				return !printf("-1\n");
			}
			b[pos] = b[pos] % (b[lef] + b[rig]);
			st.erase(now);
			st.insert(make_pair(b[pos], pos));
			if (b[pos] == 0) return !printf("-1\n");
		} else {
			if (b[pos] - a[pos] >= 0 && (b[pos]-a[pos])%(b[lef]+b[rig]) == 0) {
				ans += (b[pos]-a[pos])/(b[lef]+b[rig]);
				st.erase(now);
			} else {
				return !printf("-1\n");
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



void solve(){
  ll k,x;
  cin>>k>>x;
  if(k*500<x)
  cout<<"No";
  else cout<<"Yes";

}

int main(){
    ll t=1;
//cin>>t;
    while(t--){
     solve();
     cout<<endl;
    }
    return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int const MOD = 1e9+7;

namespace math {

constexpr int MaxComb = 2010;

struct Combination {

  long long comb_[MaxComb][MaxComb];
    
  Combination() {
    rep(i, MaxComb) {
      comb_[i][0] = 1;
      REP(j, 1, i+1) {
        comb_[i][j] = comb_[i-1][j-1] + comb_[i-1][j];
        comb_[i][j] %= MOD;
      }
    }
  }

  long long comb(int n, int r) const { return comb_[n][r]; }

};

}

math::Combination comb;

int main() {
  int N, K; cin >> N >> K;
  REP(n_blue_group, 1, K + 1) {
    ll pat = comb.comb(N - K + 1, n_blue_group);
    (pat *= comb.comb(K - 1, n_blue_group - 1)) %= MOD;
    cout << pat << "\n";
  }
}

Measured memory_bytes: 30336
fn main() {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    println!("{}", solve(&input));
}

fn solve(input: &str) -> String {
    let mut iter = input.split_whitespace();
    let h: usize = iter.next().unwrap().parse().unwrap();
    let w: usize = iter.next().unwrap().parse().unwrap();
    let maze: Vec<Vec<char>> = (0..h)
        .map(|_| iter.next().unwrap().chars().collect())
        .collect();
    let mut solver = Solver {
        h: h,
        w: w,
        maze: maze,
        distance: vec![vec![0; w]; h],
    };
    let ans = solver.solve();
    format!("{}\n", ans)
}

struct Solver {
    h: usize,
    w: usize,
    maze: Vec<Vec<char>>,
    distance: Vec<Vec<i32>>,
}

impl Solver {
    fn solve(&mut self) -> i32 {
        let mut max = 0;
        for i in 0..self.h {
            for j in 0..self.w {
                if self.maze[i][j] == '.' {
                    self.reset();
                    self.dfs(i, j, 0);
                    max = std::cmp::max(
                        max,
                        *self
                            .distance
                            .iter()
                            .map(|row| row.iter().max().unwrap())
                            .max()
                            .unwrap(),
                    );
                }
            }
        }
        max
    }
    fn reset(&mut self) {
        for i in 0..self.h {
            for j in 0..self.w {
                if self.maze[i][j] == '.' {
                    self.distance[i][j] = std::i32::MAX;
                } else {
                    self.distance[i][j] = -1;
                }
            }
        }
    }
    fn dfs(&mut self, i: usize, j: usize, d: i32) {
        if self.distance[i][j] > d {
            self.distance[i][j] = d;
            if i > 0 {
                self.dfs(i - 1, j, d + 1);
            }
            if j > 0 {
                self.dfs(i, j - 1, d + 1);
            }
            if i + 1 < self.h {
                self.dfs(i + 1, j, d + 1);
            }
            if j + 1 < self.w {
                self.dfs(i, j + 1, d + 1);
            }
        }
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <memory>
using namespace std;

#define DEBUG(x) cerr << #x << " = " << x << endl

template<class T, class U> T lexical_cast(const U& from)
{ T to; stringstream ss; ss << from; ss >> to; return to; }

struct node {
    int id;
    node *prev;
    node *next;
};

int main() {
    for(int M, N; cin >> M >> N, M + N != 0; ) {
        vector<node> p(M);
        for(int i = 0; i < M; i++) {
            p[i].id = i + 1;
            p[i].prev = &p[(i - 1 + M) % M];
            p[i].next = &p[(i + 1) % M];
        }

        int number = 1;
        node *cur = &p[0];
        while(N--) {
            // DEBUG(cur->id);
            // DEBUG(number);
            string mes; cin >> mes;
            if(number % 15 == 0) {
                if(mes != "FizzBuzz") {
                    cur->prev->next = cur->next;
                    cur->next->prev = cur->prev;
                }
            }
            else if(number % 3 == 0) {
                if(mes != "Fizz") {
                    cur->prev->next = cur->next;
                    cur->next->prev = cur->prev;
                }
            }
            else if(number % 5 == 0) {
                if(mes != "Buzz") {
                    cur->prev->next = cur->next;
                    cur->next->prev = cur->prev;
                }
            }
            else {
                if(mes != lexical_cast<string>(number)) {
                    cur->prev->next = cur->next;
                    cur->next->prev = cur->prev;
                }
            }
            cur = cur->next;
            number++;
        }

        node *end = cur;
        cur = cur->next;
        vector<int> res;
        for(; cur != end; cur = cur->next) {
            res.push_back(cur->id);
        }
        res.push_back(cur->id);
        sort(res.begin(), res.end());
        for(int i = 0; i < (int)res.size() - 1; i++) {
            cout << res[i] << ' ';
        }
        cout << *res.rbegin() << endl;
    }
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int dp[1<<21|1][21];
char S[1<<21|1];
int occ[1<<21|1],ed0[1<<20|1],L0[1<<20|1],ed1[1<<20|1],L1[1<<20|1];
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int n=gi(),K=gi();
	for(int i=0;i<=n;++i){
		scanf("%s",S);
		for(int j=0;j<1<<i;++j)if(S[j]=='1')dp[j|(1<<i)][0]=1;
	}
	for(int i=0;i<1<<n;++i)
		for(int j=0;;++j)
			if(~i>>j&1){ed0[i]=i>>j+1,L0[i]=j+1;break;}
	for(int i=1;i<1<<n;++i)
		for(int j=0;;++j)
			if(i>>j&1){ed1[i]=i>>j+1,L1[i]=j+1;break;}
	for(int S=(1<<n+1)-1,L=n;~S;--S){
		if(~S&(1<<L))--L;
		for(int i=0;i<=L;++i)
			if(dp[S][i]){
				int A=S&((1<<i)-1),B=(S^A^(1<<L))>>i;
				//printf("%d %d %d %d %d\n",S,i,A,B,dp[S][i]);
				//lenA=i,lenB=L-i
				occ[A|(1<<i)]+=dp[S][i];//end
				//pb 0
				if(B!=(1<<L-i)-1)
					dp[A|(ed0[B]<<i+1)|(1<<L+1-L0[B])][i+1]+=dp[S][i];
				//pb 1
				if(B)
					dp[A|(1<<i)|(ed1[B]<<i+1)|(1<<L+1-L1[B])][i+1]+=dp[S][i];
			}
	}
	int mxl=0;
	for(int i=0;i<1<<n+1;++i)if(occ[i]>=K)mxl=32-__builtin_clz(i);
	for(int i=0;i<1<<n+1;++i)
		if(occ[i]>=K&&mxl==32-__builtin_clz(i)){
			int p=32-__builtin_clz(i);
			for(int j=p-2;~j;--j)putchar('0'+(i>>j&1));
			return 0;
		}
	return 0;
}


Measured memory_bytes: 199040
n = int(input())
mp = [[0, 0, 0] for _ in range(n)]
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
zs = list(map(int, input().split()))

for a in xs[1:]:
  mp[a - 1][0] = 1
for b in ys[1:]:
  mp[b - 1][1] = 1
for c in zs[1:]:
  mp[c - 1][2] = 1

ans = 0
for t in mp:
  if t[2] and ((not t[0]) or t[1]):
    ans += 1
print(ans)



Measured memory_bytes: 5604
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}


void dijkstra(int s, vector<int> &d, vector<vector<pair<int,int>>> &G){
	priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
	
	d.clear();
	d.resize(G.size(),INF);
	d[s] = 0;
	q.push(make_pair(0,s));
	
	while(!q.empty()){
		pair<int,int> p = q.top();q.pop();
		int v = p.second;
		
		if(d[v] < p.first) continue;
		
		for(pair<int,int> e : G[v]){
			if(d[e.first] > d[v] + e.second){
				d[e.first] = d[v] + e.second;
				q.push(make_pair(d[e.first],e.first));
			}
		}
	}	
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, Q, K;
	vector<vector<pair<int,int>>> tree;
	vector<int> d;
	cin>>N;
	
	tree.resize(N+2);
	
	for(int i = 1; i < N; i++){
		int a, b, c;
		
		cin>>a>>b>>c;
		
		tree[a].push_back(make_pair(b,c));
		tree[b].push_back(make_pair(a,c));
	}
	
	cin>>Q>>K;
	
	dijkstra(K, d, tree);
	
	
	for(int i = 0; i < Q; i++){
		int x, y;
		cin>>x>>y;
		
		cout<<d[x] + d[y]<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 11120
#include <bits/stdc++.h>
using namespace std;
 
int main(void) 
{
    int N,M;

    cin >> N >> M;

    vector<int> L(M);
    vector<int> R(M);

    int Lmax = 1;
    int Rmin = N;
    for(int i=0;i<M;++i)
    {
        cin >> L[i] >> R[i];

        if (L[i]>Lmax) Lmax = L[i];
        if (R[i]<Rmin) Rmin = R[i];
    }

    int ans = 0;
    if (Lmax <= Rmin)
        ans = Rmin - Lmax + 1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
  int n;
  int crs;
  int a[10];

  crs = 0;
  while( 1 ){
    if( scanf("%d ",&n)==EOF )
      break;
    if( n==0 ){
      printf("%d\n",a[--crs]);
    }else{
      a[crs++] = n;
    }
  }
  return 0;
}

Measured memory_bytes: 0
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, long.Parse);
        line = Console.ReadLine().Trim().Split(' ');
        var b = Array.ConvertAll(line, long.Parse);
        Console.WriteLine(a.Sum() * b.Sum());
    }
}



Measured memory_bytes: 35028