akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

int n,s[1001],p[1001],q[1001],r[1001],c[1001];

int main(){
	while(scanf("%d",&n),n != 0){
		for(int i = 0; i < n; i++){
			scanf("%d%d%d%d",&s[i],&p[i],&q[i],&r[i]);
			c[i] = (p[i] + r[i]) * 4 + q[i] * 9;
		}
		scanf("%d%d%d%d",&p[n],&q[n],&r[n],&c[n]);
		bool t = false;
		for(int i = 0; i < n; i++){
			if(p[i] <= p[n] && q[i] <= q[n] && r[i] <= r[n] && c[i] <= c[n]){
				printf("%d\n",s[i]);
				t = true;
			}
		}
		if(!t) printf("NA\n");
	}

	return 0;
}

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

void update(int m[][50], int i, int j, int H, int W){
  for(int p=-1; p<2; p++){
    for(int q=-1; q<2; q++){
      if(p==0 && q==0) continue;
      int x = i+p, y = j+q;
      if(x > -1 && y > -1 && x < H && y < W){
        m[x][y] += 1;
      }
    }
  }
}

int main() {
  int H, W;
  int m[50][50];
  cin >> H >> W;
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      m[i][j] = 0;
    }
  }

  for(int i=0;i<H;i++){
    string x;
    cin >> x;
    for(int j=0;j<W;j++){
      if(x[j] == '#'){
        update(m, i, j, H, W);
        m[i][j] = -100; // bomb, negative
      }
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(m[i][j] >= 0){
        cout << m[i][j];
      }else{
        cout << "#";
      }
    }
    cout << endl;
  }
}


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

int main(){
    string s,t;
    cin>>s>>t;
    int sabs=s.size();
    s+=s;
    bool ok=false;
    rep(i,sabs){
        if(s.substr(i,sabs)==t){
            ok=true;
            break;
        }
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))
A = []
for i in range(n):
    for j in range(a[i]):
        A.append(i+1)
# C = [[0]*w]*h
C = [[0 for j in range(w)] for i in range(h)]
for i in range(h):
    for j in range(w):
        if i%2 == 0:
            C[i][j] = A[i*w+j]
        else:
            C[i][-j-1] = A[i*w+j]
for i in range(h):
    for j in range(w):
        print(C[i][j],end="")
        print(" ",end="")
    print("")

Measured memory_bytes: 4596
def solve(A, B, C):
  ans = []

  if A + B < C:
    ans.append(str(A + 2 * B + 1))
  else:
    ans.append(str(B + C))
  # Output according to format
  ans = '\n'.join(ans)
  return ans

# receive inputs
A, B, C = map(int, input().split())

# print outputs
print(solve(A, B, C))

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin >>a>>b>>c;
    int k;
    cin >>k;
    if(a>=b && a>=c){
        for(int i=0;i<k;i++){
            a*=2;
        }
        cout <<a+b+c;
    }else if(b>=a && b>=c){
        for(int i=0;i<k;i++){
            b*=2;
        }
        cout <<a+b+c;
    }else{
        for(int i=0;i<k;i++){
            c*=2;
        }
        cout <<a+b+c;
    }
    return 0;
}


Measured memory_bytes: 256
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>

using Input = std::vector<std::string>;
using Num = std::vector<int>;

Input input(void) {
	Input result;
	{
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				result.push_back(row);
				row = "";
			} else {
				row += buf[i];
			}
		}
		result.push_back(row);
	}
	return result;
}

Num replaceToInteger(Input original = {""}) {
	Num result;
	for (unsigned int i = 0; i < original.size(); i++) {
		result.push_back(atoi(original[i].c_str()));
	}
	return result;
}

int main(void) {

	Num s = replaceToInteger(input());

	int n = 0;
	n = s[0];

	Num mid, buf;
	mid = replaceToInteger(input());

	{
		int ans = 0;
      	bool b = true;
		while (b) {
			buf.clear();
			for (int num : mid) {
				if (0 == num % 2) {
					buf.push_back(num / 2);
				} else {
                  	b = false;
					break;
				}
			}
          	if (b) ans++;
			mid.clear();
			mid = buf;
		}
		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


// import here

int main(){
    LL n;
    cin >> n;
    string s;
    cin >> s;
    for(LL i = 0; i < s.size(); ++i){
        s[i] = (s[i] + n - 'A') % 26 + 'A';
    }
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
int number;
  scanf("%d",&number);
  if(number%10==2||number%10==4||number%10==5||number%10==7||number%10==9)
    printf("hon");
  else if(number%10==0||number%10==1||number%10==6||number%10==8)
    printf("pon");
  else if (number%10==3)
    printf("bon");
  return 0;
}

Measured memory_bytes: 2152
#include<stdio.h>
#include<string.h>
#define rep(i,n) for(int i=0;i<n;i++)
struct ongaku{
    char s[101];
    int t;
};
int music(char s[],char t[]){
    int p,q,count=0,i;
    p=strlen(s);
    q=strlen(t);
    if(p==q){
        rep(i,p){
            if(s[i]==t[i])
                count++;
        }
    }
    if(count==p)
        return 1;
    return 0;
}
int main(){
    int n,i,p;
    scanf("%d",&n);
    struct ongaku a[n];
    char x[101];
    rep(i,n){
        scanf("%s%d",a[i].s,&a[i].t);
    }
    scanf("%s",x);
    int second=0;
    rep(i,n){
        p=music(a[i].s,x);
        if(p==1){
            p=i;
            break;
        }
    }
    for(i=p+1;i<n;i++)
        second+=a[i].t;
    printf("%d\n",second);
    return 0;
}

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

int main() {
	int N,D;
	cin >> N >>D; 
	vector<vector<int>> X(N, vector<int>(D));
	for (int n = 0;n<N;++n) {
		for (int d = 0;d<D;++d) {
			cin >> X[n][d];
		}
	}
	int ans = 0;
	for (int i = 0;i<N;++i) {
		for (int j = i + 1;j<N;++j) {
			int d = 0;
			for (int k = 0;k<D;++k) {
				d += (X[i][k]-X[j][k])*(X[i][k] - X[j][k]);
			}
			int dsub = (int)sqrt(d);
			dsub *= dsub;
			if (d == dsub) {
				++ans;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

const int MOD = 1000000007;

typedef vector<vector<ll>> mat;
mat mat_mul(mat &A, mat &B) {
	mat C(A.size(), vector<ll>(B[0].size()));
	REP(i, (int)A.size()) {
		REP(k, (int)B.size()) {
			REP(j, (int)B[0].size()) {
				C[i][j] = (C[i][j] + (A[i][k] * B[k][j]) % MOD) % MOD;
			}
		}
	}
	return C;
}
mat mtpow(mat A, ll n) {
	mat B(A.size(), vector<ll>(A.size()));
	REP(i, (int)A.size()) {
		B[i][i] = 1;
	}
	while (n > 0) {
		if (n & (ll)1) B = mat_mul(B, A);
		A = mat_mul(A, A);
		n >>= 1;
	}
	return B;
}

int main() {
	int n; ll k;
    cin >> n >> k;

	mat A;
	REP(i, n) {
		vector<ll> v(n);
		REP(j, n) cin >> v[j];
		A.push_back(v);
	}

	A = mtpow(A, k);
    
	ll ans = 0;
	REP(i, n) REP(j, n) (ans += A[i][j]) %= MOD;
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
N = int(input())
count = 0
L = list(map(int, input().split()))
for i,li in enumerate(L[:-2]):
  for j,lj in enumerate(L[i+1:-1]):
    for k,lk in enumerate(L[i+j+1:]):
      if (li != lj) and (lj != lk) and (li != lk):
#        la,lb,lc = sorted([li,lj,lk])
        if li + lj > lk and lj + lk > li and lk + li > lj:
#          print(i+1,i+j+1,i+j+k+1,li,lj,lk)
          count += 1
print(count)

Measured memory_bytes: 73828
#include<stdio.h>
int main(void){
	int x, y, a, b;
	scanf("%d %d", &x, &y);
	if(x<y){
		b=x;
		x=y;
		y=b;}
	while(y>0){
		a=x%y;
		x=y;
		y=a;
	}
	printf("%d\n", x);
	return 0;
}


Measured memory_bytes: 2092
import bisect

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    
    if sum(A) < sum(B):
        return -1
    
    C = [a - b for a, b in zip(A, B)]
    C.sort()
    
    mid = bisect.bisect_left(C, 0)
    minus = sum(C[:mid])
    if minus >= 0:
        return 0
    cnt = mid
    for i in reversed(range(N)):
        minus += C[i]
        cnt += 1
        if minus >= 0:
            return cnt
        
    return -1

print(solve())

Measured memory_bytes: 18356
#include <iostream>                                                             
using namespace std;                                                            
                                                                                
int main (void) {                                                               
  int a,b;                                                                      
  cin >> a >> b;                                                                
  cout << a/b << " " << a%b << " ";                                             
  cout << fixed;                                                                
  cout.precision(5);                                                            
  cout << (double)a/(double)b << endl;                                          
}                                                                               
                                  

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

struct card{char q; int value;};

void bubbleSort(struct card A[], int N){
    bool frag = 1;
    for(int i = 0;frag; i++){
        frag = 0;
        for (int j = N-1; j > 0; j--){
            if (A[j].value < A[j-1].value){
                swap(A[j-1],A[j]);
                frag = 1;
               
            }
        }
    }
}
void selectionSort(struct card A[], int N){
    int minj;
    for(int i = 0; i < N-1; i++){
        minj = i;
        for(int j = i; j<N; j++){
            if (A[j].value < A[minj].value) minj = j;
        }
        swap(A[i],A[minj]);
    }
}
void print(struct card A[], int N){
    for(int i = 0; i < N; i++){
        if (i > 0) cout << " ";
        cout <<A[i].q <<A[i].value;
    }
    cout <<endl;
}
bool isStable(struct card t1[], struct card t2[], int N){
    for(int i = 0; i < N-1; i++){
        if(t1[i].q != t2[i].q) return false;
        
    }return true;
}
int main(){
    int N;
    cin >>N;
    card t1[40], t2[40];
    
    for(int i = 0; i < N; i++){
        cin >>t1[i].q >>t1[i].value;
        t2[i] = t1[i];
    }
    
    bubbleSort(t1, N);
    selectionSort(t2, N);
    
    print(t1, N);
    cout<<"Stable"<<endl;
    
    print(t2, N);
    if(isStable(t1,t2,N)) cout<<"Stable"<<endl;
    else cout<<"Not stable"<<endl;
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	int ans=0;
	cin>>a;
    if(a[0] != 'C') ans++;
    if(a[1] != 'O') ans++;
    if(a[2] != 'D') ans++;
    if(a[3] != 'E') ans++;
    if(a[4] != 'F') ans++;
    if(a[5] != 'E') ans++;
    if(a[6] != 'S') ans++;
    if(a[7] != 'T') ans++;
    if(a[8] != 'I') ans++;
    if(a[9] != 'V') ans++;
    if(a[10] != 'A') ans++;
    if(a[11] != 'L') ans++;
    if(a[12] != '2') ans++;
    if(a[13] != '0') ans++;
    if(a[14] != '1') ans++;
    if(a[15] != '6') ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const ll INF = 1e18 + 10;

const int mod = 1000000007;
struct mint {
    ll x;
    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 { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

string L;
mint dp[100005][2];

int main() {
    cin >> L;
    dp[0][0] = 1;
    int n = L.size();
    rep(i,n) {
        if (L[i] == '0') {
            dp[i+1][0] = dp[i][0];
            dp[i+1][1] = mint(3) * dp[i][1];
        } else {
            dp[i+1][0] = mint(2) * dp[i][0];
            dp[i+1][1] = dp[i][0] + mint(3) * dp[i][1];
        }
    }
    cout << dp[n][0] + dp[n][1] << endl;
}

Measured memory_bytes: 5316
import queue

n,m = map(int, input().split())
a = [[] for i in range(n)]

for i in range(m):
    u,v = map(int, input().split())
    u-=1
    v-=1
    a[u].append(v)

s,t = map(int, input().split())
s-=1
t-=1

inf = float('inf')
d = [[inf, inf, inf] for i in range(n)]
d[s][0]=0

q = queue.Queue()
for i in range(len(a[s])):
    q.put(a[s][i])
    d[a[s][i]][1]=1


while not q.empty():
    p = q.get()
    for i in range(len(a[p])):
        r = a[p][i]
        c = []
        if d[r][0]==inf:
            c.append(0)
        if d[r][1]==inf:
            c.append(1)
        if d[r][2]==inf:
            c.append(2)
        if not c:
            continue

        flag = False
        for j in range(len(c)):
            if c[j]==0:
                if d[p][2]!=inf:
                    break
            elif c[j]==1:
                if d[p][0]!=inf:
                    break
            elif c[j]==2:
                if d[p][1]!=inf:
                    break
            if j==len(c)-1:
                flag=True
        if flag:
            continue

        q.put(r)
        for j in range(len(c)):
            if c[j]==0:
                d[r][0] = d[p][2] + 1
            elif c[j]==1:
                d[r][1] = d[p][0] + 1
            elif c[j]==2:
                d[r][2] = d[p][1] + 1

        if r==t and d[r][0]!=inf:
            print(d[r][0]//3)
            exit()
print(-1)






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

/*
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#include <set>
*/

using namespace std;

typedef long long LL;
typedef double DB;
typedef unsigned int UI;
typedef pair<int, int> PII;

const int inf = 0x7f7f7f7f;

#define rdi() read<int>()
#define rdl() read<LL>()
#define rds(a) scanf("%s", a)
#define mk(i, j) make_pair(i, j)
#define pb push_back
#define fi first
#define se second
#define For(i, j, k) for (int i = j; i <= k; i ++)
#define Rep(i, j, k) for (int i = j; i >= k; i --)
#define Edge(i, u) for (int i = head[u]; i; i = e[i].nxt)

template<typename t> t read() {
	t x = 0; int f = 1; char c = getchar();
	while (c > '9' || c < '0') f = c == '-' ? -1 : 1 , c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - 48 , c = getchar();
	return x * f;
}

template<typename t> void write(t x) {
	if (x < 0){
		putchar('-'), write(-x);
		return;
	}
	if (x >= 10) write(x / 10);
	putchar(x % 10 + 48);
}

const int P = 1e9 + 7;
int n, m, ans;

int main() {
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = rdi(), m = rdi();
	if (n < m) swap(n, m);
	if (n - m > 1) return puts("0"), 0;
	ans = 1;
	for (int i = 1; i <= n; i ++) ans = (1ll * ans * i) % P;
	for (int i = 1; i <= m; i ++) ans = (1ll * ans * i) % P;
	if (n == m) ans = (2ll * ans) % P;
	printf("%d\n", ans);
	return 0;
}


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

typedef pair<int,int> P;

int main(){
  int i,j;
  int h,w;
  int lr[100][100],ud[100][100];
  int grid[100][100];  

  while(scanf("%d %d",&w,&h) && (w||h)){
    for(i=0;i<h-1;i++){
      for(j=0;j<w-1;j++)scanf("%d",&lr[i][j]);
      for(j=0;j<w;j++)scanf("%d",&ud[i][j]);
    }
    for(j=0;j<w-1;j++)scanf("%d",&lr[h-1][j]);

    for(i=0;i<h;i++)for(j=0;j<w;j++)grid[i][j] = 0;
    grid[0][0] = 1;

    queue<P> q;
    q.push(P(0,0));

    while(q.size()){
      P p = q.front();q.pop();
      int y = p.first,x = p.second;

      if(y==h-1 && x==w-1)break;
      
      int dy[] = {1,0,-1,0},dx[] = {0,1,0,-1};
      for(int k=0;k<4;k++){
	int sy = y+dy[k], sx = x+dx[k];
	if(sy < 0 || sx < 0 || h-1 < sy || w-1 < sx)continue;
	if(k==0 && ud[y][x])continue;
	if(k==1 && lr[y][x])continue;
	if(k==2 && ud[sy][sx])continue;
	if(k==3 && lr[sy][sx])continue;
	if(grid[sy][sx] > 0)continue;
	grid[sy][sx] = grid[y][x] + 1;
	q.push(P(sy,sx));
      }
    }

    printf("%d\n",grid[h-1][w-1]);
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;

int main()	
{
	#ifdef SANS
		freopen("C:\\Users\\ASUS\\Documents\\Sublime\\input_output\\inputf.txt","r",stdin);
		freopen("C:\\Users\\ASUS\\Documents\\Sublime\\input_output\\outputf.txt","w",stdout);
	#endif
	fast
	int t;
	cin>>t;
	set<string> s;
	while(t--)
	{
		string str;
		cin>>str;
		// cout<<str<<endl;
		s.insert(str);
	}
	cout<<s.size();
	#ifdef SANS
		cout<<"\nTime Elapsed:"<<1.0*clock()/CLOCKS_PER_SEC <<"sec\n";
	#endif
}

Measured memory_bytes: 19288
#include<bits/stdc++.h>
using namespace std;
const int N=705;
int n,m;
int vis[N],cnt[2],col[N],a[N][N],x[N],y[N],tot,dp[N][N];
void dfs(int u)
{
	vis[u]=1;
	cnt[col[u]]++;
	for(int i=1;i<=n;i++) 
	{
		if(a[u][i]==0) 
		{
			if(!vis[i]) 
			{
				col[i]=col[u]^1;
				dfs(i);
			}
			else if(col[i]==col[u]&&i!=u)
			{
				printf("-1\n");
				exit(0);
			}
		}
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) 
	{
		int x,y;
		scanf("%d%d",&x,&y);
		a[x][y]=a[y][x]=1;
	}
	for(int i=1;i<=n;i++)
	{
		if(vis[i]) continue;
		cnt[0]=cnt[1]=0;
		dfs(i);
		x[++tot]=cnt[0];y[tot]=cnt[1];
	}
 	dp[0][0]=1;
 	for(int i=1;i<=tot;i++) 
		for(int j=0;j<=n;j++) 
		if(dp[i-1][j]) 
		{
			dp[i][j+x[i]]=1;
			dp[i][j+y[i]]=1;
		}
 	int ans=n*n;
 	for(int i=0;i<=n;i++) 
 	{
 		if(dp[tot][i]) ans=min(ans,i*(i-1)/2+(n-i)*(n-i-1)/2);
 	}
 	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4096
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = int.Parse(Console.ReadLine());
            int ret = 0;
            if (r >= 500)
            {
                ret += r / 500 * 1000;
            }

            var remain = r % 500;
            ret += remain / 5 * 5;
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))

class comb{
	vector<ll> f,fr;
	ll MOD;
	public:
	//a^(p-1) = 1 (mod p)(p->Prime numbers)
	//a^(p-2) = a^(-1)
	ll calc(ll a,ll b,ll p){//a^(b) mod p   
		if(b==0)return 1;
		ll y = calc(a,b/2,p);y=(y*y)%p;
		if(b & 1) y = (y * a) % p;
		return y;
	}
	void init(ll n,ll mod){//input max_n
		MOD = mod;
		f.resize(n+1);
		fr.resize(n+1);
		f[0]=fr[0]=1;
		for(ll i=1;i<n+1;i++){
			f[i] = (f[i-1] * i) % mod;
			fr[i] = calc(f[i],mod-2,mod);
		}
	}
	ll nCr(ll n,ll r){
		return f[n] * fr[r] % MOD * fr[n-r] % MOD;
	}
};


int main(){
	ll N,K;
	cin >> N >> K;
	cout << N-K+1 << endl;
	comb co;
	co.init(N+K+10+N,MOD);
	FOR(i,2,K+1){
		ll ans = co.nCr(K-1,i-1);
		ll n = N-K-i+1;
		ll k = i+1;
		if(n<0){
			cout << 0 << endl;
			continue;
		}
		ans *= co.nCr(n+k-1,k-1);
		cout << ans%MOD << endl;
	}
}


Measured memory_bytes: 384
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Hamiltonish Path
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef vector<int> vi;

struct List {
  int id;
  List *prv, *nxt;
  List(): id(0), prv(NULL), nxt(NULL) {}
  List(int _id): id(_id), prv(NULL), nxt(NULL) {}
  List(int _id, List *_prv, List *_nxt): id(_id), prv(_prv), nxt(_nxt) {}
};

/* global variables */

vi nbrs[MAX_N];
bool used[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  for (int i = 0; i < m; i++) {
    int ai, bi;
    scanf("%d%d", &ai, &bi);
    ai--, bi--;
    nbrs[ai].push_back(bi);
    nbrs[bi].push_back(ai);
  }

  List *head = new List(0);
  List *tail = new List(nbrs[0][0]);
  head->nxt = tail, tail->prv = head;
  used[0] = used[nbrs[0][0]] = true;
  int len = 2;

  for (bool cont = true; cont;) {
    cont = false;
    vi &nbru = nbrs[head->id];
    for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &v = *vit;
      if (! used[v]) {
	List *lpt = new List(v);
	lpt->nxt = head, head->prv = lpt;
	head = lpt;
	used[v] = true;
	len++;
	cont = true;
	break;
      }
    }
  }

  for (bool cont = true; cont;) {
    cont = false;
    vi &nbru = nbrs[tail->id];
    for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &v = *vit;
      if (! used[v]) {
	List *lpt = new List(v);
	lpt->prv = tail, tail->nxt = lpt;
	tail = lpt;
	used[v] = true;
	len++;
	cont = true;
	break;
      }
    }
  }

  printf("%d\n", len);
  for (List *lpt = head; lpt != NULL; lpt = lpt->nxt) {
    if (lpt->prv != NULL) putchar(' ');
    printf("%d", lpt->id + 1);
  }
  putchar('\n');
  return 0;
}


Measured memory_bytes: 9472
/*Rabbi Zidni Ilma*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld %lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define mod 10000007
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)

ll a[100005],b[100005],c[100005];
ll dp[100005][4];

int main()
{
	ll n,i,ans;
    scl(n);
    for(i=1;i<=n;i++)
    {
    	cin >> a[i] >> b[i] >> c[i];
	}
	for(i=n;i>=1;i--)
	{
		dp[i][1]=max(dp[i+1][2]+a[i],dp[i+1][3]+a[i]);
		dp[i][2]=max(dp[i+1][1]+b[i],dp[i+1][3]+b[i]);
		dp[i][3]=max(dp[i+1][1]+c[i],dp[i+1][2]+c[i]);
	}
	ans=max(dp[1][1],max(dp[1][2],dp[1][3]));
	printf("%lld\n",ans);
}

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

namespace _0026
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int[,] map = new int[14, 14];

            while (true)
            {
                string item = RSt();
                if (item == null) break;

                int[] items = Array.ConvertAll(item.Trim().Split(','), e => int.Parse(e));
                int x = items[0] + 2;
                int y = items[1] + 2;

                map[x, y]++;
                if (items[2] >= 1)
                {
                    map[x - 1, y]++;
                    map[x + 1, y]++;
                    map[x, y - 1]++;
                    map[x, y + 1]++;
                }
                if (items[2] >= 2)
                {
                    map[x - 1, y - 1]++;
                    map[x + 1, y - 1]++;
                    map[x - 1, y + 1]++;
                    map[x + 1, y + 1]++;
                }
                if (items[2] >= 3)
                {
                    map[x - 2, y]++;
                    map[x + 2, y]++;
                    map[x, y - 2]++;
                    map[x, y + 2]++;
                }
            }
            int blank = 0;
            int max = 0;
            for (int i = 2 ; i < 12 ; i++)
            {
                for (int j = 2 ; j < 12 ; j++)
                {
                    if (map[i, j] == 0) blank++;
                    max = Math.Max(max, map[i, j]);
                }
            }
            Console.WriteLine(blank);
            Console.WriteLine(max);
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



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

// Union-Find
struct UnionFind {
    vector<int> par;
    vector<int> scale1;
    vector<int> rank;
    int size;
    // par[i]はiの親の番号
    // rank[i]はiが親の時にのみ意味を持ち, その木のrank(union操作に使う)
    // sizeは木の数

    //最初は全てが根であるとして初期化
    UnionFind(int N) : par(N), scale1(N,1), rank(N,0){
        for(int i = 0; i < N; i++) par[i] = i;
        size = N;
    }

    // データxが属する木の根を再帰で得る
    int root(int x){
        if (par[x] == x) return x;
        par[x] = root(par[x]); // 親を根にする付け替えによって次回以降の参照を高速化
        return par[x];
    }

    // xとyの木を併合(rankの大きい方の根を小さい方の根の親にする)
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if(rank[rx] > rank[ry]){
            par[ry] = rx;
            scale1[rx] += scale1[ry];
        }else if(rank[rx] < rank[ry]){
            par[rx] = ry;
            scale1[ry] += scale1[rx];
        }else{
            // 同じならxを根に
            par[ry] = rx;
            scale1[rx] += scale1[ry];
            rank[rx]++;
        }
        size--;
    }

    // 2つのデータx, yが属する木が同じならtrueを返す関数
    bool same(int x, int y){
        return root(x) == root(y);
    }

    // xの属する木の要素の数を返す関数
    int scale(int x){
        return scale1[root(x)];
    }
};

int main() {
    ll N, M, Q;
    cin >> N >> M >> Q;
    vector<int>A(Q);
    vector<int>B(Q);
    vector<int>C(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> A[i] >> B[i] >> C[i];
    }

    // パスが1個であることと木構造を持つことは同値

    UnionFind tree(N);
    for (int i = 0; i < Q; ++i) {
        if(C[i] == 1) continue;
        tree.unite(A[i], B[i]);
    }

    // 最初のグラフが木の時
    if(M == N-1){
        for (int i = 0; i < Q; ++i) {
            if (C[i] == 1) {
                cout << "No" << "\n";
                return 0;
            }
        }
        cout << "Yes" << "\n";
        return 0;
    }

    // グラフの辺の数の最大値
    ll max_M = tree.size;
    max_M = max_M * (max_M - 1) / 2;
    max_M += (N - tree.size);
    if(max_M < M) {
        cout << "No" << "\n";
        return 0;
    }

    for (int i = 0; i < Q; ++i) {
        if(C[i] == 0) continue;
        if(tree.same(A[i], B[i])){
            cout << "No" << "\n";
            return 0;
        }
    }
    cout << "Yes" << "\n";
    return 0;
}

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

int main(){
	int x;
	int copy_x;
	int cnt_500=0;
	int r_500=0;
	int cnt_5=0;
	cin>>x;
	cnt_500=x/500;
	r_500=x%500;
	cnt_5=r_500/5;
	cout<<cnt_500*1000+cnt_5*5<<flush;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
using namespace std;
int a,b,c=0,d;
string s;
signed main()
{
	cin>>a>>b;
	rep(i,a){
		c+=b+i;
	}
	if(b>0){
		cout<<c-b;
	}elif(b<1&&0<a+b){
		cout<<c;
	}else{
		cout<<c-(b-1+a);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	int a[100];
	cin>>n>>m;
	int cnt=0;
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	for(int i=0;i<n;i++){
		if(a[i]*4*m>=sum){
			cnt++;
		}
	}
	if(cnt>=m){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
struct unionfind{
    public:
    vector<ll> par;
    vector<ll> siz;
    unionfind(ll n) :par(n),siz(n,1LL){
        rep(0,i,n)par[i]=i;
    }
    ll root(ll x){
        if(par[x]==x) return x;
        else return par[x]=root(par[x]);
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }
    bool same(ll x,ll y){
        ll rx=root(x);
        ll ry=root(y);
        return rx==ry;
    }
    ll size(ll x) { 
        return siz[root(x)];
    }
};
int main(void){
    // Your code here!
    ll n,m;
    cin>>n>>m;
    unionfind tree(n);
    vector<pair<ll,ll>> a(m);
    rep(0,i,m)cin>>a[i].first>>a[i].second;
    ll ans[m+1];
    ans[m]=n*(n-1)/2;
    rep(0,i,m){
        ll x=a[m-1-i].first-1,y=a[m-1-i].second-1;
        ll n1=tree.size(x),n2=tree.size(y);
        if(!tree.same(x,y))ans[m-(i+1)]=ans[m-i]-n1*n2;
        else ans[m-(i+1)]=ans[m-i];
        tree.merge(x,y);
        
    }
    rep(0,i,m)cout<<ans[i+1]<<endl;
}

Measured memory_bytes: 5248
n = int(input())
a = [int(input()) for _ in range(n)]
sort_a = sorted(a)
max_a = max(a)
max_ind = 0
for i in range(n):
    if a[i] == max_a: max_ind = i
for i in range(n):
    ans = max_a if i != max_ind else sort_a[-2]
    print(ans)

Measured memory_bytes: 70616
//*/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <cctype>
#include <complex>

using namespace std;

typedef long long int lld;

int main() {
#ifdef LOCAL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int x, n;
	set<int> vals;
	cin >> x >> n;
	for (int i = 0; i < n; i++) {
		int val;
		cin >> val;
		vals.insert(val);
	}

	for (int k = 0;; k++) {
		if (vals.count(x - k) == 0) {
			cout << x - k << endl;
			return 0;
		}
		if (vals.count(x + k) == 0) {
			cout << x + k << endl;
			return 0;
		}
	}

	return 0;
}

//*/ 

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

int main()
{
  string s;
  int n = 0;

  cin >> s;
  for (int i = 0; i < 3; i++)
  {
    if (s[i] == 'o')
      n++;
  }
  cout << 700 + 100 * n << endl;
}

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

#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
    }
    int l = 0, r = 1e9;
    while (r - l > 1) {
        int x = (l + r) / 2;
        auto f = [&](int x) {
            ll now = 0;
            rep(i, N) {
                now += (A[i] - 1) / x;
            }
            return now <= K;
        };
        if (f(x)) {
            r = x;
        } else {
            l = x;
        }
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 4020
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
	int n;
	cin>>n;
	int a[n][3];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>a[i][j];
		}
	}

	int dp[n][3];
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];

	for(int i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1]+a[i][0],dp[i-1][2]+a[i][0]);
		dp[i][1]=max(dp[i-1][0]+a[i][1],dp[i-1][2]+a[i][1]);
		dp[i][2]=max(dp[i-1][1]+a[i][2],dp[i-1][0]+a[i][2]);
	}

	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

Measured memory_bytes: 2560
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,k:usize,
        v:[i64;n],
    }
    let mut q = MinQueue::new();

    let mut ans = 0;
    for leftp in 0..=min(n, k) {
        for rightp in 0..=min(n, k) - leftp {
            let pushc = k - leftp - rightp; //捨てられる数
            for l in 0..leftp {
                q.push(v[l]);
            }
            for r in 0..rightp {
                q.push(v[n - r - 1]);
            }
            for _ in 0..pushc {
                if let Some(x) = q.peek() {
                    if x < &0 {
                        q.pop();
                    }
                }
            }
            let mut ret = 0;
            while let Some(x) = q.pop() {
                ret += x;
            }
            ans = max(ret, ans);
        }
    }
    println!("{}", ans);
}

use std::{cmp::*, collections::*};
struct MinQueue<T: Ord + Copy> {
    que: BinaryHeap<Reverse<T>>,
}
impl<T: Ord + Copy> MinQueue<T> {
    fn new() -> MinQueue<T> {
        MinQueue {
            que: BinaryHeap::<Reverse<T>>::new(),
        }
    }
    fn is_empty(&mut self) -> bool {
        self.que.is_empty()
    }
    fn push(&mut self, x: T) {
        self.que.push(Reverse(x));
    }
    fn len(&mut self) -> usize {
        self.que.len()
    }
    fn pop(&mut self) -> Option<T> {
        if let Some(x) = self.que.pop() {
            let Reverse(y) = x;
            Some(y)
        } else {
            None
        }
    }
    fn peek(&mut self) -> Option<&T> {
        if let Some(x) = self.que.peek() {
            let Reverse(y) = x;
            Some(y)
        } else {
            None
        }
    }
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll h,w,a,b; cin>>h>>w>>a>>b;
  
  rep(i,h){
    rep(j,w){
      if(i>=b){
        if(j<a) cout<<'1';
        else cout<<'0';
      }else{
        if(j<a) cout<<'0';
        else cout<<'1';
      }
    }
    cout<<endl;
  }
  
}

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

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

  int c[10][10];
  for (int i = 0; i < N; i++) {
	for (int j = 0; j < D; j++) {
      cin >> c[i][j];
    }
  }
  
  int count = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      double d = 0;
      for (int k = 0; k < D; k++) {
        d += (c[i][k] - c[j][k]) * (c[i][k] - c[j][k]);
      }
      d = sqrt(d);
      if (ceil(d) == floor(d)) count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
<?php
$p = [];

fscanf(STDIN, "%d", $N);
for($i = 0; $i < $N; $i++) {
    fscanf(STDIN, "%d", $p[$i]);
}

rsort($p);

$p[0] = $p[0] / 2;

$result = array_sum($p);

echo $result. "\n";

Measured memory_bytes: 4856
N, A, B = list(map(int, input().split()))
S = input()
cnt1 = 0
cnt2 = 0
for x in S:
    if x == 'a':
        if cnt1 < A+B:
            print("Yes")
            cnt1 += 1
        else:
            print("No")
    elif x == 'b':
        if cnt1 < A+B and cnt2 < B:
            print("Yes")
            cnt1 += 1
            cnt2 += 1
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 4244
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define All(A) A.begin(),A.end()
#define RAll(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<double,double> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<30;


int main(){
    int D,N;
    cin >> D >> N;
    if(N<100) cout << N*(int)pow(100,D) << endl;
    else cout << 101*(int)pow(100,D) << endl;
    return 0;
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import floyd_warshall
 
N = int(input())
S = [[0 if i==j else float("inf") for i in range(N)] for j in range(N)]
for i in range(N):
    S_list = list(input())
    for j in range(N):
        if S_list[j] == "0": continue
        S[i][j] = S[j][i] = int(S_list[j])
 
# 二部グラフ判定
def is_bipartite_graph(adjacency_matrix):
    colors = [0] * len(adjacency_matrix)
    return dfs(0,1,colors,adjacency_matrix)
#頂点vをcolor(1 or -1)で塗り、再帰的に矛盾がないか調べる。
def dfs(v,color,colors,adjacency_matrix):
    #今いる点を着色
    colors[v] = color
    #今の頂点から行けるところをチェック
    for to in range(len(adjacency_matrix[v])):
        # 頂点が隣接しない場合
        if adjacency_matrix[v][to] != 1:
            continue
        #同じ色が隣接してしまったらFalse
        if colors[to] == color:
            return False
        #未着色の頂点があったら反転した色を指定し、再帰的に調べる
        if colors[to] == 0 and not dfs(to,-color,colors,adjacency_matrix):
            return False
    #調べ終わったら矛盾がないのでTrue
    return True
 
if is_bipartite_graph(S):
    d = floyd_warshall(S)
    answer = 0
    for i in range(N):
        answer = max(answer,max(d[i]))
    print(int(answer)+1)
else:
    print(-1)

Measured memory_bytes: 20264
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <typeinfo>
#include <stdlib.h>
#include <stack>
#include <queue>
#include <type_traits>

#define ll unsigned long long
#define ld long double

using namespace std;


int main(){
  ll n,arrival_time, departure_time;
  cin >> n;
  vector<ll> c(n),s(n),f(n);
  for(ll i=1; i<n; i++){
    cin >> c[i] >> s[i] >> f[i];
  }
  if(n==1){
    cout << 0 << endl;
  }else{
    for(ll i=1; i<n; i++){
      arrival_time = 0;
      for(ll j=i; j<n; j++){
        if(arrival_time > s[j]){
          if(arrival_time % f[j] == 0){
            departure_time = arrival_time;
          }else{
            departure_time = f[j] * ((arrival_time / f[j])+1);
          }
        }else{
          departure_time = s[j];
        }
        arrival_time = departure_time + c[j];
      }
      cout << arrival_time << endl;
    }
    cout << 0 << endl;    
  }


  return 0;
}



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

int main(){
	int r;cin>> r;
	string a;cin>>a;
	if(a.size() % 2)cout << "No" << endl;
	else{
		string aa,bb;
		for(int i = 0 ; i< a.size() / 2 ; i++){
			aa += a[i];
		}
		for(int i= a.size() / 2 ; i < a.size() ; i++){
			bb += a[i];
		}
		if(aa == bb)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<vector<ll>> matrix;

int n;
int a[51];
int b[51];

bool can[51][51];

void die() {
  cout << "-1\n";
  exit(0);
}

void solve() {
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++) cin >> b[i];
  ll ret = 0;
  set<int> all;
  for(int i = 1; i <= 50; i++) {
    all.insert(i);
  }
  for(int m = 50; m >= 1; m--) {
    all.erase(m);
    memset(can, 0, sizeof(can));
    for(int i = 0; i <= 50; i++) {
      can[i][i] = true;
      for(int out: all) can[i][i%out] = true;
    }
    for(int i = 0; i <= 50; i++) for(int j = 0; j <= 50; j++) for(int k = 0; k <= 50; k++) can[i][j] |= can[i][k] && can[k][j];
    for(int i = 0; i <= 50; i++) for(int j = 0; j <= 50; j++) for(int k = 0; k <= 50; k++) can[i][j] |= can[i][k] && can[k][j];
    for(int i = 0; i <= 50; i++) for(int j = 0; j <= 50; j++) for(int k = 0; k <= 50; k++) can[i][j] |= can[i][k] && can[k][j];
    for(int i = 0; i < n; i++) {
      if(!can[a[i]][b[i]]) {
        all.insert(m);
        break;
      }
    }
  }
  for(int out: all) ret += 1LL << out;
  if(ret > (1LL << 50)) ret = -1;
  cout << ret << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#define ll long long 
#define d double
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int h,a;
  cin>>h>>a;
  int count=0;
  while(h>0){
  	h-=a;
  	count++; 	
  }
  cout<<count<<endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s;
	cin>>s;
	ll k;
	cin>>k;
	ll m1,m2;
	m1=m2=0;
	string t='A'+s;
	string u=s[s.size()-1]+s;
	for(ll i=1;i<=t.size();i++){
		if(t[i]==t[i-1]){
			t[i]='A';
			m1++;
		}
	}
	for(ll i=1;i<=u.size();i++){
		if(u[i]==u[i-1]){
			u[i]='A';
			m2++;
		}
	}
	if(t[1]!=t[t.size()-1]){
		cout<<k*m1;
	}
	else{
		if(u[1]!=u[u.size()-1]){
			cout << m1+(k-1)*m2;
		}
		else{
			cout << k/2*(m1+m2)+k%2*m1;
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    char a,b; cin>>a>>b;
    if(a=='9'||b=='9')cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main(){ 
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  if (a < b) {
  ll l = a + v * t, r = b + w * t;
  if (r <= l) cout << "YES" << endl;
  else cout << "NO" << endl;
  } else {
    ll l = a - v * t, r = b - w * t;
    if (l <= r) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
} 

Measured memory_bytes: 3636