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

using namespace std;

int main(void)
{
	char s[100][100];
	int h,w;
	bool row[100]={},col[100]={};


	cin>>h>>w;

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>s[i][j];
			if(s[i][j]=='#'){
				 row[i]=true;
				 col[j]=true;
			 }
		}
	}

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(row[i]&&col[j]) cout<<s[i][j];
		}
		if(row[i]) cout<<endl;
	}



	return 0;
}


Measured memory_bytes: 256
use std::io::{BufRead, Write, stdin, stdout};
 
 
fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let mut split = s.split_whitespace();
    let n: usize = split.next().unwrap().parse().unwrap();
    let mut ab = Vec::<(usize, usize)>::with_capacity(n);
    for _ in 0..n {
        let mut s = String::new();
        input.read_line(&mut s).unwrap();
        let mut split = s.split_whitespace();
        let a: usize = split.next().unwrap().parse().unwrap();
        let b: usize = split.next().unwrap().parse().unwrap();
        ab.push((a, b));
    }
    writeln!(output,
             "{}",
             ab.iter().rev().fold(0, |acc, &(a, b)| {
        acc + b -
        match (a + acc) % b {
            0 => b,
            _ => (a + acc) % b,
        }
    }))
        .unwrap();
}
 
fn main() {
    let stdin = stdin();
    solve(stdin.lock(), stdout());
}

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
char a[N][N];
int b[N][N][4];
int main()
{
	int n,m,ans=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",a[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			b[i][j][0]=1,b[i][j][1]=1,b[i][j][2]=n,b[i][j][3]=m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]=='.')
				continue;
			int ii=i+1,jj=j;
			while(ii<=n&&a[ii][jj]=='.')
			{
				b[ii][jj][0]=i+1;
				ii++;
			}
			ii=i,jj=j+1;
			while(jj<=m&&a[ii][jj]=='.')
			{
				b[ii][jj][1]=j+1;
				jj++;
			}
			ii=i-1,jj=j;
			while(ii>=1&&a[ii][jj]=='.')
			{
				b[ii][jj][2]=i-1;
				ii--;
			}
			ii=i,jj=j-1;
			while(jj>=1&&a[ii][jj]=='.')
			{
				b[ii][jj][3]=j-1;
				jj--;
			}
		}
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(a[i][j]=='.')
				ans=max(ans,b[i][j][3]-b[i][j][1]+b[i][j][2]-b[i][j][0]+1);
	printf("%d\n",ans);
	return 0;
}


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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

int main()
{
    int n, m;
    cin >> n >> m;
    int sum = 0;
    for (size_t i = 0; i < m; i++)
    {
        int a;
        cin >> a;
        sum += a;
    }
    

    int ans = n - sum;
    if (ans<0) ans = -1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, long long a, long long b){
    if(b % 2 == a % 2){
        cout << (b - a) / 2 << endl;
        return;
    }
    i64 c = a + (((b - a) - 1) / 2);
    i64 d = (n - b + 1) + ((n - (a + (n - b + 1))) / 2);
    cout << min(c, d) << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX
#include <iomanip>

using namespace std;
int MOD = 998244353;
const int mxN = 2e3 + 9;

ll dp[mxN][mxN];
pair<ll,ll> ar[mxN];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll N; ll ai;
	cin >> N;
	priority_queue<pair<ll,ll> > pq;
	for(ll i=1; i <= N; i++){
        cin >> ai;
        pq.push( make_pair( ai, i ) );
	}
	for(int i=1; i <= N; i++){
        ar[i].first = pq.top().first;
        ar[i].second = pq.top().second;
        pq.pop();
	}
	// array ar < cost, position >
	for(ll L=N; L >= 1; --L){
        for(ll R=L; R <= N; R++){
            if( L == R ) dp[L][R] = abs( ar[N].second - L ) * ar[N].first;
            else{
                ll i = N-R+L;
                ll pos = ar[i].second; ll weight = ar[i].first;
                dp[L][R] = max( dp[L+1][R] + abs(pos-L)*weight, dp[L][R-1] + abs(pos-R)*weight );
            }
        }
	}
	/*for(int i=1; i <= N; i++){
        for(int j=1; j <= N; j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
	}*/
	cout << dp[1][N] << "\n";

}


Measured memory_bytes: 26344
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, m; cin >> n >> m;
    vector<vector<ll>> adj(n);

    rep(i, m){
        ll a, b; cin >> a >> b; a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    ll start = 0, goal = n-1;
    for(auto p: adj[start]){
        for(auto q: adj[p]){
            if(q == goal){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 12776
import sys

a = []

n, m = map(int, input().split())
for i in range(n):
    ai = list(map(int, input().split()))
    ai.append(sum(ai))
    a.append(ai)

for i in range(n):
    print(" ".join(list(map(str, a[i]))))

ai = []
for j in range(m + 1):
    s = 0
    for i in range(n):
        s += a[i][j]
    ai.append(s)

print(" ".join(list(map(str, ai))))

Measured memory_bytes: 7720
#include <stdio.h>

int main(){
	int val[5];
	int valmin1 = 10;
	int valminflag = 0;
	int sum = 0;
	int i;

	for(i = 0; i < 5; i++){
                scanf("%d", &val[i]);

		if((val[i] % 10) != 0){
			valminflag = 1;
			if((val[i] % 10) < valmin1){
				valmin1 = (val[i] % 10);
			}
		} 
        }

	for(i = 0; i < 5; i++){
		if((val[i] % 10) != 0){
			val[i] += (10 - (val[i] % 10));
		}
		sum += val[i];
	}

	if(valminflag == 1){
		sum += (valmin1 - 10);
	}

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

	return 0;
}


Measured memory_bytes: 128
#include <cstdio>

const int MAXN = 1<<15;

int dp[MAXN+10][5];

int main(){
    dp[0][0] = 1;
    for(int i=1;i*i<=MAXN;i++){
        int sqr = i*i;
        for(int k=0;k+sqr<=MAXN;k++){
            for(int n=0;n<4;n++){
                dp[k+sqr][n+1] += dp[k][n];
            }
        }
    }
    int N;
    while(~scanf("%d", &N) && N){
        printf("%d\n", dp[N][1] + dp[N][2] + dp[N][3] + dp[N][4]);
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int A[N];
  int sum = 0;
  int B[N];
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
  }
  B[0] = A[0];
  int sa = 10000;
  for(int i = 1; i < N; i++) {
    B[i] = B[i - 1] + A[i];
  }
  for(int i = 1; i < N; i++) {
    if(sum - 2 * B[i] < 0) {
      sa = min(2 * B[i] - sum, sa);
    }
    else {
      sa = min(sum - 2 * B[i], sa);
    }
  }
  cout << sa << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n, m, a, b, maxn;
int main() {
	cin >> n >> m;
	maxn = m;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		m += a - b;
		if (m < 0) { cout << '0' << endl; goto E; }
		maxn = max(maxn, m);
	}
	cout << maxn << endl;
E:;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+5,mod=998244353;
int n,inv[N],f[N],g[N],u[N],vis[N];
bool vv[N];
int tot,p[N];
void init()
{
    inv[1]=1;
    for(int i=2;i<N;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
    u[1]=1;
    for(int i=2;i<N;i++)
    {
        if(!vv[i]) p[++tot]=i,u[i]=-1;
        for(int j=1;j<=tot&&i*p[j]<N;j++)
        {
            vv[i*p[j]]=true;
            if(i%p[j]==0)
            {
                u[i*p[j]]=0;
                break;
            }
            u[i*p[j]]=-u[i];
        }
    }
    for(int i=1;i<N;i++)
        for(int j=i;j<N;j+=i)
        f[j]=(f[j]+u[j/i]*inv[i])%mod,g[i]=(g[i]+1ll*vis[j]*j)%mod;
}
int main()
{
    scanf("%d",&n);
    ll ans=0;
    while(n--)
    {
        int x;scanf("%d",&x);vis[x]++;
        ans=(ans-x)%mod;
    }
    init();
    for(int t=1;t<N;t++)
        ans=(ans+1ll*f[t]*g[t]%mod*g[t]%mod)%mod;
    ans=ans*inv[2]%mod;
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 24552
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
x = int(input())
while 1 == 1:
    if is_prime(x):
        break
    else:
        x = x + 1
print(x)

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-c) <= d) cout << "Yes" << endl;
    else if(abs(a-b) <= d && abs(b-c) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;
// const int MOD = 998244353;

const int MAX_N = 200005;
int dp[MAX_N];
vector<int> to[MAX_N];
vector<int> a, ans;

void dfs(int v, int p = -1) {
   int i = lower_bound(dp, dp + MAX_N, a[v]) - dp;
   int old = dp[i];
   dp[i] = a[v];
   ans[v] = i;
   if (p != -1) ans[v] = max(ans[v], ans[p]);
   for (int u : to[v]) {
      if (u == p) continue;
      dfs(u, v);
   }
   dp[i] = old;
}
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n;
   cin >> n;
   a.resize(n);
   ans.resize(n);
   rep(i, 0, n) cin >> a[i];
   rep(i, 0, n - 1) {
      int u, v;
      cin >> u >> v;
      u--, v--;
      to[v].push_back(u);
      to[u].push_back(v);
   }

   rep(i, 1, MAX_N) dp[i] = INF;
   dp[0] = -INF;
   dfs(0);
   rep(i, 0, n) cout << ans[i] << endl;
   return 0;
}

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

int main(void)
{
    int n,count=0;
    vector<int> a;
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin >> x;
        if(i%2 == 1 && x%2 == 1)
        {
            count++;
        }
    }
    cout << count <<endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N, H;
  cin >> N >> H;
  vec<int> ab(N);
  int maxa = 0;

  REP(i, N) {
    int p, q;
    cin >> p >> q;
    ab[i] = q;
    chmax(maxa, p);
  }
  sort(ALL(ab));
  reverse(ALL(ab));
  int ans = 0;
  while (1) {
    // DEBUG(ab[ans]);
    if (ab[ans] < maxa || ans == N) {
      break;
    } else {
      H -= ab[ans];
      ans++;

      if (H <= 0) {
        print(ans);
        return 0;
      }
    }
  }
  //  DEBUG(H);
  //  DEBUG(maxa);
  print(ans + (int)ceil(H * 1.0 / maxa));
}

Measured memory_bytes: 1024
// IOI 2021
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////
 
const int N = 2e5 + 5;

int n, m, SEG[N << 2], LAZY[N << 2];
vector<int> Q[N];

#define md (s + e) >> 1
#define lc id << 1
#define rc lc ^ 1
void Apply(int id, int x) { SEG[id] += x, LAZY[id] += x; }
void Shift(int id) {
	if (LAZY[id] == 0) return;
	Apply(lc, LAZY[id]), Apply(rc, LAZY[id]);
	LAZY[id] = 0;
}
void Update(int l, int r, int x, int id = 1, int s = 0, int e = m + 2) {
	if (l >= e || s >= r) return;
	if (l <= s && e <= r) return Apply(id, x);
	Shift(id);
	Update(l, r, x, lc, s, md), Update(l, r, x, rc, md, e);
	SEG[id] = max(SEG[lc], SEG[rc]);
}
int Get(int l, int r, int id = 1, int s = 0, int e = m + 2) {
	if (l >= e || s >= r) return - INF;
	if (l <= s && e <= r) return SEG[id];
	Shift(id);
	return max(Get(l, r, lc, s, md), Get(l, r, rc, md, e));
}
void Build(int id = 1, int s = 0, int e = m + 2) {
	if (e - s < 2) return Apply(id, s);
	Build(lc, s, md), Build(rc, md, e);
	SEG[id] = max(SEG[lc], SEG[rc]);
}

int main() {
 
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	cin >> n >> m;
	Build();
	for (int i = 0; i < n; i++) {
		int l, r; cin >> l >> r;
		Q[l].push_back(r);
	}
	int ans = max(n - m, 0);
	for (int i = 0; i <= m + 1; i++) {
		for (int r : Q[i]) Update(i + 1, r + 1, 1);
		ans = max(ans, Get(i, m + 2) - i - m - 1);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 16016
#include <iostream>
 
using namespace std;
long long n,s,i,x,b[1000000];
int main()
{
    cin >> n;
    for (i=1; i<n; i++)
    
        cin >> b[i];
     s=b[1];
        for (i=2; i<n; i++)
        s+=min(b[i-1],b[i]);
        s+=b[n-1];
        cout<<s;
    return 0;
}

Measured memory_bytes: 3628
#include<string>
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
	int c,i,t;
	int l1,l2;
	int d;
	int sum,sum1,sum2,hozonn;
	char mozi[4]={'m','c','x','i'};
	string siki1,siki2;

	cin>>c;

	while(c--){
		cin>>siki1>>siki2;
		l1=siki1.size();
		l2=siki2.size();
		d=1000;
		t=0;
		sum=0;
		sum1=0;
		sum2=0;
		hozonn=0;
		for(i=0;i<l1;i++){
			if(siki1[i]=='m'){
				if(hozonn>0)
					sum1+=1000*hozonn;
				else
					sum1+=1000;
				hozonn=0;
			}
			else if(siki1[i]=='c'){
				if(hozonn>0)
					sum1+=100*hozonn;
				else
					sum1+=100;
				hozonn=0;
			}
			else if(siki1[i]=='x'){
				if(hozonn>0)
					sum1+=10*hozonn;
				else
					sum1+=10;
				hozonn=0;
			}
			else if(siki1[i]=='i'){
				if(hozonn>0){
					sum1+=hozonn;
				}
				else{
					sum1+=1;
				}
				hozonn=0;
			}
			else{
				hozonn=(int)siki1[i]-48;
			}
		}
		hozonn=0;
		for(i=0;i<l2;i++){
			if(siki2[i]=='m'){
				if(hozonn>0)
					sum2+=1000*hozonn;
				else
					sum2+=1000;
				hozonn=0;
			}
			else if(siki2[i]=='c'){
				if(hozonn>0)
					sum2+=100*hozonn;
				else
					sum2+=100;
				hozonn=0;
			}
			else if(siki2[i]=='x'){
				if(hozonn>0)
					sum2+=10*hozonn;
				else
					sum2+=10;
				hozonn=0;
			}
			else if(siki2[i]=='i'){
				if(hozonn>0)
					sum2+=hozonn;
				else
					sum2+=1;
				hozonn=0;
			}
			else{
				hozonn=(int)siki2[i]-48;


			}
		}
		sum=sum1+sum2;
		i=0;
		while(d){
			hozonn=sum/d;
			if(sum/d>0){
				if(hozonn==1){
					cout<<mozi[i];
					i++;
					sum=sum%d;
					d=d/10;
				}
				else{
					cout<<hozonn<<mozi[i];
					i++;
					sum=sum%d;
					d=d/10;
				}
			}
			else{
				i++;
				sum=sum%d;
				d=d/10;
			}
		}
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

#define int           long long 
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define ub            upper_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(4e18)
// #define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>
#define ordered_set   tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}
template< typename T1, typename T2 > bool operator<(pair<T1, T2> p1, pair<T1, T2> p2){ return p1 < p2 ;}

template<typename T> void Unique(vector<T> &v){
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}


void solve() {
	int n; cin >> n;
	vpi v(n);
	for(int i = 0; i < n; i++)
		cin >> v[i];
	sort(all(v));

	int mx1 = -v[0].F-v[0].S;
	int mx2 = -v[0].F+v[0].S;
	int ans = 0;
	for(int i = 1; i < n; i++) {
		ans = max(ans, v[i].F+v[i].S+mx1);
		ans = max(ans, v[i].F-v[i].S+mx2);
		mx1 = max(mx1, -v[i].F-v[i].S);
		mx2 = max(mx2, -v[i].F+v[i].S);
	}
	cout << ans << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   
    start = clock(); 

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif

    int test = 1;
    // cin >> test;
    
    cout << fixed << setprecision(2);
     
    for(int i = 1; i <= test; ++i){
    	solve();
    }

    cerr << time(start);
    return 0;
}


Measured memory_bytes: 6424
#include <float.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return *(int*)b-*(int*)a;}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}

int a[200000];
int main(void){
	int k=nextpint();
	int n=nextpint();
	for(int i=0; i<n; i++){
		a[i]=nextpint();
	}
	int ans=k+a[0]-a[n-1];
	for(int i=0; i<n-1; i++){
		int now=a[i+1]-a[i];
		if(now>ans) ans=now;
	}
	printf("%d\n", k-ans);
}


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

using namespace std;
int main(){
  long n,m;
  cin >> n >> m;
   
  long res=0;
  vector<long> t(n+1);
  for(int i=0;i<n;i++){
   cin >> t[i];
  }
  t[n]=t[n-1]+m;
  
  for(int i=0;i<n;i++){
   res+=min(t[i]+m,t[i+1])-t[i];
  }
  
  
 cout << res << endl;
  
  
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,a[55],mi=INF,ma=0;

int main(){
	cin >> n;
	REP(i,0,n) cin >> a[i];
	REP(i,0,n) mi=min(mi,a[i]),ma=max(ma,a[i]);
	
	cout << 2*n-2 << endl;
	if(abs(mi)>abs(ma)){
		int pos;
		REP(i,0,n) if(mi==a[i]){pos=i; break;}
		REP(i,0,n) if(i!=pos) cout << pos+1 << " " << i+1 << endl;
		RREP(i,n-1,1) cout << i+1 << " " << i << endl;
	}else{
		int pos;
		REP(i,0,n) if(ma==a[i]){pos=i; break;}
		REP(i,0,n) if(i!=pos) cout << pos+1 << " " << i+1 << endl;
		REP(i,0,n-1) cout << i+1 << " " << i+2 << endl;
	}
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i]=='1')
      ans ++;
  }
  
  cout << ans;
}

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

int main() {
  char c;
  cin >> c;
  if('A'<=c&&c<='Z'){
    cout << 'A' << endl;
  }
  else{
    cout << 'a' << endl;
  }
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n;
    cin >> n;
    pair<ll, ll> cost[n];
    rep(i, 0, n){
        ll a, b;
        cin >> a >> b;
        cost[i].first = a + b;
        cost[i].second = a;
    }

    sort(cost, cost + n, greater<pair<ll, ll>>());

    ll x = 0, y = 0;
    rep(i, 0, n){
        if(i % 2 == 0){
            x += cost[i].second;
        }else{
            y += cost[i].first - cost[i].second;
        }
    }

    cout << x - y << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<queue>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
 
using namespace std;
 
typedef long long ll;
 
#define MAX 5100
int N;
ll K,a[MAX];
bool dp[MAX];

bool check(int i) {
  memset(dp,false,sizeof dp);
  dp[0] = true;
  rep(j,N) {
    if( i == j ) continue;
    for(int k=K-1;k>=0;--k) {
      if( dp[k] && (ll)k+a[j] < K ) {
	dp[(ll)k+a[j]] = true;
      }
    }
  }
  bool need = false;
  rep(k,K) if( k+a[i] >= K && dp[k] ) {
    need = true;
    break;
  }
  return need;
}
 
void compute() {
  sort(a,a+N);
  int ans = 0;
  int L = 0, R = N;
  while( L + 1 < R ){
    int M = ( L + R ) / 2;
    if( check(M) ) R = M;
    else           L = M;
  }
  if( check(L) ) ans = L;
  else if( check((L+R)/2) ) ans = (L+R)/2;
  else ans = R;
  cout << ans << endl;
}
 
int main() {
  cin >> N >> K;
  rep(i,N) cin >> a[i];
  compute();
  return 0;
}


Measured memory_bytes: 384
def in_same_side?(ary_1, ary_2, ary_3, ary_p)
  a, b = ary_1
  c, d = ary_2
  i, k = ary_3
  p, q = ary_p
  alpha = (d - b)/(c - a)
  #ary_1, ary_2を通る直線 y = alpha * x + b - alpha * a
  if a == c
    laterality_ary_3 = i - a
    laterality_ary_p = p - a
  elsif b == d
    laterality_ary_3 = k - b
    laterality_ary_p = q - b
  else
    laterality_ary_3 = k - (alpha*i + b - alpha*a)
    laterality_ary_p = q - (alpha*p + b - alpha*a)
  end
  
  if laterality_ary_3 > 0 == laterality_ary_p > 0
    return true
  else
    return false
  end
end

while line = gets
  p = line.chomp.split.map(&:to_f).each_slice(2).to_a
  
  if in_same_side?(p[0], p[1], p[2], p[3]) && \
        in_same_side?(p[0], p[2], p[1], p[3]) && \
        in_same_side?(p[1], p[2], p[0], p[3])
    puts :YES
  else
    puts :NO
  end
end

Measured memory_bytes: 6144
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert
#define fh(x,v) for(auto x:v)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

vector<int> v;

main(){
	int n,k;
	string s;
	int ans=0;
	cin>>n>>k>>s;
	v.pb(0);
	char mem='1';
	rep(i,n){
		if(s[i]==mem)v.back()++;
		else{
			v.pb(1);
			mem=s[i];
		}
	}
	if(s.back()=='0')v.pb(0);
	int m=v.size();
	
	//fh(x,v)dump(x);
	for(int i=0;i<=max(0ll,m-(2*k+1));i+=2){
		int t=0;
		for(int j=i;j<min(m,i+2*k+1);j++){
			t+=v[j];
			//cout<<v[j]<<' ';
		}
		//cout<<endl;
		chmax(ans,t);
	}
	dans;
}




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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int h1,m1,h2,m2; cin >> h1 >> m1 >> h2 >> m2;
    int K; cin >> K;
    int time=(h2-h1)*60+(m2-m1);
    cout << time-K << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a, b, c, d;
    a = n / 1000;
    b = n / 100 % 10;
    c = n / 10 % 10;
    d = n % 10;
    if (a + b + c + d == 7) cout << a << '+' << b << '+' << c << '+' << d << "=7";
    else if (a + b + c - d == 7) cout << a << '+' << b << '+' << c << '-' << d << "=7";
    else if (a + b - c - d == 7) cout << a << '+' << b << '-' << c << '-' << d << "=7";
    else if (a + b - c + d == 7) cout << a << '+' << b << '-' << c << '+' << d << "=7";
    else if (a - b - c - d == 7) cout << a << '-' << b << '-' << c << '-' << d << "=7";
    else if (a - b - c + d == 7) cout << a << '-' << b << '-' << c << '+' << d << "=7";
    else if (a - b + c + d == 7) cout << a << '-' << b << '+' << c << '+' << d << "=7";
    else if (a - b + c - d == 7) cout << a << '-' << b << '+' << c << '-' << d << "=7";
    
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
long long sum(long long S){
  vector<long long> digits(0);
  long long keta=1;
  while(true){
    digits.push_back((S%(keta*10))/keta);
    keta=keta*10;
    if((S/keta)==0){
      break;
    }
  }
  if(digits.size()==1){
    return S;
  }
  else{
    long long result=S;
    for(long long i=0;i<digits.size()-1;i++){
      long long right_number=0,keta=1;
      for(long long j=0;j<i+1;j++){
        right_number=right_number+digits.at(j)*keta;
        keta*=10;
      }
      long long a=1;
      for(long long j=1;j<digits.size()-1-i;j++){
        a*=2;
      }
      result=result+right_number*a;
      long long left_number=0,ket=1;
      for(long long j=i+1;j<digits.size();j++){
        left_number=left_number+digits.at(j)*ket;
        ket*=10;
      }
      result+=sum(left_number);
    }
    return result;
  }
}
int main() {
  long long S;
  cin>>S;
  cout<<sum(S)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou((int)bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
    }
    else{
      par.at(rx) = ry;
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
int main(){
  int n,m,q;
  cin >> n >> m >> q;
  vector<vector<int>> abcd(q,vector<int>(4));
  for(int i=0;i<q;i++){
    cin >> abcd.at(i).at(0) >> abcd.at(i).at(1) >> abcd.at(i).at(2) >> abcd.at(i).at(3);
    abcd.at(i).at(0)--;abcd.at(i).at(1)--;
  }
  vector<int> p;
  for(int i=0;i<m-1;i++){
    p.push_back(0);
  }
  for(int i=0;i<n;i++){
    p.push_back(1);
  }
  int ans = 0;
  do{
    vector<int> a;
    int count0 = 1;
    for(int i=0;i<n+m-1;i++){
      if(p.at(i) == 0)count0++;
      else a.push_back(count0);
    }
    int tmp = 0;
    for(int i=0;i<q;i++){
      if(a.at(abcd.at(i).at(1)) - a.at(abcd.at(i).at(0)) == abcd.at(i).at(2))tmp += abcd.at(i).at(3);
    }
    ans = max(ans,tmp);
  }
  while(next_permutation(p.begin(),p.end()));
  cout << ans << endl;
}

Measured memory_bytes: 3620
typedef struct{double x,y,k;}w;w p[101],b;m,v[100],n,j;z(w*c,w*d){return c->k>d->k?-1:1;}double o(q,r,s){return p[q].x*(p[r].y-p[s].y)+p[r].x*(p[s].y-p[q].y)+p[s].x*(p[q].y-p[r].y);}main(i){for(;j=scanf("%d",&n)+~n;){for(m=i=0;i<n;i++)scanf("%lf,%lf",&p[i].x,&p[i].y),p[m].y>p[i].y?m=i:0;b=p[m];p[m]=*p;*p=b;p[100].x=b.x;p[100].y=b.y+1;for(i=1;i<n;i++)p[i].k=o(0,i,100)/hypot(p[i].x-b.x,p[i].y-b.y);qsort(p+1,n-1,24,z);*v=0;v[1]=1;v[2]=j=2;for(i=3;i<n;i++){for(;o(v[j-1],v[j],i)<=0;j--);v[++j]=i;}printf("%d\n",n+~j);}}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[]a = new int[n];
 
    int all = 0;
    for(int i=0; i<n; i++){
        a[i] = sc.nextInt();
        all += a[i];
    }
    int cou = 0;
    for(int i=0; i<n; i++){
        if(a[i] >= (double)all/(4*m)) {
        	cou++;
        }
    }
       if(cou>=m) {
    	   System.out.println("Yes");
       }else {
    	   System.out.println("No");
       }
    }
}


Measured memory_bytes: 35872
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S; 
	cin >> S; 
	int A = 0, B = 0, C = 0; 
	int N = S.size(); 
	for(int i = 0; i < N; i++){
		if(S.at(i) == 'a') A ++; 
		if(S.at(i) == 'b') B ++; 
		if(S.at(i) == 'c') C ++; 
	}
	if(max({A, B, C}) - min({A, B, C}) <= 1) cout << "YES" << endl; 
	else cout << "NO" << endl; 
}

Measured memory_bytes: 512
#include<iostream>

using namespace std;
int main(){
  int n,i,b,t,x[5][14]={{}};
  char a;
  //x[4][8] =0;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a >> b;
    switch(a){
      case 'S':
       x[1][b]=1;
       break;
      case 'H':
       x[2][b]=1;
       break;
      case 'C':
       x[3][b]=1;
       break;
      case 'D':
       x[4][b]=1;
       break;
     }
    }
    for(t=1;t<5;t++){
      for(i=1;i<14;i++){
        if(x[t][i]==0){
          switch (t) {
          case 1:
          cout << "S " << i << endl;
          break;
          case 2:
          cout << "H " << i << endl;
          break;
          case 3:
          cout << "C " << i << endl;
          break;
          case 4:
          cout << "D " <<  i << endl;
          break;
      }
    }
  }
}
  return 0;
}



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

int main() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(0);

	int n, m,k=0; cin >> n >> m;

	if ((n+m)%3==0||n%3==0||m%3==0)cout << "Possible" << endl;
	else cout << "Impossible" << endl;

	return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rrep(i,n) for(int i=(int)(n)-1; i>=0; i--)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl
#define F first
#define S second
typedef long long ll;
typedef pair<int,string> P;
const int MAX=1000000001;
const ll MAXL=1000000000000000001LL;
const ll mod=1000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

map<string,int> mp;

bool cmp(P a, P b) {
  return a.first>b.first;
}

vector<P> m(vector<P> a) {
  if(a.size()==1) return a;
  if(a.size()==2) {
    inplace_merge(a.begin(),a.begin()+1,a.end(),cmp);
    return a;
  }
  vector<P> b,c;
  for(int i=0; i<a.size(); i++) {
    if(i<a.size()/2) b.push_back(a[i]);
    else c.push_back(a[i]);
  }
  b=m(b);
  c=m(c);
  copy(c.begin(), c.end(), back_inserter(b)); 
  inplace_merge(b.begin(),b.begin()+(b.size()-c.size()),b.end(),cmp);
  return b;
}

int main() {
  int n;
  while(cin >> n && n) {
    string s;
    getline(cin,s);
    mp.clear();
    rep(i,n) {
      getline(cin,s);
      stringstream ss;
      ss << s;
      while(ss >> s) mp[s]++;
    }
    char c;
    cin >> c;
    vector<P> v;
    tr(it,mp) {
      if(it->F[0]==c) v.pb(P(it->S,it->F));
    }
    if(v.size()==0) {
      pr("NA");
    } else {
      v=m(v);
      rep(i,v.size()) {
	if(i>=5) break;
	if(i) cout << " ";
	cout << v[i].S;
      }
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1264
import math
a,b,x = map(int,input().split())
if a*a*b/2 >= x:
  c = 2*x/a/b
  rad = math.atan(b/c)
else:
  c = (a*a*b - x)*2/a/a
  rad  = math.atan(c/a)
print(rad * 180 / math.pi)

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

int main(){
    string s;
    cin>>s;
    int n=s.size();
    if(n!=26){
        set<char>se;
        rep(i,n){
            se.insert(s[i]);
        }
        for(char i='a'; i<='z'; ++i){
            if(se.find(i)==se.end()){
                cout<<s<<i<<endl;
                return 0;
            }
        }
    }
    else{
        if(s=="zyxwvutsrqponmlkjihgfedcba"){
            cout<<-1<<endl;
            return 0;
        }
        else{
            vector<char>c;
            c.push_back(s[n-1]);
            for(int i=n-2; i>=0; --i){
                sort(c.rbegin(),c.rend());
                if(c[0]<s[i]){
                    c.push_back(s[i]);
                }
                else{
                    c.push_back(s[i]);
                    sort(c.begin(),c.end());
                    cout<<s.substr(0,i)+c[lower_bound(c.begin(),c.end(),s[i])-c.begin()+1]<<endl;
                    return 0;
                }
            }
        }
    }
}

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

using namespace std;

using ll = long long ;

ll lcm(ll a, ll b) {
    ll g = __gcd(a,b);
    return (long double)a/g * b;
}


void solve() {
    int n; cin >> n;
    ll res = 1;
    for (int _ = 0; _ < n; _++) {
        ll x; cin >> x;
        res = lcm(res, x);
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
/* ABC140-B
   Takatan */

#include<stdio.h>
#include<stdlib.h>
int main(void){
    int number, *meal, *happy, sum, i;
    sum = 0;

    scanf( "%d" , &number);
    meal = malloc(sizeof(int) * number);
    happy = malloc(sizeof(int) * number);
    for(i=0; i < number; i++){
        scanf( "%d" , &meal[i]);
    }
    for(i=0; i < number; i++){
        scanf( "%d" , &happy[i]);
        sum += happy[i]; /* 全ての料理の満足度を加算 */
    }
    for(i=0; i < number-1; i++){
        scanf( "%d" , &happy[i]);
    }

    for(i=1; i < number; i++){
        if(meal[i-1]==meal[i]-1){ /* 料理の番号が連続している時 */
            sum += happy[meal[i]-2]; /* 満足度の加算 */
        }
    }

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

Measured memory_bytes: 128
#include<iostream>
#include<bits/stdc++.h>
#include<climits>
#include<math.h>
 
#define forn(x,n,s) for(int i = x; i < n; i += s )
#define forr(x,n,s) for(int i = x; i>=n; i -= s)
#define PI 3.14159265358979323846264338327950L
 
using namespace std;
 
void go(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
 
  #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
  #endif
} 
long long int mod = 1e9+7;
 
int main(){
    go(); 
 
    // code here
    int n,m,k;cin>>n>>m>>k;
    int cost[n];
    vector<vector<int>> arr(n,vector<int>(m));
    forn(0,n,1){
        cin>>cost[i];
        for(int j = 0; j < m; j++){
            cin>>arr[i][j];
        }
    }
    int ans = INT_MAX;
    for(int i = 0; i < (1<<n); i++){
        vector<int> temp(m,0);
        int temp_c = 0; 
        for(int j = 0; j < n;j++){
            if(i&(1<<j)){
                for(int k = 0;k < m;k++){
                    temp[k] += arr[j][k]; 
                }
                temp_c += cost[j];
            }
        }
        int flag = 0;
        for(int x:temp){
            if(x<k){
                flag = 1;
                break;
            }
        }
        if(flag == 0) ans = min(ans,temp_c);
    }
    if(ans==INT_MAX) cout<<-1;
    else cout<<ans;
}

Measured memory_bytes: 3660
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C++ (GCC 5.4.1)
*/

#include <bits/stdc++.h>
using namespace std;

// utility of stdin,stdout
#define _CRT_SECURE_NO_WARNINGS
#define OUT cout << 
#define BR << endl
#define RET return 0
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,k;
	int cnt = 0;
	std::vector<int> h(100003);

	cin >> n >> k;
	for (int i = 0; i < n; ++i)
	{
		cin >> h.at(i);
		if(h.at(i) >= k)	++cnt;
	}
	OUT(cnt) BR;
	RET;
}


Measured memory_bytes: 640
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	var s = toIntArr(input[0].split(''));
	var l = s.length;
	var ans = 100000;
	var x = 0;
	for(var i = 0; i < l-2; i++){
		x = s[i]*100 + s[i+1]*10 + s[i+2];
		x = abs(x - 753);
		if(ans > x) ans = x;
	}
	if(ans == 0) ans = 0;
	
	console.log(ans);
}

Measured memory_bytes: 22080
#include <iostream>
#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 fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#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 Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
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-9;



int main() {
    
    int n,m;
    cin>>n>>m;
    vi cost(m),keys(m);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        bitset<12> bs;
        rep(j,b){
            int c;
            cin>>c;
            bs[c-1]=1;
        }
        int sum=0;
        rep(j,12){
            sum+=bs[j]*pow(2,j);
        }
        keys[i]=sum;
        cost[i]=a;
    }
    vll dp((1<<n)+10,INF);
    dp[0]=0;
    for(int i = 0; i < (1<<n); i++){
        rep(j,m){
            chmin(dp[i|keys[j]],dp[i]+cost[j]);
        }
    }
    if(dp[(1<<n)-1]!=INF)fin(dp[(1<<n)-1]);
    else fin(-1);
    // rep(i,n)cout<<i<<" : "<<keys[i]<<endl;
    // cout<<endl;
    // rep(i,1<<n)cout<<i<<" : "<<dp[i]<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main():
    inputs = list(map(lambda x: int(x), input().split(' ')))
    if inputs[0] % inputs[1] == 0:
        ans = inputs[0] // inputs[1]

    else:
        ans = inputs[0] // inputs[1] + 1

    print(ans * inputs[2])

if __name__ == '__main__':
    main()

Measured memory_bytes: 9016
import fractions as frac
A,B,C,D = map(int,input().split(' '))

countC = (B // C) - (A // C)
countD = (B // D) - (A // D)
def lcm(x, y):
    return (x * y) // frac.gcd(x, y)
lcmCD = lcm(C, D)

countlcm = (B // lcmCD) - (A // lcmCD) 

num = B - A + 1
if A % C == 0:
  countC += 1
if A % D == 0:
  countD += 1
if A % lcmCD == 0:
  countlcm += 1

print(num - countC - countD + countlcm)

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
//#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int c[10][10];
int a[10];
int b[10];
signed main(){
    rep(i,3){
        rep(j,3) cin >> c[i][j];
    }   
    a[0] = min({c[0][0],c[0][1],c[0][2]});
    a[1] = min({c[1][0],c[1][1],c[1][2]});
    a[2] = min({c[2][0],c[2][1],c[2][2]});
    b[0] = c[0][0] - a[0];
    b[1] = c[0][1] - a[0];
    b[2] = c[0][2] - a[0];
    rep(i,3){
        rep(j,3){
            if(c[i][j] - a[i] != b[j]){
                cout << "No" << '\n';
                return 0;
            }
        }
    }   
    cout << "Yes" << '\n';
    return 0;   
}


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

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    sort(v.begin(),v.end());
    cout << v[v.size()-1]-v[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

const long long MOD_CONST = 1000000007;


int main() {

	long long x, y;
	cin >> x >> y;

	long long num = y / x;
	int cnt = 0;
	while (num > 0) {
		num /= 2;
		cnt++;
	}

	cout << cnt << endl;
	
}

Measured memory_bytes: 256