akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    C=[0]*n
    for i in range(n):
        x,y=map(int,input().split())
        C[i]=complex(x,y)

    from itertools import product
    S=sum(abs(C[i]-C[j]) for i,j in product(range(n),repeat=2))
    print(S/n)
resolve()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A);
  rep(i, A) {
    cin >> a[i];
  }
  vector<int> b(B);
  rep(i, B) {
    cin >> b[i];
  }
  vector<int> x(M), y(M), c(M);
  rep(i, M) {
    cin >> x[i] >> y[i] >> c[i];
    x[i]--,y[i]--;
  }

  int ans=INF;
  rep(i, M) {
    int cost=a[x[i]]+b[y[i]]-c[i];
    chmin(ans,cost);
  }

  sort(all(a));
  sort(all(b));
  chmin(ans,a[0]+b[0]);

  cout << ans << endl;
}

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

int main() {
    int N, X;
    cin >> N;
    X = N;
    int sum = 0;
    while (N > 0) {
        sum += N % 10;
        N /= 10;
    }
    if (X % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
int main(){
  int n,a[N],i,j,key,k;
  scanf("%d",&n);


  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  for(i=0;i<n;i++){
    if(i==n-1)
      printf("%d",a[i]);
    else
      printf("%d ",a[i]);
  }
  printf("\n");
  for(i=1;i<n;i++){
    key=a[i];
    j=i-1;
    while(0<=j && a[j]>key){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=key;
    for(k=0;k<n;k++){
      if(k==n-1)
        printf("%d",a[k]);
      else
        printf("%d ",a[k]);
    }
    printf("\n");
    
  }
  return 0;
}



Measured memory_bytes: 2144
s = list(input())
q = int(input())
for i in range(q):
    cmd, a, b, *p = [x for x in input().split()]
    a = int(a)
    b = int(b)
    if cmd=='print':
        print(''.join(s[a:b+1]))
    if cmd=='reverse':
        stack = []
        for _ in range(b+1-a):
            stack.append(s.pop(a))
        for i in range(a, b+1):
            s.insert(i, stack.pop())
    if cmd=='replace':
        for i,c in zip(range(a,b+1), list(p[0])):
            s[i] = c



Measured memory_bytes: 5628
# ALDS1_3_C: Doubly Linked List

class DoublyLinkedList
  include Enumerable

  class Node
    attr_accessor :key, :next, :prev

    def initialize(key = nil)
      @key  = key
      @next = @prev = nil
    end

    def append(another)
      another.next   = self.next
      self.next.prev = another
      self.next      = another
      another.prev   = self
    end

    def disappear
      self.prev.next = self.next
      self.next.prev = self.prev
      self
    end
  end


  def initialize
    @head = Node.new
    @head.next = @head.prev = @head
  end

  def insert(key)
    node = Node.new key
    @head.append node
    node
  end

  def delete(key)
    node = search_node key
    delete_node node
  end

  def deleteFirst
    delete_node @head.next
  end

  def deleteLast
    delete_node @head.prev
  end

  def each
    node = @head.next
    while node != @head
      yield node
      node = node.next
    end
  end

  def to_s
    inject('') do |s, node|
      s << ' ' << node.key.to_s
    end.strip
  end

  private
    def delete_node(node)
      node.disappear unless node.nil?
    end

    def search_node(key)
      find do |node|
        node != @head && node.key == key
      end
    end
end

list = DoublyLinkedList.new
n_commands = gets.to_i

n_commands.times do
  input   = gets.chomp.split
  command = input.first
  args    = input.drop(1)
  list.send command, *args
end

puts list

Measured memory_bytes: 143924
#include<bits/stdc++.h>
using namespace std;
const int N = 3005;
int dp[N][N];
int path[N][N];
char a[N];
char b[N];
char ans[N];
int main()
{
    int n,m;
    scanf(" %s %s",a+1,b+1);
    n = strlen(a+1),m = strlen(b+1);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(a[i]==b[j])  dp[i][j] = dp[i-1][j-1]+1;
            else if(dp[i-1][j]>=dp[i][j-1]) dp[i][j] = dp[i-1][j],path[i][j] = 1;
            else                            dp[i][j] = dp[i][j-1],path[i][j] = 2;
            dp[i][j] = max(dp[i-1][j-1]+(a[i]==b[j]),max(dp[i-1][j],dp[i][j-1]));
        }
    }
    int x=n,y=m,idx=dp[n][m];
    while(x&&y)
    {
        if(!path[x][y]) ans[idx--] = a[x],--x,--y;
        else if(path[x][y]==1)  --x;
        else                    --y;
    }
    printf("%s\n",ans+1);
    return 0;
}


Measured memory_bytes: 70784
#include <iostream>

using namespace std;

int main(void){
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  if((A1 + A2 + A3) >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  return 0;
}








Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	int N, M, K;
	cin >> N >> M >> K;
	int num_of_black = 0;
	for (int i = 0; i <= N; i++){
		num_of_black = i * M;
		for (int j = 0; j <= M; j++){
			if (num_of_black+(-2*i+N)*j==K) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
	
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	int L;
	cin >> L;
	int  m;
	m = 0;

	vector<vector<tuple<int, int, int>>> ans;
	ans.resize(21);
	for (int i = 2; i + 1 <= 20; i++) {
		m++;
		ans[i].emplace_back(i, i + 1, 1 << (20 - i - 1));
		m++;
		ans[i].emplace_back(i, i + 1, 0);
	}

	int nxt = 0;
	for (int i = 18; i >= 0; i--) {
		while(L >= (1<<i)) {
			m++;
			ans[i].emplace_back(1, 20 - i, nxt);
			nxt += 1 << i;
			L -= 1 << i;
		}
	}
	cout << 20 << ' ' << m << endl;
	rep(i, 21) {
		for (const auto &t : ans[i]) {
			cout << get<0>(t) << ' ' << get<1>(t) << ' ' << get<2>(t) << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010

int main(){
	IOS;
	ll a,b;cin>>a>>b;
	if(a>9 or b>9)cout<<"-1";
	else cout<<a*b;
	
	
	
	return 0;
}



Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  vector<int> copy = v;
  sort(ALL(copy));
  int l = copy[n / 2 - 1];
  int r = copy[n/ 2];
  if (l == r) {
    rep(i,n) cout << l << " ";
    cout << endl;
    return;
  }
  rep(i,n) {
    if (v[i] < r) cout << r << " ";
    else cout << l << " ";
  }
  cout << endl;
}

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

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

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

  vector<int> y1, x1, y2, x2;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (j < W - 1 && A[i][j] % 2 == 1) {
        y1.push_back(i);
        y2.push_back(i);
        x1.push_back(j);
        x2.push_back(j + 1);
        A[i][j]--, A[i][j + 1]++;
      } else if (i < H - 1 && j == W - 1 && A[i][j] % 2 == 1) {
        y1.push_back(i);
        y2.push_back(i + 1);
        x1.push_back(j);
        x2.push_back(j);
        A[i][j]--, A[i + 1][j] += 1;
      }
    }
  }
  cout << y1.size() << endl;
  for (int i = 0; i < y1.size(); i++) {
    cout << y1[i] + 1 << " " << x1[i] + 1 << " " << y2[i] + 1 << " "
         << x2[i] + 1 << endl;
  }
}

Measured memory_bytes: 5224
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
ll a[300005];
ll cnt[65];
int main(){
	cin>>n;rep(i,n)cin>>a[i];
	rep(j,62)rep(i,n){
		if(((a[i]>>j)&1LL)) cnt[j]++;
	}
	ll ans = 0;
	const ll mod = 1000000007;
	rep(j,62){
		ans += (1LL<<j)%mod*cnt[j]%mod*(n-cnt[j])%mod;
	}
	cout<<(ans%mod+mod)%mod<<endl;}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int x, y, na, nb, nc, num, i;
	ll buf, ans = 0;
	cin >> x >> y >> na >> nb >> nc;
	vector<ll> a(na), b(nb);
	priority_queue<ll> c;
	rep(i, na)
		cin >> a[i];
	rep(i, nb)
		cin >> b[i];
	rep(i, nc) {
		cin >> buf;
		c.push(buf);
	}
	sort(a.begin(), a.end(), greater<ll>());
	sort(b.begin(), b.end(), greater<ll>());
	rep(i, x)
		ans += a[i];
	rep(i, y)
		ans += b[i];
	while (x > 0 && y > 0 && !c.empty()) {
		if (a[x - 1] <= b[y - 1]) {
			if (a[x - 1] < c.top()) {
				ans += c.top() - a[x - 1];
				x--;
			}
			else break;
		}
		else {
			if (b[y - 1] < c.top()) {
				ans += c.top() - b[y - 1];
				y--;
			}
			else break;
		}
		c.pop();
	}
	while (x > 0 && !c.empty()) {
		if (a[x - 1] < c.top()) {
			ans += c.top() - a[x - 1];
			x--;
			c.pop();
		}
		else break;
	}
	while (y > 0 && !c.empty()) {
		if (b[y - 1] < c.top()) {
			ans += c.top() - b[y - 1];
			y--;
			c.pop();
		}
		else break;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 2936
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

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

    double ave = (double)sum/n;
    vector<pair<double, ll>> p(n);
    rep(i, n) {
        p[i] = make_pair(abs(a[i] - ave), i);
    }
    sort(all(p));

    out(p[0].second);
    re0;
}

Measured memory_bytes: 256
N, K ,Q = map(int, input().split())
A = [int(input()) for i in range(Q)]

point = [K-Q] * N

for i in range(Q):
  point[A[i] - 1] += 1
  #print(point)

for i in range(N):
  if point[i] >= 1:
    print("Yes")
  else:
    print("No")



Measured memory_bytes: 56536
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
import numpy as np

N, K = map(int, input().split())
A = np.array(list(map(int, input().split())), dtype = np.int64)

MOD = 10**9+7
def cumprod(x, MOD = MOD):
	L = len(x)
	Lsq = int(L**.5 + 1)
	x = np.resize(x, Lsq ** 2).reshape(Lsq, Lsq)
	for n in range(1, Lsq):
		x[:,n] *= x[:,n-1]
		x[:,n] %= MOD
	for n in range(1,Lsq):
		x[n] *= x[n-1, -1]
		x[n] %= MOD
	return x.flatten()[:L]

def make_fact(U, MOD = MOD):
	x = np.arange(U, dtype = np.int64)
	x[0] = 1
	fact = cumprod(x, MOD)
	x = np.arange(U, 0, -1, dtype = np.int64)
	x[0] = pow(int(fact[-1]), MOD - 2, MOD)
	fact_inv = cumprod(x, MOD)[::-1]
	return fact, fact_inv

fact, inv = make_fact(N+100, MOD)
A.sort()
ans = 0
lim = N - K + 1
for ind, a in enumerate(A, 1):
	if ind < K:
		tmp_max = 0
	else:
		max_comb = (fact[ind-1] * inv[K-1]) % MOD * inv[ind-K] % MOD
		tmp_max = max_comb * a % MOD
	if ind > lim:
		tmp_min = 0
	else:
		min_comb = (fact[N - ind] * inv[K-1]) % MOD * inv[N - ind - K + 1] % MOD
		tmp_min = min_comb * a % MOD

	ans += (tmp_max - tmp_min) % MOD
	ans %= MOD

print(ans)

Measured memory_bytes: 23156
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

const int inf = 1000000000;

//#define DEBUG

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, 0, n) cin >> h[i];
    sort(h.begin(), h.end(), greater<int>());
    ll accum = 0;
    for (int i = k; i < n; i++) accum += h[i];
    cout << accum << endl;
}

Measured memory_bytes: 1656
import sys
h,w=map(int,raw_input().split())
a=[list(raw_input()) for _ in range(h)]
b=[['.']*w for _ in range(h)]
i=j=0
flag=True
while flag:
    b[i][j]='#'
    if (i,j)==(h-1,w-1):break
    flag=False
    if i+1<h:
        if a[i+1][j]=='#':i+=1;flag=True
    if not flag and j+1<w:
        if a[i][j+1]=='#':j+=1;flag=True
if a==b:print 'Possible'
else:print 'Impossible'


Measured memory_bytes: 2696
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  int n;
  cin>>n;
  int A=0,W=0,T=0,R=0;
  string s;
  
  rep(i,n){    
    cin>>s;
    if(s.at(0)=='A') A++;
    if(s.at(0)=='W') W++;
    if(s.at(0)=='T') T++;
    if(s.at(0)=='R') R++;
  }
  cout<<"AC x "<<A<<endl;
  cout<<"WA x "<<W<<endl;
  cout<<"TLE x "<<T<<endl;
  cout<<"RE x "<<R<<endl;
}

Measured memory_bytes: 3628
n,m=map(int,input().split())
d=[[10**18]*n for i in range(n)]
e=[]
for _ in range(m):
    a,b,c=map(int,input().split())
    d[a-1][b-1]=c
    d[b-1][a-1]=c
    e.append([a-1,b-1,c])
for i in range(n):
    d[i][i]=0
for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j]=min(d[i][j],d[i][k]+d[k][j])

print(sum(c>d[a][b] for a,b,c in e))

Measured memory_bytes: 42092
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

int main(){
	while(1){
		int N; cin >> N;
		if (N == 0) break;
		if (N == 1){
			cout << 1 << " " <<  1 << endl;
			continue;
		}
		int xmax = 0;
		int xmin = 0;
		int ymax = 0;
		int ymin = 0;
		vector< pair<int,int> > locate(N);
		locate[0] = make_pair(0,0);
		int dx[2][4] = { {-1,0,1,0},
						 {0,-1,0,1} };
		for (int i = 1; i < N; i++){
				int n,d; cin >> n >> d;
				locate[i] = make_pair(locate[n].first + dx[0][d],
										locate[n].second + dx[1][d]);
		}   
		for (int i = 0; i < N; i++){
			if (xmax < locate[i].first) xmax = locate[i].first;  
			if (xmin > locate[i].first) xmin = locate[i].first;  
			if (ymax < locate[i].second) ymax = locate[i].second;  
			if (ymin > locate[i].second) ymin = locate[i].second;  
		}
		cout << xmax - xmin + 1 << " " << ymax - ymin + 1 << endl;	
	}       	
				
return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define INF 0x3f3f3f3f
#define lli long long int
#define ulli unsigned long long int
#define for0(i,n) for(long long int i=0;i<(long long int)n;i++)
#define for1(i,n) for(long long int i=1;i<=(long long int)n;i++)
#pragma GCC target ("sse4.2")
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    bool flag=0;
    lli temp=0, ans=0;
    for0(i,3){
        if(flag && s[i]=='R')
            ++temp;
        else if(!flag && s[i]=='R'){
            temp=1;
            flag=1;
        } else if(flag && s[i]=='S'){
            ans = max(ans,temp);
            flag=0;
        }
    }
    if(flag)
        ans = max(temp,ans);
    cout<<ans<<"\n";
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
long long L[87] = {2,1};
int main(){
  int i;
  rd(N);
  for(i=2;i<N+1;i++){
    L[i] = L[i-1] + L[i-2];
  }
  wt_L(L[N]);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int N;
// ll L[87] = {2,1};
// {
//   int i;
//   rd(N);
//   rep(i,2,N+1) L[i] = L[i-1] + L[i-2];
//   wt(L[N]);
// }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define lla(s) s.rbegin(),s.rend()
#define pcnt(b) __builtin_popcount(b)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int,int>>
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ll INF = 1e18;


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,a,b,A=1,B=1;
    cin>>n;
    rep(i,0,n){
        cin>>a>>b;
        A=(A+a-1)/a*a;B=(B+b-1)/b*b;
        int r = max(A/a,B/b);
        A=r*a;
        B=r*b;
    }
    cout<<(A+B)<<endl;
}

Measured memory_bytes: 256
while 1:
    try:
        a,b,c=map(int,input().split())
        parts=[2]*(a+b+c+1)
        N=int(input())
        met_keep=[]
        for nn in range(N):
            i,j,k,r=map(int,input().split())
            if r==1:
                parts[i],parts[j],parts[k]=1,1,1
            if r==0:
                met_keep.append([i,j,k])
        for i,j,k in met_keep:
            if parts[i]==1 and parts[j]==1 and parts[k]==2:
                parts[k]=0
            elif parts[i]==1 and parts[j]==2 and parts[k]==1:
                parts[j]=0
            elif parts[i]==2 and parts[j]==1 and parts[k]==1:
                parts[i]=0
        for i in parts[1:]:
            print(i)
    except:break


Measured memory_bytes: 5712
#include <bits/stdc++.h>
#define N 200010
using namespace std;
long long n,a,qsum[N]={},qxor[N]={},i,j,sum=0,x,y;
int main(){
	cin>>n;
	qsum[0]=qxor[0]=0;
	for(i=1;i<=n;i++)
	{
		cin>>a;
		qsum[i]=qsum[i-1]+a;
		qxor[i]=qxor[i-1]^a;
	}
	j=1;
	for(i=1;i<=n;i++)
	{
		while((qsum[i]-qsum[j-1])!=(qxor[i]^qxor[j-1]))
			j++;
		sum+=(i-j+1);
	}
	cout<<sum<<endl;
	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,zb=0;
    cin >> n;
    vector<int> a(n,0);
    vector<int> b(n,0);
    for (int i=0;i<n;i++)
        cin >> a[i];
    for (int i=0;i<n;i++)
        cin >> b[i];
    for (int i=0;i<n;i++)
        if(a[i]>b[i])
            zb+=a[i]-b[i];
    cout << zb;
}



Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace atcoder;
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll
const long double pi = 3.14159265358979323846;

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}
using mint = modint998244353;
vector<mint> ten, one;
struct S {
    mint v;
    int len;
};

using F = ll;
const F ID = 0;
S op(S a, S b) {
    return S{a.v * ten[b.len] + b.v, b.len + a.len};
}

S e(){
    return {0, 0};
}

S mapping(F x, S a){
    if(x != ID){
        a.v = one[a.len] * x;
    }
    return a;
}

F composition(F a, F b){
    return a == ID ? b : a;
}

F id(){
    return ID;
}
signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    ll n,q; cin >> n >> q;
    one.resize(n + 1);
    ten.resize(n + 1);
    one[0] = 0;
    ten[0] = 1;
    vector<S> v(n);
    rep(i,0,n){
        one[i + 1] = one[i] * 10 + 1;
        ten[i + 1] = ten[i] * 10;
        v[i] = {1, 1};
    }
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);
    debug(seg.all_prod().v.val());
    rep(i, 0, q) {
        ll l,r,d; cin >> l >> r >> d;
        l--;
        seg.apply(l, r, d);
        S t = seg.all_prod();
        cout << t.v.val() << "\n";
    }
}

Measured memory_bytes: 18288
import numpy as np

w,h,n=map(int,input().split())
wh=np.ones((h,w))

for _ in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        wh[:,:x]=0
    if a==2:
        wh[:,x:]=0
    if a==3:
        wh[:y,:]=0
    if a==4:
        wh[y:,:]=0
print(int(np.sum(wh)))



Measured memory_bytes: 12508
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
typedef long long LL;
const int maxN = 1e5 + 7;
using namespace std;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n, m;
int p[maxN];
LL total = 0, ans;
struct rec {
	LL d, c;
	inline void operator += (const int &v) {d += v, ++ c;}
	inline void operator += (const rec &v) {d += v.d, c += v.c;}
	inline void operator -= (const rec &v) {d -= v.d, c -= v.c;}
}bg[maxN], ed[maxN], s;

int main() {

	n = ri(), m = ri();
	rep (i, 1, n) p[i] = ri();
	rep (i, 2, n) {
		int x = p[i-1], y = p[i];
		if (x == y) continue;
		if (x < y) {
			total += y - x;
			bg[x+1] += 0, ed[y] += y - x - 1;
		}
		else {
			int d = m - x;
			if (x < m) bg[x+1] += 0;
			bg[1] += d, ed[y] += d + y - 1;
			total += d + y;
		}
	}

	ans = total;
	rep (i, 1, m) {
		s.d += s.c;
		s += bg[i];
		ans = min(ans, total - s.d);
		s -= ed[i];
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 3712
#pragma comment(linker, "/STACK:10240000")
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 110;
const int MAX_INF = 0x3fffffff;

int a[MAXN][15], c[MAXN][15], num[MAXN];

int main ()
{
    int n;
    scanf ("%d", &n);
    for (int i = 1; i <= n; i ++)
    {
        for (int j = 1; j <= 10; j ++)
        {
            scanf ("%d", &a[i][j]);
        }
    }
    for (int i = 1; i <= n; i ++)
    {
        for (int j = 0; j <= 10; j ++)
        {
            scanf ("%d", &c[i][j]);
        }
    }
    int ans = -MAX_INF;
    memset (num, 0, sizeof (num));
    for (int i = 1; i <= 1023; i ++)
    {
        for (int j = 0; j <= 9; j ++)
        {
            if ((1 << j) & i)
            {
                for (int t = 1; t <= n; t ++)
                {
                    if (a[t][j + 1])
                    {
                        num[t] ++;
                    }
                }
            }
        }
        int tmp = 0;
        for (int j = 1; j <= n; j ++)
        {
            tmp += c[j][num[j]];
            num[j] = 0;
        }
        if (tmp > ans)
        {
            ans = tmp;
        }
    }
    printf ("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
program main
   implicit none
   integer::N,C
   integer,allocatable,dimension(:,:)::D
   integer,allocatable,dimension(:,:)::Cs
   integer,allocatable,dimension(:,:)::T
   integer::i,j,k,m
   integer::ans,preans
   read*,N,C
   allocate(D(C,C))
   do i=1,C
      read*,D(i,:)
   end do
   allocate(Cs(N,N))
   do i=1,N
      read*,Cs(i,:)
   end do

   allocate(T(0:2,C))
   T=0
   do i=1,N
      do j=1,N
         T(mod(i+j,3),Cs(i,j))=T(mod(i+j,3),Cs(i,j))+1
      end do
   end do
   
   ans=huge(ans)
   do i=1,C
      do j=1,C
         do k=1,C
            if((i-j)*(j-k)*(k-i)==0)cycle
            preans=0
            do m=1,C
               preans=preans+D(m,i)*T(0,m)+D(m,j)*T(1,m)+D(m,k)*T(2,m)
            end do
            ans=min(ans,preans)
         end do
      end do
   end do
   print"(I0)",ANS
contains

end program main

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n;
    cin >> n;
    ll a[n];
    rep(i,n)cin >> a[i];

    ll ans = -1;

    ll x = 0;
    srep(i,2,n)x ^= a[i];

    bitset<50> f(x);

    ll yy = a[0] + a[1];
    ll zz = 0;
    ll two[55] = {};
    two[0] = 1;
    srep(i,1,55)two[i] = two[i-1]*2;
    drep(i,50){
        if(f[i] == 1){
            // yy -= two[i];
            yy -= 1LL<<i;
        }else{
            if(two[i]*2 <= yy){
                // yy -= two[i]*2;
                // yy -= 1LL<<(i+1);
                yy -= (ll)1<<(i+1);
                // zz += two[i];
                // zz += 1LL<<i;
                zz += (ll)1<<i;
            } 
        }
    }

    if(yy != 0 || zz > a[0]){
        cout << -1 << endl;
        return 0;
    }

    ans = 0;

    drep(i,50){
        if(f[i] == 1){
            if(zz + two[i] <= a[0]){
                // zz += two[i];
                // zz += 1LL<<i;
                zz += (ll)1<<i;
            }
        }
    }

    ans = a[0] - zz;
    if(ans == a[0]){
        cout << -1 << endl;
        return 0;
    }

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




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

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

    int n, l;
    cin >> n >> l;
    string s[n];
    rep(i, n){
        cin >> s[i];
    }
    
    sort(s, s+n);
    
    string ans = "";
    for(auto data : s){
        ans += data;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import numpy as np
S = np.array(list(input()))
T = np.array(list(input()))

lenS = len(S)
lenT = len(T)

# 一番重なりが多い部分を探す
max_kasanari = np.sum(S[:lenT] == T)  # Sの最初lenT文字と、Tの重なっている部分
for i in  range(lenS - lenT + 1):
    kasanari = np.sum(S[i:lenT+i] == T)
    if max_kasanari < kasanari:
        max_kasanari = kasanari

print(lenT - max_kasanari)



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

int main() {
  string s;
  char jubge;
  bool a = true;
  cin >> s;
  sort(s.begin(),s.end());
  jubge = s.at(0);
  for(int i = 1; i < s.size(); i++){
    if(jubge == s.at(i)){
      a = false;
      break;
    }else{
      jubge = s.at(i);
    }
  }
  if(a)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main() {
	long long int n, a[100000], b[100000];
	cin >> n;
	long long int max = 0, yan=0;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		if (max < a[i]) {
			max = a[i];
			yan = b[i];
		}
	}
	cout << max + yan << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B; cin >> A >> B;
  if(A==B) cout << "Draw" << endl;
  else if(A==1) cout << "Alice" << endl;
  else if(B==1) cout << "Bob" << endl;
  else if(A>B) cout << "Alice" << endl;
  else cout << "Bob" << endl;
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int ans = 0;
  for(int i = 1; i <= N; i++) {
    int sum = 0;
    int I = i;
    while(I > 0) {
      sum += I % 10;
      I /= 10;
    }
    if(A <= sum && sum <= B)
      ans += i;
  }
  cout << ans << endl;
}

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;





int main(){
  ll n,m; cin>>n>>m;
  vector<ll> h(n);
  rep(i,n) cin>>h[i];
  bool good[n];
  rep(i,n) good[i]=true;
  rep(i,m){
      ll a, b; cin>>a >>b;
      a--; b--;
      if(h[a]>h[b]) good[b]=false;
      else if(h[b]>h[a]) good[a]=false;
      else good[a]= good[b]= false;
  }
  ll ans=0;
  rep(i,n) if(good[i]) ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 4024
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
int A,B,C,T; 
signed main()
{
	cin>>A>>B>>C>>T;
	vector<int> a(A),b(B),c(C); 
	for(int i=0;i<A;i++)cin>>a[i];
	for(int i=0;i<B;i++)cin>>b[i];
	for(int i=0;i<C;i++)cin>>c[i];
	sort(a.rbegin(),a.rend());
	sort(b.rbegin(),b.rend());
	sort(c.rbegin(),c.rend());
	vector<int> ans;
	for(int i=0;i<A;i++)
	{
		for(int j=0;j<B;j++)
		{
			for(int k=0;k<C;k++)
			{
				if((i+1)*(j+1)*(k+1)>T)continue;
				ans.push_back(a[i]+b[j]+c[k]);
			}
		}
	}
	sort(ans.rbegin(),ans.rend());
	for(int i=0;i<T;i++)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 1404
import math
a,b,h,m = map(int, input().split()) 
minute = m + 60 * h
h2 = [a*math.sin(math.pi*minute/360),a*math.cos(math.pi*minute/360)]
m2 = [b*math.sin(math.pi*minute/30),b*math.cos(math.pi*minute/30)]
l = ((h2[0]-m2[0])**2 +(h2[1]-m2[1])**2 ) ** 0.5
print(l)

Measured memory_bytes: 9564
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
    int N;
    cin >> N;
    vector<int>L(N);
    rep(i,N)cin >> L[i];
    sort(L.begin(),L.end());
    ll ans=0;
    for(int i=0;i<N-1;i++)for(int j=i+1;j<N;j++){
        int s=L[i]+L[j];
        int l=j;int r=N;
        while(r-l>1){
            int mid=(l+r)/2;
            if(L[mid]>=s){r=mid;}
            else{l=mid;}
        }
        ans+=max(0,l-j);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <stdlib.h>
#include <functional>
#define ll long long
#define llu unsigned long long
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
using namespace std;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
int n, m;
ll A[2*N];
ll psum[2*N];
ll pxor[2*N];

ll combination2(ll n) {
	return n * (n - 1) / 2;
}


int main()
{
	int i, j, k, x, y, u, v, num, t, test;

	scanf("%d", &n);

	for (i = 1; i <= n; ++i) {
		scanf("%lld", &A[i]);
		psum[i] = psum[i - 1] + A[i];
		pxor[i] = (pxor[i - 1] ^ A[i]);
	}

	int left = 1;
	int right = 1;
	ll cnt = 0;

	while (1) {
		while (right <= n && ((pxor[right] ^ pxor[left - 1]) == (psum[right] - psum[left - 1]))) right++;
		int nn = right - left;
		cnt += combination2(nn + 2 - 1);
		if (right > n) break;
		while ((pxor[right] ^ pxor[left - 1]) != (psum[right] - psum[left - 1])) left++;
		nn = right - left;
		cnt -= combination2(nn + 2 - 1);
	}
	printf("%lld\n", cnt);
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define itn int
#define gI gi
 
using namespace std;
 
typedef long long ll;
 
inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}
 
inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}
 
int ans, n, m, a[200003], minn = 200003;
char s[100003];
 
int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi();
	for (int i = 1; i <= n; i+=1) a[i] = gi();
	for (int i = 1; i <= n; i+=1)
	{
		minn = min(minn, a[i]);
		if (minn == a[i]) ++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

int main()
{
	int n;
	std::cin >> n;

	std::string ans = "Three";
	for( int i = 0; i < n; i++ ) {
		std::string s;
		std::cin >> s;
		if( s == "Y" ) {
			ans = "Four";
			break;
		}
	}

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

// Most important thing in CP - Have Fun :)

void solve(){
    int n;
    cin>>n;
    vii arr(n);
    rep(i,0,n)cin>>arr[i].ff>>arr[i].ss;
    int cons = 0;
    for (int i = 0 ; i<n ; i++){
        if (arr[i].ff == arr[i].ss)cons++;
        else cons = 0;
        if (cons>=3){
            cout<<"Yes"<<endl;
            return;
        }
    }
    cout<<"No"<<endl;
    return;
}

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

Measured memory_bytes: 3660
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int S;
  int h,m,s;
  cin >> S;
  h=S/3600;
  S=S-h*3600;
  m=S/60;
  S=S-m*60;
  s=S;
  cout << h << ":"<< m << ":"<< s << endl;
  return(0);
}



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

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

const int N = 1e5 + 11;
const int M = 1e6 + 11;
const int MOD = 1e9 + 7;

int main(int argc, char **args){
    string s; cin >>s;   
    int cur = 0;
    int i;
    for(i = 0; s[i]; i++){
        if(s[i] == 'h' && cur == 0) {
            cur ^= 1;
        }
        else if(s[i] == 'i' && cur == 1){
            cur ^= 1;
        }else break;
    }
    if(s[i] || cur == 1){
        puts("No");
    }else 
        puts("Yes");
return 0;
}

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

int main()
{
    string s;
    cin>>s;
    int k;
    cin>>k;
    int n = s.size();
    int dp[n+1][n+1][k+1];
    int ans = 0;
    for(int i=0; i<n+1; i++){
        for(int j=0; j<n+1; j++){
            for(int c=0; c<k+1; c++){
                dp[i][j][c] = 0;
            }
        }
    }


    for(int i=0; i<n+1; i++){
        for(int j=0; j<n+1; j++){
            for(int c=0; c<k+1; c++){
                if(i<n)
                    dp[i+1][j][c] = max(dp[i][j][c],dp[i+1][j][c]);
                if(j<n)
                    dp[i][j+1][c] = max(dp[i][j][c],dp[i][j+1][c]);
                if(i<n &&j<n && i+j<n){
                    if(s[i] == s[n-1-j]){
                         dp[i+1][j+1][c] = max(dp[i+1][j+1][c], dp[i][j][c]+1);
                         if(i+j==n-1)
                            ans = max(ans, 2*dp[i+1][j+1][c]-1);
                         else
                            ans = max(ans,2*dp[i+1][j+1][c]);
                    }
                    else if(c<k){
                        dp[i+1][j+1][c+1] = max(dp[i+1][j+1][c+1], dp[i][j][c]+1);
                         if(i+j==n-1)
                            ans = max(ans, 2*dp[i+1][j+1][c+1]-1);
                         else
                            ans = max(ans,2*dp[i+1][j+1][c+1]);
                    }
                }


            }
        }
    }
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 106752
#include <bits/stdc++.h>
using namespace std;
#define ll long long
string s,t;
ll solve()
{
    bool f[26] ={};
    for(int i=0;i<t.size();++i)
        f[t[i]-'a'] = 1;
    for(int i=0;i<s.size();++i)
        f[s[i]-'a'] = 0;
    for(int i=0;i<26;++i)
        if( f[i] )
        {
            return -1;
        }
    vector<int>v[26];
    for(int i=0;i<s.size();++i)
    {
        v[s[i]-'a'].push_back(i);
    }
    ll ans = 0;
    int index = -1;
    for(int i=0;i<t.size();++i)
    {
        auto it = upper_bound(v[t[i]-'a'].begin(),v[t[i]-'a'].end(),index);
        if( it == v[t[i]-'a'].end() )
        {
            ans+=s.size()-1-index;
            index = -1;
            --i;
        }
        else
        {
            ans+=*it-index;
            index = *it;
        }
        if( index == s.size()-1 )
            index = -1;
    }
    return ans;

}
int main()
{
    cin >> s >> t;
    cout << solve();
}

Measured memory_bytes: 1216
#include<iostream>
#include<cstdlib>
using namespace std;
int return_num(int num,int one_or_zero){
  if(one_or_zero==1) num*=-1;
  return num;
}
char porm(int num){return (num==0)?'+':'-';}
int main(){
  int temp,num[4];
  bool flag=false;
  string s;
  cin >> s;
  for(int i=0;i<4;i++){
    num[i]=s[i]-'0';
  }
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
        temp=num[0];
        temp+=return_num(num[1],i)+return_num(num[2],j)+return_num(num[3],k);
        if(temp==7){
          cout<<num[0]<<porm(i)<<num[1]<<porm(j)<<num[2]<<porm(k)<<num[3];
          cout << "=7"<<endl;
          flag=true;
          break;
        }
      }
      if(flag==true) break;
    }
    if(flag==true) break;
  }
  }


Measured memory_bytes: 256
nums = list(map(int, input().split()))
c1 = nums[4] <= nums[2]
c2 = nums[4] <= nums[3]
c3 = nums[4] + nums[3] <= nums[1]
c4 = nums[4] + nums[2] <= nums[0]
if c1 and c2 and c3 and c4:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 5596
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		for (int j = 0; j < s.size() - 1; j++) {
			if (s[j] == s[j + 1]) {
				cout << "No\n";
				goto end;
			}
		}
		cout << "Yes\n";
	end:;
	}
}

Measured memory_bytes: 3280
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();

        if (A == B) {
            System.out.println(A * 2);
        } else {
            if (A < B) {
                int temp = B;
                B = A;
                A = temp;
            }
            System.out.println((A - 1) + A);
        }
    }
}


Measured memory_bytes: 23124
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

template<typename T> bool is_prime(T n)
{
	if (n == 2)
	{
		return true;
	}
	else if ((n == 1) || (n % 2 == 0))
	{
		return false;
	}

	T p = (T)sqrt(n);
	for (T i = 3; i <= p; i += 2)
	{
		if (n % i == 0)
		{
			return false;
		}
	}

	return true;
}

int main()
{
	vector<int> p(100001);
	int c = 0;
	for (int i = 1; i <= 100000; i++)
	{
		int x = (i + 1) / 2;
		if (is_prime(i) && is_prime(x))
		{
			c++;
		}
		p.at(i) = c;
	}

	int n;
	for (cin >> n; n--; )
	{
		int l, r;
		cin >> l >> r;

		l -= (l < 2) ? 0 : 2;
		cout << p.at(r) - p.at(l) << endl;
	}
}


Measured memory_bytes: 1152
INF = float("inf")
MOD = 10 ** 9 + 7
# ----------

X, N = map(int, input().split())
P = set(map(int, input().split()))

S = set([i for i in range(102)])
S = S - P

ans = -1
diff = INF
for s in sorted(S):
    if abs(s - X) < diff:
        ans = s
        diff = abs(s - X)

print(ans)

Measured memory_bytes: 9224
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    string a,b,c;
    cin>>a>>b>>c;
    int count=0;
    for (int i=0;i<n;i++) {
        if (a[i]!=b[i]&&a[i]!=c[i]&&b[i]!=c[i]) {
            count+=2;
        } else if (a[i]==b[i]&&a[i]!=c[i]) {
            count++;
        } else if (a[i]==c[i]&&a[i]!=b[i]) {
            count++;
        } else if (b[i]==c[i]&&a[i]!=b[i]) {
            count++;
        }
    }
    cout<<count<<endl;
}

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


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

    bool prev = false;
    REP(i, N) {
        if (S[i] == 'x') {
            if (prev) {
                cout << i << endl;
                return 0;
            }
            prev = true;
        } else {
            prev = false;
        }
    }

    cout << N << endl;
}

Measured memory_bytes: 3340
#include <cstdio>
#include <algorithm>

using namespace std;

int m[31],n;

void dfs(int h,int l,int last){
   int i;
   if(l==0){
     for(i=0;i<h;i++)
       printf(i<h-1?"%d ":"%d\n",m[i]);
       return;
   }
   for(i=min(l,last);i>0;i--){
     m[h]=i;
     dfs(h+1,l-i,i);
   }
   return;
}

int main(){
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    dfs(0,n,n);
  }
  return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define init(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, a, b) for (int i = a; i < b; i++)
#define loopr(i, a, b) for (int i = a; i >= b; i--)
#define loops(i, a, b, step) for (int i = a; i < b; i += step)
#define looprs(i, a, b, step) for (int i = a; i >= b; i -= step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie();                        \
    cout.tie();
#define FILE_READ_IN freopen("input.txt", "r", stdin);
#define FILE_READ_OUT freopen("output.txt", "w", stdout);
#define all(a) a.begin(), a.end()
#define ld long double
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int sum = 0;
    while (a != 0 && k != 0)
    {
        sum += 1;
        a--;
        k--;
    }

    while (b != 0 && k != 0)
    {
        b--;
        k--;
    }

    while (c != 0 && k != 0)
    {
        sum = sum - 1;
        c--;
        k--;
    }

    cout << sum << "\n";

    return 0;
}

Measured memory_bytes: 3588
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
long long int lis[300000];
int main(){
    int N,K;
    cin>>N>>K;

    for(int i=0;i<N;i++)cin>>lis[i];
    for(int i=K;i<N;i++){
        if(lis[i-K]<lis[i])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 5188