akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ri register int
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	// no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} 
using io :: gi;
using io :: putc;
using io :: print;
const int N=2e5+5,inf=2e9,S=N*20;
int n,p[N],rt[N],size,lc[S],rc[S],mx[S][2];
char ans[N];
inline int max(ri x,ri y){
	return x>y ? x:y;
}
int now0,now1;
inline void upd(int &x,ri l,ri r,ri p,ri k0,ri k1){
	ri y=++size;
	lc[y]=lc[x];
	rc[y]=rc[x];
	mx[y][0]=max(mx[x][0],k0);
	mx[y][1]=max(mx[x][1],k1);
	x=y;
	if(l==r) return;
	ri mid=l+r>>1;
	p<=mid?upd(lc[x],l,mid,p,k0,k1):upd(rc[x],mid+1,r,p,k0,k1);
}
inline void query(ri x,ri l,ri r,ri ql,ri qr){
	if(!x) return;
	if(ql<=l&&r<=qr){
		now0=max(now0,mx[x][0]);
		now1=max(now1,mx[x][1]);
		return;
	} 
	ri mid=l+r>>1;
	if(ql<=mid) query(lc[x],l,mid,ql,qr);
	if(qr> mid) query(rc[x],mid+1,r,ql,qr);
}
int tag[N],suf[N];
inline bool check1(ri i,ri hx,ri hy,ri cx,ri cy){
	hx=max(hx,p[i]);
	cx+=hx==p[i];
	ri L=cy+suf[i+1]-cx;
	if(L<0) return false;
	now0=0;now1=-inf;
	query(rt[i+1],1,n,hx,n);
	return (L&1?now1:now0)>=L;
}
inline bool check2(ri i,ri hx,ri hy,ri cx,ri cy){
	hx=max(hx,p[i]);
	cx+=hx==p[i];
	ri L=cx+suf[i+1]-cy;
	if(L<0) return false;
	now0=0;now1=-inf;
	query(rt[i+1],1,n,hy,n);
	return (L&1?now1:now0)>=L;
}
int main(){
	ri i,premax,cx,cy,hx,hy,k0,k1;
	gi(n);premax=0;
	for(i=1;i<=n;++i)
		gi(p[i]),
		premax=max(premax,p[i]),
		tag[i]=premax==p[i];
	for(i=n;i;--i) suf[i]=suf[i+1]+tag[i];
	mx[0][1]=-inf;
	for(i=n;i;--i){
		rt[i]=rt[i+1];
		now0=0;now1=-inf;
		query(rt[i],1,n,p[i],n);
		if(tag[i])
			k0=now0+2,
			k1=now1+2;
		else
			k0=now1+1,
			k1=now0+1;
		k0=max(k0,now0);
		k1=max(k1,now1);
		upd(rt[i],1,n,p[i],k0,k1);
	}
	hx=hy=cx=cy=0;
	for(i=1;i<=n;++i){
		if(check1(i,hx,hy,cx,cy)||check2(i,hx,hy,cx,cy)){
			ans[i]='0';
			hx=max(hx,p[i]);
			cx+=hx==p[i];
		}
		else{
			ans[i]='1';
			hy=max(hy,p[i]);
			cy+=hy==p[i];
		}
	}
	if(cx!=cy)
		puts("-1");
	else
		printf("%s",ans+1);
    return 0;
}

Measured memory_bytes: 70016
PROGRAM piyo
      IMPLICIT NONE
      INTEGER,PARAMETER :: prec = 16
      integer(prec) :: n,ans,i
      integer(prec),allocatable :: a(:)
      
      read*,n
      allocate( a(n) )
      read*,a(1:n)
      
      if( count(a==0)>=1 )then
        print*,0
        stop
      end if
      
      ans = a(1)
      do i = 2,n
        ans = ans * a(i)
        if( ans>10_prec**18_prec )then
          print*,'-1'
          stop
        end if
      end do
      
      print*,ans
      
      
      
      stop
      !debugg
      
      
      
      END PROGRAM

Measured memory_bytes: 4600
#include <stdio.h>
#include <algorithm>

int main() {
  int K, A, B; scanf("%d%d%d", &K, &A, &B); ++K;
  if(B - A <= 2 || K <= A) {
    printf("%d\n", K);
  } else {
    long long exch = (K - A) / 2;
    printf("%lld\n", K - exch * 2 + exch * (B - A));
  }
  return 0;
}


Measured memory_bytes: 128
n, y=map(int, input().split())
a=y//10000
b=y//5000
c=y//1000
y/=1000
for i in range(c+1):
    for j in range(n+1-i):
        k=n-i-j
        if 0<=k<=a and i + 5*j + 10*k == y:
            print(k, j, i)
            exit()

print(-1, -1, -1)

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0;i < n;i++){
    cin >> h.at(i);
  }
  
  sort(h.begin(), h.end());
  
  long long ans = 0;

  for (int i = 0;i < (n-k);i++){
    ans += h.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
ll n, w;
ll ans;
ll dp[100009];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n >> w;
    
    for(ll i = 0; i < n; ++i){
        ll x, y;
        cin >> x >> y;
        for(ll j = 1e5; j >= x; --j){
            dp[j] = max(dp[j-x] + y, dp[j]);
            //cout << i << " " << j << " " << dp[j] << "\n";
        }
    }
    cout << dp[min(w, (ll)1e5)] << "\n";
    
}


Measured memory_bytes: 1024
use std::io;

fn main() {

	let mut line = String::new();

	io::stdin().read_line(&mut line).expect("Failed to read line.");
	let _ : i64 = line.trim().parse().unwrap();

	line = "".to_string();
	io::stdin().read_line(&mut line).expect("Failed to read line.");
	let a : Vec<i64> = line.trim().split(" ").map(|val| val.parse().unwrap()).collect();

	let mut prev : i64 = a[0];
	let mut ans : i64 = 0;
	for a_ in a {
		let mut step = prev - a_;
		if 0 >= step {
			step = 0;
		}
		// println!("{}", step);
		ans += step;
		prev = a_ + step;
	}



	println!("{}", ans );
}


Measured memory_bytes: 5848
import math
n,x = map(int,input().split())
x_input = list(map(int,input().split()))

#各都市の移動距離を求め、そのgcd
x_input.append(x)
x_li = sorted(x_input)

cost_li = [0]*n
for i in range(n):
    cost_li[i] = x_li[i+1]-x_li[i]

g = cost_li.pop(0)
for c in cost_li:
    g = math.gcd(g,c)

print(g)

Measured memory_bytes: 20028
#include <iostream>

using namespace std;

int myMax(int l, int r){
	if(l<r)return r;
	else return l;
}

int myMin(int l, int r){
	if(l<r)return l;
	else return r;
}

int main(int argc, char const *argv[])
{
	int n,l,r,ans=0;
	cin >> n;

	for(int i = 0; i < n;i++){
		cin >> l >> r;
		ans+=myMax(l,r)-myMin(l,r)+1;
	}
	cout << ans << endl;
	return 0;
}


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

#define Set(a, b) memset(a, b, sizeof (a))
#define For(i, j, k) for (int i = j; i <= k; ++ i)
#define Forr(i, j, k) for (int i = j; i >= k; -- i)

using namespace std;

inline int read() {
	int x = 0, p = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') p = -1;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x * p;
}

inline void File() {
	freopen("c.in", "r", stdin);
	freopen("c.out", "w", stdout);
}

typedef long long ll;

const int N = 100, bas = N * N << 1;
int a[N], A, n; ll f[N][bas << 1];

int main() {

	n = read(), A = read();
	For(i, 1, n) a[i] = read() - A;

	f[1][bas] = 1;
	For(i, 1, n) {
		For(w, -10000, 10000)
			f[i + 1][bas + w] += f[i][w + bas],
			f[i + 1][bas + w] += f[i][w + bas - a[i]];
	}	

	cout << f[n + 1][bas] - 1 << endl;
	return 0;
}


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

int main()
{
    string A, B, C;
    cin >> A >> B >> C;
    reverse(begin(A), end(A));
    reverse(begin(B), end(B));
    reverse(begin(C), end(C));
    char c = A[A.size() - 1];
    A.pop_back();
    while (1)
    {
        switch (c)
        {
        case 'a':
            if (A.empty())
            {
                cout << "A" << endl;
                return 0;
            }
            c = A[A.size() - 1];
            A.pop_back();
            break;
        case 'b':
            if (B.empty())
            {
                cout << "B" << endl;
                return 0;
            }
            c = B[B.size() - 1];
            B.pop_back();
            break;
        case 'c':
            if (C.empty())
            {
                cout << "C" << endl;
                return 0;
            }
            c = C[C.size() - 1];
            C.pop_back();
            break;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    int x;
    x = stoi(s+t);
    for(int i=0; i<=1000; i++){
        if(i*i==x){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}




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

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

const int MAXN = 3001;
double dp[MAXN][MAXN], p[MAXN];
int n;

int main(){

	#ifdef MaxWell
    	freopen(".in", "r", stdin);
        cout << "<<<------------ MaxWell defined ---------------->>>\n";
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n;
    for(int i=1; i<=n; i++)
        cin >> p[i];

    dp[0][0] = 1;
    for(int i=1; i<=n; i++)
        dp[0][i] += dp[0][i - 1] * (1 - p[i]);

    for(int i=1; i<=n; i++)
        for(int j = i; j<=n; j++)
            dp[i][j] += dp[i][j-1] * (1 - p[j]) + dp[i-1][j-1] * p[j];

    double ans = 0;
    for(int i = n; i > n/2; i--)
        ans += dp[i][n];

    cout << setprecision(10) << fixed << ans << '\n';

    return 0;
}

Measured memory_bytes: 70016
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int n = s.size();
	int k; cin >> k;
	set<string>st;
	rep(i, n) {
		for (int j = 1; j <= k && i + j <= n; j++) {
			st.insert(s.substr(i, j));
		}
	}
	int i = 1;
	for (auto sa : st) {
		if (i == k) {
			cout << sa << endl; return 0;
		}
		i++;
	}
	return 0;
}

Measured memory_bytes: 1664
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    def same(self, x, y):
        if self.find(x) == self.find(y):
            return True
        else:
            return False


N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

ans = 0
for i in range(M):
    UF = UnionFind(N)

    for j in range(M):
        a, b = ab[j]
        if j != i:
            UF.unite(a-1, b-1)
    s = set()
    for j in range(N):
        s.add(UF.find(j))
    
    if len(s) > 1:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int N;
VL A(2000);
VVL X(2000,VL(2000));
vector<PII> P(2000);
VVL dp(2000,VL(2000));

ll solve(int L,int R){
  if(dp[L][R]!=-1) return dp[L][R];
  ll tmp=0;
  int M=N-(R-L+1)-1;
  if(L>0) tmp=max(tmp,solve(L-1,R)+X[P[M].second][L-1]);
  if(R<N-1) tmp=max(tmp,solve(L,R+1)+X[P[M].second][R+1]);
  return dp[L][R]=tmp;
}

int main(){
  cin>>N;
  rep(i,N) cin>>A[i];
  rep(i,N) rep(j,N) X[i][j]=A[i]*abs(i-j);
  rep(i,N) P[i]=mp(A[i],i);
  sort(all(P),greater<PII>());
  ll ans=0;
  rep(i,N) rep(j,N) dp[i][j]=-1;
  dp[0][N-1]=0;
  rep(i,N) ans=max(ans,solve(i,i)+X[P[N-1].second][i]);
  cout<<ans<<endl;
}




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

int main(void)
{
  int n;
  scanf("%d",&n);
  char w[200][128];
  for(int i=0;i<n;i++){
    scanf("%s",w[i]);
  }

  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(strcmp(w[i],w[j])==0){
        puts("No");
        return 0;
      }
    }
  }

  for(int i=0;i<n-1;i++){
    int len=(int)strlen(w[i]);
    if(w[i][len-1]!=w[i+1][0]){
      puts("No");
      return 0;
    }
  }

  puts("Yes");

  return 0;
}


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

using namespace std;
 
int main()
{
    int x,m,n,r;
     
    cin>>x;
    cin>>m;
     
    for (int i=1;i<=x-1;i++){
        cin>>n;
        do{
            r=m%n;
            m=n;
            n=r;
        }while(r!=0);
    }
     
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
#define MV 100000
#define INF 1e9

struct edge{int to,cost; };
vector <edge> G[MV];
bool used[MV];
int V,E;
int d[MV+1];

void bellmanford(int s){
  fill(d,d+MV,INF);
  d[s] = 0;
  int c = 0;
  bool upd = false;
  while(true){
    upd = false;
    for(int i = 0;i < V;i++){
      for(int j = 0;j < G[i].size();j++){
	edge e = G[i][j];
	if(d[i] != INF && d[e.to] > d[i] + e.cost){
	  d[e.to] = d[i] + e.cost;
	  upd = true;
	}
      }
    }
    if(!upd)
      break;
    if(c == V-1)
      return;
    c++;
  }
}

int main(){
  d[MV] = INF+10;
  int first;
  
  cin >> V >> E >> first;
  for(int i = 0;i < E;i++){
    int f,t;
    edge e;
    cin >> f >> e.to >> e.cost;
    G[f].push_back(e);
    t = e.to;
    
    //e.to = f;
    //G[t].push_back(e);
  }

  
  bellmanford(first);

  for(int i = 0;i < V;i++){
    if(d[i] == INF){
      cout << "INF" << endl;
    }
    else{
      cout << d[i] << endl;
    }
  }
  
}

Measured memory_bytes: 12268
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <complex>
#include <cstdio>
#include <queue>

using namespace std;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	multiset<int> D;
	for (int i = 0; i < N; i++) {
		int d;
		cin >> d;
		D.insert(d);
	}
	int M;
	cin >> M;
	bool ans = true;
	for (int i = 0; i < M; i++) {
		int T;
		cin >> T;
		auto it = D.find(T);
		if (it != D.end()) {
			D.erase(it);
		} else {
			ans = false;
			break;
		}
	}
	cout << (ans?"YES":"NO") << endl;
	return 0;
}


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

using namespace std;

const int MAX = 1000005;
vector<int> ans, a;
bitset<MAX> prime;
int _max = -1;

void sieve() {
  prime.set();
  prime[0] = prime[1] = false;
  for (int i = 4; i < MAX; i += 2) {
    prime[i] = false;
  }
  for (int i = 3; i * i < MAX; i += 2) {
    if (prime[i]) {
      for (int j = i * i; j < MAX; j += 2 * i) {
        prime[j] = false;
      }
    }
  }
}

void _fill(long long n) {
  long long pr = 2;
  int pos = 1;
  
  while (pr * pr <= n) {
    int e = 0;
    while (n % pr == 0) {
      e++;
      n /= pr;
    }
    if (e > 0) {
      _max = max(_max, e);
      ans.push_back(e);
    }
    pr = a[pos++];
  }
  if (n > 1) {
    ans.push_back(1);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  sieve();
  for (int i = 2; i < MAX; i++) {
    if (prime[i]) {
      a.push_back(i);
    }
  }
  vector<int> b, c;   
  for (int i = 1;; i++) {
    int foo = i * (i + 1) / 2;
    if (foo > MAX) break;
    b.push_back(foo);
    c.push_back(i);
  }
  long long n;
  cin >> n;
  _fill(n);
  int cnt = 0;
  for (int i = 0; i < (int)ans.size(); i++) {
    //cout << ans[i] << endl;
    int pos = lower_bound(b.begin(), b.end(), ans[i]) - b.begin();
    if (b[pos] > ans[i]) {
      cnt += c[pos - 1];
    } else {
      cnt += c[pos];
    }
  }
  cout << cnt << '\n';
  return 0;
}

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

int main()
{
    int N, T, X;
    cin >> N >> X >> T;
    int a, b, ans;
    a = N / X;
    b = N % X;
    if (b != 0)
    {
        ans = (a + 1) * T;
        cout << ans << endl;
    }
    else
    {
        ans = a * T;
        cout << ans << endl;
    }
    return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  long long int a[m];
  for(int i=0;i<m;i++){
    cin >> a[i];
  }
  sort(a,a+m);
  long long int b[m-1];
  for(int i=0;i<m-1;i++){
    b[i]=a[i+1]-a[i];
  }
  sort(b,b+m-1);
  int t=max(0,m-n);
  long long int ans=0;
  for(int i=0;i<t;i++){
    ans=ans+b[i];
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 1792
import sys

n = int(sys.stdin.readline())
b = list(map(int, sys.stdin.readline().split()))
ans = []

for i in range(n):
    temp = 0
    for j in range(len(b)):
        if j+1 == b[j]:
            temp = max(temp, b[j])
    if temp == 0:
        ans = [-1]
        break
    ans.insert(0, temp)
    b.pop(temp-1)

print('\n'.join(map(str, ans)))


Measured memory_bytes: 38768
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 1e9 + 7;

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 powMod(ll n, ll k, ll m) {
	if (k == 0) {
		return 1;
	} else if (k % 2 == 1) {
		return powMod(n, k - 1, m) * n % m;
	} else {
		ll t = powMod(n, k / 2, m);
		return t * t % m;
	}
}

int main() {
	ll k, n;
	cin >> k >> n;
	
	vector<int> v(n);
	
	rep(i, n) {
		cin >> v[i];
	}
	v.push_back(v[0]+k);

	int m = 0;
	rep(i, n) {
		m = max(m, v[i+1]-v[i]);
	}

	ll ans = k-m;
	cout << ans << endl;
}

Measured memory_bytes: 1792
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data)

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

n = I()
if n//100 == 7 or (n//10) % 10 == 7 or n % 10 == 7:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 27100
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define ll long long int
#define vec vector
#define forn(a) for(ll a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define deb(x) cerr<<#x<<" = "<<x<<endl

using namespace std;

int main() {
    IOS;

    ll n;
    string v; cin>>v;
    n = v.size();

    bool r = true;
    ll R = 0LL; ll L = 0LL;
    ll last = 0;
    vec<pair<ll, ll>> info;
    forn(i){
        if(r && v[i]=='R') R++, info.push_back({-1,-1});
        else if(r && v[i]=='L') r = false, L=1, info.push_back({R, L}), last = i;
        else if(!r && v[i]=='R') r = true, info.push_back({-1,-1}), R=1;
        else if(!r && v[i]=='L') L++, info.push_back({-1,-1}), info[last].second++;

    }
    info.push_back({-1,-1});

    for(ll k=1; k<=n; k++){
        if(info[k].first==-1) {cout<<0<<" "; continue;}
        //cout<<endl<<"# "<<k<<" "<<info[k].first<<" "<<info[k].second<<endl;

        ll RR = info[k].first; ll LL = info[k].second;
        ll primero = RR/2 + LL-LL/2;
        ll segundo = RR-RR/2 + LL/2; k++;
        cout<< segundo <<" "<< primero <<" ";
    } cout<<endl;

    return 0;
}


Measured memory_bytes: 2548
def matrix(X):
    x = [[0 for i in range(len(X))] for j in range(len(X))]
    for l in range(2, len(X)+1):
        for i in range(0, len(X)-l+1):
            j = i + l - 1
            x[i][j] = min(x[i][k] + x[k+1][j] + X[i][0]*X[k][1]*X[j][1] for k in range(i, j))

    print x[0][len(X)-1]

n = input()
X = []

for i in range(n):
    X.append(map(int, raw_input().split()))

matrix(X)

Measured memory_bytes: 6568
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
    long long int n,sum=0;
    cin>>n;
    vector<int>a(1000000);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end(),std::greater<>());
    for(int i=0;i<n-1;i++){
        sum+=a[i+1];
    }
    if(sum>a[0]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }


    return 0;
}

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

int main() {
    long long X;
    cin >> X;

    long long s = 100;
    bool flag = false;

    for (long i = 1; i <= 1000000000000; i++) {
        s *= 1.01;
        if (s >= X ) {
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <bits/stl_numeric.h>

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


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

    int w[N],v[N];
    REP(i,N)
    {
        cin >> w[i] >> v[i];
    }
    int V = 1000*100;
    ll dp[N+1][V+1] = {};
    //dp[i][j]: min(dp[i-1][j-v[i]] + w[i-1],
    //dp[i][j]: 品物をiを選んだ時点での価値jの最小の重さ
    
    REP(i,N+1)
    {
        REP(j,V+1)
        {
            dp[i][j] = INF;
        }
    }
    REP(i,N+1)
    {
        dp[i][0] = 0;
    }

    for(ll j = 0; j <= V; ++j)
    {
        for(int i = 1; i <= N; ++i)
        {
            if(j < v[i-1])
            {
                dp[i][j] = dp[i-1][j];
            }
            else
            {
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i-1]] + w[i-1]);
            }
        }
    }

#if DEBUG
    for(int i = 0; i <= V; ++i)
    {
        cout << dp[i][W] << endl;
    }
#endif

    ll res = 0;
    for(ll i = V; i >= 0; --i)
    {
        if(dp[N][i] <= W)
        {
            res = i;
            break;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 79104
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

def func():
    N = int(input())

    A = list(map(int, input().split()))
    P = [[(A[0], 0), (0, 0)] for i in range(2 ** N)]

    for i in range(1, 2 ** N):
        if (A[i], i) > P[i][0]:
            P[i][1] = P[i][0]
            P[i][0] = (A[i], i)
        elif (A[i], i) > P[i][1]:
            P[i][1] = (A[i], i)
        for j in range(N):
            if (i & (1 << j)) == 0:
                index = i + (1 << j)
                for k in range(2):
                    if P[i][k] > P[index][0]:
                        P[index][1] = P[index][0]
                        P[index][0] = P[i][k]
                    elif P[i][k] > P[index][1] and P[i][k] != P[index][0]:
                        P[index][1] = P[i][k]
    ans = 0
    for i in range(1, 2 ** N):
        ans = max(ans, P[i][0][0] + P[i][1][0])
        print(ans)
    #print(P)

func()

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

int main(){
    vector<int> pnum(1);
    pnum[0] = 2;
    int X;
    int p=3;
    cin >> X;
    if(X == 2){
        cout << 2 << endl;
        return 0;
    }
    while(true){
        bool flg = true;
        for(int i=0;i<pnum.size();i++){
            if(p%pnum[i]==0){
                flg = false;
                break;
            }
        }
        if(flg){
            pnum.push_back(p);
            if(p>=X){
                cout << p << endl;
                return 0;
            }
        }
        p++;
    }
    return 0;
}

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

int main()
{
  int n;cin>>n;
  vector<int> a(n);
  int mn = 200010;
  int ans = 0;
  int x;
  for(int i=0;i<n;i++)
  {
    cin>>x;
    mn = min (mn, x);
    if(mn==x)ans++;
  }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
n = input()
a = input().split()
out = [0] * int(n)

#for i in range( int(n) ):
#    print( a.count(str(i+1)) )

for a_i in a:
    a_i = int(a_i)
    out[a_i-1] += 1

for out_i in out:
    print( out_i )

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

long long gcd(long long x, long long y){
    if(y == 0){
        return x;
    }

    return gcd(y, x%y);
}

int main(){
    long long n;

    cin >> n;

    long long a[n];

    long long g = 0;

    for(int i = 0; i < n; i++){
        cin >> a[i];
        g = gcd(g, a[i]);
    }

    printf("%lld\n", g);

    return 0;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int ll
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
/*inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}*/
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
#define rank __RANK
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
#define rd read
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
int n,a[55],b[55],deg[55],mark[55];
int way[55][55];
ll ans = 0;
signed main(){
	n = rd();
	Rep(i,1,n) a[i] = rd();
	Rep(i,1,n) b[i] = rd();
	mem(mark,true);
	Dep(i,51,1){
		mem(way,0);
		mark[i]=false;
		Rep(j,0,50){
			way[j][j]=1;
			Rep(k,1,50) if(mark[k]) way[j][j%k]=1;
		}
		Rep(a,0,50)Rep(b,0,50)Rep(c,0,50) 
			way[b][c] |= way[b][a] & way[a][c];
		bool ok = 1;
		Rep(j,1,n) ok &= way[a[j]][b[j]];
		if(!ok) mark[i]=1,ans+=1ll<<i;
	}
	if(ans >= (1ll << 51)) ans = -1;
	writeln(ans);
}


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

void solve() 
{
    ll x,y,a,b,c;cin>>x>>y>>a>>b>>c;
    ll p[a],q[b];
    REP(i,a)cin>>p[i];sort(p,p+a,greater<ll>());
    REP(i,b)cin>>q[i];sort(q,q+b,greater<ll>());
    priority_queue<ll>r; REP(i,c){ll x;cin>>x;r.push(x);}
    priority_queue<ll,vector<ll>,greater<ll> >que;
    REP(i,x)que.push(p[i]);
    REP(i,y)que.push(q[i]);
    ll sum=0;
    while(que.top()<r.top()&&!r.empty()){
        que.pop();
        sum+=r.top();
        r.pop();
    }
    while(!que.empty()){
        sum+=que.top();
        que.pop();
    }cout<<sum<<endl;
}

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

Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int N;cin>>N;
    int tmp;
    int count=0;
    int ans=0;
    for(int i=1;i<=N;i++){
        tmp=i;
        if(tmp%2==0){//偶数かどうか確認
            continue;
        }
        for(int j=1;j<=N;j+=2){//正の約数の個数を確認(奇数で割っていく)
            if(tmp%j==0){
                count++;
            }
        }
        if(count==8){
            ans++;
        }
        count=0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3548
n, m = map(int, input().split())

ans = [0]*m

for _ in range(n):
    a = list(map(int, input().split())) 

    for i in a[1:]:
        ans[i-1] += 1

cnt = 0

for i in ans:
    if i == n:
        cnt += 1

print(cnt)

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

int main() {
    int64_t n;
    cin >> n;
    vector<vector<pair<int64_t, int64_t>>> t(n);
    for (int64_t i = 0; i < n - 1; i++) {
        int64_t a, b, c;
        cin >> a >> b >> c, a--, b--;
        t[a].emplace_back(b, c);
        t[b].emplace_back(a, c);
    }
    int64_t q, k;
    cin >> q >> k, k--;
    vector<int64_t> d(n, -1);
    d[k] = 0;
    queue<int64_t> p;
    p.push(k);
    while (!p.empty()) {
        int64_t tmp = p.front(); p.pop();
        for (auto& e : t[tmp]) {
            if (d[e.first] != -1) continue;
            d[e.first] = d[tmp] + e.second;
            p.push(e.first);
        }
    }
    
    vector<int64_t> ans(q);
    for (auto& e : ans) {
        int64_t x, y;
        cin >> x >> y, x--, y--;
        e = d[x] + d[y];
    }
    for (auto& e : ans) cout << e << endl;
}


Measured memory_bytes: 12144
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , 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; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    ll n,m,s[10];
    char c[10];
    cin>>n>>m;
    rep(i,m){
        cin>>s[i]>>c[i];
        s[i]--;
    }
    ll a=0,b=10;
    if(n==2) a=10,b=100;
    else if(n==3) a=100,b=1000;
    if(true){
        rep2(i,a,b){
            bool ok=true;
            string k=to_string(i);
            rep(j,m){
                if(k[s[j]]!=c[j]) ok=false;
            }
            if(ok){
                cout<<i<<endl;
                return ;
            }

        }
        cout<<-1<<endl;
    }
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


Measured memory_bytes: 256
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(l[K - 1])


Measured memory_bytes: 2940
//C.cpp
#include <iostream>
#include <string>
using namespace std;

int main(){
  string S;
  long long K;
  cin >> S >> K;
  int a;
  if(K==1) printf("%c\n",S[0]);
  else{
    bool flag = true;
    for(int i = 0; i < K; i++){
      if(S[i]!='1'){
        flag = false;
        a = i;
        break;
      }
    }
    if(flag) printf("1\n");
    else printf("%c\n",S[a]);
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a==b){
        printf("%d\n",a+b);
    }else if(a>b){
        printf("%d\n",a+a-1);
    }else{
        printf("%d\n",b+b-1);
    }
    return 0;
}

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

const ll INF = 1LL << 60;
const ll MOD = 998244353;

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

    ll n,k;
    cin >> n >> k;
    vector<pair<ll,ll>> p(k);
    for (ll i = 0;i < k;i++){
        cin >> p[i].first >> p[i].second;
        p[i].first--;
        p[i].second--;
    }
    vector<ll> d(k);
    for (ll i = 0;i < k;i++){
        d[i] = p[i].second - p[i].first +1;
    }

    /*vector<ll> h;
    for (ll i = 0;i < k;i++){
        for (ll j = p[i].first; j <= p[i].second; j++){
            h.push_back(j);
        }
    }
    sort(h.begin(), h.end());
    ll hn = h.size();

    for (ll i = 0; i < h.size(); i++){
        cout << h[i] << endl;
    }*/

    vector<ll> dp(n,0);
    dp[0] = 1;
    vector<ll> s(k,0);

    for (ll i = 0; i < n; i++){
        for (ll j = 0; j < k; j++){
            dp[i] += s[j];
            dp[i] %= MOD;
        }

        for (ll j = 0; j < k; j++){
            if (i >= p[j].first){
                if (i <= p[j].second){
                    s[j] += dp[i - p[j].first];
                }
                else{
                    s[j] -= dp[i - p[j].first - d[j]];
                    s[j] += dp[i - p[j].first];
                }
            }
        }
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 4760
#include <bits/stdc++.h>
using namespace std;
struct edge { int s, t, c; };
bool compare(const edge& e1, const edge& e2) {
	return e1.c < e2.c;
}
int V, E, par[10009]; edge e[100009];
int root(int x) {
	if(par[x] == x) return x;
	return par[x] = root(par[x]);
}
void unite(int x, int y) {
	x = root(x);
	y = root(y);
	par[x] = y;
}
bool same(int x, int y) {
	return root(x) == root(y);
}
int main() {
	scanf("%d%d", &V, &E);
	for(int i = 0; i < E; i++) scanf("%d%d%d", &e[i].s, &e[i].t, &e[i].c);
	sort(e, e + E, compare);
	int ret = 0;
	for(int i = 0; i < V; i++) par[i] = i;
	for(int i = 0; i < E; i++) {
		if(!same(e[i].s, e[i].t)) {
			ret += e[i].c;
			unite(e[i].s, e[i].t);
		}
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

bool check(ll A,ll K){
    while(A || K){
        ll a = A%2,k = K%2;
        if(a > k)return 0;
        A /= 2;
        K /= 2;
    }
    return 1;
}

ll solve(ll K,const vl& A,const vl& B){
    ll ans = 0;
    FOR(i,0,A.size()){
        if(check(A[i],K)){
            ans += B[i];
        }
    }
    return ans;
}

signed main(){
    ll N,K,ans=0;
    cin >> N >> K;
    vl A(N),B(N);
    FOR(i,0,N)cin >> A[i] >> B[i];
    bool bit[30] = {0};
    chmax(ans,solve(K,A,B));
    FOR(i,0,30){
        bit[i] = K%2;
        K /= 2;
    }
    REP(i,0,30){
        if(bit[i]){
            bool tmpbit[30];
            FOR(j,0,30)tmpbit[j] = bit[j];
            FOR(j,0,i)tmpbit[j] = 1;
            tmpbit[i] = 0;
            ll tmpK = 0;
            FOR(j,0,30){
                if(tmpbit[j]){
                    tmpK += (1 << j);
                }
            }
            chmax(ans,solve(tmpK,A,B));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <algorithm> 
#include <vector>

using namespace std;

int main () {
    int N;
    cin >> N;
    vector <int>a(N);
    vector <int>b(N);
    vector <int>c(N);
    for (int i = 0; i < N ; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    vector <vector <int> >dp(N + 1, vector<int>(3, 0));
    for (int i = 0 ; i < N ; i++)
    {
        dp[i + 1][0] = a[i] + max(dp[i][1], dp[i][2]);
        dp[i + 1][1] = b[i] + max(dp[i][0], dp[i][2]);
        dp[i + 1][2] = c[i] + max(dp[i][0], dp[i][1]);
    }
    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
    
}


Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void)
{
    int n; cin >> n;
    vector<long long> a(n);
    long long amax = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        amax = max(amax, a[i]);
    }
    sort(a.begin(), a.end());
    vector<bool> dp(amax, false);
    long long tar;
    for (int i = 0; i < n; i++)
    {
        tar = a[i] * 2;
        while (tar <= amax)
        {
            dp[tar - 1] = true;
            tar += a[i];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] == a[i - 1] || a[i] == a[i + 1]) continue;
        else if (!dp[a[i] - 1])
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4792
package main

import "fmt"

func main() {
	var S, T string
	fmt.Scan(&S)
	fmt.Scan(&T)

	var cnt int
	cnt = 0
	for i := 0; i < len(S); i++ {
		if S[i] != T[i] {
			cnt += 1
		}

	}
	fmt.Println(cnt)
}


Measured memory_bytes: 4492
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;


int c[3][3];
int main() {
  for (int i = 0; i < 3; ++i) for (int j = 0; j < 3; ++j) cin >> c[i][j];
  bool res = true;
  for (int i = 0; i < 3; ++i) {
	c[1][i] -= c[0][i];
	c[2][i] -= c[0][i];
  }
  if (c[1][1] != c[1][0]) res = false;
  if (c[1][2] != c[1][0]) res = false;
  if (c[2][1] != c[2][0]) res = false;
  if (c[2][2] != c[2][0]) res = false;
  if (res) puts("Yes");
  else puts("No");
}



Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-


use proconio::input;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a
use itertools::Itertools;

fn main() {
/*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
 */
    input! {
        s: String,
    }
    if s == "ABC" {
        println!("ARC");
    } else {
        println!("ABC");
    }
}


Measured memory_bytes: 2112
N = int(input())
x = N
if(N%2==1):
  print(0)
else:
  ans = 0
  num = 1
  while( x//(5**num) > 1 ):
    #print(ans,(x//(5**num)//2) )
    ans += ( (x//(5**num)) // 2)
    num += 1
  print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int>a(n, 0);
  rep(i, q) {
    int j;
    cin >> j;
    a[j-1]++;
  }
  rep(i, n) {
    if(q-a[i] < k) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

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

int c[100];

int main(void)
{
	int i;
	int j;
	j = 0;
	while(scanf("%d", &i) != EOF){
		if(i != 0){
			c[j] = i;
			j++;
		}
		else if(i == 0){
			printf("%d\n",c[j - 1]);
			j--;
		}
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#define N 15
using namespace std;
void func(int,int);
int jump(int,int);
int X,Y,data[N][N],memo[N][N];
int main(){
  while(1){
    cin >> X >> Y;
    if(X==0&&Y==0) break;
    for(int i=0;i<Y;i++)
      for(int j=0;j<X;j++) cin >> data[i][j],memo[i][j]=0;
    for(int i=0;i<X;i++)
      if(data[0][i]==0) func(0,i);
    int cnt=0;
    for(int i=0;i<X;i++) cnt+=memo[0][i];
    cout << cnt << endl;
  }
  return 0;
}
void func(int y,int x){
  if(y==Y-1){
    memo[Y-1][x]=1;
    return ;
  }
  if(0<=x-1&&data[y+1][x-1]==0){
    if(memo[y+1][x-1]==0) func(y+1,x-1);
    memo[y][x]+=memo[y+1][x-1];
  }
  if(x+1<X&&data[y+1][x+1]==0){
    if(memo[y+1][x+1]==0) func(y+1,x+1);
    memo[y][x]+=memo[y+1][x+1];
  }
  if(data[y+1][x]==0){
    if(memo[y+1][x]==0) func(y+1,x);
    memo[y][x]+=memo[y+1][x];
  }
  if(data[y+1][x]==2){
    int r=jump(y+1,x);
    if(r==-2) memo[y][x]+=1;
    else if(r!=-1){
      if(memo[r][x]==0) func(r,x);
      memo[y][x]+=memo[r][x];
    }
  }
  if(memo[y][x]==0) data[y][x]=1;
}
int jump(int y,int x){
  while(1){
    y+=2;
    if(y>Y-1) return -2;
    if(data[y][x]==1) break;
    if(y==Y-1) return -2;
    if(data[y][x]==0) return y;
  }
  return -1;
}

Measured memory_bytes: 1160
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  string a;
  cin >> a;
  for (int i = 1; i < a.size(); i++) {
    if (a[i] == a[i - 1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}


Measured memory_bytes: 256
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

n = inp[0]
p r_up(n,2)

Measured memory_bytes: 2044
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>

int arr[3], a, b, c;

void task(){
    scanf("%d %d %d", &a, &b, &c);
    arr[0] = abs(c - a);
    arr[1] = abs(b - a);
    arr[2] = abs(c - b);
    std::sort(arr, arr + 3);
    printf("%d\n", arr[0] + arr[1]);
}

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

    //freopen("/Users/deepsajeda/Projects/input.txt","r", stdin);
    // freopen("/Users/deepsajeda/Projects/output","w",stdout);
    task();
}
//printf("%.5f\n", clock() / (float)CLOCKS_PER_SEC); time in seconds

Measured memory_bytes: 256
n,k = map(int, input().split())
a = [0]+[int(x) for x in input().split()]
 
def hyouka(gakki):
    if a[gakki-k]<a[gakki]:
        print("Yes")
    else:
        print("No")

for i in range(k+1,n+1):
    hyouka(i)


Measured memory_bytes: 31748