akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int n, m, a, b;
LL ans;

const int mod = 1000000007;

inline LL qpow(LL a, LL b)
{
	LL res = 1;
	while (b)
	{
		if (b & 1) res = (res * a) % mod;
		a = a * a % mod, b >>= 1;
	}
	return res % mod;
}

LL work(int x)
{
    LL s,c;
    s=c=1;
    for(int i=1;i<=x;i+=1)s=(s*i)%mod;
    for(int i=n-x+1;i<=n;i++)c=(c*i)%mod;
    return (c*qpow(s,mod-2))%mod;
}

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	cin >> n >> a >> b;
	ans = (((qpow(2, n) - 1) % mod - work(a) % mod - work(b) % mod) % mod + mod) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

line_num = int(sys.stdin.readline().rstrip())
maxv = -2000000000000000
minv = int(sys.stdin.readline().rstrip())

for i in range(1, line_num):
    rt = int(sys.stdin.readline())
    if rt - minv > maxv:
        maxv = rt -minv
    if rt < minv:
        minv = rt

print(maxv)


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

int main(){
    map<string,int> m;
    int n;
    scanf("%lld",&n);
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        m[s]++;
    }
    int maxv=0;
    for(const auto& x:m){
        int v=x.second;
        if(v>maxv)maxv=v;
    }
    for(auto it=m.begin();it!=m.end();it++){
        
        if(it->second==maxv){
            cout<<it->first<<endl;
        }
    }
}

Measured memory_bytes: 25216
#include<iostream>
#include<cstdio>
typedef long long ll;
using namespace std;
const int MAXN=2e5+10;
ll n,a[200003],fsum[200003],bsum[200003],ans=-2e18,sum,su;
int main(){
	scanf("%lld",&n);
	for(int i=1; i<=n; i++) scanf("%lld",&a[i]);
	fsum[1]=a[1],fsum[2]=a[2],bsum[n]=a[n],bsum[n-1]=a[n-1];
	for(int i=3; i<=n; i++) fsum[i]=fsum[i-2]+a[i];
	for(int i=n-2; i>=1; i--) bsum[i]=bsum[i+2]+a[i];
	sum=fsum[n];
	if(n%2==0){
		ans=max(fsum[n-1],fsum[n]);
		for(int i=1; i<=n; i+=2){
            ans=max(ans,fsum[i]+bsum[i+3]);
		}
		printf("%lld\n",ans);
		return 0;
	}
	for(int i=1; i<=n; i++){
        if(i%2==0) su+=a[i];
		else su=max(su-a[i],-a[i]),ans=max(ans,sum+su);
	}
	printf("%lld\n",ans);
	return 0;
}


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

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

    int pa = 0, pb = 0;
    for(int i=0;i<n;i++){
        if(a[i] > b[i]) pa += a[i]+b[i];
        else if(a[i] < b[i]) pb += a[i]+b[i];
        else{
            pa += a[i];
            pb += b[i];
        }
    }
    cout << pa << " " << pb << endl;
}

int main(){
    while(1){
        cin >> n;
        if(n==0) break;
        solve();
    }
}



Measured memory_bytes: 3144
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
using ll = long long int;

const int MAXP = 1010;
ll N, K, MOD, dp[310][310], comb[MAXP+5][MAXP+5];

ll mod_pow(ll n, ll k) { return k ? mod_pow(n*n%MOD, k/2) * ((k&1)?n:1) % MOD : 1; }
void init() {
    for(int i=0; i<=MAXP; i++) {
        comb[i][0] = 1;
        for(int j=1; j<=i; j++) {
            comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % MOD;
        }
    }
}

ll nCr(ll n, ll r) {
    return (n < r or r < 0) ? 0 : comb[n][r];
}

ll solve(ll n, ll x) {
    if(x > K) return 0;
    if(dp[n][x] != -1) return dp[n][x];
    if(n == 1) return dp[n][x] = K-x+1;
    
    ll ans = 0;
    for(int k=1; k<n; k++) {
        ll v1 = solve(k, x+1);
        ll v2 = solve(n-k, x);
        ll v3 = solve(n-k, x+1);

        ll m1 = v1, m2 = (v2 - v3 + MOD) % MOD, m3 = nCr(n-2, k-1);
        (ans += m1 * m2 % MOD * m3 % MOD) %= MOD;
    }
    return dp[n][x] = (ans + solve(n, x+1)) % MOD;
}

int main() {
    cin >> N >> K >> MOD;
    init();
    fill(dp[0], dp[N+2], -1);
    cout << (solve(N+1, 0) - solve(N+1, 1) + MOD) % MOD << endl;
    return 0;
}


Measured memory_bytes: 8320
import sys
s=input()
c=s.find('C')
if c==-1:
     print('No')
     sys.exit()
s=s[::-1]
f=s.find('F')
if f==-1:
     print('No')
     sys.exit()
f=len(s)-f-1
if f>c:
     print('Yes')
else:
     print('No')

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

int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  int scores[] = {0, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
  string winner[] = {"Alice", "Draw", "Bob"};
  int a, b;
  cin >> a >> b;
  int as = scores[a], bs = scores[b];
  if (as < bs) {
    cout << winner[2] << "\n";
  } else if (bs < as) {
    cout << winner[0] << "\n";
  } else {
    cout << winner[1] << "\n";
  }
}


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

typedef long long int ll;

using namespace std;

int n = 3;
string s, t;

int main(void) {

	cin >> s >> t;
	int ret = 0;
	for (int i = 0; i < n; i++) {
		ret += s[i] == t[i] ? 1 : 0;
	}

	cout << ret;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int m[]={5,1,2,4,1,3,1,0,0,2,3,2,2,4,5,1,4,0,4,3,3,5,0,5};
char s[99];
int main(){
	s[87]=1;s[78]=4;s[69]=3;s[83]=2;
	for(int a,b,c,n,r,d;a=c=0,b=r=scanf("%d",&n),n;printf("%d\n",r)){
		for(;n--;r+=a%3?b%3?(b+6-a)%6<3?2:5:b?3:4:a?6:1){
			scanf("%s",s);
			d=s[*s];
			d?a=m[4*a+(d+c)%4],b=m[4*b+(d+c)%4]:c+=*s==76?3:1;
		}
	}
}

Measured memory_bytes: 0
import sys,collections as cl,bisect as bs,random
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

d = onem()

c = l()

s = []
sel = [0 for i in range(365)]

day = [[0 for i in range(26)] for j in range(365)]
ans = 0
for i in range(d):
	s.append(l())
	ss = [[s[-1][i],i+1] for i in range(26)]

	ak = 0

	for j in range(26):
		if i != 0:
			ak -= c[j] * (i-day[i-1][j]+1)
		else:
			ak -= c[j]

	ma = [-1,-1]
	for j in range(26):
		if i != 0:
			if ma[0] <= c[j] * (i-day[i-1][j]+1) + s[-1][j]:
				ma[0] = c[j] + (i-day[i-1][j]+1) + s[-1][j]
				ma[1] = j
		else:
			if ma[0] <= c[j] + s[-1][j]:
				ma[0] = c[j] + s[-1][j]
				ma[1] = j
	ans += ma[0] + ak
	sel[i] = ma[1]+1

	for j in range(26):
		if j == ma[1]:
			day[i][j] = i
		else:
			day[i][j] = day[i-1][j] if i - 1 >= 0 else 0



for _ in range(140000):
	ima = random.randrange(365)
	po = [[s[ima][i]-c[i],i+1] for i in range(26)]
	po.sort(reverse = True)
	while True:
		data = po[random.randrange(10)][1]
		if sel[ima] != data:
			break
	data = data-1
	ppp = 0
	now = sel[ima]-1
	for i in range(ima+1,365):
		if day[i][data] == i:
			ppp += (i - ima) * c[data]
			break
	else:
		ppp += (364-ima) * c[data]
	ppp += s[ima][data]

	for i in range(ima+1,365):
		if day[i][now] == i:
			ppp -= (i - ima) * c[now]
			break
	else:
		ppp -= (364-ima) * c[now]
	ppp -= s[ima][now]
	if ppp > 0:
		for i in range(ima,365):
			if day[i][data] != i:
				day[i][data] = ima
			else:
				break
		po = day[ima-1][now] if ima != 0 else 0
		for i in range(ima,365):
			if i == ima:
				day[i][now] = po
			elif day[i][now] != i:
				day[i][now] = po
			else:
				break
		sel[ima] = data+1
		ans += ppp

for i in sel:
	print(i)


Measured memory_bytes: 83872
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,p,cnt=1;
ll ans,tmp;
int main(){
	cin>>n>>p;
	if(n>=50){
		cout<<1<<endl;
		return 0;	
	}
	if(n==1){
		cout<<p<<endl;
		return 0;
	}
	while(1){
		tmp=1;
		for(long long i=1;i<=n;i++)tmp*=cnt;
		if(tmp>p)break;
		if(p%tmp==0)ans=cnt;
		cnt++;
	}
	cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
	if(a*b<c){
		d=a*b;
	}else{
		d=c;
	}
	printf("%d",d);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define lowbit(i) ((i)&(-(i)))
#define lson(i) ((i)<<1)
#define rson(i) ((i)<<1|1)
#define fi first
#define se second
#define MP(x,y) make_pair((x),(y))
using namespace std;

typedef long long ll;typedef unsigned long long ul;
typedef pair<int,int> pii;typedef pair<ll,ll> pll;
typedef vector<string> vss;
typedef vector<int> vii;typedef vector<pii> vpi;
typedef queue<int> qii;typedef queue<pii> qpi;

const int inf=0x3f3f3f3f;
const int maxn=100007;

int n,m,mn=inf,res;

int digit(int x){
	res=0;
	while(x!=0){
		res+=x%10;
		x/=10;
	}
	return res;
}

int main()
{
// 	freopen("","r",stdin);
// 	freopen("","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n/2+1;i++){
		mn=min(mn,digit(i)+digit(n-i));
	}
	printf("%d\n",mn);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
  string s;
  cin>>s;
  int ans=0;
  int tmp=0;
  for(int i=0;i<3;i++){
    if(s[i]=='R')
      tmp++;
    else{
      ans=max(ans,tmp);
      tmp=0;
    }
  }
  ans=max(ans,tmp);
  cout<<ans<<endl;
}

Measured memory_bytes: 3612
/*input
10
1000 193 256 777 0 1 1192 1234567891011 48 425
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
// #define endl "\n"
///------------------------------------------------------------
#define int long long
#define MAX 500
#define INF 0x3f3f3f3f

int n , x[MAX];
int solve(){
    int big = 0;
    REP(i , 1 , n + 1) big = max(big , x[i]);
    if(big < n) return 0;
    REP(i , 1 , n + 1) if(x[i] == big){
        REP(j , 1 , n + 1) x[j] ++;
        x[i] += -1 - n;
        return 1;
    }
}
int32_t main(){
    IOS;
    cin >> n;
    int ans = 0;
    REP(i , 1 , n + 1) cin >> x[i];
    REP(times , 0 , 3000000 / n / n){

        REP(i , 1 , n + 1) if(x[i] >= n) {
            int tmp = x[i] / n;
            x[i] %= n;
            ans += tmp;
            // if(tmp >= n) ans += (tmp - (n - 1)) * n , tmp = n - 1;
            REP(j , 1 , n + 1) if(i != j) x[j] += tmp;
        }
    // REP(i , 1 , n + 1) cout << x[i] << " " ; cout << endl;
    // DBGG("now ans = " , ans);
        
    }
    while(solve()) ans ++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())

a=list(map(int,input().split()))

a.sort()
c=1
ans=0
for i in range(N-1):
    if a[i]==a[i+1]:
        c+=1
        if c>a[i]:
            ans+=1
    else:
        if c<a[i]:
            ans+=c
            c=1
        else:
            c=1
if c<a[N-1]:
    ans+=c

print(ans)


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

typedef long long ll;
int main() {
  ll w, h;
  cin >> w >> h;
  vector<ll> lp(w), lq(h);
  for (ll &p: lp) cin >> p;
  for (ll &q: lq) cin >> q;
  sort(lp.begin(), lp.end());
  sort(lq.begin(), lq.end());
  lp.push_back(1e10);
  lq.push_back(1e10);
  int ip = 0, iq = 0;
  ll ans = 0;
  while (ip < w || iq < h) { 
    if (lp[ip] <= lq[iq]) {
      ans += (h-iq+1)*lp[ip];
      ++ip;
    }
    else { 
      ans += (w-ip+1)*lq[iq];
      ++iq;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

double W, H, x, y, Ans ;
long long  judgey[100000];
string S;
int n = 0;

int main() {
	cin >> W >> H >> x >> y;

	Ans = W * H / 2.0;
	cout << Ans<<" ";

	if (W / 2.0 == x && H / 2.0 == y)
		cout << 1;
	else
		cout << 0;

	return 0;
}


Measured memory_bytes: 256
x, y = map(int, input().split())

# x, y = 3, 12
# yが奇数だと駄目
if y%2 == 1:
  print('No')
  exit()
# 全部亀だとしても少なかったらNo
# 全部鶴としても多かったらNo
if x*4 < y or x*2 > y:
  print('No')
  exit()

# ほぼ解が存在
print('Yes')

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

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

	if(N.at(0)=='7' || N.at(1)=='7' || N.at(2) =='7')
		cout << "Yes";
	else
		cout << "No";
	cout << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>

using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  vector<int> v;
  if (S[0] == '0') v.push_back(0);
  int streak = 1;
  for (int i = 1; i < N; ++i) {
    if (S[i - 1] != S[i]) {
      v.push_back(streak);
      streak = 1;
    }
    else {
      ++streak;
    }
  }
  v.push_back(streak);
  if (S[N - 1] == '0') v.push_back(0);

  if (v.size() == 1) {
    cout << N << endl;
  }
  else {
    int ans = 0;
    for (int i = 0; i < (int)v.size(); i += 2) {
      int sum = 0;
      for (int j = i; j <= i + 2 * K; ++j) {
	if (j >= (int)v.size()) break;
	sum += v[j];
      }
      ans = max(ans, sum);
    }
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    long double a,b;
    cin>>a>>b;
    string n=to_string(a*b);
    string ans="";
    rep(0,i,n.length()){
        if(n[i]=='.')break;
        ans+=n[i];
    }
    cout<<ans;
}


Measured memory_bytes: 3820
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


struct edge {
	ll to;
	ll cost;
};
typedef pair<ll, ll> P;

void dijkstra(int s, vector<vector<edge>>& g, vector<ll>& d) {
	priority_queue<P, vector<P>, greater<P>> q;
	d = vector<ll>(g.size(), INF_LL);
	d[s] = 0;
	q.push(P{ 0,s });

	while (!q.empty()) {
		P p = q.top(); q.pop();
		ll v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < g[v].size(); i++) {
			edge e = g[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				q.push(P{ d[e.to] , e.to });
			}
		}
	}
}


int main() {
	int N, M, S, T;
	cin >> N >> M;
	vector<vector<edge>> g(N * 3);
	for (int i = 0; i < M; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		g[u].push_back({ N + v,1 });
		g[N + u].push_back({ N * 2 + v,1 });
		g[N * 2 + u].push_back({ v,1 });
	}
	cin >> S >> T;
	vector<ll> d;
	dijkstra(S - 1, g, d);
	if (d[T - 1] == INF_LL) {
		cout << -1 << endl;
		return 0;
	}
	cout << d[T - 1]/3 << endl;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;

int comp(ll i, ll j) {
    if (i > j) {
        return -1;
    } else if (i == j) {
        return 1;
    } else {
        return 1;
    }
}
// https://atcoder.jp/contests/abc107/submissions/8719924
// 転倒数の数え方が理解できなかったのでお借りした。

// Binary Indexed Tree モジュール (0-indexed)
template<typename T>
class BIT {
private:
    vector<T> val;
public:
    ll n;

    BIT(ll _n) : val(_n + 1, 0), n(_n) {}

    BIT(vector<T> arr) : val(arr.size() + 1, 0), n(arr.size()) {
        rep(i, n) add(i, arr[i]);
    }

    // a[i] に v を足す O(logN)
    void add(const ll _i, const T _v) {
        for (ll i = _i + 1; i <= n; i += i & (-i)) {
            val[i] += _v;
        }
    }

    // [0, _i) の和を求める O(logN)
    T get(ll i) const {
        T ans = 0;
        for (; i > 0; i ^= i & (-i)) {
            ans += val[i];
        }
        return ans;
    }

    // [l, r) の和を求める o(N)
    T sum(const ll l, const ll r) {
        return get(r) - get(l);
    }
};

size_t inversion(vector<ll> &x0) {

    vector<ll> x = x0;
    const int n = x0.size();

    // 座圧
    vector<ll> unq = x;
    sort(unq.begin(), unq.end());
    unq.erase(unique(unq.begin(), unq.end()), unq.end());
    map<ll, int> sahz;
    for (size_t i = 0; i < unq.size(); i++) sahz[unq[i]] = i;
    for (size_t i = 0; i < x.size(); i++) x[i] = sahz[x[i]];

    // BITで転倒数を求める
    size_t ans = 0;
    BIT<int> bit(n);
    for (int i = 0; i < n; i++) {
        ans += bit.sum(x[i] + 1, n);
        bit.add(x[i], 1);
    }

    return ans;

}


int main() {
    ll n;
    cin >> n;

    vector<ll> as(n);
    rep(i, n) cin >> as[i];

    ll max_a = -1;
    ll min_a = INF;
    rep(i, n) max_a = max(max_a, as[i]);
    rep(i, n) min_a = min(min_a, as[i]);


    ll cell = max_a + 1;
    ll floor = min_a;
    while (floor + 1 < cell) {
        ll mid = (cell + floor) / 2;
//    for (int mid = 0; mid < 35; mid++) {
        vector<ll> u_or_d(n, 0);
        rep(j, n) u_or_d[j] = comp(mid, as[j]);

        vector<ll> ruisekiwa(n + 1, 0);
        for (int i = 0; i < n; i++) {
            ruisekiwa[i + 1] = ruisekiwa[i] + u_or_d[i];
        }

        vector<ll> nuo(n + 1);
        rep(i, n + 1) nuo[i] = ruisekiwa[i] * 2 - i;
        reverse(nuo.begin(), nuo.end());

        ll tento_su = inversion(ruisekiwa);
        bool check = tento_su >= n * (n + 1) / 4 + 1;

        if (check) {
            cell = mid;
        } else {
            floor = mid;
        }
    }
    cout << floor << endl;


}

Measured memory_bytes: 10024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {

			long a = sc.nextLong();
			long b = sc.nextLong();
			long c = sc.nextLong();
			long d = sc.nextLong();

			long cd = c * d / gcd(c, d);

			long s = 0;
			long t = 0;
			long u = 0;

			if (a % c == 0) {
				s = b / c - a / c + 1;
			} else {
				s = b / c - a / c;
			}

			if (a % d == 0) {
				t = b / d - a / d + 1;
			} else {
				t = b / d - a / d;
			}

			if (a % cd == 0) {
				u = b / cd - a / cd + 1;
			} else {
				u = b / cd - a / cd;
			}

			long result = (b - a + 1) - (s + t - u);

			System.out.println(result);
		}

	}

	private static long gcd(long m, long n) {
		if (m < n)
			return gcd(n, m);
		if (n == 0)
			return m;
		return gcd(n, m % n);
	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int main(){
  string s;
  cin>>s;
  int a=0,b=0,c=0,L=s.length();
  for(int i=0;i<L;i++){
    if(s[i]=='a') a++;
    else if(s[i]=='b') b++;
    else c++;
  }
  int tmpa=a,tmpb=b,tmpc=c;
  tmpa=max({a,b,c});
  tmpc=min({a,b,c});
  tmpb=a+b+c-tmpa-tmpc;
  a=tmpa, b=tmpb, c=tmpc;
  for(int i=1;i<=L;i++){
    if(i%3==1){
      a--;
    }else if(i%3==2){
      b--;
    }else{
      c--;
    }
    if(a<0||b<0||c<0){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}


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

int main(void){
	int n, k;
	scanf("%d %d", &n, &k);
	char *str;
	str = (char *)malloc(sizeof(char)*n);
	scanf("%s", str);
	str[k-1] -= 'A' - 'a';
	puts(str);
	free(str);
	return 0;
	
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int n,s;
    int  S[10000];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        S[i]=s;
    }
    int q,t;
    int  T[500];
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>t;
        T[i]=t;
    }
    int count=0;
    for(int i=0;i<q;i++){
        for(int j=0;j<n;j++){
            if(T[i]==S[j]){
                count++;
            }
            if(T[i]==S[j])break;
        }
    }
  
    cout<<count<<endl;
    return 0;
    
}



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

#define ll long long
#define all(it) it.begin(), it.end()
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPU(i, a, b, s) for(int i = a; i < b; i += s)
#define REPD(i, a, b, s) for(int i = a; i > b; i -= s)
#define endl "\n"

ll INF = 2e18;
ll MOD = 1e9 + 7;
int i, j, k, t;

int main() {
    double A, B, C;
    cin >> A >> B >> C;
    cout << A * B / 2 << endl;
}

Measured memory_bytes: 3756
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let (N, M): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let (a, b): (Vec<usize>, Vec<usize>) = {
        let (mut a, mut b) = (vec![], vec![]);
        for _ in 0..M {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            a.push(iter.next().unwrap().parse().unwrap());
            b.push(iter.next().unwrap().parse().unwrap());
        }
        (a, b)
    };

    let ans = (1..(N + 1))
        .map(|i| (
            a.iter().filter(|&&x| x == i).count() +
            b.iter().filter(|&&x| x == i).count()
        ).to_string())
        .collect::<Vec<_>>()
        .join("\n");

    println!("{}", ans);
}


Measured memory_bytes: 4352
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s,t;
    cin >> s >> t;
    vector<set<ll>> st(26);
    vl T(t.size());
    rep(i,26){
        st[i].insert(INF);
    }
    rep(i,s.size()){
        st[s[i]-'a'].insert(i);
    }
    ll now=-1;
    ll cnt=0;
    ll k=0;
    rep(i,t.size()){
        ll x=t[i]-'a';
        if(st[x].size()==1){
            cout << -1 << endl;
            return 0;
        }
        else{
            k=*st[x].upper_bound(now);
            if(k==INF){
                cnt++;
                now=-1;
                k=*st[x].upper_bound(now);
            }
            now=k;
        }
    }
    cout << cnt*s.size()+k+1;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

using Tup = tuple<int64, int64, int64>;

vector<int64> prime;

void init(){
	bool notPrime[112345] = {};
	notPrime[0] = notPrime[1] = 1;
	FOR(i, 2, 112345){
		if(!notPrime[i]){
			prime.push_back(i);
			for(int64 j = 2;i*j < 112345;j++){
				notPrime[i*j] = 1;
			}
		}
	}
}

int main(void){
	init();
	int64 N, P;
	while(cin >> N >> P && N+P != -2){
		int32 idx = upper_bound(all(prime), N)-prime.begin();
		vector<int64> v1(100);
		REP(i, 100){
			v1[i] = prime[idx+i];
		}
		vector<int64> v2;
		REP(i, 100){
			FOR(j, i, 100){
				v2.push_back(v1[i]+v1[j]);
			}
		}
		sort(all(v2));
		cout << v2[P-1] << endl;
	}
}



Measured memory_bytes: 3380
while True:
    m,f,r=list(map(int,input().split()))
    if m==r==f==-1:
        break
    elif m==-1 or f==-1:
        print("F")
    elif 80<=m+f:
        print("A")
    elif 65<=m+f<80:
        print("B")
    elif 50<=m+f<65:
        print("C")
    elif 30<=m+f<50 and r<50:
        print("D")
    elif 30<=m+f<50 and r>=50:
        print("C")
    elif m+f<30:
        print("F")



Measured memory_bytes: 5592
#include <stdio.h>
#include <math.h>
#include <vector>

//FILE *in = freopen("2424.txt", "r", stdin);
//FILE * out = freopen("outputA.txt", "w", stdout);


int main()
{
	int n, count, cut;
	int num, front, back, max, now;
	std::vector<int> prev;

	//while (scanf("%d", &n) > 0){
		scanf("%d", &n);
		for(int i = 0; i < n; i++){
			scanf("%d", &num);
			max = 0;
			count = 0;
			if(num < 10)
			{
				printf("%d\n", count);
				continue;
			}
			while(num >= 10){
				count++;
				back = 0;
				cut = 0;
				max = 0;
				int a = 1;
				while((front = num / 10) > 0){
					back += (num%10)*a;
					now = back * front;
					if(max < now)
						max = now;
					num/=10;
					a *= 10;
				}
				num = max;
				if(prev.size() != 0){
					for(int i = 0; i < prev.size(); i++)
						if(num == prev.at(i))
						{
							count = -1;
							goto out;
						}
				}
				prev.push_back(num);

			}
			out:
			printf("%d\n", count);
			prev.clear();
		}
	//}
	return 0;
}

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

int main(){
    int a[5], k;
    for(int i = 0; i < 5; i++)
        cin >> a[i];
    cin >> k;

    for(int i = 0; i < 4; i++){
        for(int j = i + 1; j < 5; j++){
            if(abs(a[i] - a[j]) > k){
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
	/* time: O(n), space: O(1) */
	int buffet(const vector<int>& A, const vector<int>& B, const vector<int>& C) {
		const int n = A.size();
		int ans = 0;
		for (int i = 0; i < n; ++i) {
			const int curr = A[i] - 1;
			ans += B[curr];
			if (i > 0) {
				const int prev = A[i - 1] - 1;
				if (prev + 1 == curr)
					ans += C[prev];
			}
		}
		return ans;
	}
};

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

	vector<int> A(n), B(n), C(n - 1);
	for (int i = 0; i < n; ++i)
		cin >> A[i];
	for (int i = 0; i < n; ++i)
		cin >> B[i];
	for (int i = 0; i < n - 1; ++i)
		cin >> C[i];

	Solution sol;
	int ans = sol.buffet(A, B, C);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class MyClass
{
    public static void Main(string[] args)
    {
        var q1 = new Queue<string>();
        var q2 = new Queue<int>();
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = input[0];
        var q = input[1];
        var time = 0;
        for (int i = 0; i < n; i++)
        {
            var input2 = Console.ReadLine().Split();
            q1.Enqueue(input2[0]);
            q2.Enqueue(int.Parse(input2[1]));
        }
        while (q1.Count > 0)
        {
            var s = q1.Dequeue();
            var t = q2.Dequeue();
            if (t > q)
            {
                time += q;
                q1.Enqueue(s);
                q2.Enqueue(t - q);
            }
            else
            {
                time += t;
                Console.WriteLine("{0} {1}", s, time);
            }
        }
    }
}


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

using namespace std;

const int N = 1000;

int aa[N];

int main() {
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> aa[i];
	sort(aa, aa + n);
	int ans = 0;
	for (int i = 0; i < k; i++)
		ans += aa[i];
	cout << ans << '\n';
	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    priority_queue<int> que;
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        que.push(a);
    }

    int al = 0, bo = 0;
    for(int i = 0; i < n; i++)
    {
        if (i % 2 == 0)
        {
            al += que.top();
        }
        else
        {
            bo += que.top();
        }
        que.pop();
    }
    cout << al - bo << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("avx")

#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <utility>

template <const unsigned int N>
struct FastInput{
    char Input[N];
    char* input;
    FastInput(void):Input(), input(Input){ fread_unlocked(Input, sizeof(char), N, stdin); }
    inline int getint(void){
        int res = 0, c; while((c = *(input++) - '0') >= 0) res = 10 * res + c;
        return res;
    }
};

constexpr unsigned int MAX_INPUT = 7400'000; //'
FastInput<MAX_INPUT> Input;

template <const unsigned int N>
struct FastOutput{
    char Output[N];
    char S[10];
    char* ptr;
    FastOutput(void):Output(), ptr(Output){}
    ~FastOutput(void){ fwrite_unlocked(Output, sizeof(char), ptr - Output, stdout); }
    inline void write(int x){
        char* p = S;
        while(x){ *p++ = '0' + (x % 10); x /= 10; }
        while(p != S) *ptr++ = *(--p); 
        *(ptr++) = '\n';
    }
};
constexpr unsigned int MAX_OUTPUT = 2400'100; // '
FastOutput<MAX_OUTPUT> Output;

constexpr unsigned int MAX_N = 200'000; //'
int A[MAX_N + 1];
int Lis[MAX_N + 1];

struct edge{
    int to; 
    edge* next;
};

edge Edge[2 * MAX_N + 1];
edge* begin[MAX_N + 1];
edge* e_ptr = Edge;
inline void append(const int u, const int v){
    e_ptr -> to = v;
    e_ptr -> next = begin[u];
    begin[u] = e_ptr++;
}

int Ans[MAX_N + 1];
bool visited[MAX_N + 1];

struct stack_type{
    int vertex;
    int val;
};
stack_type Stack[2 * MAX_N + 3];
stack_type * stack = Stack;
inline stack_type* pop(void){ return --stack; }
inline void push(const int v, const int value){ stack -> vertex = v, stack -> val = value; ++stack;}
inline bool empty(void){ return stack == Stack; }

struct Index{
    int index;
    int val;
};
Index Restore[MAX_N + 1];

int main(void){
    int n = Input.getint();
    for(int i = 1; i <= n; ++i) A[i] = Input.getint();
    Lis[0] = 0; std::memset(Lis + 1, 0x7f, sizeof(Lis + 1));
    for(int i = 1; i < n; ++i){
        int u = Input.getint(), v = Input.getint();
        append(u, v); append(v, u);
    }
    visited[1] = true; push(1, 0);
    while(!empty()){
        const stack_type* p = pop();
        const int v = p ->vertex, value = p -> val;
        if(value == -1){ Lis[Restore[v].index] = Restore[v].val; }
        else{
            if(Lis[value] < A[v]){
                Restore[v].index = value + 1; Restore[v].val = INT32_MAX;
                Lis[value + 1] = A[v]; Ans[v] = value + 1;
            }
            else{
                int ok = 0, ng = value;
                while(ng - ok > 1){
                    const int mid = (ok + ng) >> 1;
                    if(Lis[mid] < A[v]) ok = mid; else ng = mid;
                }
                Restore[v].index = ng; Restore[v].val = Lis[ng];
                Lis[ng] = A[v]; Ans[v] = value;
            }
            push(v, -1);
            for(edge* itr = begin[v]; itr; itr = itr -> next) if(!visited[itr -> to]){ 
                visited[itr -> to] = true; push(itr -> to, Ans[v]);
            }
        }
    }
    for(int i = 1; i <= n; ++i) Output.write(Ans[i]);
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; ++i) cin >> H[i];

    int res = 0;
    int cnt = 0;
    for(int i = 1; i < N; ++i) {
        if(H[i - 1] >= H[i]) {
            cnt++;
        } else {
            cnt = 0;
        }

        if(res < cnt) {
            res = cnt;
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 10*9+7

int main(){
  int n; cin >> n;
  set<string>gift;
  for(int i=0;i<n;i++){
    string s; cin >> s;
    gift.insert(s);
  }
  cout<< gift.size() <<endl;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> b(N);
    for(int i=0; i<N; ++i) cin >> b[i];

    vector<int> res(N);
    for(int i=0; i<N; ++i) {
        int rm = b.size();
        for(int j = rm - 1; j >= 0; --j) {
            if(b[j] == j + 1) {
                rm = j;
                break;
            }
        }
        if(rm == b.size()) {
            cout << -1 << endl;
            return 0;
        } else {
            res[N - 1 - i] = rm + 1;
            b.erase(begin(b) + rm);
        }
    }
    for(int j : res) cout << j << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,v,b;
  cin >> a >> v >> b;
  if(a==v && v != b||v==b && v != a|| b==a && v!=b )cout << "Yes" << endl;
  else if(a==b && b==v || a!=b && b!= v && v!=a)cout << "No" << endl;
}


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

void solve(int x) {
	printf("%d", x);
	exit(0);
}
int main() {
	int n, m, a[3] = {-1, -1, -1}, s, c, i;
	scanf("%d %d", &n, &m);
	for(i = 0; i < m; i++) {
		scanf("%d %d", &s, &c);
		if(a[--s] == -1)
			a[s] = c;
		else if(a[s] != c)
			solve(-1);
	}
	if(n == 1)
		solve(a[0] == -1 ? 0 : a[0]);
	else {
		int r = 0;
		for(i = 0; i < n; i++)
			r = 10*r + (a[i] == -1 ? !i : a[i]);
		solve(a[0] ? r : -1);
	}
}

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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)

using namespace std;

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

int main () {
	ios::sync_with_stdio(false); cin.tie(0);
	int n,q;
	cin>>n>>q;
	string s;
	cin>>s;
	int prefix[n];
	prefix[0] = 0;
	rep(i,0,s.size()-2){
		int a;
		if(s[i]=='A' && s[i+1] == 'C') a=1;
		else a = 0;
		prefix[i+1] = a + prefix[i]; 
		//cout<<prefix[i+1]<<endl;
	}
	
	
	rep(i,0,q-1){
		int l,r;
		cin>>l>>r;
		if(l==1){
			cout<<prefix[r-1]<<"\n";
		}
		else{
			
			cout<<prefix[r-1] - prefix[l-1]<<"\n";
		}
	}
	return (0);
}

Measured memory_bytes: 1488
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    string s;
    cin >> s;
    int num = s.size();
    int k;
    cin >> k;
    int l = min(k, num);

    vs ss;
    rep(i, l) {
        rep(j, num-i) {
            ss.push_back(s.substr(j, i+1));
        } 
    }

    sort(all(ss));
    ss.erase(unique(all(ss)), ss.end());

    cout << ss[k-1] << endl;
}

Measured memory_bytes: 1660
#define _CRT_SECURE_NO_WARNINGS
 
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
 
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? (-(a)) : (a))
 
typedef long long ll;
 
using namespace std;
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
 
	bool contain = false;
 
	int N;
 
	scanf("%d", &N);
 
	while (N)
	{
		if (N % 10 == 7) contain = true;
		N /= 10;
	}
 
	if (contain) printf("Yes\n");
	else printf("No\n");
 
	return 0;
}

Measured memory_bytes: 3712
N,A,B,C=map(int,input().split())
lst=[int(input()) for i in range(N)]
key=4**N
ans=float("inf")
for i in range(4**N):
 flg=[0]*N 
 for j in range(N):
  if i!=0:
   flg[j]=i%4
  i=int(i/4)
 TA=0
 TB=0
 TC=0
 TD=0
 for k in range(N):
  if flg[k]==0:
   TA+=lst[k]
  elif flg[k]==1:
   TB+=lst[k]
  elif flg[k]==2:
   TC+=lst[k]
  else:
   TD+=1
  if TA!=0 and TB!=0 and TC!=0 :
   ans=min((N-TD-3)*10+abs(A-TA)+abs(B-TB)+abs(C-TC),ans)
print(ans)


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

int bubbleSort(vector<int> a,int n){
    bool flag=1;
    int cnt=0;
    while(flag){
        flag=0;
        for(int i=n-1;i>0;i--){
            if(a[i]<a[i-1]){
                swap(a[i],a[i-1]);
                flag=1;
                cnt++;
            }
        }
    }
    rep(i,n-1) cout<<a[i]<<' ';
    cout<<a[n-1]<<endl;
    cout<<cnt<<endl;
    
    return 0;
}

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    
    bubbleSort(a,n);
    
    return 0;
}


Measured memory_bytes: 3136
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
#define double long double
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<lint, lint> pll;
typedef complex<double> xy_t;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    char c;
    scanf("%c", &c);
    printf("%c\n", c+1);
}

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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int a,b,c,d, A[100], B[100], C[100][100], D[100][100][100];
string s, t, r;




int main(){
	cin >> a >> b >> c;
	if(c-b > a){
		cout << "dangerous" << endl;
	}else if(b>=c){
		cout << "delicious" << endl;
	}else{
		cout << "safe" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int N;
  std::cin >> N;

  if (N % 2 == 1) {
    std::cout << (double)(N / 2 + 1) / N << std::endl;
  } else {
    std::cout << (double)(N / 2) / N << std::endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sc scanf
using namespace std;
const int N=1e5+5;
const int mod=1e9+7;
typedef unsigned long long ull;
typedef long long ll;
template <typename it>int o(it a){cout<<a<<endl;return 0;}
ll a,b,c,d;
ll lcm(ll x,ll y){return x*y/__gcd(x,y);}
ll cal(ll x){
    return x/c+x/d-x/lcm(c,d);
}
int main(){
    cin>>a>>b>>c>>d;
    o(b-a+1-(cal(b)-cal(a-1)));
}

Measured memory_bytes: 256
n = int(input())
a = [0]*n
b = [0]*n
c = [0]*n
for i in range(n):
    a[i], b[i], c[i] = map(int,input().split())
dp = [[0]*3 for _ in range(n)]
dp[0][:] = [a[0],b[0],c[0]]
for i in range(1,n):
    for j in range(3): # 今日やること
        for k in range(3):# 前日やったこと
            if j == k:
                continue
            if j == 0:
                dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i])
            if j == 1:
                dp[i][j] = max(dp[i][j], dp[i-1][k] + b[i])
            if j == 2:
                dp[i][j] = max(dp[i][j], dp[i-1][k] + c[i])
print(max(dp[n-1][i] for i in range(3)))
#print(dp)

Measured memory_bytes: 61912
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s,t;
  int ans=0;
  cin>>s;
  cin>>t;
  for(int i=0;i<s.length();i++){
    if(s[i]!=t[i]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3912
#include <stdio.h>

typedef struct _point {
	double x,y;
}point;

double check_rotate(point a, point b, point c) {
	// x1(y2-y3)+x2(y3-y1)+x3(y1-y2)
	return a.x*(b.y-c.y)+b.x*(c.y-a.y)+c.x*(a.y-b.y);
}

int main(void) {
	double abc, dab, dbc, dca;
	point a, b, c, d;
	/*
	三角形ABCの回転の方向（A→B→C→Aと回ったときの向きが右周りか左周りか）と、
	３つの三角形DAB,DBC,DCAの回転の方向が同じであれば
	三角形の中に入っていることになります。
	（３つの三角形DAB,DBC,DCAの回転の方向が全部同じかどうかでも判断できます）

	三角形ABCの回転の方向は、
	x1(y2-y3)+x2(y3-y1)+x3(y1-y2)
	の符号で判断できます。
	（正なら左周り、負なら右回り）
	*/
	/* x1 y1 x2 y2 x3 y3 xp yp */
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf\n", &a.x, &a.y, &b.x, &b.y, &c.x, &c.y, &d.x, &d.y)==8) {
		abc = check_rotate(a, b, c);
		dab = check_rotate(d, a, b);
		dbc = check_rotate(d, b, c);
		dca = check_rotate(d, c, a);
		
		if(abc > 0 && dab > 0 && dbc > 0 && dca > 0) {
			printf("YES\n");
		} else if(abc < 0 && dab < 0 && dbc < 0 && dca < 0) {
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
	
	return 0;
}

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

#define MAX 100

int n, pre, pos;
int Preorder[MAX], Inorder[MAX], Postorder[MAX];

int find_parent(int key){
  for(int i=0; i<n; i++){
    if(key == Inorder[i]) return i;
  }
}

void reconstruction(int left, int right){
  if(left >= right) return;
  
  int key=Preorder[pre++];
  int position=find_parent(key);
  
  reconstruction(left, position);
  reconstruction(position+1, right);
  
  Postorder[pos++]=key;
}

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

  for(int i=0; i<n; i++) scanf("%d", &Preorder[i]);
  for(int i=0; i<n; i++) scanf("%d", &Inorder[i]);

  reconstruction(0, n);

  for(int i=0; i<n; i++){
    if(i) printf(" ");
    printf("%d", Postorder[i]);
  }

  printf("\n");
}



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

#define ll long long

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    int ans=a[0];
    for(int i=1;i<n;i++){
        ans=gcd(ans,a[i]);
    }
    cout<<ans<<endl;

    /*int mina=a[0];
    for(int i=0;i<n;i++){
        cout<<a[i]%mina<<" "<<mina<<endl;
        if(a[i]%mina<mina&&a[i]%mina>0){mina=a[i]%mina;a[i]=mina;i=0;}
        for(int j=0;j<n;j++)cout<<a[j]<<" ";
        cout<<i<<endl;
    }
    cout<<mina<<endl;*/

    return 0;
}




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

bool comp_str(string str1, string str2, int n){
  for(int i=0; i<n; i++){
    if(str1[i] != str2[i]){
      return false;
    }
  }
  return true;
}

int main(){
  string str;
  char sub_str[100];
  string pattern;
  int s_length, p_length;
  cin >> str;
  cin >> pattern;
  s_length = str.length();
  p_length = pattern.length();
  for(int i=0; i < s_length ; i++){
    if(pattern[0]==str[i]){
      for(int j=i; j<i+p_length; j++){
        sub_str[j-i] = str[j%s_length];
      }
       if(comp_str(sub_str, pattern, p_length)){
         cout << "Yes" << endl;
         return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3212
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;
using ll=long long;

#define PRI(n) cout << n <<endl;
#define PRI2(n, m) cout << n << " " << m << endl;
#define PRI3(n, m, o) cout << n << " " << m<< " " << o << endl;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REPInv(i, n)  for(int i = n-1; i >= 0; --i)

#define FOR(i, t, n)  for(int i = t; i <= (int)n; ++i)
#define FORInv(i, t, n)  for(int i = t; i >= (int)n; --i)

const char alphabet[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'};
const ll MOD = 1e9 + 7;

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

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll nCr(int n, int r) {
    vector<ll> C(r + 1);
    C[0] = 1;
    FOR(i, 1, n) FORInv (j, min(i, r), 1)C[j] = (C[j] + C[j - 1]) % MOD;
    return C[r];
}

struct edge {
    int to, cost;
    bool flag = false;
};
double N, M;
int A;
string S;
vector<edge> X[100010];
bool B[100010];
int D[100010];

int main() {
    cin >> S;
    ll sum = 0;
    for (int bit = 0; bit < (1 << S.length() - 1); bit++) {
        ll tmp = S[0] - '0';
        FOR(i, 1,S.length()-1) {
            if (bit & (1 << i-1)) {
                sum += tmp;
                tmp = (S[i] - '0');
            } else {
                tmp = tmp * 10 + (S[i] - '0');
            }
        }
        sum += tmp;
    }
    PRI(sum)
    return 0;

}

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

#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ldb long double 
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

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

const int md = 1e9+7;
const int MX = 2e5+5;
const ll INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n)
{
 ll res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a*=a;
  n/=2;
}
return res;
}

ll abst(ll a)
{
 return ((a<0)?(-1*a):(a));
}
ll dp[2001][20001],h,n;
vpi v;
ll fun(ll i,ll p)
{
  if(i==n)
    {
        if(p<=0)
         return 0;
         else
          return 1e12;
    }
    if(p<=0)
     return 0;
  
    if(dp[i][p]!=-1)
     return dp[i][p];
     ll ans;
     ans=min(fun(i+1,p),fun(i,p-v[i].first)+v[i].second);
     return dp[i][p]=ans;
}
int main()
{
      memset(dp,-1,sizeof(dp));
      cin>>h>>n;
      for(int i=0;i<n;i++)
      {
          ll x,y;
          cin>>x>>y;
           v.pb({x,y}); 
      }
      ll res=fun(0,h);
      cout<<res<<"\n";
      return 0;
}

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

int main(){
    int N;
    cin >>N;
    vector<string> W(N);
    string ans="Yes";
    for(int i=0;i<N;i++){
      cin>>W.at(i);
      if(i>0){
        int len=W.at(i-1).size();
        if(W.at(i-1).at(len-1)!=W.at(i).at(0)){
        ans="No";
      }}
    }
    if(ans=="Yes"){
      sort(W.begin(),W.end());
      for(int i=1;i<N;i++){
        if(W.at(i-1)==W.at(i)){
          ans="No";
          break;
        }
      }
    }
    cout<<ans<<endl;
  }


Measured memory_bytes: 256