akhauriyash/Code-Regression huggingface dataset:
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

h = Hash.new(0)
x = 0
a.each {|e| h[(x += e) % m] += 1}
h[0] += 1

p h.inject(0) {|r, (_, v)| r + v * (v - 1) / 2}

Measured memory_bytes: 14596
//BISMILLAHIR RAHMANIR RAHIM
                                               //BY THE NAME OF ALLAH
                                               //FAISAL AHAMMED SHAWON
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#include<set>
#include<map>
#include<iterator>
#include<numeric>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define SQ(a) (a)*(a)
#define pi acos(-1.0)
const int MAX=100001;
const int MOD=1e9+7;
int ara[MAX];
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    else
    gcd(b,a%b);
}
ll lcd(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}

bool f(ll a,ll b)
{
    return a>b;
}
ll max_sum_subarrays(ll ara[],ll n)
{
    ll ans=0,sum=0;
    for(ll k=0;k<n;k++){
        sum=max(ara[k],sum+ara[k]);
        ans=max(ans,sum);
    }
    return ans;
}
ll num_divisors(ll n)
{
    long long cnt=0;
    for(int i=1;i*i<=n;i++)
    {
        if(n%i==0 && i*i==n)
            cnt+=1;
        if(n%i==0 && i*i!=n)
                cnt+=2;
    }
    return cnt;
}
ll comb(ll m, ll n)
{
    ll x = max(m-n,n),ans = 1,i=1;
    for(ll k=m;k>=x+1;k--){
        ans*=k;
        ans/=i;
        i++;
    }
    return ans;
}
ll binsearch(ll low,ll high,ll target)
{
    while(low<=high)
    {
        ll mid=(low+high)/2;
        if(ara[mid]>target)
            high=mid-1;
        else if(ara[mid]<target)
            low=mid+1;
        else return mid;
    }
    return -1;
}

int main()
{
    fast();
    int n;
    cin>>n;
    int ara[n];
    for(int i=0;i<n;i++)
    {
        cin>>ara[i];
    }
    int maxm=ara[0];
    int ans=0;
    for(int i=1;i<n;i++)
    {
        if(maxm>ara[i])
        {
            maxm=ara[i];
            ans++;
        }
    }
    cout<<ans+1<<endl;
}



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

int main(){
    string s;
    cin >> s;
    ll ans = 0;
    for(auto ss : s){
        if(ss == '1')ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
#define PI             acos(-1.0)
#define IOS            ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ms(a,b)         memset(a, b, sizeof(a))
#define filein      freopen("input.txt", "r", stdin);
#define fileout     freopen("output.txt", "w", stdout);
#define debug       cout<<"Hello, i am in here."<<endl;
#define bit_cnt(mask) __builtin_popcountll(mask)
#define ll long long int
#define dst(u,v,x,y) sqrt((x*1.0-u*1.0)*(x*1.0-u*1.0)+(y*1.0-v*1.0)*(y*1.0-v*1.0))
using namespace std;
const int MOD = (int)1e9+7;
/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/
void solve()
{
 ll n;
 cin>>n;
 vector<ll>dp(n+1,1);
 for(ll i=2;i<=n;i++)
 {
   for(ll j=1;j<=n;j++)
   {
     if(i*j>n)break;
     dp[i*j]++;
   }
 }
 ll result=0;
 for(int i=1;i<=n;i++)result+=(i*dp[i]);
 cout<<result<<endl;
}
int  main()
{
    IOS
    solve();
    return 0;
}


Measured memory_bytes: 81292
from heapq import heapify, heappush, heappop
from operator import itemgetter

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    heapify(A)

    query = [list(map(int, input().split())) for _ in range(M)]
    query.sort(key=itemgetter(1), reverse=True)

    for b, c in query:
        for _ in range(b):
            m = heappop(A)
            if m >= c:
                heappush(A, m)
                break
            heappush(A, c)
        else:
            continue
        break
    
    print(sum(A))


if __name__ == "__main__":
    main()

Measured memory_bytes: 35140
#include <stdio.h>

int main(void)
{
    int a = 0, b = 0, c = 0,
        d = 0, e = 0, f = 0,
        g = 0, h = 0, M = 0;

    scanf("%d %d %d", &a, &b, &M);

    g = 2*M - b;
    h = 2*M - a;
    f = 3*M - g - h;
    c = 2*M - f;
    e = 3*M - c - h;
    d = 2*M - e;

    printf("%d %d %d\n", a, b, c);
    printf("%d %d %d\n", d, M, e);
    printf("%d %d %d\n", f, g, h);

    return 0;
}


Measured memory_bytes: 128
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

main = do
  [a, b] <- getIntList
  let diff = a - b
  if odd diff
    then putStrLn "IMPOSSIBLE"
    else print $ b + diff `div` 2


Measured memory_bytes: 3688
N = int(input())
row1 = list(map(int, input().split()))
row2 = list(map(int, input().split()))

candies = []
for n in range(N):
  c1 = sum(row1[0:n + 1])
  c2 = sum(row2[n : N])
  candies.append(c1 + c2)

print(max(candies))

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

using namespace std;

int main() {
        int n,a,b,c,d;
        cin >> n >> a >> b >> c >> d;
        string s;
        cin >> s;
        int temp = 0;
        
        if(c < d){
         for(int i=a-1;i<d-1;i++){
             if(s[i]==s[i+1]&&s[i]=='#'){temp=1;break;}
             
         }
            if(temp)cout <<"No";
            else cout <<"Yes";
            
        }
        if(c > d){
           for(int i = b-1;i<d;i++){
               if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){
                    temp=1;break;}
           }  
          if(temp)cout<<"Yes";
          else cout <<"No";
            
        }
    
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdbool.h>

int ans[1500];
int P, Q, A, N;
int tmpans = 0;

// nume 現在の分子,　deno 現在の分母, x 追加した分母の値, depth 今の再起の深さ(1回目を0としている)
void dps(int nume, int deno, int x, int depth){
    // P/Q < nume/demo ならこれ以上確認しない
    if(P * deno < Q * nume) return;
    // P/Q = nume/demoなら答えに1を追加
    if(P * deno == Q * nume) {tmpans++; return;}
    // 深さの限度に達したら終了
    if(depth == N) return;

    // Aの条件を超えないまで分母の値を増やして再起関数に突っ込む
    for(int i = x; i * deno <= A; i++){
        dps(nume * i + deno, deno * i, i, depth + 1);
    }
}

int main(){
    int i = 0;

    for(i = 0; i < 1500; i++){
        ans[i] = -1;
    }
    i = 0;
    while(true){
        scanf("%d %d %d %d", &P, &Q, &A, &N);
        if(P == 0 && Q == 0) break;
        tmpans = 0;

        // 0/1から始める, 分母の値は1, 初期の深さは0
        dps(0, 1, 1, 0);

        ans[i] = tmpans;
        i++;
    }


    for(int i = 0; i < 1500; i++){
        if(ans[i] != -1) printf("%d\n", ans[i]);
        else break;
    }   

    return 0;
}


Measured memory_bytes: 2064
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,s,t) for(int i=s;i<=(t);++i)
using namespace std;

#define Pr(f,...) ///fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

const int N=4005;

set<int> edg[N]; 
vector<int> g[N];
// lc same rc diff
int del[N],n,deg[N],q,m,e[N][2],ch[N][2],w[N][2],o[N][2],dir[N];

void dfs(int v,int d){
	dir[v]=d;
	if(ch[v][0])dfs(ch[v][0],d^w[v][0]);
	if(ch[v][1])dfs(ch[v][1],d^w[v][1]);
}

void ins(int u,int v,int l=0,int r=0,int wl=0,int wr=0){
	Pr("ins %d,%d,%d,%d,%d,%d\n",u,v,l,r,wl,wr); 
	++m,e[m][0]=u,e[m][1]=v,ch[m][0]=l,ch[m][1]=r,w[m][0]=wl,w[m][1]=wr;
	if(e[m][0]==e[m][1])dfs(m,0);
	else edg[u].insert(m),edg[v].insert(m);
}

void construct(){
	int rem=n,root,adj;
	while(rem>1){
		rep(i,1,n)if(deg[i]==1&&!del[i])root=i;
		for(int d:g[root])if(!del[d])adj=d;
		--deg[adj],del[root]=1,--rem;

		Pr("root=%d,adj=%d\n",root,adj); 
		
		int p=0;
		vector<int> z; for(int i:edg[root])z.pb(i); 
		for(int i:z){
			if(!p){ p=i; continue; }
			int a=e[p][1]==root,b=e[i][1]==root;
			int u=e[p][!a],v=e[i][!b];
			edg[u].erase(p),edg[v].erase(i);
			ins(u,v,p,i,!a,b),p=0;
		}

		if(p){
			int z=(e[p][e[p][1]==root]=adj);
			if(e[p][0]!=e[p][1])edg[z].insert(p); else {
				edg[adj].erase(p); dfs(p,0); }
		}
	}
	for(int i=1;i<=q;++i)printf("%d %d\n",dir[i]?o[i][0]:o[i][1],dir[i]?o[i][1]:o[i][0]);
}

int dep[N],prt[N],cov[N];
void build(int v,int p){
	dep[v]=dep[p]+1,prt[v]=p;
	for(int d:g[v])if(d!=p)build(d,v);
}

void run(int u,int v){
	while(u!=v){
		if(dep[u]<dep[v])swap(u,v);
		++cov[u],u=prt[u];
	}
}

void count(){
	build(1,0); 
	rep(i,1,q){
		run(o[i][0],o[i][1]); 
	}
	int ans=0; 
	for(int i=2;i<=n;++i)ans+=min(2,cov[i]);
	printf("%d\n", ans);
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	freopen("my.out","w",stdout);
#endif
	scanf("%d%d",&n,&q); 	
	rep(i,1,n-1){
		int u,v;
		scanf("%d%d",&u,&v); 
		g[u].pb(v),g[v].pb(u); 
		++deg[u],++deg[v];
	}
	rep(i,1,q){
		scanf("%d%d",&o[i][0],&o[i][1]); 
		ins(o[i][0],o[i][1]);
	}
	count(); 
	construct();
	return 0;
}

Measured memory_bytes: 1024
H,W= map(int,input().split())
alfa = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for h in range(H):
    Ss = list(input().split())
    if "snuke" in Ss:
        print(alfa[Ss.index("snuke")]+str(h+1))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()

template<class T> using V = vector<T>;
template<class T> using V2 = V<V<T>>;


void solve(){
  bool DBG = false;
  int n, m; cin  >> n >> m;
  V<int> a(m), b(m), k(m,0);
  V2<int> c(m);
  FOR(i,0,m){
    cin >> a[i] >> b[i];
    c[i] = V<int>(b[i]);
    FOR(j,0,b[i]) {cin >> c[i][j]; k[i] += (1<<(c[i][j]-1));}
  }
  int INF = 1<<29;
  V2<int> dp(m+1,V<int>((1<<n)+1, INF));
  dp[0][0] = 0;
  FOR(i,0,m){
    FOR(j,0,(1<<n)){
      dp[i+1][j] = dp[i][j];
    }
    FOR(j,0,(1<<n)){
      dp[i+1][j|k[i]] = min(dp[i+1][j|k[i]], dp[i+1][j] + a[i]);
    }
  }
  if(dp[m][(1<<n)-1] < INF) cout << dp[m][(1<<n)-1]  << '\n';
  else cout << -1 << '\n';
  if(DBG){
  FOR(i,0,m+1){
    FOR(j,0,(1<<n)){
      if(dp[i][j]<INF)printf("%02d ",dp[i][j]);
      else printf("oo ");
    }
    printf("\n");
  }
  }
}

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

Measured memory_bytes: 16384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
#define N 222
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int n,G[N][N],ans,dep[N],d[N];
int col[N],vis[N];
char s[N];
queue<int> q;
bool dfs(int u){
	for(int i=1;i<=n;i++){
		if(G[u][i]){
			if(~col[i]){
				if(col[u]==col[i])return false;
			}
			else{
				col[i]=(col[u]^1);
				if(!dfs(i))return false;
			}
		}
	}
	return true;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		scanf("%s",s+1);
		for(int j=1;j<=n;j++){
			G[i][j]=s[j]-'0';
			if(G[i][j]){
				++d[i],++d[j];
			}
		}
	}
	memset(col,-1,sizeof(col));
	col[1]=0;
	if(!dfs(1)){
		return !printf("-1\n");
	}
	for(int S=1;S<=n;++S){
		q.push(S);
		memset(dep,0,sizeof(dep));
		dep[S]=1;
		while(!q.empty()){
			int u=q.front();
			q.pop();
			for(int v=1;v<=n;++v){
				if(!G[u][v]||dep[v])continue;
				dep[v]=dep[u]+1;
				ans=max(ans,dep[v]);
				q.push(v);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define ALL(v) (v).begin(), (v).end()
#define SZ(v) ((int)(v).size())
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1);

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

int main(void) {
    int n;
    cin >> n;
    map<string, int> dic;
    rep(i, n) {
        string s;
        cin >> s;
        dic[s]++;
    }
    int ma = 0;
    for (auto &&i : dic) {
        chmax(ma, i.second);
    }
    vector<string> ans;
    for (auto &&i : dic) {
        if (i.second == ma) {
            ans.push_back(i.first);
        }
    }
    sort(ALL(ans));
    for (auto &&i : ans) {
        cout << i << endl;
    }


    return 0;
}

Measured memory_bytes: 26868
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    COMinit();
    int N, K;
    ll ans = 0,tmp=0;
    cin >> N >> K;
    if(N>K)
    {
    rep2(i,1,K+1)
    {
        cout<< (COM(K-1, i - 1) * (COM(N - K-1, i) + 2 * COM(N - K-1, i - 1) + COM(N - K-1, i - 2))) % MOD << endl;
    }
    }
    else
    {
        rep2(i,1,K+1)
        {
            if(i!=1)
                cout << 0 << endl;
                else
                {
                    cout << 1 << endl;
                }
        }
    }
    
    return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0)cout << "Possible" << endl;
    else cout << "Impossible" << endl;

    return 0;
}


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

#define rep(i,s,n) for(int i=(s);i<(n);i++)

using namespace std;

int main ( void ){
	while(true){
		// 列車本数の入力
		int n;
		cin >> n;
		//0なら終了
		if(n==0) break;

		//時刻表を保存するためのmap
		//keyに時間(string)，valueに発車(1)か到着(-1)のmultiset
		//同一時間に出発，発着があり得るため，setではなくmultiset
		//また後の処理で到着の方を優先する必要があるため到着が先頭に来るように
		//到着を-1で出発を1としてソートする．
		map<string,multiset<int> > timetable;

		//n回の入力に対して
		rep(i,0,n){
			// 入力用文字列 電車の出発・到着時間
			string time;
			//まず出発時間を取得
			cin >> time;
			//出発時間に対して出発を示す(1)を挿入
			timetable[time].insert(1);
	
			//到着時間を取得
			cin >> time;
			//到着時間に対して到着を示す(-1)を挿入
			timetable[time].insert(-1);
		}
	
		//必要な台数を保持しておく,cntを用意する
		int cnt=0;
		//もっとも必要になった時間を保持するmaxNofCar
		int maxNofCar=0;

		//入力された時刻表を先頭から走査する
		for(map<string,multiset<int> >::iterator it=timetable.begin();it!=timetable.end();it++){
			//同一時間のものは到着から処理する
			for(multiset<int>::iterator it2=(*it).second.begin();it2!=(*it).second.end();it2++){
				//必要な台数に対して到着したなら -1 出発したなら +1 を足す
				cnt+=(*it2);
				//その際の最大値を保持する
				maxNofCar=maxNofCar<cnt?cnt:maxNofCar;
			}
		}
		//解を出力
		cout << maxNofCar << endl;
	}
}

Measured memory_bytes: 4660
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n, k;
    cin >> n >> k;
    vector<bool> A(n + 1, false);
    rep(i, k) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            A[a] = true;
        }
    }
    int ans = 0;
    rrep(i, n) {
        if(A[i] == false) ans++;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    int a, b; cin >> a >> b;
    int ans=0;
    int out = 1;
    while(out < b){
        out--;
        out += a;
        ans++;
    }
    cout << ans;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int div2(int i)
{
  int cnt=0;
  while(i%2==0)
  {
    i/=2;
    cnt++;
  }
  return cnt;
}

int main()
{
  int n;
  cin>>n;
  if(n==1)
  {
    cout<<1<<endl;
    return 0;
  }

  vector<int> dp(n+10,0);
  for (int i = 1; i <= n; ++i)
  {
    dp[i]=div2(i);
  }

  cout<<(max_element(dp.begin(),
   dp.end())-dp.begin())<<endl;
}

Measured memory_bytes: 3564
x1, y1, x2, y2 = gets.split.map(&:to_i)
dy = y1 - y2
dx = x2 - x1
x3 = x2 + dy
y3 = y2 + dx
x4 = x1 + dy
y4 = y1 + dx
puts [x3, y3, x4, y4].join(" ")

Measured memory_bytes: 1916
def f(A): return A.count(a)>1
R=[0,3,6]
N=range(9)
Z=[0]*9

n=input()
while n:
  F=[[" " for _ in Z] for _ in Z]
  M=[map(int,raw_input().split()) for _ in Z]
  M1=[[M[y][x] for y in N] for x in N]
  M2=[M[y][x:x+3]+M[y+1][x:x+3]+M[y+2][x:x+3] for y in R for x in R]
  for y in N:
    A=M[y]
    p0=y/3*3
    for x in N:
      p=p0+x/3
      a=A[x]
      if any(map(f,[A,M1[x],M2[p]])): F[y][x]="*"
    print "".join([a+b for a,b in zip(F[y],map(str,A))])
  if n>1: print
  n-=1

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

int main()
{
	char b;
	cin >>b;
	if(b=='A'){
		cout <<'T';
	}else if (b=='T'){
		cout <<'A';
	}else if(b=='C'){
		cout <<'G';
	}else if(b=='G'){
		cout <<'C';
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n,a[200010];
bool check(int k){
    if((a[n-1]<=k&&a[n]<=k)||(a[n]<=k&&a[n+1]<=k)) return 1;
    if((a[n-1]>k&&a[n]>k)||(a[n]>k&&a[n+1]>k)) return 0;
    for(int i=1;i<n-1;i++){
        if((a[n+i]<=k&&a[n+i+1]<=k)||(a[n-i]<=k&&a[n-i-1]<=k)) return 1;
        if((a[n+i]>k&&a[n+i+1]>k)||(a[n-i]>k&&a[n-i-1]>k)) return 0;
    }
    return a[1]<=k;
}
int main(){
    cin>>n;
    for(int i=1;i<n<<1;i++) scanf("%d",a+i);
    int l=1,r=(n<<1)-1;
    int ans=0;
    while(l<r){
        int mid=(l+r)/2;
        if(check(mid)){
            r=mid;ans=mid;
        }
        else l=mid+1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1152
s = input()
k = int(input())
# Tyou = 5000000000000000

s_arr = [int(i) for i in s]

one = 0
num = 0
for i in range(len(s_arr)):
    if s_arr[i] == 1:
        one += 1
    else:
        num = s_arr[i]
        break

if k <= one:
    print(1)

else:
    print(num)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

void Calc() {
  string s = in;
  ll k = in;

  for (auto& i : s) {
    if (i != 'a' && 'z' < i + k) {
      k -= ('z' - i + 1);
      err(k);
      i = 'a';
    }
  }
  for (auto& i : s) {
    if (i == 'a') {
      k %= 'z' - 'a' + 1;
      break;
    }
  }
  assert(k <= 'z' - 'a' + 1);
  s.back() += k;
  cout << (s) << endl;
}


Measured memory_bytes: 640
package main

import (
  "fmt"
  "math"
  "sort"
)

func main() {
  var n int
  fmt.Scan(&n)
  p := Points{}
  for i:=0;i<n;i++ {
    var x,y float64
    fmt.Scan(&x,&y)
    p = append(p,Point{x,y,i})
  }
  h := p.GetHull()
  var f []float64 = make([]float64,n)
  var m int = h.Len()
  if m == 1 {
    for i:=0;i<n;i++ {
      p[i].x,p[i].y = -p[i].y,p[i].x
    }
    h = p.GetHull()
    m = h.Len()
  }
  f[h[0].id] = (math.Pi-h[0].angle(h[1],h[m-1]))/(2*math.Pi)
  f[h[m-1].id] = (math.Pi-h[m-1].angle(h[0],h[m-2]))/(2*math.Pi)
  for i:=1;i<m-1;i++ {
    f[h[i].id] = (math.Pi-h[i].angle(h[i+1],h[i-1]))/(2*math.Pi)
  }
  for i:=0;i<n;i++ { fmt.Printf("%.10f\n",f[i]) }
}

type Point struct {
  x,y float64
  id int
}
func(p Point) equals(t Point) bool { return p.x == t.x && p.y == t.y }
func(p Point) angle(sta Point,end Point) float64 {
  ax := sta.x - p.x
  bx := end.x - p.x
  ay := sta.y - p.y
  by := end.y - p.y
  return math.Atan2(ax*by-ay*bx,ax*bx+ay*by)
}
func(p Point) distance(t Point) float64 {
  dx := p.x - t.x
  dy := p.y - t.y
  return math.Sqrt(dx*dx+dy*dy)
}
type Points []Point
func(ps Points) Len() int { return len(ps) }
func(ps Points) Swap(i,j int) { ps[i],ps[j] = ps[j],ps[i] }
func(ps Points) Less(i,j int) bool {
  if ps[i].x == ps[j].x {
    if ps[i].y == ps[j].y { return ps[i].id < ps[j].id }
    return ps[i].y < ps[j].y
  }
  return ps[i].x < ps[j].x
}
func(ps Points) GetHull() Points {
  sort.Sort(sort.Reverse(ps))
  now := ps[0]
  prv := Point{now.x,now.y-1,-1}
  hull := Points{now}
  for {
    var minagl,maxdst float64
    minagl = 2*math.Pi
    maxdst = 0
    nxt := ps[0]
    for _,p := range ps {
      if p.equals(now) { continue }
      var angle,dstnc float64
      angle = now.angle(prv,p)
      dstnc = now.distance(p)
      if angle < 0 { angle += 2*math.Pi }
      if angle < minagl && angle >= math.Pi {
        minagl = angle
        nxt = p
        maxdst = dstnc
      } else if angle == minagl && dstnc > maxdst {
        nxt = p
        maxdst = dstnc
      }
    }
    if nxt.equals(hull[0]) { break }
    hull = append(hull,nxt)
    prv = now
    now = nxt
  }
  return hull
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};
const int mod = 1000000007;

void Main(){
  ll a,b;
  cin>>a>>b;
  if(a==1 or b==1){
    cout<<1<<endl;
  }else{
    cout<<dup(a*b,2)<<endl;
  }



} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,k,j=1,m;
int i,l;
int main()
{
	cin>>n>>k;
	for(i=1;i<=n;i++)
	{
		j*=2;
		if(j>=k)
		break;

	}
	if(i<n)
	l = k*(n-i);
	j+=l;
	cout<<j<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#define	MOD  1000000007;
using namespace std;

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

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

	int x1 = 0;
	int x2 = W;
	int y1 = H;
	int y2 = 0;
	for (int i = 0; i < N; i++)
	{
		switch (a[i])
		{
		case 1:if (x1 < x[i]) { x1 = x[i]; }; break;
		case 2:if (x2 > x[i]) { x2 = x[i]; }; break;
		case 3:if (y2 < y[i]) { y2 = y[i]; }; break;
		case 4:if (y1 > y[i]) { y1 = y[i]; }; break;
		}


	}
	if (x1 < x2 && y1 > y2)
	{
		cout << (x2 - x1) * (y1 - y2) << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// atcoder/abc179/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n;
  while (cin >> n) {
    vec<pair<int, int>> v(n);
    cin >> v;

    bool f = false;
    for (int i = 0; i + 2 < v.size(); ++i) {
      f = f || (v[i].first == v[i].second && v[i + 1].first == v[i + 1].second && v[i + 2].first == v[i + 2].second);
    }
    cout << (f ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;
int n,m,d[5000][5000],dd[5000];
vector<int> v[5000];
P a[5000];

void bfs(int s) {
  queue<int> que;
  for(int i=0; i<n; i++) d[s][i]=1<<29;
  d[s][s]=0;
  que.push(s);
  while(!que.empty()) {
    int x=que.front();que.pop();
    for(int i=0; i<v[x].size(); i++) {
      int y=v[x][i];
      if(d[s][y]>d[s][x]+1) {
        d[s][y]=d[s][x]+1;
        que.push(y);
      }
    }
  }
  for(int i=0; i<n; i++) {
    if(s==i) continue;
    if(d[s][i]<=a[s].S) d[s][i]=a[s].F;
    else d[s][i]=1<<29;
  }
}

int main() {
  cin >> n >> m;
  for(int i=0; i<n; i++) cin >> a[i].F >> a[i].S;
  for(int i=0; i<m; i++) {
    int x,y;
    cin >> x >> y;
    x--,y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for(int i=0; i<n; i++) bfs(i);
  fill(dd,dd+n,1<<29);
  dd[0]=0;
  priority_queue<P,vector<P>,greater<P> > que;
  que.push(P(0,0));
  while(!que.empty()) {
    P p=que.top();que.pop();
    int x=p.S,c=p.F;
    if(x==n-1) break;
    if(dd[x]>c) continue;
    for(int y=0; y<n; y++) {
      if(dd[y]>dd[x]+d[x][y]) {
        dd[y]=dd[x]+d[x][y];
        que.push(P(dd[y],y));
      }
    }
  }
  cout << dd[n-1] << endl;
  return 0;
}


Measured memory_bytes: 101332
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

inline string chmax(string &lhs, string rhs) {

	//sort(rhs.begin(), rhs.end(), greater<char>());
	if (lhs.size() > rhs.size()) return lhs;
	else if (lhs.size() < rhs.size()) return rhs;
	else return lhs > rhs ? lhs : rhs;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	vector<int> m_num({ 2,5,5,4,5,6,3,7,6 });
	vector<int> A(M);
	for (int i = 0; i < M; i++) cin >> A[i];

	vector<string> dp(N + 1);
	int idx;
	for (int m = 0; m <= N; m++) {
		for (int i = 0; i < M; i++) {

			idx = m - m_num[A[i] - 1];
			if (idx >= 0 && (dp[idx] != "" | idx == 0)) {
				dp[m] = chmax(dp[m], dp[idx] + to_string(A[i]));
			}

		}
	}

	cout << dp[N] << "\n";

	return 0;
}

Measured memory_bytes: 32000
def ABC67_B():
    N, K = LI()
    L = LI()
    L.sort(reverse=True)
    ans = sum(L[:K])
    print(ans)
    return

def ABC100_C():
    def factorization_2(n):
        arr = defaultdict(int)
        temp = n
        i = 2
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
        if temp != 1:
            arr[temp] = 1
        if arr == []:
            arr[n] = 1
        return arr[2]
    N = I()
    A = LI()
    ans = 0
    for a in A:
        ans += factorization_2(a)
    print(ans)
    return

def ARC68_C():
    X = I()
    ans = 0
    ans += 2*(X//11)
    rest = X%11
    if rest>0:
        ans += 1
    if rest>=7:
        ans += 1
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    ARC68_C()

"""

"""

Measured memory_bytes: 3956
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
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; }
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;
// const ll k=998244353;

const ll MAX = 510000;
const ll MOD =998244353;



int main(){

  int n;cin>>n;
  string s;cin>>s;

  if(n%2==1){
    out("No");
    return 0;
  }
  else{
    rep(i,0,n/2){
      if(s[i]==s[i+n/2]){}
      else {
        out("No");
        return 0;
      }

    }

  }

  out("Yes");

  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var n, m, ans int
	var k [30]int
	var array [30]int
	fmt.Scanf("%d %d", &n, &m)
	for i := 0; i < n; i++ {
		k[i] = nextInt()
		for j := 0; j < k[i]; j++ {
			a := nextInt()
			a--
			array[a]++
		}
	}

	for _, a := range array {
		if a == n {
			ans++
		}
	}

	fmt.Println(ans)

}


Measured memory_bytes: 1844
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define nl '\n'
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int M = 1e9+7;
const int N = 2*1e5;



int main(){
    AC
    string s;
    cin>>s;
    ll ans = 0;
    ll res = 0;
    ll p = 1;
    map<ll, int> freq;
    for(int i=s.size()-1; i>=0; i--){
        res = (res + (s[i]-'0')*p)%2019;
        ans+=freq[res];
        if(res==0)
            ans++;
        freq[res]++;
        p = (p*10)%2019;
    }
    cout<<ans<<endl;
}

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

struct UnionFind {
  vector<int> r;

  UnionFind(int N) {
    r = vector<int>(N, -1);
  }

  int getRoot(int x) {
    if (r[x] < 0) return x;
    return r[x] = getRoot(r[x]);
  }

  /**
   * 指定の2頂点が属する木が同じか
   */
  bool belongTo(int x, int y) {
    int rx = getRoot(x);
    int ry = getRoot(y);
    return rx == ry;
  }

  void unite(int x, int y) {
    int rx = getRoot(x);
    int ry = getRoot(y);
    if (rx == ry) return;

    r[rx] += r[ry];
    r[ry] = rx;
  }

  int size(int x) {
    return -r[getRoot(x)];
  }
};

int main() {
  int N,M,x,y,i,ans=0;
  cin>>N>>M;
  UnionFind UF(N);
  vector<int> p(N);
  for (i=0;i<N;i++) cin>>p[i];
  for (i=0;i<M;i++) {
    cin>>x>>y;
    UF.unite(x-1, y-1);
  }
  for (i=0;i<N;i++) {
    if (p[i]-1 == i || UF.belongTo(i,p[i]-1)) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3612
n, m = map(int, input().split())
ab = []
cd = []
for i in range(n):
    ab.append(list(map(int, input().split())))
for i in range(m):
    cd.append(list(map(int, input().split())))
for i in ab:
    m_d = 10 ** 9
    m_n = 0
    for k, j in enumerate(cd):
        if abs(i[0] -j[0]) + abs(i[1] - j[1]) < m_d:
            m_d = abs(i[0] -j[0]) + abs(i[1] - j[1])
            m_n = k + 1
    print(m_n)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}

	gcd(b, a % b);
}

int main()
{
	/*int a, b;
	cin >> a >> b;
	int ans = 6 - a - b;
	cout << ans;*/


	/*int n;
	string s, t;
	cin >> n >> s >> t;
	string ans;
	rep(i, n) {
		ans += s[i];
		ans += t[i];
		
	}
	cout << ans;*/


	/*ll a, b;
	cin >> a >> b;
	ll ans = a * b / gcd(a, b);
	cout << ans;*/


	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n)cin >> a[i];
	int ans = 0;
	int x = 1;
	rep(i, n) {
		if (a[i] == x) {
			ans++;
			x++;
		}
	}
	if (ans == 0)puts("-1");
	else cout << n - ans;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int n,l,r,ans;
int main()
{
	cin >> n;
	for (int i = 1;i <= n;i++)
	{
		cin >> l >> r;
		ans += r-l+1;
	}
	cout << ans << endl;
	return 0;
}

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

const int MOD = 1e9 + 7;
typedef long long ll;

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

  ll ans;
  if (abs(N - M) >= 2) {
    ans = 0;
  } else {
    ans = 1;
    for (int i = N; i > 1; i--) {
      ans *= i;
      ans %= MOD;
    }
    for (int i = M; i > 1; i--) {
      ans *= i;
      ans %= MOD;
    }
    if (N == M) {
      ans *= 2;
      ans %= MOD;
    }
  }

  // 解答
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    mx = 0
    cnt = 0
    for _ in range(n):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        if mx < cnt:
            mx = cnt
    if 3 <= mx:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9184
#include <stdio.h>
int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x>=-100 && x<=100 && y>=-100 && y<=100){
		if(W>0 && W<=100 && H>0 && H<=100 && r>0 && r<=100){
			if((x-r)>=0 && (x+r)<=W){
				if((y-r)>=0 && (y+r)<=H){
					printf("Yes\n");
				}else{
					printf("No\n");
				}
			}else{
				printf("No\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1820
public class Main {
  public static void main(String[] args) {
      java.util.Scanner scanner = new java.util.Scanner(System.in);
       int n = scanner.nextInt();
       int k = scanner.nextInt();
				  int result = Integer.MAX_VALUE;
				  for (int i = 0; i <= n; i++) {
					  int tmp =  (int) Math.pow(2, i) + k * (n - i);
					  if (tmp < result) {
						  result = tmp;
					  }
				  }
				  System.out.println(result);


 }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+9;
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int s,w;
    cin>>s>>w;
    cout<<(w>=s?"unsafe":"safe");
    
    
    

    return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
	int n, ans = 0;
	cin >> n;
	string s;
	cin >> s;
	for (int i = 0; i < n - 2; i++){
		if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C'){
			ans ++;
		}
	}		
	cout << ans;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        long[] bitcount = new long[60];
        long[] a = new long[n];
        for(int i=0;i<n;i++)a[i] = fs.nextLong();

        for(int i=0;i<60;i++){
            for(int j=0;j<n;j++){
                if(((a[j]>>i)&1)==1)bitcount[i]++;
            }
        }
        int mod = 1000000007;
        long res = 0;
        for(int i=0;i<60;i++){
            res+=((1L<<i)%mod)*((bitcount[i])*(n-bitcount[i])%mod);
            res%=mod;
        }
        System.out.println(res);
    }
    static class FastScanner{
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte(){
            if(ptr < buflen){
                return true;
            }else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen <= 0){
                    return false;
                }
            }
            return true;
        }

        private int readByte(){
            if(hasNextByte())return buffer[ptr++];
            else return -1;
        }

        private boolean isPrintableChar(int c){
            return 33<=c && c<=126;
        }

        public boolean hasNext(){
            while(hasNextByte() && !isPrintableChar(buffer[ptr]))ptr++;
            return hasNextByte();
        }

        public String next(){
            if(!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)){
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong(){
            if(!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if(b == '-'){
                minus = true;
                b = readByte();
            }
            if(b < '0' || '9' < b){
                throw new NumberFormatException();
            }
            while(true){
                if('0' <= b && b<='9'){
                    n*=10;
                    n+=b-'0';
                }else if(b==-1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt(){
            long nl = nextLong();
            if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)throw new NumberFormatException();
            return (int)nl;
        }
        public double nextDouble(){return Double.parseDouble(next());}
    }
}

Measured memory_bytes: 29920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
int main(){
    int n;cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    int mx=0;
    int num=-1;
    bool allP=true;
    bool allM=true;
    for(int i=0;i<n;i++){
        if(a[i]<0) allP=false;
        else if(a[i]>0) allM=false;
        if(abs(a[i])>abs(mx)){
            mx=a[i];
            num=i+1;
        }
    }
    //cout << mx << " " << endl;
    vector<P> ans;
    if(mx==0){
        cout << 0 << endl;
        return 0;
    }
    if(allP){
        for(int i=1;i<n;i++) ans.push_back({i,i+1});
        cout << n-1 << endl;
        for(int i=0;i<(int)ans.size();i++) cout << ans[i].first << " " << ans[i].second << endl;
    }
    else if(allM){
        for(int i=n;i>=2;i--) ans.push_back({i,i-1});
        cout << n-1 << endl;
        for(int i=0;i<(int)ans.size();i++) cout << ans[i].first << " " << ans[i].second << endl;
    }
    else{
        int cnt=0;
        if(mx<0){
            for(int i=0;i<n;i++){
                if(a[i]>0){
                    ans.push_back({num,i+1});
                    cnt++;
                }
            }
            for(int i=n;i>=2;i--) ans.push_back({i,i-1});
            cnt+=n-1;
            cout << cnt << endl;
            for(int i=0;i<(int)ans.size();i++) cout << ans[i].first << " " << ans[i].second << endl;
        }
        else{
            //cout << "kitayo" << endl;
            for(int i=0;i<n;i++){
                if(a[i]<0){
                    ans.push_back({num,i+1});
                    cnt++;
                }
            }
            //cout << cnt << endl;
            for(int i=1;i<n;i++) ans.push_back({i,i+1});
            cnt+=n-1;
            cout << cnt << endl;
            for(int i=0;i<(int)ans.size();i++) cout << ans[i].first << " " << ans[i].second << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<stdio.h>
int x;
char c;
inline int read()
{
    x=0; c=getchar();
    while(c<'0'||c>'9') c=getchar();
    while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
    return x;
}
int main(void)
{
    long n = read(), ans = n;
    for (int i = 1; i < n; ++i)
    {
        int u = read(), v = read();
        switch(u > v)
        {
            case true: ans += i * (n - i + 1) - v * (n - u + 1); break;
            default: ans += i * (n - i + 1) - u * (n - v + 1);
        }
    }
    printf("%ld", ans);
    return 0;
}


Measured memory_bytes: 1604
def dis(p,q)
    return ((p[0]-q[0])**2+(p[1]-q[1])**2)
end

n=gets.to_i
ps=[]
n.times do
    ps.push(gets.split.map(&:to_i))
end
ps.sort!{|a,b|a[0]<=>b[0]}
res=[]
for i in 0..n-2
    res.push(dis(ps[i],ps[i+1]))
end
ps.sort!{|a,b|a[1]<=>b[1]}
for i in 0..n-2
    res.push(dis(ps[i],ps[i+1]))
end
p res.min


Measured memory_bytes: 50684
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    if (N % 10 == 9 || N / 10 == 9){
        puts("Yes");
    }else{
        puts("No");
    }
}


Measured memory_bytes: 256
struct Scanner {
    private var elements = [String]()
    private var index = 0

    mutating func peek() -> String {
        while elements.count == index {
            elements = readLine()!.split(separator: " ").map(String.init)
            index = 0
        }
        return elements[index]
    }

    mutating func next() -> String {
        let value = peek()
        index += 1
        return value
    }

    mutating func nextInt() -> Int {
        return Int(next())!
    }

    mutating func nextDouble() -> Double {
        return Double(next())!
    }
}

var scanner = Scanner()
let S = [Character](scanner.next())

if S[0] == "R" && S[1] == "R" && S[2] == "R" {
    print(3)
} else if S[0] == "R" && S[1] == "R" || S[1] == "R" && S[2] == "R" {
    print(2)
} else if S[0] == "R" || S[1] == "R" || S[2] == "R" {
    print(1)
} else {
    print(0)
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    llint x;
    cin >> x;

    llint tmp = 100, ans = 0;
    while(tmp<x) {
        ans++;
        tmp *= 1.01;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<bool> present(8);
    long high_achievers = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] >= 3200) {
            high_achievers++;
        } else {
            present[a[i] / 400] = true;
        }
    }
    long lo, hi;
    long c = count(present.begin(), present.end(), true);
    if (c > 0) {
        lo = c;
        hi = c + high_achievers;
    } else {
        lo = 1;
        hi = high_achievers;
    }

    cout << lo << " " << hi << endl;
    return 0;
}

Measured memory_bytes: 384