akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)a
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    ll n, d;
    cin >> n >> d;
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ll x, y;
        cin >> x >> y;

        bool good = x * x + y * y <= d * d;
        ans += good;
    }
    cout << ans;
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

constexpr int evx[4] = { 1, 0, -1, 0 };
constexpr int evy[4] = { 0, 1, 0, -1 };

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

template<typename container>
inline void print_STL(container c)
{
        if(c.size() == 0)
                return;
        std::cout << c[0]; 
        for(int i = 1; i < c.size(); i++)
                std::cout << ' ' << c[i];
        std::cout << '\n';
}

signed main()
{
    ios::sync_with_stdio(false);
        int n;
        cin >> n;
        vector<int> nums;
        for(int i = 0; i < n; i++)
        {
                int tmp;
                cin >> tmp;
                nums.push_back(tmp);
        }
        print_STL(nums);
        for(int i = 1; i <n; ++i)
        {
                int key = nums[i];
                int j = i - 1;
                while(j >= 0 && nums[j] > key)
                {
                        nums[j+1] = nums[j];
                        j--;
                }
                nums[j+1] = key;

                print_STL(nums);
        }
}

Measured memory_bytes: 3208
import sys
import copy
import string
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

k, s = na()
ct = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if 0 <= z <= k:
            ct += 1
print(ct)











Measured memory_bytes: 3896
#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define pb push_back
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y);
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y);
#define sz(x) (int)(x.size())
#define nax 100010
#define inf 1001000100
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define mp make_pair
#define pc pair<char ,int>
#define pi pair<int ,int>
#define pii pair <int,pi>
#define ull unsigned long long int
using namespace std;
int arr[nax];
int siz[nax];
vector< ll > ans;
vector< pi > v;

int root(int x)
{
	while(arr[x] != x)
	{
		 x = arr[x];
		 arr[x] = arr[arr[x]];
	}
	return x;
}

ll unite(int a, int b)
{
	a = root(a);
	b = root(b);
	ll ret = siz[a] * 1ll * siz[b];
	if(siz[a] > siz[b])
	{
		arr[b] = a;
		siz[a] += siz[b];
	}
	else
	{
		arr[a] = b;
		siz[b] += siz[a];
	}
	return ret;
}


int main() {

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string str;
    cin >> str;
    int l = str.length();
    stack < int > stk;
    int ans = 0;
    for(int i = 0 ; i < l; i++)
    {
    	if(!stk.empty() && stk.top() != str[i])
    	{
    		stk.pop();
    		ans += 2;
    	}
    	else
    		stk.push(str[i]);
    }
    cout << ans << '\n';
    return 0;
}

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


int main(){
  long long int a,b,x[55]={0},y[55]={0};
  cin >> a >> b;
  
  for(int i=0;i<a;i++){
    cin >> x[i] >> y[i];
  }
  
  long long int  ans=9e18;
  
  for(int xi=0;xi<a;xi++){
    for(int xj=0;xj<a;xj++){
      for(int yi=0;yi<a;yi++){
        for(int yj=0;yj<a;yj++){
          long long int xa=x[xi],xb=x[xj],ya=y[yi],yb=y[yj];
          
          int res=0;
          for(int i=0;i<a;i++){
            if(min(xa,xb)<=x[i] && x[i]<=max(xa,xb)&& min(ya,yb)<=y[i] && y[i]<=max(ya,yb)){
              res++;
            }
          }
          
          if(res>=b){
            ans= min(ans,abs(xa-xb)*abs(ya-yb));
          }
        }
      }
    }
  }
  cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> boss(n);
  boss.at(0)= 0;
  for(int i =1; i<n; i++){
    cin >> boss.at(i);
  }
  vector<vector<int>> child(n+1);
  for(int i =1; i<n+1; i++){
    child.at(boss.at(i-1)).push_back(i);
  }
  for (int i =1; i<n+1; i++){
    int size = child.at(i).size();
    cout<< size <<endl;  
  }
}

Measured memory_bytes: 14772
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)


int main() {
	int a, b;
	cin >> a >> b;
	if (a + b >= 10) {
		cout << "error" << endl;
	}
	else
		cout << a + b << endl;
	return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int main(){

	int n;cin >> n;
	vector<ll> v(n);
	REP(i,n)cin >> v[i];

	sort(ALL(v));

	ll ans = 0;

	REP(i,n){
		if(i != n - 1)ans += v[i];
		else ans += v[i] / 2;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
def kazu(p, q):
    return max(p[0], q[0]), min(p[1], q[1]), max(-max(p[0], q[0]) + min(p[1], q[1]) + 1, 0)
def kazu1(p):
    return max(p[1] - p[0] + 1, 0)
def main():
    N = int(input())
    l = []
    for _ in range(N):
        L, R = map(int, input().split())
        l.append((L, R))
    l.sort(key=lambda x:x[1])
    dp= (l[0], l[1])
    for i in range(2, N):
        a, b, c = kazu(dp[0], l[i]) 
        d, e, f = kazu(dp[1], l[i])
        g, h, j = kazu(dp[0], dp[1])
        m = max(f + kazu1(dp[0]), c + kazu1(dp[1]), j + kazu1(l[i]))
        if  m == f + kazu1(dp[0]):
            dp = ((d,e),dp[0])
        elif m == c + kazu1(dp[1]):
            dp = ((a,b),dp[1])
        else:
            dp = ((g,h), l[i])
    return kazu1(dp[0]) + kazu1(dp[1])
print(main())


Measured memory_bytes: 18264
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d %d",&a,&b);
  if(1<=a && a<=1000000000 && 1<=b && b<=1000000000){
    while(a%b!=0){
      c=a%b;
      a=b;
      b=c;
    }
    printf("%d\n",b);
  }
  return 0;
}


Measured memory_bytes: 2124
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int A[26];
int main() {
    string s;
    cin >> s;
    rep(i, 0, s.size()) {
        A[s[i] - 'a']++;
    }
    rep(i, 0, 26) {
        if (A[i] % 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = NextInt();
            var H = NextLong();
            long maxA = 0;
            var b = new List<int>();

            for (int i = 0; i < N; i++) {
                maxA = Math.Max(maxA, NextLong());
                b.Add(NextInt());
            }

            b.Sort((x, y) => y - x);
            var count = 0;
            for (; count < N && b[count] > maxA && H > 0; count++) {
                H = Math.Max(H - b[count], 0);
            }

            
            Console.WriteLine(count + Math.Ceiling((decimal)H / maxA));
        }
    }

    class MyMath {
        static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

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

int main(){
  string s;bool j;char a,b;
  cin >> s;
  a=s.at(5);
  b=s.at(6);
  if(a=='1')
    j=false;
  else if(b=='5')
    j=false;
  else if(b=='6')
    j=false;
  else if(b=='7')
    j=false;
  else if(b=='8')
    j=false;
  else if(b=='9')
    j=false;
  else
    j=true;
  if(j)
    cout << "Heisei";
  else
    cout << "TBD";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define MII map<int,int>
#define PB push_back
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main()
{
    FIO
    int r; cin>>r;
    cout<<r*r;
    
    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def dfs(x):
        fx = ans[x]
        nf = fx*inv[s[x]-1]%mod
        sx = s[x]
        for y in v[x]:
            sy = s[y]
            nsx = sx-sy
            nsy = s[x]
            if ans[y] == None:
                fy = nf*s[y]*f[nsy-1]*pow(nsx,mod-2,mod)%mod
                ans[y] = fy
                s[x] = nsx
                s[y] = nsy
                dfs(y)
                s[x] = sx
                s[y] = sy

    n = I()
    f = [1]
    for i in range(1,n+1):
        f.append(f[-1]*i%mod)
    inv = [None]*(n+1)
    inv[n] = pow(f[n],mod-2,mod)
    for i in range(n)[::-1]:
        inv[i] = inv[i+1]*(i+1)%mod

    v = [[] for i in range(n)]
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    d = [0]*n
    d[0] = 1
    q = deque([0])
    p = [None]*n
    while q:
        x = q.popleft()
        nd = d[x]+1
        for y in v[x]:
            if not d[y]:
                d[y] = nd
                p[y] = x
                q.append(y)
    V = list(range(n))
    V.sort(key = lambda x:-d[x])
    m = d[V[0]]
    s = [0]*n
    res = 1
    for i in V:
        j = p[i]
        s[i] += 1
        if j != None:
            s[j] += s[i]
            res *= inv[s[i]]
        if d[i] == m:
            continue
        res *= f[s[i]-1]
        res %= mod
    ans = [None]*n
    ans[0] = res
    dfs(0)
    for i in ans:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 133468
#include <bits/stdc++.h>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdlib.h>
using namespace std;

int main()
{
    int n,i,ans;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);

    sort(a,a+n);

    ans=a[n/2]-a[n/2-1];

    printf("%d",ans);
}



Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define INF 1e9

int main(void){

  //変数の準備
  int max = 0, min = INF, N;
  
  //入力
  cin >> N;
  
  //配列の受け取り
  int A[N];
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if(A[i] > max) max = A[i];
    if(A[i] < min) min = A[i];
  }
  
  cout << max - min << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 11:46-

            // 11:54-

            int n = sc.nextInt();
            double[] vs = new double[n];
            for (int i = 0; i < vs.length; i++) vs[i] = sc.nextInt();

            Arrays.sort(vs);

            for (int i = 1; i < n; i++) vs[i] = (vs[i - 1] + vs[i]) / 2.0;

            out.println(vs[n - 1]);
        }
    }

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int gcd(int x,int y){
  int r;
  if(x<y){
    swap(x,y);
  }
  while(y>0){
    r=x%y;
    x=y;
    y=r;
  }
  return x;
}
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int k;
  ll sum=0;
  cin>>k;
  REP(i,1,k+1){
    REP(j,1,k+1){
      REP(l,1,k+1){
        int a=gcd(i,j);
        int b=gcd(a,l);
        sum+=b;
      }
    }
  }
  cout<<sum<<'\n';
  return(0);
}


Measured memory_bytes: 3664
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int N;
    string S, T, ST;
    cin >> N;
    cin >> S >> T;
    for (int i = 0; i < N; i++) {
      ST += ""s + S[i] + T[i];
    }
    cout << ST << endl;

    return 0;
}



Measured memory_bytes: 256
(let* ((n (read))
       (m (read))
       (lst (loop :repeat m :collect (cons (1- (read)) (read-char)))))
  (if (= n 1)
      (loop :for k :from 0 :upto 9
            :if (loop :for (x . y) :in lst
                      :with j = (format nil "~A" k)
                      :always (char= y (aref j x)))
              :do (progn (princ k) (return))
            :finally (princ -1))
      (loop :for k :from (expt 10 (1- n)) :upto (1- (expt 10 n))
            :if (loop :for (x . y) :in lst
                      :with j = (format nil "~A" k)
                      :always (char= y (aref j x)))
              :do (progn (princ k) (return))
            :finally (princ -1))))

Measured memory_bytes: 16100
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    char s[n];
    int cnt=0; 
    for(int i=0;i<n;i++)cin>>s[i];
    for(int j=2;j<n;j++){
        if(s[j]=='C'&&s[j-1]=='B'&&s[j-2]=='A')cnt++;
    }
    cout<<cnt<<endl;

}



Measured memory_bytes: 256
import math
from datetime import date

def main():
	
	s = input()
	a = [0 for i in range(26)]

	for c in s:
		a[ord(c) - ord('a')] += 1

	ok = 'True'
	for i in range(26):
		if a[i] % 2 == 1:
			ok = 'False'

	if ok == 'True':
		print("Yes")
	else:
		print("No")

main()


Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int n=s.size();
  for(int i=0;i<(1<<(n-1));i++){
    int ans=s[0]-'0';
    vector<char> enzan;
    for(int j=0;j<n-1;j++){
      if(i&(1<<j)){
        ans-=s[j+1]-'0';
        enzan.push_back('-');
      }else{
        ans+=s[j+1]-'0';
        enzan.push_back('+');
      }
    }
    if(ans==7){
      cout<<s[0]<<enzan[0]<<s[1]<<enzan[1]<<s[2]<<enzan[2]<<s[3]<<'='<<7<<endl;
      return 0;
    }
  }      
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)
#define M 1000000007

ll fact[200010];
ll invfact[200010];

ll choose(int n,int r){
	if(n<0||r<0||n-r<0)return 0;
	return fact[n]*invfact[r]%M*invfact[n-r]%M;
}

ll a[100010];
int main(){
	fact[0]=1;
	rep(i,1,200005)fact[i]=fact[i-1]*i%M;
	invfact[200000]=invp(fact[200000],M);
	for(int i=199999;i>=0;i--)invfact[i]=invfact[i+1]*(i+1)%M;

	int n;
	scanf("%d",&n);

	int x;
	rep(i,0,n+1){
		int t;
		scanf("%d",&t);
		if(a[t])x=i+1-a[t];
		else a[t]=i+1;
	}
	//区別出来ない⇔2つあるものを一方だけ選び、その間を選ばない
	//C(n+1,k)-C(n-x,k)
	rep(k,1,n+2)printf("%lld\n",(choose(n+1,k)-choose(n-x,k-1)+M)%M);
	return 0;
}

Measured memory_bytes: 4992
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type pair struct{ f, s int }
type ps []pair

func (a ps) Len() int           { return len(a) }
func (a ps) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ps) Less(i, j int) bool { return a[i].f > a[j].f }

func solve() {
	n, m := getInt(), getInt()
	mp := make(map[int]int)
	for i := 0; i < n; i++ {
		a := getInt()
		mp[a]++
	}

	for i := 0; i < m; i++ {
		b, c := getInt(), getInt()
		mp[c] += b
	}

	s := make([]pair, 0, len(mp))
	for k, v := range mp {
		s = append(s, pair{k, v})
	}
	sort.Sort(ps(s))

	ans := 0
	for _, p := range s {
		if p.s >= n {
			ans += p.f * n
			break
		} else {
			ans += p.f * p.s
			n -= p.s
		}
	}
	fmt.Fprintln(wr, ans)
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 15616
#include <stdio.h>
#define Max 100
#define INF 10000

int c[Max];

//連鎖行列積を求める
int matrixChainOrder(int n){
  int i,j,k,l,q;
  int m[Max][Max];
  
  for(i = 1 ; i <= n ; i++){
    m[i][i]=0;
  }

  for(l = 2 ; l <= n ; l++){
    for(i = 1 ; i <= n-l+1 ; i++){
      j = i+l-1;
      m[i][j] = INF;
      for(k = i ; k < j ; k++){
        q = m[i][k] + m[k+1][j] + c[i-1] * c[k] * c[j];
        if(k == i){
          m[i][j] = q;
        }
        else if(m[i][j] > q){
          m[i][j] = q;
        }
      }
    }
  }
  return m[1][n];
}

int main(){
  int i, n, ans;

  scanf("%d",&n);

  for(i = 1 ; i <= n ; i++){
    scanf("%d %d",&c[i-1], &c[i]);
  }

  ans = matrixChainOrder(n);
  
  printf("%d\n",ans);

  return 0;
}



Measured memory_bytes: 2056
import java.util.Scanner;

public class Main {
	class Card {
		char d;
		int v;
		Card(char d, int v) {
			this.d = d;
			this.v = v;
		}
		
		public String toString() {
			return this.d + " " + this.v;
		}
	}
	final int INF = Integer.MAX_VALUE;

	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		Card[] m = new Card[n];
		Card[] q = new Card[n];
		for (int i = 0; i < n; i++) {
			char d = scan.next().charAt(0);
			int v = scan.nextInt();
			m[i] = new Card(d, v);
			q[i] = new Card(d, v);
		}
		quickSort(q, 0, n - 1);
		mergeSort(m, 0, n);	// a stable sort
		
		boolean isStable = true;
		for (int i = 0; i < n; i++)
			if (!(q[i].v == m[i].v && q[i].d == m[i].d))
				isStable = false;
		
		System.out.println(isStable ? "Stable" : "Not stable");
		for (int i = 0; i < n; i++)
			System.out.println(q[i].toString());
	}
	
	void quickSort(Card[] a, int p, int r) {
		if (p < r) {
			int q = partition(a, p, r);
			quickSort(a, p, q - 1);
			quickSort(a, q + 1, r);
		}
	}
	
	int partition(Card[] a, int p, int r) {
		int x = a[r].v;
		int i = p - 1;
		for (int j = p; j < r; j++) {
			if (a[j].v <= x) {
				i += 1;
				Card tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
		Card tmp = a[i + 1];
		a[i + 1] = a[r];
		a[r] = tmp;
		return i + 1;
	}

	void mergeSort(Card[] a, int left, int right) {
		if (left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(a, left, mid);
			mergeSort(a, mid, right);
			merge(a, left, mid, right);
		}
	}
	
	void merge(Card[] a, int left, int mid, int right) {
		int n1 = mid - left;
		int n2 = right - mid;

		Card[] l = new Card[n1 + 1];
		Card[] r = new Card[n2 + 1];
		for (int i = 0; i < n1; i++)
			l[i] = a[left + i];
		for (int i = 0; i < n2; i++)
			r[i] = a[mid + i];
		l[n1] = r[n2] = new Card(' ', INF);
		
		int i = 0, j = 0;
		for (int k = left; k < right; k++) {
			if (l[i].v <= r[j].v)
				a[k] = l[i++];
			else
				a[k] = r[j++];
		}
	}

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



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

int main(){

 int x,y;
 int t;

 while(true){
 
 cin >> x >> y;

 if (x == y & x == 0) break;

 (x <= y) ? cout<<x << " " << y << endl : cout << y << " " << x << endl; 


}



}



Measured memory_bytes: 3008
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,n,p,q,m,c1,c2,c3;
    string s="error";
    cin>>p>>q;
    if(p+q<10) cout<<p+q<<endl;
    else cout<<s<<endl;
}




Measured memory_bytes: 256
#{print (input().replace('Hoshino','Hoshina')) for i in range(int(input()))}

for i in range(int(input())): 
  textlist = []
  output = ""
  text = input()
  while 1:
    a = text.find("Hoshino")
    if a == -1 :
      textlist.append(text[a+1:])
      break  
    else:
      textlist.append(text[:a]) 
      textlist.append("Hoshina")
      text = text[(a+7):]   
  for j in textlist:
    output += j
  print(output)


Measured memory_bytes: 5596
import math

N,K = map(int,input().split())
A = list(map(int,input().split()))

m = 1
M = max(A)

while(M-m>0):
    mm = 0

    mid = (M+m)//2
    for i in range(N):
        mm += math.ceil(A[i]/mid)-1

    if mm>K:
        m = mid+1
    else:
        M = mid

print(math.ceil(m))




Measured memory_bytes: 103888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int p,y,w,g;
  p = 0;
  y = 0;
  w = 0;
  g = 0;
  string c;
  int N,i;
  cin >> N;
  for(i = 0; i < N; i++){
    cin >> c;
    if(c == "P")
      p = 1;
    if(c == "Y")
      y = 1;
    if(c == "W")
      w = 1;
    if(c == "G")
      g = 1;
  }
  int ans;
  ans = p + y + w + g;
  if(ans == 3){
    cout << "Three" << endl;
  }else{
    cout << "Four" << endl;
  }
}

Measured memory_bytes: 256
a=input().split(" ")

number1=int(a[0])
number2=int(a[1])
n1=0
n2=0

for i in range(number1+1):
    for j in range(number1+1):
        n1=number2-int(i)-int(j)
        if n1<=number1 and 0<=n1:
            n2=n2+1

print(n2)


Measured memory_bytes: 41324
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[] a = new String[h + 2] ;
		for(int i = 0; i <= h + 1; i++) {
			a[i] = "#";
		}
		for(int i = 1; i <= w; i++) {
			a[0] += "#";
			a[h + 1] += "#";
		}
		for(int i = 1; i <= h; i++) a[i] += sc.next();
		for(int i = 0; i <= h + 1; i++) {
			a[i] += "#";
		}
		for(int i = 0; i <= h + 1; i++) {
			System.out.println(a[i]);
		}
	}

}

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

//#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//#define endl "\n"
//#define ll long long

int main()
{
    //ios;

    string str;
    cin>>str;

    int len = str.size();
    for(int i=0; i<len; i++)
    {
        int c = str[i];

        if(isupper(c))
        {
            cout<<"A"<<endl;
        }
        else if(islower(c))
        {
            cout<<"a"<<endl;
        }
    }
    return 0;
}



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

const long long int INF = 1000000000; //KÈå«¢
long long int n, ans, a[21];

void dfs(int i, long long int A, long long int B){
	if( i == n ){
		ans = min( ans , abs(A-B) );
		return;
	}
	dfs( i+1 , A+a[i] , B );
	dfs( i+1 , A , B+a[i] );
	
}

int main(){
	while( cin >> n , n ){
		for(int i=0 ; i < n ; i++ ){
			cin >> a[i];
		}
		ans = INF;
		dfs( 0 , 0 , 0 );
		cout << ans << endl;
	}
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int main()
{
    int n,l;
    cin>>n>>l;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    sort(all(s));
    for(int i=1;i<n;i++){
        s[0]+=s[i];
    }
    cout<<s[0]<<endl;
}


Measured memory_bytes: 256
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

int step(int a, int m) {
    return (a*a)%m;
}

/* At less than m elements the seq repeats. */
void solve() {
    cini(n);
    cini(x);
    cini(m);

    vi first(m, -1);
    vi pre(2*m);

    int ans=0;
    for(int i=1; i<=n; i++) {
        if(first[x]>=0) {
            int loopsize=i-first[x];
            int loopsum=pre[i-1]-pre[first[x]-1];

            int loops=(n-i)/loopsize;
            ans+=loops*loopsum;
            i+=loops*loopsize;
            for(int j=0; j<first.size(); j++)
                first[j]=-1;
        }

        if(i<pre.size()) {
            pre[i]=pre[i-1]+x;
            first[x]=i;
        }

        ans+=x;
        x=step(x,m);
    }
    cout<<ans<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


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


bool solve(string& S, string& T) 
{
	map<char, char> mc, mt;
	int len = S.length();
	for (int i = 0; i < len; i++) {
		char cs = S[i];
		char ct = T[i];
		if (mc.find(cs) != mc.end()) {
			if (mc[cs] != ct) return false; 
		} else {
			mc[cs] = ct;
		}
		if (mt.find(ct) != mt.end()) {
			if (mt[ct] != cs) return false;
		} else {
			mt[ct] = cs;
		}
	}
	return mc.size() == mt.size();
}

int main() 
{
	string S, T;
	cin >> S >> T;
	bool b = solve(S, T);
	if (b) printf("Yes\n");
	else printf("No\n");	
	return 0;
}

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

int main(void){
    int n;
    cin >> n;
    int a[n];
    long long ans = 0;
    rep(i,n){
        cin >> a[i];
        while(a[i] % 2 == 0){
            a[i] /= 2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
## C - Anti-Division
from fractions import gcd
A, B, C, D = map(int, input().split())
s = B-A+1
t = B//C - (A-1)//C
u = B//D - (A-1)//D
v = B//( (C*D)//gcd(C,D) ) - (A-1)//( (C*D)//gcd(C,D) )
print(s - t - u + v)

Measured memory_bytes: 5048
#include<stack>
#include<map>
#include<set>
#include<cstdio>
#include<vector>
#include<iostream>
#include<string>
#include<algorithm> 
using namespace std;
int main(){
	int a=700;
	char c;
	cin>>c;
	if(c=='o'){
		a+=100;
	}
	cin>>c;
	if(c=='o'){
		a+=100;
	}
	cin>>c;
	if(c=='o'){
		a+=100;
	}
	cout<<a<<endl;
	return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  for(int i = a; i <= b; i++) {
    if(c % i == 0) ans++;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3088
#ifdef LOCAL
#include "libs/debug/print_list.hpp"
#define debug(x) (cout << # x ": " << x << endl)
#define dev(v, m, n) for(int i=0;i<n;++i){for(int j=0;j<m;++j){cout<<"|"<<v[j][i];}cout<<"|"<<endl;}
#else
#define debug(x) ;
#define dev(v, m, n) ;
#endif

// :----------------------------------------

#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;
using pi = pair<int, int>;
using vp = vector<pi>;
using Graph = vector<vector<int>>;

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(b<a){a=b;return 1;}return 0;}

#define P (1'000'000'007)

signed main() {
    int d, t, s;
    cin >> d >> t >> s;

    if (d <= t * s) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    
    return 0;
}


Measured memory_bytes: 3132
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer n=nil->next;
  while(1){
    if(n->key==key){
      return n;
    }
    if(n->next==nil){
      break;
    }
    n=n->next;
  }
  return nil;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

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

void deleteNode(NodePointer t){
  NodePointer tmp;
  tmp = t;
  //printf("%d\n", tmp->key);
  //printf("%d\n", tmp->prev->key);
  tmp->prev->next = t->next;
  tmp->next->prev = t->prev;

}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer n=nil->prev;
  deleteNode(n);
  return ;
}

void delete(int key){
  NodePointer n=listSearch(key);
  if(n==nil) return ;
  else deleteNode(n);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  x->prev = nil;
  nil->next->prev = x;
  nil->next = x;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ) {scanf("%d",&key);insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	scanf("%d",&key);
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}




Measured memory_bytes: 36084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, k, a;
  in(n);
  k = n / 11;
  a = n % 11;
  k = k * 2;
  if(0 < a && a < 7)
    k++;
  else if(6 < a)
    k = k + 2;
  out(k);
  memi;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 10000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n,aim[3];
	cin>>n>>aim[0]>>aim[1]>>aim[2];
	vector<int> l;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		l.pb(x);
	}
	ll ans = inf;
	for( int i = 0; i < ( 1 << (2*n) ) ; i++){
		int cur = i;
		int tmp = 0;
		vector<int> v[3];
		for(int j=0;j<n;j++){
			if( cur % 4 != 3) v[ cur % 4 ].pb(l[j]);
			cur /= 4;
		}
		if( v[0].size() != 0 && v[1].size() != 0 && v[2].size() != 0){
			for(int j=0;j<=2;j++){
				tmp += 10 * (v[j].size()-1);
				int sum = 0;
				for(int k=0;k<v[j].size();k++){
					sum += v[j][k];
				}
				tmp += abs( aim[j] - sum );
			}
			if( tmp < ans ) ans = tmp;
		}
	}	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF (ll)(1e17+5)
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
ll H,W;
char grid[1005][1005];
ll dp[1005][1005];
ll fn(ll i,ll j)
{
    if(dp[i][j]!=-1)
     return dp[i][j];
    if(grid[i][j]=='#')
     return dp[i][j]=0;
    if(i==H-1&&j==W-1)
     return dp[i][j]=1;
    if(i==H-1)
     return dp[i][j]=fn(i,j+1)%Mod;
    if(j==W-1)
     return dp[i][j]=fn(i+1,j)%Mod;
    return dp[i][j]=((fn(i+1,j)%Mod)+(fn(i,j+1)%Mod))%Mod;    
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       cin>>H>>W;
       ll i,j,ans;
       memset(dp,-1,sizeof(dp));
       for(i=0;i<H;i++)
        for(j=0;j<W;j++)
         cin>>grid[i][j];
       ans=fn(0,0);
       cout<<ans<<"\n";  
   }
}

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

int main() {
 int a,b,c;
  cin >> a >> b >> c;
  if(a>b){
    swap(a,b);
  }
  if(b>c){
    swap(b,c);
  }
  if(a>b){
    swap(a,b);
  }
  cout << a << ' ' << b << ' ' << c << endl;
}


Measured memory_bytes: 3080
#include <cstdio>
int main()
{
    int N,minn,X,m;
    scanf("%d%d",&N,&X);
    minn=1001;
    for(int i=0;i<N;i++)
    {
        scanf("%d",&m);
        X-=m;
        if(m<minn)
            minn=m;
    }
    printf("%d\n",N+X/minn);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<queue>
#include<map>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;

typedef long long ll;	
typedef pair<int, int> P;
const int maxn = 102;
const int inf = 0x3f3f3f3f;
char a[maxn][maxn];
int vis[maxn][maxn];
int dre[4][2] = { 0,1,1,0,0,-1,-1,0 };
int n, m;

void init()
{
	memset(vis, 0, sizeof(vis));
}

void DFS(int x, int y)
{
	vis[x][y] = 1;
	for (int i = 0; i < 4; i++)
	{
		int nx = x + dre[i][0], ny = y + dre[i][1];
		//cout << " " << nx << " " << ny << endl;
		if (nx >= 0 && nx < n&&ny >= 0 && ny < m && a[nx][ny] == a[x][y] &&!vis[nx][ny])
			DFS(nx, ny);
	}
	return;
}

int main()
{

	while (scanf("%d%d", &n, &m), m || m)
	{
		init();
		int ans = 0;
		for (int i = 0; i < n; i++)
			scanf("%s", &a[i]);
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)
			{
				if (!vis[i][j])
				{
					DFS(i,j);
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3660
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio> 
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rangeRep(i, n, m) for(int (i) = (n); (i) < (m); (i)++)

struct Node
{
	int x, y, turn;
};

class Solve {
public:
	Solve() {};
	~Solve() {};

	void solver() {
		std::vector<int> results;
		std::array<std::array<bool, 121>, 121> field;
		int dx[] = { 1, 0, -1, -1, 0, 1 };
		int dy[] = { 0, -1, -1, 0, 1, 1 };
		while (1) {
			int t, n;
			int startX, startY;
			std::cin >> t >> n;
			if (!t && !n) break;

			//Setting obstacles
			field = { { 0 } };
			rep(i, n) {
				int x, y;
				std::cin >> x >> y;
				field[y + 60][x + 60] = true;
			}
			std::cin >> startX >> startY;
			field[startY + 60][startX + 60] = true;

			//Breadth-first search
			std::queue<Node> q; //Remember coordinates
			int discoverdCount = 1;
			q.push(Node{ startX + 60, startY + 60, 0 });
			while (!q.empty()) {
				auto now = q.front(); q.pop();
				rep(i, 6) {
					auto next = now;
					next.x += dx[i]; next.y += dy[i]; next.turn++;

					//out of range
					if (next.x < 0 || next.x > 120 || next.y < 0 || next.y > 120) {
						continue;
					}
					//obstacle or discovered
					if (field[next.y][next.x]) {
						continue;
					}
					//OK
					discoverdCount++;
					field[next.y][next.x] = true;
					//turn is over
					if (next.turn >= t) continue;
					q.push(next);
				}
			}
			results.push_back(discoverdCount);
		}

		for (auto& x : results) {
			std::cout << x << std::endl;
		}
	}
private:

};

int main() {
	Solve solve;
	solve.solver();
	return 0;
}

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

using namespace std;

typedef long long ll;

constexpr int M = 1000 * 1000 * 1000 + 7;

ll dp[2011][2011];

void init(int n) {
    dp[0][0] = 1;
    for (int j = 1; j <= n; ++j) {
        ll sum = dp[j - 1][j - 1];
        for (int i = j; i <= n; ++i) {
            dp[i][j] = sum;
            sum += dp[i][j - 1];
            sum %= M;
        }
    }
}

ll count(int balls, int positions) {
    return dp[balls][positions];
}

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    init(n);
    for (int i = 1; i <= k; ++i) {
        ll first = count(k, i);
        ll second = 2 * count(n - k, i) % M;
        second += count(n - k, i + 1);
        second += count(n - k, i - 1);
        second %= M;
        cout << first * second % M << endl;
    }
    return 0;
}


Measured memory_bytes: 30208
#include<iostream>
using namespace std;
int main() {
	int N,max = 0,sum = 0;
	int L[1000];
	cin >> N;
	for (int i = 0; i < N; i++) {

		cin >> L[i];
		if (i == 0) {
			max = L[i];
		}
		else if (max <= L[i]) {
			max = L[i];
		}
		sum += L[i];

	}
	sum -= max;
	if (max < sum) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll  INFL = 1e18;

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

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll N, W; cin >> N >> W;
    vl w(N), v(N); REP(i, N) cin >> w[i] >> v[i];
    vvl dp(N+1, vl(W+1, 0));
    REPS(i, N)
    {
        REPS(j, W)
        {
            if(w[i-1] <= j) chmax(dp[i][j], dp[i-1][j-w[i-1]]+v[i-1]);
            chmax(dp[i][j], dp[i-1][j]);
        }
    }
    cout << dp[N][W] << endl;
}

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

int main(){
  string str;
  int n;
  cin>>n>>str;
  if((int)str.length()>n){
    for(int i=0;i<n;i++){
      cout<<str[i];
    }
    cout<<"..."<<endl;
  }
  else cout<<str;
  return 0;
}


Measured memory_bytes: 3596
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var A, B, C, X, Y int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d %d %d %d", &A, &B, &C, &X, &Y)

	ans := math.MaxInt64
	for numC := 0; numC <= 2*max(X, Y); numC = numC + 2 {
		numA := max(X-numC/2, 0)
		numB := max(Y-numC/2, 0)
		v := numA*A + numB*B + numC*C
		ans = min(ans, v)
	}
	fmt.Println(ans)
}

func max(ns ...int) int {
	ret := math.MinInt64
	for _, n := range ns {
		if n > ret {
			ret = n
		}
	}
	return ret
}

func min(ns ...int) int {
	ret := math.MaxInt64
	for _, n := range ns {
		if n < ret {
			ret = n
		}
	}
	return ret
}


Measured memory_bytes: 640
#include<stdio.h>

struct CARD{
  char suit;
  char value;
};

int main(){

  struct CARD C1[100],C2[100],new;
  int n,i,j,min;
  int cnt = 0;
  char c;

  scanf("%d",&n);
  scanf("%c",&c);

  for (i=0;i<n;i++){
    scanf("%c%c%c", &C1[i].suit, &C1[i].value,&c);
  }

  for(i=0;i<n;i++){
    C2[i] = C1[i];
  }

  for(i=0;i<=n-1;i++){
    for(j=n-1; j>=i+1; j--){

      if(C1[j].value < C1[j-1].value){
        new = C1[j];
        C1[j] = C1[j-1];
        C1[j-1] = new;
      }
    }
  }

  for(i=0;i<=n-1;i++){
    min = i;
    for(j=i; j<=n-1; j++)
      if(C2[j].value < C2[min].value) min = j;
    if(min != i) {
      new = C2[i];
      C2[i] = C2[min];
      C2[min] = new;
    }
  }

  for(i=0;i<n-1;i++){
   printf("%c%c ",C1[i].suit,C1[i].value);
  }
  printf("%c%c\n",C1[n-1].suit,C1[n-1].value);
  printf("Stable\n");

  for(i=0;i<n-1;i++){
    printf("%c%c ",C2[i].suit,C2[i].value);
    if(C1[i].suit != C2[i].suit) cnt=1;
  }
  printf("%c%c\n",C2[n-1].suit,C2[n-1].value);

  if(cnt == 1) {
  	printf("Not stable\n");
  }else{
  	printf("Stable\n");
  }

  return 0;
}


Measured memory_bytes: 2108
import sys, math
from functools import lru_cache
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

N, M = mi()
x, y = i2(M)

boxes = [1]*N
red = [False for i in range(N)]
red[0] = True

for i in range(M):
    boxes[x[i]-1] -= 1
    boxes[y[i]-1] += 1

    if red[x[i]-1]:
        red[y[i]-1] = True
    if boxes[x[i]-1] == 0:
        red[x[i]-1] = False

print(red.count(True))



Measured memory_bytes: 35916
#include <iostream>
using namespace std;
int main(void){
    int s[1010],p[1010],q[1010],r[1010];
    int n,P,Q,R,C;
    while(true){
        cin >> n;
        if(n == 0){
            break;
        }
         
        for(int i = 0; i < n; i++){
            cin >> s[i];
            cin >> p[i] >> q[i] >> r[i];
        }
        cin >> P >> Q >> R >> C;
 
        int kcal[1010] = {0};
        for(int i = 0; i < n; i++){
            kcal[i] = 4*p[i] + 9*q[i] + 4*r[i];
        }
         
        int count = 0;
        for(int i = 0; i < n; i++){
            if(p[i] <= P && q[i] <= Q && r[i] <= R && kcal[i] <= C){
                cout << s[i] << endl;
            }
            else
                count++;
        }
        if(count == n){
            cout << "NA" << endl;
        }
    }
}


Measured memory_bytes: 3100