akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

void func(int age, int cost) {
    if (age <= 5) {
        cout << 0 << endl;
    } else if (age > 12) {
        cout << cost << endl;
    } else {
        cout << (cost >> 1) << endl;
    }
}

int main() {
    int age, cost;
    cin >> age >> cost;
    func(age, cost);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1.0)
#define pb push_back
#define vi vector<int>
#define mapii map<int , int>
#define mapci map<char, int>
#define mapsi map<string,int>
#define FOR(i,n) for(int i = 0;i<n;i++)
#define CP(n) printf("Case %d: \n",n);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdin)
#define MAX 1000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll x , ans = LONG_MAX;
    cin>>n;
    int a[n];
    FOR(i,n)cin>>a[i];
    sort(a,a+n);
    for(int i = a[0];i<=a[n-1];i++)
    {
        x = 0;
        FOR(j,n)x+=((i-a[j])*(i-a[j]));
        ans = min(ans,x);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stdio.h>
#include <set>
#include <iomanip>
using namespace std;
 
 
int main(){
    long double A, B;
    cin >> A >> B;
    cout << long(A*B) << endl;
    return 0;
}

Measured memory_bytes: 3732
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
using namespace std;
using ll=long long;
#define MOD  1000000007

int main(int argc, char const *argv[]) {
  int n,k,x,y;
  std::cin >> n >> k >> x >> y;
  if(n<=k) std::cout << n*x << '\n';
  else std::cout << k*x+(n-k)*y << '\n';
  return 0;
}


Measured memory_bytes: 256
a,b,c = input().split()
A = int(a)
B = int(b)
C = int(c)
if A == B:
    if B == C:
        print("No")
    else:
        print("Yes")
elif A == C:
    if B == C:
        print("No")
    else:
        print("Yes")
elif B == C:
    if A == B:
        print("No")
    else:
        print("Yes")
else:
    print("No")

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

int main()
{
    ll N, M;
    cin >> N >> M;

    ll A[N];
    ll tot = 0;
    rep(i, N)
    {
        cin >> A[i];
        tot += A[i];
    }

    int ans = 0;
    rep(i, N)
    {
        if ((A[i] * 4 * M) >= tot)
        {
            ans++;
        }
    }

    if (ans >= M)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

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

int main()
{
  int N; cin >> N;
  vector<int> array(N);
  REP(i, N){ cin >> array[i]; }

  sort(array.begin(), array.end());
  int ans = array[(N/2)] - array[(N/2)-1];
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
      
      
int main(){
  ll x;
  cin >> x;
  ll q=100;
  ll ans=0;
  for(int i=0;i<5000;i++){
     if(q>=x){cout << ans << endl;
     return 0;}
     q*=1.01;
     ans++;
  }
}

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

using namespace std;

const int MAX_N = 1e5 + 10, MOD = 1e9 + 7;

int lowbit(int x) { return x & -x; }

struct Point {
    int x, y;
    Point() {}
    Point(int x, int y) : x(x), y(y) {}

    bool operator<(const Point &rhs) const {
        if (x != rhs.x) return x > rhs.x;
        return y < rhs.y;
    }

    bool operator==(const Point &rhs) const {
        return x == rhs.x && y == rhs.y;
    }
};

int N, M, PE[MAX_N], PR[MAX_N], nX, nY, relabel[MAX_N], bit[MAX_N];
vector<Point> robots;

void modify(int x, int y) {
    for (; x; x -= lowbit(x)) (bit[x] += y) %= MOD;
}

int query(int x) {
    int y = 0;
    for (; x <= nY; x += lowbit(x)) (y += bit[x]) %= MOD;
    return y;
}
 
int main() {
    scanf("%d%d", &N, &M);
    for (int i = 1; i <= N; i++) scanf("%d", &PR[i]);
    for (int i = 1; i <= M; i++) scanf("%d", &PE[i]);
    for (int i = 1; i <= N; i++) {
        int p = lower_bound(PE + 1, PE + M + 1, PR[i]) - PE;
        if (p == 1 || p == M + 1) continue;
        robots.emplace_back(PR[i] - PE[p - 1], PE[p] - PR[i]);
    }
    for (Point robot : robots) relabel[++nX] = robot.x;
    sort(relabel + 1, relabel + nX + 1); nX = unique(relabel + 1, relabel + nX + 1) - (relabel + 1);
    for (Point &robot : robots) robot.x = lower_bound(relabel + 1, relabel + nX + 1, robot.x) - relabel;
    for (Point robot : robots) relabel[++nY] = robot.y;
    sort(relabel + 1, relabel + nY + 1); nY = unique(relabel + 1, relabel + nY + 1) - (relabel + 1);
    for (Point &robot : robots) robot.y = lower_bound(relabel + 1, relabel + nY + 1, robot.y) - relabel;
    sort(robots.begin(), robots.end()); robots.erase(unique(robots.begin(), robots.end()), robots.end());
    nY++;
    modify(nY, 1);
    for (Point &robot : robots) {
        int res = query(robot.y + 1);
        modify(robot.y, res);
    }
    int ans = query(1);
    printf("%d\n", ans);
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int cnt[2010] = {};
    int ans = 0;
    rep(i, n)
    {
        rep(j, n)
        {
            if (j == i)
                continue;
            if (j < i)
            {
                if (a[i] > a[j])
                    (ans += (k - 1) * k / 2) %= mod;
            }
            else
            {
                if (a[i] > a[j])
                    (ans += k * (k + 1) / 2) %= mod;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
using namespace std;
using ll = long long;
const int mod = 1000000007;

int main() {
	int n,ans=0;
	string a, b, c;
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i++) {
		if (a[i] != b[i] && b[i] != c[i] && a[i] != c[i])ans += 2;
		else if (a[i] == b[i] && a[i] == c[i]);
		else ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define n_max int(1e5 + 5)
#define MOD int(1e9 + 7)


llong fac[n_max];  /// fac[n] = n!
llong finv[n_max]; /// (fac[n] * finv[n]) % MOD = 1
llong inv[n_max];  /// (n * inv[n]) % MOD = 1
 
void init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  FOR (i, 2, n_max) {
    fac[i] = fac[i-1]*i % MOD;
    inv[i] = MOD - inv[MOD%i]*(MOD/i) % MOD;
    finv[i] = finv[i-1]*inv[i] % MOD;
  }
}
 
llong nCk (int n, int k) {
  if (n < k || k < 0 || n < 0) return 0;
  return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int main(){
    init();
    int n;
    cin >> n;
    llong A[n_max+5];
    REP(i,n) scanf("%lld",&A[i]);
    llong P[n_max+5];
    llong ruiseki[n_max+5];
    ruiseki[0]=0;
    REP(i,n){
        ruiseki[i+1] = ruiseki[i] + inv[i+1];
        ruiseki[i+1] %= MOD;
    }

    REP(i,n){
        P[i] = 0;
        P[i] += ruiseki[i+1];
        P[i] += ruiseki[n-i];
        P[i] = (P[i] + MOD -1)% MOD; 
    }

    llong ans=0;

    REP(i,n){
        ans += (P[i] * fac[n] % MOD) * A[i];
        ans%=MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int H, W;

string s[105];
int dis[105][105];


int main(void) {

	cin >> H >> W;
	string tmp;
	for (int i = 1; i <= H; i++) {
		cin >> tmp;
		s[i] =  "?"+ tmp + "?";
	}

	for (int i = 0; i <= W + 1; i++) {
		s[0] += "?";
		s[H + 1] += "?";
	}

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			dis[i][j] = 999999;
		}
	}

	if (s[1][1] == '#') { dis[1][1] = 1; }
	else {
		dis[1][1] = 0;
	}

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (s[i + 1][j] != s[i][j]) { dis[i + 1][j] = min(dis[i + 1][j], dis[i][j] + 1); }
			else { dis[i + 1][j] = min(dis[i + 1][j], dis[i][j]); }
			if (s[i][j + 1] != s[i][j]) { dis[i][j + 1] = min(dis[i][j + 1], dis[i][j] + 1); }
			else { dis[i][j + 1] = min(dis[i][j + 1], dis[i][j]); }
		}
	}

	int ans = (dis[H][W] + 1) / 2;

	cout << ans << endl;

	return 0;
}

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

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

	bool humi = true;
	for (int i = 0; i < s.length(); i++) {
		if ((i % 2 == 1) && (s[i] == 'R')) {
			humi = false;
			break;
		}
		else if ((i % 2 == 0) && (s[i] == 'L'))
		{
			humi = false;
			break;
		}
	}

	cout << (humi ? "Yes" : "No") << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;

const ll M = 4e18;

ll n, m, l;
ll a[305][305];
ll q;
ll b[305][305];

int main()
{
    scanf("%lld%lld%lld", &n, &m, &l);
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 1; j <= n; j++)
        {
            a[i][j] = M;
        }
    }
    for(ll i = 0; i < m; i++)
    {
        ll u, v, w;
        scanf("%lld%lld%lld", &u, &v, &w);
        a[u][v] = w;
        a[v][u] = w;
    }
    for(ll k = 1; k <= n; k++)
    {
        for(ll i = 1; i <= n; i++)
        {
            if(a[i][k] == M) continue;
            for(ll j = 1; j <= n; j++)
            {
                if(a[k][j] < M) a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
            }
        }
    }
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 1; j <= n; j++)
        {
            if(a[i][j] <= l) b[i][j] = 1;
            else b[i][j] = M;
        }
    }
    for(ll k = 1; k <= n; k++)
    {
        for(ll i = 1; i <= n; i++)
        {
            if(b[i][k] == M) continue;
            for(ll j = 1; j <= n; j++)
            {
                if(b[k][j] < M) b[i][j] = min(b[i][j], b[i][k] + b[k][j]);
            }
        }
    }
    scanf("%lld", &q);
    while(q--)
    {
        ll u, v;
        scanf("%d%d", &u, &v);
        printf("%d\n", b[u][v] == M ? -1 : b[u][v] - 1);
    }
    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main()
{
  int t=0,h=0;
  int n;
  cin>>n;
  while(n--)
  {
    string a,b;
    cin>>a>>b;
    if(a>b)
    {
      t=t+3;
    }
    else if(a<b)
    {
      h=h+3;
    }
    else
    {
      t=t+1;
      h=h+1;
    }
  }
  cout<<t<<" "<<h<<endl;
}



Measured memory_bytes: 3232
import sys
from numba import njit


@njit('i8(i8)', cache=True)
def solve(X):
    money = 100
    res = 0
    while (money < X):
        money *= 1.01
        money = int(money)
        res += 1
    return res


def main():
    input = sys.stdin.buffer.readline
    X: int = int(input())
    print(solve(X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 106200
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7

def f():
    s = input()
    r = 0
    n = 0
    for c in s:
        if c == 'S':
            n -= 1
        else:
            n += 1
        if r < n:
            r = n

    return r*2

print(f())


Measured memory_bytes: 8224
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N;
  cin >> N;
  cout << 0 << "\n";
  string lsex, rsex;
  cin >> lsex;
  rsex = lsex;
  if (lsex == "Vacant") {
    return 0;
  }
  ll l = 0, r = N;
  while (true) {
    ll m = (l + r) / 2;
    cout << m << "\n" << flush;
    string msex;
    cin >> msex;
    if (msex == "Vacant") {
      break;
    }
    if ((m - l) % 2 == 0) {
      if (msex != lsex) {
        r = m;
        rsex = msex;
      }
      else {
        l = m;
        lsex = msex;
      }
    }
    else {
      if (msex == lsex) {
        r = m;
        rsex = msex;
      }
      else {
        l = m;
        lsex = msex;
      }
    }
  }
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
/* {{{ */
/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)

#define all(i) (i).begin(),(i).end()
#define rall(i) (i).begin(),(i).end(),greater<int>()
#define PB push_back
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
//#define int long long

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1}; 

inline int in(){int x;std::cin>>x;return x;}

struct FAST {FAST(){cin.tie(0);ios::sync_with_stdio(false);}} Fast;

template <class X> void print(X hoge){ cout << hoge << '\n'; }
/*-------------------------------*/
/* }}} */ 

signed main(void)
{
  char c;
  char list[5] = {'a', 'i', 'u', 'e', 'o'};

  cin >> c;

  rep(i, 5) {
    if (c == list[i]) {
      cout << "vowel" << endl;
      return 0;
    }
  }
  cout << "consonant" << endl;

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main(){
	int n;
	int i,j,k;
	int a[55][30];
	char c,ca[50];
	memset(a,0,sizeof(a));
	cin>>n;
	for(i=0;i<n;i++){
		cin>>ca;
		for(j=0;j<strlen(ca);j++){
			for(k=0,c='a';c<='z';c++,k++){
				if(ca[j]==c)a[i][k]++;
			}
		}
	}
	for(i=0,c='a';c<='z';c++,i++){
		k=100;
		for(j=0;j<n;j++){
			if(a[j][i]<k)k=a[j][i];
		}
		for(j=0;j<k;j++){cout<<c;}
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
long long n,l,r,ans,a[N],s[N],c[4*N];
inline long long read()
{
    long long sum=0,x=1;
    char ch=getchar();
    while (ch<'0'||ch>'9')
	{
        if (ch=='-')
          x=-1;
        ch=getchar();
    }
    while (ch>='0'&&ch<='9')
	{
        sum=sum*10+ch-'0';
        ch=getchar();
    }
    return sum*x;
}
inline void write(long long x)    
{
    if (x<0)
    {
    	putchar('-');
    	x=-x;
	}
	if (x>9)
      write(x/10);
    putchar(x%10+'0');
}
inline void add(long long x)
{
	for (;x<=2*N;x+=(x&(-x)))
	  ++c[x];
}
inline long long query(long long x)
{
	long long res=0;
	for (;x;x-=(x&(-x)))
	  res+=c[x];
	return res;
}
inline bool check(long long x)
{
	long long res=0;
	memset(c,0,sizeof(c));
	s[0]=0;
	for (register int i=1;i<=n;++i)
	  if (a[i]>=x)
        s[i]=s[i-1]+1;else
        s[i]=s[i-1]-1;
	for (register int i=0;i<=n;++i)
	{
		res+=query(s[i]+N);
		add(s[i]+N);
	}
	if (res>=1ll*n*(n+1)/4)
	  return true;
	return false;
}
int main()
{
	n=read();
	for (register int i=1;i<=n;++i)
	{
		a[i]=read();
		r=max(r,a[i]);
	}
	while (l<=r)
	{
		long long mid=(l+r)/2;
		if (check(mid))
		{
			l=mid+1;
		    ans=mid;
		}else
		  r=mid-1;
	}
	write(ans);
	return 0;
}

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

int main() {
	int N, K;
	double ans = 0;
	cin >> N >> K;
	for (int i = 1; i <= N; i++) {
		double X = i;
		int Y = log2((K - 1) / X) + 1;
		double Z = 1 / (double)N;
		for (int i = 0; i < Y; i++) {
			Z *= 0.5;
		}
		ans += Z;
	}
	printf("%.12f", ans);
}

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

int top, S[1000];

void push(int x) {
    top++;
    S[top] = x;
}

int pop() {
    top--;
    return S[top + 1];
}

int main() {
    int a, b;
    top = 0;
    char T[100];

    while(scanf("%s", &T) != EOF) {
        if(T[0] == '+') {
            a = pop();
            b = pop();
            push(a + b);
        } else if(T[0] == '-') {
            b = pop();
            a = pop();
            push(a - b);
        } else if(T[0] == '*') {
            a = pop();
            b = pop();
            push(a * b);
        } else {
            push(atoi(T));
        }
    }

    printf("%d\n", pop());

    return 0;     
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int m1,d1,m2,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1+1==m2)print(1);
    else print(0);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 256
<?php

while ($stdin = fgets(STDIN)) {
    $line[] = trim($stdin);
}
foreach ($line as $key => $value) {
    $data[] = explode(' ', $value);
}

foreach ($data as &$line) {
    $line = array_map(function($val) { return (int)$val; }, $line);
}


$A = $data[0][0];
$B = $data[0][1];
$C = $data[0][2];
$D = $data[0][3];

function f($n, $C, $D) {
    $deathByC = intdiv($n, $C);
    $deathByD = intdiv($n, $D);
    $lcm = lcm($C, $D);
    $deathByCD = intdiv($n, $lcm);
    return $n - $deathByC - $deathByD + $deathByCD;
}

//最大公約数
function gcd($a, $b) {
    if ($b === 0) {
        return $a;
    }
    return gcd($b, $a % $b);
}
 
//最小公倍数
function lcm($m, $n){
    return $m * $n / gcd($m, $n);
}

$left = f($A - 1, $C, $D);
$right = f($B, $C, $D);

$ans = $right - $left;

printf('%d', $ans);


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

struct struct_Query{
  int T;
  int F;
  char C;
};

int main(){
  string S;
  int Q;
  cin >> S >> Q;
  struct_Query Query[Q];
  int rev=1;
  for(int i=0;i<Q;i++){
    int T;
    cin >> T;
    if(T==1){
      Query[i].T=1;
      rev = rev*(-1);
    }else{
      int F;
      char C;
      cin >> F >> C;
      Query[i].T=2;
      Query[i].F=F;
      Query[i].C=C;
      if (F+rev==2||F+rev==1){
        S.insert(0, string()+C);
      }else {
        S.push_back(C);
      }
    }
  }
  if (rev==-1) reverse(S.begin(),S.end());
  cout << S;
}


Measured memory_bytes: 3332
#include <iostream>
#include <algorithm>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

int N;
int ml, mr;
pair<int, int> A[200005];
int v[200005];

int main(void) {
    scanf("%d", &N);
    
    REP (i, 0, N) {
      int a;
      scanf("%d", &a);
      A[i] = make_pair(a, i);       
    }
    
    sort(A, A+N);
    
    ml = A[N/2 - 1].first;
    mr = A[N/2].first;
   
    
    REP(i, 0, N) v[A[i].second] = i < N/2 ? mr : ml;
    
    REP(i, 0, N) printf("%d\n", v[i]);
    
	return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#define ll long long
#define mp(a,b) make_pair(a,b)
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
using namespace std;

int main(){
  ll a,b;
  cin >> a >> b ;
  ll ans = -1;
  ll blah = 0;
  for(ll i=1;i<=998;i++){
    blah+=i;
    if(blah>=a){
      ll diff = blah-a;
      ll t = b+diff;
      if(t==blah+(i+1)){
        ans=diff;
        break;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
xy=[]
for i in range(n):
    ai=int(input())
    xyi=[]
    for j in range(ai):
        xyj=list(map(int,input().split()))
        xyi.append(xyj)
    xy.append(xyi)
#print(xy)

ans=0
for i in range(2**n):
    bit_i=format(i,'b').zfill(n)
    person=list(bit_i)
    clear=True
    for j in range(n):
        if(person[j]=='0'):
            continue

        xyj=xy[j]
        for k in range(len(xyj)):
            if(person[xyj[k][0]-1] != str(xyj[k][1])):
                clear=False
                break

        if(not clear):
            break

    if(clear and (ans < person.count('1'))):
#        print(person)
        ans=person.count('1')

print(ans)

Measured memory_bytes: 3188
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define MAX (1 << 29)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  string S;
  cin >> S;
  if (S == "Sunny") {
    print("Cloudy");
  } else if (S == "Cloudy") {
    print("Rainy");
  } else {
    print("Sunny");
  }
  return 0;
}

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

int main(){
	int N = 0;
	cin >> N;
	
	double sum = 0;
	for(int i=1;i<=N;i++){
		if(i%2==1){
			sum++;
		}
	}
	double ans = 0;
	ans = sum / N;
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scn = new Scanner(System.in);

        while(true){
            int count = scn.nextInt();

            if(count == 0) break;

            int [] array;
            array = new int[count];

            int sum = 0;
            Double ave = 0.0;
            Double ans = 0.0;
            Double answer = 0.0;


            for(int i = 0; i < count; i++){
                array[i] = scn.nextInt();
                sum += array[i];
            }

            ave = Double.valueOf(sum) / Double.valueOf(count);

            for(int i = 0; i < count; i++){
                ans += (array[i] - ave) * (array[i] - ave);
            }
            ans /= count;
            answer = Math.sqrt(ans);

            System.out.println(String.format("%.8f", answer));

        }
    }
}



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

#define REP(i,n) for(ll i=0;i<(n);i++)
#define REAP(i,a,n) for(ll i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vector<pair<ll,ll> > table(n);
    ll a,b;
    REP(i,n){
        cin >> a >> b;
        table[i].fr=a;
        table[i].sc=b;
    }
    sort(All(table));
    ll cou=0,res=-1;
    bool flg=false;
    REP(i,n){
//        cout << table[i].fr <<" "<< table[i].sc << endl;
        cou+=table[i].sc;
        if(cou>=k&&!flg){
            res=table[i].fr;
            flg=1;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 1792
n = int(input())
s = input()

ans = []
x = 0

for i in range(n):
  if s[i] == "I":
    x +=1
    ans.append(x)
    
  elif s[i] == "D":
    x -=1
    ans.append(x)
    
ans.sort(reverse=True)

print(max(ans[0],0))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;

bool is_integer(long double x ){
  double r;
  return 0==std::modf(x, &r);
}


signed main() {
    ll a, b, t;
    cin >> a >> b >> t;
    
    mes(t/a * b);
    
}


Measured memory_bytes: 3648
def solve( p, t ):
	global isExist, n, A
	isExist[ t ] = True
	if p < n:
		solve( p+1, t-A[p] )
		solve( p+1, t )
	else:
		return

isExist = [False]*2001 
n = int( raw_input() )
A = map( int, raw_input().rstrip().split( " " ) )
q = int( raw_input() )
M = map( int, raw_input().rstrip().split( " " ) )
s = sum( A )
solve( 0, s )
for i in range( 0, q ):
	if isExist[ M[i] ]:
		print( "yes" )
	else:
		print( "no" )

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

using namespace std;

long long solve(long long x){
    return (x/500)*1000 + ((x-(x/500)*500)/5)*5;
}

int main(){
    long long x;
    cin >> x;
    long long ans = solve(x);
    cout << ans;
    return 0;
}

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

 int main() {
   int n;
   cin >> n;
   int res = 0;
   int count;
   if (n >= 105) {
     for (int i = 105; i <= n; i++) {
       count = 1;
       if (i % 2 != 0) {
         for (int j = 1; j < i/2; j++) {
           if (i % j ==0) count++;
         }
       }
       if (count == 8) res++;
     }
   }
   cout << res << "\n";
 }


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include <algorithm>
using namespace std;
int main()
{
	int A,B;
	cin >> A >> B;

	int sum=0;
	if(A>B){
		sum+=A;
		A--;
	}else{
		sum+=B;
		B--;
	}

	if(A>B){
		sum+=A;
		A--;
	}else{
		sum+=B;
		B--;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
    int a[1000];
    int ans=0;
	cin >> n;
	for(int i = 1; i <= 2*n; i++)
	 cin >> a[i];
	sort(a+1 , a+1+n*2);
	for(int i = 1; i <= 2*n; i += 2)
	 ans += a[i];
	cout<< ans;
}

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

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "Yes" : "No")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

const int siz = 2e5 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "2";



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

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    int x;
    cin >> x;

    int ans = 0;
    for (int rat = 400; rat <= x; rat += 200) {
        ans++;
    }

    cout << 8 - ans + 1;

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


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

using namespace std;


int main()
{
	string inp;

	cin >> inp;
	for (int i = 0; i < inp.length() - 3; i++) {
		if (inp.at(i) == '2') {
			if (inp.at(i + 1) == '0') {
				if (inp.at(i + 2) == '1') {
					if (inp.at(i + 3) == '7') {
						inp[i + 3] = '8';
					}
				}
			}
		}
	}

	cout << inp << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

vector<vector<int>> G;
int n; 

vector<int> bfs(int s){
    vector<int> dist(n, -1);
    queue<int> q;
    q.push(s);
    dist[s] = 0;
    while(!q.empty()){
        int v = q.front(); q.pop();
        for(auto nv : G[v]){
            if(dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            q.push(nv);
        }
    }
    return dist;
}

int main(){
    cin >> n;
    G.resize(n);
    rep(i,n-1){
        int a, b; cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> dist1 = bfs(0);
    vector<int> dist2 = bfs(n-1);
    int fen = 0;
    int snu = 0;
    rep(i,n){
        if(dist1[i] <= dist2[i]) fen++;
        else snu++;
    } 
    if(fen > snu) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>

using namespace std;

//Modsum
int main(){
	 
	long long int n=0,ans=0;

	cin>>n;

	for(long long int i=1;i<n;i++){
		ans=ans+i;
	}

	cout<<ans;

	return 0;
}

Measured memory_bytes: 256
/**
 * C - Lining Up
 * https://atcoder.jp/contests/abc050/tasks/arc066_a
 **/
#include<iostream>
#include<map>

using namespace std;

#define ll long long

const ll MOD = 1000000007;

int main() {
    int n; cin >> n;
    map<int, int> m;
    for(int i=0; i<n; i++) {
        int ai; cin >> ai;
        if(m.count(ai)==0) {
            m[ai] = 1;
        } else {
            m[ai] += 1;
        }
    }

    bool flag = true;
    for(auto e:m) {
        if(e.first==0) {
            if(n%2==0&e.second>0) {
                flag = false;
                break;
            }
            if(n%2==1&e.second>1) {
                flag = false;
                break;
            }
        } else {
            if(e.second!=2) {
                flag = false;
                break;
            }
        }
    }

    ll ans;
    if(flag) {
        ans = 1;
        for(int i=0; i<n/2; i++) {
            ans *= 2;
            ans %= MOD;
        }
    } else {
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  rep(i,N){
    ll x;
    cin >> x;
    int cnt = 0;
    while(1){
      if (x % 2 == 0){
        cnt++;
        x = x / 2;
      }
      else break;
    }
    ans += cnt;
  }

  cout << ans << endl;
}


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

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

long long int n,m,x,k,d,i,index,flag,count=0,result,odd,even,sum=0,temp;
cin>>n>>m>>x;
//long long int a[200005];
/*for(i=0;i<n;i++)
{
    cin>>a[i];
}
*/
for(i=n;i<=m;i++)
{
    if(i%x==0)
    {
        count++;
    }
}
cout<<count<<endl;

    return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
	
		int c = 0;
		
		if((a + b) % 2 == 0) {
			c = (a + b) / 2;
		} else {
			c = (a + b) / 2 + 1;
		}
		System.out.println(c);
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

int m;
vs32 s, c;
bool ok(string& x)
{
    bool ret = true;
    rep (i, m)
    {
        if (x[s[i] - 1] != c[i] + '0') ret = false;
    }
    return ret;
}

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

    int n;
    cin >> n >> m;
    s.resize(m);
    c.resize(m);
    rep (i, m)
    {
        cin >> s[i] >> c[i];
    }

    string ans = "-1";
    int lim = 1;
    rep (i, n) lim *= 10;
    for (int i = 0; i < lim; ++i)
    {
        string temp = to_string(i);
        if (temp.size() != n) continue;
        if (ok(temp))
        {
            ans = temp;
            break;
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline

    N, x = map(int, input().split())
    A = list(map(int, input().split()))
    S = sum(A)

    for i in range(N-1):
        if A[i+1] + A[i] > x:
            A[i+1] -= min(A[i+1] + A[i] - x, A[i+1])
        if A[i] > x:
            A[i] = x
    print(S - sum(A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 59632
h,w,m = map(int,input().split())
H = [0]*(h+1)
W = [0]*(w+1)
d = {}
for i in range(m):
    x,y = map(int,input().split())
    d[(x,y)] = 1
    H[x] += 1
    W[y] += 1

mh = max(H)
mw = max(W)
la = []
lb = []
for i in range(h+1):
    if H[i] == mh:
        la.append(i)
    
for i in range(w+1):
    if W[i] == mw:
        lb.append(i)

ans = mh+mw-1

for i in la:
    for j in lb:
        if (i,j) not in d:
            print(ans+1)
            exit()
print(ans)


Measured memory_bytes: 168164
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	int N,D,X;
	cin>>N>>D>>X;
	
	for(int i=0;i<N;i++){
		int A;
		cin>>A;
		for(int j=1;j<=D;j+=A){
			X ++;
		}
	}
	
	cout<<X<<endl;
		
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
// cmath ではない
#include <math.h>
#include <iomanip> // for setprecision

using namespace std;

int main()
{
    int n;

    // sigma
    double sum2, sum;
    double a;

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

        // Clear
        sum2 = 0;
        sum = 0;

        for (int i=0; i<n; i++)
        {
            cin >> a;
            sum2 += pow(a, 2);
            sum += a;
        }

        // E[X^2] - (E[X])^2 を用いて出す
        double var = sum2/n - pow(sum/n, 2);
        // +fixed で小数点下の桁数を指定
        cout << fixed << setprecision(4) << sqrt( var ) << endl;
    }
    return 0;
}


Measured memory_bytes: 3288
#include <stdio.h>


int suf(int n,int r)
{

  int tow[n],i,j,k,p,c,x;

  for(i=0;i<n;i++){
    tow[i]=n-i;
  }
  for(i=0;i<r;i++){
    scanf("%d %d", &p,&c);
    for(j=1;j<=c;j++){
      x=tow[p+c-2];
      for(k=1;k<p+c-1;k++)
	tow[p-k+c-1]=tow[p-k+c-2];
      tow[0]=x;
    }
  }

  return(tow[0]);
}

int main(void)
{

  int n,r,out;

  while(1){
    scanf("%d %d", &n,&r);
    if(n==0&&r==0)break;
    out=suf(n,r);
    printf("%d\n", out);
  }
  return 0;
}

Measured memory_bytes: 600
/******************************************
/@Author: LeafBelief
/@Date: 2020-04-04
/@Remark:    
/@FileName: coffeestring
******************************************/
#include <bits/stdc++.h>
#define CSE(x,y) memset(x,y,sizeof(x))
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll , ll> pll;

const int maxn = 111;
char str[maxn];

int main()
{
    FAST;
    while(cin >> str)
    {
        if(str[2] == str[3] && str[4] == str[5])
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
        
    }
    return 0;
}

Measured memory_bytes: 768
//written by utkarsh on 18/08/19
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
  	cin>>n;
  	int a[n],b[n],c[n];
  	for(int i=0;i<n;i++)
    cin>>a[i]>>b[i]>>c[i];
	int next[3]={0},dp[3]={0};
  	for(int i=0;i<n;i++)
    {
    	next[0]=max(dp[1],dp[2])+a[i];//we take the element of type 1 and then the maximum from the other two kinds
    	next[1]=max(dp[0],dp[2])+b[i];
      	next[2]=max(dp[1],dp[0])+c[i];
    	dp[0]=next[0];
      	dp[1]=next[1];
      	dp[2]=next[2];
    }	
  	cout<<max(dp[0],max(dp[1],dp[2]));
  
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  set<int> s;
  rep(i,n) s.insert(a[i]);


  if(s.size()==n){
    puts("YES");
  }else{
    puts("NO");
  }
}

Measured memory_bytes: 10368
#include <iostream>
#include <cstring>
#include <cmath>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define M /* your task*/
#define L 14

int solve( int n, int i, int m, int* A){
  if( m == 0 ) return 1;
  if( i >= n ) return 0;
  int res = solve(n, i+1, m, A ) || solve(n,  i+1, m-A[i], A);
  return res;

}

int main(){

 int n, A[2010], q, m;  

  cin >> n;

  REP(i, n){
    cin >> A[i];
  }
  cin >> q;

  REP(i, q){
    cin >> m;
    if( solve( n, 0, m, A ) == 1 ) cout << "yes" << endl;
    else cout << "no" << endl;
  }

  return 0;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 3096
#include <stdio.h>
int main()
{
	double s=0;
	int i,x;
	scanf("%d",&x);
	double n[x];
	while(x--)
	{
		scanf("%lf",&n[i]);
		s=s+(1.0/n[i]);
	}
	printf("%lf",1/s);
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int get_n(int n) {
    int ret = 1; while(ret < n) ret <<= 1;

    return ret;
}

ll alp_to_bit(char c) {
    return 1LL << (c - 'a');
}

template <typename T>
struct SegTree {
    int N;
    vector<T> dat;
    typedef vector<T> D;

    explicit SegTree(int n): N(get_n(n)){
        dat.resize(2*N-1);
    }
    explicit SegTree(const string& s) {
        N = get_n(s.size());
        dat.resize(2*N-1);

        REP(i, s.size()) dat[N + i - 1] = alp_to_bit(s[i]);
        for (int i=N-2; i > -1; --i) dat[i] = fm(dat[2*i+1], dat[2*i+2]);
    }

    T fm(const T& a, const T& b){
        return a | b;
    }

    void update(int i, char c) {
        i += N - 1;
        dat[i] = alp_to_bit(c);

        while(i > 0) {
            i = (i - 1) / 2;
            dat[i] = fm(dat[2*i+1], dat[2*i+2]);
        }

    }

    // query for [a, b), k: current node id, [l, r): current range.
    ll query(int a, int b, int k=0, int l=0, int r=-1) {
        if (r < 0) r = N;

        if (b <= l || r <= a) return 0;
        if (a <= l && r <= b) return dat[k];

        int mid = (l + r) / 2;
        ll c1 = query(a, b, 2 * k + 1, l, mid);
        ll c2 = query(a, b, 2 * k + 2, mid, r);

        return fm(c1, c2);
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    string S;
    cin >> S;

    SegTree<ll> st(S);

    int Q; cin >> Q;

    REP(i, Q) {
        int t;
        cin >> t;

        if (t == 1) {
            int n; char c;
            cin >> n >> c;
            --n;
            st.update(n, c);
        } else {
            int l, r;
            cin >> l >> r;
            --l; --r;
            ll res = st.query(l, r + 1);
            cout << bcnt(res) << endl;
        }

    }
}


Measured memory_bytes: 9116
#include <iostream>
#include <string>
#include <vector>
#include <memory.h>
#include <algorithm>
using namespace std;
typedef long long LL;
const int MAXN = 2e5 + 10;
string s;
int cnt[26], pre[MAXN], tree[MAXN<<1], n;;
vector<int> nums;
inline int lowbit(int i) {
    return i&(-i);
}
void add (int i) {
    while (i <= n) {
        tree[i]++;
        i += lowbit(i);
    }
}
int sum (int i) {
    int ret = 0;
    while (i > 0) {
        ret += tree[i];
        i -= lowbit(i);
    }
    return ret;
}

void check() {
    for (char c : s) cnt[c-'a']++;
    int flag = 0, even = -1;
    for (int i = 0; i < 26; i++) {
        if (cnt[i] % 2 != 0) {
            flag++;
            even = i;
        }
    }
    if (flag > 1) {
        cout << -1 << endl;
        exit(0);
    }
}
void solve() {
    memset(pre, -1, sizeof(pre));
    memset(cnt, -1, sizeof(cnt));
    for (int i = 0; i < s.size(); i++) {
        pre[i] = cnt[s[i]-'a'];
        cnt[s[i]-'a'] = i;
    }
    nums.resize(n, 0);
    for (int i = 0; i < n; i++) {
        if (i < cnt[s[i]-'a']) {
            nums[i] = n - cnt[s[i]-'a'];
            nums[cnt[s[i]-'a']] = (n + 1 + cnt[s[i]-'a']);
            cnt[s[i]-'a'] = pre[cnt[s[i]-'a']];
        }
        else if (i == cnt[s[i]-'a']) {
            nums[i] = n+1;
        }
    }
}
int main() {
//    freopen("test.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> s;
    n = s.size();
    check();
    solve();
    LL ret = 0;
    n = 2*n + 1;
    for (int i = 0; i < nums.size(); i++) {
        int num = nums[i];
        add (num);
        int val = (sum(n) - sum(num));
        ret += val;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3092
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 600010
using namespace std;

main(){
    int n;
    cin>>n;
    string s[200];
    rep(i,n){
        cin>>s[i];
    }
    rep(i,n)rep(j,n){
        if(i!=j&&s[i]==s[j]){cout<<"No";return 0;}
    }
    rep2(i,1,n-1){
        if(s[i-1][s[i-1].size()-1]!=s[i][0]){cout<<"No";return 0;}
    }
    cout<<"Yes";return 0;
}

Measured memory_bytes: 256