akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    ll n, m, k; cin >> n >> m >> k;
    ll a[n], b[m];
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];

    ll know = 0;
    ll cnt = 0;
    ll ia = -1;
    rep(i, n){
        if(know + a[i] > k){
            ia = i - 1;
            break;
        }

        know += a[i];
        cnt++;
    }

    if(ia == -1) ia = n - 1;

    ll cntmax = cnt;
    // cout << "know: " << know << ", ";
    // cout << "(ia, ib): " << ia << ", " << 0 << endl;
    // cout << "  cnt: " << cnt << endl;
    bool is_finished = false;
    rep(ib, m){
        if(know + b[ib] <= k){
            know += b[ib];
            cnt++;
            cntmax = max(cnt, cntmax);
            // cout << "know: " << know << ", ";
            // cout << "(ia, ib): " << ia << ", " << ib << endl;
            // cout << "  cnt: " << cnt << endl;
        }
        else{
            know += b[ib];
            cnt++;
            // cout << "know: " << know << ", ";
            // cout << "(ia, ib): " << ia << ", " << ib << endl;
            while(know > k){
                if(ia == -1){
                    is_finished = true;
                    break;
                }
                know -= a[ia];

                ia--;
                cnt--;

                // cout << "know: " << know << ", ";
                // cout << "(ia, ib): " << ia << ", " << ib << endl;
            }

            if(!is_finished){
                cntmax = max(cnt, cntmax);
            }
            // cout << "  cnt: " << cnt << endl;
        }

        if(is_finished) break;
    }

    cout << cntmax << endl;


    return 0;
}

Measured memory_bytes: 6752
#include<bits/stdc++.h>
using namespace std;
main()
{
    int w, a, b;
    while(cin>>w>>a>>b)
    {
        if((b>=a && b<=w+a)||(a>=b && a<=w+b))printf("0\n");
        else if(b>a && b>a+w)printf("%d\n", b-(a+w));
        else if(a>b && a>b+w)printf("%d\n", a-(b+w));
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int r[4010], g[4010], b[4010];
string s;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n >> s;
    int i, j, k;
    if (s[n-1] == 'R') r[n-1]++;
    if (s[n-1] == 'G') g[n-1]++;
    if (s[n-1] == 'B') b[n-1]++;
    for(i = n -2; i >= 0; i--) {
        r[i] += r[i+1];
        g[i] += g[i+1];
        b[i] += b[i+1];
        if (s[i] == 'R') r[i]++;
        if (s[i] == 'G') g[i]++;
        if (s[i] == 'B') b[i]++;
    }
    ll ans(0);
    rep(i, s.length()) {
        xrep(j, i+1, s.length()) {
            if (s[i] == s[j]) continue;
            if ((s[i] == 'R' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'R')) {
                if (j + j - i < n && s[j+j-i] == 'B') ans--;
                ans += b[j + 1];
            }
            if ((s[i] == 'R' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'R')) {
                if (j + j - i < n && s[j+j-i] == 'G') ans--;
                ans += g[j + 1];
            }
            if ((s[i] == 'B' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'B')) {
                if (j + j - i < n && s[j+j-i] == 'R') ans--;
                ans += r[j + 1];
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3708
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<Integer, Integer> m = new HashMap<>();
		long ans = 0;
		for(int i = 0; i < N; i++) {
			int a = sc.nextInt();
			m.put(a, m.getOrDefault(a, 0) + 1);
			ans += a;
		}
		int Q = sc.nextInt();
		for(int i = 0; i < Q; i++){
			int b = sc.nextInt();
			int c = sc.nextInt();
			ans += (long)(c - b) * m.getOrDefault(b, 0);
			m.put(c, m.getOrDefault(b, 0) + m.getOrDefault(c, 0));
			m.remove(b);
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 65564
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,A[200005],dp[200005][22],maxx;
string s;
map <string,long long> mp;
int main() {
           cin>>n;
           for(long long i=1;i<=n;i++) {
                      cin>>s;
                      if(mp[s]==0) k++;
                      mp[s]++;
           }
           cout<<k;
}

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

void solve()
{
    int n;
    cin>>n;
    vi a(n);
    rep(i,0,n) cin>>a[i];
    vi dp(n);
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    rep(i,2,n)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1];
}
 
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0)
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  IO;
  int n, k; cin>>n>>k;
  vector<int> v(n+k+10);
  for (int i = 1; i <= n; i++) cin>>v[i];
  vector<int> dp(n+k+10, 1e9);
  dp[1] = 0;

  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= k; j++) dp[i + j] = min(dp[i + j], dp[i] + abs(v[i] - v[i + j]));
  }

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

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
#include <tuple>
using namespace std;

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

int main(){
  using mint = modint<(int)1e9+7>;
  int H, W, N;
  cin >> H >> W >> N;
  vector<pair<int,int>> V;
  for(int i = 0; i < N; ++i){
    int r, c;
    cin >> r >> c;
    V.emplace_back(r,c);
  }
  V.emplace_back(H,W);
  sort(V.begin(), V.end(),
       [](const pair<int,int> &A, const pair<int,int> &B){
         return A.first+A.second < B.first+B.second;
       });
  vector<mint> F(H+W+1,1), F_(H+W+1,1);
  for(int i = 0; i < H+W; ++i) F[i+1] = F[i]*(i+1);
  F_.back() = (mint)1/F.back();
  for(int i = H+W-1; i >= 0; --i) F_[i] = F_[i+1]*(i+1);
  auto comb = [&](const int n, const int k){
                if(n < 0 or k > n) return (mint)0;
                return F[n]*F_[k]*F_[n-k];
              };
  vector<mint> dp(N+1);
  for(int i = 0; i <= N; ++i){
    int r, c;
    tie(r,c) = V[i];
    dp[i] = comb(r-1+c-1,r-1);
    //cerr << r << " " << c << " " << dp[i] << endl;
    for(int j = 0; j < i; ++j){
      int r_, c_;
      tie(r_,c_) = V[j];
      if(r_ > r or c_ > c) continue;
      dp[i] -= dp[j]*comb(r-r_+c-c_,r-r_);
    }
  }
  cout << dp.back() << endl;
}


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

int main(){

  long double n;
  while(cin >> n){
    long double sum=n;
    for(int i=2;i<=10;i++){
      if(i%2 == 0){
        n *= 2.;
      }
      else{
        n /= 3.;
      }
      sum += n;
	}
	cout << fixed
		<< setprecision(6)
		<< sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;
using tdata=pair<datas,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

ll modncr(ll n,ll r){
  if(r*2>n)return modncr(n,n-r);
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i,N,ans,bf;
  cin>>N;
  string s,t;cin>>s>>t;
  if(s[0]==t[0]){
    ans=3;
    bf=i=1;
  }else{
    ans=6;
    bf=i=2;
  }
  while(i<N){
    if(s[i]==t[i]){
      if(bf==1){
        ans=(ans*2)%mod;
      }
      bf=1;
    }else{
      if(bf==1){
        ans=(ans*2)%mod;
      }else{
        ans=(ans*3)%mod;
      }
      bf=2;
    }
    i+=bf;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int N, C;

vector<int> Card[2];

vector<bool> A;

int main()
{
	while (true)
	{
		cin >> N;

		if (N == 0) { break; }

		A.clear(); A = vector<bool>(2 * N + 1, false);

		for (int i = 0; i < N; i++)
		{
			cin >> C;

			A[C] = true;
		}

		Card[0].clear();
		Card[1].clear();

		for (int i = 1; i <= 2 * N; i++)
		{
			if (A[i] == true)
			{
				Card[0].push_back(i);
			}
			else
			{
				Card[1].push_back(i);
			}
		}

		int turn = 0; int max_card = 0;

		while (Card[0].size() != 0 && Card[1].size() != 0)
		{
			int ptr = distance(Card[turn].begin(), lower_bound(Card[turn].begin(), Card[turn].end(), max_card + 1));

			if (ptr != Card[turn].size())
			{
				max_card = Card[turn][ptr];

				Card[turn].erase(Card[turn].begin() + ptr);
			}
			else
			{
				max_card = 0;
			}

			if (turn == 0)
			{
				turn = 1;
			}
			else
			{
				turn = 0;
			}
		}

		cout << Card[1].size() << endl;
		cout << Card[0].size() << endl;
	}

	return 0;
}

Measured memory_bytes: 3080
#include"bits/stdc++.h"
using namespace std;

int main() {
    long long A, B, C, K;
    cin >> A >> B >> C >> K;

    cout << (long long)max({ A * pow(2, K) + B + C, B * pow(2, K) + A + C, C * pow(2, K) + A + B }) << endl;
}

Measured memory_bytes: 256
N = int(input())
D = [int(_) for _ in input().split()]
M = int(input())
T = [int(_) for _ in input().split()]
levels = {}
for d in D:
    levels[d] = levels.get(d, 0) + 1
tests = {}
for t in T:
    tests[t] = tests.get(t, 0) + 1
for t in tests:
    if tests[t] > levels.get(t, 0):
        print('NO')
        exit()
print('YES')


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

typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<bool> > vvb;
typedef map<int, bool> mib;

typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vpll;

typedef vector<string> vs;

typedef long double ld;

#define _GLIBCXX_DEBUG

#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n-1); i >= 0; --i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORED(i, s, n) for (int i = (s); i >= (int)(n); i--)
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << '\n'
#define debug3(x, y, z) cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << '\n'
#define debugs(s) cerr << s << "\n"
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

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

#define fst first
#define snd second
#define pb push_back
#define mk(x,y) make_pair((x),(y))

// http://ehafib.hatenablog.com/entry/2015/12/23/164137
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qpm(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
// gcd : O(logN)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define sz(v) int(v.size())

// x1, x2ライブラリとの被りを避ける
#define x1 x192837465
#define x2 x123456789
#define y1 y192837465
#define y2 y123456789

// typo
#define itn int
#define reutrn return
#define reutnr return
#define srting string

#define make(type, x) type x; cin>>x;
#define make2(type, x, y) type x, y; cin>>x>>y;
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z;
#define make4(type, x, y, z, t) type x, y, z, t; cin>>x>>y>>z>>t;

int ctoi(const char c){
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}


const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

signed main() {
    make2(int, N, P);

    // Pのn乗根までしかありえない → 相当小さそう。
    // P = (ans * ans * ans * ...) * ans * rest

    if (N == 1) {
        cout << P << endl;
        return 0;
    }

    // P % ans^N == 0
    int ans = 1;
    FORE(cand, 2, P) {
        int prod = 1;
        bool isOK = true;
        REP(i, N) {
            prod *= cand;

            if (prod > P) {
                isOK = false;
                break;
            }
        }

        if (!isOK) {
            break;
        }

        if (P % prod == 0) {
            ans = cand;
        }
    }

    cout << ans << endl;
}


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

int main() {
  int n,a[100]={0},x=0,y=0;
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n,greater<int>());
  for(int i=0;i<n;i=i+2){
    x=x+a[i];
    y=y+a[i+1];
  }
  cout<<x-y<<endl;
  return 0;
}


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

using namespace std;

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

  string ans;
  for(int i = 0; i < s.size(); i++) {
    if(s[i] == '0') ans.push_back('0');
    if(s[i] == '1') ans.push_back('1');
    if(s[i] == 'B' && !ans.empty()) ans.pop_back();
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
// review
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

const int MAXN = 2 * 1e5 + 10;

int n;
ll A[MAXN], B[MAXN];

void solve() {
  sort(A, A + n);
  sort(B, B + n);

  ll midA = n & 1 ? A[(n-1)/2] : A[n/2] + A[n/2 - 1];
  ll midB = n & 1 ? B[(n-1)/2] : B[n/2] + B[n/2 - 1];
  cout << midB - midA + 1 << endl;
}

int main() {
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> A[i] >> B[i];
  }
  solve();
}


Measured memory_bytes: 6724
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    int a,b;
    cin >> a >> b;
    cout << a * b /2 << endl;


    return 0;
}



Measured memory_bytes: 256
/**


  ######                                                                     ######   #     #  #######
  #     #    ##    #####   #    #  #    #  #    #  #   ####   #    #  #####  #     #  #     #       #
  #     #   #  #   #    #  #   #   #   #   ##   #  #  #    #  #    #    #    #     #  #     #      #
  #     #  #    #  #    #  ####    ####    # #  #  #  #       ######    #    ######   #######     #
  #     #  ######  #####   #  #    #  #    #  # #  #  #  ###  #    #    #    #   #    #     #    #
  #     #  #    #  #   #   #   #   #   #   #   ##  #  #    #  #    #    #    #    #   #     #   #
  ######   #    #  #    #  #    #  #    #  #    #  #   ####   #    #    #    #     #  #     #  #######



**/
/*

    BismiLLAHIR RAHMANIR RAHIM
    It's not how you look or who you are underneath, it's what you do that defines you

                                ------********-------

    Status : ;
    TC: xxx/xxx;
    DOS: ;
    OJ: ;

*/

#include <bits/stdc++.h>

using namespace std;

#define test        cout<<"thiq ase boss"<<endl;
#define PB          push_back
#define PF          push_front
#define PII         pair <int,int>
#define MII         map <int,int>
#define MSI         map <string,int>
#define MIS         map <int,string>
#define MLI         map <long long int,int>
#define MIL         map <int,long long int>
typedef long long int           LL;
typedef vector <string>         VS;
typedef vector <int>            VI;
typedef vector <char>           VC;
typedef vector <LL>             VLL;

const int INF = 1e9;
const int MX = 1e9;
const double PI = acos(-1);

/* Functions */

int main() {
    #ifdef LU_SERIOUS
        freopen("get.txt","r",stdin);
    #endif // LU_SERIOUS
    int t,cs=0,n,l,r,i,j,x,y,h,w;
    string ara[110],ans[220];
    while (cin >> h >> w) {
        for (i = 1; i <= h; i++) {
            cin >> ara[i];
        }
//        for (i = 1; i <= h; i++) cout << ara[i] << endl;
//        cout << "P" << endl;
//        for (i = 0; i < 220; i++) ans[i] = "";
//        for (i = 1; i <= 2*h; i++) {
//            ans[i] = ans[(i+1)/2];
//        }
        for (i = 1; i <= h; i++) {
            cout << ara[i] << endl;
            cout << ara[i] << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
S = input()
Q = int(input())

flip = 0
ad1 = []
ad2 = []
for i in range(Q):
  st = input()
  if(st[0] == '1'):
    flip += 1
  else:
    if((st[2] == '1' and flip % 2 == 0) or (st[2] == '2' and flip % 2 == 1)):
      #nS = st[4] + S
      ad1.append(st[4])
    else:
      #nS = S + st[4]
      ad2.append(st[4])

ft = ''.join(ad1)
ft = ft[::-1]
ed = ''.join(ad2)

S = ft + S + ed

if(flip % 2 != 0):
  S = S[::-1]
print(S)


Measured memory_bytes: 5852
fun main(args: Array<String>) {

    val input = readLine()?.split(" ")
    val list = arrayListOf<Int>()
    input?.forEach { list.add(it.toInt()) }


    println("${list[0] / list[1]} ${list[0] % list[1]} ${"%f".format(list[0].toDouble() / list[1])}")
}



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

int main()
{
    int n, F[50];
    cin >> n;
    F[0] = F[1] = 1;
    for (int i = 2; i <= n; i++)
    {
        F[i] = F[i - 2] + F[i - 1];
    }
    cout << F[n] << endl;
    return 0;
}


Measured memory_bytes: 3084
#include <stdio.h>
int binarySearch(int n, int key, int A[]){
  int i, left = 0, right = n, mid;
  while(left < right){
    mid = ((left + right)/2);
    if(A[mid] == key)return 1;
    else if(key < A[mid])right = mid;
    else left = (mid + 1);
  }
  return 0;

}

int main(){
  int i, n, q, key, sum = 0;
  int S[100000];

  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d",&S[i]);
  
  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&key);
    sum += binarySearch(n, key, S);
  }
 
  printf("%d\n",sum);


  return 0;
}



Measured memory_bytes: 2076
import std.stdio,
       std.string,
       std.conv,
       std.algorithm;

void main() {
  int[] buf = readln.chomp.split.to!(int[]);
  int a = buf[0] - 1, b = buf[1] - 1;
  int K = 50;
  char[100][100] m;

  for (int i = 0; i < K; i++) {
    for (int j = 0; j < K * 2; j++) {
      m[i][j] = '#';
    }
  }

  for (int i = K; i < K * 2; i++) {
    for (int j = 0; j < K * 2; j++) {
      m[i][j] = '.';
    }
  }

  for (int i = 1; i < K - 1; i += 2) {
    if (a <= 0) break;
    for (int j = 1; j < K * 2; j += 2) {
      if (a <= 0) break;
      m[i][j] = '.';
      a--;
    }
  }

  for (int i = K + 1; i < K * 2; i += 2) {
    if (b <= 0) break;
    for (int j = 1; j < K * 2; j += 2) {
      if (b <= 0) break;
      m[i][j] = '#';
      b--;
    }
  }

  writeln("100 100");
  foreach(line; m) {
    writeln(line);
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int v[105];
int main()
{char w[105];
int len,cnt=0,value;
	scanf("%s",w);
	len=strlen(w);
for(int i=0;i<len;i++)
	{value=w[i]-'a';
			v[value]++;
	}
	for(int j=0;j<26;j++)
	{	
		if(v[j]%2==1)
		{cnt=1;
		} 
		
	
		else if(v[j]%2==0) {
		}
	}
	if(cnt!=1) printf("Yes");
	else  printf("No");
		return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define re register
#define inc(i,j,k) for(re int i=j;i<=k;i++)
using namespace std;
const int N=405;
inline int read(){
	int x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while('0'<=ch&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x;
}
int n,h,fa[N],in[N],ot[N];
bool flag[N];
int gf(int x){return fa[x]==x?x:fa[x]=gf(fa[x]);}
int main(){
	n=read(),h=read()*2;
	inc(i,1,h) fa[i]=i; 
	inc(i,1,n){
		int a=read(),b=read(),c=read(),d=read();
		int l=c?c+(h>>1):a,r=d?d:b+(h>>1);
		ot[l]++,in[r]++;
		l=gf(l),r=gf(r);
		if(l!=r) fa[l]=r;
	}
	inc(i,1,(h>>1)) if(in[i]>ot[i]) return puts("NO"),0;
	inc(i,(h>>1)+1,h) if(ot[i]>in[i]) return puts("NO"),0;
	inc(i,1,h) if(in[i]!=ot[i]||!in[i]&&!ot[i]) flag[gf(i)]=1;
	inc(i,1,h) if(fa[i]==i&&!flag[i]) return puts("NO"),0;
	puts("YES");
}

Measured memory_bytes: 3640
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, sum = 0; cin >> N;
    vl ls(N, 0);
    REP(i, N){
        cin >> ls[i]; sum += ls[i];
    }
    sort(ls.begin(), ls.end());
    ll lm = ls[ls.size() - 1];
    cout << ( lm < (sum - lm) ? "Yes" : "No") << endstr;
    return 0;
}


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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")



signed main() {

	int N, L;
	cin >> N >> L;
	int s = 0;
	rep(i, N) s += L + i;

	int ans = INF, t = INF;
	rep(i, N) {
		if (abs(L + i) < t) {
			t = abs(L + i);
			ans = s - (L + i);
		}
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    int ans=0;
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            ans+=a[i]*a[j];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define F first
#define S second
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll vis[N],res[N];

int solve() 
{
	//happy coding

	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int x = INT_MAX;
	ll sum = 0LL;
	bool f = false;
	for(int i=n-1;i>=0;i--){
		x = min(x,a[i]);
		sum = (ll)a[i] - x;
		if(sum>1){
			f = true;
		}
	}

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


	
	return 0;
}
int main(){
	int test = 1;
  	//scanf("%d", &test);
  	while (test--)solve();return 0;
}

Measured memory_bytes: 640
n, x = map(int, input().split())
cnt = 0

m = [int(input()) for _ in range(n)]
M = sorted(m)
if sum(m) <= x:
    cnt += (n +(x - sum(m)) // min(m))
else:
    while x >= 0:
        for i in range(n):
            x -= M[i]
            cnt += 1
print(cnt)

Measured memory_bytes: 62560
#include <bits/stdc++.h>
using namespace std;
 
int GCD(int a,int b){
  if(b==0){
  	return a;
  }else{
  	return GCD(b,a%b);
  }
}


int main() {
  int K;cin>>K;
  long wa=0;
  for(int a=1;a<=K;a++){
    for(int b=1;b<=K;b++){
      for(int c=1;c<=K;c++){
        wa+=GCD(a,GCD(b,c));
      }
    }
  }
  cout<<wa<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <bitset>
#include <functional>
#include <tuple>
#include <complex>
#include <chrono>
#include <climits>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef unsigned int uint;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
// default_random_engine generator;
// mt19937 rnd(1);

const int MAXN = 200200;
const int P = 1e9 + 7;

void add(int &a, int b) {
    a += b;
    if (a >= P) {
        a -= P;
    }
}

void mul(int &a, int b) {
    ll c = (ll)a * b;
    c %= P;
    a = c;
}

int res[MAXN];
int cnt[MAXN];
int a[MAXN];

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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

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

    cnt[a[0]] = 1;
    res[0] = 1;

    for (int i = 1; i < n; ++i) {
        res[i] = cnt[a[i]];
        if (a[i - 1] != a[i]) {
            add(res[i], res[i - 1]);
            add(cnt[a[i]], res[i - 1]);
        }
    }


    cout << res[n - 1] << endl;

}


Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(10**6)
def main():
    input = sys.stdin.readline
    H, W, K = map(int, input().split())
    S = [list(map(int, input().rstrip())) for _ in range(H)]

    C = [[0] * (W+1) for _ in range(H+1)]
    for i in range(H):
        for j in range(W):
            C[i+1][j+1] = C[i][j+1] + C[i+1][j] - C[i][j] + S[i][j]

    def sm(a,b): #b:exclusive
        i1,j1 = a
        i2,j2 = b
        return C[i2][j2] - C[i1][j2] - C[i2][j1] + C[i1][j1]
    
    ans = 10**9
    for p in range(1<<(H-1)):
        ha = []
        i = 1
        tmp = 0
        p1 = p
        while p1:
            if p1&1: ha.append(i)
            i += 1
            p1 >>= 1
        tmp += len(ha)
        ha.append(H)
        #print(ha,tmp)
        j1, j2 = 0, 1
        flag = False
        while j2 <= W:
            mx = 0
            i1 = 0
            for i2 in ha:
                mx = max(mx, sm((i1,j1),(i2,j2)))
                i1 = i2
            #print(mx,j1,j2)
            if mx > K:
                if j2-j1==1:
                    flag = True
                    break
                tmp += 1
                j1 = j2-1
            else:
                j2 += 1
        if flag: continue
        #print(tmp,p)
        ans = min(ans, tmp)

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 42972
#include <stdio.h>
#include <string.h>
#include<algorithm>
using namespace std;

int main() {
  char s[11];
  char t[11];
  char u[11];
  int a, b;
  scanf("%s %s", s, t);
  scanf("%d %d", &a, &b);
  scanf("%s", u);
  if (strcmp(s, u) == 0) {
    a = a - 1;
  }
  if (strcmp(t, u) == 0) {
    b = b - 1;
  }
  printf("%d %d\n", a, b);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
const int MOD = 998244353;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

int dp[3010][6010];
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,S; cin >> N >> S;
    int A[N]; 
    dp[0][0]=1;
    rep(i,N) cin >> A[i];
    rep(i,N) {
        per(j,S+1) {
            dp[i+1][j+A[i]]+=dp[i][j];
            dp[i+1][j+A[i]]%=MOD;
            dp[i+1][j]+=2*dp[i][j];
            dp[i+1][j]%=MOD;
        }
    }
    cout << dp[N][S] << endl;
}

Measured memory_bytes: 97708
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

int main(){
    int n; cin >> n;
    int l; cin >> l;
    int sum = 0;
    long long min = (1 << 10);
    long long minmin = 0;
    for(int i = 0; i < n; i++){
        int tmp = l + i;
        sum += tmp;
        if(min > abs(tmp)){
            min = abs(tmp);
            minmin = tmp;
        }
    }
    cout << sum - minmin << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include "unistd.h"
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream&o,const pair<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
template<typename T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
//V<ll>fac,rfac;void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

void RE(){cout<<1/0;}
void TLE(){sleep(100);}
void WA(){cout<<char(0);exit(0);}

const int N = 5e3+1;
const ll MOD = 1593222625338049;
int n;
string s;
lll a[N+1], p[N];
inline ll hs(int l, int r){
  return ((a[r]-a[l]*p[r-l])%MOD+MOD)%MOD;
}
bool check(int m){
  unordered_set<ll> t;
  FOR(i, 0, n-m*2+1){
    t.insert(hs(n-m-i, n-i));
    if(t.find(hs(n-m*2-i, n-m-i)) != t.end()) return true;
  }
  return false;
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> s;
  p[0] = 1;
  FOR(i, 0, n){
    a[i+1] = (a[i]*27+(s[i]-'`')) % MOD;
    p[i+1] = p[i]*27 % MOD;
  }
  int l = 0, r = n/2+1, m;
  while(r-l>1){
    m = (l+r)/2;
    (check(m) ? l : r) = m;
  }
  cout << l << endl;
}

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

int main() {
	int N; //ひなあられ数
	int y = 0;
  	int i;
	cin >> N;
  
	for (i = 0; i < N; i++) {
      string c;
      cin >> c;
      
	 if (c == "Y") {
       y += 1;
       break;
      }
    }
  
  	if (y > 0) {
        cout << "Four" << endl;
    } else {
		cout << "Three" << endl;
    }
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.array, std.algorithm;
import std.uni, std.range, std.math, std.container, std.datetime;
import core.bitop, std.typetuple, std.typecons;

immutable long MOD = 1_000_000_007;
alias tie = TypeTuple;
alias triplet = Tuple!(int, int, int);

void main(){
    int a, b, c;
    readVars(a, b, c);

    if (a & 1 || b & 1 || c & 1) {
        writeln(0);
        return;
    }

    if (a == b && b == c) {
        writeln(-1);
        return;
    }

    int ans;

    while(true){
        if (a & 1 || b & 1 || c & 1) {
            writeln(ans);
            return;
        }

        auto tmp1 = (b + c) / 2, tmp2 = (a + c) / 2, tmp3 = (a + b) / 2;
        a = tmp1, b = tmp2, c = tmp3;

        ans++;
    }
}


void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) prllf("%d",n)
#define pl(n) prllf("%d",n)
using namespace std;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d){
    cout<<"Yes"<<endl;
  }
  else if(abs(a-b)<=d && abs(b-c)<=d){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll kill_monster(ll health){
    if(health == 1)
        return 1;
    return 1 + 2 * kill_monster(health / 2);
}
int main() {
    
   ll H;
   cin >> H;
   cout << kill_monster(H);

   return 0;
}


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

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

  rep(i, N.size())
  {
    if (N[i] == '1')
      N[i] = '9';
    else if(N[i] == '9')
      N[i] = '1';
  }
  cout << N << endl;
  return 0;
}

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

using namespace std;

const int N = 100005;

int x[N], p[N], d[N], pa[N][20];
int n, l, q, a, b;
vector<int> G[N];

void dfs(int v, int depth) {
	d[v] = depth;
	pa[v][0] = p[v];
	for(int k=1;k<20;k++)
		pa[v][k] = pa[pa[v][k-1]][k-1];
	for(int ch:G[v])
		dfs(ch, depth+1);
}

int main()
{
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> x[i];
	cin >> l >> q;
	p[n-1]=n-1;
	for(int i=0;i<n-1;i++) {
		p[i] = upper_bound(x+i, x+n, x[i]+l)-x-1;
		G[p[i]].push_back(i);
	}
	dfs(n-1, 0);
	while(q--) {
		int ct = 0;
		cin >> a >> b;
		a--, b--;
		if(a > b) swap(a, b);
		for(int k=19;k>=0;--k){
			if(pa[a][k] < b)
				a = pa[a][k], ct += 1 << k;
		}
		cout << ++ct << endl;
	}
}


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

long long calc(int n, const vector<int>& options, const vector<int>& cost,
               const vector<array<int, 26>>& s, int dd, int nt, int ot) {
  //long long x(total);
  int before(dd-1), after(dd+1);
  while (before >= 0 && options[before] != nt) before--;
  while (after < n && options[after] != nt) after++;
  int a(dd - before - 1), b(after - dd - 1), c(after - before - 1);
  int diff = c * (c+1) / 2 - a * (a+1) / 2 - b * (b+1) / 2;
  int before2(dd-1), after2(dd+1);
  while (before2 >= 0 && options[before2] != ot) before2--;
  while (after2 < n && options[after2] != ot) after2++;
  int a2(dd - before2 - 1), b2(after2 - dd - 1), c2(after2 - before2 - 1);
  int diff2 = c2 * (c2+1) / 2 - a2 * (a2+1) / 2 - b2 * (b2+1) / 2;
  return + (long long) diff * cost[nt] - (long long) diff2 * cost[ot] + s[dd][nt] - s[dd][ot];
}
int main() {
  int n;
  cin >> n;
  vector<int> c(26);
  vector<array<int, 26>> s(n);
  
  vector<int> last(26, -1);
  
  for (int i = 0; i < 26; ++i)
    cin >> c[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 26; ++j)
      cin >> s[i][j];
  
  long long total(0);
  vector<int> options(n);
  
  for (int i = 0; i < n; ++i) {
    int neg(0), test(-1);
    for (int j = 0; j < 26; ++j) {
      neg -= c[j] * (i - last[j]);
    }
    //cout << neg << 'n' << endl;
    int max_score = -1e9;
    for (int j = 0; j < 26; ++j) {
      int ss = s[i][j] + neg + c[j] * (i - last[j]);
      if (ss > max_score) {
        max_score = ss;
        test = j;
      }
    }
    total += max_score;
    //cout << test + 1 << endl;
    options[i] = test;
    //cout << test + 1 << ' ' << max_score << endl;
    last[test] = i;
  }
  //cout << total << endl;
  for (int t = 1; t <= 500; ++t) {
    for (int dd = n - 1; dd >= 0; --dd) {
      for (int tt = 25; tt >= 0; --tt) {
        if (tt == options[dd]) continue;
        int ot = options[dd];
        
        long long ns = calc(n, options, c, s, dd, tt, ot);
        //cout << ns << endl;
        if (ns > 0) {
      		total += ns;
          options[dd] = tt;
    	}
      }
    }
  }
  for (const int& i: options) cout << i + 1 << endl;
  //cout << total << endl;
  return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

struct UnionFind {
    ll n, cnt;
    vector<int> par, rank, sz;

    UnionFind(ll n) : n(n), cnt(n), par(n), rank(n), sz(n, 1) {
        iota(par.begin(), par.end(), 0);
    }

    ll find(ll x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }

    bool same(ll x, ll y) {
        return find(x) == find(y);
    }

    ll size(ll x) {
        return sz[find(x)];
    }

    void unite(ll x, ll y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
            sz[y] += sz[x];
        } else {
            par[y] = x;
            sz[x] += sz[y];
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
        cnt--;
    }
};

int main(){
  ll i,j;
  ll n;
  cin>>n;
  VVI v1(101010),v2(101010);
  for(i=0;i<n;i++){
   ll x,y;
   cin>>x>>y;
   v1[x].pb(y);
   v2[y].pb(x);
  }
  UnionFind uf1(101010),uf2(101010);

  for(i=0;i<101010;i++){
    for(j=0;j+1<v1[i].size();j++){
      uf1.unite(v1[i][j],v1[i][j+1]);
    }
  }

  for(i=0;i<101010;i++){
    for(j=0;j+1<v2[i].size();j++){
      uf2.unite(v2[i][j],v2[i][j+1]);
    }
  }

  set<ll> s1,s2;
  ll ans=0;

  for(i=0;i<101010;i++){
    if(v1[i].size()!=0){
      if(s1.count(uf1.find(v1[i][0]))==0||s2.count(uf2.find(i))==0){
        s1.insert(uf1.find(v1[i][0]));
        s2.insert(uf2.find(i));
        ans+=uf1.size(v1[i][0]) * uf2.size(i);
      }
    }
  }
  cout<<ans-n<<endl;
  return 0;  
}

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

using namespace std;

int N, A, B;

int main()
{
    cin >> N >> A >> B;

    int sum = 0;

    for (int i = 1; i <= N; i++) {
        int val = i % 10 + (i % 100) / 10 + (i % 1000) / 100 + (i % 10000) / 1000 + (i == 10000 ? 1 : 0);
        if (A <= val && val <= B) sum += i;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import numpy as np
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import math

N = int(input())
S = str(input())

# ans = 10**6
# blacks = [0 for i in range(N)]
# black = 0
# white = 0
# for i in range(N):
#     if S[i] == "#":
#         black += 1
#
#     else:
#         white += 1
#     blacks[i] = black
#
# ans = min(black,white,ans)
#
# # print(blacks)
# for i in range(1,N):
#     cnt = 0
#     cnt += (N-(i+1))-(blacks[N-1]-blacks[i])#white
#     # print("white",cnt)
#     cnt += blacks[i-1]#black
#     # print(cnt)
#     ans = min(ans,cnt)
#
# print(ans)

#count white
cnt = S.count(".")

l = [cnt] #all black
for i in range(N):
    if S[i]==".":
        cnt -= 1
        l.append(cnt)
    else:
        cnt += 1
        l.append(cnt)

# print(l)
print(min(l))


Measured memory_bytes: 21680
#include<stdio.h>
int main()
{
	int N;
    double C;
	scanf("%d",&N);
	if(N%2==0)
	{   
		C=0.5;
		printf("%lf\n",C);

	}
	else
	{
    C=(N+1)*0.5*1/N;
	printf("%lf\n",C);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


ll n, a; set <ll> s;

void solve()
{
    cin >> n; for (int i=0; i<n; i++) cin >> a, s.insert(a);
    nout(s.size()==n ? "YES" : "NO");
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 12896
def init
  x = 1
  while x <= $n
    x <<= 1
  end
  $n = x
  $arr = [0] * (2 * $n - 1)
end
 
def update(i, m)
  x = i
  i += $n - 1
  $arr[i] += m
  while i > 0
    i = (i - 1) / 2
    break if i > 0 && $arr[i] == [$arr[i*2+1], $arr[i*2+2]].max
    $arr[i] = $arr[i*2+1] >= $arr[i*2+2] ? $arr[i*2+1] : $arr[i*2+2]
  end
  $idx = query(x) - $n + 1
  $max = $arr[0]
end

def query(k)
  i = 0
  while i < $n
    i = $arr[i*2+1] >= $arr[i*2+2] ? i*2+1 : i*2+2
  end
  i
end

$n, q = gets.split.map(&:to_i)
init
$idx = $max = 0
q.times do
  update(*gets.split.map(&:to_i))
  puts "#{$idx} #{$max}"
end

Measured memory_bytes: 25132