akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
int A;
int B;
int C;
int D;
int main(){
  rd(A);
  rd(B);
  rd(C);
  rd(D);
  for(;;){
    C -= B;
    if(C <= 0){
      wt_L("Yes");
      wt_L('\n');
      break;
    }
    A -= D;
    if(A <= 0){
      wt_L("No");
      wt_L('\n');
      break;
    }
  }
  return 0;
}
// cLay varsion 20200419-1

// --- original code ---
// int A, B, C, D;
// {
//   rd(A,B,C,D);
//   for(;;){
//     C -= B;
//     if(C <= 0) wt("Yes"), break;
//     A -= D;
//     if(A <= 0) wt("No"), break;
//   }
// }


Measured memory_bytes: 3600
# Popular Vote
# https://atcoder.jp/contests/abc161/tasks/abc161_b

from sys import stdin, stdout

n, m = map(int, stdin.readline().split())
a = sorted(list(map(int, stdin.readline().split())), reverse=True)
items = 0
for item in a:
    if items >= m or item < sum(a) / (4 * m):
        break
    items += 1
if items >= m:
    stdout.write("Yes\n")
else:
    stdout.write("No\n")


Measured memory_bytes: 2940
from collections import Counter
n, x, y = map(int, input().split())

def func(i,j,x=x,y=y):
  return min(abs(j-i), abs(x-i)+1+abs(y-j))

count = []
for i in range(1,n):
  for j in range(i+1, n+1):
    count.append(func(i,j))
    
counted = Counter(count)
for i in range(1,n):
    print(str(counted[i]))

Measured memory_bytes: 67716
#include<stdio.h>

struct Card{
  char suit;
  char value;
};

void bubble(struct Card A[], int n){
  int i, j;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    for ( j = n-1; j >= i+1; j-- ){
      if ( A[j].value < A[j-1].value ){
        t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(struct Card A[], int n){
  int i, j, mini;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    mini = i;
    for ( j = i; j < n; j++ ){
      if ( A[j].value < A[mini].value ) mini = j;
    }
    t = A[i]; A[i] = A[mini]; A[mini] = t;
  }
}

void print(struct Card A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i ) printf(" ");
    printf("%c%c", A[i].suit, A[i].value);
  }
  printf("\n");
}

int isStable(struct Card C1[], struct Card C2[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( C1[i].suit != C2[i].suit ) return 0;
  }
  return 1;
}

int main(){
  struct Card C1[101], C2[101];
  int n, i;
  char ch;

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

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

  bubble(C1, n);
  selection(C2, n);

  print(C1, n);
  printf("Stable\n");
  print(C2, n);
  if ( isStable(C1, C2, n) ){
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
const ll INF = ll(1e18);
const ll mod = ll(1e9 + 7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (b) - 1; (i) >= (a); --(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
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; }
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

//modの値の確認をすること
int main(){
    ll n,ans = 0;
    cin >> n;
    rep1(i, n){
        ll a;
        cin >> a;
        if(a & 1 && i & 1)++ans;
    }
    pf(ans);
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int main(void)
{
    int n,result=0;
    cin>>n;
    int num[n];
    for(int i=0;i<n;i++)
    {
        cin>>num[i];
    }
    int i=0;
    while(i<n)
    {
        for(int j=n-1;j>i;j--)
        {
            if(num[j]<num[j-1])
            {
                swap(num[j],num[j-1]);
                result++;
            }
        }
        i++;
    }
    for(int i=0;i<n;i++)
    {
        if(i==n-1)cout<<num[i]<<endl;
        else cout<<num[i]<<' ';
    }
    cout<<result<<endl;
    return 0;
}



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

#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

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  string s;
  cin >> s;

  string ans = "";
  REP(i, s.size()) {
    switch(s[i]) {
      case '0':
        ans += "0";
        break;
      case '1':
        ans += "1";
        break;
      case 'B':
        if(ans.size()) {
          ans.pop_back();
        }
        break;
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
def main():
    N, X = (int(x) for x in input().split())
    L = [int(x) for x in input().split()]
    D = [0]

    for i in range(1, N+1):
        a = D[i - 1] + L[i - 1]
        if a <= X:
            D.append(a)
        else:
            break

    print(len(D))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll g1(ll n, ll p) {
  if (n == 0) return  0;
  return n/p + g1(n/p, p);
}

ll g2(ll n, ll p) {
  // 二重階乗
  if (n&1) return g1(n, p) - g2(n-1, p);
  ll res = g1(n/2, p);
  if (p == 2) res += n/2;
  return res;
}

int main() {
  // 二重階乗（Double Factorial）、二重階乗が2と5で何回割れるか
  ll N;
  cin >> N;
  ll ans = min(g2(N, 2), g2(N, 5));
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3544
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {
 
  public struct City{
    public long num;
    public long year;
    public int ID;
    public City(long n, long y, int i){
      num = n;
      year = y;
      ID = i;
    }

  }

  public static void Main (string[] args) {
    var S = Console.ReadLine();
    var ans = new List<int>();

    for(var i = 0; i < S.Length - 2; i++ ){
      var n = int.Parse(S.Substring(i,3));
      ans.Add(Math.Abs(753 - n));
    }

    Console.WriteLine(ans.Min());
  }
  
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

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

	ll ans = 0;
	for(int i=1; i<=N; i++){
		int ha = i;
		while(ha>=10) ha /= 10;
		int ta = i%10;
		if(ta == 0) continue;

		if(ha == ta) ans+=1;
		int ta1 = ta+1;
		ta *= 10;
		ta1 *= 10;
		for(int k=0; k<5; k++){
			int upper = ta1 + ha - 10;
			int lower = ta + ha;
			debug(lower, upper);
			if(lower > N) break;
			if(upper > N) {
				ans += (N - lower + 10) / 10;
				break;
			} else {
				ans += (upper - lower + 10) / 10;
				ta *= 10;
				ta1 *= 10;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


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

#define size_max 100+10

#define Y first
#define X second

int map[size_max][size_max];

int mx[4] = { 1,-1,0,0 };
int my[4] = { 0,0,1,-1 };

void paint(int c, int y, int x, int H, int W)
{
	int i, j;
	for (i = y; i < y + H; i++)
	{
		for (j = x; j < x + W; j++)
		{
			map[i][j] = c;
		}
	}
}

typedef pair<int, int> PR;

int main(void)
{
	PR now, tmp;
	queue< PR > QU;

	int w, h;
	int xs, ys, xg, yg, n;
	int c, d, set_x, set_y;

	int i, j;

	while ((cin >> w >> h), w != 0 && h != 0)
	{
		memset(map, 0, sizeof map);

		cin >> xs >> ys >> xg >> yg >> n;

		for (i = 0; i < n; i++)
		{
			cin >> c >> d >> set_x >> set_y;

			if (d == 0)
			{
				paint(c, set_y, set_x, 2, 4);
			}
			else
			{
				paint(c, set_y, set_x, 4, 2);
			}
		}

		if (map[ys][xs] == 0)
		{
			cout << "NG\n";
			continue;
		}

		int SC = map[ys][xs];

		QU.push(make_pair(ys, xs));

		bool goal = false;
		while (!QU.empty())
		{
			now = QU.front();
			QU.pop();

			if (map[now.Y][now.X] == SC)
			{
				map[now.Y][now.X] = -1;

				if (now.Y == yg && now.X == xg)
				{
					goal = true;

					while (!QU.empty())
					{
						QU.pop();
					}

					break;
				}

				for (i = 0; i < 4; i++)
				{
					if (map[now.Y + my[i]][now.X + mx[i]] == SC)
					{
						QU.push(make_pair(now.Y + my[i], now.X + mx[i]));
					}
				}
			}
		}
		if (goal)
		{
			cout << "OK\n";
		}
		else
		{
			cout << "NG\n";
		}

	}

	return 0;
}


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

int main(){
    ll n,k;
    cin>>n>>k;
    ll mi = (k+(k+2*n-1))*n;
    ll ma = (k+2*n+k+3*n-1)*n/2;
    if(mi>ma){
        cout<<-1<<endl;
        return 0;
    }
    vector<int> a(2*n),c(n);
    rep(i,2*n){
        if(i%2)a[i] = i/2+k;
        else a[i] = i/2+k+n;
    }
    if(n%2==0){
        rep(i,n){
            if(i%2==0)a[i]-=n;
            else a[i]+=n;
        }
    }
    rep(i,n)c[i]=k+2*n+i;
    rep(i,n){
        //assert(c[i]>=a[i]+a[i+n]);
        cout<<a[i]<<" "<<a[i+n]<<" "<<c[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    int n;
    vector<pair<int, int>> tasks;
    cin >> n;
    REP(i, n){
        int a, b;
        cin >> a >> b;
        tasks.emplace_back(b, a);
    }

    sort(tasks.begin(), tasks.end());
    int sum = 0;
    bool isyes = true;
    for(auto v : tasks){
        sum += v.second;
        if(sum > v.first){
            isyes = false;
            break;
        }
    }
    cout << (isyes ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;
using ll=long long;

#define PRI(n) cout << n <<endl;
#define PRI2(n, m) cout << n << " " << m << endl;
#define PRI3(n, m, o) cout << n << " " << m<< " " << o << endl;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REPInv(i, n)  for(int i = n-1; i >= 0; --i)

#define FOR(i, t, n)  for(int i = t; i <= (int)n; ++i)
#define FORInv(i, t, n)  for(int i = t; i >= (int)n; --i)

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;

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

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll nCr(int n, int r) {
    vector<ll> C(r + 1);
    C[0] = 1;
    FOR(i, 1, n) FORInv (j, min(i, r), 1)C[j] = (C[j] + C[j - 1]) % MOD;
    return C[r];
}

double N, M;
int A;
string S;

int main() {
    cin >> N >> M;
    double ans = 0;
    FOR(i, 1, N) {
        bool flag = true;
        double n = 0, c = i * 2;
        if (i < M) {
            while (flag) {
                if (c >= M) {
                    n++;
                    break;
                } else {
                    c = c * 2;
                    n++;
                }
            }
            ans += (1 / N) * pow(0.5, n);
        } else ans += (1 / N);
    }
    printf("%.10f", ans);
    return 0;
}

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

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647


int main() {
	string s;
	cin >> s;
	bool check = true;
	if (s.length() % 2 == 1)check = false;
	for (int i = 0; i < s.length() - 1; i+=2) {
		string hi = "";
		hi += s[i];
		hi += s[i + 1];
		if (hi != "hi") {
			check = false;
		}
	}

	if (check) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int N;
    int i, flag = 0;

    scanf("%d",&N);

    int A[N];

    for ( i = 0; i < N; i++)
    {
        scanf("%d",&A[i]);
    }
    
    for ( i = 0; i < N; i++)
    {
        if (A[i] % 2 == 0)
        {
            if (A[i] % 3 == 0 || A[i] % 5 == 0)
            {

            }else{
                flag = 1;
            }
        }
        
    }
    if (flag == 0)
    {
        printf("APPROVED\n");
    }else{
        printf("DENIED\n");
    }

    return 0;
}

Measured memory_bytes: 128
//  |. . . . . . . . . .|       NEXT  
//  |. . . . . . . . . .|      ______ 
//  |. . . . . . . . . .|     |      |
//  |. . . . . . . . . .|     |  OO  |
//  |. . . . . . . . . .|     |  OO  |
//  |. . . . . . . . . .|     |______|
//  |. . . . I . . . . .|             
//  |. . . . I . . . . .|             
//  |. . . . I . . . . .|     PLAYER  
//  |. . . . I . . . . .|    STYXCEL  
//  |. . . . . . . . . .|             
//  |I J J J . T T T S S|      LINES  
//  |I J O O . L T S S T|          0  
//  |I L O O . L Z Z T T|      SCORE  
//  |I L L L . L L Z Z T|      00021  

#include <bits/stdc++.h>

using namespace std;
//#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC target ("tune=native")

#define ll long long
#define ull unsigned long long
#define ld long double
#define vi vector<ll>
#define vii vector<vector<ll>>
#define fr() front()
#define bc() back()
#define pushb push_back
#define popb pop_back

#define pii pair<ll,ll>
#define piii pair<pair<ll,ll>,ll>
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define psplit(pp,a,b) (a=pp.fi,b=pp.se);
#define ppsplit(ppp,a,b,c) (a=ppp.fi.fi,b=ppp.fi.se,c=ppp.se);

#define endl ("\n")
const ll INF=1<<30;
const ll LINF=1LL<<62;
const double EPS=1e-9;
const ll MOD=1e9+7;

ll func(ll b, ll n){
    if(n==0)
        return n;
    return func(b,n/b) + n%b;
}

int main(){

    //freopen("inp.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    
    ll n=0,s=0;
    cin>>n>>s;

    ll x=n-s;
    ll m=LINF;
    for(ll i=1;i*i<=x;i++){
        if(x%i==0){
            if(func(i+1,n)==s){
                m=min(m,i+1);
            }
            else if(func(x/i+1,n)==s){
                m=min(m,x/i+1);
            }
        }
    }
    if(func(max(2LL,n),n)==s){
        m=min(m,max(2LL,n));
    }
    if(func(n+1,n)==s)
        m=min(m,n+1);
    if(m==LINF)
        m=-1;
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin>>s;
  for(int i=0;i<5;i++) cout<<s[i];
  cout<<" ";
  for(int i=6;i<13;i++) cout<<s[i];
  cout<<" ";
  for(int i=14;i<19;i++) cout<<s[i];
  cout<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int n,ans=0,ok=0;
	scanf("%d",&n);
	int h[n+1];
	h[0]=0;
	for(int i=1;i<=n;i++)scanf("%d",&h[i]);
	for(int i=1;i<=n;i++){
		ok=0;
		for(int j=0;j<i;j++){
			if(h[j]>h[i]){
				ok=0;
				break;
			}else{
				ok=1;
			}
		}
		if(ok)ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)

int main() {

	int n; cin >> n;

	set<string> sets;

	vector<string> words(n);

	for (int i = 0; i < n; i++) {
		cin >> words[i];
	}

	for (int i = 0; i < n; i++) {
		sets.insert(words[i]);
	}

	if (words.size() != sets.size()) {
		cout << "No" << endl;
		return 0;
	}

	

	for (int i = 0; i < n-1; i++) {
		if (words[i + 1][0] != words[i][words[i].size()-1]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str = sc.nextLine();
      
      for(int i = str.length() - 1; i >= 0; i --){
         System.out.print(str.charAt(i));
      }
      System.out.println();
   
   }//main
}//class

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M,C;
int B[1010];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>C;
	int ret=0;
	FOR(i,M) cin>>B[i];
	
	FOR(i,N) {
		int cur=C;
		FOR(j,M) {
			cin>>x;
			cur+=x*B[j];
		}
		if(cur>0) ret++;
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 
 
int main() {
  int A, B;
  cin >> A >> B;
  cout << (A + B) % 24 << endl;
  return 0;
}

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

int main()
{
  long long H, i;
  int W, j;
  char target[6]="snuke", ss[6];

  scanf("%lld%d", &H, &W);

  for(i=0; i<H; i++){
    for(j=0; j<W; j++){
      scanf("%s", ss);
      if(!strcmp(target, ss)){
        printf("%c%lld\n", 'A'+j, i+1);
        i=H;
        break;
      }
    }
  }
  return(0);
}

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

using namespace std;

signed main()
{
    cout << fixed << setprecision(10);

    while(true)
    {
        int a, b; char op; cin >> a >> op >> b;
        if(op == '+') cout << a + b << endl;
        else if(op == '-') cout << a - b << endl;
        else if(op == '*') cout << a * b << endl;
        else if(op == '/') cout << a / b << endl;
        else break;
    }
}


Measured memory_bytes: 3092
#include <stdio.h>

int main(){
  int i,j,a,flag=1,ch,N,cnt=0;

  scanf("%d",&N);

  int A[N];

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

  while(flag == 1){
    flag = 0;
    for(j=N-1;j>a;j--){
      if(A[j] < A[j-1]){
	ch = A[j];
	A[j] = A[j-1];
	A[j-1] = ch;

	cnt++;
	flag = 1;
      }
    }
  }

  for(i=0;i<N-1;i++) printf("%d ",A[i]);
  printf("%d",A[N-1]);
  printf("\n%d\n",cnt);
  return 0;
}
  
	



Measured memory_bytes: 2052
//File Name: E.cpp
  //Author: long
  //Mail: 736726758@qq.com
  //Created Time: 2016年10月26日 星期三 10时29分59秒
                                   
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <math.h>
#include <vector>
#define LL long long
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
const int MAXN  = 500000 + 5;
const int MOD = (int)1e9 + 7;
int p[MAXN],bit1[MAXN],bit2[MAXN],n;
bool use[MAXN];
LL jie[MAXN];
void update(int x,int add,int *bit){
	for(int i=x;i<=n;i+=i&-i)
		bit[i] += add;
}
int query(int x,int *bit){
	int res = 0;
	for(int i=x;i>0;i-=i&-i)
		res += bit[i];
	return res;
}
struct Seg{
	int n,ly;
	LL s;
}seg[MAXN << 2];
void pushup(int rt){
	seg[rt].s = seg[rt<<1].s + seg[rt<<1|1].s;
	seg[rt].n = seg[rt<<1].n + seg[rt<<1|1].n;
}
void pushdown(int rt){
	if(seg[rt].ly){
		int &ly = seg[rt].ly;
		int L = rt<<1,R = rt<<1|1;
		seg[L].ly += ly,seg[R].ly += ly;
		seg[L].s += (LL)seg[L].n * ly;
		seg[R].s += (LL)seg[R].n * ly;
		ly = 0;
	}
}
void build(int l,int r,int rt){
	seg[rt].s = seg[rt].ly = seg[rt].n = 0;
	if(l == r){
		if(!use[l]) seg[rt].n = 1;
		return ;
	}
	int m = l + r >> 1;
	build(lson);
	build(rson);
	pushup(rt);
}
void update(int L,int R,int add,int l,int r,int rt){
	if(L <= l && R >= r){
		seg[rt].ly += add;
		seg[rt].s += (LL)add * seg[rt].n;
		return ;
	}
	pushdown(rt);
	int m = l + r >> 1;
	if(L <= m) update(L,R,add,lson);
	if(R > m) update(L,R,add,rson);
	pushup(rt);
}
int init(){
	build(1,n,1);
	jie[0] = 1;
	for(int i=1;i<=n;i++)
		jie[i] = jie[i-1] * i % MOD;
	int sum = 0;
	for(int i=1;i<=n;i++){
		if(!use[i]){
			update(i,1,bit2);
			sum++;
		}
	}
	return sum;
}
LL solve(){
	int sum = init();
	LL ans = 0,tmp1,tmp2;
	int suf = 0;
	for(int i=n;i>0;i--){
		tmp1 = tmp2 = 0;
//		ans = 0;
		if(p[i]){
			int x = query(p[i] - 1,bit1);
			tmp1 = x * jie[sum] % MOD * jie[n - i] % MOD;
			int y = query(p[i],bit2);
			if(sum >= 1)
				tmp2 = (LL)y*suf % MOD * jie[sum-1] % MOD * jie[n-i] % MOD;
			ans = (ans + tmp1 + tmp2) % MOD;
			update(p[i],1,bit1);
			if(p[i] < n) update(p[i]+1,n,1,1,n,1);
		}
		else{
			if(sum >= 2)
				tmp1 = ((LL)sum * (sum - 1) / 2) % MOD * jie[sum-2] % MOD * suf % MOD * jie[n-i] % MOD;
			if(sum >= 1)
				tmp2 = seg[1].s % MOD * jie[sum-1] % MOD * jie[n-i] % MOD;
//			printf("tmp1 = %lld\ntmp2 = %lld\n",tmp1,tmp2);
			ans = (ans + tmp1 + tmp2) % MOD;
			suf++;
		}
//		printf("i = %d ans = %lld\n",i,ans);
	}
//	cout << jie[sum] << endl;
	ans = (ans + jie[sum]) % MOD;
	return ans;
}
int main(){
	scanf("%d",&n);
	memset(use,false,sizeof(use));
	for(int i=1;i<=n;i++){
		scanf("%d",p + i);
		use[p[i]] = true;
	}
	printf("%d\n",(int)solve());
	return 0;
}

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

using namespace std;

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

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

const ll mod = 998244353;

void solve() {
    int n, q;
    cin >> n >> q;
    map<int, int> m;
    m[0] = 1, m[n] = 0;

    vt<ll> m10(n);
    m10[0] = 1;
    for (int i = 1; i < n; i++) m10[i] = m10[i - 1] * 10 % mod;

    vt<ll> len(n + 1);
    len[0] = 0;
    for (int i = 1; i <= n; i++) len[i] = (len[i - 1] * 10 + 1) % mod;

    ll ans = len.back();
    while (q--) {
        int l, r, d;
        cin >> l >> r >> d;
        tie(l, r) = make_pair(n - r, n - l);

        auto it_next = m.upper_bound(l);
        auto it_cur = it_next;
        it_cur--;

        while (it_cur->fi <= r) {
            int st = max(l, it_cur->fi),
                en = min(r, it_next->fi - 1);
            ans = (ans +
                m10[st] * len[en - st + 1] % mod *
                (d - it_cur->se + mod)
            ) % mod;

            if (r + 1 < it_next->fi) m[r + 1] = it_cur->se;
            if (l <= it_cur->fi) m.erase(it_cur);
            it_cur = it_next;
            it_next++;
        }
        m[l] = d;

        cout << ans << '\n';
    }
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}



Measured memory_bytes: 15628
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <sstream>


using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int h, w;
	while (1)
	{
		cin >> w >> h;
		if (h == 0 && w == 0) break;
		for (int i = 0; i < w; i++)
		{
			for (int j = 0; j < h; j++)
			{
				if (j == h - 1) cout << '#' << endl;
				else cout << '#';
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3108
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, ans = 0;
    cin >> n;
    vector<pair<ll, ll>> w(n);
    for(int i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        w[i] = make_pair(b, a);
    }
    sort(begin(w), end(w));
    ll sum = 0;
    bool f = true;
    for(int i = 0; i < n; i++){
        sum += w[i].second;
        if(w[i].first < sum){
            f = false;
            break;
        }
    }
    cout << (f? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 3328
N, K = map(int, input().split())

a_list = [int(a) for a in input().split()]

result_list = [[0,0] for _ in range(N)]
for i in range(N):
    aa = a_list[i]

    f = 0
    for j in range(N):
        an = a_list[j]
        if i == j:
            f = 1
            continue

        if aa > an:
            result_list[i][f] += 1

c = 0
for i, j in result_list:
    kk = i+j
    c += (kk*K*(K+1)//2 - i*K)

n = 1000000000+7

print(c%n)

Measured memory_bytes: 3308
n = gets.to_i
s = []
n.times do
  s.push(gets.chomp!)
end

s = s.sort.chunk(&:itself)
c = 0
l = []
for k, v in s
 if c < v.count
   c = v.count
   l = [k]
 elsif c == v.count
   l.push(k)
 end
end

puts l.sort

Measured memory_bytes: 26588
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
// #include <bits/stdc++.h> all

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int a,b;
  cin >> a >> b;
  
  if(a < 10 && b < 10){
   cout << a*b << endl; 
  } else {
    cout << -1 << endl;
  }

  return 0;
}

Measured memory_bytes: 764
s = input()
t = input()
cnt = 0
min = 0
for i in range(len(s)-len(t)+1):
    cnt = 0
    for j in range(len(t)):
            if s[i+j] == t[j]:
                cnt += 1
    if min < cnt:
        min = cnt
ans = len(t)-min

s = s[::-1]
t = t[::-1]
cnt=0
min=0
for i in range(len(s)-len(t)+1):
    cnt = 0
    for j in range(len(t)):
            if s[i+j] == t[j]:
                cnt += 1
    if min < cnt:
        min = cnt
if ans > len(t)-min:
    ans = len(t)-min
f = s.find(t)
if f < ans and f != -1:
    ans = f
print(ans)

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main()
{
    //ifstream cin("input.in");
   // ofstream cout("output.out");
    char A,B;
    cin>>A>>B;
    if(A=='H')
    	cout<<B;
    else{
    	if(B=='D')
    		cout<<'H';
    	else
    		cout<<'D';}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define input() for(int i=0;i<n;i++)cin>>a[i];
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int h, w, ans;
char c[405][405];
bool visit[405][405];
int dx[5] = { 1,0,-1,0 }, dy[5] = { 0,1,0,-1 };
int white, black;
void dfs(int a, int b, int x, int y) {
	visit[x][y] = true;
	if (c[x][y] == '.')white++;
	else black++;
	rep(i, 4) {
		int nx = x + dx[i], ny = y + dy[i];
		char d;
		if (b == 0 && a % 2 == 0)d = '#';
		else if (b == 0)d = '.';
		else if (a % 2 == 0)d = '.';
		else d = '#';
		if (nx >= 0 && nx < h&&ny >= 0 && ny < w && !visit[nx][ny] && c[nx][ny] == d) {
			dfs(a + 1, b, nx, ny);
		}
	}
}
signed main() {
	cin >> h >> w;
	rep(i, h)rep(j, w)cin >> c[i][j];
	rep(i, h) {
		rep(j, w) {
			if (visit[i][j])continue;
			if (c[i][j] == '#') {
				dfs(0, 1, i, j);
				ans += white * black;
				white = 0;
				black = 0;
			}
		}
	}
	cout << ans << endl;
	endre;
}


Measured memory_bytes: 10624
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,q;
int dp[502][502];
int main() {
    int a,b;
    scanf("%d%d%d",&n,&m,&q);
    for(int i = 0;i < m;i ++) {
        scanf("%d%d",&a,&b);
        dp[a][b] ++;
    }
    for(int j = 1;j < n;j ++) {
        for(int i = 1;i + j <= n;i ++) {
            int k = i + j;
            dp[i][k] += dp[i + 1][k] + dp[i][k - 1];
            if(j > 1)dp[i][k] -= dp[i + 1][k - 1];
        }
    }
    for(int i = 0;i < q;i ++) {
        scanf("%d%d",&a,&b);
        printf("%d\n",dp[a][b]);
    }
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define ip pair<int,int>
#define MAX 3005
// const ll INF = 1000000000000000000;
const ll MOD = 1000000007;

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

	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll dp[n+1][n+1];
	memset(dp,0,sizeof(dp));
	dp[1][1] = 1;
	for(int i=2;i<=n;i++){
		if(s[i-2] == '<'){
			ll cur = 0;
			for(int j=2;j<=i;j++){
				cur += dp[i-1][j-1];
				if(cur >= MOD)
					cur -= MOD;
				dp[i][j] = cur;
			}
		}
		else{
			ll cur = 0;
			for(int j=i-1;j>=1;j--){
				cur += dp[i-1][j];
				if(cur >= MOD)
					cur -= MOD;
				dp[i][j] = cur;
			}
		}
	}

	ll ans = 0;
	for(int i=1;i<=n;i++){
		ans += dp[n][i];
		if(ans >= MOD)
			ans -= MOD;
	}

	cout<<ans<<endl;
}


Measured memory_bytes: 70656
#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(void)
{
  string s;
  cin >> s;
  string ans;
  if (s == "ABC") {
    ans = "ARC";
  } else {
    ans = "ABC";
  }
  cout << ans << endl;
  return 0;
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<int> a(n);
	for (int i=0; i<n; i++)
		cin>>a[i];
	sort(a.begin(),a.end());
	cout<<a[n/2]-a[n/2-1]<<"\n";
	return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int N, M; cin >> N >> M;
    VI num(N, 1); VB red(N, false);
    red[0] = true;
    REP(i, M){
        int x, y; cin >> x >> y;
        --x; --y;
        --num[x]; ++num[y];
        if(red[x]) red[y] = true;
        if(!num[x]) red[x] = false;
    }
    int cnt(0);
    REP(i, N) if(red[i]) ++cnt;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 640
package main

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

const (
	maxN = 200005
	mod  = 1000000007
)

func main() {
	n := nextInt()
	as := make([]int, n+2)
	var maxNum, s, pre, nex int
	for i := 1; i <= n+1; i++ {
		as[i] = nextInt()
		maxNum = max(maxNum, as[i])
	}
	vis := make([]bool, maxNum+1)
	inv := make([]int, maxN)
	f := make([]int, maxN)
	invf := make([]int, maxN)
	for i := 1; i <= n+1; i++ {
		if vis[as[i]] {
			s = as[i]
		}
		vis[as[i]] = true
	}
	for i := 1; i <= n+1 && as[i] != s; i++ {
		pre++
	}
	for i := n + 1; i >= 0 && as[i] != s; i-- {
		nex++
	}
	f[0], invf[0] = 1, 1
	inv[1], f[1], invf[1] = 1, 1, 1
	for i := 2; i <= nex+pre || i <= n+1; i++ {
		inv[i] = mod - (mod/i)*inv[mod%i]%mod
		f[i] = f[i-1] * i % mod
		invf[i] = invf[i-1] * inv[i] % mod
	}
	for i := 1; i <= n+1; i++ {
		ans := (c(n+1, i, f, invf) - c(pre+nex, i-1, f, invf) + mod) % mod
		fmt.Println(ans)
	}
}

func c(n, m int, f, invf []int) int {
	if n < m {
		return 0
	}
	return f[n] * invf[m] % mod * invf[n-m] % mod
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

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

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 6656
#include<stdio.h>
int main()
{
	int i,a,b,n,s,f;
	scanf("%d%d",&a,&b);
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&s,&f);
		if(a<f&&b>s){
			printf("1\n");
			return 0;
		}
	}
	printf("0\n");
    return 0;
}

Measured memory_bytes: 2596
#include <iostream>
typedef long long LL;
using namespace std;
int main(int argc, char* argv[])
{
	LL K,A,B;
	cin>>K>>A>>B;
	if (K<=A){
		cout<<1<<endl;
		return 0;
	}
	if (A<=B){
		cout<<-1<<endl;
		return 0;
	}
	LL AB=A-B;
	LL x=(K-A)/AB;
	LL y=K%AB;
	LL z=x*AB;
	LL aw=2*x;
	while (z<K){
		aw++;
		z+=A;
		if (z>=K){
			break;
		}
		z-=B;
		aw++;
	}
	cout<<aw<<endl;
	return 0;
}

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

dic = []
for i in range(N):
    S, P = input().split()
    P = int(P)
    dic.append([S, P, i+1])

dic = sorted(dic, key=lambda x:x[1], reverse=True)
dic = sorted(dic, key=lambda x:x[0])


for i in range(N):
    print(dic[i][2])


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N;
    ll a, b;
    vector<ll> D;
    cin >> N;
    D.resize(N);
    for(ll i = 0;i < N;i++) cin >> D[i];
    sort(D.begin(), D.end());
    a = D.size() / 2 - 1;
    b = a + 1;
    if(D[a] == D[b]) {
        cout << 0 << endl;
    } else {
        cout << D[b] - D[a] << endl;
    }
    return 0;
}


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

using namespace std;

int main(){
    int n;
    string s1,s2;
    cin>>n>>s1>>s2;
    for(int i=n;i>=0;i--) if (s1.substr(n-i,i)==s2.substr(0,i)){
        printf("%d",2*n-i);
        break;
    }
}


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

int n,m,s,arr[1000001];

int f(int n){
	if(n % 2 == 0){
		return n / 2;
	}
	return 3 * n + 1;
}

int main(){
	cin>>s;
	arr[s]++;
	for(int i = 2;i <= 1000000;i++){
		s = f(s);
		if(arr[s] > 0){
			cout<<i<<endl;
			break;
		}else{
			arr[s]++;
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int main()
{
    int X, Y;
    cin >> X >> Y;
    cout << X + Y / 2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define repf(i,n) for(int i=0;i<=n;i++)
const ll INF=1e9;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge> >;

Graph G;
vector<ll> res;

//  pvはvの親。vをcに塗る。
void dfs(ll v, ll pv, ll c){
    res[v]=c;
    for(auto itr: G[v]){
        if(itr.first == pv)continue;    //逆流しているのでコンティニュー
        if(1 & itr.second)dfs(itr.first, v, 1-c);  //距離の偶奇判定
        else dfs(itr.first, v, c);
    }
}

int main(){
    ll N;cin >> N;
    G.assign(N,vector<Edge>());
    rep(i,N-1){
        ll v1, v2, w; cin >> v1 >> v2 >> w;
        v1--;v2--;
        G[v1].push_back(make_pair(v2,w));
        G[v2].push_back(make_pair(v1,w));
    }
    res.assign(N,0);
    dfs(0,-1,0);

    rep(i,N)cout << res[i] << endl;
}

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

int main(){
  int V=10,t,d[10][10],h,w,ans=0;cin>>h>>w;
  REP(i,V) REP(j,V) cin>>d[i][j];
  REP(k,V) REP(i,V) REP(j,V) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
  REP(i,h*w){
    cin>>t;
    if(t>-1) ans+=d[t][1];
  }
  cout<<ans;
}



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

//counterの値を親から子に伝搬させる
void dfs(int vertex, int parent, 
    vector<vector<int> >& Tree, vector<int>& counter){

  //親のカウンターの値を足し合わせる
  counter[vertex] += counter[parent];

  //子に伝播させる
  for(const int &nxtv : Tree[vertex]){
    if(nxtv == parent)continue;
    dfs(nxtv, vertex, Tree, counter);
  }
}

//方針：親から子にカウンターの値を伝播させていくことで実現
int main(void){
  //入力
  int N,Q;
  cin >> N >> Q;
  //木
  vector<vector<int> > Tree(N+1);
  //頂点のカウンター
  vector<int> counter(N+1,0);
  //木の構築
  for(int i = 0; i < N-1; ++i){
    int a,b;
    cin >> a >> b;
    Tree[a].push_back(b);
    Tree[b].push_back(a);
  }

  //カウンターの加算
  for(int j = 0; j < Q; ++j){
    int p,x;
    cin >> p >> x;
    counter[p] += x;
  }

  //カウンターの伝搬
  dfs(1,0,Tree,counter);

  //出力
  for(int i = 1; i <= N; ++i){
    cout << counter[i] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 26624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#ifndef LOCAL
struct ostdmy{template<class T>ostdmy&operator<<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(const T&i:v)o<<i<<' ';return o;}
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n;
    cin>>n;
    cout<<n*800-(n/15)*200<<endl;
    return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
x=[0 for i in range(N)]
y=[0 for i in range(N)]
for i in range(N):
    a,b,c=map(str,input().split())
    a=int(a)
    b=int(b)
    if c=="W":
        b+=K
    x[i]=a%(2*K)
    y[i]=b%(2*K)
board=[[0 for i in range(2*K+1)] for i in range(2*K+1)]
for i in range(N):
    if x[i]>=K and y[i]>=K:
        x[i]-=K
        y[i]-=K
    if x[i]<K and y[i]>=K:
        x[i]+=K
        y[i]-=K
    if x[i]>=K and y[i]<K:
        board[0][y[i]+1]+=1
        board[0][y[i]+K+1]-=1
        board[x[i]-K+1][y[i]+1]-=2
        board[x[i]-K+1][y[i]+K+1]+=2
        board[x[i]-K+1][0]+=1
        board[x[i]+1][0]-=1
        board[x[i]+1][y[i]+1]+=2
        board[x[i]+1][y[i]+K+1]-=2
    if x[i]<K and y[i]<K:
        board[x[i]+1][y[i]+1]+=2
        board[x[i]+K+1][y[i]+K+1]+=2
        board[x[i]+1][y[i]+K+1]-=2
        board[x[i]+K+1][y[i]+1]-=2
        board[0][0]+=1
        board[x[i]+1][0]-=1
        board[0][y[i]+1]-=1
        board[x[i]+K+1][0]+=1
        board[0][y[i]+K+1]+=1
tmp=[[0 for i in range(2*K)] for i in range(2*K)]
bs=[[0 for i in range(2*K)] for i in range(2*K)]
for i in range(2*K):
    for j in range(2*K):
        if i==0:
            tmp[i][j]=board[i][j]
        else:
            tmp[i][j]=board[i][j]+tmp[i-1][j]
for i in range(2*K):
    for j in range(2*K):
        if j==0:
            bs[i][j]=tmp[i][j]
        else:
            bs[i][j]=tmp[i][j]+bs[i][j-1]
ans=bs[0][0]
for i in range(2*K):
    for j in range(2*K):
        if bs[i][j]>ans:
            ans=bs[i][j]
print(ans)


Measured memory_bytes: 141388