akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef pair<ll, l_l> lll;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    vector<int> closed;
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        closed.resize(n + 1); par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) closed[i] = 0, par[i] = i, rank[i] = 0, Size[i] = 1;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        closed[x] |= closed[y];
        return true;
    }

    ll size(int x){
        return Size[root(x)];
    }

    bool isclosed(int x) {
        x = root(x);
        return closed[x] > 0;
    }

    void close(int x) {
        x = root(x);
        closed[x] = 1;
    }
};

int N;
vector<lll> v;
ll H, W;


int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> H >> W;
    v.resize(N);
    for(int i = 0; i < N; i++) {
        ll r, c, a;
        cin >> r >> c >> a;
        v[i] = {a, {r, c}};
    }
    sort(v.begin(), v.end(), greater<lll>());
    UnionFind uni(200050);
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        ll a = v[i].first;
        ll r = v[i].second.first;
        ll c = v[i].second.second;
        if(!uni.issame(r, 1e5 + c)) {
            if(uni.isclosed(r) && uni.isclosed(1e5 + c)) continue;
            ans += a;
            uni.merge(r, 1e5 + c);
            //cerr << i << " ";
            continue;
        }
        if(uni.isclosed(r)) continue;
        uni.close(r);
        ans += a;
        //cerr << i << " ";
    }
    //cerr << endl;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

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

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

  ll ans = 0;
  // 高々1000種類できるかなのでそれぞれ判定する
  rep(i, 1000){
    ll a,b,c;
    a = i / 100;
    b = (i / 10) % 10;
    c = i % 10;
    bool tmp1 = false, tmp2 = false, tmp3 = false;
    rep(j,N){
      ll d = s[j] - '0';
      if(tmp3){
        continue;
      }
      else if(tmp2){
        if(d == c){
          tmp3 = true;
          // cout<<a<<b<<c<<endl;
          ans++;
        }
      }
      else if(tmp1){
        if(d == b){
          tmp2 = true;
        }
      }
      else{
        if(d == a) tmp1 = true;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
using namespace std;
 
int main(){
    
    int N,L[26]={},R[26]={},f[26]={},tmp,ans=0;
    string S,str="abcdefghijklmnopqrstuvwxyz";

    cin >>N;
    cin >>S;

    for(int i=0;i<26;i++){
        R[i]=0;
    }


    for(int i=0;i<N;i++){
        for(int j=0;j<26;j++)
         if(S[i]==str[j]){
            if(f[j]==0){
                L[j]=i;
                f[j]=1;
            }else{
                R[j]=i;
            }
        }
    }

    for(int i=1;i<N;i++){
        tmp=0;
        for(int j=0;j<26;j++){
            if(i>=L[j]&&i<=R[j]){
                tmp+=1;
            }
        }

        if(tmp>ans){
            ans=tmp;
        }

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
#pragma warning(disable:4996)
long long N, T, Q, a[1 << 17], b[1 << 17], c[1 << 17];
int main() {
	cin >> N >> T >> Q;
	for (int i = 0; i < N; i++)scanf("%lld%lld", &a[i], &b[i]);
	long long H = -1LL << 62;
	for (int i = 0; i < N; i++) {
		if (b[i] == 2) {
			if (i >= 1) {
				if (b[i - 1] == 1) {
					long long C = (a[i - 1] + a[i]) / 2;
					if (abs(C - a[i]) <= T) { H = C; c[i] = C; }
					else { c[i] = a[i] - T; }
				}
				else {
					if (abs(H - a[i]) <= T)c[i] = H;
					else { c[i] = a[i] - T; }
				}
			}
			if (i == 0)c[i] = a[i] - T;
		}
	}
	H = 1LL << 62;
	for (int i = N - 1; i >= 0; i--) {
		if (b[i] == 1) {
			if (i < N - 1) {
				if (b[i + 1] == 2) {
					long long C = (a[i + 1] + a[i]) / 2;
					if (abs(C - a[i]) <= T) { H = C; c[i] = C; }
					else { c[i] = a[i] + T; }
				}
				else {
					if (abs(H - a[i]) <= T)c[i] = H;
					else { c[i] = a[i] + T; }
				}
			}
			if (i == N - 1)c[i] = a[i] + T;
		}
	}
	for (int i = 0; i < Q; i++) {
		int p; scanf("%d", &p); p--; cout << c[p] << endl;
	}
	return 0;
}

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

typedef pair<ll, int> P;

const int MAX_N = 1 << 17;
const int def = 0;
const int INF = 1 << 25;


struct SumSegTree {
	int n;
	ll dat[2 * MAX_N - 1];
	void init(int n_) {
		n = 1;
		while(n < n_) n *= 2;
		for(int i = 0; i < 2 * n - 1; i++) dat[i] = 0;
	}

	void update(int k, ll a) {
		k += n - 1;
		dat[k] += a;
		while(k > 0) k = (k - 1) / 2, dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2];
	}

	ll query(int a, int b) { return query(a, b, 0, 0, n); }

	ll query(int a, int b, int k, int l, int r) {
		if(r <= a || b <= l) return 0;
		if(a <= l && r <= b) return dat[k];
		ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return vl + vr;
	}

	void show() {
		for(int i = 0; i < n; i++) cout << dat[i + n - 1] << " ";
		cout << endl;
	}
};

SumSegTree st1, st2;

ll a[100000];
ll ans[100000];

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


	int N;
	cin >> N;
	st1.init(N);
	st2.init(N);

	priority_queue<P, vector<P>, greater<P>> q;
	for(int i = 0; i < N; i++) {
		cin >> a[i];
		q.push({ a[i], i });
		st1.update(i, a[i]);
		st2.update(i, 1);
	}

	ll h = 0;
	for(int i = 0; i < N; i++) {
		if(a[i] < h) continue;
		ll sum = 0;

		while(q.size() && q.top().first <= a[i]) {
			ll b = q.top().first, idx = q.top().second;
			q.pop();
			sum += b - h;
			st1.update(idx, -a[i]);
			st2.update(idx, -1);
		}
		sum += st2.query(i, N) * (a[i] - h);
		ans[i] = sum;
		h = a[i];
	}

	for(int i = 0; i < N; i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 8432
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;



int main() {

int N,cnt,ans=0;
cin>>N;

for (int n = 1; n <= N; ++ ++ n)
{
	cnt=0;
	for (int j = 1; j*j <=n; ++j)
	{
		if (n%j==0){cnt++;}
	}

if (cnt==4){ans++;}

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



Measured memory_bytes: 3532
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;

inline int read(){
	re int ans = 0;re bool f = 1;re char ch = getchar();
	while(ch<'0'||ch>'9'){if (ch=='-')f = 0;ch = getchar();}
	while(ch>='0'&&ch<='9'){
		ans = (ans<<3)+(ans<<1)+(ch^48);
		ch = getchar();
	}
	return f?ans:-ans;
}
int minn(int a,int b){return a>b?b:a;}
int aBs(int a){return a>0?a:-a;}
signed main(void){
	int n,k;
	n = read();k = read();
	printf("%lld\n",min(aBs(n%k-k),n%k));
	return 0;
}

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

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

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

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

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

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

int A, B, C, D;
map<int, int> memo;

int rec(int X) {
  if (X == 0)
    return 0;
  if (X == 1)
    return D;

  if (memo.find(X) != memo.end())
    return memo[X];

  int l2 = X / 2 * 2, r2 = (X + 1) / 2 * 2;
  int l3 = X / 3 * 3, r3 = (X + 2) / 3 * 3;
  int l5 = X / 5 * 5, r5 = (X + 4) / 5 * 5;

  int res = INF;
  if (res / D > X)
    res = X * D;
  chmin(res, llabs(l2 - X) * D + A + rec(l2 / 2));
  chmin(res, llabs(r2 - X) * D + A + rec(r2 / 2));
  chmin(res, llabs(l3 - X) * D + B + rec(l3 / 3));
  chmin(res, llabs(r3 - X) * D + B + rec(r3 / 3));
  chmin(res, llabs(l5 - X) * D + C + rec(l5 / 5));
  chmin(res, llabs(r5 - X) * D + C + rec(r5 / 5));
  return memo[X] = res;
}

signed main() {
  int T;
  cin >> T;
  while (T-- > 0) {
    int N;
    cin >> N;
    cin >> A >> B >> C >> D;

    memo.clear();
    int ans = rec(N);
    cout << ans << endl;
  }
}

Measured memory_bytes: 4364
import math
n, k = map(int, input().split())

ans = 0
ma = 10**9
for i in range(1, n+1):
    p = math.ceil(math.log2(k) - math.log2(i))
    if p >= 1:
        ans += 1/(n*2**p)
    else:
        ans += 1/n

print(ans)

Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
  int i,num,j;
  int x,y,w,h,n;
  int nx,ny;
  int count;

  scanf("%d",&num);

  for(i=0;i<num;i++){
    scanf("%d%d%d%d%d",&x,&y,&w,&h,&n);

    count=0;

    for(j=0;j<n;j++){
      scanf("%d%d",&nx,&ny);
      if(x<=nx && nx<=x+w &&
          y<=ny && ny<=y+h)
        count++;
    }

    printf("%d\n",count);
  }

  return 0;
}

Measured memory_bytes: 0
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter};
use std::io::*;
use std::ops::*;
use std::*;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn main() {
    let _ = read!(usize);
    let A = read![[usize]];

    let mut k = 0;
    let mut i = 1;
    let mut l = 0;
    let mut prev = A[0];
    while i < A.len() {
        if prev != A[i] {
            k += (i - l) / 2;
            l = i;
        }

        prev = A[i];
        i += 1;
    }

    k += (i - l) / 2;

    println!("{}", k);
    return;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;



int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

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

    sort(a, a + nn, greater<>());
    map<int, int> have, rem;
    have[a[0]]++;
    for (int i = 1; i < nn; i++) rem[a[i]]++;

    for (int sz = 1; sz <= nn / 2; sz *= 2) {
        vector<int> just;
        for (auto e : have) {
            int el = e.first;
            for (int i = 0; i < e.second; i++) {
                auto it = rem.lower_bound(el);
                if (it != rem.begin()) {
                    it--;
                    it->second--;
                    just.pb(it->first);
                    if (it->second == 0) rem.erase(it);
                }

                else {
                    cout << "No";
                    return 0;
                }
            }
        }

        for (int e : just) {
            have[e]++;
        }
    }

//    cout << "Yes";

    cout << (rem.empty() ? "Yes" : "No");

}


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

struct union_find {
  int components;
  vector<int> root, next, size;
  void clear(int n) {
    components = n;
    root.resize(n);
    iota(root.begin(), root.end(), 0);
    next.assign(n, -1);
    size.assign(n,  1);
  }
  bool find(int x, int y) { return root[x] == root[y]; }
  bool unite(int x, int y) {
    if ((x = root[x]) == (y = root[y])) return false;
    if (size[x] < size[y]) swap(x, y);
    size[x] += size[y];
    for (int z; y >= 0; y = z) {
      z = next[y];
      next[y] = next[x];
      next[x] = y;
      root[y] = x;
    }
    --components;
    return true;
  }
};

main(){
  int h,w,res=0;
  cin>>h>>w;
  vector<vector<bool>> a(h,vector<bool>(w,false));
  for(int i=0;i<h;++i){
    string s;
    cin>>s;
    for(int j=0;j<w;++j)if(s[j]=='#')a[i][j]=true;
  }
  union_find u;
  u.clear(h*w);
  for(int i=0;i<h;++i)for(int j=0;j<w;++j){
    if(0<i&&a[i-1][j]!=a[i][j])u.unite((i-1)*w+j,i*w+j);
    if(i<h-1&&a[i+1][j]!=a[i][j])u.unite((i+1)*w+j,i*w+j);
    if(0<j&&a[i][j-1]!=a[i][j])u.unite(i*w+j-1,i*w+j);
    if(j<w-1&&a[i][j+1]!=a[i][j])u.unite(i*w+j+1,i*w+j);
  }
  vector<vector<bool>> vis(h,vector<bool>(w,false));
  for(int i=0;i<h;++i)for(int j=0;j<w;++j){
    int p=i*w+j;
    p=u.root[p];
    if(vis[p/w][p%w])continue;
    vis[p/w][p%w]=true;
    int bl=0,wh=0;
    do{
      if(a[p/w][p%w])++bl;
      else ++wh;
      vis[p/w][p%w]=true;
      p=u.next[p];
    }while(p!=-1);
    res+=bl*wh;
  }
  cout<<res;
}

Measured memory_bytes: 4096
while True:
    try:
        S = input()
    except EOFError:
        break
    for i in range(len(S) - 5 + 1):
        if S [i:i + 5] == 'apple':
            S = S [:i] + 'peach' + S [i + 5:]
        elif S [i:i + 5] == 'peach':
            S = S [:i] + 'apple' + S [i + 5:]
    print(S)

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

int main(){
    long long a, b;
    cin >> a >> b;
    string s;
    cin >> s;

    for(long long i = 0; i < a + b + 1; i++){
        if(i < a) {
            if('0' <= s[i] and s[i] <= '9') continue;
            else{
                printf("No\n");
                return 0;
            }
        }
        else if(i == a) {
            if(s[i] == '-') continue;
            else{
                printf("No\n");
                return 0;
            }
        }
        else {
            if('0' <= s[i] and s[i] <= '9') continue;
            else{
                printf("No\n");
                return 0;
            }
        }
    }

    printf("Yes\n");
    return 0;
}

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

int prime_number(long int X){
	long int half_X = X /2;
	long int j=2;
	while(1){
		if(j>half_X)break;
		if(X%j==0)return 0;
		j =j + 1;
	}
	return 1;
}

int main(void){
	long int X;
	int P;

	cin >> X;

	long int i = 0;
	while(1){
		if(prime_number(X + i)==1){
			cout << X+i << "\n";
			break;
		}
		if(X+i%2==0)i++; 
		i++;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;

int main() {
  ll N; cin>>N;
  vi D(N); REP(i,N) cin>>D[i];
  ll M; cin>>M;
  vi T(M); REP(i,M) cin>>T[i];
  UM<ll,ll> a,b;
  REP(i,N) a[D[i]]+=1;
  REP(i,M) b[T[i]]+=1;
  for(auto i:b) {
    if(!(i.second<=a[i.first])) {
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}


Measured memory_bytes: 19912
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll A; cin>>A;
  string S; cin>>S;
  ll B=0;
  ll c=1;
  int i=0;
  bool deci = false;
  while(S[i]){
    if (S[i] >= '0' && S[i] <= '9')
      B = B * 10 + S[i] - '0';
    if (deci)
      c *= 10;
    if (S[i] == '.')
      deci = true;
    i++;
  }
  ll ans = A * B / c;
  cout << ans << endl;
}


Measured memory_bytes: 3628
function Main(input) {
    var A = parseInt(input[0], 10);
    var B = parseInt(input[1], 10);
    
    var aMin = Math.ceil(A / 0.08);
    var aMax = (A+1) / 0.08 === Math.ceil((A+1) / 0.08) ? (A+1) / 0.08 - 1 : Math.floor((A+1) / 0.08);
    
    var bMin = Math.ceil(B / 0.1);
    var bMax = (B+1) / 0.1 === Math.ceil((B+1) / 0.1) ? (B+1) / 0.1 - 1 : Math.floor((B+1) / 0.1);

    if (aMin === bMin) {
        console.log(aMin);
    } else if (aMin > bMin) {
        if (bMax >= aMin) {
            console.log(aMin);
        } else {
            console.log(-1);
        }
    } else {
        if (aMax >= bMin) {
            console.log(bMin);
        } else {
            console.log(-1);
        }
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 7372
import java.util.*;
 
class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    //値段
 	int n = sc.nextInt();
    for(int i = 0; i <= 10;i++){
      if(n <= i * 1000){
        System.out.println(i * 1000 - n);
        break;
      }
    }
  }
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001

int m, n;
char c[500][500];
vector<P> v[26];

bool check(P a, P b) {
    char tmp = c[a.fi][a.se];
    if (a.fi == b.fi) {
        if (a.se > b.se) swap(a.se, b.se);
        repl(i, a.se, b.se + 1) {
            if (c[a.fi][i] != tmp && c[a.fi][i] != '.') return false;
        }
    } else {
        if (a.fi > b.fi) swap(a.fi, b.fi);
        repl(i, a.fi, b.fi + 1) {
            if (c[i][a.se] != tmp && c[i][a.se] != '.') return false;
        }
    }
    return true;
}

int main(){
    cin.sync_with_stdio(false);
    cin >> m >> n;
    rep(i, m)rep(j, n) {
        cin >> c[i][j];
        if (c[i][j] != '.') v[c[i][j] - 'A'].pb(P(i, j));
    }

    bool rem[26] = {};
    int cnt = 0;
    rep(i, 26)rep(j, 26)if (v[j].size() > 0 && !rem[j]) {
        P tmp = P(v[j][0].fi - v[j][1].fi, v[j][0].se - v[j][1].se);
        if (abs(tmp.fi) + abs(tmp.se) == 1) {
            rem[j] = true;
            continue;
        }
        tmp = P(v[j][0].fi, v[j][1].se);
        if (check(v[j][0], tmp) && check(v[j][1], tmp)) {
            rem[j] = true;
            c[v[j][0].fi][v[j][0].se] = '.';
            c[v[j][1].fi][v[j][1].se] = '.';
            cnt += 2;
            continue;
        }
        tmp = P(v[j][1].fi, v[j][0].se);
        if (check(v[j][0], tmp) && check(v[j][1], tmp)) {
            rem[j] = true;
            c[v[j][0].fi][v[j][0].se] = '.';
            c[v[j][1].fi][v[j][1].se] = '.';
            cnt += 2;
        }
    }
    cout << cnt << endl;

    return 0;
}

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

public class Main{
  public static void main(String[] args) {
     Scanner in = new Scanner(System.in);
     String str = in.nextLine();
     if(str.charAt(2)==str.charAt(3) && str.charAt(4)==str.charAt(5)){
        System.out.println("Yes");
     }
     else 
        System.out.println("No");
  }
}


Measured memory_bytes: 21844
#define errOut(s) \
  { std::cerr << __LINE__ << ":" << #s << ":" << (s) << std::endl; }

#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
//#include <boost/multi_array.hpp>
//#include <boost/optional.hpp>
//#include <boost/range/adaptors.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

int64_t solve(int64_t l, int64_t r, int64_t d) {
  return (r / d) - ((l - 1) / d);
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t l;
  std::cin >> l;
  int64_t r;
  std::cin >> r;
  int64_t d;
  std::cin >> d;
  auto const res = solve(l, r, d);
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

vector<pair<ll, ll>> pF;


void prime_fact(ll n){
// 素因数分解
for(ll i = 2; i * i <= n; i ++){
ll cnt = 0;
while(n % i == 0){
cnt ++;
n /= i;
}
pair<ll, ll> f = {i, cnt};
pF.push_back(f);
}
if(n != 1){
pF.push_back({n, 1});
}
}


int main(){
    int N;
    cin >> N;
    if(N == 1){
        cout << "Hello World" << endl;
    }else{
        int x, y;
        cin >> x >> y;
        cout << x + y << endl;
    }
    return 0;
}


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

typedef long long ll;
typedef long double ld;

vector <int> vec;

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n, m;
    cin >> n >> m;
    for(int i=1; i*i<=m; i++){
        if(m%i == 0){
            vec.push_back(i);
            vec.push_back(m/i);
        }
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    for(auto c : vec){
        if(1LL*n*c <= 1LL*m){
            cout << c;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA() cerr << "AAAAA" << endl
#define debug_() cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;

using Graph = vector<vector<int>>;

int main()
{
    int n, k;
    cin >> n >> k;
    if (k > (n - 1) * (n - 2) / 2)
    {
        cout << "-1" << endl;
        return 0;
    }

    int m = (n - 1) + (n - 1) * (n - 2) / 2 - k;
    cout << m << endl;
    for (int i = 2; i <= n; i++)
    {
        cout << "1 " << i << endl;
    }
    int node = (n - 1) * (n - 2) / 2 + 1;
    for (int i = 2; i <= n; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            node--;
            if (node == k)
            {
                return 0;
            }
            if (i == j)
            {
                continue;
            }
            cout << i << " " << j << endl;
        }
    }
    return 0;
}


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

int main(void)
{ 
  int w,h,x,y,r;
  cin>>w>>h>>x>>y>>r;
  if((x-r)>=0&&(x+r)<=w&&y-r>=0&&y+r<=h)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
  return 0;
}


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

int main()
{
	ios::sync_with_stdio(false);
	int n,a=0,b=0,flag=1,temp=0;
	cin>>n;
	while(n--)
	{
		int x,y,t;
		cin>>t>>x>>y;
		temp=t-temp;
		int d=abs(a-x)+abs(b-y);
		if(d<=temp)
		{
			if((temp-d)%2==1)
			{
				flag=0; break;
			}
			a=x; b=y;
		}
		else 
		{
			flag=0; break;
		}	
		temp=t;
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
void foo(){
    double n;
    cin>>n;
    if((int)n&1)cout<<fixed<<setprecision(12)<<(n-(int)n/2)/n;
    else cout<<fixed<<setprecision(12)<<(n/2)/n;   
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class AStationAndBus {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      string s; cin >> s;
      if (s[0] == s[1] && s[1] == s[2]) {
        cout << "No" << endl;
      } else {
        cout << "Yes" << endl;
      }
    }
};

signed main() {
  AStationAndBus solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAX_N = 1e3 + 5;
const int MAX_H = 1e4 + 5;
ll h, n;
pll v[MAX_H];
ll memo[MAX_N][MAX_H];
ll cost(int i, ll x) {
    //cout << i << " " << x << endl;
    if (x <= 0) return 0;
    if (i >= n) return 1e9;
    ll &ans = memo[i][x];
    if (ans != -1) return ans;
    ans = 0;
    ans = min(cost(i, x - v[i].F) + v[i].S, min(cost(i + 1, x - v[i].F) + v[i].S, cost(i + 1, x)));
    return ans;
}
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    memset(memo, -1, sizeof memo);
    cin >> h >> n;
    forn(i, n) cin >> v[i].F >> v[i].S;
    cout << cost(0, h) << endl;
    // int mn = 1e9;
    // pll best = {0, 0};
    // forn(i, n) {
    //     if (v[i].S - v[i].F < mn) {
    //         mn = v[i].S - v[i].F;
    //         best = v[i];
    //     }
    // }
    // ll cost = best.S * (h / best.F);
    // cout << h % best.F << endl;
    // cout << cost << endl;
    // if (h % best.F != 0) {
    //     int mnc = 1e9;
    //     forn(i, n) {
    //         if (v[i].F >= h % best.F && v[i].S < mnc) {
    //             mnc = v[i].S;
    //         }
    //     }
    //     cost += mnc;
    // }
    // //h = h - best.F * (h / best.F);

    // cout << cost << endl;
    return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n, k;
    cin >> n >> k;
    int h[100020];
    for(int i = 1; i <= n; i++){
        cin >> h[i];
    }
    int dp[100020];
    dp[1] = 0;
    for(int i = 2; i <= n; i++){
        dp[i] = INF;
        for(int j = max(i - k, 1); j < i; j++){
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
string S[] = {"pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon"};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    cout << S[N % 10] << endl;
    return 0;
}

Measured memory_bytes: 3652
n = int(input())
w = list(map(int,input().split()))
ans = abs(sum(w[0:1]) - sum(w[1:n+1]))
for i in range(1,n-1):
  a = abs(sum(w[0:i+1]) - sum(w[i+1:n+1]))
  ans = min(ans,a)
print(ans)

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

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<vector<int>> G(N);
    rep(i, 0, N - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> X(N);
    rep(i, 0, Q) {
        int p, x;
        cin >> p >> x;
        p--;
        X[p] += x;
    }
    function<void(int, int)> dfs = [&](int cur, int pre) {
        for(auto &to : G[cur]) {
            if(to == pre) continue;
            X[to] += X[cur];
            dfs(to, cur);
        }
    };
    dfs(0, -1);
    for(auto &x : X) cout << x << " ";
    return 0;
}


Measured memory_bytes: 29696
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long l = sc.nextLong();
        long[] ls = new long[n + 1];
        int sp = -1;
        for (int i = 1; i <= n; i++) {
            ls[i] = sc.nextLong();
            if (ls[i - 1] + ls[i] >= l) {
                sp = i;
            }
        }
        if (sp < 0) {
            System.out.println("Impossible");
        } else {
            System.out.println("Possible");
            for (int i = 1; i < sp - 1; i++) {
                System.out.println(i);
            }
            for (int i = n - 1; i >= sp - 1; i--) {
                System.out.println(i);
            }
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 65808
#include <iostream>

using namespace std;

int main() {

  int n, x, t = 0;
  long long ans = 0;
  char ch;
  cin >> n;
  for(int i = 1;i <= n;i++){
    cin >> x;
    //cerr << t << ' ' << x << '\n';
    if(t > x){
      ans += t - x;
      x = t;
    }
    t= x;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n);
	string str; cin >> str;
	// dp[i][j] denotes the length of longest repeating and non-overlapping substring of str[i..j] (one-indexed)
	LL dp[n+1][n+1]; clr(dp);
	LL ans = 0;
	rep(i, 1, n+1) {
		rep(j, i+1, n+1) {
			if(str[i-1] == str[j-1] && dp[i-1][j-1] < (j-i)) {
				dp[i][j] = dp[i-1][j-1] + 1;
				if(dp[i][j] > ans)	ans = dp[i][j];
			}
			else	dp[i][j] = 0;

		}
	}
	pll(ans); nl;
}


Measured memory_bytes: 195712
// D - ABS

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int N;
int a[2000];

int X_max(int k, int Z, int W);
int Y_min(int k, int Z, int W);

// 手番がXでk以降が残っている時のスコアの最大値
int X_max(int k, int Z, int W) {
	if (k == N) {
		return (abs(Z - W));
	}

	int result = 0;
	for (int i=k; i<N; i++) {
		result = max(result, Y_min(i+1, a[i], W));
	}

	return result;
}

// 手番がYでk以降が残っている時のスコアの最小値
int Y_min(int k, int Z, int W) {
	if (k == N) {
		return (abs(Z - W));
	}

	int result = INF;
	for (int i=k; i<N; i++) {
		result = min(result, X_max(i+1, Z, a[i]));
	}

	return result;
}


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

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

	int ans = X_max(max(0, N-2), Z, W);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
x, y, a, b, c = gets.split(" ").map(&:to_i)
pa = gets.split(" ").map(&:to_i).sort.reverse[0..(x-1)]
qa = gets.split(" ").map(&:to_i).sort.reverse[0..(y-1)]
ra = gets.split(" ").map(&:to_i)
puts (pa + qa + ra).sort.reverse[0..(x+y-1)].inject(&:+)

Measured memory_bytes: 30928
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int n = sc.nextInt(); 
    
    List<Integer> a = new ArrayList<>();
    List<Integer> b = new ArrayList<>();
    
    for(int i = 0; i < n; i++){
      int tmp1 = sc.nextInt();
      int tmp2 = sc.nextInt();
      a.add(tmp1);
      b.add(tmp2);
    }
    
    long[][] dp = new long[n+1][h+1];
    
    for(int i = 0; i < dp.length; i++){
      for(int j = 0; j < dp[i].length; j++){
        dp[i][j] = Long.MAX_VALUE;
      }
    }
    
    dp[0][0] = 0;
    
    for(int i = 0; i < n; i++){
      for(int j = 0; j <= h; j++){
        if(dp[i][j] != Long.MAX_VALUE){
          int index = Math.min(h,j+a.get(i));
          
          dp[i][index] = Math.min(dp[i][index], dp[i][j] + b.get(i));
          dp[i+1][j] = Math.min(dp[i][j], dp[i+1][j]);
          dp[i+1][index] = Math.min(dp[i+1][index], dp[i][j] + b.get(i));
        }
        
        if(j < a.get(i)){
          dp[i+1][j] = dp[i][j];
        }else{
          if(dp[i+1][j-a.get(i)] == Long.MAX_VALUE){
            dp[i+1][j] = Math.min(dp[i][j], Long.MAX_VALUE);
          }else{
            dp[i+1][j] = Math.min(dp[i][j], dp[i+1][j-a.get(i)] + b.get(i));
          }
        }
      }
    }
    

    System.out.println(dp[n][h]);
  }
}

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

int main(void) {
    long n;
    cin >> n;
    vector<long> a(n);
    long sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
        sum += a.at(i);
    }
    long min = a.at(0);
    long max = a.at(0);
    for (int i = 0; i < n; i++) {
        if (a.at(i) <= min) {
            min = a.at(i);
        }
        if (a.at(i) >= max) {
            max = a.at(i);
        }
    }
    
    cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3164
#include <iostream>
#include <queue>
#include <vector>
#include <cstdint>
#include <algorithm>
using namespace std;

#define LL int64_t

LL h,w;
vector<pair<LL,LL>> heap;
unsigned long long ans=0;
LL oper[2];
int main()
{
    cin>>w>>h;
    oper[0]=w+1;
    oper[1]=h+1;
    for (int i=0;i<w;i++)
    {
     LL temp;
     cin>>temp;
     heap.push_back(make_pair(temp,0));
    }
    for (int i=0;i<h;i++)
    {
     LL temp;
     cin>>temp;
     heap.push_back(make_pair(temp,1));
    }
    //while (!heap.empty())
    sort(heap.begin(),heap.end());
    for (auto f:heap)
    {
    // auto f=heap.top();
     //heap.pop();
     ans+=oper[1-f.second]*f.first;
     //cout<<f.first<<' '<<oper[1-f.second]<<' '<<oper[f.second]<<' '<<f.second<<' '<<ans<<endl;
     oper[f.second]--;
    // cout<<f.first<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,m,n) for(int i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;


int main(){
  int s,w;
  cin >> s >> w;
  if(w>=s)cout << "unsafe";
  else cout << "safe";
}


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
using namespace std;
#include <cmath>
#include <cstring>
#include <algorithm>
int main()
{
    int X,a,b,c,i,j,n,m=0;
    cin>>a>>b>>c>>X;
    for(i=0; i<=a&&i*500<=X; i++)
        for(j=0; j<=b&&j*100<=X; j++)
            for(n=0; n<=c&&n*50<=X; n++)
                if((i*500+j*100+n*50)==X)
                    m++;
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a);i>int(b);--i)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define show(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl;
#define MOD 1000000007
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define SZ(x) ((int)(x).size())
#define sum(v,i) accumulate(all(v),i)
//#define int long long
using ll = long long;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
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 (b < a) { a = b; return 1; } return 0; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }//最大公約数
int lcm(int a, int b) { return a * b / gcd(a, b); }	//最小公倍数
//template <typename... Args>void IN(Args& ... args) {cin >>args;IN(args...);return;} //まとめて入力　IN(a,b,c,d...)

void Main() {
	int nn; cin >> nn;
	//char ss[4010]; cin >> ss;
	string ss; cin >> ss;
	//rep(i, strlen(ss)) {
	rep(i,ss.length()){
		int n = nn;
		if (int(ss[i]) + n > 65 + 25)n =n-26;
		ss[i] = ss[i] + n;
	}
	//string s; cin >> s;
	//cout << char(s[1]+ 1);
	//printf("%d", ss);
	//cout <<int(ss) ;
	//for (i = 0; moji[i] != '\0'; ++i);
	//cout << int(ss[0]);
	cout << ss;

}

signed main() {
	Main();

	return 0;
}


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

int main(){
  int i,h,w,d;

  scanf("%d %d %d",&h,&w,&d);
  int a[h*w][2],s;
  for(i=0;i<h;i++){
    for(int j=0;j<w;j++){
      scanf(" %d",&s);
      a[s-1][0]=i;
      a[s-1][1]=j;
    }
  }

  int q;
  scanf("%d",&q);
  int l,r;
  int z[q];
  int b[h*w];

  for(i=0;i<d;i++) b[i]=0;
  for(i=d;i<h*w;i++){
    b[i]=b[i-d]+abs(a[i][0]-a[i-d][0])+abs(a[i][1]-a[i-d][1]);
  }

  for(i=0;i<q;i++) z[i]=0;

  for(i=0;i<q;i++){
    scanf("%d %d",&l,&r);
    z[i]=b[r-1]-b[l-1];
  }

  for(i=0;i<q;i++) printf("%d\n",z[i]);
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define P pair<int,int>
#define enld endl


int main() {
	lint N, K;
	cin >> N >> K;
	lint ans = 0;
	for (lint i = K; i <= N; i++) {
		ans += i * (N - i + 1) + 1;
		ans %= 1000000007;
	}
	cout << ans+1 << endl;
}

Measured memory_bytes: 3592
s = list(input())
a_cnt = 0
b_flag = 0
total = 0

for c in s:
#  print(c, a_cnt, b_flag)
  if c == "A":
    if b_flag == 1:
      b_flag = 0
      a_cnt = 1
    else:
      a_cnt += 1
  elif c == "B":
    if b_flag:
      b_flag = 0
      a_cnt = 0
    elif a_cnt:
      b_flag = 1
  elif c == "C":
    if b_flag:
      total += a_cnt
      b_flag = 0
#      print(total)
    else:
      a_cnt = 0
      
print(total)

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

int main(){
  int a,b; cin >> a >> b;
  if(b==0) {
    cout << "Zero" << endl;  
  } else if(b>0) {
    cout << ( a<=0 ? "Zero" : "Positive" ) << endl;  
  } else {
    cout << ( (b-a+1)%2==0 ? "Positive" : "Negative" ) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  string s;
  cin >> s;
  if (s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi") cout << "Yes" << endl;
  else cout << "No" << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256