akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll Q,t=0,B=0,me=0,suma=0,sumi=0;
  cin >> Q;
  multiset<ll> ma,mi;
  rep(i,Q){
    ll x,a,b;
    cin >> x;
    if(x==1){
      cin >> a >> b;
      B+=b;
      if(t==0){
        me=a;
        t++;
      }else if(t%2==0){
        if(*begin(ma)<=a){
          me=*begin(ma);
          suma-=me;
          ma.erase(ma.begin());
          ma.insert(a);
          suma+=a;
          t++;
        }else if(*rbegin(mi)<a){
          me=a;
          t++;
        }else{
          me=*rbegin(mi);
          sumi-=me;
          mi.erase(mi.lower_bound(me));
          mi.insert(a);
          sumi+=a;
          t++;
        }
      }else{
        if(me<=a){
          mi.insert(me);
          ma.insert(a);
          sumi+=me;
          suma+=a;
          t++;
        }else{
          mi.insert(a);
          ma.insert(me);
          suma+=me;
          sumi+=a;
          t++;
        }
      }
    }else{
      ll x,f;
      f=B;
      if(t%2==0){
        x=*rbegin(mi);
        f+=suma;
        f-=sumi;
        cout << x << " " << f << endl;
      }else{
        x=me;
        f+=suma;
        f-=sumi;
        cout << x << " " << f << endl;
      }
    }
  }
}

Measured memory_bytes: 12900
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=1000005;
#define M 1000000007
#define double long double
#define BINF 100000001
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
const int LG = 22;


#undef int 
int main() { 
#define int long long int 
 
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0); 


	int l,r,c,d;
	cin >> l >> r >> c >> d;
	int lcm = (c * d) / __gcd(c,d);

	int count = 0;
	count = r / c - (l - 1) / c + r / d - (l - 1) / d - r / lcm + (l - 1) / lcm;
	cout << (r - l + 1 ) - count << endl;



return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll arr[1010], n, m;

int main() {
	cin>>n>>m;

	ll sum = 0LL;
	for(int i=1;i<=n;i++) {
		cin>>arr[i];
		sum += arr[i];
	}

	ll minvotes = (sum+4*m-1)/ (4*m);

	int br = 0;
	for(int i=1;i<=n;i++) {
		if(arr[i] >= minvotes) br++;
	}

	if(br >= m) cout<<"Yes\n";
	else cout<<"No\n";
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

ll N, M;

ll calc(ll num) {
    ll ret = 1;
    REP(i, num) {
        ret *= 2;
    }
    return ret;
}

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

    double fail = 1.0 / static_cast<double>(calc(M));
    double succ = 1.0 - fail;
    double s1 = 1.0;
    double ans = 0;
    ll base = (N - M) * 100 + M * 1900;
    ll b1 = base;

    while(s1 * fail > 0.0) {
        ans += static_cast<double>(b1) * (s1 * fail);
        DBG("%lld %lld %lld\n", static_cast<ll>(ans));
        b1 += base;
        s1 *= succ;
    }

    printf("%lld\n", static_cast<ll>(round(ans)));

    return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(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 ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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()
{
    int N=0;
    cin >> N;
    int A[N]; 
    rep(i,N) cin >> A[i];
    long double a1[N];
    long double a2 = 0;
    rep(i,N){
        a1[i] = 1./A[i];
        a2 += a1[i];
    }
    long double ans = 1./a2;

    std::cout << std::setprecision(8) << ans << endl;
}

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

typedef struct {int id, solved, penalty;} Team;

int compare(const void *a, const void *b) {
	const Team ta = *(Team *)a, tb = *(Team *)b;

	if (ta.solved != tb.solved)
		return tb.solved - ta.solved;
	if (ta.penalty != tb.penalty)
		return ta.penalty - tb.penalty;
	return ta.id - tb.id;
}

int main(void) {
	int i;
	int t, p, r;

	while (scanf("%d %d %d", &t, &p, &r), t) {
		Team team[50] = {0};
		int wrong[50][10] = {0};

		for (i = 0; i < t; i++)
			team[i].id = i + 1;

		for (i = 0; i < r; i++) {
			int tid, pid, t;
			char mes[10];

			scanf("%d %d %d %s", &tid, &pid, &t, mes);
			tid--;
			pid--;

			if (mes[0] == 'C') {
				team[tid].solved++;
				team[tid].penalty += wrong[tid][pid] * 1200 + t;
			} else
				wrong[tid][pid]++;
		}

		qsort(team, t, sizeof(Team), &compare);

		for (i = 0; i < t; i++)
			printf("%d %d %d\n", team[i].id, team[i].solved, team[i].penalty);
	}

	return 0;
}

Measured memory_bytes: 1044
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


# 整数(x, y)最大公約数を求める
def gcd(x, y):
    if x % y == 0:
        return y
    else:
        x, y = y, x % y
        return gcd(x, y)


n = II()
A = LI()

ans = A[0]
for a in A:
    ans = gcd(ans, a)

print(ans)


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

int idx(char c) {
    int idx;
    switch (c) {
        case 'R':
            idx = 0;
            break;
        case 'G':
            idx = 1;
            break;
        default:
            idx = 2;
            break;
    }
    return idx;
}

int main(void) {
    long long N;
    cin >> N;
    string S;
    cin >> S;
    if (N < 3) {
        printf("0\n");
        return 0;
    }
    long long rgb[4010][3];
    for (int i = 0; i < 3; i++) {
        rgb[N][i] = 0;
    }
    for (int i = N - 1; i >= 0; i--) {
        for (int j = 0; j < 3; j++) {
            rgb[i][j] = rgb[i + 1][j];
        }

        ++rgb[i][idx(S[i])];
    }
    long long same = 0;
    for (long long l = 3; l <= N; l += 2) {
        same += (N - l + 1);
    }
    long long sameS = 0, sameSsame = 0;

    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            if (S[i] != S[j]) {
                sameS += rgb[j + 1][idx(S[j])];
                sameS += rgb[j + 1][idx(S[i])];
            } else {
                sameS += N - 1 - j;
            }
        }
    }
    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j + (j - i) < N; j++) {
            int k = j + (j - i);
            if (S[i] == S[j] || S[j] == S[k] || S[k] == S[i]) {
                ++sameSsame;
            }
        }
    }

    long long ans = N * (N - 1) * (N - 2) / 6;
    ans = ans - same - sameS + sameSsame;

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  int x = 0, res = 0;
  while (n--) {
    char c; cin >> c;
    if (c == 'I') {
      ++x;
    } else {
      --x;
    }
    res = max(res, x);
  }
  cout << res << '\n';
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N,ans=0;

int main(){
    cin>>N;
    ans+=N/25;
    N%=25;
    ans+=N/10;
    N%=10;
    ans+=N/5;
    N%=5;
    ans+=N;
    out(ans);
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;


// with respect to @drken1215

const int MAX = 510000;
ll 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;
    }
}

// 二項係数計算
ll 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;
}

ll mx[100010];
ll mn[100010];

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> a;
    rep(i, n) {
        ll tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    COMinit();
    sort(a.begin(), a.end());

    rep(i, n){
        mx[i] = COM(i, k-1);
        mn[i] = COM(n-i-1, k-1);
    }

    ll ans = 0;
    rep(i, n){
        // cout << mx[i] << " " << mn[i] << endl;
        ans += (mx[i] - mn[i]) * a[i] % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}

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

int main() {
	// your code goes here
	int n,i,max=0,memo=0;
	long long h[100005];
	cin >> n;
	for(i=1;i<=n;i++){
		cin >> h[i];
		if(i>1){
			if(h[i-1]>=h[i]) memo++;
			else memo=0;
			if(memo>max) max=memo;
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 1024
(defun split (string &key (delimiterp #'(lambda (c) (char= c #\Space))))
  (loop :for beg = (position-if-not delimiterp string)
        :then (position-if-not delimiterp string :start (1+ end))
        :for end = (and beg (position-if delimiterp string :start beg))
        :when beg :collect (subseq string beg end)
        :while end))

(defun main ()
  (destructuring-bind (n m) (mapcar #'parse-integer (split (read-line)))
    (let ((ps (loop for i from 0 below m
                     collect (split (read-line))))
          (ac (make-array (+ n 1) :initial-element 0))
          (wan (make-array (+ n 1) :initial-element 0)))
      (loop for pair in ps
            for p = (parse-integer (car pair))
            for s = (cadr pair)
            do (progn
                 (when (and (string= s "WA") (zerop (aref ac p)))
                   (incf (aref wan p)))
                 (when (string= s "AC")
                   (setf (aref ac p) 1))))
      (format t "~d ~d~%"
              (loop for a across ac summing a)
              (loop for i from 1 to n
                    summing (if (zerop (aref ac i))
                                0
                                (aref wan i)))))))

(main)


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

int main()
{
  int a, k, b;
  cin >> k>> a >> b;
  for (;a <= b; a++){
    if (a % k == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}


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

count = 0
flag = 0
for i in range(N):
    D = list(map(int, input().split()))
    if D[0] == D[1]:
        count += 1
    else:
        count = 0
    if count == 3:
        flag = 1

if flag == 0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 9168
n = int(input())
waru = 10**9+7
#nmod = n%(waru)
nmod = pow(10,n,waru)
#print(nmod)
#n1mod = int((n-1)%waru)
n1mod = pow(9,n,waru)*2
#print(n1mod)
#nnmod = int((9**(n-2))%waru)
nnmod = pow(8,n,waru)
#print(nnmod)
ans = (nmod-n1mod+nnmod) % waru
print(ans)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
int dp[513][100001],v[(1<<18)+1],w[(1<<18)+1],n,a,b,q;
int f(int x,int y){
    if(y<0)return -1e9;
    if(x==0)return 0;
    if(x<513){
        if(dp[x][y]!=-1)return dp[x][y];
        return dp[x][y]=max({f(x,y-1),f(x/2,y-w[x])+v[x],f(x/2,y)});
    }
    return max(f(x/2,y-w[x])+v[x],f(x/2,y));
}
int main(void){
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++)cin>>v[i+1]>>w[i+1];
    cin>>q;
    while(q--){
        cin>>a>>b;
        cout<<f(a,b)<<endl;
    }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1e18;

int main() {
  ll n, mn = INF, mx = -INF, ans = INF;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i], mn = min(a[i], mn), mx = max(mx, a[i]);

  for (int i = mn; i <= mx; ++i) {
    ll tans = 0;
    rep(j, n) tans += abs(i - a[j]) * abs(i - a[j]);
    ans = min(tans, ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N,K = map(int, input().split())
A = [int(x)-1 for x in map(int, input().split())]
flag = [False]*N
l = []
place = 0
while True:
    if K==0:
        print(place+1)
        exit()
    l.append(place)
    flag[place]=True
    place = A[place]
    K -= 1
    if flag[place]:
        ind = l.index(place)
        count = len(l) - ind
        print(l[ind + K%count]+1)
        exit()

Measured memory_bytes: 94792
N = int(input())
A = list(map(int, input().split()))

if 0 in A:
    print(0)
    exit()

count = 1
for i in A:
    count *= i
    if 10 ** 18 < count:
        break

if 10 ** 18 < count:
    count = -1

print(count)


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

void call(int n);

int main() {
    int m;
    cin >> m;
    call(m);
    cout << endl;
}

void call(int n){
    bool o;
    int x;
    for(int i=1;i<=n;i++){
        o=0;
        if((i%3==0)or(i%10==3)){
            o=1;
        }
        x=i/10;
        while(x>0){
            if (x%10==3)
                o=1;
            x/=10;
        }
        if (o) 
            cout << ' ' << i ;
    }
}


Measured memory_bytes: 3096
n,m = map(int,input().split())
a = [int(input().replace(" ",""),2) for i in range(n)]
mod = 998244353
cnt = 0
for j in range(m)[::-1]:
  for i in range(cnt,n):
    if a[i] & 1<<j:
      for k in range(n):
        if (i != k) and (a[k] & 1<<j):
          a[k] ^= a[i]
      a[i],a[cnt] = a[cnt],a[i]
      cnt += 1
if cnt == 0:
  print(0)
else:
  ans = pow(2,n+m-2*cnt,mod)*pow(2,cnt-1,mod)*(pow(2,cnt,mod)-1)%mod
  print(ans)

Measured memory_bytes: 42588
#include <bits/stdc++.h>
#define maxi 300005
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define ll long long
#define si(n) scanf("%d",&n)
#define sll(n) scanf("%lld",&n)
#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif
#define gc getchar
#define REP(i,j,n)               for( i=j;i<n;i++)
#define PER(i,j,n)               for( i=n-1;i>=j;i--)
ll mpow(ll a, ll n,ll mod){
	ll ret=1;ll b=a;
	while(n) {
		if(n&1)
			ret=(ret*b)%mod;
		b=(b*b)%mod;
		n>>=1;
	}
	return (ll)ret;
}
inline void read(int &x){
	x=0;
	register char c=gc();
	for(;c<'0' || c>'9';c=gc());
	for(;c>='0' && c<='9';c=gc())
		x=(x<<3)+(x<<1)+(c-'0');
}
inline void write(int x){
	register char buffor[35];
	register int i=0;
	do{
		buffor[i++]=(x%10)+'0';
		x/=10;
	} while(x);
	i--;
	while(i>=0) putchar(buffor[i--]);
	putchar('\n');
}
inline int in() { int x; read(x); return x; }
void solve();
int dbg=1;
using namespace std;
int main(){
	int t=1;
	//read(t);
	for(int i=0;i<t;i++){
		//printf("Case #%d:\n",i);
		solve();
	}
	return 0;
}
void solve() {
	ll n,k,q,i,j,a[100005],c[100005]={0};
	cin>>n>>k>>q;
	REP(i,0,q){
		cin>>a[i];
		c[a[i]]++;
	}
	REP(i,1,n+1)
		if(q-c[i]>=k)
			cout<<"No\n";
		else
			cout<<"Yes\n";
}



Measured memory_bytes: 2176
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, k = na()

ans = 0
for b in range(k + 1, n + 1):
    p = n // b
    r = n % b
    ans += p * (b - k) + max(0, r - k + 1)
    if k == 0:
        ans -= 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	string s;
	cin>>s;

	lli data[2];
	data[0]=0,data[1]=0;

	REP(i,0,s.size()){
		data[s.at(i)-'0']++;
	}

	cout<<min(data[0],data[1])*2<<endl;
 
	return 0;
}

Measured memory_bytes: 512
S = input()
T = input()
#dp[i][j]をs,tをそれぞれ右からi,j番目まで見た時の最大の部分列の長さとする。
lenS = len(S)
lenT = len(T) 
memo = []
dp = [[0]*(lenS+1) for _ in range(lenT+1)]
for i in range(1,lenT+1):
    for j in range(1,lenS+1):
        if S[j-1] == T[i-1]:
            dp[i][j] = max(dp[i-1][j-1]+1,dp[i][j-1],dp[i-1][j])
        else:
            dp[i][j] = max(dp[i][j-1],dp[i-1][j])
 
#dpから最澄列を復元する。
ans = ""
s = lenS
t = lenT
while s>0 and t>0:
    if S[s-1] == T[t-1]:
        ans += S[s-1]
        s -= 1
        t -= 1
    else:
        if dp[t][s-1] > dp[t-1][s]:
            s -= 1
        else:
            t -= 1
print(ans[::-1])

Measured memory_bytes: 112604
#include "bits/stdc++.h"
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define mp make_pair
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) for(ll i=0;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()
using namespace std;
ll mod=1000000007;


int main(){
    ll n,k,ans=0;
    cin>>k>>n;
    for(;;){
        k-=n;
        ans++;
        if(k<=0)break;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut a: Vec<(usize, usize)> = vec(n, |i| (scan(tokens), i + 1));
    a.sort();
    for i in 0..n {
        if i > 0 {
            print!(" ");
        }
        print!("{}", a[i].1);
    }
    println!("");
}


Measured memory_bytes: 8956
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
#define pi 3.1415926

using namespace std;
struct point
{
	double x, y;
};
int n;
double th = pi * 60 / 180;

void koch(int n, point a, point b)
{
	if (n == 0) return;
	point s, t, u;
	s.x = (b.x + 2 * a.x) / 3;
	s.y = (b.y + 2 * a.y) / 3;
	t.x = (2 * b.x + a.x) / 3;
	t.y = (2 * b.y + a.y) / 3;
	u.x = (t.x - s.x)*cos(th) - (t.y - s.y)*sin(th)+s.x;
	u.y = (t.x - s.x)*sin(th) + (t.y - s.y)*cos(th)+s.y;
	//printf("n=%d, (%.2f %.2f) (%.2f %.2f) (%.2f %.2f) (%.2f %.2f) (%.2f %.2f)\n",n, a.x, a.y, s.x, s.y, u.x, u.y, t.x, t.y, b.x, b.y);
	koch(n - 1, a, s);
	printf("%.8f %.8f\n", s.x, s.y);
	koch(n - 1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	koch(n - 1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	koch(n - 1, t, b);
	
	

}

int main()
{
	cin >> n;
	point a,b;
	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;
	printf("%.8f %.8f\n", a.x, a.y);

	koch(n, a, b);
	printf("%.8f %.8f\n", b.x, b.y);
	return 0;
}


Measured memory_bytes: 3376
import java.util.Scanner;
import java.util.Stack;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		int N = sc.nextInt();
		int height[] = new int[N + 1];
		int ans = 0;
		for (int i = 0; i < N; i++) {
			height[i] = sc.nextInt();
		}
		Stack<Rect> stack = new Stack<Rect>();
		height[N] = 0;
		for (int i = 0; i <= N; i++) {
			Rect rect = new Rect(height[i], i);
			if (stack.isEmpty() || stack.peek().height < height[i]) {
				stack.push(rect);
			} else if (stack.peek().height > height[i]) {
				while (!stack.isEmpty() && stack.peek().height > height[i]) {
					stack.pop();
					ans++;
				}
				if (stack.isEmpty() || stack.peek().height != rect.height) {
					stack.push(rect);
				}
			}
		}
		System.out.println(ans);
	}

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

	class Rect {
		long height;
		int pos;

		Rect(long height, int pos) {
			this.height = height;
			this.pos = pos;
		}
	}
}

Measured memory_bytes: 96980
N=int(input())
h=list(map(int,input().split()))
dp=[0]*N
for i in range(1,N):
  if i==1:
    dp[i]=abs(h[i]-h[i-1])
  else:
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[N-1])

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

vector <ll> a;
vector <ll> b;

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

    ll i,j,k,l,m,n;

    cin >> n;

    for(i=0;i<n;i++)
    {
        cin >> k >> l;
        a.push_back(k);
        b.push_back(l);
    }

    bool doublet = false;

    for(i=0;i+2<n;i++)
    {
        if(a[i] == b[i] && a[i+1] == b[i+1] && a[i+2] == b[i+2])
            doublet = true;
    }

    if(doublet == true)
        cout << "Yes\n";
    else
        cout << "No\n";




}

Measured memory_bytes: 3656
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main() {

	ll h, w, n;
	ll c = 1;
	ll ans[10] = { 0 };
	cin >> h >> w >> n;
	vector<pair<int, int>> p;
	pair<int, int> t;

	rep(i, n) {
		int x, y; cin >> y >> x;
		for (int i = 0; i <= 2; i++) {
			for (int j = 0; j <= 2; j++) {
				if (x - i >= 1 && y - j >= 1&&x-i+2<=w&&y-j+2<=h) {
					t.first = x - i; t.second = y - j;
					p.push_back(t);
				}
			}
		}
	}

	sort(all(p));

	rep(i, p.size()) {
		if (i > 0) {
			if (p[i] == p[i - 1]) {
				c++;
			}
			else {
				ans[c]++;
				c = 1;
			}
		}
		if (i == p.size() - 1)ans[c]++;
	}


	ll sum = 0;
	for (int i = 1; i <= 9; i++) {
		sum += ans[i];
	}

	cout << (h - 2)*(w - 2) - sum << endl;

	for (int i = 1; i <= 9; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 10348
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	ans := make([]int, 0, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		if len(ans) == 0 || a <= ans[len(ans)-1] {
			ans = append(ans, a)
			continue
		}
		p := sort.Search(len(ans), func(i int) bool { return ans[i] < a })
		ans[p] = a
	}
	fmt.Println(len(ans))
}


Measured memory_bytes: 4272
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 28;
int a[maxn], gc[maxn], gc1[maxn];
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(i == 0)
			gc[1] = a[i];
		else if (i != 1)
			gc[i] = __gcd(gc[i - 1], a[i - 1]);
	}
	for(int i = n - 1; i >= 0; i--){
		if(i == n - 1)
			gc1[n - 2] = a[n - 1];
		else
			gc1[i] = __gcd(gc1[i + 1], a[i + 1]); 
	}
	int maxi = 0;
	for(int i = 1; i < n - 1; i++)
		maxi = max(__gcd(gc[i], gc1[i]), maxi);
	maxi = max(maxi, gc1[0]);
	maxi = max(maxi, gc[n - 1]);
	cout << maxi;
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_A
 * 
 * @author eitatsuro
 * 
 */
public class Main {
    static final String HASHMARK = "#";
    static final String DOTMARK  = ".";
    
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            while ((sStr = stdReader.readLine()) != null) {
                String[] inputs = sStr.split(" ");
                
                int h = Integer.valueOf(inputs[0]);
                int w = Integer.valueOf(inputs[1]);
                
                if (h == 0 && w == 0) {
                    break;
                    // nothing to do.
                }
                
                for (int i = 0; i < h; i++) {
                    for (int j = 0; j < w; j++) {
                        if (i < h - 1 && j < w - 1 && 0 <i && 0 < j) {
                            System.out.print(DOTMARK);
                        } else {
                            System.out.print(HASHMARK);
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            }
            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
    }
}

Measured memory_bytes: 35356
#include<stdio.h>

int main(){
 int i,j,H,W,I;
 scanf("%d %d",&H,&W);
 while(H*H+W*W){
  for(i=1;i<=H;i++){
   for(j=1;j<=W;j++){
    I=i+j;
    if(I%2){
     printf(".");}
    else{
     printf("#");}}
   printf("\n");}
  printf("\n");
  scanf("%d %d",&H,&W);}
 return 0;}

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

const int INF = pow(2, 31) - 1;
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)

int main() {
  int N;
  int T, A;
  cin >> N;
  cin >> T >> A;
  vector<int> H(N);
  REP(i, N) {
    cin >> H[i];
  }
  double ans = (double)INF;
  REP(i, N) {
    double tmp = T - H[i] * 0.006;
    if(ans > abs(A - tmp)) {
      ans = abs(A - tmp);
    }
  }
  REP(i, N) {
    double tmp = T - H[i] * 0.006;
    if(ans == abs(A - tmp)) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0;
}


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

int a[2000];
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = 0; j < i; j++)
      ans += (a[j] > a[i])*k;
  }
  ll mod = ll(1e9+7);
  ll mul = (k*(k-1)/2) % mod;
  for (int i = 0; i < n; i++) {
    ll bigger = 0;
    for (int j = 0; j < n; j++)
      bigger += (a[j] > a[i]);
    (ans += mul*bigger) %= mod;
  }
  cout << ans%mod << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    while(true){
    int N,M,pos=1,count=0;
    cin >> N >> M;
        if(N==0) break;
    int sugoroku[N],dice[M];
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        sugoroku[i] = a;
    }
    for (int j=0;j<M;j++){
        int b;
        cin >> b;
        dice[j] = b;
    }
    while(true){
        if(pos>=N) break;
        pos = pos + dice[count];
        pos = pos + sugoroku[pos-1];
        count++;
    }
    cout << count << endl;
    }
}

Measured memory_bytes: 1164
#include <stdio.h>

int main(void);

int main(){
  unsigned char s[3] = {};
  unsigned int tmp;
  
  scanf("%c%c%c", &s[0], &s[1], &s[2]);
  tmp = (unsigned int)((s[0]-'0') + (s[1]-'0') + (s[2]-'0'));
  printf("%d\n", tmp);
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,key;
  int A[N+1];
  scanf("%d", &n);

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

  for(i = 1; i <= n; i++){
    key = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
    }
  A[j+1] = key;
  trace(A, n);
  }
  return 0;
}

Measured memory_bytes: 608
import java.util.*;

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

class Solver {

    private void mark(int[][] card, int v) {
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (card[i][j] == v) {
                    card[i][j] = 0;
                }
            }
        }
    }

    private void check(boolean bingo) {
        if (bingo) {
            System.out.println("Yes");
            System.exit(0);
        }
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        int[][] card = new int[3][3];

        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                card[i][j] = sc.nextInt();
            }
        }

        int N = sc.nextInt();
        int[] b = new int[N];
        for (int i = 0; i < N; i++) {
            b[i] = sc.nextInt();
            mark(card, b[i]);
        }

        //for (int i = 0; i < 3; i++) {
        //    for (int j = 0; j < 3; j++) {
        //        System.out.print(card[i][j] + " ");
        //    }
        //    System.out.println();
        //}

        // horizontal check
        boolean bingo = true;
        for (int i = 0; i < 3; i++) {
            bingo = true;
            for (int j = 0; j < 3; j++) {
                if (card[i][j] != 0) {
                    bingo = false;
                }
            }
            check(bingo);
        }

        // vertical check
        for (int j = 0; j < 3; j++) {
            bingo = true;
            for (int i = 0; i < 3; i++) {
                if (card[i][j] != 0) {
                    bingo = false;
                }
            }
            check(bingo);
            //System.out.println(String.format("checking: false col[%d]", j));
        }

        bingo = true;
        for (int i = 0; i < 3; i++) {
            if (card[i][i] != 0) {
                bingo = false;
            }
        }
        check(bingo);

        bingo = true;
        for (int i = 0; i < 3; i++) {
            if (card[i][2 - i] != 0) {
                bingo = false;
            }
        }
        check(bingo);

        System.out.println("No");

        return;
    }

}


Measured memory_bytes: 23764
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int[] NMC = new int[3];
        int cont = 0;
        for (String s:str.split(" ")){
            NMC[cont] = Integer.parseInt(s);
            cont++;
        }
        str = br.readLine();
        int[] B =new int[NMC[1]];
        cont = 0;
        for (String s:str.split(" ")){
            B[cont] = Integer.parseInt(s);
            cont++;
        }
        int res;
        int ans = 0;
        for (int i=0;i<NMC[0];i++){
            str = br.readLine();
            res = 0;
            cont = 0;
            for (String s:str.split(" ")){
                res += Integer.parseInt(s) * B[cont];
                cont++;
            }
            res += NMC[2];
            if (res>0){
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	cin>>a;
	bool flag = true;
	for(int i = 0; i < a.length(); i++){
		if(a[i] == 'h' && a[i + 1] == 'i') {
			i += 1;
		}else flag = false;
	}
	if(flag) cout<<"Yes";
	else cout<<"No";
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 1000000007
#define tc(t) 			int t;cin >> t;while(t--)
#define for0(i , n)		for(int i=0;i<n;i++)
#define loop(i , a, b)	for(int i=a;i<=b;i++)
#define endl '\n'

char mat[1001][1001];
int h,w;
int dp[1001][1001];

int totalPath(int i,int j){
	if(i==h && j==w){
		return 1;
	}

	if(i > h || j > w) return 0;

	if(dp[i][j] != -1) return dp[i][j];

	if(mat[i][j] == '#'){
		return 0;
	}

	return dp[i][j]=(totalPath(i,j+1) + totalPath(i+1,j))%mod;
}

signed main() {

	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

	cin >> h >> w;

	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin >> mat[i][j];
		}
	}

	memset(dp,-1,sizeof(dp));

	cout << totalPath(1,1);

	return 0;
}

Measured memory_bytes: 12560
n, a, b = (int(s) for s in input().strip().split(' '))
s = input()
passed = 0
b_passed = 0
for c in range(0,len(s)):
    if s[c] == "a" and passed < a+b:
        passed += 1
        print("Yes")
    elif s[c] == "b" and passed < a+b and b_passed < b:
        passed+=1
        b_passed+=1
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4040
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main(){
  int x, n;
  cin >> x >> n;
  vector<int> p(102);
  rep(i,n){
    int a;
    cin >> a;
    p[a] = 1;
  }
  int dist = 10000;
  int ans = -1;
  rep(i,102){
    if(p[i] == 1) continue;
    int t = abs(x - i);
    if(t < dist){
      ans = i;
      dist = t;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = std::vector<int>;
using ll = long long;
using vll = std::vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = std::min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = std::max(a, b); }
#define output(x) cout << x << endl;
typedef pair<int, int> P;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main()  {
    int A, B;
    cin >> A >> B;
    bool flag = false;
    FOR(i, 1, 3) {
        if ((A * B * i % 2) != 0) flag = true;
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int a = std.nextInt();
        int b = std.nextInt();
        int c = std.nextInt();
        if (a + b + 1 >= c) {
            long ans = b + c;
            System.out.println(ans);
        } else {
            long ans = a + b + 1 + b;
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t { as swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;

int main() {
    int n, x;
    cin  >> n >> x;
    vector<int> m(n);
    forin(i, 0, n) {
        cin >> m[i];
    }
    sort(m.begin(), m.end());
    auto count = 0;
    forin(i, 0, n) {
        if (x < m[i]) break;
        x -= m[i];
        count++;
    }
    while (x >= m[0]) {
        x -= m[0];
        count++;
    }
    cout << count << endl;
    
}



Measured memory_bytes: 256
import numpy as np
import math
from math import factorial

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

mod = 1000000000 + 7

fact_table = dict()

def dupcomb(n, k, p):
    return comb(n+k-1, k, p)

def comb(n,k,p):
    if n<0 or k<0 or n<k: return 0
    if n==0 or k==0: return 1

    if n in fact_table:
        a = fact_table[n]
    else:
        a=factorial(n) %p
        fact_table[n] = a

    if k in fact_table:
        b = fact_table[k]
    else:
        b=factorial(k) %p
        fact_table[k] = b
        
    if n-k in fact_table:
        c = fact_table[n-k]
    else:
        c=factorial(n-k) %p
        fact_table[n-k] = c
        
    return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p

def power_func(a,b,p):
    if b==0: return 1
    if b%2==0:
        d=power_func(a,b//2,p)
        return d*d %p
    if b%2==1:
        return (a*power_func(a,b-1,p ))%p


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

N, M = map(int, input().split())

primes = factorize(M)

count = 1

fk_save = dict()

for pair in primes:
    k = pair[1]
    # print('k=', k)

    if k in fk_save:
        fk = fk_save[k]
    else:
        fk = dupcomb(N, k, mod)
        fk_save[k] = fk
    # print('fk=', fk)

    count = (fk * count) % mod
    # print('count=', count)
    
print(count)
# ret = comb(10, 5, mod)
# print(ret)


Measured memory_bytes: 15060
# include <iostream>
using namespace std; 
int main(){
 string str; 
 int n, i, ans,count; 
 char p; 
 cin>>str;
 n=str.length();
 ans=0;
 count=0;
 p=str[0];
 for(i=0;i<n;i++){
   if(str[i]=='R'){
     if(p==str[i]){
       count++;
     }
     else{
       count=1;
     }
     ans=max(ans,count);
   }
   p=str[i];
 }
 cout<<ans; 
 return 0;
}

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

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second

typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

const int MOD = 1e9+7;

int main(){ _

	int n; cin >> n;
	vector<vector<int>> g(n);
	for(int i=0; i<n-1; i++) {
		int a, b; cin >> a >> b; a--, b--;

		g[a].push_back(b);
		g[b].push_back(a);
	}

	vector<vector<ll>> memo(2,vector<ll>(n,-1)); // 0 am black, 1 am white

	function<void(int)> dfs = [&] (int x) {
		memo[0][x] = memo[1][x] = 1;

		for(auto u : g[x]) if(memo[0][u] == -1) {
			dfs(u);
			memo[0][x] = memo[0][x] * memo[1][u] % MOD;
			memo[1][x] = memo[1][x] * ((memo[0][u] + memo[1][u]) % MOD) % MOD;
		}
	};

	dfs(0);

	cout << (memo[0][0] + memo[1][0]) % MOD << endl;

	return 0;
}


Measured memory_bytes: 18488
n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]

cnt = 0
ans = 0
for d1, d2 in d:
    if d1 == d2:
        cnt += 1
        if cnt >= 3:
            print('Yes')
            exit()
    else:
        cnt = 0

print('No')

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

#define rep(i, n) for (auto i = 0; i < (n); i++)
#define MOD 1e9 + 7
typedef long long ll;

using namespace std;

int main() {
  int n;
  cin >> n;
  int l[n];
  rep(i, n) {
    cin >> l[i];
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      for (int k = j+1; k < n; k++) {
        if (l[i] != l[j] && l[i] != l[k] && l[j] != l[k] &&
            (l[i] + l[j] > l[k]) && (l[i] + l[k] > l[j]) && (l[j] + l[k] > l[i])) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}



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

int ctoi(char& c) { return (int)c - 'a'; }

char itoc(int& i) {
  int a = 0x61;
  return (char)i + a;
}

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

  int buckets[26] = {};
  for (int i = 0; i < S.size(); i++) {
    buckets[ctoi(S.at(i))]++;
  }

  for (int i = 0; i < 26; i++) {
    if (buckets[i] == 0) {
      printf("%c", itoc(i));
      return 0;
    }
  }
  printf("None");
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int unsigned long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];



void solve() {
    int n , p;
    cin>>n>>p;
    int e = 0 , o = 0;
    for (int i = 0; i < n; ++i) {
        int v ;
        cin>>v;
        if(v % 2 == 0)
            e++;
        else o++;
    }
    int t1 = ((int)1 << e);
    int t2 = ((int)1 << o);
    if(p == 0){
        if(o != 0){
            cout<<t1 * t2 / 2 <<endl;
        }else {
            cout<<t1<<endl;
        }
    }else{
        if(o != 0){
            cout<<t1 * t2 / 2 <<endl;
        }else cout<<0<<endl;
    }
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    for(int i=0;i<2;i++)
        for(int j=i+1;j<=2;j++)
            if(a[i]>a[j])
                swap(a[i],a[j]);
    int ans=0;
    ans+=a[2]-a[1];
    a[0]+=ans;
    a[1]+=ans;
    if((a[2]-a[0])%2==0)
        ans+=(a[2]-a[0])/2;
    else
        ans+=(a[2]-a[0])/2+2;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
def encode(x):
    return chr(x + 97)


def solve(N):
    ans = []
    while True:
        N -= 1
        q, r = divmod(N, 26)
        ans.append(r)
        if q == 0:
            break
        N //= 26
    return "".join(map(encode, ans[::-1]))


print(solve(int(input())))


Measured memory_bytes: 9144
using System;

namespace Sorts
{
    class Program
    {
        public struct Card
        {
            public readonly char m;
            public readonly int n;
            public Card(char m, int n)
            {
                this.m = m;
                this.n = n;
            }
        }

        private static Card[] B_Sort(Card[] ca)
        {
            var c = new Card[ca.Length];
            Array.Copy(ca, 0, c, 0, c.Length);
            for (var i = 0; i < c.Length; i++)
                for (var j = c.Length - 1; j > i; j--)
                    if (c[j].n < c[j - 1].n)
                    {
                        var t = c[j];
                        c[j] = c[j - 1];
                        c[j - 1] = t;
                    }
            return c;
        }

        private static Card[] S_Sort(Card[] ca)
        {
            var c = new Card[ca.Length];
            Array.Copy(ca, 0, c, 0, c.Length);
            for (var i = 0; i < c.Length; i++)
            {
                var m = i;
                for (var j = i; j < c.Length; j++)
                {
                    if (c[m].n > c[j].n)
                        m = j;
                }
                var t = c[m];
                c[m] = c[i]; c[i] = t;
            }
            return c;
        }

        private static string Join(Card[] ca)
        {
            var s = string.Join(" ", Array.ConvertAll(ca, 
                    e => string.Format("{0}{1}", e.m, e.n)));
            return s;
        }

        public static void Main()
        {
            Console.ReadLine();
            var i = Console.ReadLine().Split();
            var cards = new Card[i.Length];
            for(int j = 0; j < i.Length; j++)
            {
                var m = i[j][0];
                var n = int.Parse(i[j].Remove(0, 1));
                cards[j] = new Card(m, n);
            }
            var b_cs = Join(B_Sort(cards));
            var s_cs = Join(S_Sort(cards));
            Console.WriteLine("{0}", b_cs);
            Console.WriteLine("Stable");
            Console.WriteLine("{0}", s_cs);
            Console.WriteLine("{0}table", b_cs == s_cs ? "S" : "Not s");
        }
    }
}

Measured memory_bytes: 9332
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    if N==1:
        print('Hello World')
    else:
        A=int(input())
        B=int(input())
        print(A+B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256