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

int main() {
    cin.tie(NULL);
    ios::sync_with_stdio(false);
    long long int a,b;
    cin>>a>>b;
    int count=0;
    while(a<=b){
        a*=2;
        count++;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main(void) {
  ll N, M;
  cin >> N >> M;
  string S;
  cin >> S;
  vector<string> Q(M);
  REP(i, 0, M) cin >> Q[i];

  const ll B = 1009, MOD1 = 1000000007, MOD2 = 1000000009;
  vector<ll> p1(N + 1), p2(N + 1), h1(N + 1), h2(N + 1);
  p1[0] = p2[0] = 1;
  REP(i, 0, N) p1[i + 1] = (p1[i] * B) % MOD1;
  REP(i, 0, N) p2[i + 1] = (p2[i] * B) % MOD2;
  h1[0] = h2[0] = 0;
  REP(i, 0, N) h1[i + 1] = (h1[i] * B + S[i]) % MOD1;
  REP(i, 0, N) h2[i + 1] = (h2[i] * B + S[i]) % MOD2;

  ll l = 0, r = 1;
  set<pll> st;
  REP(i, 0, M) {
    if(Q[i] == "L++") l++;
    if(Q[i] == "L--") l--;
    if(Q[i] == "R++") r++;
    if(Q[i] == "R--") r--;

    ll x1 = (h1[r] - (h1[l] * p1[r - l] % MOD1) + MOD1) % MOD1;
    ll x2 = (h2[r] - (h2[l] * p2[r - l] % MOD2) + MOD2) % MOD2;
    st.insert(pll(x1, x2));
  }

  cout << st.size() << endl;
}



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

int main(){
  int N,a,b,c,d,e,f;
  cin >> N;
  a = N / 1000;
  b = ( N - 1000*a) / 100;
  c = ( N - 1000*a - b*100 ) / 10;
  d = N - 1000*a - 100*b - 10*c;
  if( a == b && b == c){
    cout << "Yes" << endl;
  }else if( b == c && c == d){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}
  


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

int main() {
    int N;
    cin >> N;
    int max_value = 0;
    int sum = 0;
    for (int i = 0; i < N; i++){
        int b = 0;
        cin >> b;
        sum += b;
        max_value = max(max_value, b);
    }
    cout << sum - max_value / 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n;
vector<pair<LL, LL>> v;

int main() {
	cin >> n;
	inc(i, n) {
		LL a, b;
		cin >> a >> b;
		v.EB(b, a);
	}
	sort(ALL(v));
	
	bool ans = true;
	LL t = 0;
	RF(e, v) {
		t += e.SE;
		ans &= (t <= e.FI);
	}
	
	cout << (ans ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 6384
#include <iostream>
using namespace std;
int main()
{
	int N;
	cin >> N;
	char S;
	string ans = "Three";
	for (int i = 0; i < N; i++)
	{
		cin >> S;
		if (S=='Y')
		{
			ans = "Four";
			break;
		}
	}
	cout << ans << endl;
}

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

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

  int n;

  while(1){
    cin >> n;
    if(n == 0) break;

    vector<int> a;
    int temp;
    for(int i = 0;i < n;++i){
      cin >> temp;
      a.push_back(temp);
    }

    int i;
    for(i = 0;i < 10001;++i){
      // 三角形がどうか調べる
      bool flag = true;
      for(int j = 0;j < a.size() && flag;++j){
	if(a[j] != j + 1){
	  flag = false;
	}
      }
      // 三角形ができた
      if(flag){
	cout << i << endl;
	break;
      }
      // 最下段ぶんを引く
      for(int j = 0;j < a.size();++j){
	--a[j];
      }
      a.push_back(a.size());
      // 最下段を最左行へ
      for(int j = 0;j < a.size();++j){
	if(a[j] == 0){
	  a.erase(a.begin() + j);
	  --j;
	}
      }
    }
    if(i == 10001){
      cout << "-1" << endl;
    }
  }

  return 0;
}




Measured memory_bytes: 3260
A, B, C, D, E, F = map(int, input().split())
ans = []
water = []
for i in range(31):
    for j in range(31):
        tmp = 100*i*A + 100*j*B
        if tmp <= F:
            water.append(tmp)
water = list(set(water))
water.remove(0)

sugar = []
for i in range(101):
    for j in range(101):
        tmp = i*C + j*D
        if tmp <= F:
            sugar.append(tmp)
sugar = list(set(sugar))
sugar.remove(0)

            
for miz in water:
    for sato in sugar:
        if miz + sato <= F and sato / (miz + sato) <= E / (100 + E):
            ans.append([miz, sato, sato / (miz + sato)])
            
if ans:
    ans.sort(key=lambda x:x[2], reverse = True)
    print(ans[0][0]+ans[0][1], ans[0][1])
else:
    print(water[0], 0)

Measured memory_bytes: 4208
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vi vector<ll>
#define pb push_back
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define pii pair<ll,ll>
#define vii vector<pii>
#define MOD 1000000007LL
#define calc_fact(n) tgamma(n+1)


signed main()
{
    FIO;
    ll n,k,x,y;
    cin>>n>>k>>x>>y;
    if(k>=n)cout<<x*n;
    else
    cout<<(x*k)+(n-k)*y;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(a, n) rep(hoge, n) printf("%d%c", a[hoge], hoge == n - 1? '\n' : ' ');
#define all(a) (a).begin(), (a).end()

using namespace std;
using P = pair<int, int>;
using ll = long long;

signed main() {
    bool ans[3];
    fill(ans, ans + 3, true);
    rep(i, 2) {
        int tmp;
        cin >> tmp;
        ans[tmp - 1] = false;
    }
    rep(i, 3) if(ans[i]) cout << i + 1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;
#pragma unused(M)

int main(){
	int t;
	cin >> t;
	for(int i=0;i<t;i++){
		int n, d;
		cin >> n >> d;
		priority_queue<int, vector<int>, greater<int>> pq;
		pq.push(d);
		// cout << solve(d, n - 1) << endl;
		for(int i=0;i<n-1;i++){
			int c = pq.top();
			pq.pop();
			pq.push(127);
			pq.push(127 ^ c);
		}
		int ans = 0;
		for(int i=0;i<n;i++){
			ans += pq.top();
			pq.pop();
		}
		cout << ans << endl;
	}
	// cout<<cnt<<endl;
	return 0;
}



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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N;
    int tanku[] = {5,7,5,7,7};
    vector<int> ans;
    while(true){
        cin >> N;
        if(N == 0) break;
        vector<int> work(N);
        rep(i, N){
            string temp; cin >> temp;
            work[i] = temp.length();
        }
        rep(i, N){
            int idx = i;
            int acc = 0;
            int phase = 0;
            while(phase < 5 && acc < tanku[phase]){
                acc += work[idx];
                if(acc == tanku[phase]){
                    acc = 0;
                    phase++;
                }
                idx++;
            }
            if(phase == 5){
                ans.push_back(i+1);
                break;
            }
        }
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long int lt;
typedef vector<ll> vi;
typedef vector<int> vin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
#define all(a) a.begin(),a.end()
#define rep(i,a,b) for(int i=a;i<b;++i)
#define f(i,b) for(int i=0;i<b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define test(t) int t; cin>>t; while(t--) solve()
#define endl "\n"
#define p1 cout<<"YES"<<endl
#define p0 cout<<"NO"<<endl
#define fst ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define read(x) for(auto &i:x) cin>>i;

const int mod=1e9+7;

ll mod_pow(ll a,ll n,ll mod)	//(a^n)%mod
{	ll res=1;
	while(n){	if(n&1)	res=(res*a)%mod; n/=2; a=(a*a)%mod;	}
	return res;
}

void solve()
{
    ll a,b,c,d;

    cin>>a>>b>>c>>d;

    ll ans=max(a*c,max(a*d,max(b*c,b*d)));
    cout<<ans<<endl;

}

int main()
{
    fst;
    //test(t);
    solve();
}



Measured memory_bytes: 3644
from collections import deque
n,q = map(int,input().split())
data = [[] for i in range(n)]
counter = [0]*n
visited = [0]*n
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    data[a].append(b)
    data[b].append(a)
for i in range(q):
    p,x = map(int,input().split())
    p -= 1
    counter[p] += x
dq =deque([0])
while dq:
    r = dq.pop()
    visited[r] = 1
    if data[r]:
        for i in data[r]:
            if not visited[i]:
                counter[i] += counter[r]
                dq.append(i)
print(" ".join(map(str,counter)))

Measured memory_bytes: 67168
import java.util.*;
import javax.lang.model.util.ElementScanner6;
//import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 入力
        int n = sc.nextInt();

        // 処理
        long out = 0;
        for(int i = 1; i <= n; i++){
            if(i % 3 == 0 || i % 5 == 0) {
                continue;
            } else {
                out += i;
            }
        }

        // 出力
        System.out.println(out);
    }

}

Measured memory_bytes: 35796
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> A(3);
  for(int i=0;i<3;i++){
    cin>>A.at(i);
  }
  int K;
  cin>>K;
  sort(A.begin(),A.end());
  
  A.at(2)=A.at(2)*pow(2,K);
  
  cout<<A.at(0)+A.at(1)+A.at(2)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;
typedef long long LL;

const int MOD = 1e9+7;
void solve(){
    char c;
    cin>>c;
    cout<<char(c+1)<<endl;
}

int main(){
    int T = 1;
    while(T--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

using namespace std;

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

typedef long long ll;
typedef unsigned long long ull;

int main(void) {
  string S; cin >> S;
  int A, B, C, D;

  A = S[0] - '0';
  B = S[1] - '0';
  C = S[2] - '0';
  D = S[3] - '0';

  int res;
  rep(i, 1 << 3) {
    res = A;
    res = res + ((i & (1 << 0)) ? B : -B);
    res = res + ((i & (1 << 1)) ? C : -C);
    res = res + ((i & (1 << 2)) ? D : -D);
    if (res != 7) continue;
    printf("%d%c%d%c%d%c%d=7\n",
        A, (i & (1 << 0)) ? '+' : '-',
        B, (i & (1 << 1)) ? '+' : '-',
        C, (i & (1 << 2)) ? '+' : '-',
        D);
    break;
  }
  return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n; cin >> n;
	vector<int> maru(n+1);
	vector<int> batu(n+1);

	string s; cin >> s;
	
	for (int i = 0; i < n; i++) {
		if (s[i] == '#') {
			batu[i+1] = batu[i] + 1;
		}
		else {
			batu[i + 1] = batu[i];
		}
	}

	for (int i = n-1; i>=0; i--) {
		if (s[i] == '.') {
			maru[i] = maru[i+1] + 1;
		}
		else {
			maru[i] = maru[i+1];
		}
	}

	LL ans = INF2;
	for (int i = 0; i < n+1; i++) {

		LL tmp = batu[i] + maru[i];

		if (i == 0) {
			tmp = maru[i];
		}

		if (i == n) {
			tmp = batu[i];
		}

		ans = min(ans, tmp);
	}

	cout << ans << endl;

	

	return 0;
}

Measured memory_bytes: 2180
#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1 << 21);

int n, M[N][N];
int d[N]; 
/* d[N] are distances which describe the state whether the node is already visited.
   if the value == INFTY, the edge is NOT yet visited.
 */

void bfs(int s) {
    queue<int> q;
    q.push(s);
    for (int i = 0; i < n; i++) d[i] = INFTY;
    d[s] = 0;
    int u;
    while (!q.empty()) {
        u = q.front(); q.pop();
        for (int v = 0; v < n; v++) {
            if (M[u][v] == 0) continue;
            if (d[v] != INFTY) continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    for (int i = 0; i < n; i++) {
        cout << i+1 << " " << ( (d[i] == INFTY) ? (-1) : d[i] ) << endl;
    }
}

int main() {
    int u, k, v;
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) M[i][j] = 0;
    }
    
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        u--; // because the index is 0-origin!
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--; // because the index is 0-origin!
            M[u][v] = 1; // edges between u and v are available (connected).
        }
    }
    
    bfs(0);
    
    return 0;
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  int N;
  cin >> N;
  vector<int> X(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }
  int ans = INF;
  sort(all(X));
  for (int i = X.front(); i <= X.back(); i++) {
    int tmp = 0;
    for (int j = 0; j < N; j++) {
      tmp += sqr(X[j] - i);
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

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

enum Tenki
{
    Sunny,
    Cloudy,
    Rainy
};

int main()
{
    string s;
    cin >> s;
    regex re(",");
    string fmt = " ";

    cout << regex_replace(s, re, fmt) << endl;

}

Measured memory_bytes: 256
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
xy=[lnii() for i in range(n)]
xy.sort(key=lambda x:x[0])

ans=n

pq=[]
for i in range(n):
  for j in range(n):
    if i==j:
      continue
    t_p=xy[j][0]-xy[i][0]
    t_q=xy[j][1]-xy[i][1]
    pq.append([t_p,t_q])

for p,q in pq:
  cnt=0
  for x,y in xy:
    if [x+p,y+q] in xy:
        cnt+=1
  ans=min(ans,n-cnt)

print(ans)

Measured memory_bytes: 9224
//Love and Freedom.
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#define inf 20021225
#define ll long long
#define N 100010
using namespace std;
int read()
{
	int f=1,s=0; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9')	s=s*10+ch-'0',ch=getchar();
	return f*s;
}
struct edge{int to,lt;}e[N<<1];
int f[N],in[N],cnt,n;
void add(int x,int y)
{
	e[++cnt].to=y; e[cnt].lt=in[x]; in[x]=cnt;
	e[++cnt].to=x; e[cnt].lt=in[y]; in[y]=cnt;
}
void dfs(int x,int fr)
{
	for(int i=in[x];i;i=e[i].lt)
	{
		int y=e[i].to; if(y==fr)	continue;
		dfs(y,x); f[x]^=(f[y]+1);
	}
}
int main()
{
	n=read();
	for(int i=1;i<n;i++)	add(read(),read());
	dfs(1,0); puts(f[1]?"Alice":"Bob");
	return 0;
}

Measured memory_bytes: 7168
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

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

    int ans = c - (a-b);

    if(ans < 0){
        cout << 0 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mxn= 5e4+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
//#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    rishabh();
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int ans=arr[0];
    for(int i=1;i<n;i++){
        if(arr[i]>arr[i-1]){
            ans+=arr[i]-arr[i-1];
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3632
#include <stdio.h>
int abs(int a){
	return a>0?a:-a;
}
int main(void){
	int w,a,b;
	scanf("%d %d %d",&w,&a,&b);
	if(abs(a-b)<=w){
		puts("0");
	}
	else{
		printf("%d\n",abs(a-b)-w);
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
string s;
int main() {
	cin >> s;
	unsigned len=s.size();
	bool(s[0]==s[len-1])?(bool(len%2)?cout << "Second\n":cout << "First\n"):(bool(len%2)?cout << "First\n":cout << "Second\n");
	return 0;
}

Measured memory_bytes: 512
package main

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

func main() {
	h, a := readInt(), readInt()
	if h%a == 0 {
		fmt.Println(h / a)
	} else {
		fmt.Println(h/a + 1)
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m;
	while(cin>>m>>n,n+m){
		vector<string>in(n);
		rep(i,n)cin>>in[i];
		int q[256]={0};
		int sx,sy;
		int co=1;
		rep(i,n)rep(j,m){
			char c=in[i][j];
			c=tolower(c);
			if(c=='@')sx=i,sy=j;
			if(islower(c)&&q[c]==0){
				q[c]=co;
				q[toupper(c)]=co;
				co++;
			}
		}
		
		queue<pair<pii,pii> >w;
		w.push(pair<pii,pii>(pii(sx,sy),pii(0,0)));
		int dx[]={0,0,1,-1};
		int dy[]={1,-1,0,0};
		co=0;
		map<int,map<int,map<int,bool> > >M;
		while(!w.empty()){
			co++;
			pair<pii,pii>e=w.front();
			w.pop();
			pii a=e.first,b=e.second;
			if(M[a.first][a.second][b.second])continue;
			M[a.first][a.second][b.second]=true;
			rep(i,4){
				int nx=a.first+dx[i];
				int ny=a.second+dy[i];
				int t=b.second;
				if(in[nx][ny]=='#')continue;
//				if(isalpha(in[nx][ny])&&q[tolower(in[nx][ny])]==0)continue;
				if(in[nx][ny]=='<'){
					cout<<b.first+1<<endl;
					goto end;
				}
				if(isupper(in[nx][ny])&&!(t&1<<(q[in[nx][ny]]-1)))continue;
				if(islower(in[nx][ny]))t^=1<<(q[in[nx][ny]]-1);
				w.push(pair<pii,pii>(pii(nx,ny),pii(b.first+1,t)));
			}		
		}
		cout<<-1<<endl;
		end:;
	}
}

Measured memory_bytes: 10748
#include<stdio.h>
#include<stdlib.h>

int main(void){
    int n;
    int *ap;
    scanf("%d",&n);

    ap = (int *)malloc((n+1) * sizeof(int));

    for(int i=1; i<n+1; i++){
        scanf("%d",&ap[i]);
    }
    ap[0] = ap[1];

    for(int i=1; i<n+1; i++){
        if(ap[i-1]<ap[i]){
            ap[i]--;
        }
    }

    int check=0;

    for(int i=1; i<n+1; i++){
        if(ap[i-1]>ap[i]){
            check++;
        }
    }

    if(check==0){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 512
N,K = map(int,input().split())
p = list(map(int,input().split()))

MX = 0
ttl = 0

for i in range(K):
    ttl += p[i]

mm = ttl

for i in range(K,N):
    mm = mm+p[i]-p[i-K]
    ttl = max(ttl,mm)

print((ttl+K)/2)





Measured memory_bytes: 25060
//q3.cpp

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 52


int h,w;
char flag[SIZE][SIZE];

int check(int a,int b){
    int res = 0;
    // [0,a) 'W'
    // [a,b) 'B'
    // [b,h-1) 'R'
    
    assert(0<=a && a<=b && b<=h-1);
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i<a && flag[i][j]!='W') res++;
            if(a<=i && i<b && flag[i][j]!='B') res++;
            if(b<=i && flag[i][j]!='R') res++;
        }
    }
    
    return res;
}

int main(){
    int ans = INF;
    
    scanf("%d%d",&h,&w);
    
    for(int i=0;i<h;i++){
        scanf("%s",flag[i]);
    }
    
    for(int i=1;i<h;i++){
        for(int j=i+1;j<h;j++){
            
            ans = min(ans,check(i,j));
            
        }
    }
    
    
    printf("%d\n",ans);
    
    
    return 0;
}

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

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

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

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

const int N = 100005;
struct E {
	int to, s;
};
vector<E> g[N];
ll adjust, as[N];
int dist[N];
bool vis[N];

bool dfs(int v, ll val, int d) {
	as[v] = val;
	dist[v] = d;
	vis[v] = 1;
	bool ok(true);
	for (auto e : g[v]) {
		if (!vis[e.to]) {
			ok &= dfs(e.to, e.s - val, d + 1);
		}
		else {
			if ((d + dist[e.to]) % 2 == 0) {
				if ((val + as[e.to] + e.s) % 2 == 0) {
					adjust = (val + as[e.to] - e.s) / 2;
					if (d & 1) adjust = -adjust;
				}
				return false;
			}
			if (val + as[e.to] != e.s) {
				return false;
			}
		}
	}
	return ok;
}

bool dfs2(int v, ll val) {
	if (val <= 0) return false;
	as[v] = val;
	vis[v] = 1;
	bool ok(true);
	for (auto e : g[v]) {
		if (!vis[e.to]) {
			ok &= dfs2(e.to, e.s - val);
		}
		else {
			if (val + as[e.to] != e.s) {
				return false;
			}
		}
	}
	return ok;
}

bool check(ll v, int n) {
	fill(vis, vis + n, false);
	return dfs(0, v, 0);
}

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n, m; cin >> n >> m;
	REPU(i, 0, m) {
		int u, v, s;
		cin >> u >> v >> s;
		--u, --v;
		g[u].push_back((E) {v, s});
		g[v].push_back((E) {u, s});
	}

	adjust = LLONG_MIN;
	ll v = 0;

	if (check(v, n)) {
		ll mini[2] = {LLONG_MAX, LLONG_MAX};
		REPU(i, 0, n) {
			amin(mini[dist[i] & 1], as[i]);
		}
		ll ans = 0;
		amax(ans, mini[1] + mini[0] - 1);
		cout << ans << endl;
	}
	else {
		if (adjust == LLONG_MIN) {
			puts("0");
		}
		else {
			fill(vis, vis + n, false);
			v -= adjust;
			if (dfs2(0, v)) puts("1");
			else puts("0");
		}
	}

	return 0;
}


Measured memory_bytes: 13312
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	string s;
	cin >> n >> s;
	
	int ans = 0;
	for(int i = 0; i < n - 1; ++i) {
		
		if( s[i] == s[i + 1] ) continue;
		else ans++;
	}
	
	cout << ans + 1 << endl;
	
	return 0;
}


Measured memory_bytes: 512
from itertools import*;from scipy.sparse import*
N,M,R=map(int,input().split());r=map(int,input().split())
G=[[9e9]*N for _ in[0]*N]
for _ in[0]*M:A,B,C=map(int,input().split());G[A-1][B-1]=G[B-1][A-1]=C
D=csgraph.dijkstra(csr_matrix(G))
print(int(min(sum(D[i-1,j-1]for i,j in zip(t,t[1:]))for t in permutations(r))))

Measured memory_bytes: 19628
//ABC 162 D
#include <bits/stdc++.h>
using namespace std;

int main(){
   int n;
   string s;
   cin >> n;
   cin >> s;
   int r[n+1], g[n+1], b[n+1];
   
   for (int i=0; i<=n; i++){
   	  r[i]=g[i]=b[i]=0;
   }
   
   for (int i=n-1; i>=0; i--){
   	   if (s[i]=='R')
   	      r[i]=r[i+1]+1;
   	   else
   	   	  r[i]=r[i+1];
   	   
   	   if (s[i]=='G')
   	      g[i]=g[i+1]+1;
   	   else
   	   	  g[i]=g[i+1];
   	   
   	   if (s[i]=='B')
   	      b[i]=b[i+1]+1;
   	   else
   	   	  b[i]=b[i+1];
   }
   
   long long ans=0;
   
   for(int i=0; i<=n-4; i++){
   	 for(int j=i+1; j<=n-2; j++){
   	 	if (s[i]!=s[j]){
   	 	   int k=j+(j-i);
           if (s[i]!='B' && s[j]!='B'){
           	  ans += b[j+1];
           	  if (k<=n-1 && s[k]=='B') ans--;
           }
           
           if (s[i]!='G' && s[j]!='G'){
           	  ans += g[j+1];
           	  if (k<=n-1 && s[k]=='G') ans--;
           }
           
           if (s[i]!='R' && s[j]!='R'){
           	  ans += r[j+1];
           	  if (k<=n-1 && s[k]=='R') ans--;
           }
   	 	}
   	 }
   }
   
   cout << ans << endl;
   return 0;
} 

Measured memory_bytes: 3684
#include<stdio.h>
int main()
{
    int a[3];
    int i;
    for (i = 0; i < 3; i++)
        scanf("%d", &a[i]);
    int x;
    for (i = 0; i < 2; i++)
        if (a[i] > a[i + 1])
        {
            x = a[i];
            a[i] = a[i + 1];
            a[i + 1] = x;
            i = -1;
        }
    int ans = 0;
    ans = a[2] - a[1];
    if ((a[1] - a[0]) % 2 == 0)
        ans += (a[1] - a[0]) / 2;
    else
        ans += ((a[1] - a[0]) / 2) + 2;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const int N = 100005 ;
using namespace std ;

int n, a[N] ;

int main() {
	scanf("%d", &n) ;
	rep(i, 1, n) {
		scanf("%d", &a[i]) ;
	}
	sort(a + 1, a + n + 1) ;
	if (a[1] == a[n]) {
		int l = 1, r = n / 2 ;
		if (a[1] == n - 1 || (a[1] >= l && a[1] <= r)) printf("Yes\n") ; 
			else printf("No\n") ; 
		return 0 ; 
	}
	if (a[n] - a[1] > 1) {
		printf("No\n") ;
		return 0 ;
	}
	rep(i, 1, n - 1) if (a[i] != a[i + 1]) {
		if (i + 1 == n) {
			printf("No\n") ;
			return 0 ; 
		}
		int l = i + 1, r = i + (n - i) / 2 ;
		if (a[n] >= l && a[n] <= r) {
			printf("Yes\n") ; 
		} else {
			printf("No\n") ;
		}
		break ;
	}
	return 0 ; 
} 

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define yorn(f) puts((f)?"Yes":"No")
ll h,w;
//ld ;
//string s;
 
int main() {
  cin >> h >> w;
  ll ans = ((h-1)*(w-1)==0)?1:(h*w+1)/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;


int main(){
	string a,b;
	std::cin >> a>>b;
	if(a.size()>b.size()){
		std::cout << "GREATER" << std::endl;
	}else if(a.size()<b.size()){
		std::cout << "LESS" << std::endl;
		
	}else {
	if(a>b){
		std::cout << "GREATER" << std::endl;
	}else if(a<b){
		std::cout << "LESS" << std::endl;
	}else std::cout << "EQUAL" << std::endl;}
}





Measured memory_bytes: 384
#include <stdio.h>

int main(void){
	int card[4][13]={0};
	char mark[4]={'S','H','C','D'};
	char c;
	int b;
	int n;
	int i,j;
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf(" %c %d",&c,&b);
		for(j=0;j<4;j++){
			if(c == mark[j]) card[j][b-1] = 1;
		}
	}
	for(i=0;i<4;i++){
	for(j=0;j<13;j++){		
		if(card[i][j] == 0) printf("%c %d\n",mark[i],j+1);
	}
	}
	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<string.h>
#include<string>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
#define ll long long
const int N = 1e3+99;
int n,m;
int ans = 1;
int main()
{
    //freopen("in.txt","r",stdin);
    cin>>n;
    int a,b;
    if(n==1)
    {
        cout<<"Hello World"<<endl;
    }
    else{
        cin>>a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        if(c<=0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a<=0){
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define DEKAI 1000000007
#define INF (1<<28)
#define int long long
/* ┗(^o^)┛ｗｗｗｗｗ┏(^o^)┓ﾄﾞｺﾄﾞｺﾄﾞｺﾄﾞｺｗｗｗｗｗ */

signed main(){
	int n,m,x,y;
	cin>>n>>m>>x>>y;
	int a[300],b[300];
	lp(i,300){
		a[i]=b[i]=0;
	}
	lp(i,n){
		int hoge;
		cin>>hoge;
		hoge+=100;
		a[hoge]++;
	}
	lp(i,m){
		int hoge;
		cin>>hoge;
		hoge+=100;
		b[hoge]++;
	}
	string ans="War";
	for(int i=x+1;i<=y;i++){
		int stat=0;
		for(int j=-100;j<i;j++){
			if(b[j+100]>0) stat=1;
		}
		for(int j=i;j<=100;j++){
			if(a[j+100]>0) stat=1;
		}
		if(stat==1) continue;
		ans="No War";
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
int n,m,x[100010],cha[100010],num,ans;
int read()
{
	int x=0,f=1;
	char k=getchar();
	while(k<'0'||k>'9')
	{
		if(k=='-') f=-1;
		k=getchar();
	}
	while(k>='0'&&k<='9')
	{
		x=x*10+k-'0';
		k=getchar();
	}
	return x*f;
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;i++) x[i]=read();
	if(n>=m)
	{
		printf("0\n");
	}
	else
	{
		num=0;ans=0;
		std::sort(x+1,x+m+1);
		for(int i=2;i<=m;i++) cha[++num]=x[i]-x[i-1];
		std::sort(cha+1,cha+num+1);
		for(int i=1;i<=num-(n-1);i++) ans+=cha[i];
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iterator>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

#define rep(i, n, m) for (int i = n; i <= m; i++)
#define Rep(i, n, m) for (int i = m; i >= 1; i--)

typedef long long ll;

int main() {
    int n;
    cin >> n;
    string str;
    cin >> str;
    int r = 0, b = 0;
    rep(i, 0, n - 1)
        if (str[i] == 'R')
            r++;
        else
            b++;
    cout << (r > b ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = pow(10,9);
const int nil = -1;
int i, n, m, k, ans;
string s;
ll a[2019];

int main() {
    cin >> s;
    n = s.size();
    init(a, 2019, 0)
    ll val = 0;
    ll moddigit = 1;
    a[0] = 1;
    rep(0, n) {
        val = (val + (s[n-i-1] - '0') * moddigit) % 2019;
        a[val]++;
        moddigit = moddigit * 10 % 2019;
    }
    ll ans = 0;
    rep(0, 2019) {
        ans += a[i] * (a[i]-1) / 2;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 3872
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
  public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

   double alph;

   while(true){

	   String st = br.readLine();
	   if( st.equals("0") ) break;
       double n = Double.parseDouble( st );
       String[] s = br.readLine().split(" ");

       double sum = 0;
       for(int i = 0; i < n ; i++){
    	   sum += Double.parseDouble( s[i] );//?????????????¨????????¨??????????
       }

       double ave = sum / n;

       double sigma = 0;

       for(int i = 0; i < n ; i++){
    	   sigma += Math.pow(Double.parseDouble( s[i] ) - ave , 2);//?£????¨??????????
       }

       alph =Math.sqrt (sigma / n );//?£???n??§?????£?????????????????????????????£??¨??????
       System.out.println(alph);

   }


  }
}

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

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

  int n = t.size();

  if (n == 1) {
    if (t[0] == '?') {
      cout << "D" << endl;
    } else {
      cout << t << endl;
    }
    return 0;
  }

  string ans = "";
  if (t[0] == '?' && t[1] != 'P') {
    ans += 'P';
  } else if (t[0] == '?') {
    ans += 'D';
  } else {
    ans += t[0];
  }

  for (int i = 1; i < n; i++) {
    char c = t[i];
    if (c == '?') {
      if (ans[i - 1] == 'P') {
        ans += 'D';
      } else {
        if (i + 1 < n && t[i + 1] != 'P') {
          ans += 'P';
        } else {
          ans += 'D';
        }
      }
    } else {
      ans += c;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3924
import sys
from math import floor, sqrt, ceil

q, *ab = map(int, sys.stdin.read().split())
ab = zip(*[iter(ab)] * 2)

def main():
    for a, b in ab:
        if a > b:
            a, b = b, a
        res = 0
        res += (a - 1) * 2
        
        if b - a <= 1:
            yield res 
            continue
        
        p = a * b
        c = floor(sqrt(p))
        res += (c - a) * 2 + 1
        if c * (c + 1) >= p:
            res -= 1
        if c * c == p:
            res -= 1
        yield res



if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Measured memory_bytes: 3188
#include <stdio.h>
 
int main()
{
  int i;
  char p[4];
  
  scanf("%s",&p);
 
  if(p[0]==p[1]||p[1]==p[2]||p[2]==p[3])
  {
    printf("Bad");
  }
  else
  {
    printf("Good");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define INF 10000000
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
    int N;
    cin>>N;
    int v[N];
    rep(i,N) cin>>v[i];
    sort(v,v+N);
    double ans=(double)(v[0]+v[1])/2;
    for(int i=2; i<N; i++){
        ans=(double)(v[i]+ans)/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

class Edge
{
public:
	int to;
	int size;
	Edge(int to)
	{
		this->to = to;
	}
};
vector<Edge> edges[100010];
	
void dfs(int v, int p, int *d)
{
	if (p == -1)
	{
		d[v] = 0;
	}
	else
	{
		d[v] = d[p]+1;
	}
	

	for (auto &e : edges[v])
	{
		if (e.to != p)
		{
			dfs(e.to, v, d);
		}
	}
}

int main()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;

	int dist1[N], dist2[N];
	memset(dist1, 0, sizeof(dist1));
	memset(dist2, 0, sizeof(dist2));
	
	rep(i, N-1)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		edges[a].push_back(Edge(b));
		edges[b].push_back(Edge(a));

	}
	dfs(0, -1, dist1);
	dfs(N-1, -1, dist2);
	int cnt = 0;
	rep(i, N)
	{
		if (dist1[i] <= dist2[i])
		{
			cnt++;
			//cout << "i=" << i << "; dist1=" <<  dist1[i] << "; dist2=" << dist2[i] << endl;
		}
	}
	if (cnt * 2 > N)
	{
		cout << "Fennec" << endl;
	}
	else
	{
		cout << "Snuke" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 11264
#include <iostream>

#define M 10000

int main(int argc, char const *argv[]) {
  int N,i;
  char S[M],T[M];

  scanf("%d\n", &N);
  scanf("%s %s", S,T);

  for ( i=0;i<N;i++ ) {
    printf("%c%c", S[i],T[i]);
  }printf("\n");


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  string S;
  cin>>S;
  if(S.size()==2 and S[0]==S[1]){
    cout<<"1 2"<<endl;
    return 0;
  }
  REP(i,S.size()-2){
    if(S[i]==S[i+1] or S[i]==S[i+2] or S[i+1]==S[i+2]){
      cout<<i+1<<" "<<i+3;
      return 0;
    }
  }
  cout<<"-1 -1"<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll n;
	cin>>n;n++;
	int *a=new int[400],now=0;
	a+=200;
	for(int i=40;~i;i--){
		if(now){
			*(a+now-1)=now;
			now++;
		}
		if(n>>i&1){
			if(!now){
				now=1;continue;
			}
			a--;
			*a=now++;
		}
	}
	cout<<2*now-2<<'\n';
	for(int i=0;i<now-1;i++)
		cout<<*(a+i)<<' ';
	for(int i=1;i<now;i++)
		cout<<i<<' ';
	cout<<'\n';
	return 0;
}


Measured memory_bytes: 256
j;i;k;t;main(n){
int c[501],f[500],s[500];
for(scanf("%d",&n);k<n-1;k++)scanf("%d%d%d",&c[k],&s[k],&f[k]);
            
for(;i<n-1;i++){
	t=0;
	for(j=i;j<n-1;j++)
		if(t>s[j]) t=s[j]+c[j]+ceil( (double)(t-s[j])/f[j] )*f[j];else t=s[j]+c[j];
	printf("%d\n",t);
}
printf("0");
}

Measured memory_bytes: 1684
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << " " << max(0ll,(a + b) - n) << endl;
}

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

const int offset = 80 * 160;
const int M = 80 * 160 * 2;
typedef bitset<M> bs;

int X[80][80];
int Y[80][80];
int A[80][80];
bs dp[80][80];
int H, W;

void solve() {
    cin >> H >> W;
    REP(i, H) REP(j, W) cin >> X[i][j];
    REP(i, H) REP(j, W) cin >> Y[i][j];
    REP(i, H) REP(j, W) A[i][j] = abs(X[i][j] - Y[i][j]);

    dp[0][0][offset + A[0][0]] = true;
    dp[0][0][offset - A[0][0]] = true;

    REP(i, H) REP(j, W) {
        if (i < H - 1) {
            dp[i + 1][j] |= dp[i][j] << A[i + 1][j];
            dp[i + 1][j] |= dp[i][j] >> A[i + 1][j];
        }
        if (j < W - 1) {
            dp[i][j + 1] |= dp[i][j] << A[i][j + 1];
            dp[i][j + 1] |= dp[i][j] >> A[i][j + 1];
        }
    }

    int ans = 1 << 29;
    REP(i, M) if (dp[H-1][W-1][i]) ans = min(ans, abs(i - offset));
    cout << ans << endl;
}

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



Measured memory_bytes: 20352
fn main() {
    proconio::input! {
        n: usize,
        a: [u64; n],
    }
    let mut r = 1000;

    for i in 0..n - 1{
        if a[i] < a[i + 1] {
            r += (r / a[i]) * (a[i + 1] - a[i]);
        }
    }
    println!("{}", r);
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    ll n, h;
    cin >> n >> h;
    vector<ll> a(n);
    vector<ll> b(n);
    REP(i,n) cin >> a[i] >> b[i];
    sort(a.begin(), a.end(), greater<ll>());
    sort(b.begin(), b.end(), greater<ll>());
    ll ans = 0;
    REP(i,n) {
        if(b[i] <= a[0]) continue;
        h -= b[i];
        ans++;
        if (h <= 0) {
            cout << ans << std::endl;
            return 0;
        }
    }
    int d = (h+a[0]-1)/a[0];
    ans += d;
    cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <queue>
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}
const int N = 1e6;

int n;
string s, t;
queue<int> q;
int ans;

int main()
{
	n = read();
	cin >> s;
	cin >> t;

	if (s == t) {
		printf("0\n");
		return 0;
	}
	int from = n - 1, to = n - 1;
	while (to >= 0) {
		while (to && t[to - 1] == t[to])
			to--;
		while (from >= 0 && (s[from] != t[to] || from > to))
			from--;
		if (from < 0) {
			printf("-1\n");
			return 0;
		}
		while (!q.empty() && to + q.size() <= q.front())
			q.pop();
		if (from != to)
			q.push(from);
		if (q.size() + 1 > ans)
			ans = (q.size() + 1);
		to--;
	}

	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 9352