akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  int count = 0;
  vector<int> v(n);
  REP(i, n) {
    cin >> v[i];
    count += v[i];
  }
  sort(v.begin(), v.end(), greater<int>());
  REP(i, m) {
    if(v[i] < ((double)count / (4 * m))) {
        cout << "No" << endl;
        return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
const int mod=1e6+3;
typedef long long ll;
map<int,int>mp,mmp;
#define inf 0x3f3f3f3f
#define mem(a,b) memset(a,b,sizeof(a))
#define pi acos(-1.0)
void read(int &x)
{
	int f=1;x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=f;
}
int a[205],n,l;
int main()
{
   read(n),read(l);
   int sum=0,i,j;
   for(i=1;i<=n;i++)
   {
   	a[i]=l+i-1;
   	sum+=a[i];
   }
   if(a[n]<0)sum-=a[n];
   else if(a[1]>0)sum-=a[1];
   printf("%d\n",sum);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include<set>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*約数*/vector<ll>div(ll a){vector<ll>b;ll i;rep(i,1,a){if(!a%i)push(b,a);}return b;}
/*円周率*/ double pi=acos(-1);
llfor;///////////////////////////////////////////////////////////
int main(){
 int a,b,c;
 sc(a);sc(b);sc(c);
 if(a<=c&&c<=b)py;
 else pn;
return 0;}



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

int main(){
   double xA,yA,xB,yB,xC,yC,xD,yD;
   while(cin >> xA >> yA >> xB >> yB >> xC >> yC >> xD >> yD){
      if(xA<=xD && yA<=yD && xC<=xB && yC<=yB)cout << "YES" << endl;
      else cout << "NO" << endl;
   }
   return 0;
}

Measured memory_bytes: 1228
a = gets.split.map(&:to_i)
ans = a[1]
if (a[0]%2)+(a[3]%2)+(a[4]%2) >= 2 && [a[0], a[3], a[4]].min > 0
  ans += 3
  a[0] -= 1
  a[3] -= 1
  a[4] -= 1
end

ans += (a[0] / 2) * 2
ans += (a[3] / 2) * 2
ans += (a[4] / 2) * 2

puts ans

Measured memory_bytes: 3836
import java.util.*;
import java.io.*;

class Main {
	public static void main(String... args) {
		int K = IN.nextInt();
		puts((K / 2) * ((K + 1) / 2));
		flush();
	}

	static final Scanner IN = new Scanner(System.in);
	static final PrintWriter OUT = new PrintWriter(System.out);
	static <T> void puts(T arg) { OUT.println(arg); }
	static void flush() { OUT.flush(); }
}


Measured memory_bytes: 23124
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(k-1,n-1):
  if int(a[i-k+1]) < int(a[i+1]):
    print("Yes")
    i+=1
  elif int(a[i-k+1])>=int(a[i+1]):
    print("No")
    i+=1


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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define ll long long
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 1e5 + 10;
const int inf = 1e9 + 7;

main()
{
    string s;
    cin >> s;
    for( int i = 0; i < s.size() - 8; i ++ )
        cout << s[i];
}


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

using namespace std;

int main()
{
  string S; cin >> S;
  bool isGood = true;
  for (int i=1; i < S.size(); i++) {
    if (S.at(i) == S.at(i - 1)) isGood = false;
  }

  cout << (isGood ? "Good" : "Bad") << endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		
		if(n%2 == 0) System.out.println(n);
		else System.out.println(n*2);
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n;
   cin>>n;
   vector<int> p(n);
   for(int i=0;i<n;i++){
      cin>>p.at(i);
   }

   int count=0;
   for(int i=1;i<n-1;i++){
      if(p.at(i-1)<=p.at(i) && p.at(i)<=p.at(i+1))
         count++;
      else if(p.at(i-1)>=p.at(i) && p.at(i)>=p.at(i+1))
         count++;
   }
   cout<<count<<endl;
}

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

int main(){
    string s;
    cin >> s;
    int stl = s.size();
    char last = '0';
    int cnt = 0;
    for(int i = 0;i < stl;i++){
        char S = s[i];
        if(S==last&&i<stl-1){
            S='0';
            i++;
        }
        if(S!=last) cnt++;
        last = S;
    }
    
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdlib>

using namespace std;
#define SIZE 200
struct Stack{
  int line[SIZE];
  int top;
  void init()
  {
    top=-1;
  }
  bool isFull()
  {
    return top==SIZE;
  }
  bool isEmpty()
  {
    return top==-1;
  }
  void push(int x)
  {
    if(isFull()){
      cout<<"ERROR (OVER FLOW)"<<endl;
      exit(1);
    }
    top++;
    line[top]=x;
  }
  int pop()
  {
    if(isEmpty()){
      cout<<"ERROR (UNDER FLOW)"<<endl;
      exit(1);
    }
    int x=line[top];
    top--;
    return x;
  }
};

int calc(int numA,string str,int numB)
{
  //cout<<"numA,numB,str:"<<numA<<','<<numB<<','<<str<<endl;
  if(str=="+"){
    return numB+numA;
  }else if(str=="-"){
    return numB-numA;
  }else{
    return numB*numA;
  }
}


int main()
{
  string str;
  Stack stack;
  stack.init();
  int numA,numB;
  while(cin>>str){
    if((str=="+")or(str=="-")or(str=="*")){
      numA=stack.pop();
      numB=stack.pop();
      stack.push(calc(numA,str,numB));
    }else{
      int num=atoi(str.c_str());
      stack.push(num);
    } 
  }
  cout<<stack.pop()<<endl;
  return 0;
}



Measured memory_bytes: 3204
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class BDigits {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, k; cin >> n >> k;
      int d = 0;
      while(n > 0) {
        n /= k;
        d++;
      }
      cout << d << endl;
    }
};

signed main() {
  BDigits solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
int a,b;
scanf("%5d",&a);
scanf("%5d",&b);
 if(a>b){
   printf("a > b\n",a,b);
 }
 if(a<b){
   printf("a < b\n",a,b);
 }
 if(a==b){
   printf("a == b\n",a,b);
 }
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

ll N, M, R;
llvec r;
ll d[300][300];

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  cin >> N >> M >> R;
  r = llvec(R);
  rep(i, R){
    cin >> r[i];
    --r[i];
  }
  /*
  rep(i, N){
  rep(j, N){
  d[i][j]=1e18;
  }
  }
  */
  fill(d[0], d[300], 1e18);
  rep(i, M){
    ll a, b, c;
    cin >> a >> b >> c;
    a--;b--;
    d[a][b]=c;
    d[b][a]=c;
  }
  rep(i, N){
    d[i][i]=0;
  }  
  rep(k, N){
    rep(i, N){
      rep(j, N){
        d[i][j]=min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  ll ans = 1e18;
  llvec o(R);
  rep(i, R)o[i]=i;
  do{
    ll tmp = 0;
    rep(i, R-1){
      tmp += d[ r[o[i]] ][ r[o[i+1]] ];
    }
    ans = min(ans, tmp);
    //DUMP(j, r);cerr<<endl;
  }while(next_permutation(ALL(o)));
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back

int main(){
    int n,x;
    cin >> n >> x;
    int m[n];
    for(int i=0;i<n;i++) cin >> m[i];

    int count=n;
    int min=m[0];
    for(int i=0;i<n;i++){
        x-=m[i];
        if(min>m[i]){
            min=m[i];
        }
    }
    count+=x/min;
    cout << count << endl;
    return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;

    double ans = 0.0;
    if(N >= K){
        for(int i = 1; i <= K-1; ++i){
            ans += pow(0.5, ceil(log2(K)-log2(i)));
        }
        ans += N-K+1.0;
        ans /= N;
    }else{
        for(int i = 1; i <= N; ++i){
            ans += pow(0.5, ceil(log2(K)-log2(i)));
        }
        ans /= N;
    }

    printf("%.10lf\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  string s;
  cin >> s;
  for(int i=0;i<3;++i){
      if(s[i] == '7'){
          cout << "Yes" << endl;
          return 0;
      }
  }
  cout << "No" << endl;
  return 0;
}

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

Measured memory_bytes: 3600
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    w = int(input())

    res = [s[i] for i in range(0, len(s), w)]
    print("".join(res))


if __name__ == '__main__':
    resolve()


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

int func(int num){
    if (num < 10) {
        return num;
    }
    int sum = 0;
    while (num) {
        sum += num % 10;
        num /= 10;
    }
    return sum;
}

int main() 
{
    int N;
    int A, B;
    cin >> N >> A >> B;
    
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int sum = func(i);
        if (A <= sum && sum <= B) {
            ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
r, c = map(int, input().split())
nums = []
for i in range(r):
    i = list(map(int, input().split()))
    i_add = sum(i)
    i.append(i_add)
    nums.append(i)
last = []
for j in range(c):
    add_num = 0
    for k in range(r):
        add_num += nums[k][j]
    last.append(add_num)
last_sum = sum(last)
last.append(last_sum)
nums.append(last)
for i in nums:
    L = [str(m) for m in i]
    print(' '.join(L))




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

#define mod 1000000007
#define LOCAL 0
#define pb push_back
#define ll long long

ll po(ll a,ll b){
	ll x = 1,y=a;
	while(b>0){
		if(b%2){
			x = x*y;
			x %= mod;
		}
		y=y*y;
		y%=mod;
		b/=2;
	}
	return x;
}

vector<pair<int,ll> > adj[200005];


//	multiple source dijkstra.
//	returns the distance vector from the source/s.

ll dij(int src,int des,int n,ll lim){
	set<pair<ll,int> > q;	//	pair(dist,node).
	static bool vis[305];
	memset(vis,false,sizeof(vis));
	static ll dis[305];
	q.insert(make_pair(0ll,src));
	for(int i=0;i<=n;i++){
		dis[i] = 1e16;
	}
	dis[src] = 0ll;

	while(q.size()){
		pair<ll,int> tmp = *q.begin();
		q.erase(q.begin());
		if(vis[tmp.second]){
			continue;
		}
		if(tmp.second == des){
			return tmp.first;
		}
		if(tmp.first >= lim){
			continue;
		}
		vis[tmp.second] = true;
		dis[tmp.second] = tmp.first;

		int cur = tmp.second;
		for(int i=0;i<adj[cur].size();i++){
			if(!vis[adj[cur][i].first] && dis[adj[cur][i].first] > tmp.first + adj[cur][i].second){
				dis[adj[cur][i].first] = tmp.first + adj[cur][i].second;
				q.insert(make_pair(dis[adj[cur][i].first],adj[cur][i].first));
			}
		}
	}

	return 1e16;
}

int main(){
	if(LOCAL){
    	freopen("C:/Users/gold/Desktop/sublime IO/input.txt","r",stdin);
    	freopen("C:/Users/gold/Desktop/sublime IO/output.txt","w",stdout);
	}
	int T = 1;
	//scanf("%d",&T);
	while(T--){
		int n = 300;
		scanf("%d",&n);
		static int A[305][305];
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				scanf("%d",&A[i][j]);
			}
		}		
		for(int k=0;k<n;k++){
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					if(A[i][k] + A[k][j] < A[i][j]){
						puts("-1");
						exit(0);
					}
				}
			}
		}
		//	yes valid one.
		ll ans = 0ll;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				bool res = false;
				for(int k=0;k<n;k++){
					if(k != i && k != j){
						if(A[i][k] + A[k][j] == A[i][j]){
							res = true;
						}
					}
				}
				if(!res){
					ans += A[i][j];
				} 
			}
		}
		printf("%lld\n",ans);
	}
	return 0;	
}

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

using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	if(a>0) puts("Positive");
	else if(a<=0&&b>=0) puts("Zero");
	else if((b-a)&1) puts("Positive");
	else puts("Negative"); 
	return 0;
}

Measured memory_bytes: 256
N=int(input())

Station=[]
for n in range(N-1):
    Station.append(list(map(int,input().split())))
    
S=range(N)
for i in range(len(S)):
    t=0
    for s in range(i,len(S)-1):
        if t <= Station[s][1]:
            t = Station[s][1] + Station[s][0]
        else:
            if t%Station[s][2] != 0:
                t = t + (Station[s][2]-t%Station[s][2]) + Station[s][0]
            else:
                t = t + Station[s][0]
    print(t)

Measured memory_bytes: 74456
n,a,b,k = map(int, input().split())

mod = 998244353
NUM = 10**6
g1 = [1, 1]
g2 = [1, 1]
inv = [0, 1]

for i in range( 2, NUM + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inv.append( ( -inv[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inv[-1]) % mod )

def comb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

ans=0
for i in range(n+1):
    if (k-i*a)%b == 0 and (k-i*a)>=0:
        j=(k-i*a)//b
        if j>n:
            continue
        ans+=(comb(n,i,mod)*comb(n,j,mod))
        ans%=mod
print(ans)

Measured memory_bytes: 128012
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

#define INF 210000000
#define int long long

static long long gcd(long long a, long long b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

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

signed main() {
    int n;
    cin >> n;
    int tele,walk;
    cin >> walk >> tele;
    vector<int> town;
    for (int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        town.push_back(tmp);
    }
    int ans = 0;
    for (int i=1;i<n;i++){
        if((town[i] - town[i-1]) * walk < tele){
            ans += (town[i] - town[i-1]) * walk;
        }else{
            ans += tele;
        }
    }
    cout << ans;
}



Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main() {

int N;
cin >>N;

int x[100];
int y[100];
int h[100];

int xo;
int yo;
int ho;//高さを推定するために使うサンプルデータ

for(int i=0;i<N;i++){
cin >>x[i]>>y[i]>>h[i];

if(h[i]!=0){xo=x[i];yo=y[i];ho=h[i];}
}

int cx;
int cy;
int H;

int sh;//中心を決め打ちした時の推定の高さ

for(int i=0; i<=100; i++){
for(int j=0; j<=100; j++){

sh=ho+abs(xo-i)+abs(yo-j);//サンプルデータから高さを推定


for(int k=0;k<N;k++){
if(h[k]!=max(sh-abs(x[k]-i)-abs(y[k]-j),0)){break;}

if(k==N-1){cx=i;cy=j;H=sh;}
}
}
}

cout<<cx<<" "<<cy<<" "<<H;

}



Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string s, comp = "AIDUNYAN";
  sort(comp.begin(),comp.end());
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    string c = s.substr( i, 8);
    sort( c.begin(), c.end());
    if(c == comp) cout << "AIZUNYAN", i += 7;
    else cout << s[i];
  }
  cout << endl;
}

Measured memory_bytes: 1212
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct log{
  int t,n,m,s;
  bool operator<(const log&a)const{
    return n==a.n ? (m == a.m? t < a.t : m < a.m) : n<a.n;
  }
};
int main(){
  int nu,me,i,j,k,o,f;
  cin >> nu >> me;
  while(nu!=0||me!=0){
    int r,q;
    cin >> r;
    int t,n,m,s,ts,te;
    vector <log> logs;
    log l;
    for(i=0;i<r;i++){
      cin >> l.t >> l.n >> l.m >> l.s ;
      logs.push_back(l);
    }
    cin >> q;
    sort(logs.begin(),logs.end());
    i=0;

    int a;
    for(a=0;a<q;a++){
      cin >> ts >> te >> m ;
      
      j=0;
      o=0;
      f=0;
      for(i=ts;i<te;i++){
	f=0;
	k=0;
	for(j=0;j<logs.size();j+=2){
	  if(logs[j].m==m&&logs[j].t<=i&&i<logs[j+1].t){
	    f=1;
	  }
	}
	
	o+=f;
      }
      cout << o << endl;
    }
    
    cin >> nu >> me;
  }
  return 0;
}

Measured memory_bytes: 1248
N = int(input())
xs = [[] for i in range(N)]
for i in range(N):
    a = int(input())
    for j in range(a):
        x,y = map(int,input().split())
        xs[i].append((x-1,y))
ans = 0
for b in range(1<<N):
    mujun = False
    for k,z in enumerate(xs):
        for x,y in z:
            if b&(1<<k):
                if b&(1<<x):
                    if y==0:
                        mujun = True
                else:
                    if y==1:
                        mujun = True
            if mujun:
                break
        if mujun:
            break
    if not mujun:
        tmp = bin(b).count('1')
        ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 44780
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int a,b;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cout << fixed << setprecision(12);
	cin >> a >> b;
	print1(ceiling(a,2*b+1));
	return 0;
}

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

using namespace std;

int main()
{
    //system("chcp 65001");

    int A,B;
    cin >> A >> B;

    int your_coin = 0;

    if(A == B)
    {
        your_coin += A;
        A--;
    }
    else if(A > B)
    {
        your_coin += A;
        A--;
    }
    else
    {
        your_coin += B;
        B--;
    }

    if (A == B)
    {
        your_coin += A;
        A--;
    }
    else if (A > B)
    {
        your_coin += A;
        A--;
    }
    else
    {
        your_coin += B;
        B--;
    }

    cout << your_coin;

    return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    for(i <- 1 to 9) {
      for (j <- 1 to 9) {
        if (n == i*j) {
          println("Yes")
          System.exit(0)
        }        
      }
    }
    println("No")
  }
}


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

long long n;
vector<long long> a, ans;

void solve();

int main() {
  cin >> n;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  solve();
  for(int i = 0; i < n; ++i) {
    if(i != 0) cout << " ";
    cout << ans[i] + 1;
  }
  cout << endl;
  return 0;
}

void solve() {
  auto f = [](long long& l, long long& r) {
    return a[l] < a[r];
  };
  for(int i = 0; i < n; ++i) ans.push_back(i);
  sort(ans.begin(), ans.end(), f);
}

Measured memory_bytes: 2548
# ABC131D - Megalomania
from itertools import accumulate as acc
from operator import itemgetter as gt


def main():
    N = int(input())
    A = sorted([tuple(map(int, input().split())) for _ in range(N)], key=gt(1))
    T, D = zip(*A)  # tasks, deadlines
    # all tasks finish within each deadline?
    flg = all(t <= d for t, d in zip(acc(T), D))
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

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


ll H;

void Main() {
  cin >> H;

  int i = 0;
  ll ans = 0;
  while (true) {
    ans += pow(2, i);
    i++;

    if (H == 1) break;
    H /= 2;
  }

  cout << ans << endl;
}

int main() {
  Main();
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String resultA = "";
        String resultB = "";
        for (int i = 0; i < Integer.parseInt(b); i++) {
            resultA += a;
        }
        for (int i = 0; i < Integer.parseInt(a); i++) {
            resultB += b;
        }
        System.out.print((resultA.compareTo(resultB)) < 0? resultA : resultB);
    }
}

Measured memory_bytes: 21844
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int NMAX=3*1e5+1;
int n,est_total=0,ouest_total=0,est=0,ouest=0;
string s;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> s;
	
	int minimum=n;
	
	for(int i=0;i<n;i++){
		if(s[i]=='E') est_total++;
		else ouest_total++;
	}
	
	for(int i=0;i<n;i++){
		
		minimum=min(minimum,ouest+est_total-(s[i]=='E')-est);
		
		if(s[i]=='E') est++;
		else ouest++;
	}
	
	cout << minimum << '\n';
}


Measured memory_bytes: 720
def cost(m, w)
  (m - w).abs * (((m - w).abs - 30) ** 2)
end

until gets.split.map(&:to_i).all?(&:zero?)
  m = gets.split.map(&:to_i)
  w = gets.split.map(&:to_i)

   dp = Array.new(m.size + 1){Array.new(1 << w.size, 0)}

  m.size.times do |i|
    (1 << w.size).times do |bit|
      w.size.times do |j|
        next if bit[j].zero?
        dp[i][bit] = [dp[i - 1][bit], dp[i][bit], dp[i - 1][bit ^ (1 << j)] + cost(m[i], w[j])].max
      end
    end
  end

  p dp[m.size - 1].max
end

Measured memory_bytes: 6960
N,C = map(int,input().split())
D = [list(map(int,input().split())) for i in range(C)]
L = [list(map(int,input().split())) for i in range(N)]

d0 = {}
d1 = {}
d2 = {}

for i in range(N) :
    for j in range(N) :
        before = L[i][j] - 1
        
        if (i+j) % 3 == 0 :
            if before not in d0 :
                d0[before] = 1
            else :
                d0[before] += 1

        elif (i+j) % 3 == 1 :
            if before not in d1 :
                d1[before] = 1
            else :
                d1[before] += 1

        else :
            if before not in d2 :
                d2[before] = 1
            else :
                d2[before] += 1



A0 = []
A1 = []
A2 = []

for after in range(C) :
    calc = 0
    for before in d0 :
        calc += D[before][after] * d0[before]
    A0.append([calc,after])

for after in range(C) :
    calc = 0
    for before in d1 :
        calc += D[before][after] * d1[before]
    A1.append([calc,after])

for after in range(C) :
    calc = 0
    for before in d2 :
        calc += D[before][after] * d2[before]
    A2.append([calc,after])
    
A0 = sorted(A0,key=lambda x:x[0],reverse=False)[:3]
A1 = sorted(A1,key=lambda x:x[0],reverse=False)[:3]
A2 = sorted(A2,key=lambda x:x[0],reverse=False)[:3]
B = [A0,A1,A2]

ans = float("inf")

for i in range(3) :
    for j in range(3) :
        for k in range(3) :
            if (B[0][i][1] - B[1][j][1]) * (B[1][j][1] - B[2][k][1]) * (B[2][k][1] - B[0][i][1]) == 0 :
                continue
            
            ans = min(ans, B[0][i][0] + B[1][j][0] + B[2][k][0])

print(ans)


Measured memory_bytes: 5748
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    N =ii()%10
    if N==3:
        print('bon')
    elif N in (0, 1,6,8):
        print('pon')
    else:
        print('hon')

main()



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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

ll inf = (1ll << 40);

int main() {
  ll n, m;
  cin >> n >> m;
  vi u(m), v(m);
  for (ll i = 0; i < m; i++) {
    cin >> u[i] >> v[i];
    u[i] -= 1;
    v[i] -= 1;
  }
  ll s, t;
  cin >> s >> t;
  s -= 1;
  t -= 1;

  vvi g(n);

  for (ll i = 0; i < m; i++) {
    g[u[i]].push_back(v[i]);
  }

  vi dist0(n, inf), dist1(n, inf), dist2(n, inf);

  dist0[s] = 0;
  priority_queue<pii, vpii, greater<pii>> pq0, pq1, pq2;
  pq0.push({0, s});

  while (pq0.size() + pq1.size() + pq2.size()) {
    ll i0 = pq0.size() ? pq0.top().first : inf;
    ll i1 = pq1.size() ? pq1.top().first : inf;
    ll i2 = pq2.size() ? pq2.top().first : inf;

    if (i0 <= min(i1, i2)) {
      ll fr = pq0.top().second;
      pq0.pop();
      for (ll to: g[fr]) {
        if (dist1[to] > dist0[fr] + 1) {
          dist1[to] = dist0[fr] + 1;
          pq1.push({dist1[to], to});
        }
      }
    } else if (i1 <= min(i0, i2)) {
      ll fr = pq1.top().second;
      pq1.pop();
      for (ll to: g[fr]) {
        if (dist2[to] > dist1[fr] + 1) {
          dist2[to] = dist1[fr] + 1;
          pq2.push({dist2[to], to});
        }
      }
    } else {
      ll fr = pq2.top().second;
      pq2.pop();
      for (ll to: g[fr]) {
        if (dist0[to] > dist2[fr] + 1) {
          dist0[to] = dist2[fr] + 1;
          pq0.push({dist0[to], to});
        }
      }
    }
  }

  if (dist0[t] == inf) {
    cout << -1 << endl;
    return 0;
  }

  cout << dist0[t] / 3 << endl;
}


Measured memory_bytes: 9600
using System;
using System.Collections.Generic;

namespace abc131_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var a = CIn.ReadLong();
      var b = CIn.ReadLong();
      var c = CIn.ReadLong();
      var d = CIn.ReadLong();

      var lcm = LCM(c, d);

      var cn = b / c - (a - 1) / c;
      var dn = b / d - (a - 1) / d;
      var cdn = b / lcm  - (a - 1) / lcm;

      var ans = b - a + 1 - cn - dn + cdn;

      Console.WriteLine(ans);
    }

    static long LCM(long a, long b)
    {
      var ab = a * b;

      if (a < b)
      {
        var tmp = a;
        a = b;
        b = tmp;
      }

      var r = a % b;

      while (r != 0)
      {
        a = b;
        b = r;
        r = a % b;
      }

      return ab / b;
    }
  }


  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 13268
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <vector>
#include <cmath>

int init_state (std::vector<int32_t>& state, int32_t pattern, int32_t N) {
  int32_t t_cnt = 0;
  for (int32_t i = 0; i < N; i++) {
    if ((pattern & 1) == 1) {
      state[i] = 1;
      t_cnt++;
    } else {
      state[i] = 0;
    }
    pattern = pattern >> 1;
  }
  return t_cnt;
}

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

  int32_t N;
  std::cin >> N;
  std::vector<std::vector<int32_t>> testify(N, std::vector<int32_t>(N,-1));
  for (int32_t i = 0; i < N; i++) {
    int32_t ai;
    std::cin >> ai;
    for (int32_t j = 0; j < ai; j++) {
      int32_t x, y;
      std::cin >> x >> y;
      testify[i][x-1] = y;
    }
  }

  int32_t max = std::pow(2, N) - 1;
  int32_t num_true = 0;
  int32_t max_num_true = 0;
  for (int32_t pattern = max; pattern >= 0; pattern--) {
    // T/F state
    std::vector<int32_t> state(N);
    num_true = init_state(state, pattern, N);
    bool contradiction = false;

    for (int32_t a = 0; a < N; a++) {
      if (state[a] == 0) continue;
      for (int32_t x = 0; x < N; x++) {
        int32_t test = testify[a][x];
        if (test == -1) continue;
        if (test == 0 && state[x] == 1) {
          contradiction = true;
          break;
        } else if (test == 1 && state[x] == 0) {
          contradiction = true;
          break;
        }
      }
      if (contradiction) {
        break;
      }
    }
    if (!contradiction) {
      max_num_true = std::max(max_num_true, num_true);
    }
  }
  std::cout << max_num_true << std::endl;
  return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};



int main()
{
  int n; cin >> n;
  vector<int> c(n);
  rep(i, n) cin >> c[i];
  vector<mint> dp(n+1, 0);
  map<int, int> prev;
  dp[0] = 1;
  rep(i, n) {
    dp[i+1] = dp[i];
    if(prev[c[i]] != 0 && i != prev[c[i]]) dp[i+1] += dp[prev[c[i]]];
    prev[c[i]] = i+1;
  }
  cout << dp[n].x << endl;
}


Measured memory_bytes: 14796
#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <random>
#include <stdio.h>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl


void func() {
  LL N;
  cin >> N;
  N--;
  vector<LL> C(N);
  vector<LL> S(N);
  vector<LL> F(N);

  REP(i, N) {
    cin >> C[i];
    cin >> S[i];
    cin >> F[i];
  }

#if 0
  PRINTLN(C);
  PRINTLN(S);
  PRINTLN(F);
#endif

  for (LL start = 0; start < N+1; start++) {
    LL now = 0;
    for (LL i = start; i < N; i++) {
      now = max(now, S[i]);
      
      LL wait = (now - S[i]) % F[i];
      LL wait_ = 0;
      // for (; now % F[i] != 0; now++) {}
      //
      if (now % F[i] != 0) {
        now += F[i] - (now % F[i]);
      }
      
      now += C[i];
    }
    cout << now << endl;
  }
}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, x;
    cin >> n >> x;

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    int64_t ans = 1L << 50;
    for (auto i : irange(0L, n)) {
        int64_t s = accumulate(a.begin(), a.end(), 0L);
        ans = min(s + i * x, ans);

        auto aa = a[n - 1];
        for (auto j : irange(1L, n) | reversed) {
            a[j] = min(a[j], a[j - 1]);
        }
        a[0] = min(a[0], aa);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 1e5 + 5;
const int mod = 1e9 + 7; 
using namespace std;

int n, fac[N], inv[N], ans[N], pos[N], len, a[N]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int C(int n, int m)
{
	if(n < 0 || m < 0 || n < m) return 0;
	return 1ll * fac[n] * inv[m] % mod * inv[n - m] % mod; 
}

int fpow(int x, int y)
{
	int res = 1;
	for( ; y; y >>= 1, x = 1ll * x * x % mod)
		if(y & 1) res = 1ll * res * x % mod;
	return res; 
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin); 
#endif
	n = read <int> ();
	for(int i = (fac[0] = 1); i <= n + 1; i++)
	{
		a[i] = read <int> (), fac[i] = 1ll * fac[i - 1] * i % mod;
		if(!pos[a[i]]) pos[a[i]] = i; 
		else len = i - pos[a[i]] - 1; 
	}
	inv[n + 1] = fpow(fac[n + 1], mod - 2);
	for(int i = n; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;
	for(int i = 1; i <= n + 1; i++)
	{
		ans[i] = C(n, i); 
		if(i >= 2) ans[i] = (ans[i] + C(n - 1, i - 2)) % mod; 
	}
	for(int i = 1; i <= n; i++) ans[i] = (1ll * ans[i] + C(n - 1, i - 1) - C(n - len - 1, i - 1) + mod) % mod; 
	for(int i = 1; i <= n + 1; i++) printf("%d\n", ans[i]); 
	return 0; 
}


Measured memory_bytes: 4968
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
using namespace std;
using ll=long long;

int main(){
	int a,b,c;

	cin>>a>>b>>c;

	if(min(a,b)<=c&&max(a,b)>=c)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;



}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) cin >> p[i];

  int ans = 0;
  for (int i = 1; i < n - 1; ++i) {
    if ((p[i] > p[i - 1] && p[i] < p[i + 1]) || (p[i] < p[i - 1] && p[i] > p[i + 1])) ans++;
				    
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
import math 
import bisect
import heapq
from collections import deque

n = int(input())
b = list(map(int,input().split())) + [0]
b[n-1] = 100000 
a = [0] * n
a[0] = b[0]
for i in range(1,n):
    a[i] = min(b[i-1],b[i])

print(sum(a))


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

int main(){
  int A, B;
  cin >> A >> B;
  if (A <= 9 && B <= 9) cout << A*B << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
	double d;
	while(cin>>d,d){
		for(int i = 1; i < 1000000; i++){
			int x = M_PI * i;
			double y = (double) x / i;
			if(abs(y - M_PI) < d){
				printf("%d/%d\n",x,i);
				break;
			}
			y = (double)(x+1)/i;
			if(abs(y - M_PI) < d){
				printf("%d/%d\n",x+1,i);
				break;
			}
		}
	}

	return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;

  if (A % 2 != B % 2)
    cout << "IMPOSSIBLE" << endl;
  else
    cout << (A + B) / 2 << endl;
  return 0;
}

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

int main(void){
	char s[1000] = {'\0'};
    int w;
	int i;
	int len;
    scanf("%s %d", s, &w);
	len = strlen(s);
	for(i=0;i<len;i+=w){
		printf("%c",s[i]);
	}
	putchar('\n');
    return 0;
}

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


int substr_count(string s,string target)
{
	int occurrences = 0;
   std::string::size_type pos = 0;
   // std::string s = "FooBarFooBarFoo";
   // std::string target = "Foo";
   while ((pos = s.find(target, pos )) != std::string::npos) {
          ++ occurrences;
          pos += target.length();
   }
   // std::cout << occurrences << std::endl;
   return occurrences;
}

int main(){
	string s; getline(cin,s);
	int ans = (substr_count(s,"-") * -1) + substr_count(s,"+");
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        String line =  new Scanner(System.in).next();
        int r1 = 0, r2 = 0;
        boolean b = true;
        for (char c : line.toCharArray()) {
            if (b) {
                if (c == '0') {
                    ++r1;
                } else {
                    ++r2;
                }
            } else {
                if (c == '1') {
                    ++r1;
                } else {
                    ++r2;
                }
            }
            b = !b;
        }
        System.out.println(Math.min(r1, r2));
    }
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  string s;
  cin >> s;

  ll n = s.size();

  for (int i = 1; i < n; i += 2) {
    if (s[i] == '0') {
      s[i] = '1';
    } else {
      s[i] = '0';
    }
  }

  REP(i, n) {
    if (s[i - 1] == s[i]) {
      s.erase(s.begin() + i - 1, s.begin() + i + 1);
      i -= 2;
      if (i < 0) {
        i = 0;
      }
    }
  }

  cout << n - s.size() << endl;

  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

typedef pair<int, int> pii;

int p[100001];
set<int> nbrs[100001];
int vis[100001];

void dfs(int a, int marker) {
    if (vis[a] != 0) return;
    vis[a] = marker;
    for (set<int>::iterator iter = nbrs[a].begin(); iter != nbrs[a].end(); ++iter) {
        int nbr = *iter;
        if (!vis[nbr]) dfs(nbr, marker);
    }
}

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.setf(ios::showpoint);
    cout.precision(12);
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    for (int i = 0; i < N; ++i) { cin >> p[i]; --p[i]; }
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        nbrs[a].insert(b);
        nbrs[b].insert(a);
    }

    int marker = 1;
    for (int i = 0; i < N; ++i) {
        if (!vis[i]) dfs(i, marker++);
    }

    map<int, set<int> > sets;
    for (int i = 0; i < N; ++i) {
        sets[vis[i]].insert(i);
    }

    int best = 0;
    for (int i = 0; i < N; ++i) {
        if (sets[vis[i]].find(p[i]) != sets[vis[i]].end()) ++best;
    }

    cout << best << endl;

    return 0;
}


Measured memory_bytes: 29056
def gcd(x,y):
  if y == 0:
    return x
  else:
    return gcd(y,x%y)
n,x = map(int,input().split())
X = list(map(int,input().split())) + [x]
X.sort()
Dif_X = []
for i in range(n):
    Dif_X += [X[i+1]-X[i]]
gcd_Dif_X = Dif_X[0]
for i in range(n):
    gcd_Dif_X = gcd(gcd_Dif_X,Dif_X[i])
print(gcd_Dif_X)

Measured memory_bytes: 14252