akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N, K;
  cin >> N >> K;
  vi H(N);
  cin >> H;
  sort(all(H));
  int ans = 0;
  rep(i, 0, max(0LL, N - K)) ans += H[i];
  cout << ans << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 1920
#include <iostream>

using namespace std;

int main()
{
	long long int n;
	cin>>n;
	long long int ans = 0;
	for(size_t i = 0; i<n; i++)
	{
		if((i+1)%3==0||(i+1)%5==0)
		{

		}
		else
		{
			ans += (i+1);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
function Main(input) {
  input = input.split("\n");
  S= input[0].split("");
  var ans =0
  var n=0
  var w=0
  for(i=0;i<S.length;i++){
    if(S[i]=="W"){
      ans+=i-n;
      n++;
    }
  }
  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

typedef long long ll;

ll MOD = 1000000007;

int main(int, char**) {
	int n;
	cin >> n;
	vector<ll> A, B, C;
	
	for (int i=0; i<n; i++) {
		ll a; cin>>a; A.push_back(a);
	}
	for (int i=0; i<n; i++) {
		ll a; cin>>a; B.push_back(a);
	}
	for (int i=0; i<n; i++) {
		ll a; cin>>a; C.push_back(a);
	}
	
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	ll ans = 0;
	for (int i=0; i<n; i++) {
		ll b = B[i];
		auto aitr = lower_bound(A.begin(), A.end(), b);
		auto citr = upper_bound(C.begin(), C.end(), b);
		ll na = aitr - A.begin();
		ll nc = C.end() - citr;
		ans += na * nc;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,i;
	cin >> n >> i;
	cout << n-i+1 << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 505;
const int mod = 1e9 + 7;
int h,w;
char mp[maxn][maxn];
int main() {
    cin>>h>>w;
    for (int i=0; i<h; i++) {
        cin>>mp[i];
    }
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (j == 0) putchar('.');
            else if (!(i & 1)) putchar('#');
            else if ((i & 1) && j == w-1) putchar('#');
            else if (mp[i][j] == '#') putchar('#');
            else putchar('.');
        }
        puts("");
    }
    puts("");
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (j == w-1) putchar('.');
            else if (i & 1) putchar('#');
            else if (!(i & 1) && j == 0) putchar('#');
            else if (mp[i][j] == '#') putchar('#');
            else putchar('.');
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 1024
#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>;

const int mod = 2019;

int main(){
	ll l,r;
	cin >> l >> r;
	ll ans = 2018;
	ll a = 0;
	r = min(r,l+4039);
	for(ll i = l; i <= r; i++){
		for(ll j = i+1; j <= r; j++){
			a = i%mod*j%mod%mod;
		ans = min(a,ans);
		}
	}
	cout << ans << endl;
}

// cout << fixed << setprecision(15) <<  << endl;

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

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

    int n,c;
    cin >> n >> c;
    vector<vector<int> > d(c,vector<int>(c));
    vector<vector<int> > cmet(n,vector<int>(n));
    for(int i = 0; i < c; i++){
        for(int j = 0; j < c; j++){
            cin >> d[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> cmet[i][j];
        }
    }

    vector<vector<int> > st(3, vector<int>(c, 0));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            int mod = (i+j)%3;
            int color = cmet[i][j]-1;
            st[mod][color]++;
        }
    }

    long long ans = numeric_limits<long long>::max() / 2;
    for(int i = 0; i < c; i++){
        for(int j = 0; j < c; j++){
            for(int k = 0; k < c; k++){
                if(i == j || j == k || i == k) continue;
                long long score = 0;
                for(int from = 0; from < c; from++){
                    score += st[0][from] * d[from][i];
                    score += st[1][from] * d[from][j];
                    score += st[2][from] * d[from][k];
                }
                ans = min(ans, score);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1280
MOD = 10**9 + 7
r1,c1,r2,c2 = map(int,input().split())

n = 2000100
fact = [1]*(n+1)
inv = [1]*(n+1)
ifact = [1]*(n+1)
for i in range(1,n+1):
    fact[i] = fact[i-1]*i % MOD
    inv[i] = pow(i,MOD-2,MOD)
    ifact[i] = ifact[i-1]*inv[i] % MOD

def nCr(n,r):
    return fact[n] * ifact[r] * ifact[n-r] % MOD

def f(r,c):
    return nCr(r+c+2,c+1)-1
    
print((f(r2,c2) - f(r2,c1-1) - f(r1-1,c2) + f(r1-1,c1-1)) % MOD)


Measured memory_bytes: 88824
unittest
{
	assert( [ "4", "10", "8", "8", "6" ].parse.expand.solve == 3 );
	assert( [ "3", "15", "15", "15" ].parse.expand.solve == 1 );
	assert( [ "7", "50", "30", "50", "100", "50", "80", "30" ].parse.expand.solve == 4 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	auto ds = new long[ n ];
	foreach( ref d; ds )
	{
		input.popFront;
		d = input.front.strip.to!( long );
	}
	return tuple( ds );
}

auto solve( long[] ds )
{
	return ds.sort().uniq.walkLength;
}


Measured memory_bytes: 256
// luogu-judger-enable-o2
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
string a,b;
int main(){
	cin>>a;
	b=a;
	reverse(a.begin(),a.end());
	for (register int i=0;i<a.length();++i){
		if (a[i]=='b') a[i]='d';
		else if(a[i]=='d') a[i]='b';
		if(a[i]=='p') a[i]='q';
		else if(a[i]=='q') a[i]='p';
	}
	if (a==b) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <string>

int main() {
  int n, m; std::cin >> n >> m;
  std::string s, t; std::cin >> s >> t;

  long long g = std::__gcd(n, m);
  long long si = n/g;
  long long ti = m/g;

  for (int i = 0; i<g; ++i) {
    if (s[si*i] != t[ti*i]) {
      std::cout << -1 << std::endl;
      return 0;
    }
  }
  std::cout << g*si*ti << std::endl;
  return 0;
}


Measured memory_bytes: 512
import bisect
import copy

def check(a, b, bar):
    sm = 0
    cnt = 0
    n = len(a)
    for x in a:
        i = bisect.bisect_left(a, bar - x)
        if i == n:
            continue

        cnt += n - i
        sm += b[i] + x * (n-i)
        
    return cnt, sm

n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

b = copy.deepcopy(a)
for i,_ in enumerate(b[:-1]):
    b[n-i-2] += b[n-i-1]
    
left = 0
right = b[0] * 2

while right - left > 1:
    middle = ( right + left ) // 2    
    if check(a, b, middle)[0] < m:
        right = middle
    else:
        left = middle
             
print(check(a, b, left)[1] - left * (check(a, b, left)[0]-m) ) 

Measured memory_bytes: 81072
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, M, X;
    cin >> N >> M >> X;

    vector<int> A(M);
    int count_a = 0;
    int count_b = 0;

    for (int i = 0; i < M; i++){
        cin >> A.at(i);

        if (A.at(i) < X ){
            count_a++;
        }
        else if (X < A.at(i)){
            count_b++;
        }
    }
    cout << min(count_a, count_b) << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        String[] s = stdR.readLine().split(" ");
        int N = Integer.parseInt(s[0]);
        int K = Integer.parseInt(s[1]);
        s = stdR.readLine().split(" ");
        int count = 0;
        for(int i = 0 ; i < N ; i++) {
            if(Integer.parseInt(s[i]) >= K)count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 31564
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int a, b; cin >> a >> b;
	int n = b - a;
	cout << n * (n+1) / 2 - b << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>





using namespace std;
int main() {
	double a, b;
	int  c, d;
	cin >> a >> b >> c >> d;
	cout << (double)(a)*(double)(b) / 2 << " ";
	if (c * 2 == a&&d * 2 == b)cout << 1 << endl;
	else cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int W;
	int H;
	int N;
	int answer;
	
	cin >> W >> H >> N;

	int mostLeftPoint = 0;
	int mostRightPoint = W;
	int mostUpperPoint = H;
	int mostUnderPoint = 0;

	int x[N];
	int y[N];
	int a[N];

	for (int i = 0; i < N; i++) {

		cin >> x[i] >> y[i] >> a[i] ;

		if (a[i] == 1) {
			mostLeftPoint = max(mostLeftPoint, x[i]);
		}
		else if (a[i] == 2) {
			mostRightPoint = min(mostRightPoint, x[i]);
		}
		else if (a[i] == 3) {
			mostUnderPoint = max(mostUnderPoint, y[i]);
		}
		else { // a[i] == 4
			mostUpperPoint = min(mostUpperPoint, y[i]);
		}
	}

	answer = max(0, ( mostRightPoint - mostLeftPoint ) ) * max( 0, ( mostUpperPoint - mostUnderPoint ) );

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 100005
#define pb push_back
#define mp make_pair
#define pii pair<long long,long long>
#define read(a) scanf("%d",&a)
#define p1(a) cout<<"Check "<<a<<endl;
#define p2(a,b) cout<<"Check "<<a<<' '<<b<<endl;
#define p3(a,b,c) cout<<"Check "<<a<<' '<<b<<' '<<c<<endl;
#define fo(i,n) for(i=0;i<n;i++)
#define ll long long
#define clr(a) memset(a,0,sizeof(a))
#define MOD 10000000000
#define INF 10000000000000

using namespace std;

int n,cp;
ll cost[MAX];
ll weight[MAX];
ll dp[MAX];


int main()
{
    cin>>n>>cp;
    for(int i=0;i<n;i++){
        scanf("%lld%lld",&weight[i],&cost[i]);
    }
    for(int i=0;i<=MAX;i++) dp[i]=INF;
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=MAX;j>0;j--){
            if(j-cost[i]>=0 && dp[j-cost[i]]!=INF){
                dp[j]=min(dp[j],dp[j-cost[i]]+weight[i]);
            }
        }
    }
    for(int j=MAX;j>=0;j--){
        if(dp[j]<=cp){
            cout<<j<<endl;
            break;
            //break;
        }
    }

    return 0;
}


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

int main(){
        int n,m,i;
        ll tmp,ans = 0;
        cin >> n >> m;
        priority_queue<ll> q;
        for(i=0;i<n;++i){
                cin >> tmp;
                q.push(tmp);
        }
        for(i=0;i<m;++i){
                q.push(q.top()/2);
                q.pop();
        }
        while(!q.empty()){
                ans += q.top();
                q.pop();
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 4228
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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;
}

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}


void solve() {
   int a,b,c;
   cin >> a >> b >> c;
   cout << max(c-(a-b),0) << endl;
}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> h(n), c(n);
	for(int i = 0; i < n; i++) {
		cin >> h[i];
		c[i] = 1000000000;
	}
	c[0] = 0;
	for (int i = 0; i < n-1; i++) {
		for (int j = 1; j <= k && i + j < n; j++){
			c[i+j] = min(c[i+j], c[i] + abs(h[i] - h[i+j]));
		}
	}
	cout << c[n-1] << endl;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<sstream>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define loop(i,a,b) for(i=(int)a;i<(int)b;i++)
#define revloop(i,a,b) for(i=(int)a;i>=(int)b;i--)
#define stloop(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define ll long long int
#define PI acos(-1.0)
#define f first
#define s second
#define rs resize
int main()
{  std::ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   ll n,m;
   cin>>n>>m;
   if(n < m)
     cout<<n + (m-n*2)/4;
   else
     cout<<m/2;
   return 0;
}


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

int main()
{
    double n,ans,minCity;
    vector<double> M(5);
  
    cin >> n >> M[0] >> M[1] >> M[2] >> M[3] >> M[4];
    minCity = *min_element(M.begin(), M.end());
      
    ans = ceil(n/minCity)+4;
    cout << (long long)ans << endl;
    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn._
object Main extends App {

  val n = readInt
  val a = readLine.trim.split(' ').map(_.toLong).sorted
  val max = (for (i ← 0 until (n - 3)) yield {
    Rational(a(n - 1) + a(n - 2), a(i + 1) - a(i))
  }).max
  val res = List(makeByFour(a.takeRight(4)), max).max.let{case Rational(num, den) ⇒ num.toDouble / den}
  println(
    f"$res%15f"
  )

  def makeByFour(nums: Seq[Long]): Rational = {
    nums.permutations.map{a ⇒
      Rational(a(0) + a(1), math.abs(a(2) - a(3)))
    }.max
  }

  case class Rational(num: Long, den: Long) extends Ordered[Rational] {
    override def compare(that: Rational): Int = (num * that.den).compare(den * that.num)
  }

  implicit class Extension[T](val value: T) extends AnyVal {
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }
}



Measured memory_bytes: 44952
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let O = readLine()!.toArray()
let E = readLine()!.toArray() + [""]
for i in 0..<O.count {
    print(O[i]+E[i], terminator: "")
}


Measured memory_bytes: 1408
// Problem : A - Registration
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define ll long long
#define endl "\n"
#define lb "lower_bound"
#define ub "upper_bound"
#define bs "binary_search"

int dif(int a,int b){if(a > b)return a - b;else return b - a;}
int min(int a,int b){if(a > b)return b;else return a;}
int max(int a,int b){if(a > b)return a;else return b;}
int gcd(int a, int b){if(b == 0)return a;return gcd(b, a%b);}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    string a,b;
    cin>>a>>b;
    ll c = a.length(),d = b.length();
    ll i  = 0;
    while(a[i] != '\0')
    {
    	if(a[i] != b[i])
    	{
    		cout<<"No";
    		return 0;
    	}
    	i++;
    }
    if(d - c == 1)
    cout<<"Yes";
    else cout<<"No";
	return 0;
}


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353
#define Graph vector<vector<int>>

int main() {
    int N, M, X; cin >> N >> M >> X;
    set<int> A;
    for (int i = 0; i < M; i++) {
        int a; cin >> a;
        A.insert(a);
    }
    int left = 0, right = 0;
    for (int i = X; i <= N; i++) {
        if (A.count(i)) right++;
    }
    for (int i = X; i >= 0; i--) {
        if (A.count(i)) left++;
    }
    cout << min(left, right) << endl;
}

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

main(){

ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

long long i,j,k,l,m,n;

while(cin>>l){

    char s[l];
    cin>>s;

    k=0;
    for(i=0;i<l;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')k++;
    }
    cout<<k<<endl;

}

 return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main() {
    int h,w,n;
    cin>>h>>w>>n;
    if(h<w)h=w;
    cout<<(n+h-1)/h<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
 
int main() {
  int n,i;
  int a[101];

  cin >> n;

  for(i=0;i<n;i++){
    cin >> a[i];
  }
  
  cout << a[n-1];
  for(i=1;i<n;i++){
    cout << " " << a[n-1-i];
  }
  cout << endl;

  return 0;
}



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

int main() {
  int a,b;
  cin >> a >> b;
  int ans;
  if(a>=b){
    ans +=a;
    a--;
  }else{
    ans += b;
    b--;
  }
  cout << ans+max(a,b) << endl;
}

Measured memory_bytes: 256
let () =
  Scanf.scanf "%d %d %d\n" @@ fun a b m ->
  let arr = Array.init a @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  let brr = Array.init b @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  let crr = Array.init m @@ fun i -> Scanf.scanf "%d %d %d\n" @@
    fun x y c -> arr.(x-1) + brr.(y-1) - c in
  let ans1 =
    (Array.fold_left min arr.(0) arr) + (Array.fold_left min brr.(0) brr) in
  let ans2 = Array.fold_left min crr.(0) crr in
  Printf.printf "%d\n" (min ans1 ans2)

Measured memory_bytes: 6400
#include <iostream>
#include <fstream>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <forward_list>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <bitset>
#include <memory>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdint>
#include <iomanip>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <utility>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
string s,t;
bool solve() {
    if(s.length() != t.length())return false;
    for(int i = 1;i <= s.length();i++) {
        if(s.substr(0,i) == t.substr(s.length()-i,i) &&
s.substr(i,s.length()-i) == t.substr(0,t.length()-i))return true;
}
    return false;
}
int main(void) {
    cin >> s;
    cin >> t;
    if(solve())
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ << ' ' <<
#define squ(x)  ((x) * (x))
#define VAR_NAME(var)  cout << #var << " : ";
#define debug(var)  VAR_NAME(var); view(var);
#define max(v)  *max_element(v.begin(), v.end())
#define min(v)  *min_element(v.begin(), v.end())
#define sort(var)  std::sort(var.begin(), var.end());
#define rsort(var)  std::sort(var.begin(), var.end(), std::greater<>());
using namespace std;
using ll = long long;
int gcd(int m, int n){return !n ? m : gcd(n, m%n);}
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;
template<typename T> void view(const T e){ std::cout << e << std::endl;}
template<typename T> void view(const vector<T>& v){ for(const auto& e : v) std::cout << e << " "; std::cout << std::endl; }
template<typename T> void view(const VV<T>& vv){ for(const auto& v : vv){ view(v); } }

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(auto& e : a) cin >> e;
  double inv_sums = 0;
  for(const auto& e : a) inv_sums += (1.0 / e);
  cout << 1.0/inv_sums << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <boost/multi_array.hpp>

int main() {
    int a, b, c;
    
    std::cin >> a >> b;
    c = std::max(a+b, a-b);
    c = std::max(c, a*b);
    
    std::cout << c << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define s(a,b) a^=b^=a^=b
void ans(a,b,c){
	printf("%3$d %2$d %1$d\n",a,b,c);
}
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a<b)
	s(a,b);
	if(b<c)
	s(b,c);
	if(a<c)
	s(a,c);
	if(a<b)
	s(a,b);
	ans(a,b,c);
}

Measured memory_bytes: 1776
import itertools
n,m=map(int,input().split())
data=[[] for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    data[a].append(b)
    data[b].append(a)
z=[i+2 for i in range(n-1)]
ans=0
for u in itertools.permutations(z):
    if u[0] in data[1]:
        for i in range(1,n-1):
            if u[i] in data[u[i-1]]:
                continue
            else:
                break
        else:
            ans+=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <map>
using namespace std;
#define mod 1000000007
#define ll long long
int main () {
  int H, W, K;
  cin >> H >> W >> K;
  // 位置Hの時にKにいる場合の数
  ll dp[H][W];
  for (ll i = 0; i < H; i++) {
    for (ll j = 0; j < W; j++) {
      dp[i][j] = 0;  
    }  
  }
  // map<x, y> x本横に並べてあった時に、yの数の横棒が引けるという意味、ただしあとで掛け算するので場合の数が0となるものは1にしておく
  map<ll, ll> ww;
  ww[-1] = 1;
  ww[9] = 1;
  ww[-2] = 1;
  ww[8] = 1;
  ww[0] = 1;
  ww[1] = 1;
  ww[2] = 2;
  ww[3] = 3;
  ww[4] = 5;
  ww[5] = 8;
  ww[6] = 13;
  ww[7] = 21; 
  for (ll i = 0; i < H; i++) {
    for (ll j = 0; j < W; j++) {
      if (i == 0) {
        if (j == 0) {
          dp[i][j] = 1 * ww[W - 1] ;  
        }  
        else {
          if (j == 1) {
            dp[i][j] = 1 * ww[W - 2];  
          }
          else {
            dp[i][j] = 0;
          }  
        }
      }  
      else {
        dp[i][j] = dp[i - 1][j] * ww[W - j - 1] * ww[j] % mod;
        if (j > 0) {
          dp[i][j] += dp[i - 1][j - 1] * ww[W - j - 1] * ww[j - 1] % mod;  
        }   
        if (j < W - 1) {
          dp[i][j] += dp[i - 1][j + 1] * ww[W - j - 2] * ww[j] % mod;  
        }
      }
    }  
  }
  cout << dp[H - 1][K - 1] % mod << endl;

  
}

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

int main(){
    int n, i, ans=0, tmp = 0;
    cin >> n;
    vector<int> v(n);
    for (i=0; i<n; i++) {
        cin >>v[i];
    }
    
    for (i=0; i < n-1; i++) {
        if (v[i] >= v[i+1]) {
            tmp++;
            if (ans < tmp) {
                ans = tmp;
            }
        } else {
            tmp = 0;
        }
    }
    cout << ans;
    return 0;
}

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

using vi = vector<int>;
#define f(i,a,b) for (int i = a; i < b; i++)
#define pb push_back

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n,m; cin>>n>>m;
	vi adj[n];
	bool vis[n];
	f(i,0,m) {
		int a,b; cin>>a>>b;
		adj[--a].pb(--b); adj[b].pb(a);
	}
	f(i,0,n) vis[i] = 0;
	deque<int> dq;	
	f(i,0,n) if (!dq.size() && adj[i].size()) {
		dq.pb(i);	
		vis[i] = 1;
	}
	while (1) {
		int v = dq.back();
		bool found = 0;
		for (int w : adj[v]) if (!found && !vis[w]) {
			vis[w] = 1;
			dq.pb(w);
			found = 1;
		}
		if (!found) break;
	}
	while (1) {
		int v = dq.front();
		bool found = 0;
		for (int w : adj[v]) if (!found && !vis[w]) {
			vis[w] = 1;
			dq.push_front(w);
			found = 1;
		}
		if (!found) break;
	}
	stringstream ss;
	ss << dq.size() << endl;
	for (int v : dq) ss << v+1 << " ";
	cout << ss.str() << endl;

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



Measured memory_bytes: 8068
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;vector<int>a(n);
  for(int x=1;x<100;x++){
    for(int y=1;y<100;y++){
      for(int z=1;z<100;z++){
        int s=(x+y)*(x+y)+(y+z)*(y+z)+(z+x)*(z+x);
        if(s%2==0 && s/2>0 && s/2<n+1){
          a[s/2-1]++;
        }
      }
    }
  }
  for(int i=1;i<=n;i++){
    cout<<a[i-1]<<endl;
  }

}


Measured memory_bytes: 3600
#include<stdio.h>
#include<stdlib.h>
#define MAX 100005
#define NIL -1

struct Node {int p, l, r; };

struct Node T[MAX];
int n, D[MAX];

void print(int u){
  int i, c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if(T[u].p == NIL){
    printf("root, ");
  }
  else if(T[u].l == NIL){
    printf("leaf, ");
  }
  else{
    printf("internal node, ");
  }

  printf("[");

  for(i = 0, c = T[u].l ; c != NIL ; i++, c = T[c].r){
    if(i){
      printf(", ");
    }
    printf("%d",c);
  }

    printf("]\n");
}

int rec(int u, int p){
  D[u] = p;
  if(T[u].r != NIL){
    rec(T[u].r, p);
  }
  if(T[u].l != NIL){
    rec(T[u].l, p + 1);
  }
}

int main(){
  
  int i, j, d, v, c, l, r;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    T[i].p = T[i].l =T[i].r = NIL;
  }

  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&v,&d);
    for(j = 0 ; j < d ; j++){
      scanf("%d",&c);
      if(j == 0){
	T[v].l = c;
      }
      else{
	T[l].r = c;
      }
      l = c;
      T[c].p = v;
    }
  }

  for(i = 0 ; i < n ; i++){
    if(T[i].p == NIL){
      r = i;
    }
  }

  rec(r, 0);

  for(i = 0 ; i < n ; i++){
    print(i);
  }
  return 0;
}

Measured memory_bytes: 5300
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (ll i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
struct edge {int to,cost;};
#define VMAX 51
//typedef std::pair<int,int> P;

    ll N,A[100010];
    ll ans;

int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N)cin>>A[i];
    sort(A,A+N);
    ll buff=A[0],cnt=0;
    REP(i,N){
        if(buff==A[i])cnt++;
        if(buff!=A[i]){
            DEB(cnt)DEB(buff)END
            if(cnt!=buff){
                if(buff<cnt)ans+=cnt-buff;
                else ans+=cnt;
            }
            cnt=1;
            buff=A[i];
        }
    }
        if(cnt!=buff){
            if(buff<cnt)ans+=cnt-buff;
            else ans+=cnt;
        }

    cout<<ans<<endl;
    return 0;
}

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

int main()
{
	int N, K,A[100000];

	cin >> N >> K;
	
	for (int i = 0; i < N; i++) {
		scanf("%d",&A[i]);
	}

	sort(A, A + N);

	int ans = 1,o=0;
	for (;;ans++) {
		for (int i = o,k=0; i < N; i++) {
			if (A[i] != 1) {
				A[i] = 1;
				k++;
				o = i;
			}
			if (k == K-1)break;
		}
		if (A[N - 1] == 1)break;
	}

	cout << ans << endl;

	return 0;
}

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

#define N 200001
#define INF 2e9

int seg[N*4][2],in[N],ind[N],lazy[N*4];
void init(int pos,int l,int r) {
    lazy[pos] = 1;
    if(l==r) {
        seg[pos][0] = seg[pos][1] = INF;
        seg[pos][l&1] = in[l];
        return;
    }
    int mid = (l+r)/2;
    init(pos*2,l,mid);
    init(pos*2+1,mid+1,r);
    seg[pos][0] = min(seg[pos*2][0],seg[pos*2+1][0]);
    seg[pos][1] = min(seg[pos*2][1],seg[pos*2+1][1]);
}
int query(int pos,int l,int r,int ql,int qr,int bit) {
    if(qr<l || r<ql) {
        return INF;
    }
    if(ql<=l&& r<=qr) {
        return seg[pos][bit];
    }
    int mid = (l+r)/2;
    return min(query(pos*2,l,mid,ql,qr,bit),query(pos*2+1,mid+1,r,ql,qr,bit));
}
struct node {
    int l,r,val;
    node(int l_,int r_,int n) {
        l = l_,r = r_;
        val = query(1,1,n,l,r,l&1);
    }
    friend bool operator<(node x,node y) {
        return x.val>y.val;
    }
};
int ret[N];
void solve() {
    //input
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;++i) {
        scanf("%d",&in[i]);
        ind[in[i]] = i;
    }
    init(1,1,n);
    priority_queue<node> pq;
    node root = node(1,n,n);
    pq.push(root);
    int pos = 0;
    while(!pq.empty()) {
        node tmp = pq.top();
        pq.pop();
        int l = tmp.l,r = tmp.r, x = tmp.val;
        int xind = ind[x];
        int y = query(1,1,n,xind,r, (l&1)^1);
        ret[pos++] = x;
        ret[pos++] = y;
        int yind = ind[y];
        if(l<=xind-1) {
            pq.push(node(l,xind-1,n));
        }
        if(xind+1<=yind-1) {
            pq.push(node(xind+1,yind-1,n));
        }
        if(yind+1<=r) {
            pq.push(node(yind+1,r,n));
        }
    }
    for(int i=0;i<n;++i) {
        printf("%d ",ret[i]);
    }
    putchar('\n');
}
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 12284
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut a: [i64; n],
    }
    a.sort();
    let ans: i64 = if a[0] == 0 {
        0
    } else {
        let mut prod: i64 = 1;
        for v in a {
            prod = prod.saturating_mul(v);
            prod = if prod > 1_000_000_000_000_000_000 {
                prod = -1;
                break;
            } else {
                prod
            }
        }
        prod
    };
    println!("{}", ans);
}


Measured memory_bytes: 5104
object Main extends App {
	val n = scala.io.StdIn.readInt
	val x = scala.io.StdIn.readLine.split(" ").map(_.toLong)

	val max = x.max
	val min = max/2

	val x2 = x.filter(_ != max)

	val y = x2.map(z => math.abs(z - min))
	val tp = y.min

	if(x2.contains(min + tp)){
		println(max + " " + (min+tp))
	}else{
		println(max + " " + (min-tp))
	}
}

Measured memory_bytes: 55432
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    long long int n;
    cin >> n;
    if (n == 0) {
    	cout << 0 << endl;
    	return 0;
    }
    string res;
    long long int base = 1;
    while (n != 0) {
    	if (n / base % 2 != 0) {
    		res.push_back('1');
    		n -= base;
    	} else {
    		res.push_back('0');
    	}
    	base *= -2;
    }
    reverse(res.begin(), res.end());
    cout << res << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second

 
 
using namespace __gnu_pbds;
using namespace std;
 const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i; 
int multiply(int a, int b, int in_mod){return (a*b)%in_mod;} 
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}



void solve()
{
    int n, m;
    cin>>n>>m;
    readv(h,n);
    h.insert(h.begin(),0);
    vector<int> ans(n+1);
    for(int i=0;i<m;i++)
    {
        int a, b;
        cin>>a>>b;
        if(h[a]<=h[b])
        {
            ans[a]++;
        }
        if(h[b]<=h[a])
        {
            ans[b]++;
        }
    }
    int sm=0;
    for(int i=1;i<=n;i++)
    {
        if(ans[i]==0)
            sm++;
    }
    cout<<sm<<endl;
}

 
 
signed main()
 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        if(fopen("INPUT.txt","r"))
        {
            freopen ("INPUT.txt" , "r" , stdin);
            freopen ("OUTPUT.txt" , "w" , stdout);
        }
    #endif
    auto clk=clock(); 
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------     
 
    int t=1;
    // cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        solve();
        // cout<<endl;
 
    }
 
    // -------------------------------------Code ends here------------------------------------------------------------------
 
 
    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
 }


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

int main(){
  string s;cin>>s;
  cout<<"2018";
  for(int i=4;i<s.length();++i)cout<<s[i];
}

Measured memory_bytes: 256
n = gets.to_i
as = gets.chomp.split.map(&:to_i)
as.map!.with_index(1) do |a, i|
  a - i
end
as.sort!
b = as.size % 2 == 0 ? as[as.size / 2 - 1, 2].inject(:+) / 2 : as[as.size / 2]
as.map! do |a|
  (a - b).abs
end
puts as.inject(:+)

Measured memory_bytes: 19456
import java.util.*;
 
public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        long X = sc.nextLong();
        long Y = sc.nextLong();
        sc.close();

        int count = 0;
        while(X <= Y){
            count++;
            X *= 2;
        }

        System.out.println(count);
    }
}

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

#define debug(x) cout << #x << " = " << x << endl

const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> P;


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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
void mincost(ll i, ll mi[], ll h[])
{

	if (i == 0)
	{
		mi[i] = 0;
		return;
	}
	else if (i == 1)
	{
		mi[i] = abs(h[i] - h[i - 1]);
		return;
	}
	else
	{
		if (mi[i - 1] == -1)
			mincost(i - 1, mi, h);
		if (mi[i - 2] == -1)
			mincost(i - 2, mi, h);
		mi[i] = min(abs(h[i] - h[i - 1]) + mi[i - 1], abs(h[i] - h[i - 2]) + mi[i - 2]);
	}
	return;
}

int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin >> n;
	ll h[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> h[i];
	}
	ll mi[n];
	mem(mi, -1);
	mincost(n - 1, mi, h);
	cout << mi[n - 1];
	return 0;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}
 
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  int a, b, c;
  a = max({A,B,C});
  b = A + B + C - max({a,b,c}) - min({a,b,c});
  c = min({a,b,c});
  
  int cnt = a-b;
  
  b += cnt;
  c += cnt;
  
  if((a-c)%2 == 0) cnt += (a-c)/2;
  else cnt += (a-c)/2 + 2;
  
  cout << cnt << endl;
  
  
  
}
  



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

using namespace std;

long long ans;
int n;
int s[1000010];

int main(){
	cin >> n;
	
	for(int i = 1; i <= n; ++i) if(i % 3 != 0 && i % 5 != 0) ans += i;
	cout << ans << endl;
}


Measured memory_bytes: 3628
while true
    n, p = gets.chomp.split.map(&:to_i)
    break if [n, p] == [0, 0]
    arr = Array.new(n, 0)
    player, cup = 0, p
    while true
        if cup != 0
            cup -= 1
            arr[player] += 1
            break if arr[player] == p
        else
            if arr[player] != 0
                cup += arr[player]
                arr[player] = 0
            end
        end
        player = (player + 1) % n
    end
    puts player
end



Measured memory_bytes: 6860
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl
 
//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) > (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)
 
constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;
 
int main(){
 
    int a,b;
    cin>>a>>b;
    if(b%a==0){
        cout<<a+b<<endl;
    }else{
        cout<<b-a<<endl;
    }
 
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int a,b,k;
    cin >> a >> b >> k;
    map<int,int> used;
    rep(i,k){
        if(i+a<=b){
            cout << i+a << endl;
            used[i+a]=1;
        }
        else break;
    }
    rep(i,k){
        if((!used.count(b-k+i+1))&&(b-k+i+1>a))cout << b+i+1-k << endl;
    }
}

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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int n, m, K;
char board[15][15];

int main() {
    
    scanf("%d %d %d", &n, &m, &K);
    
    
    for (int i = 0; i < n; i++) {
        scanf("%s", &board[i][0]);
    }
    
    int ans = 0;
    for (int mr = 0; mr < (1 << n); mr++) {
        for (int mc = 0; mc < (1 << m); mc++) {
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (board[i][j] == '#' && ((1 << i) & mr) && ((1 << j) & mc)) {
                        cnt++;
                    }
                }
            }
            if (cnt == K) ans++;
        }
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 3816
#include "iostream"
#include "vector"
#include "map"
 
#define N_MAX 55
 
 
using namespace std;
 
vector<int> eratos(int n) {
    vector<int> arr(n + 1);
 
    for (int i = 0; i <= n; i++) arr[i] = 1;
 
    for (int i = 2; i <= n; i++) {
        if (arr[i] != 0) {
            for (int j = 2; i * j <= n; j++) {
                arr[i * j] = 0;
            }
        }
    }
 
    vector<int> ret;
    for (int i = 2; i <= n; i++) {
        if(arr[i] != 0) {
            ret.push_back(i);
        }
    }
    return ret;
}
 
int N;
 
int main() {
 
    cin >> N;
 
    vector<int> primes = eratos(55555);
 
    vector<int> ans;
    for (int i = 0; i < primes.size(); i++) {
        if (primes[i] % 5 == 1) {
            ans.push_back(primes[i]);
        }
    }
 
    for (int i = 0; i < N - 1; i++) {
        cout << ans[i] << " ";
    }
    cout << ans[N - 1];
}

Measured memory_bytes: 512
n, k = gets.split.map(&:to_i)
sushi = Hash.new { |h, k| h[k] = [] }

s_0 = []
s_1 = []

n.times do
  t, d = gets.split.map(&:to_i)
  sushi[t] << d
end
sushi.values.each do |arr|
  arr.sort!.reverse!
  arr.each_with_index do |a, i|
    if i == 0
      s_1 << a
    else
      s_0 << a
    end
  end
end
s_0.sort!.reverse!
s_1.sort!.reverse!

n_0 = s_0.size
n_1 = s_1.size

tmp = 0
sum_0 = [0].concat(s_0.map { |si| tmp += si })
tmp = 0
sum_1 = [0].concat(s_1.map { |si| tmp += si })
ans = 0
(k + 1).times do |i|
  next if i == 0
  # s_1 からi個とる
  x = i
  y = k - i
  # 取れないときのための微調整
  if x > n_1
    y += x - n_1
    x = n_1
  end
  if y > n_0
    x += y - n_0
    y = n_0
  end
  sum = sum_1[x] + sum_0[y] + x * x
  ans = sum if sum > ans
end

p ans


Measured memory_bytes: 18596
n = int(input())
t_, a_ = 1, 1
for _ in range(n):
    x, y = map(int, input().split())
    l = max(((t_ - 1) // x), ((a_ - 1) // y)) + 1
    t_ = l * x
    a_ = l * y
print(t_ + a_)

Measured memory_bytes: 3060