akhauriyash/Code-Regression huggingface dataset:
import math
def resolve():
    A,B,C = map(int,input().split())
    K = int(input())
    if A < B:
        magic_B = 0
    else:
        magic_B = int(math.log2(A/B)) + 1
    B_mult = B * pow(2,magic_B)

    if B_mult < C:
        magic_C = 0
    else:
        magic_C = int(math.log2(B_mult/C)) + 1
    
    if magic_B + magic_C <= K:
        print("Yes")
    else:
        print("No")
resolve()

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

int main(){
    int N,M;
    
    //入力
	cin>>N;
    vector<string> vecBlue(N);
    for (int i=0; i<N; i++){
        cin >> vecBlue.at(i);
    }
    cin>>M;
    vector<string> vecRed(M);
    for (int i=0; i<M; i++){
        cin >> vecRed.at(i);
    }
    
    vector<string> vecName(N+M);//検索済みを入れる配列
    int NameNum=0;
    char F;            
    int maxPoint=0;
    
    //処理
    
    //検索済みとすべて比較して、かぶったらやらない
    //vecNameに存在する加点文字列がかぶりなしで入り、
    //NameNumにその種類の数が入る
    for (int i=0;i<N;i++){
        F='?';
        for (int j=0;j<NameNum;j++){
            if( vecBlue.at(i)==vecName.at(j) ){//既出ならスルー
                F='F';
            }
        }
        if(F!='F'){//加点文字列で新しいものが見つかれば、
            vecName.at(NameNum)=vecBlue.at(i);
            NameNum++;
            
            //その文字列が何点か調べる
            int point=0;
            for(int k=0;k<N;k++){//加点と比較
                if( vecBlue.at(i)==vecBlue.at(k) ){
                    point++;
                }
            }
            for(int k=0;k<M;k++){//減点と比較
                if( vecBlue.at(i)==vecRed.at(k) ){
                    point--;
                }
            }
            if(maxPoint<point){maxPoint=point;}
            //cout<<point<<"点"<<vecBlue.at(i)<<endl;//各点確認できる
        }
    }
    
    //出力
    if(maxPoint<0){
        cout<<"0"<<endl;
    }
    else{
        cout<<maxPoint<<endl;
    }
    for (int i=0; i<N; i++){
        //cout << vecBlue.at(i) << endl;
    }
    for (int i=0; i<M; i++){
        //cout << vecRed.at(i) << endl;
    }
    
    
}

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

int main(int argc, const char * argv[]) {
    int a, b;
    
    
    cin >> a >> b;
    if(a==1 || b==1){
        if(a==1 && b==1){
            cout << "Draw" << endl;
        }else if(a==1){
            cout << "Alice" << endl;
        }else{
            cout << "Bob" << endl;
        }
    }else{
        if(a>b){
            cout << "Alice" << endl;
        }else if(a<b){
            cout << "Bob" << endl;
        }else{
            cout << "Draw" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
mod_0 = 0
mod_harf = 0

for i in range(1, n + 1):
    if i % k == 0:
        mod_0 += 1
    elif i % k == (-i) % k:
        mod_harf += 1

res = mod_0 ** 3 + mod_harf ** 3
print(res)

Measured memory_bytes: 9120
#include<stdio.h>

int main(void)
{
	long long int x,quo;
	int rem;
	scanf("%lld", &x);
	

	quo = x / 11; 
	rem = x % 11;

	if (rem>6) printf("%lld",(quo+1) * 2);
	else if (rem == 0)printf("%lld", quo  * 2);
	else printf("%lld",quo * 2 + 1);
	
	return 0;
}

Measured memory_bytes: 128
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t){e.exports=require("fs")},function(e,t,n){"use strict";n.r(t);var r=n(0);!function(e){e.split("\n")[0];var t=e.split("\n")[1].match(/ABC/g);t?console.log(t.length):console.log(0)}(r.readFileSync("/dev/stdin","utf8").trim())}]);

Measured memory_bytes: 9420
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt()
    var g = 0
    var m = 0

    for (i in 0 until n) {
        val a = sc.nextInt()
        if (i == 0) {
            g = a
            m = a
        }
        g = gcd(g, a)
        m = Math.max(m, a)
    }

    if (k % g == 0 && k <= m) {
        println("POSSIBLE")
    } else {
        println("IMPOSSIBLE")
    }
}

fun gcd(x: Int, y: Int): Int {
    var x = x
    var y = y
    while (y != 0) {
        x %= y
        val tmp = x
        x = y
        y = tmp
    }
    return Math.abs(x)
}


Measured memory_bytes: 52528
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
H = np.array([-10] + lr() + [10**10])
x = H[1:] <= H[:-1]

temp = np.arange(len(x))
temp[x>0] = 0
np.maximum.accumulate(temp, out=temp)
left = temp
x_reversed = x[::-1]
temp = np.arange(len(x))
temp[x_reversed > 0] = 0
np.maximum.accumulate(temp, out=temp)
right = len(x) - 1 - temp[::-1]
y = right
y -= left + 1
y[x == 0] = 0
answer = y.max()
print(answer)


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

typedef long long lli;
typedef vector<int> Vi;
typedef vector<lli> Vl;
typedef pair<int, int> Pii;
typedef pair<lli, lli> Pll;


//===


int main() {
	int N;
	cin >> N;
	
	vector<vector<Pii>> to(N);
	for (int i = 0; i < N - 1; ++i) {
		int u, v, w;
		cin >> u >> v >> w;
		--u; --v;
		to[u].push_back(make_pair(v,w));
		to[v].push_back(make_pair(u,w));
	}

	Vi ans(N,-1);
	stack<int> s;
	ans[0] = 0;
	s.push(0);
	while (!s.empty()) {
		int v = s.top();
		s.pop();
		for (int i = 0; i < to[v].size(); ++i) {
			int u = to[v][i].first;
			int w = to[v][i].second;
			if (ans[u] != -1) continue;
			ans[u] = (ans[v] + w) % 2;
			s.push(u);
		}
	}

	for (const auto& val : ans) {
		cout << val << endl;
	}
}

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

int main()
{
    ll A, B;
    cin >> A >> B;
    cout << (B - 1 + (A - 2)) / (A - 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define DEB 0

/*
real	0m2.093s  --> 
real	0m2.000s
*/
const int dx[] = {1,0,-1,0}; //r,d,l,u
const int dy[] = {0,1,0,-1};

int w,h,sx,sy,home,last;
int field[16][16];
int num[16][16];
int hS[25],hx[25],hy[25],edge[25][4][25]; //[src][dir][dest]
//int memo[885777];
map<int,int> msi;

inline bool isnotgoal(int s){
  return (((last&s)) == last);
}
inline bool isnot(int s){
  rep(i,home)if( !(s&(1<<i)) ){
    if( (hS[i]&s)==hS[i] ) return true;
  }
  return false;
}
inline bool inside(int x, int y){
  return (x<0 || y<0 || x>=w || y>=h);
}

int dfs(int S){
  int src = S&((1<<5)-1);
#if DEB
  printf("S:%d  src:%d\n",S,src);
#endif
  int x = hx[src];
  int y = hy[src];
  int s = S>>5;

#if DEB
  printf("src:%d , x:%d , y:%d , s:%d\n",src,x,y,s);
#endif

  if( (1<<home)-1 == s ){ //âÎÉßêé
    return 1;
  }
  if( isnotgoal(s) ){ //³ïÉßé½ßÌÆðÁïµ½©Ç¤©
    return 0;
  }
  if( msi.count(S) ){ //ùÉÊÁ½óÔ
    return msi[S];
  }
  
  // v[gªu¯È¢ÆÌL³
  /*
    1831764
    ari  :: msi_sz: 885661  >0:376369  ==0:509292  already>0:222390 , already==0:408636
    nari :: msi_sz:1028771  >0:376369  ==0:652402  already>0:222390 , already==0:565310
   */
  
  if( s>0 && ((s&(s-1))!=0) && isnot(s&~(1<<num[y][x])) ){
    return 0;
  }
  
  
  int ret = 0;
  rep(k,4){
    for(int j=0; edge[src][k][j]!=-1; j++){
      int dest = edge[src][k][j];
      int nx = hx[dest];
      int ny = hy[dest];
      if( field[ny][nx]==1 ){
	field[ny][nx] = 0;
#if DEB
	printf("dest:%d  (%d,%d)   ,%d  , %d\n",dest,nx,ny,s|(1<<dest),(s|(1<<dest))<<4);
#endif
	ret += dfs(((s|(1<<dest))<<5)|dest);
	field[ny][nx] = 1;
	break;
      }
    }
  }
  msi[S] = ret;
  return ret;
}

int main(){

  while(scanf("%d%d",&w,&h),w|h){
    msi.clear();
    memset(num,-1,sizeof(num));
    memset(edge,-1,sizeof(edge));
    memset(hS,0,sizeof(hS));
    home = last = 0;
    rep(i,h){
      rep(j,w){
	scanf("%d",&field[i][j]);
	if( field[i][j]==2 ){
	  sx=j; sy=i;
	}
	if( field[i][j]==1 ){
	  hx[home]=j; hy[home]=i;
	  num[i][j] = home;
	  home++;
	}
      }
    }
    hx[home] = sx;
    hy[home] = sy;

    // other homes
    rep(i,home){
      rep(k,4){
	int sz = 0;
	for(int j=1; j<20; j++){
	  int tx = hx[i] + dx[k]*j;
	  int ty = hy[i] + dy[k]*j;
	  if( inside(tx,ty) ) break;
	  if( field[ty][tx]==1 ){
	    hS[i] |= (1<<num[ty][tx]);
	    edge[i][k][sz++] = num[ty][tx];
	  }
	}
      }
    }

    //last homes
    rep(k,4){
      int sz = 0;
      for(int i=1; i<20; i++){
	int tx = sx + dx[k]*i;
	int ty = sy + dy[k]*i;
	if( inside(tx,ty) )break;
	if( field[ty][tx]==1 ){
	  last |= (1<<num[ty][tx]);
	  edge[home][k][sz++] = num[ty][tx];
	}
      }
    }
    printf("%d\n",dfs(home));
  }
  

  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    string A[301];
    REP(i, H) cin >> A[i];

    int out[300][300] = {};
    int no = 1;
    REP(i, H) {
        bool has_s = false;
        REP(j, W) if (A[i][j] == '#') has_s = true;
        if (!has_s) continue;

        has_s = false;
        REP(j, W) {
            if (A[i][j] == '#') {
                if (has_s) {
                    no++;
                }
                has_s = true;
                out[i][j] = no;
            }
            else {
                out[i][j] = no;
            }
        }
        no++;
    }

    FOR(i, 1, H) {
        if (out[i][0] == 0) {
            REP(j, W) {
                out[i][j] = out[i - 1][j];
            }
        }
    }

    RFOR(i, H - 2, -1) {
        if (out[i][0] == 0) {
            REP(j, W) {
                out[i][j] = out[i + 1][j];
            }
        }
    }

    REP(i, H) {
        REP(j, W) cout << out[i][j] << " ";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
// Ho-kago Tea Time

#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef pair<int, int> pii;

const int MOD = (int) 1e9 + 7;

inline int fpm(int x, LL y)
{
	int res = 1;
	for(; y; y >>= 1, x = (LL) x * x % MOD) if(y & 1) res = (LL) res * x % MOD;
	return res;
}

const int MAXN = (int) 1e3;

int n, m;
LL K;

int A[MAXN + 5][MAXN + 5];

inline char safe_getchar()
{
	register char ch(getchar());
	while(!isgraph(ch)) ch = getchar();
	return ch;
}

inline void input()
{
	n = read<int>(), m = read<int>();
	K = read<LL>();
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			A[i][j] = safe_getchar() == '#';
}

struct matrix
{
	int A[2][2];

	inline int * operator [] (int p) { return A[p]; }
	inline const int *operator [] (int p) const { return A[p]; }
	inline void reset() { memset(A, 0, sizeof A); }

	inline matrix operator * (const matrix &rhs) const
	{
		static matrix res;
		res.reset();

		for(int i = 0; i < 2; ++i)
			for(int j = 0; j < 2; ++j) if(this->A[i][j])
				for(int k = 0; k < 2; ++k)
					(res[i][k] += (LL) this->A[i][j] * rhs[j][k] % MOD) %= MOD;
		return res;
	}
};

inline matrix unit()
{
	static matrix res;
	for(int i = 0; i < 2; ++i) res[i][i] = 1;
	return res;
}

inline matrix fpm(matrix x, LL y)
{
	matrix res(unit());
	for(; y; y >>= 1, x = x * x) if(y & 1) res = res * x;
	return res;
}

inline void solve()
{
	if(K == 0) { puts("1"); return; }

	int N = 0, eud = 0, elr = 0;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
		{
			N += A[i][j];
			if(i < n) eud += A[i][j] & A[i + 1][j];
			if(j < m) elr += A[i][j] & A[i][j + 1];
		}

	int ud = 0, lr = 0;
	for(int i = 1; i <= m; ++i) ud += A[1][i] & A[n][i];
	for(int i = 1; i <= n; ++i) lr += A[i][1] & A[i][m];

	if(ud == 0 && lr == 0) printf("%d\n", (fpm(N, K - 1) + MOD) % MOD);
	else if(ud > 0 && lr > 0) puts("1");
	else
	{
		int t = ud == 0 ? lr : ud, e = ud == 0 ? elr : eud;

		static matrix S, T;

		S.reset(), S[0][0] = 1, S[0][1] = 0;
		T.reset();
		T[0][0] = N;
		T[0][1] = e;
		T[1][1] = t;

		S = S * fpm(T, K - 1);

		int ans = (S[0][0] - S[0][1]) % MOD;
		printf("%d\n", (ans + MOD) % MOD);
	}
}

int main()
{
#ifdef K_ON // K-ON!
		freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 4224
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int64 n,k; cin >> n >> k;
		int64 r, s, p; cin >> r >> s >> p;
		string t; cin >> t;
		string myh;
		vector<bool> res(t.length());
		int64 ans = 0;
		rep (i, t.length()) {
			if (i < k || t[i] != t[i - k]) {
				res[i] = true;
			} else if(t[i] == t[i - k] && res[i - k] != true) {
				res[i] = true;
			} else {
				continue;
			}
		}
		rep (i, t.length()) {
			if (res[i]) {
				char ts = t[i];
				if (ts == 'r') {
					ans += p;
				} else if (ts == 's') {
					ans += r;
				} else {
					ans += s;
				}
			}
		}
		cout << ans << endl;
    return;
}

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



Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cctype>
#include <cmath>
#include <string>
using namespace std;
int judge(char,char);
int main(){
    int X,ans;
    cin >> X;
    for(int i = 0;i < X;i ++){
        int testX = X - i;
      	int count = 0;
        for(int j = 2;j <= floor(sqrt(X));j ++){
          	testX = X - i;
          	count = 0;
            while(testX != 1){
                if(testX % j == 0){
                    testX /= j;
                  	count ++;
                }else{
                    break;
                }
            }
          	if(testX == 1 && (count > 1 || X == 1)) break;
        }
        if(testX == 1 && (count > 1 || X == 1)){
            ans = X - i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    int64_t res = 700;
    for(char c:s){
        if(c=='o') res+=100;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  ll h, n;
  cin >> h >> n;
  ll sum = 0;
  rep(i, 0, n){
    ll a;
    cin >> a;
    sum += a;
  }

  if(sum >= h) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
bool prime[50001];
void eratosutenesu(){
	fill(prime, prime + 50001, true);
	prime[0] = false; prime[1] = false;
	for(int i = 2; i * i <= 50000; i++){
		if(prime[i] == true){
			for(int j = 2;; j++){
				if(j * i > 50000) break;
				prime[j * i] = false;
			}
		}
	}
	return;
}
int main(){
	eratosutenesu();
	for(;;){
		int n;
		cin >> n;
		if(n == 0) break;
		int ans = 0;
		for(int i = 1; i <= n / 2; i++){
			if(prime[i] && prime[n - i]) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
  int a=0,b=0,c=0;
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='a'){a++;}
    if(s[i]=='b'){b++;}
    if(s[i]=='c'){c++;}
  }
  if(1>=max({a,b,c})-min({a,b,c})){cout << "YES" << endl;}else{cout << "NO" << endl;}
  
}

Measured memory_bytes: 764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        int count = 0;
        for (int i = 1; i <= n; i++) {
            int count2 = 0;
            if (i % 2 != 0) {
                for (int j = 1; j <= i; j++) {
                    if (i % j == 0)
                        count2++;
                }
                if (count2 == 8)
                    count++;
            }
        }
        System.out.println(count);
    }
}


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

int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);
    vector<int> ad(0);
    long ans=0;
    rep(i,n){
        cin>>a[i];
        if(i>0 && a[i-1]+1==a[i]){
            int aa=a[i-1]-1;
            ad.push_back(aa);
        }
    }
    rep(i,n){
        cin>>b[i];
        ans+=b[i];
    }
    rep(i,n-1){
        cin>>c[i];
    }
    rep(i,ad.size()){
        ans+=c[ad[i]];
    }
    cout<<ans<<endl;
}

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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
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; }

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

    vector <string> t;
    t.push_back("dream");
    t.push_back("dreamer");
    t.push_back("erase");
    t.push_back("eraser");
    int now = int(s.size());

    while (now > 0) {
        //cout << now << endl;
        bool ok = false;
        for (int i = 0; i < 4; i++) {
            if (now - int(t[i].size()) >= 0) {
                if (s.substr(now - int(t[i].size()), int(t[i].size())) == t[i]) {
                    ok = true;
                    now -= int(t[i].size());
                    break;
                }
            }
        }
        if (!ok) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main()
{
   int k,o=0,e=0;
   cin>>k;

for(int i=1;i<=k;i++)
   {
       if(i%2==0)

           e+=1;
       else
            o+=1;
   }
   cout<<o*e;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 2333,mo=1e9+7;
int n,k,C[N][N],res,f[N][N],g[N];
void ini(int n){
	rep(i,2,n+1)f[n][i]=1;
	per(i,n-1,1){
		int s=f[i+1][2];
		rep(j,2,i+1)
			s=(s+f[i+1][j+1])%mo,f[i][j]=s;
	}
	rep(i,1,n)g[i]=f[i][i+1];g[0]=g[1];
}
int main() {
	read(n);read(k);
	rep(i,0,n){
		C[i][0]=C[i][i]=1;
		rep(j,1,i-1)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	}
	ini(k-1);
	if(k==1)res=1;
	else if(k==n)res=g[0];
	else{rep(i,n-k,n-1)res=(res+1LL*C[i-1][n-k-1]*g[i-(n-k)])%mo;}
	rep(i,1,n-k-1)res=2LL*res%mo;
	cout<<res;
	return 0;
}


Measured memory_bytes: 38144
import java.util.*;

public class Main {
  public static void main(String[] args) {
    long MOD = 1000000007;
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s1 = sc.next();
    String s2 = sc.next();
    long ans = 1;
    int pos = 0;
    int pre = 0;
    if(n > 1) {
      if(s1.charAt(0) == s1.charAt(1)) {
        ans = 6;
        pos = 2;
      } else {
        ans = 3;
        pos = 1;
        pre = 1;
      }
      while(pos < n) {
        if(pre == 0) {
          if(pos == n - 1) {
            pos++;
          } else {
            if(s1.charAt(pos) == s1.charAt(pos + 1)) {
              ans = (ans * 3) % MOD;
              pos += 2;
              pre = 0;
            } else {
              pos++;
              pre = 1;
            }
          }
        } else {
          if(pos == n - 1) {
            ans = (ans * 2) % MOD;
            pos++;
          } else {
            if(s1.charAt(pos) == s1.charAt(pos + 1)) {
              ans = (ans * 2) % MOD;
              pos += 2;
              pre = 0;
            } else {
              ans = (ans * 2) % MOD;
              pos++;
              pre = 1;
            }
          }          
        }
      }
    } else {
      ans = 3;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N=1e3+5;
const int M=2e5+5;

int n,m,A[M],B[M],vis[N],tag[N],flag[2][N][N];
vector <int> G[N];

template <typename _Tp> inline void IN(_Tp&x) {
	char ch;bool flag=0;x=0;
	while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	if(flag) x=-x;
}

void dfs(int u,int rt) {
	if(vis[u]) return;
	flag[0][rt][u]=vis[u]=true;
	for(auto v:G[u]) dfs(v,rt);
}
void dfs(int u,int rt,int id,int now) {
	if(vis[u]) return;
	vis[u]=true;
	if(!now) tag[u]=id;
	else flag[1][rt][u]=(bool)(tag[u]!=id);
	for(auto v:G[u]) dfs(v,rt,id,now);
}

int main() {
	IN(n),IN(m);
	for(int i=1;i<=m;++i)
		IN(A[i]),IN(B[i]),G[A[i]].push_back(B[i]);
	for(int u=1;u<=n;++u) memset(vis,0,sizeof(vis)),dfs(u,u);
	for(int u=1;u<=n;++u) {
		memset(tag,0,sizeof(tag));
		memset(vis,0,sizeof(vis)),vis[u]=true;
		for(int i=0;i<=(int)G[u].size()-1;++i) dfs(G[u][i],u,i,0);
		memset(vis,0,sizeof(vis)),vis[u]=true;
		for(int i=(int)G[u].size()-1;i>=0;--i) dfs(G[u][i],u,i,1);
	}
	for(int i=1;i<=m;++i)
		puts(flag[0][B[i]][A[i]]^flag[1][A[i]][B[i]]?"diff":"same");
	return 0;
}

Measured memory_bytes: 12288
#include <stdio.h>
#include <string.h>
int main(void){
    long long n,r,ans;
    scanf("%lld%lld",&n,&r);
    if (n < 10){
        ans = r + 100*(10-n);
    }else{
        ans = r;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[200005];
long long sum=0;
int main(){
    int n;
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    long long temp=0;
    for (int i = 0; i < n; i++)
    {
        temp+=a[i];
        if(temp>=sum/2){
            cout<<min(2*temp-sum,sum-2*(temp-a[i]));
            return 0;
        }
    }
    
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int a[] = {1,2,3,4,5,6,7,8,9,19,29,39,49,59,69,79,89,99,199,299,399,499,599,699,799,899,999};
int main()
{
	int k;
	scanf("%d", &k);
	if(k <= 27)
	{
		for(int i = 0; i < k; ++ i)
			printf("%d\n", a[i]);
		return 0;
	}
	k -= 27;
	for(int i = 0; i < 27; ++ i)
		printf("%d\n", a[i]);
	for(int i = 4; i <= 14; ++ i)
	{
		for(int j = 10; j < min(100, (i - 2) * 10); ++ j)
		{
			printf("%d", j);
			for(int q = 1; q <= i - 2; ++ q)
				putchar('9');
			puts("");
			-- k;
			if(k == 0)
				return 0;
		}
		for(int j = i - 2; j <= 9; ++ j)
		{
			printf("%d", j);
			for(int q = 1; q <= i - 1; ++ q)
				putchar('9');
			puts("");
			-- k;
			if(k == 0)
				return 0;
		}
	}
	for(int i = 100; i <= 108; ++ i)
	{
		printf("%d", i);
		for(int j = 1; j <= 12; ++ j)
			putchar('9');
		puts("");
		-- k;
		if(k == 0)
			return 0;
	}
	for(int i = 10; i <= 99; ++ i)
	{
		printf("%d", i);
		for(int j = 1; j <= 13; ++ j)
			putchar('9');
		puts("");
		-- k;
		if(k == 0)
			return 0;
	}
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef long int li;

int main(void){
    li ans = 1000000007;
    li n,k;
    cin >> n >> k;
    li h[n];
    li d;
    for(li i=0;i<n;i++){
        cin >> h[i];
    }
    sort(h,h+n);
    for(li i=0;i<n-k+1;i++){
        d=h[i+k-1]-h[i];
        ans=min(ans,d);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();

        if(a>b){
            if(a>=c&&b>=c){
                System.out.println(c + " " + b + " " + a);
            }else if(a>=c&&c>-b){
                System.out.println(b + " " + c + " " + a);
            }else{
                System.out.println(b + " " + a + " " + c);
            }
        }else{
            if(b>-c&&a>=c){
                System.out.println(c + " " + a + " " + b);
            }else if(b>=c&&c>=a){
                System.out.println(a + " " + c + " " + b);
            }else{
                System.out.println(a + " " + b + " " + c);
            }
        }

    }
}


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

int main(){
    int N, a, b;
    cin >> N;
    a = N % 10;
    b = N / 10;


    if(a == 9 || b == 9){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	const int N = n;

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

	int hu=0,hd=1000000000;
	for(int i=0;i<N;i++){
		if(h[i]>hu)	hu=h[i];
		if(h[i]<hd)	hd=h[i];
	}

	int C_x, C_y, H;
	for(int _x=0;_x<101;_x++){
		for(int _y=0; _y<101;_y++){
			for(int _h=hu;_h<=hu+101;_h++){
				int flag = 1;
				for(int i=0;i<N;i++){
					if(h[i] != max(0, _h - abs(x[i]-_x)-abs(y[i]-_y)))	flag = 0;
				}
				if(flag == 1){
					C_x = _x;
					C_y = _y;
					H = _h;
					break;
				}
			}
		}
	}
	cout << C_x << " " << C_y << " " << H;
	return 0;
}


Measured memory_bytes: 256
SIZE=100010; MOD=10**9+7 #998244353 #ここを変更する

SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
inv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD

# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

n = int(input())
x = [int(i) for i in readline().split()]

dx =[j-i for i,j in zip(x,x[1:])]

from itertools import accumulate
acc = list(accumulate(inv))

#print(dx)
#print(acc[:10])
ans = 0
for i,di in enumerate(dx):
    ans += di*acc[i+1]
    ans %= MOD

#print(ans)

for i in range(1,n):
    ans *= i
    ans %= MOD
print(ans)



    


Measured memory_bytes: 20316
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll x, y;
  cin >> x >> y;
  priority_queue<ll, vector<ll>, greater<ll>> pq;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      ll nx = i ? -x : x;
      ll ny = j ? -y : y;
      if (nx <= ny) {
        pq.push(i + j + (ny - nx));
      }
    }
  }

  cout << pq.top() << ln;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

using namespace std;

class Alchemy{
public:
  string product, material[100];
  int num;
};
main(){
  int n;
  while(1){
    cin >> n;
    if(n==0) break;
    map<string, int> items;
    for(int i=0;i<n;i++){
      string tmp;
      cin >> tmp;
      cin >> items[tmp];
    }

    int m;
    cin >> m;
    Alchemy alc[100];
    for(int i=0;i<m;i++){
      cin >> alc[i].product >> alc[i].num;
      for(int j=0;j<alc[i].num;j++){
	cin >> alc[i].material[j];
      }
    }
    for(int i=0;i<m;i++){
      for(int j=i, k=0;k<m;j++, k++){
	if(j==m) j=0;
	int sum=0;
	for(int l=0;l<alc[j].num;l++){
	  sum+=items[alc[j].material[l]];
	}
	if(sum<items[alc[j].product]) items[alc[j].product]=sum;
      }
    }

    string in;
    cin >> in;
    cout << items[in] << endl;;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,K;
    cin >> N >> K;
//    vector<int> A(N);
//    for (int i=0;i<N;i++){
//        cin >> A.at(i) ;
//    }
    if(N*500>=K) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
from  fractions  import gcd
n,m = map(int,input().split())
s = input()
t = input()
def lcm(x,y):
  return (x*y)//gcd(x,y)

a = lcm(n,m)
b = gcd(n,m)
if b==1:
  if s[0]==t[0]:
    print(a)
  else:
    print(-1)
else:
  k = int(a//b)
  for i in range(b):
    w = int(n*i//b)
    ww = int(m*i//b)
    if s[w]==t[ww]:
      continue
    else:
      print(-1)
      exit()
  else:
    print(a)

Measured memory_bytes: 5472
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000000
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=1e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int n,m,k,t,l[30][maxn],r[30][maxn];
ll a[maxn],p;
void init()
{
    memset(l,-1,sizeof l);
    memset(r,-1,sizeof r);
    for(int i=0;i<=n-1;i++)
    {
        r[0][i]=lower_bound(a,a+n,a[i]+p)-a;
        if(r[0][i]==n||a[r[0][i]]>a[i]+p)r[0][i]--;
        l[0][i]=lower_bound(a,a+n,a[i]-p)-a;
        if(i==n-1)r[0][i]=-1;
        if(i==0)l[0][i]=-1;
    }
    for(int i=1;i<=29;i++)
    {
        for(int j=0;j<=n-1;j++)
        {
            if(r[i-1][j]<n-1)r[i][j]=r[i-1][r[i-1][j]];
            if(l[i-1][j]>0)l[i][j]=l[i-1][l[i-1][j]];
        }
    }
}
int main()
{
    int i,j;
    scanf("%d",&n);
    rep(i,0,n-1)scanf("%lld",&a[i]);
    scanf("%lld",&p);
    init();
    int q;
    scanf("%d",&q);
    while(q--)
    {
        int b,c,ans=0;
        scanf("%d%d",&b,&c);
        b--,c--;
        if(b<c)
        {
            for(i=29;i>=0;i--)
            {
                if(r[i][b]!=-1&&r[i][b]<=c)
                {
                    ans+=qpow(2,i);
                    b=r[i][b];
                    if(b==c)break;
                }
            }
            if(i==-1)ans++;
        }
        else
        {
            for(i=29;i>=0;i--)
            {
                if(l[i][b]!=-1&&l[i][b]>=c)
                {
                    ans+=qpow(2,i);
                    b=l[i][b];
                    if(b==c)break;
                }
            }
            if(i==-1)ans++;
        }
        printf("%d\n",ans);
    }
    //system("Pause");
    return 0;
}

Measured memory_bytes: 25088
import java.util.Scanner;
//int[] date=new int[2];
public class Main {
int i,o,sum,h,s,e,u,ty,yu,ui,n,num,qw;
double m,t,r,j,k,f,d,g,w;
static double l;
String b,c,z,x,v,a,q;
Scanner scan =new Scanner(System.in);
//入力
	public void input() {	
	
	}
	//演算
	public void compute() {
	
		}
//出力
	public void output() {
		h=scan.nextInt();
h=2*h;
m=h*3.14;
System.out.println(m);
		}
	public static void main(String [ ] args) {
		Main p = new Main ();
		p.input();
		p.compute();
		p.output();
		}
	}

Measured memory_bytes: 35872
#include <bits/stdc++.h>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define prin(a) cout<<a<<"\n"
#define kaigyo cout<<"\n"
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef unsigned long long  ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll mod=1e+9+7;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);  
  int a,b;
string s;
cin>>a>>b>>s;
 
rep(i,s.size()){
	if(i==a){
		if(s[i]!='-'){
			prin("No"); return 0;
		}
	}else{
		if(s[i]=='-'){
			prin("No"); return 0;
		}
	}
}
prin("Yes");
return 0;
 
}


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

using ll = long long;

const int N = 1e5 + 5;

// dp[i]: the number of ways to distribute i candies
int dp[N];
int dif[N];
int n, k;
const int MOD = 1e9 + 7;

void add(int& a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void sub(int& a, int b) {
    a -= b;
    if (a < 0) a += MOD;
}

void solve() {
    int a;
    memset(dp, 0, sizeof dp);
    dp[0] = 1; // only 1 way to distribute 0 candie

    for (int i = 0; i < n; ++i) {
        scanf("%d", &a);
        memset(dif, 0, sizeof dif);
        for (int used = k; ~used; --used) { // iterate the count of distributed candies
            // why reverse the order?

            // d: [1, min(a, k - used)]
            // use difference array to perform fast addition
            int L = used + 1;
            int R = used + min(a, k - used);
            add(dif[L], dp[used]);
            sub(dif[R + 1], dp[used]);
        }
        int part_sum = 0;
        for (int j = 0; j <= k; ++j) {
            add(part_sum, dif[j]);
            add(dp[j], part_sum);
        }
    }
    printf("%d\n", dp[k]);
}

int main() {
    while (~scanf("%d%d", &n, &k)) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 896
fun main(args: Array<String>) {
    readLine()
    val bl = readLine()!!.split(" ").map { it.toInt() }
    val al = mutableListOf( bl[0] )
    for (n in bl.withIndex()) {
        val m = bl.getOrNull(n.index + 1) ?: n.value
        val min = if (n.value <= m) n.value else m
        al.add(min)
    }
    print(al.sum())
}
// a1     a2 a3  a4 a5 a6
// 100000 0  153 10 10 23 23
// 0      0  10  10 10 23

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

const int N_MAX = 1010;
#define P pair<ll, ll>
struct edge { ll to; ll cost; };
vector<edge> adj[N_MAX];
ll d[N_MAX], par[N_MAX];
ll N, M;

vector<ll> dijkstra(ll s) {
  priority_queue<P, vector<P>, greater<P>> q;
  fill_n(d, N, LLINF); d[s] = 0; q.push(P(0, s));
  fill_n(par, N, LLINF); par[s] = -1;
  while (!q.empty()) {
    P p = q.top(); q.pop();
    ll v = p.second;
    for (auto e: adj[v]) {
      if (e.to==s) {
        ll now = v;
        vector<ll> result = {now};
        while(par[now]!=-1) {
          result.push_back(par[now]);
          now = par[now];
        }
        return result;
      }
      if (d[e.to] > d[v]+e.cost) {
        d[e.to] = d[v]+e.cost;
        par[e.to] = v;
        q.push(P(d[e.to], e.to));
      }
    }
  }
  return {};
}

int main() {
  cin >> N >> M;
  rep(i,M) {
    int A, B; cin >> A >> B; A--; B--;
    adj[A].push_back({B,1});
  }

  vector<ll> result(N+1);
  rep(i,N) {
    vector<ll> tmp = dijkstra(i);
    if (!tmp.empty()&&tmp.size()<result.size()) {
      result.resize(tmp.size());
      copy(tmp.begin(),tmp.end(),result.begin());
    }
    // rep(i,N) cout << d[i] << " "; cout << endl;
    // rep(i,N) cout << par[i] << " "; cout << endl;
    // cout << endl;
  }
  if (result.size()!=N+1) {
    reverse(result.begin(), result.end());
    cout << result.size() << endl;
    for (auto x: result) cout << x+1 << endl;
    return 0;
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 384
L,R = map(int,input().split())


if R // 2019 != L // 2019:
    ans = 0

else:

    ans = float("inf")
    mini = L % 2019
    maxi = R % 2019

    for I in range(maxi - mini + 1):
        i = L+I

        for J in range(I):

            j = L + J

            ans = min (ans, (i*j) % 2019)

print (ans)


Measured memory_bytes: 41836
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int n, m;
	int sum = 0;
	int ans = 0;
	cin >> n >> m;
	Vi a(n);
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	rep(i, n) {
		if (a[i] >= ((double)sum / (4 * m))) {
			ans++;
		}
	}
	cout << solve(ans >= m) << endl;
}

Measured memory_bytes: 3612
n=int(input())
a=[[[0]*10 for i in range(3)] for j in range(4)]
for i in range(n):
    b,f,r,v=map(int,input().split())
    a[b-1][f-1][r-1]+=v
for i in range(4):
    for j in range(3):
        for e in range(10):
            print(' '+str(a[i][j][e]),end='')
        print()
    if i!=3:
        print('#'*20)


Measured memory_bytes: 5620
# -*- coding: utf-8 -*-

n, m = map(int, input().split())

if n % 2 == 0:
    count = 1
    while(count<=m):
        if count <= n // 4:
            print(str(count) + ' ' + str(n-count+1))
        else:
            c = count - n // 4
            print(str(int(n/2-c+1)) + ' ' + str(int(n/2+1+c)))
        count += 1
else:
    for i in range(m):
        print(str(i+1) + ' ' + str(n-i))

Measured memory_bytes: 9224
import sys

def Forbidden_List(x,n,p):
  for i in range(n//2 + n%2 + 1):
    if x - i not in p: 
        return x - i
    if x + i not in p:
        return x + i

if __name__ == '__main__':
    input = sys.stdin.readline
    
    inp1 = input().rstrip().split()
    x,n = int(inp1[0]),int(inp1[1])
    if n == 0:
        print(x)
    else: 
        inp2 = input().rstrip().split()
        p = list(map(int,inp2))
        print(Forbidden_List(x,n,p))

Measured memory_bytes: 9196
#include <stdio.h>

int main()
{
  long int N;
  scanf("%ld", &N);
  long int D1[N], D2[N];
  long int j;
  for(j=0;j<N;j++){
    scanf("%ld", &D1[j]);
    scanf("%ld", &D2[j]);
  }

  long int i;
  int ans = 0;

  for(i=0;i<N;i++){
    if(D1[i]==D2[i] && D1[i+1]==D2[i+1] && D1[i+2]==D2[i+2] && D1[i]<=6 && D1[i+1]<=6 && D1[i+2]<=6 && 1<=D1[i] && 1<=D1[i+1] &&1<=D1[i+1]){
      ans = 1;
    }
  }

  if(ans==1){
    puts("Yes");
  }else{
    puts("No");
  }

    return 0;
}


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

int main () {
    int X[2];
    int ans = 0;
    for (int i=0; i < 3; i++) cin >> X[i];
    sort(X, X+3);
    int mxn = X[2]-X[0];
    int mxm = X[2]-X[1];
    if (mxn%2 == mxm%2) ans = (mxn+mxm)/2;
    else ans = (mxn+mxm)/2+2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  cin >> n;
  vi d(n);
  rep(i, n) cin >> d[i];
  sort(all(d));
  int ans = 0;
  rep(i, 1e5 + 1) {
    auto in = lower_bound(all(d), i) - d.begin();
    if(in == n / 2) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
struct mint
{
    ll x;
    mint(ll x = 0) : x(x % mod) {}
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

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

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} comb(100005);

mint f(int n, int k)
{
    if (n < 0)
        return 0;
    // nPk = nCk * k!
    mint res = comb(n, k);
    res *= comb.fact[k];
    return res;
}

int k;
mint ans;
vector<int> to[100005];
void dfs(int v, int p = -1)
{
    for (int u : to[v])
    {
        if (u == p)
            continue;
        dfs(u, v);
    }
    int nk = (p == -1) ? k : k - 2;
    int c = (p == -1) ? to[v].size() + 1 : to[v].size() - 1;
    ans *= f(nk, c);
}

int main()
{
    int n;
    cin >> n >> k;
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans = 1;
    dfs(0);
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 10752
import collections

n,m=map(int,input().split())
g=[[] for _ in range(n+1)]
cnt=[0]*(n+1)
for _ in range((n-1)+m):
  a,b=map(int,input().split())
  g[a].append(b)
  cnt[b]+=1
root=0
for i in range(1,n+1):
  if cnt[i]==0:
    root=i
    break
ans=[0]*(n+1)
q=collections.deque()
q.append(root)
while len(q)!=0:
  v=q.popleft()
  for u in g[v]:
    if cnt[u]==1:
      ans[u]=v
      q.append(u)
    else:
      cnt[u]-=1
for i in range(1,n+1):
  print(ans[i])

Measured memory_bytes: 20760