akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MAX 200200
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
ll n,a[MAX],b[MAX],ans,tot,sum,L[MAX],R[MAX];
ll x[MAX],y[MAX],sx[MAX],sy[MAX],sa[MAX];
int main()
{
	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	
	int l=1,r=n;
	while(!a[l]&&l<=n)++l;
	while(!a[r]&&r>=1)--r;
	if(l>n||r<1||l>=r){puts("0");return 0;}
	for(int i=l;i<=r;++i)a[i-l+1]=a[i];n=r-l+1;
	a[n+1]=0;ans=1e18;
	for(int i=1;i<=n;++i)x[i]=~a[i]&1,y[i]=a[i]<=2?2-a[i]:(a[i]%2);
	for(int i=1;i<=n;++i)sx[i]=sx[i-1]+x[i],sy[i]=sy[i-1]+y[i],sa[i]=sa[i-1]+a[i];
	ll mn=0;
	for(int i=1;i<=n;++i)mn=min(mn,sa[i]-sy[i]),L[i]=mn+sy[i];
	mn=sy[n];
	for(int i=n-1;~i;--i)mn=min(mn,sa[n]-sa[i]+sy[i]),R[i]=mn-sy[i];
	mn=ans;
	for(int i=0;i<=n;++i)mn=min(mn,L[i]-sx[i]),ans=min(ans,mn+R[i]+sx[i]);
	cout<<ans<<endl;
	/*
	for(int i=1;i<=n;++i)b[i]=a[i]&1;
	for(int i=1;i<=n;++i)if(a[i]==0)tot+=1,b[i]=1;
	for(int i=1;i<=n;++i)if(!b[i])b[i]+=2;
	for(int i=2;i<=n;++i)if(b[i]!=b[i-1])++tot;
	if(b[1]!=b[2])ans=min(ans,tot-1);
	if(b[n-1]!=b[n])ans=min(ans,tot-1);
	ans=min(ans,tot);
	for(int i=2,fl=0;i<n;++i)
	{
		if(b[i]!=b[i-1]&&b[i]!=b[i+1])
		{
			if(!fl)ans=min(ans,tot-=2),fl=true,b[i]=b[i-1];
			else ans=min(ans,tot-=1),b[i]=b[i-1];
		}
	}
	*/
	//printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 14080
#include<iostream>
#include<regex>
#include<string>
std::string S;
std::regex akiba("A?KIHA?BA?RA?");
int main() {
	std::cin >> S;
	std::cout << (std::regex_match(S, akiba) ? "YES" : "NO") << std::endl;
	return 0;
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
for i in range(1, n + 1):
    a[i] += a[i - 1]
for i in range(1, m + 1):
    b[i] += b[i - 1]
i, j, z = 0, m, 0
while i <= n and a[i] <= k:
    while b[j] > k - a[i]:
        j -= 1
    z = max(z, i + j)
    i += 1
print(str(z))

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

int main(){
  int i,n;
  long long int L[87];

  L[0]=2; L[1]=1;

  cin >> n;

  for(i=2;i<=n;i++) L[i]=L[i-1]+L[i-2];

  cout << L[i-1] << endl;
  
  return 0;
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

const int MOD = 1e9 + 7;
vector<vector<int>> P;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N, M, A, ans = 1, rcnt = 0, ccnt = 0, fp = 0;
	cin >> N >> M;
	P.resize(N*M + 1);
	for (int i = 0; i < N; i++) {
		cin >> A;
		P[A].push_back(1);
	}
	for (int i = 0; i < M; i++) {
		cin >> A;
		P[A].push_back(-1);
	}
	for (int k = N * M; k; k--) {
		if (P[k].size() > 2 || P[k].size() == 2 && P[k][0] == P[k][1]) {
			cout << "0\n";
			return 0;
		}
		if (P[k].size() == 2) {
			fp += rcnt + ccnt;
			rcnt++;
			ccnt++;
		}
		else if (P[k].empty()) {
			if (fp) {
				ans = (1LL * ans*fp--) % MOD;
			}
			else {
				cout << "0\n";
				return 0;
			}
		}
		else if (P[k][0] == 1) {
			ans = (1LL * ans*rcnt) % MOD;
			ccnt++;
			fp += rcnt - 1;
		}
		else {
			ans = (1LL * ans*ccnt) % MOD;
			rcnt++;
			fp += ccnt - 1;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 23808
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int n, m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;
}

Measured memory_bytes: 384
import java.io.*;

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

		int a, b;


		String str = br.readLine();
		String strArr[] = str.split(" ");

		a = Integer.parseInt(strArr[0]);
		b = Integer.parseInt(strArr[1]);

		System.out.println(a*b + " " + (a*2 + b*2));
	}
}

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

using namespace std;

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

    for (int i = 0; i < 4; i++) {
        cout << s[i];
    }
    cout << " ";
    for (int i = 4; i < 12; i++) {
        cout << s[i];
    }
    cout << endl;
    
    return 0;
}

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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long N;
    cin >> N;
    long long k = 0;
    for(int i = 1;i<=N;i+=2){
      const auto &pf = prime_factorize(i);
      long long res = 1;
      for (auto p : pf) res *= p.second + 1;
      if(res==8) k++;
    }
    cout<<k;
}

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

using namespace std;
using ll = long long;

vector<vector<int> > vs;

vector<int> visited;
void dfs(int v, int id) {
  if (visited[v] != -1) {
    return;
  }
  visited[v] = id;
  for (auto nv : vs[v]) {
    if (visited[nv] != -1) {
      continue;
    }
    dfs(nv, id);
  }
  return;
}

int main() {
  int n, m;
  cin >> n >> m;
  visited.assign(n, -1);
  vs.assign(n, vector<int>());
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    vs[a].emplace_back(b);
    vs[b].emplace_back(a);
  }
  int id = 0;
  rep(i, n) {
    if (visited[i] != -1) {
      continue;
    }
    dfs(i, id);
    id++;
  }
  sort(visited.begin(), visited.end());
  int mv = 0;
  int cnt = 1;
  for (int i = 1; i < visited.size(); i++) {
    if (visited[i - 1] == visited[i]) {
      cnt++;
    } else {
      mv = max(cnt, mv);
      cnt = 1;
    }
  }
  mv = max(cnt, mv);
  cout << mv << endl;
  return 0;
}


Measured memory_bytes: 21048
import sys
input = sys.stdin.readline
from collections import deque
n = int(input())
a = list(map(int,input().split()))
n += 2
ls = [0 for i in range(n*n)]
for i in range(n):
  for j in range(n):
    ls[i*n+j] = min(i,j,n-1-i,n-1-j)-1
ans = 0
st = [0]*(n*n)
for i in a:
  x,y = divmod(i-1,n-2)
  i = (x+1)*n+(y+1)
  ans += ls[i]
  st[i]=1
  q = deque([i])
  while q:
    j = q.popleft()
    for k in (j-n,j+n,j+1,j-1):
      if st[j]:
        if ls[j] < ls[k]:
          ls[k] = ls[j]
          q.append(k)
      elif ls[j]+1 < ls[k]:
        ls[k] = ls[j]+1
        q.append(k)
print(ans)

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

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

    string s;
    cin >> s;
    
    int ans = 0;

    for(int i = 1; i < s.size(); i++){
        if(s[i - 1] == s[i]){
            ans++;
            if(s[i] == '0') s[i] = '1';
            else s[i] = '0';
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int nowMin = 1001001001;
    int ans = 0;
    rep(i,n) {
        int p;
        cin >> p;
        nowMin = min(nowMin, p);
        if (nowMin == p) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int X = sc.nextInt();
      int Y = sc.nextInt();
      int Z = sc.nextInt();
      int W;
      W=X;
      X=Y;
      Y=W;
      
      W=X;
      X=Z;
      Z=W;
      System.out.println(X+" "+Y+" "+Z);
    }
}

Measured memory_bytes: 39308
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int64_t a,b,c,k; cin >> a >> b >> c >> k;
  if(k%2==0) cout << a-b << endl;
  else cout << b-a << endl;
}

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

int main()
{
    int n;
    cin >> n;
    int d, x;
    cin >> d >> x;
    int ans = x;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        ans += (d - 1) / a + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
h,w=map(int,input().split())
s=[input() for _ in range(h)] #マップ
vi=[ [-1 for _ in range(w)] for _ in range(h)]#visit
st=deque()

d=[[0,1],[-1,0],[1,0],[0,-1]]

mx=0

for i in range(h):
  for j in range(w):
    vi=[ [-1 for _ in range(w)] for _ in range(h)]
    st.append([i,j,0])
    
    while st:
      h1,w1,k=st.popleft()

      if 0<=h1<h and 0<=w1<w and vi[h1][w1]==-1 and s[h1][w1]==".":
        vi[h1][w1]=k
        for m in d:
          st.append([h1+m[0],w1+m[1],k+1])
    for m in vi:
      mx=max(mx,max(m))

print(mx)

Measured memory_bytes: 9376
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<(#a)<<':'<<(a)<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key < value;
}

int binary_search(vector<ll> a,ll key){
  ll ok = a.size();
  ll ng = -1;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<pair<pair<string,int>,int>> a(n);
  rep(i,n){
    cin>>a[i].fi.fi>>a[i].fi.se;
    a[i].fi.se = -a[i].fi.se;
    a[i].se = i+1;
  }
  sort(all(a));
  rep(i,n)print(a[i].se);
  return 0;
} 


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(
            new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while(true){
        	String[] line = br.readLine().split(" ");
        	int h = Integer.parseInt(line[0]);
        	int w = Integer.parseInt(line[1]);
        	if(h==0 && w== 0) break;
        	
        	for(int j=0;j<h;j++){
        	for(int i=0;i<w;i++){
        	sb.append("#");
        	}
        	sb.append("\n");
        	}
        	sb.append("\n");	
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 25588
N, M = map(int, input().split())
scl = [list(map(int, input().split())) for _ in range(M)]
if N != 1:
    mincand = 10**(N-1)
else:
    mincand = 0
maxcand = 10**N-1

for i in range(mincand, maxcand+1):
    if all([str(i)[s-1] == str(c) for s, c in scl]):
        print(i)
        exit()
print(-1)

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

int main() {
    int N, x;
    cin >> N >> x;

    int a[N];
    for (int i=0; i<N; ++i) cin >> a[i];

    sort(a, a+N);
    int ans = 0;
    for (int i=0; i<N; ++i) {
        if (x >= a[i]) {
            ++ans;
            x -= a[i];
        } else {
            break;
        }
    }
    if (ans == N && x > 0) --ans; 

    cout << ans << endl;

    return 0;
}

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

using namespace std;

namespace MyLib {
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long
}

using namespace MyLib;


int main() {
	string r;
	int n;
	cin >> n;
	REP(x,n){
		cin >> r;
		string s = "";
		int co = 0;
		string buf = "";
		int num = 0;
		REP(i, r.size())
			if (r[i] == '0') {
				if (num == 0)
					continue;
				if (num == 1)
					if (co % 5 == 1)
						buf = ".";
					else if (co % 5 == 2)
						buf = ",";
					else if (co % 5 == 3)
						buf = "!";
					else if (co % 5 == 4)
						buf = "?";
					else
						buf = ' ';
				else if (2 <= num&& num<= 6)
					buf = 'a' + (num - 2) * 3 + (co + 2) % 3;
				else if (num == 7)
					buf = 'p' + (co + 3) % 4;
				else if (num == 8) 
					buf = 't' + (co + 2) % 3;
				else {
					buf = 'w' + (co + 3) % 4;
				}
				s = s + buf;
				co = 0;
				num = 0;

			}
			else {
				num = (r[i] - '0');
				co++;
			}
			cout << s << endl;
	}

	return 0;

}

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

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

    vector<ll> Num(N); 
    vector<ll> ans;
    for(int i = 0; i < N; i++) {
        cin >> Num[i];
    }

    for(int i = 0; i < N; i++){
        for(int j = Num.size() - 1; j >= 0; j--){
            if(Num[j] == j + 1){
            Num.erase(Num.begin() + j);
            ans.push_back(j + 1);
            break;
            }
        }
    }

    if(Num.size() != 0){
        ans.clear();
        ans.push_back(-1);
    }
    reverse(ans.begin(), ans.end());
    for(ll x : ans) cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
from itertools import combinations
input = sys.stdin.readline

n,m,x = map(int,input().split())
c = [list(map(int,input().split())) for _ in range(n)]
ans = float('inf')
for num in range(1,n+1):
    for e in combinations(range(n),num):
        cost = 0
        under = [0 for _ in range(m)]
        for f in e:
            cost += c[f][0]
            for i in range(m):
                under[i] += c[f][i+1]
        if min(under) >= x:
            ans = min(ans,cost)
if ans == float('inf'):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9224
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N = int(readline())
    A = list(map(int, readline().split()))

    lcmnum = 1
    def gcd(a, b):
        if (a == 0):
            return b
        return gcd(b%a, a)

    def lcm(x, y):
        return (x * y) // gcd(x, y)
    for a in A:
        lcmnum = lcm(lcmnum, a)

    ans = 0
    for a in A:
        a = lcmnum // a
        ans += a
    ans %= mod

    print(ans)




if __name__ == '__main__':
    solve()


Measured memory_bytes: 80992
import java.util.*;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		int N=s.nextInt();
		int K=s.nextInt();
		int X=s.nextInt();
		int Y=s.nextInt();
		int i=0;
		int all=0;
		
		if(K<N){
		for(i=1;i<=K;i++){
			all+=X;
		}
		for(i=K+1;i<=N;i++){
			all+=Y;
		}
	}else{
		for(i=0;i<N;i++){
			all+=X;
		}
	}

		System.out.print(all);
	}

}

Measured memory_bytes: 23124
import sys
import numpy as np
from numba import jit, njit
input = lambda: sys.stdin.buffer.readline().rstrip()

@njit(cache=True)
def main(n,m,k,a,b):
  sa = np.cumsum(a)
  sb = np.cumsum(b)
  rx = 0
  rb = m
  for ra in range(0,n+1): 
    while (sb[rb] + sa[ra]) > k and rb>0 :
      rb-=1
    if (sb[rb] + sa[ra]) <= k:
      rx = max(rx,ra+rb)
  return(rx)

n,m,k = map(int, input().split())
a = np.array([0]+list(map(int, input().split())))
b = np.array([0]+list(map(int, input().split())))
print(main(n,m,k,a,b))

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

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

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  Int n,m,k;
  while(cin>>n>>m>>k,n){
    using D = double;
    const Int ofs = m+10;
    
    const D INF = 1e15;
    vector<D> as(k+ofs,-INF),bs(k+ofs,-INF),cs(k+ofs,-INF);
    vector<D> fs(k+ofs,0),ds(k+ofs,0);
    for(Int i=0;i<n;i++){
      Int x,l,f,d,ud;
      cin>>x>>l>>f>>d>>ud;
      if(ud) swap(f,d),bs[x]=0;
      fs[x]=(D)l/f;
      ds[x]=(D)l/d;      
    }
    vector<D> vs(m);
    for(Int i=0;i<m;i++) cin>>vs[i];

    for(Int i=0;i<m;i++){
      D t=(D)i/vs[i];
      for(Int j=1;j+1<k+ofs;j++){       
        t+=(D)1/vs[i];
        // wait prev ship
        chmax(t,as[j+1]);
        as[j]=t;

        // wait gate down
        chmax(t,bs[j]+ds[j]);
        
        // wait gate up
        t+=fs[j];
        bs[j]=t;

        // wait prev ship
        chmax(t,cs[j+1]);
        cs[j]=t;

        //cout<<i<<" "<<j<<":"<<as[j]<<" "<<bs[j]<<" "<<cs[j]<<endl;
      }      
    }
    cout<<fixed<<setprecision(12)<<as[k]<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 3312
def solve(b, n):
	a = [10**10 for _ in range(n)]

	for i in range(n-1):
		a[i] = min(a[i], b[i])
		a[i+1] = min(a[i+1],b[i])

	return sum(a)

def main():
	n = int(input())

	b = list(map(int,input().strip().split()))

	print (solve(b,n))

if __name__ == "__main__":
	main()

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
long long int max_p(int w[],int v[],int n,int W){
    long long int dp[n+1][W+1];
    for(int i=0;i<n+1;i++){
        for(int j=0;j<W+1;j++){
            if(i==0 || j==0) dp[i][j]=0;
            else if(j-w[i-1] >=0){
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
            } 
            else {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    return dp[n][W];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,w;
    cin>>n>>w;
    int we[n],va[n];
    for(int i=0;i<n;i++) cin>>we[i]>>va[i];
    cout<<max_p(we,va,n,w);
	return 0;
}

Measured memory_bytes: 82320
#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){
    ll n;
    cin>>n;
    vector<ll>a(n),b(n),c(n);
    rep(0,i,n)cin>>a[i];
    rep(0,i,n)cin>>b[i];
    rep(0,i,n)cin>>c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll ans=0;
    rep(0,i,(ll)b.size()){
        auto l=lower_bound(a.begin(),a.end(),b[i]);
        auto r=upper_bound(c.begin(),c.end(),b[i]);
        ans+=(l-a.begin())*(c.end()-r);
    }
    cout<<ans;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define ff first
#define ss second
typedef pair<int,int> pii;

int32_t main()
{
	int x , n ;
	cin >> x >> n ;

	int a[500] ;
	memset(a , 0 , sizeof(a)) ;

	if(n == 0)
		return cout << x , 0 ;

	for(int i = 0 ; i < n ; i++){
		int y ;
		cin >> y ;
		a[y]++ ;
	}

	int diff = INT_MAX , ans ; 

	for(int val = 0 ; val < 200 ; val++){
		if(!a[val] && abs(val - x) < diff){
			diff = abs(val - x) ;
			ans = val ;
		}
		else if(!a[val] && abs(val - x) == diff && ans > val)
			ans = val ;
	} 

	cout << ans ;
	return 0;
}        

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> v;
    int x; //0より大の最小値の添字
    int tmp = 9;
    rep(i, 5){
        int t; cin>>t;
        v.push_back(t);
        int u = t%10;
        if(u<tmp && u!=0){
            tmp = u;
            x=i;
        }
    }
    int ans=0;
    rep(i, 5) {
        if(i!=x){
           ans += (v[i]+9)/10*10;
        }
    }
    ans += v[x];
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    int ans=64;
    while(ans>N){
        ans/=2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fr(i,s,e) for(i=s;i<e;i++)
typedef long long ll;
int main() {
	string s;
	ll i,n;
	cin>>s;
	n=s.length();
	if(s[n-1]=='s')
	{
		cout<<s<<"es";
	}
	else
	{
		
	
			cout<<s<<"s";
		
	}
	return 0;
}

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

int main(void){
    double a, b, h, m, x;
    cin >> a >> b >> h >> m;
    double theta = abs((60.0*h+m) - 12.0*m)/(60.0*12.0) * 2.0 * M_PI;
    double ans = sqrt(a*a + b*b - 2*a*b*cos(theta));
    printf("%.15f\n", ans);
    return 0;
}

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

#define ALL(a)  a.begin(),a.end()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define debug(x) cerr << #x << ": " << x << endl

using LL = long long; template<class T> using V = vector<T>;

/*-----------------------------------------------
グラフのトポロジカルソートを行う。
topological_sort : グラフに対してトポロジカルソートを行い、各順序に対する頂点を返す
is_tps_graph_unique : その順序がuniqueかを判定する
-----------------------------------------------*/

vector<int> f(const vector<vector<int>> &g) {
	int n = SZ(g), k = 0;
	vector<int> ord(n, 0), in(n, 0);
	FOR(i, 0, SZ(g)) {
		FOR(j, 0, SZ(g[i])) {
			in[g[i][j]]++;
		}
	}
	queue<int> q;
	FOR(i, 0, n) {
		if (in[i] == 0) q.push(i);
	}
	while (q.size()) {
		int v = q.front(); q.pop();
		ord[k++] = v;
		FOR(i, 0, SZ(g[v])) {
			if (--in[g[v][i]] == 0) q.push(g[v][i]);
		}
	}
	return *max_element(in.begin(), in.end()) == 0 ? ord : vector<int>();
}

bool f2(const vector<int> &ord, const vector<vector<int>>&g) {
	int not_uniq = 0; int n = SZ(g);
	FOR(i,0, n - 1) {
		int i_to_nxi = 0;
		FOR(j, 0, SZ(g[ord[i]])) {
			if (g[ord[i]][j] == ord[i + 1])i_to_nxi = 1;
		}
		if (i_to_nxi == 0) { not_uniq = 1; }
	}
	return not_uniq;
}


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

	int N, E; cin >> N >> E;
	V<V<int>>G(N);
	FOR(i, 0, E) {
		int a, b; cin >> a >> b; a--, b--;
		G[a].push_back(b);
	}
	auto dagv = f(G);
	FOR(i, 0, N) {
		cout << dagv[i]+1 << endl;
	}
	cout << f2(dagv, G) << endl;
	return 0;
}


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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int dur = h2 * 60 + m2 - (h1 * 60 + m1) - k;
  cout << dur << "\n";
  return 0;
}


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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll N, M;
    cin >> N >> M;
    ll A[N];
    for(int i = 0; i < N; i++)
        cin >> A[i];
    sort(A, A + N);
    ll low = -1, high = INF;
    while(high - low > 1) {
        ll mid = (high + low) / 2;
        ll cnt = 0;
        for(int i = 0; i < N; i++) {
            ll idx = lower_bound(A, A + N, mid - A[i]) - A;
            cnt += N - idx;
        }
        if(cnt < M) {
            high = mid;
        } else {
            low = mid;
        }
    }
    ll ans = 0;
    ll sum[N + 1] = {};
    for(int i = 0; i < N; i++) {
        sum[i + 1] = sum[i] + A[i];
    }
    for(int i = 0; i < N; i++) {
        ll idx = lower_bound(A, A + N, high - A[i]) - A;
        ll cnt = N - idx;
        ans += cnt * A[i] + (sum[N] - sum[idx]);
        M -= cnt;
    }
    ans += M * low;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll A, B, C, D; cin >> A >> B >> C >> D;
  if (A+B == C+D) {
    cout << "Balanced" << endl;
  } else if (A+B > C+D) {
    cout << "Left" << endl;
  } else if (A+B < C+D) {
    cout << "Right" << endl;
  }
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

class Main{

	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();

		if((0 <= x-r) && (x+r <= W) && (0 <= y-r) && (y+r <= H)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 26404
def sum_digits(n)
  n = n.to_s
  sum = 0
  0.upto(n.size-1) do |i|
    sum += n[i].to_i
  end
  return sum
end
sum = 0
n, a, b = gets.chomp.split(" ").map(&:to_i)
1.upto(n) do |num|
  s = sum_digits(num)
  if a <= s && s <= b
    sum += num
  end
end
puts sum

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< int , ll > P;

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

int w,h;

ll getHash(vector<int> &v){
  ll res=0;
  for(int i=0;i<9;i++){
    res=res*10LL+(ll)v[i];
  }
  return res;
}

vector<int> change(ll n){
  vector<int> res(9);
  for(int i=8;i>=0;i--){
    res[i]=n%10;
    n/=10;
  }
  return res;
}

int solve(vector<int> si,vector<int> ti){
  map< ll , int > d;
  priority_queue< P , vector< P > , greater< P > > Q;
  d[getHash(si)]=0;
  Q.push(P(0,getHash(si)));
  
  while(!Q.empty()){
    int cost=Q.top().first;
    ll key=Q.top().second;
    vector<int> p=change(key);
    Q.pop();
    if(cost > d[key])continue;
    if(p==ti)return cost;
    
    int py,px;
    for(int i=0;i<9;i++)if(p[i]==0)py=i/3,px=i%3;
    
    for(int i=0;i<4;i++){
      int ny=py+dy[i];
      int nx=px+dx[i];
      int ncost=cost+(i%2==0?h:w);
      
      if(ny<0)ny=2;
      if(nx<0)nx=2,ny=(ny+2)%3;
      if(ny>2)ny=0;
      if(nx>2)nx=0,ny=(ny+1)%3;
      
      swap(p[py*3+px],p[ny*3+nx]);
      ll nkey=getHash(p);
      if(d.count(nkey)==0||d[nkey]>ncost){
        d[nkey]=ncost;
        Q.push(P(ncost,nkey));
      }
      swap(p[py*3+px],p[ny*3+nx]);
    }
  }
  return -1;
}

int main(){
  while(1){
    cin>>w>>h;
    if(w==0&&h==0)break;
    vector<int> t(9),u(9);
    for(int i=0;i<9;i++)cin>>t[i];
    for(int i=0;i<9;i++)cin>>u[i];
    cout<<solve(t,u)<<endl;
  }
  return 0;
}

Measured memory_bytes: 25868
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REPR(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define FOR(i, x, n) for (int i = x; i < (int)(n); ++i)
#define ALL(n) begin(n), end(n)
#define ll long long
#define INF 1e9
int main() {
    string s;
    cin >> s;
    int count = 0;
    REP(i, 3) {
        if (s[i] == 'R') count++;
    }
    if (s[0] == 'R' && s[1] == 'S' && s[2] == 'R') count = 1;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3620
import sys
from collections import Counter
def input(): return sys.stdin.readline().rstrip()
 
 
def main():
    H,W,m=map(int, input().split())
    Hline=[]
    wline=[]
    blist=dict()
    for k in range(m):
        h,w=map(int, input().split())
        Hline.append(h)
        wline.append(w)
        blist[h*(W+2)+w]=0
    hc=Counter(Hline).most_common()
    wc=Counter(wline).most_common()
    ans=hc[0][1]+wc[0][1]
    hl=[]
    wl=[]
    for hcc in hc:
        if hcc[1]!= hc[0][1]:
            break
        hl.append(hcc[0])
    for wcc in wc:
        if wcc[1]!= wc[0][1]:
            break
        wl.append(wcc[0])
    for hll in hl:
        for wll in wl:
            if hll*(W+2)+wll not in blist:
                print(ans)
                exit()
    print(ans-1)
 
    
        
 
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 119080
X = int(input())

if X >=400 and X<600:
    print(8)
elif  X<800:
    print(7)
elif  X<1000:
    print(6)
elif  X<1200:
    print(5)
elif  X<1400:
    print(4)
elif  X<1600:
    print(3)
elif  X<1800:
    print(2)
elif  X<2000:
    print(1)

Measured memory_bytes: 9120
N = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

ans = 0
for i in range(N):
  x = a[i]
  x = x-1
  ans += b[x]
  if i<N-1:
    if a[i]+1 == a[i+1]:
      ans += c[x]
print(ans)

Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
#define MAXN 100000
#define LL long long
#define MOD 
#define Pr pair<int,int>
#define X first
#define Y second
int n,sum;
int a[MAXN+5],cnt[MAXN+5];
map<int,int> D;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{scanf("%d",&a[i]);sum^=a[i];}
	if(!sum)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 640
import numpy as np
h,w,k=list(map(int,input().split()))

ans=np.zeros([h,w])
count=[]
area_num=1


for i in range(h): 
  tmp=input()
  tmp_count=0
  for j in range(w):
    if tmp[j] == "#":
      ans[i][j] = area_num
      area_num += 1
      tmp_count += 1
    elif j != 0 and tmp[j-1] != 0:
      k = ans[i][j-1]
      ans[i][j] = k
  count.append(tmp_count)
    
for i in range(h):
  if count[i] == 0:
    if i == 0:
      have_num = 0
      while count[have_num] == 0:
        have_num += 1
      t = ans[have_num]
      ans[i] = t
    else:
      t = ans[i-1]
      ans[i] = t

for i in range(h): 
  for j in range(w):
    if ans[i][w-1-j] == 0:
      k = ans[i][w-j] 
      ans[i][w-j-1] = k      
      
for i in range(h):
  for j in range(w):
   	print(int(ans[i][j]),end=" ")
  print("")

Measured memory_bytes: 15528
import scala.io.StdIn

object Main {
  
  def main(args: Array[String]): Unit = {
    val n = StdIn.readLine().toInt
    val hs = StdIn.readLine().split(' ').toList.map(_.toInt)
    val ans = hs.foldLeft(Some(0): Option[Int]){ (acc, h) =>
      acc.flatMap{ pre =>
        if (h - 1 >= pre) Some(h - 1)
        else if (h >= pre) Some(h)
        else None
      }
    }.isDefined
    println(if(ans) "Yes" else "No")
  }
  
}


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

int main() {
	int a, b; cin >> a >> b;
	if (a <= 5) {
		cout << 0 << endl;
	}
	else if (a <= 12) {
		cout << b / 2 << endl;
	}
	else {
		cout << b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main(){

    int N, K;
    cin >> N >> K;
    
    vector<int> v(N);
    for(int i = 0; i < N; i++) cin >> v[i];

    sort(v.rbegin(), v.rend() );

    int sum = 0;
    for(int i = 0; i < K; i++) sum += v[i];
    cout << sum << endl;

}

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

int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  
  sort(a, a + n);
  int alice = 0, bob = 0;
  for (int i = n-1; 0 <= i; i--) {
    if (i % 2 == 0) alice += a[i];
    else bob += a[i];
  }
  
  cout << abs(alice - bob) << endl;
}

Measured memory_bytes: 256
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
ll a[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    cin>>t>>n;
    ll sum=0;
    Ff(i,0,n) cin>>a[i],sum+=a[i];
    if(sum>t)
    cout<<"-1";
    else
    {
        cout<<t-sum;
    }
    
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10724
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//




int main() {

    int N; cin >> N;
    vector <int> d(N);
    rep(i,N) cin >> d[i];
    Sort(d);
    int ans = d[N/2] - d[N/2-1];
    out(ans);

    return 0;
}










Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<set>
using namespace std;
typedef long long ll;
vector<int> a1[100004];
vector<int> a2[100004];
int par[100004],ank[100004];
void init(int n)
{
	for(int i=1;i<=n;i++)
	{
		par[i]=i;
		ank[i]=1;
	}
}
int find(int x)
{
	if(par[x]==x)
	{
		return x;
	}
	else
	{
		return par[x]=find(par[x]);
	}
}
void unite(int x,int y)
{
	x=find(x);
	y=find(y);
	if(x==y)
	{
		return;
	}
	if(ank[x]>ank[y])
	{
		par[y]=x;
		ank[x]+=ank[y];
	}
	else
	{
		par[x]=y;
		ank[y]+=ank[x];
	}
}
int main()
{
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	init(n);
	for(int i=0;i<m;i++)
	{
		int a11,b1;
		scanf("%d%d",&a11,&b1);
		a1[a11].push_back(b1);
		a1[b1].push_back(a11);
		unite(a11,b1);
	}
	for(int i=0;i<k;i++)
	{
		int c1,d1;
		scanf("%d%d",&c1,&d1);
		a2[c1].push_back(d1);
		a2[d1].push_back(c1);
	}
	for(int i=1;i<=n;i++)
	{
		int ans=ank[find(i)]-a1[i].size();
		for(int j=0;j<a2[i].size();j++)
		{
			if(find(a2[i][j])==find(i))
			{
				ans--;
			}
		}
		printf("%d ",ans-1);
	}
} 

Measured memory_bytes: 12536
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main()
{
    long long a, b, c, d, e, f;
    scanf("%lld", &a);
    /*if (a>b)
{
    e=a;
    a=b;
    b=e;
}
if (c>d)
{
    e=c;
    c=d;
    d=e;
}

//if (c%2==0)
printf("%lld",a+c);
//else*/
    printf("%lld", a / 3);
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007

ll ans=1<<30;
string s;
void cal(bool w,int d,ll sum){
	if(d==s.size()){
		ans=min(ans,sum);
		return;
	}
	if(w){
		if(s[d]=='0'){
			sum++;
		}
		cal(false,d+1,sum);
	}
	else{
		if(s[d]!='0'){
			sum++;
		}
		cal(true,d+1,sum);
	}
}

int main() {
	cin>>s;
	cal(true,0,0);cal(false,0,0);
	cout <<ans;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long

int main(){
	char a[11], b[11], c[11];
	int an, bn;

	scanf("%s %s %s",a,b,c);

	an = strlen(a);
	bn = strlen(b);

	if(a[an-1] == b[0] && b[bn-1] == c[0])
		printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin >> s;
  int N = s.size();

  if(N < 26){
    //cout << "aaa" << endl;
    bool used[26];
    fill(used,used+26,false);
    for(int i=0;i<N;i++){
      used[(int)(s[i] - 'a')] = true;
    }
    cout << s;
    for(int i=0;i<26;i++){
      if(!used[i]){
        cout << (char)('a' + i) << endl;
        return 0;
      }
    }
  }

  else if(s == "zyxwvutsrqponmlkjihgfedcba"){
    cout << -1 << endl;
  }

  else{
    int ind = 25;
    while(1){
      if(s[ind-1] > s[ind]) ind--;
      else break;
    }
    for(int i=0;i<ind-1;i++){
      cout << s[i];
    }

    char x = s[ind - 1];
    while(1){
      if(s[ind + 1] > x) ind++;
      else break;
    }

    cout << s[ind] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	
	int a=in();int b=in();int x=in();
	a=(a+x-1)/x;a*=x;
	b/=x;b*=x;
	//cout<<a<<" "<<b<<"\n";
	int ans=max(0LL, (b/x-a/x)+1);
	cout<<ans;
}

Measured memory_bytes: 3744
use proconio::*;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
use std::*;

#[allow(dead_code)]
const MOD: i128 = 100_000_007;

#[fastout]
fn main() {
    input!{
        x : usize,
        mut num_list : [i128;x]
    };
    num_list.sort();
    let mut ans = 1;
    for num in num_list.iter() {
        ans *= *num;
        if ans > 1_000_000_000_000_000_000 {
            println!("{}",-1);
            return ;
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 6156
#include <iostream>
using namespace std;
#define MAX_H 50
#define MAX_W 50
int H,W;
int k=0;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
char field[MAX_H][MAX_W];
void dfs(int x,int y){
    field[x][y]='.';
    k++;
    for (int i=0;i<4;i++){
        int nx=x+dx[i];
        int ny=y+dy[i];
        if (0<=nx && nx<H && 0<=ny && ny<W){
            if (field[nx][ny]=='#'){
                dfs(nx,ny);
            }
        }
    }
    return ;
}
int main(void){
    cin >> H >> W;
    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            cin >> field[i][j];
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if (field[i][j]=='#'){
                k=0;
                dfs(i,j);
                if (k==1){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes"<< endl;
    return 0;
}


Measured memory_bytes: 256
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<"\n";
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()           
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   N     =  1e6+5;
const ll   mod   =  1e9;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, n, m, p[N], sz[N];

void make(ll n){
	for(int i = 1; i <= n; i++){
		p[i] = i;
		sz[i] = 1;
	}
}

int find(ll x){
	return (p[x] == x)? x: p[x] = find(p[x]);
}

void merge(ll x, ll y){
	ll a = find(x);
	ll b = find(y);
	if(a != b){
		if(sz[a] >= sz[b]) swap(a,b);
		p[a] = b;
		sz[b] += sz[a];
	}
}

void solve(){
	cin >> n >> m;
	make(n);
	for(int i = 1; i <= m; i++){
		int u, v, z; cin >> u >> v >> z;
		merge(u,v);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(find(i) == i) ans++;
	}
	deb1(ans)
}

int main(){
	GODSPEED;
	//cin>>test;
	for(int i = 1; i <= test; i++){
		solve();
	}
	#ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}

Measured memory_bytes: 5204
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.nextLine();
		String[] a = x.split(" ");
		int[] b = new int[a.length];
		for (int i = 0; i < b.length; i++) {
			b[i] = Integer.parseInt(a[i]);

		}
		System.out.println((b[0] * b[1]) + " " + (2 * b[0] + 2 * b[1]));
	}
}

Measured memory_bytes: 25988
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ss second
#define ff first
#define INF 3000000000000001
#define ll_max 9000000000000000001
#define mod 1000000007
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 100001;
const ll M = 1;

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m = 0, x = 0, y = 0, k, W, H;
        cin >> n >> m;
        n = (n + m - 1) / m;
        cout << n << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) {
    cout << "Possible" << endl;
  } else {
	cout << "Impossible" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
// Practice AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let a = get!() + get!() + get!();
    if a >= 22 {
        println!("bust");
    } else {
        println!("win");
    }
    
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int a, b;
    cin >> a >> b;
    if(a == b) cout << "Draw";
    else if((a > b && b != 1) || a == 1) cout << "Alice";
    else cout << "Bob";
    return 0;
}


Measured memory_bytes: 256
/**
                 MD.Faysal Hasan
                Comilla Univesity               **/

#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<string>
#include <stdlib.h>
using namespace std;

#define         rep(i,n)       for ( i=0 ; i<n ; i++ )
#define         rep1(i,n)      for ( i=1 ; i<=n ; i++ )
#define         sajo(str)      sort(str.begin(),str.end())
#define         rev(str)       reverse(str.begin(),str.end())
#define         usajo(str)     sort(str.rbegin(),str.rend())
#define         pi             2*acos(0.0)
#define         nel            printf("\n")
#define         longmx         92233720368547758
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         yes            cout<<"YES"<<"\n"
#define         no             cout<<"NO"<<"\n"
#define         vcl            vector<ll>
#define         pb             push_back
#define         prl            pair< ll , ll >
#define         mkp(x,y)       make_pair(x,y)
#define         ff             first
#define         sc             second
#define         spc            ' '
#define         nn             '\n'
#define         Faysal         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef         long long int  lli;
typedef         long long      ll;

int main(){Faysal

    ll ans,sum,tot,cnt,mx,mn,idx,chk,rem,ret,tmp,mid,lft,rgt,pos;

    ll tc,n,m,a,b,c,d,g,h,l,r,x,y,i,j,k;

    cin>>a>>b;
    if(min(a,b)==1)
    {
        cout<<1<<endl;
        return 0;
    }
    x=(a+1)/2;
    y=a/2;
    i=(b+1)/2;
    cout<<(i*x)+(y*(b/2))<<endl;
    return 0;
}


Measured memory_bytes: 256