akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

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

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


int main() {
    long double n,m,d;
    cin >> n >> m >> d ;

    if(d==0){
        printf("%.12Lf\n",(m-1)/n);
    } else {
        printf("%.12Lf\n",(n-d)*2/(n*n)*(m-1));
    }

    return 0;
}

Measured memory_bytes: 256
#if 0
2019.12.15

假设 l, r 的最高位 (k) 相同，那么 [l, r] 内的数的或的第 k 位一定为 1 。
那么第 k 位无需考虑，也就是说 l, r 可以去掉一些位直到 r 的最高位为 1 且 l 最高位为 0 。
设此时的位数为 k ，有 l < 2^k <= r 。

1) [l, 2^k) 内的数的或的集合恰好也是 [l, 2^k) ，因为两个数的或不会小于其中任意一个数。

2) [2^k, r] 内的数的或的集合是 [2^k, 2^k + 2^d) ，其中 d 是 r 去掉第 k 位后的最小的前导零。

3) 考虑 [l, 2^k) 和 [2^k, r] 之间的或，
也就是 [l, 2^k) 和 [2^k, 2^k + 2^d) 分别选一个数得到的或的集合，
前者的第 k 位一定是 0 但是后者在该位上为 1 ，
因此就是 [2^k + l, 2^(k+1)) 和 [2^k, 2^k + 2^d) 的或的集合，
根据 1) 可以知道这部分或的集合是 [2^k + l, 2^(k+1)) 。

将三者的或的集合并起来求大小即可，总复杂度可以做到 O(1) 。
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;
typedef unsigned long long ull;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int main() {
	ll l = read, r = read;

	if(l == r) return puts("1"), 0;

	int k = 63 - __builtin_clzll(ull(l ^ r));

	/* debug("%d\n", k); */

	l &= (2ll << k) - 1;
	r &= (2ll << k) - 1;

	/* debug("%lld %lld\n", l, r); */

	int d = r == (1ll << k) ? 0 : 64 - __builtin_clzll(ull(r ^ (1ll << k)));

	/* debug("%d\n", d); */

	ll l1 = l, r1 = (1ll << k) + (1ll << d) - 1;
	ll l2 = (1ll << k) + l, r2 = (1ll << k << 1) - 1;

	/* debug("%lld %lld %lld %lld\n", l1, r1, l2, r2); */

	if(l2 <= r1) printf("%lld\n", r2 - l1 + 1);
	else printf("%lld\n", r2 - l2 + r1 - l1 + 2);
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder {
    class MainClass {
        public static void Main(string[] args) {

            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            int ans = 0;

            for(int i = 0; i <= n -3; i++) {

                if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {

                    ans++;

                }

            }

            Console.WriteLine(ans);

        }

        
    }
}

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

int main() {
    std::string str[3];

    for(int i = 0; i < 3; ++i) {
        std::cin >> str[i];
    }

    for(int i = 0; i < 3; ++i) {
        std::cout << str[i][i];
    }

    std::cout << "\n";
}

Measured memory_bytes: 3616
n = int(input())
if 1 <= n <= 9:
    print(n)
elif 10 <= n <= 99:
    print(9)
elif 100 <= n <= 999:
    print(n-90)
elif 1000 <= n <= 9999:
    print(909)
elif 10000 <= n <= 99999:
    print(n-9090)
else:
    print(90909)

Measured memory_bytes: 38384
import java.util.*;
import java.io.*;
 
public class Main {
    
    static int m;
    static int n;
    static ArrayList<Integer>[] next;
    static boolean[] dp;
    static int[] count;
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        //StringTokenizer st=new StringTokenizer(br.readLine());
        n=Integer.parseInt(br.readLine());
        System.out.println((n<1200) ? "ABC":"ARC");
    }
    
}


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

int main() {
  int n;
  cin >> n;
  string s;
  cin >>s;
  int k;
  cin >>k;
  int tmp = s.at(k-1);
  for (int i = 0; i < n; i++) {
    if(s.at(i) != tmp) {
      s.at(i) = '*';
    }
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
  par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
  vector<int> gt;
  aa(int n){
  gt= vector<int>(n, 1);
  }
  void c(V<int> d,int b){
  if(d[b]==0){
    gt[d[b]-1]++;
    gt[gt.sz-1]++;
  }
  else{
    gt[d[b]-1]++;
    c(d,d[d[b]]-1);
  }
}
void cok(int a){
  cout<<gt[a-1]<<endl;
  fo(i,a-1)
  cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
  int h;
  cin>>h;
  
  int a=0;
  while(h>0){
    h/=2;
    a++;
  }
  int b=0;
  b=pow(2,a);
  cout<<b-1<<endl;
}


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

int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A+B-C-D<0)cout<<"Right"<<endl;
  else if(A+B-C-D==0)cout<<"Balanced"<<endl;
  else cout<<"Left"<<endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 2e18;

signed main() {
    int H, W, N;
    cin >> H >> W >> N;
    vector<set<int>> check(W + 1);
    for (int i = 1; i <= W; i++) check[i].insert(H + 1);
    for (int i = 0; i < N; i++) {
        int X, Y;
        cin >> X >> Y;
        check[Y].insert(X);
    }
    int ans = INF, custom = 0;
    for (int i = 1; i <= W && i + custom <= H; i++) {
        int dist = *check[i].lower_bound(i + custom);
        if (dist == i + custom) {
            --i;
            custom++;
            continue;
        }
        // cout << i + custom << " " << i << " " << dist << endl;
        ans = min(ans, dist - 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 28416
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//mint型にキャスト
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(ll n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint 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];
}
template<typename T>
map<T,ll> factorize(T x){
	map<T,ll> res;
	for(ll i=2;i*i<=x;i++){
		while(x%i==0){
			x/=i;
			res[i]++;
		}
	}
	if(x!=1) res[x]++;
	return res;
}
int main(){
    ll n,m;
    cin>>n>>m;
    map<ll,ll> mp=factorize(m);
    mint ans=1;
    init();
    for(auto p:mp){
        ans*=COM(n+p.se-1,p.se);
    }
    cout<<ans<<"\n";
}

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long mod = 1000000007;
// auto mod int
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main(){
    int s;
    cin >> s;
    vector<mint> dp(s+1);
    rep1(i, s) {
        if (i<=2) continue;
        if (i-3<0) continue;
        dp[i] = 1;
        for (int j=3; i-j>=0; ++j) {
            dp[i] += dp[i-j];
        }
    }
    cout << dp[s] << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
const   int MaxN=1e5+5;
int n,a[MaxN],f[MaxN];

void Xuli()
{
    f[1]=0;
    for(int i=2;i<=n;i++)
    {
        if (i>=1) f[i]=f[i-1]+abs(a[i]-a[i-1]);
        if (i>2) f[i]=min(f[i],f[i-2]+abs(a[i]-a[i-2]));
    }
    printf("%d",f[n]);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    Xuli();
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
  int n; cin>>n;
      if(n >= 400 && n <= 599)
            cout<<8<<endl;
        else if(n >= 600 && n <= 799)
            cout<<7<<endl;
        else if(n >= 800 && n <= 999)
            cout<<6<<endl;
        else if(n >= 1000 && n <= 1199)
            cout<<5<<endl;
        else if(n >= 1200 && n <= 1399)
             cout<<4<<endl;
        else if(n >= 1400 && n <= 1599)
             cout<<3<<endl;
        else if(n >= 1600 && n <= 1799)
            cout<<2<<endl;
        else if(n >= 1800 && n <= 1999)
            cout<<1<<endl;
        else
            cout<<-1<<endl;
     return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> piipi;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back
char s[100005];
int main(){
    scanf("%s", s+1);
    int n = strlen(s+1);
    if(s[1] == s[n]){
        if((n-2)%2) printf("Second\n");
        else printf("First\n");
    }
    else{
        if((n-2)%2) printf("First\n");
        else printf("Second\n");   
    }
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
#define pb push_back
#define fi0(i,n) for(int i=0; i<n; i++)
#define fi1(i,n) for(int i=1; i<n; i++)
#define fll0(i,n) for(long long i=0; i<n; i++)
#define fll1(i,n) for(long long i=1; i<n; i++)
#define vll vector<long long>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define N 1000000000000000000
int main()
  {
  	ld a,b;
  	cin>>a>>b;
  	ld x=a*b;
  	ll y=(ll)x;
  	cout<<y<<endl;
  }

Measured memory_bytes: 3728
n = int(input())
a = [0] + list(map(int, input().split()))
def max_heapify(a, i):
    global n
    l = 2 * i
    r = 2 * i + 1
    largest = l if l <= n and a[l] > a[i] else i
    if r <= n and a[r] > a[largest]:
        largest = r
    if largest != i:
        a[largest], a[i] = a[i], a[largest]
        max_heapify(a, largest)

for i in range(int(n / 2), 0, -1):
    max_heapify(a, i)
    
print(" " + " ".join(map(str, a[1:])))


Measured memory_bytes: 64172
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
int winner(const int depth, int from, int until, const std::vector<std::vector<int>>& calculated, const std::string& state) {
	const auto length = 1 << depth;
	if (from + length == until && (calculated.front().size() <= from || until <= calculated.front().size())) 
		return calculated.front().size() <= from ? calculated[depth][from - calculated.front().size()] : calculated[depth][from];
	const auto a = winner(depth - 1, from, from + (length >> 1), calculated, state);
	const auto b = winner(depth - 1, from + (length >> 1), until, calculated, state);
	const auto x = std::min(a, b);
	const auto y = std::max(a, b);
	return state[y - x - 1] == '0' ? x : y;
}
int main() {
	int n; std::cin >> n;
	std::string str; std::cin >> str;
	std::vector<int> permutation(1 << n);
	for (auto& p : permutation) std::cin >> p;
	std::vector<std::vector<int>> calculated;
	calculated.push_back(permutation);
	for (auto d = 0; d < n; ++d) {
		std::vector<int> winner; winner.reserve(calculated.back().size() >> 1);
		const auto length = 1 << calculated.size();
		for (auto i = 0; i + length <= permutation.size(); ++i) {
			const auto x = std::min(calculated.back()[i], calculated.back()[i + (length >> 1)]);
			const auto y = std::max(calculated.back()[i], calculated.back()[i + (length >> 1)]);
			if (str[y - x - 1] == '0') 
				winner.push_back(x);
			else 
				winner.push_back(y);
		}
		calculated.push_back(winner);
	}
	for (auto i = 0; i < permutation.size(); ++i) {
		std::cout << winner(calculated.size() - 1, i, i + permutation.size(), calculated, str) << '\n';
	}
}

//https://onlinejudge.u-aizu.ac.jp/challenges/sources/VPC/KUPC/3147


Measured memory_bytes: 23176
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int d = a / b;
		int r = a % b;
		double f = (double)a / (double)b;
		System.out.printf("%d %d %.5f", d, r, f);
	}
}

Measured memory_bytes: 17352
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

template<typename T>
void chmax(T& a,const T& b)
{
	a=max(a,b);
}

int main()
{
	for(int c,d,w,x;scanf("%d%d%d%d",&c,&d,&w,&x),c|d|w|x;){
		static int e[30][15],f[30][15];
		rep(i,c) rep(j,d) scanf("%d",&e[j][i]);
		rep(i,c) rep(j,d) scanf("%d",&f[j][i]);
		
		static int dp[31][6][1000]; // [日][2回以上ライブを行った回数][疲労]
		memset(dp,-1,sizeof dp);
		
		dp[0][0][0]=0;
		rep(i,d) rep(j,x+1) rep(k,1000){
			if(dp[i][j][k]==-1) continue;
			rep(l,c){
				chmax(dp[i+1][j][k],dp[i][j][k]);
				chmax(dp[i+1][j][k+f[i][l]],dp[i][j][k]+e[i][l]);
			}
			if(j==x) continue;
			rep(l,c){
				if(e[i][l]==0) continue;
				int esum=e[i][l],fsum=f[i][l];
				repi(r,l+1,c){
					if(e[i][r]==0) break;
					esum+=e[i][r];
					fsum+=f[i][r];
					chmax(dp[i+1][j+1][k+fsum],dp[i][j][k]+esum);
				}
			}
		}
		
		int res=0;
		rep(i,x+1) rep(j,w+1)
			chmax(res,dp[d][i][j]);
		printf("%d\n",res);
	}
	
	return 0;
}

Measured memory_bytes: 1924
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include <initializer_list>
#include<unordered_set>
#include<map>
#include<cmath>
#include <iterator>
#include<stack>
#include<queue>
#include <iomanip>
#include<math.h>
#include <limits.h>
#include <numeric>
#include <functional>
#include<fstream>
#define ll long long

#define sondos ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;



   int main() {

       sondos
           int a, b; cin >> a >> b; 
      
       if (a % 2 == 0 && b % 2 == 0)
           cout << ((a / 2 - 1) * a + a / 2) + ((b / 2 - 1) * b + b / 2);
       else if (a % 2 != 0 && b % 2 != 0)
           cout << ((a / 2) * a) + ((b / 2) * b);
       else if (a % 2 == 0 && b % 2 != 0)
           cout << ((a / 2 - 1) * a + a / 2 ) + ((b / 2) * b);
       else if (a % 2 != 0 && b % 2 == 0)
           cout << ((a / 2) * a) + ((b / 2 - 1) * b + b / 2); 
            
           return 0;
   }
 

Measured memory_bytes: 256
n = int(input())

lists = []

count = 0

while n:
  
  doublets = tuple(map(int, input().split()))
  lists.append(doublets)

  n -= 1

for x,y in lists:
  if x == y:
    count += 1
    continue
  elif count == 3:
   	break
  else:
   	count = 0
if (count >= 3):
    print('Yes')
else:
    print('No')

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

void solve(){
	int n, i;
	cin>>n;
	int arr[n+1];
	for(i=1;i<=n;i++)
		cin>>arr[i];
	int prev1 = abs(arr[1]-arr[2]);
	int prev2 = 0;
	if(n==1){
		cout<<prev2<<endl;
		return;
	}
	if(n==2){
		cout<<prev1<<endl;
		return;
	}
	int curr = 0;
	for(i=3;i<=n;i++){
		curr = min( abs(arr[i] - arr[i-1]) + prev1, abs(arr[i] - arr[i-2]) + prev2 );
		prev2 = prev1;
		prev1 = curr;
	}
	cout<<curr<<endl;
	return;
}


int main(){
	//int tc;
	//cin>>tc;
	//while(tc--){
		solve();
	//}
	return 0;
}



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

#define MOD 1000000007
typedef unsigned long long ull;

int a, b;
int main() {
  cin >> a >> b;

  if (a == 1) {
    if (b == 2) {
      cout << 3;
      return 0;
    }
    if (b == 3) {
      cout << 2;
      return 0;
    }
  }

  if (a == 2) {
    if (b == 1) {
      cout << 3;
      return 0;
    }
    if (b == 3) {
      cout << 1;
      return 0;
    }
  }

  if (a == 3) {
    if (b == 1) {
      cout << 2;
      return 0;
    }
    if (b == 2) {
      cout << 1;
      return 0;
    }
  }
}


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

int main() {
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> a(n);
  vector<pair<int,int>> b(m);
  for ( int i=0; i<n; i++ ) cin >> a[i].first >> a[i].second;
  for ( int i=0; i<m; i++ ) cin >> b[i].first >> b[i].second;
  for ( int i=0; i<n; i++ ) {
    int ans=0,mi=1e9;
    for ( int j=0; j<m; j++ ) {
      int x=abs(a[i].first-b[j].first)+abs(a[i].second-b[j].second);
      if ( mi>x ) {
        mi=x;
        ans=j;
      }
    }
    cout << ans+1 << '\n';
  }
  return 0;
}


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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int n,m,b,j;
int main() {
    cin >> n;

    int a[n];
    rep(i,0,n){
        cin >> a[i];
    }
    cin >> m;
    int cnt = 0;
    rep(i,0,m){
        cin >> b;
        a[n] = b;
        for(j=0; a[j] != b; j++);
        if(j != n) cnt++;
    }
    pout(cnt);
    return 0;
}


Measured memory_bytes: 3204
import java.util.*;

class Main
{
    private static Scanner scan = new Scanner(System.in);

    public static void out(boolean flag)
    {
        if (flag)
        {
            System.out.println("ABC");
        }
        else
        {
            System.out.println("ABD");
        }
    }

    public static void main(String[] args)
    {
        int val = scan.nextInt();

        if (val < 1999)
        {
            if (val < 1000)
            {
                out(true);
            }
            else
            {
                out(false);
            }
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;

int main() {
	int n;
	cin >> n;
	vector<pii> a(n); // deadline, duration
	for (int i = 0; i < n; i++) {
		cin >> a[i].second >> a[i].first;
	}
	sort(a.begin(), a.end());
	int elap = 0;
	for (int i = 0; i < n; i++) {
		elap += a[i].second;
		if (elap > a[i].first) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 1792
n, a, b = map(int, input().split())

mod = 10**9 + 7

ans = pow(2, n, mod) - 1

x = 1
y = 1
for i in range(1, b+1):
  x = (x*(n-i+1)) % mod
  y = (y*i) % mod
  if i == a or i == b:
    ans -= (x * pow(y, mod-2, mod)) % mod

ans %= mod

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


#define	max(a, b)	a > b ? a : b


int main()
{
	int q;
	char x[1010], y[1010];
	int **table, *s_table;
	int x_len, y_len;
	int i, j, k;


	scanf("%d", &q);

	s_table = (int *)malloc(sizeof(int) * 1001 * 1001);
	table = (int **)malloc(sizeof(int *) * 1001);
	for(i = 0; i < 1001; i++)
		table[i] = s_table + (i * 1001);

	for(i = 0; i < q; i++){
		scanf("%s %s", x, y);
		x_len = strlen(x);
		y_len = strlen(y);

		// 初期化
		for(j = 0; j <= x_len; j++)
			table[0][j] = 0;
		for(j = 0; j <= y_len; j++)
			table[j][0] = 0;

		// LCSを求める
		for(j = 1; j <= x_len; j++){
			for(k = 1; k <= y_len; k++){
				if(x[j - 1] == y[k - 1]){
					table[k][j] = table[k - 1][j - 1] + 1;
				}else
					table[k][j] = max(table[k - 1][j], table[k][j - 1]);
			}
		}
		printf("%d\n", table[y_len][x_len]);
	}

	return 0;
}


Measured memory_bytes: 5776
#include <iostream>

int main()
{
    while(1) {
        int H,W;
        std::cin >> H >> W;

        if (H == 0 && W == 0){
            break;
            }

        for (int j = 0; j < H; j++) {
            for (int i = 0; i < W; i++) {
                if ((i + j) % 2 == 0) {
                    std::cout << "#";
                } else {
                    std::cout << ".";
                }

                if (i == W - 1) {
                    std::cout << std::endl;
                }
            }
        }

        std::cout << std::endl;


    }

    return 0;
}

Measured memory_bytes: 1152
#include<cstdio>
#define int long long
#define min(a,b) (a<b?a:b) 
using namespace std;

int n;
int a[20];

inline int dp(int l, int r, int x, int y) {
	if(r - l <= 1) return 0;
	int ans = 1e18;
	for(register int i = l + 1; i <= r - 1; i++)
		ans = min(ans, dp(l, i, x, x + y) + dp(i, r, x + y, y) + a[i] * (x + y));
	return ans;
}

signed main() {
	scanf("%lld", &n);
	for(register int i = 1; i <= n; i++) scanf("%lld", &a[i]);
	printf("%lld\n", dp(1, n, 1, 1) + a[1] + a[n]);
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    H = [int(i) for i in input().split()]

    flg = True
    max_ = -1
    for h in H:
        if h < max_:
            flg = False
            break
        if h == max_:
            continue
        max_ = h - 1
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 14172
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
s = input()
res = 0
for i in range(n-2):
    if s[i:i+3] == 'ABC':
        res += 1

print(res)

Measured memory_bytes: 64108
########### E
H, W, M = map(int, input().split())
bombs = []
for _ in range(M):
    bomb = tuple(map(lambda x:int(x)-1, input().split()))
    bombs.append(bomb)

H_list = [0]*H
W_list = [0]*W
for h,w in bombs:
    H_list[h] += 1
    W_list[w] += 1
    
maxX = max(H_list)
maxY = max(W_list)

max_H = [i for i,k in enumerate(H_list) if k == maxX]
max_W = [i for i,k in enumerate(W_list) if k == maxY]

bombs = set(bombs)
for i in max_H:
    for k in max_W:
        if (i,k) not in bombs:
            print(maxX + maxY)
            exit()

print(maxX + maxY -1)

Measured memory_bytes: 90080
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
using namespace std;

//common
typedef long long i64,ll;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,r) for(int i=(l);i<(int)(r);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

char tmp[1000];
#define nextInt(n) scanf("%d",&n)
#define nextLong(n) scanf("%lld",&n)//I64d
#define nextDouble(n) scanf("%lf",&n)  
#define nextChar(n) scanf("%c",&n)
#define nextString(n) scanf("%s",tmp);n=tmp

template<typename T,typename V> inline T pmod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}


ll MOD=1000000007;

namespace SyntaxAnalysis{
	typedef string::const_iterator Cursor;
	
	class ParseError{};
	
	map<char,int> vmap;
	map<char,bool> used;

	class Syntax{
	public:
		const string& s;
		Cursor& c;
		Syntax(const string& s,Cursor& c):s(s),c(c){}

		ll expression(){
			ll r=term();
			if(c==s.end())return r;
			if(*c=='<')return r;
			c++;c++;
			ll l =expression();	
			return l>>min(r,31LL);
		}

		ll term(){
			if(*c=='>'){
				c++;
				ll t=expression();
				c++;c++;
				return t*t%MOD;
			}
			ll v=number();//DUMP(v);
			return v;
		}
		ll number(){
		    stringstream ss;
		    while(isdigit(*c)){
		        ss << *c;c++;
		    }
		  	string tmp;ss>> tmp;ss.clear();reverse(ALL(tmp));ss<<tmp;
			ll ret;ss >> ret;return ret;
		}
	};
}
using namespace SyntaxAnalysis;


class Main{
public:

	string l;		
	bool input(){
		getline(cin,l);
		if(l=="#")return false;
		l.erase(remove(l.begin(), l.end(), ' '), l.end());//空白除去
		return true;
	}

	void run(){
		while(input()){
			reverse(ALL(l));
			Cursor s=l.begin();
			Syntax sy(l,s);
			cout <<sy.expression()<<endl;
		}
	}
};

 int main(){
	//ios::sync_with_stdio(false);
 	Main().run();
 	return 0;
 }

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

int main() {
    int N, M;
    cin >> N >> M;
    int ans[N];
    bool flag = true;
    for (int n = 0; n < N; n++) {
        ans[n] = 10;
    }
    for (int m = 0; m < M; m++) {
        int s, c;
        cin >> s >> c;
        if (ans[s - 1] != 10 && ans[s - 1] != c) {
            flag = false;
        }
        ans[s - 1] = c;
    }
    if (N == 1) {
        if (ans[0] == 10) {
            ans[0] = 0;
        }
    } else {
        if (ans[0] == 0) {
            flag = false;
        }
        if (ans[0] == 10) {
            ans[0] = 1;
        }
        for (int n = 1; n < N; n++) {
            if (ans[n] == 10) {
                ans[n] = 0;
            }
        }
    }
    if (flag) {
        for (int n = 0; n < N; n++) {
            cout << ans[n];
        }
    } else {
        cout << -1;
    }
    return 0;
}

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

int main() {
  ll W, H, x, y;
  cin >> W >> H >> x >> y;
  
  cout << W*H/2;
  if (W*H %2 != 0) cout << ".5";
  cout << " ";
  
  if (x*2 == W && y*2 == H) cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i,  r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define X real()
#define Y imag()
#define maxN 100005
#define oo 1000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, deg[maxN];
vector<int> g[maxN];
queue<int> q;
bool deleted[maxN], inQ[maxN];

void del(int u) {
    deleted[u] = true;
    forit(it, g[u]) {
        int v = *it;
        if (!deleted[v]) {
            --deg[v];
            if (deg[v] == 1 && !inQ[v]) {
                inQ[v] = true;
                q.push(v);
            }
        }
    }
}

int main () {
    scanf("%d", &n);
    fto(i, 1, n-1) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].pb(v); g[v].pb(u);
        ++deg[u]; ++deg[v];
    }

    fto(u, 1, n) {
        if (deg[u] == 1) {
            q.push(u);
            inQ[u] = true;
        }
    }

    while (!q.empty()) {
        int u = q.front(); q.pop();
        if (deleted[u]) continue;
        if (deg[u] == 0) {
            puts("First");
            return 0;
        }
//        debug(u);

        int v;
        forit(it, g[u]) {
            if (!deleted[*it]) {
                v = *it;
                break;
            }
        }

        del(u);
        del(v);
    }

    puts("Second");

    return 0;
}


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

int main(int argc, char *argv[])
{
  int n;
  cin >> n;
  int count[9] = {0};
  for (; n-->0;) {
    int i;
    cin >> i;
    i /= 400;
    if (i > 8) i = 8;
    count[i]++;
  }
  int v = 0;
  for(int i = 0; i < 8; ++i) {
    if (count[i] > 0) v++;
  }

  int mn, mx;
  mn = (v == 0)? 1 : v;
  mx = v + count[8];
  cout << mn << " " << mx << endl;
  return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
h = []
for i in range(n):
    h.append(int(input()))
h.sort()
min_number = 10**9+1
for i,j in zip(h[0:n-k+1],h[k-1:]):
    min_number = min(min_number,j-i)
    #print('{} {}'.format(i,j))
print(min_number)


Measured memory_bytes: 8648
#include <stdio.h>

int main(void)
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a==b)puts("Draw");
    else if(a==1)puts("Alice");
    else if(b==1)puts("Bob");
    else if(a>b)puts("Alice");
    else puts("Bob");
    return 0;
}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<long long>;
using ld = long double;

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

string board;

bool CanReach(int x, int y) {
  while (x < y - 2) {
    bool any = false;
    for (int t : {1, 2}) {
      if (board[x + t] == '.') { any = true; x += t; break; }
    }
    if (!any) { return false; }
  }
  return true;
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  cin >> board;

  --a; --b; --c; --d;
  if (!CanReach(a, c) || !CanReach(b, d)) {
    cout << "No\n";
    return 0;
  }

  bool ok = true;

  if (c > d) {
    ok = false;
    for (int i = b; i <= d; ++i) {
      if (i > 0 && i < n - 1 && board.substr(i - 1, 3) == "...") {
        ok = true;
      }
    }
  }

  cout << (ok ? "Yes\n" : "No\n");

  
}



Measured memory_bytes: 592
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    map<ll, ll> mp;
    ll a[200005];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i] -= i;
        mp[a[i]]++;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        mp[a[i]]--;
        ans += mp[-(a[i] + i * 2)];
    }
    cout << ans << endl;
}


Measured memory_bytes: 27776
import itertools

n,m,x = map(int,input().split())
ca = [input() for _ in range(n)]

c = []
a = []
calc = [0] * m


for cai in ca:
  tmp = list(map(int,cai.split()))
  c.append(tmp[0])
  a.append(tmp[1:])

ite = itertools.product(range(2), repeat=n)
ans = float('inf')
tmp = 0
k = 0
for i in ite:
  calc = [0] * m
  tmp = 0
  for j in range(n):
    if i[j] == 1 :
      tmp += c[j]
      for k in range(m):
        calc[k] += a[j][k] 
  if len([z for z in calc if z >= x]) == m:
    ans = min(ans,tmp)

print(ans if ans != float('inf') else -1)

Measured memory_bytes: 9168
/*
  GOOD is not Enough
  You've got to be GREAT.
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define pii pair<int,int>
#define dbg(x) cout << (#x) << " is " << (x) << '\n' 
#define F first
#define S second
#define all(a) a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

const double pi=3.142857;

void solve()
{ 
  double r;
  cin >> r;
  cout << 2.0*pi*r << '\n';
  return;
}

signed main()
{
  FAST
  int T=1;
  // cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}

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

int main() {
    long long  W, H, x, y;
    cin >> W >> H >> x >> y;

    int b = 0;
    if (x == 0 && y == 0){
        b = 0;
    }else{
        if (x == W / 2 && W % x == 0) {
            if (y == H /2 && H % y == 0){
                b = 1;
            }
        }        
    }

    double d = 0;
    d = double(H) * double(W) / 2;
    cout << d << " " << b << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int sx,sy,tx,ty;
  scanf("%d%d%d%d",&sx,&sy,&tx,&ty);

  int x = tx-sx;
  int y = ty-sy;

  for(int i = 0;i < y;i++) printf("U");
  for(int i = 0;i < x;i++) printf("R");
  for(int i = 0;i < y;i++) printf("D");
  for(int i = 0;i <= x;i++) printf("L");
  for(int i = 0;i <= y;i++) printf("U");
  for(int i = 0;i < x;i++) printf("R");
  printf("RDR");
  for(int i = 0;i <= y;i++) printf("D");
  for(int i = 0;i < x;i++) printf("L");
  printf("LU\n");

  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<string>
using ull = unsigned long long;
const static int MOD = 1000000007;
ull RepeatSquaring(ull N, ull P){
	if(P == 0 || N == 1) return 1;
	if(N == -1) return P & 1 ? -1 : 1;
	if(!(P & 1)){
		ull t = RepeatSquaring(N, P >> 1);
		return t*t %MOD;
	}
	//Pが偶数のときN^(P/2)を求めてからそれの2乗を返す
	return N*RepeatSquaring(N, P - 1) % MOD;
	//Pが奇数のときN^((P - 1)/2)を求めてからそれの2乗を返す
}

/*
組合せ(nCr)
O(min(r, n - r) + log(MOD))
*/
ull Combination(ull n, ull r){
	if(n - r < r) r = n - r;
	ull numerator = 1, denominator = 1;
	for (ull i = 0; i < r; ++i){
		numerator = numerator*((n - i) %MOD) %MOD;
		denominator = denominator*((i + 1) %MOD) %MOD;
	}
	return numerator*RepeatSquaring(denominator, MOD-2) %MOD;
}

int main(){
    ull K;
    scanf("%llu", &K);
    std::string S;
    std::cin >> S;
    ull sz = S.size();
    ull answer = 1;
    ull power = 1, cmb = sz;
    for (size_t i = sz; i < K + sz; i++){
        power = power*25 %MOD;
        answer = (answer*26 %MOD + cmb*power %MOD) %MOD;
        cmb = cmb*(i+1) %MOD *RepeatSquaring(i + 2 - sz, MOD-2) %MOD;
    }
    printf("%llu\n", answer);
	return 0;
}

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

using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> v;
  for (int i = 0; i < n; i++){
    int k;
    cin >> k;
    v.push_back(k);
  }
  sort(v.begin(), v.end());
  long long sum = 0;
  for (int i = 0; i < (n-k); i++){
    sum += v[i];
  }
  cout << sum << "\n";

}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <sstream>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    int n,a;
    cin >> n >> a;
    cout << (n%500<=a ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
N  = int(input())
S = input()

cnt_rgt = 0
cnt = 0
for i in range(len(S)):
    if S[i]=="(":
       cnt += 1
    if S[i]==")":
        cnt -= 1
        if cnt<0:
            cnt = 0
            cnt_rgt += 1

rgt = "("*cnt_rgt
lft = ")"*cnt

print(rgt+S+lft)
        
    

Measured memory_bytes: 61828
import java.util.*;
import java.util.function.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    sc.close();

    int ans = 1;
    for (; ans <= 3; ans++)
      if (ans != A && ans != B) break;
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    A = []
    for i in range(N):
        a = int(input())
        A.append(a - 1)

    idx = 0
    used = [0] * N
    ans = 0
    while True:
        if idx == 1:
            break
        if used[idx]:
            print(-1)
            return
        used[idx] = 1
        idx = A[idx]
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
    
    int n;
    cin>>n;
    
    int A[n],i;
    for(i=0;i<n;++i)
    {
        cin>>A[i];
    }
    sort(A,A+n);
    int c=0;
    for(int j=0;j<n;++j)
    {
        for( i=j+1;i<n;++i)
        {
            for(int k=i+1;k<n;++k)
            {
                if(A[i]!=A[j]&&A[j]!=A[k]&&A[k]!=A[i])
                {   
                    if((A[i]+A[j])>A[k])
                    {
                       c++; 
                    }
                    
                    //cout<<(j+1)<<" # "<<(i+1)<<" # "<<(k+1)<<endl;
                }
            }
        }
    }
    
    cout<<c<<endl;
}

Measured memory_bytes: 3652