akhauriyash/Code-Regression huggingface dataset:
//----->|try=0; while(!success) try++;|<------
//----->|Belief Yourself,Respect Yourself|<----
//----->|Be Proud Of Yourself,You're Doing Your best|<-----
#include<bits/stdc++.h>
using namespace std;
#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search;
#define lower(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Lower value search;
#define max3(a,b,c) max(max(a,b),c)//maximum value find three value;
#define min3(a,b,c) min(min(a,b),c)//minimum value find three value;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, n) for(int i = 1; i <= n; ++i)
#define rep1(i,start,n) for(int i=start;i<n;++i)
#define PI acos(-1.0)//PI Calculation
#define LL long long
#define AND(a,b) ((a) & (b))
#define OR(a,b) ((a)|(b))
#define XOR(a,b) ((a) ^ (b))
#define MP make_pair
#define sqr(x) ((x)*(x))
#define sqrt(x) sqrt(1.0*(x))
#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define MX 1000005
#define MOD 1000000007
template<typename T> T POW(T b,T p)          //Pow calculation
{
    T r=1;
    while(p)
    {
        if(p&1)r=(r*b);
        b=(b*b);
        p>>=1;
    }
    return r;
}

template<typename T> T BigMod(T b,T p,T m) //BigMod Calculation
{
    T r=1;
    while(p)
    {
        if(p&1)r=(r*b)%m;
        b=(b*b)%m;
        p>>=1;
    }
    return r;
}

//||--------------------------->||Main_Code_Start_From_Here||<---------------------------------||
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    LL a,b,c,ans;
    while(cin>>a>>b>>c)
    {
        //ans=0;

        LL t1=a/c;
        LL t2=b/c;
        LL ans=t2-t1;
        if(a%c==0) ans+=1;

        cout<<ans<<endl;
    }

}


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

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

int main() {
	int cnt = 0;
	while (1) {
		cnt++;
		int num;
		cin >> num;
		if (num == 0) {
			break;
		}
		cout << "Case " << cnt << ": " << num << endl;
	}
	return 0;
}



Measured memory_bytes: 2976
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pf push_front
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("board.in");ofstream out("board.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

ll f(ll r, ll c, ll d){
    ll n = c*d/__gcd(c,d);
    return r/c+r/d-r/n;
}

int main() {
    fast;
    ll a,b,c,d; cin>>a>>b>>c>>d;
    cout<<b-a+1-(f(b,c,d)-(a==1 ? 0 : f(a-1,c,d)));
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]

pre_max = 0
pre_max_2 = 0
forward = [0]
backward = [0]
for ii in range(1, N):
    pre_max = max(pre_max, A[ii-1])
    forward.append(pre_max)
    pre_max_2 = max(pre_max_2, A[-ii])
    backward.append(pre_max_2)

backward.reverse()

for ii in range(N):
    print(max(forward[ii], backward[ii]))


Measured memory_bytes: 15664
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <climits>
#include <utility>
#include <deque>
using namespace std;

int main()
{
	vector<int> pqr(3);
	for (auto& v : pqr)cin >> v;
	sort(pqr.begin(), pqr.end());

	cout << pqr[0] + pqr[1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;

int N, H;
int a[100010], b[100010];
int res;

void solve()
{
	int i;
	int mxa = a[0];
	for(i=1; i<N; i++){
		if(mxa<a[i])
			mxa = a[i];
	}
	sort(b, b+N, greater<int>() );
	for(i=0; i<N; i++){
		if(b[i]<=mxa)
			break;
		H -= b[i];
		res ++;
		if(H<=0)
			break;
	}
	if(H>0){
		res += (H-1)/mxa+1;
	}
	printf("%d\n", res);
}

int main()
{
	int i;
	scanf("%d%d", &N, &H);
	for(i=0; i<N; i++)
		scanf("%d%d", &a[i], &b[i]);
	solve();
	return 0;
}

Measured memory_bytes: 896
# ABC 72, C - together
from collections import Counter

n = int(input())
A = [int(el) for el in input().split(' ')]
C = Counter(A)
max_count = 0
for x in range(min(A), max(A)+1):

    count = C[x-1] + C[x] + C[x+1]

    if count > max_count:
        max_count = count
print(max_count)


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

int main() {
  int N, A, x, y, N2, A1;
  cin >> N;

  N2 = pow(2, N);
  int dp[N2];
  for (int i = 0; i < N2; i++) dp[i] = i;

  for (int i = 0; i < N; i++) {
    cin >> A;
    for (int j = 0; j < A; j++) {
      cin >> x >> y;
      x--;
      for (int k = 0; k < N2; k++) {
        if (dp[k] == 0) continue;

        if ((dp[k] >> i) & 1)
          if (((dp[k] >> x) & 1) != y) dp[k] = 0;
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < N2; i++) {
    if (dp[i] == 0) continue;
    int tempAns = 0;
    for (int j = 0; j < N; j++) {
      tempAns += dp[i] >> j & 1;
    }
    ans = max(ans, tempAns);
  }

  cout << ans << endl;

  return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

ll n;
ll x[101010],y[101010],t[101010];

int main(){
	cin>>n;
  repl(i,1,n+1)cin>>t[i]>>x[i]>>y[i];
  rep(i,n){
    ll d=t[i+1]-t[i];
    ll dl=abs(x[i]-x[i+1])+abs(y[i]-y[i+1]);
    if(dl>d||dl%2!=d%2){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int r;
  cin >> r;

  if (r < 1200) cout << "ABC" << endl;
  else if (r < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
}


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


class Main {
	static final int MASS = 21;
	static int PX,PY;
	static int[][] map = new int[MASS][MASS];
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			int ts = Integer.parseInt(in.readLine());
			if(ts == 0){
				break;
			}
			PX = 10;
			PY = 10;
			for(int i= 0;i < map.length ;i++){
				Arrays.fill(map[i], 0);
			}
			for(int i = 0; i < ts ;i++){
				String[] s = in.readLine().split(" ");
				map[Integer.parseInt(s[0])][Integer.parseInt(s[1])] = 1;
			}
			int mn = Integer.parseInt(in.readLine());
			int gettr = 0;
			for(int i = 0; i < mn ;i++){
				String[] s = in.readLine().split(" ");
				gettr = gettr + move(s[0],Integer.parseInt(s[1]));
			}
			if(ts == gettr){
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}	
	}
	static int move(String h ,int n){
		int num = 0;
		if(h.equals("N")){
			for(int i = 1;i <= n;i++){
				if(map[PX][PY+i] == 1){
					num++;
					map[PX][PY+i] = 0;
				}	
			}	
			PY = PY + n;
		}
		else if(h.equals("S")){
			for(int i = 1;i <= n;i++){
				if(map[PX][PY-i] == 1){
					num++;
					map[PX][PY-i] = 0;
				}	
			}	
			PY = PY - n;
		}
		else if(h.equals("E")){
			for(int i = 1;i <= n;i++){
				if(map[PX+i][PY] == 1){
					num++;
					map[PX+i][PY] = 0;
				}	
			}
			PX = PX + n;
		}
		else {
			for(int i = 1;i <= n;i++){
				if(map[PX-i][PY] == 1){
					num++;
					map[PX-i][PY] = 0;
				}		
			}	
			PX = PX - n;
		}
		return num;
	}

}

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

int main(void)
{
    int N,cnt = 0;
    cin >> N;

    vector<int> l(N);
    rep(i, N) 
        cin >> l[i];

    sort(l.begin(),l.end());
    for(int i = 0;i < N;i++){
        for(int j = i+1;j < N;j++){
            for(int k = j+1;k < N;k++){
                if(l[i] != l[j] && l[i] != l[k] && l[j] != l[k] && l[k] <l[i]+l[j])
                    cnt++;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 200000
#define INF 10000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    int n;
    IN(n);
    vector<int>a(n+1),b(n);
    REP(i,n+1){
        IN(a[i]);
    }
    REP(i,n){
        IN(b[i]);
    }
    int tmp=0;
    ll ans=0;
    REP(i,n){
        if(a[i]>=b[i]){
            ans+=b[i];
        }else{
            ans+=a[i];
            if(a[i+1]>=b[i]-a[i]){
                ans+=b[i]-a[i];
                a[i+1]-=b[i]-a[i];
            }else{
                ans+=a[i+1];
                a[i+1]=0;
            }
        }
    }
    OUT(ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <tuple>
#include <bitset>
#include <random>
#define REP(i,n) for(int i=0;i<n;i++)
#define INF 100000000000007
using namespace std;
using pii=pair<int,int>;
using LL=int64_t;





int main(){
    int n;
    cin>>n;
    int ans=n%1000;
    if(ans!=0){
    ans=1000-ans;
    }
    cout<<ans<<endl;


    
    return 0;
}

Measured memory_bytes: 3160
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))}
const main=()=>{
  let n=tn(),m=tn(),a=[],b=[],bb=[]
  for(let i=0;i<n;i++)a.push(ts().split(''))
  for(let i=0;i<m;i++)b.push(ts())
  let f=true
  for(let i=0;i<=n-m;i++){
    for(let j=0;j<=n-m;j++){
      let f=true
      for(let k=0;k<m;k++){
        if(a[i+k].slice(j,j+m).join('')!=b[k])f=false
      }
      if(f){
        to('Yes')
        return
      }
    }
  }
  to('No')
}
main()

Measured memory_bytes: 10060
(defn a [nums]
  (->> nums
       (sort <)
       (take 2)
       (apply +)))

(let [args (-> (line-seq (java.io.BufferedReader. *in*))
               first
               (clojure.string/split #" "))]
  (->> args (mapv #(Integer/parseInt %)) a prn ))

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T, typename U, typename V> inline
ostream& operator<<(ostream &o, tuple<T,U,V> &p)
{
    return o << "{" << get<0>(p) << "," << get<1>(p) << "," << get<2>(p) << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

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

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

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

int main(void)
{
    ll n, k;
    cin >> n >> k;
    
    map<int, ll> kmod;
    irep2(i, 1, n) {
        if(i%k) {
            kmod[i%k]++;
        } else {
            kmod[k]++;
        }
    }
    
    ll ans = 0;
    irep2(a, 1, n) {
        ll bc =2* (k - (a%k));    
        if(bc % k == 0) {
            ans += kmod[k-(a%k)] * kmod[k-(a%k)];
        }
    }
    cout << ans << endl;

    return 0;
}


/*atcoder*/


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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

#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int a,b;
    cin>>a>>b;
    a *= b;
    if(a%2==1) yn;
    //cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
    string s;
    cin >> s;
    ll cnt = 0;
    ll ans = 0;
    rep(i, 3)
    {
        if (s[i] == 'R')
            cnt++;
        else
        {
            ans = max(cnt, ans);
            cnt = 0;
        }
    }
    ans = max(cnt, ans);

    cout << ans << endl;
}

Measured memory_bytes: 3620
$<.gets.to_i.times do
  text = $<.gets.chomp
  result = ""
  po = 0
  while result.size < text.size
    if text[po, 7] == "Hoshino"
      result += "Hoshina"
      po += 7
    else
      result += text[po]
      po += 1
    end
  end
  puts result
end


Measured memory_bytes: 7516
function main(input) {
  input = input.trim().split("\n");
  const [n, k] = input[0].split(" ").map(n => Number(n));
  const hs = input.slice(1).map(n => Number(n));
  hs.sort((a, b) => a - b);
  let result;
  for (let i = 0; i <= n - k; i++) {
    const dif = hs[i + k - 1] - hs[i];
    if (result === undefined || dif < result) {
      result = dif;
    }
  }
  console.log(result)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30540
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int maxn=100005;

int n,q,l,sec,st[maxn],ed[maxn];
vector<vector<int>>up;
vector<int>G[maxn];

void dfs(int u,int p) {
	st[u]=sec++;
	up[u][0]=p;
	for (int i=1;i<=l;i++) 
		up[u][i]=up[up[u][i-1]][i-1];
	for (int v:G[u])
		if (v!=p) dfs(v,u);
	ed[u]=sec;
}

bool upper(int u,int v) {
	return st[u]<st[v] && ed[u]>=ed[v];
}

int lca(int u,int v) {
	if (u==v) return u;
	if (upper(u,v)) return u;
	if (upper(v,u)) return v;
	for (int i=l;i>=0;i--) 
		if (!upper(up[u][i],v))
			u=up[u][i];
	return up[u][0];
}

int main() {
	cin>>n;
	for (int i=0;i<n;i++) {
		int m; cin>>m;
		for (int j=0;j<m;j++) {
			int v; cin>>v;
			G[i].pb(v);
		}
	}
	while ((1<<l)<=n) l++;
	 up.assign(n, vector<int>(l + 1));
	dfs(0,0);
	cin>>q;
	for (int i=0;i<q;i++) {
		int u,v; cin>>u>>v;
		cout<<lca(u,v)<<'\n';
	}
}


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    ll x, y;

    cin >> x >> y;
    
    ll ans = LINF;
    
    if(x <= y) { ans = min(ans, y-x); }
    if(-x<= y) { ans = min(ans, y+x+1); }
    if(x <= -y) { ans = min(ans, -y-x+1); }
    if(-x<= -y) { ans = min(ans, -y+x+2); }

    cout << ans << endl;
    return 0;
}   
/** atcoder **/


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

// #define multitest 1
#ifdef WIN32
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.first << ", " << p.second << ']';
	return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
	std::cerr << name << " { ";
	for (const auto &v : arg)
		cerr << v << ' ';
	cerr << " }\n";
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;
auto TimeStart = chrono::steady_clock::now();

const int nax = 2e5 + 10;

void solve()
{
	int n, x;
	cin >> n;
	vector<pair<int, int>> St;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		St.pb({x, i});
	}
	sort(St.begin(), St.end());
	for (int i = 0; i < n; ++i)
		cout << St[i].s + 1 << ' ';
}

int main()
{
#ifndef WIN32
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
#ifdef WIN32
	cerr << "\n\nTime elapsed: " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " seconds.\n";
	flush(cout);
#endif
	return 0;
}

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

struct Edge{
  ll to;
  ll weight;
  Edge(ll t,ll w) : to(t),weight(w){}
};

using Graph = vector<vector<Edge>>;



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

  for(int i=0;i<n-1;++i){
    ll from,to,weight;
    cin >> from >> to >> weight;
    from--;
    to--;
    G[from].push_back(Edge(to,weight));
    G[to].push_back(Edge(from,weight));
  }
  vector<ll> dist(n,-1);
  queue<ll> que;
  int q,k;
  cin >> q >> k;
  k--;
  //cout << q << endl;
  vector<ll> x(q),y(q);
  for(int i=0;i<q;i++){
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
    //cout << "OK" << endl;
  }
  dist[k]=0;
  que.push(k);
  while(!que.empty()){
    ll v=que.front();
    que.pop();
    for(auto nv : G[v]){
      if(dist[nv.to]==-1 || dist[nv.to]>dist[v]+nv.weight){
        dist[nv.to]=dist[v]+nv.weight;
        que.push(nv.to);
      }
    }
  }
  for(int i=0;i<q;++i){
    ll ans=dist[x[i]]+dist[y[i]];
    cout << ans << endl;
  }
  return 0;
}


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

#define MAX 2000001
#define VMAX 10000
int main(){ 
    unsigned short *A,*B;

    int C[VMAX+1];
    int n,i,j;
    cin>>n;

    A=(unsigned short*)malloc(sizeof(unsigned short)*n+1);
    B=(unsigned short*)malloc(sizeof(unsigned short)*n+1);

    for(i=0;i<=VMAX;i++)C[i]=0;
            
    for(i=0;i<n;i++){
        cin>>A[i];
        C[A[i]]++;
    }   
    for(i=0;i<VMAX;i++)C[i+1]=C[i+1]+C[i];

    for(i=0;i<n;i++){
        B[C[A[i]]]=A[i];
        C[A[i]]--;                                                        
    }   
    for(i=1;i<=n;i++){
        cout<<(i>1?" ":"")<<B[i];
    }   
    cout<<"\n";
    return 0;

}



Measured memory_bytes: 10904
#include<bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
int arr[305][305]; 

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);  //关闭输入输出流，相当于scanf和printf速度更快 
	int n,m,l;
	cin>>n>>m>>l;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i==j)arr[i][j]=0;
			else arr[i][j]=INF;
		}
	}
	while(m--){
		int a,b,w;
		cin>>a>>b>>w;
		arr[a][b]=w;
		arr[b][a]=w;
	}
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if(arr[i][k]+arr[k][j]<arr[i][j])
					arr[i][j]=arr[i][k]+arr[k][j];
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(arr[i][j]<=l)arr[i][j]=1;
			else arr[i][j]=INF;
		}
	}
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if(arr[i][k]+arr[k][j]<arr[i][j])
					arr[i][j]=arr[i][k]+arr[k][j];
			}
		}
	}	
	int q;
	cin>>q;
	while(q--){
		int s,t;
		cin>>s>>t;
		if(arr[s][t]>=INF)cout<<"-1"<<"\n";
		else cout<<arr[s][t]-1<<"\n";
	}
	return 0;
} 

Measured memory_bytes: 896
def main():
    a = list(map(int, input().split()))

    ans = 0
    while True:
        a.sort()
        if a[0] == a[1] and a[1] == a[2]:
            break
        elif a[1] < a[2]:
            a[0] += 1
            a[1] += 1
        else:
            a[0] += 2
        ans += 1

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll h; cin>>h;
	ll a; cin>>a;
	cout<<h/a+(h%a!=0)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

	int n;
char dp[1<<24];
const char NONE=255;
int dfs(vi &c,vvi &g,vi &cnt,int mask){
	int ret=0;
	if(dp[mask]!=NONE){
		return dp[mask];
	}
	REP(i,n){
		FOR(j,i+1,n){
			if(cnt[i]==0&&cnt[j]==0&&c[i]==c[j]&&!(mask&(1<<i))&&!(mask&(1<<j))){
				vi ncnt(cnt);
				REP(k,n){
					if(g[i][k]){
						ncnt[k]--;
					}
					if(g[j][k]){
						ncnt[k]--;
					}
				}
				int nmask=mask;
				nmask|=(1<<i);
				nmask|=(1<<j);
				ret=max(ret,dfs(c,g,ncnt,nmask)+2);
			}
		}
	}
	return dp[mask]=ret;
}

int main(){
	while(cin>>n,n){
		REP(i,(1<<24)){
			dp[i]=NONE;
		}
		vi x(n),y(n),r(n),c(n);
		vvi g(n,vi(n));
		vi cnt(n);
		REP(i,n){
			cin>>x[i]>>y[i]>>r[i]>>c[i];
		}
		REP(i,n){
			FOR(j,i+1,n){
				int dx=abs(x[i]-x[j]);
				int dy=abs(y[i]-y[j]);
				int rr=r[i]+r[j];
				if(dx*dx+dy*dy<rr*rr){
					g[i][j]=1;
					cnt[j]++;
				}
			}
		}
		cout<<dfs(c,g,cnt,0)<<endl;
	}
}

Measured memory_bytes: 17612
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	int x,t;
	cin>>x>>t;
	cout<<max(0,x-t);
	re 0;
}

Measured memory_bytes: 3608
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int cCount = 0;
    bool firstA = false;
    bool bad = false;
    for(int i = 0; i < S.length(); i++){
        if(i == 0){
            if(S.at(0) == 'A'){
                firstA = true;
            }
            
        }else if(i >= 2 && i < S.length()-1){
            if(S.at(i) == 'C'){
                cCount++;
            }else if(isupper(S.at(i))){
                bad = true;
            }
        }else{
            if(isupper(S.at(i))){
                bad = true;
            }
        }
    }
    string ans;
    if(firstA && cCount == 1 && !bad){
        ans = "AC";
    }else{
        ans = "WA";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    string s; cin >> s;
    Out(s.substr(0, SZ(s) - 8));

    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]

EDGE = [[] for _ in range(N+1)]

for a,b in AB:
  EDGE[a].append(b)
  EDGE[b].append(a)
  
def dfs(p,u,d):
  if u == N:
    return True
  
  if d == 0:
    return False
  
  ans = False
  
  for v in EDGE[u]:
    if v == u:
      continue
      
    ans |= dfs(u,v,d-1)
  
  return ans

ans = dfs(-1,1,2)

s = 'POSSIBLE' if ans else 'IMPOSSIBLE'

print(s)


Measured memory_bytes: 66820
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

int main() {
	ll n = 0, m = 0,counter = 0;
	string in;
	vector<ll>vec;
	cin >> n;
	rep(i, n) {
		cin >> m;
		counter = 0;
		while (m % 2 == 0) {
			counter++;
			m/=2;
		}
		vec.push_back(counter);
	}
	sort(vec.begin(), vec.end());
	cout << vec[0] << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
typedef long double ld;
const ld eps = 1e-9;

vector<ld> quadraticEquation(ld a, ld b, ld c){
    if(abs(a) < eps){
        return { -c/b };
    } else {
        ld d = b*b - 4*a*c;
        if(abs(d) < eps){
            return { (-b + sqrt(d)) / (2*a) };
        } else if(0 < d){
            return { (-b + sqrt(d)) / (2*a),
                     (-b - sqrt(d)) / (2*a) };
        } else {
            return {};
        }
    }
}

ld simpson(ld x0, ld x_max, function<ld(ld)> f){
    ld a;
    const int n = 1e5;
    const ld dx = (x_max - x0) / n;
    a = f(x0);
    a += f(x0 + dx * n);
    int i;
    for(i=1; i<n; i+=2){
        a += 4.0 * f(x0 + dx * i);
    }
    for(i=2; i<n; i+=2){
        a += 2.0 * f(x0 + dx * i);
    }
    return a*dx/3.0;
}

ld W,H,N;
ld a[55], p[55], q[55];

ld f(int i, ld x){
    return a[i]*(x-p[i])*(x-p[i]) + q[i];
}

bool inside(ld x, ld y){
    if (x < -eps || W < x-eps) return false;
    if (y < -eps || H < y-eps) return false;
    return true;
}

ld solve(){
    vector<ld> es = { 0, W };
    rep(i,N){
        auto xs = quadraticEquation(a[i], -a[i]*2*p[i], q[i] + a[i]*p[i]*p[i]); // on x axis
        for(ld x : xs) if(inside(x,f(i,x))) es.push_back(x);
        rep(j,i){
            ld aa = a[i] - a[j];
            ld bb = -a[i]*2*p[i] - (-a[j]*2*p[j]);
            ld cc = (q[i] + a[i]*p[i]*p[i]) - (q[j] + a[j]*p[j]*p[j]);
            auto cs = quadraticEquation(aa, bb, cc);
            for(ld x : cs) {
                if(inside(x,f(i,x))){
                    es.push_back(x);
                }
            }
        }
    }
    sort(es.begin(), es.end());
    ld ans = 0;
    rep(i,es.size()-1){
        ld x1 = es[i], x2 = es[i+1];
        ld m = (x1+x2) / 2;
        int idx = -1;
        ld maxy = -1e9;
        rep(j,N){
            if(maxy < f(j,m)){
                maxy = f(j,m);
                idx = j;
            }
        }
        if(maxy > -eps){
            ans += simpson(x1, x2, [&](ld x){
                    ld dy = a[idx] * 2 * (x - p[idx]);
                    return sqrt(1 + dy*dy);
                });
        }
    }
    return ans;
}

int main(){
    while(cin >> W >> H >> N){
        rep(i,N) cin >> a[i] >> p[i] >> q[i];
        printf("%.10lf\n", (double)solve());
    }
}

Measured memory_bytes: 3384
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<vector<Int> > G(n);
  for(Int i=1;i<n;i++){
    Int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  Int k;
  cin>>k;
  vector<Int> c(k),d(k);
  for(Int i=0;i<k;i++) cin>>c[i]>>d[i],c[i]--;

  auto check=[&](Int x){
    if(!x){
      cout<<"No"<<endl;
      exit(0);
    }
  };
  const Int INF = 1e8;
  vector<Int> x(n,-INF),y(n,-INF),a(n,-1);
  auto calc=[&](auto &z,Int o){
    using P = pair<Int, Int>;
    priority_queue<P> pq;
    for(Int i=0;i<k;i++){
      a[c[i]]=z[c[i]]=o*d[i];
      pq.emplace(z[c[i]],c[i]);
    }
    while(!pq.empty()){
      Int v,w;
      tie(w,v)=pq.top();pq.pop();
      if(z[v]>w) continue;
      for(Int u:G[v]){
	Int nw=w-1;
	check(z[u]==-INF||(z[u]-nw+INF)%2==0);
	if(a[u]<0&&z[u]<nw){
	  z[u]=nw;
	  pq.emplace(z[u],u);
	}
      }
    }
    for(Int i=0;i<n;i++) z[i]*=o;
  };
  calc(x,1);
  calc(y,-1);
  for(Int i=0;i<n;i++)
    check(x[i]<=y[i]);
  cout<<"Yes"<<endl;
  //for(Int i=0;i<n;i++) cout<<x[i]<<" "<<y[i]<<endl;
  for(Int i=0;i<n;i++) cout<<x[i]<<endl;
  return 0;
}


Measured memory_bytes: 13788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    ll N,A,B;
    cin >> N >> A >> B;
    cout << N/(A+B)*A+ min(N%(A+B),A) << endl;

    
    
    
    

    return 0;
}


Measured memory_bytes: 256
/*===================*\
|ID : harryPotter_421  |
|      LANG: C++       |
\*====================*/
#include <iostream>
#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define pb push_back
#define f(j,m,n) for(lli j=m;j<n;j++)
#define harry ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
   {harry
    lli n;
    cin>>n;
    lli arr[n+1][4];
    for(lli i=1;i<=n;i++)
     {cin>>arr[i][1]>>arr[i][2]>>arr[i][3];}
     lli dp[n+1][4];
     dp[1][1]=arr[1][1];
     dp[1][2]=arr[1][2];
     dp[1][3]=arr[1][3];
     for(int i=2;i<=n;i++)
        {dp[i][1]=max(dp[i-1][2]+arr[i][1],dp[i-1][3]+arr[i][1]);
         dp[i][2]=max(dp[i-1][1]+arr[i][2],dp[i-1][3]+arr[i][2]);
         dp[i][3]=max(dp[i-1][2]+arr[i][3],dp[i-1][1]+arr[i][3]);
        }
    cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
   }

















Measured memory_bytes: 6528
N=int(input())
lst=[tuple(map(int,input().split())) for _ in range(N)]
lst_=sorted(lst,key=lambda x:x[1])
t=0
for n in range(N):
    t+=lst_[n][0]
    if t>lst_[n][1]:
        print("No")
        exit(0)
print("Yes")

Measured memory_bytes: 33364
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define for(i,a,b) for(ll i=a;i<b;i++)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  int n;
  string s;
  cin >> n >> s;
  vl r_dp(n,0),g_dp(n,0),b_dp(n,0);
  for(i,0,n-1){
    if(s[i]=='R'){
      r_dp[i+1]=r_dp[i]+1;
      g_dp[i+1]=g_dp[i];
      b_dp[i+1]=b_dp[i];
    }
    else if(s[i]=='G'){
      g_dp[i+1]=g_dp[i]+1;
      r_dp[i+1]=r_dp[i];
      b_dp[i+1]=b_dp[i];
    }
    else{
      b_dp[i+1]=b_dp[i]+1;
      g_dp[i+1]=g_dp[i];
      r_dp[i+1]=r_dp[i];
    }
  }
  ll cnt=0;
  for(i,1,n-1){
    for(j,i+1,n){
      if(s[i]!=s[j]){
        if(s[i]!='R'&&s[j]!='R'){
          cnt +=r_dp[i];
          if(2*i-j>=0&&s[2*i-j]=='R'){
            cnt--;
          }
        }
        if(s[i]!='G'&&s[j]!='G'){
            cnt +=g_dp[i];
            if(2*i-j>=0&&s[2*i-j]=='G'){
              cnt--;
           }
         }
    if(s[i]!='B'&&s[j]!='B'){
          cnt +=b_dp[i];
          if(2*i-j>=0&&s[2*i-j]=='B'){
            cnt--;
          }
        }
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3704
#include<stdio.h>
main(){
  int i,j,sum,n,ans;
  int a[5000];
  while(1){
    scanf("%d",&n);
    ans=-100000000;
    if(n==0){
      break;
    }
    for(i=0;i<n;i++){
      scanf("%d",&a[i]);
      }
    for(i=0;i<n;i++){
      sum=0;
      for(j=i;j<n;j++){
	sum+=a[j];
	if(sum>ans){
	  ans=sum;
	}
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, a[102] = {}, b[102] = {}, z = 0;
    cin >> n;
    fr1(n) cin >> a[i];
    fr1(n) cin >> b[i];
    fr1(n) a[i] += a[i - 1];
    for (int i = n; i; i--) b[i] += b[i + 1];
    fr1(n) z = max(z, a[i] + b[i]);
    cout << z;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = a % 10;

    let c: String = convert_string(b);
    println!("{}", c);
}

fn convert_string(i: u32) -> String {
    return match i {
        3 => "bon".to_string(),
        0 => "pon".to_string(),
        1 => "pon".to_string(),
        6 => "pon".to_string(),
        8 => "pon".to_string(),
        _ => "hon".to_string()
    };
}

Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef long double     ld;
typedef string          str;
#define all(x)			(x).begin(),(x).end()
#define Sort(x)			sort(all(x))
#define A               first
#define B               second
#define sep             ' '
#define endl            '\n'
#define fast_io         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int MAX1 = 2e5 + 7;

ll a, b, c, T, d, e, l, r, x, y, z, mid, cnt, flag, mod = 1e9+7;
string s, t;
pair <ll, ll> num[MAX1];
vector <ll> vec;

int main(){
	fast_io;
	cin >> a;
	for (int i = 0; i < a; ++i){
		cin >> num[i].A;
		num[i].B = i+1;
	}
	sort(num, num+a);
	for (int i = 0; i < a; ++i)	cout << num[i].B << sep;
    return 0;
}
/*                          now or never                         */


Measured memory_bytes: 2432
#include<stdio.h>
int main(void){
	int n,d=0,i,j;
	char s[101],t[51];
	scanf("%d",&n);
	scanf("%s",s);

	for(i=0;i<n/2;i++){
		t[i]=s[i];
	}
	for(j=0;j<n/2;j++){
		if(s[i++] != t[j]){
			d=1;
			break;
		}
	}
	if(d==1 || n%2==1){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
}

Measured memory_bytes: 128
// atcoder/abl/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

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

using namespace std;

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

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

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

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

class UnionFind {
public:
  UnionFind(int n) {
    r.resize(n, 0);
    p.resize(n, -1);
  }
  void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if (a == b) return ;
    if (r[a] > r[b]) {
      p[a] += p[b];
      p[b] = a;
    } else {
      p[b] += p[a];
      p[a] = b;
      if(r[a] == r[b]) r[b]++;
    }
    return ;
  }
  int find(int a) {
    return (p[a] < 0) ? a : p[a] = find(p[a]);
  }
  bool same(int a, int b) {
    return find(a) == find(b);
  }
  size_t size(int n) {
    return -p.at(find(n));
  }
private:
  vector<int> r, p;
};

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

  int n, m;
  while (cin >> n >> m) {
    UnionFind uf(n);
    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      uf.unite(a, b);
    }
    for (int i = 0; i < n; ++i) {
      uf.find(i);
    }
    set<int> s;
    for (int i = 0; i < n; ++i) {
      s.insert(uf.find(i));
    }
    cout << s.size() - 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 7804
n,y=io.read("*n","*n")

for i=0,n do
    for j=0,n do
        x=y-(10000*i+5000*j)
        k=(x%1000==0 and x//1000 or 2*n)
        if i+j+k==n and x>=0 then
            print(i,j,k)
            return
        end
    end
end
print(-1,-1,-1)

Measured memory_bytes: 376
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

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

template <int M> class ModInt {
    int x;

  public:
    constexpr ModInt() : x(0) {}
    constexpr ModInt(int64_t y) : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}
    constexpr ModInt &operator+=(const ModInt p) {
        if((x += p.x) >= M) x -= M;
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt p) {
        if((x += M - p.x) >= M) x -= M;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt p) {
        x = (int)(1LL * x * p.x % M);
        return *this;
    }
    constexpr ModInt &operator/=(const ModInt p) {
        *this *= p.inverse();
        return *this;
    }
    constexpr ModInt operator-() const { return ModInt(-x); }
    constexpr ModInt operator+(const ModInt p) const {
        return ModInt(*this) += p;
    }
    constexpr ModInt operator-(const ModInt p) const {
        return ModInt(*this) -= p;
    }
    constexpr ModInt operator*(const ModInt p) const {
        return ModInt(*this) *= p;
    }
    constexpr ModInt operator/(const ModInt p) const {
        return ModInt(*this) /= p;
    }
    constexpr bool operator==(const ModInt p) const { return x == p.x; }
    constexpr bool operator!=(const ModInt p) const { return x != p.x; }
    constexpr ModInt inverse() const {
        int a = x, b = M, u = 1, v = 0, t = 0;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    constexpr ModInt pow(int64_t k) const {
        ModInt ret(1), mul(x);
        while(k > 0) {
            if(k & 1) ret *= mul;
            mul *= mul;
            k >>= 1;
        }
        return ret;
    }
    constexpr friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
    constexpr friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t = 0;
        is >> t;
        a = ModInt(t);
        return (is);
    }
};
using modint = ModInt<mod>;

modint dp[100009];

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

    ll n, k;
    cin >> n >> k;

    for(int i = k; i; i--) {
        dp[i] = modint(k / i).pow(n);
        for(int j = i << 1; j <= k; j += i)
            dp[i] -= dp[j];
    }

    modint ans;
    FOR(i, 1, k + 1) {
        ans += dp[i] * i;
        // cout << dp[i] << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3996