akhauriyash/Code-Regression huggingface dataset:
cal :: String -> String
cal input = let (a:op:b:_) = words $ input
            in case op of
              "+" -> show $ read a + read b
              "-" -> show $ read a - read b
              "*" -> show $ read a * read b
              "/" -> show $ read a `div` read b
              other   -> other

getCal :: IO ()
getCal = do
    l <- getLine
    let res = cal l
    if res == "?" then return ()
    else do
      putStrLn res
      getCal

main = getCal

Measured memory_bytes: 4036
#include<iostream>
#include<string>
#include<cstdlib>
#include<complex>
#include<vector>
using namespace std;

complex<int> parse(string str){
  vector<complex<int> > v;
  vector<char> op;
  int pos = 0;

  while(pos<(int)str.size()){
    if(str[pos] == '('){
      string tmp;
      pos++;
      int cnt = 0;
      while(str[pos]!=')' || cnt){
	if(str[pos]=='(')cnt++;
	if(str[pos]==')')cnt--;
	tmp.push_back(str[pos++]);
      }
      v.push_back(parse(tmp));
    }else if(str[pos]== '+' || str[pos]=='-' || str[pos]=='*'){
      op.push_back(str[pos]);
    }else{
      complex<int> num;
      string tmp;
      while(pos<(int)str.size() && str[pos]!='+' && str[pos]!='-'){
	if(str[pos]=='*'){
	  if(str[pos+1]=='i'){
	    pos++;
	    tmp+=str[pos++];
	    break;
	  }else break;
	}
	if(str[pos]=='i'){
	  if(tmp.empty())tmp+='1';
	  tmp+=str[pos++];
	  break;
	}
	tmp+=str[pos++];
      }
      pos--;
      if(tmp[(int)tmp.size()-1]=='i'){
	num.real() = 0;
	tmp.erase(tmp.begin()+(int)tmp.size()-1);
	num.imag() = atoi(tmp.c_str());
      }else{
	num.real() = atoi(tmp.c_str());
	num.imag() = 0;
      }
      v.push_back(num);
    }
    pos++;
  }
  for(int i=0;i<(int)v.size();i++){
    if(v[i].real()>10000 || v[i].real()<-10000)return v[i];
    if(v[i].imag()>10000 || v[i].imag()<-10000)return v[i];
  }

  for(int i=0;i<(int)op.size();i++){
    if(op[i]=='*'){
      v[i+1] = v[i]*v[i+1];
      v.erase(v.begin()+i);
      op.erase(op.begin()+i);
      if(v[i].real()>10000 || v[i].real()<-10000)return v[i];
      if(v[i].imag()>10000 || v[i].imag()<-10000)return v[i];
      i--;
    }
  }
  for(int i=0;i<(int)op.size();i++){
    if(op[i]=='+')v[i+1] = v[i]+v[i+1];
    else v[i+1] = v[i]-v[i+1];
    v.erase(v.begin()+i);
    op.erase(op.begin()+i);
    if(v[i].real()>10000 || v[i].real()<-10000)return v[i];
    if(v[i].imag()>10000 || v[i].imag()<-10000)return v[i];
    i--;
  }
  return v[0];
}


int main(){
  string exp;

  while(cin>>exp){
    complex<int> ans = parse(exp);
    int r = ans.real(),i = ans.imag();
    if(r>10000 || r<-10000 || i>10000 || i<-10000)cout << "overflow\n";
    else if(!r){
      if(!i)cout << "0\n";
      else cout << i << "i\n";
    }else{
      if(!i)cout << r << endl;
      else if(i<0)cout << r << i << "i\n";
      else cout << r << "+" << i << "i\n";
    }
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    long long int a;
    std::deque<long long int> deq;
    cin>>n;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(a);
    }
    sort(deq.begin(),deq.end());
    for (int j=0;j+1<n;j++) {
        long long int a=deq[j];
        long long int b=deq[j+1];
        long long int tmp;
        while (a%b!=0) {
            tmp=b;
            b=a%b;
            a=tmp;
        }
        deq[j+1]=b;
    }
    cout<<deq.back()<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <queue>

using namespace std;

struct  pos {
	int x, y;
	pos(int _x, int _y) { x = _x; y = _y;}
};

int a[50][50];

void ans(int p,int q,int h,int w);

int main(){
	int H,W,count;
	while(1){
		count=0;
		cin >> H;
		cin >> W;
		if(H==0&&W==0){
			break;
		}
		for(int i=0;i<W;i++){
			for(int j=0;j<H;j++){
				cin >> a[i][j];
			}
		}
		
		for(int i=0;i<W;i++){
			for(int j=0;j<H;j++){
				if(a[i][j]==1){
					a[i][j]=0;
					ans(i,j,H,W);
					count++;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

void ans(int p, int q, int h, int w)
{
	queue<pos> Q;
	Q.push(pos(p, q));
	while (Q.size()) {
		pos b= Q.front();
		Q.pop();
		for (int i=-1;i<=1;i++) {
			for (int j=-1;j<=1;j++) {
				if(0<=b.x+i&&b.x+i<w&&0<=b.y+j&&b.y+j<h){
					if(a[b.x+i][b.y+j]==1){
						a[b.x+i][b.y+j]=0;
						Q.push(pos(b.x+i,b.y+j));
					}
				}
			// mawariwomiru
			}
		}
	}
}


/*
void ans(int p,int q,int h,int w){
	for(int i=-1;i<=1;i++){
		for(int j=-1;j<=1;j++){
			if(0<=p+i&&p+i<h&&0<=q+j&&q+j<w){
				if(a[p+i][q+j]==1){
					a[p+i][q+j]=0;
					Q.push(pos(p+i,q+j));
				}
			}
		}
	}
	if(Q.size()){
		pos b=Q.front();
		Q.pop();
		ans(b.x,b.y,h,w);
	}
}*/
				
	

Measured memory_bytes: 1224
def divisors(n)
  r = []
  1.upto(n) do |i|
    break unless i <= n / i
    next unless (n % i).zero?
    r << i
    r << n / i if i != n / i
  end
  r
end

def common(a, b)
  used=Hash.new{|h,k|h[k]=0}
  a.each do |i| used[i]=1 end
  b.select{|i| used[i]==1}
end

A,B=gets.split.map(&:to_i)
used=[]
common(divisors(A), divisors(B)).sort.each do |d|
  used << d if used.all?{|i| d.gcd(i)==1}
end
p used.size


Measured memory_bytes: 2428
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define MOD 1000000007
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define OTP(s) cout<<s<<endl;
#define FOR(i,j,k,l) for(int i=j;i<k;i+=l)
#define REP(i,j) FOR(i,0,j,1)
inline ll add(ll a, ll b){a += b; if(a >= MOD)a -= MOD; return a;}
inline ll sub(ll a, ll b){a -= b; if(a < 0)a += MOD; return a;}
inline ll mul(ll a, ll b){return (ll)((ll) a * b %MOD);}
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

ll min(ll a,ll b)
{
    return a>b?b:a;
}
ll max(ll a,ll b)
{
    return a>b?a:b;
}

int main()
{
    IOS
    ll a,b;
    cin>>a>>b;
    if(a!=2 && b!=2)
    {
        cout<<2<<endl;
    }   
    else    if(a!=1 && b!=1)
    {
        cout<<1<<endl;
    }   
    else
    {
        cout<<3<<endl;
    }
    
}

Measured memory_bytes: 256
def main():
    n = int(input())
    hs = tuple(map(int, input().split()))
    
    a, b = 0, abs(hs[1] - hs[0])
    
    for i in range(2, n):
        c = hs[i]
        a, b = b, min(a + abs(c - hs[i-2]), b + abs(c - hs[i-1]))
    
    print(b)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14108
#include<iostream> 
#include<string>
#include<algorithm>
using namespace std;
int a[100];
int main()
{
	int num,sum=0;
	cin >> num;
	for (int i = 0; i < num; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < num - 1; i++) {
		int minNumber = i;
		for (int k = i + 1; k < num; k++) {
			if (a[k] < a[minNumber]) {
				minNumber = k;
			}
		}
		if (minNumber != i) {
			int temp = a[minNumber];
			a[minNumber] = a[i];
			a[i] = temp;
			sum++;
		}
	}
	cout << a[0];
	for (int i = 1; i < num; i++) {
		cout << " " << a[i];
	}
	cout << endl;
	cout << sum << endl;
	
}


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

const ll mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

// 0-indexed, 半開
template <typename T> struct BIT {
  private:
    int n;
    vector<T> dat;

  public:
    BIT(vector<T> v) : n(v.size()) {
        dat.assign(n + 1, 0);
        for(int i = 0; i < n; i++)
            dat[i + 1] = v[i];
        for(int i = 1; i < n; i++)
            if(i + (i & -i) <= n) dat[i + (i & -i)] += dat[i];
    }
    BIT(int n) : n(n) { dat.assign(n + 1, 0); }
    void add(int k, T a) {
        for(k++; k <= n; k += k & -k)
            dat[k] += a;
    }
    // [0,a)
    T sum(int a) {
        T ret = 0;
        for(; a > 0; a -= a & -a)
            ret += dat[a];
        return ret;
    }
    // [a,b)
    T sum(int a, int b) { return sum(b) - sum(a); }
    int lowerBound(int w) {
        if(w <= 0) return 0;
        int x = 0;
        for(int k = 1 << int(log2(n)); k; k /= 2) {
            if(x + k <= n && dat[x + k] < w) {
                x += k;
                w -= dat[x];
            }
        }
        return x + 1;
    }
};

ll n, d, a;
pair<ll, ll> p[200009];

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

    cin >> n >> d >> a;
    rep(i, n) {
        int x, h;
        cin >> x >> h;
        p[i] = {x, h};
    }
    sort(p, p + n);
    vector<ll> vec;
    rep(i, n) vec.push_back(p[i].first);
    BIT<ll> bit(n + 10);
    rep(i, n) {
        bit.add(i, p[i].second);
        bit.add(i + 1, -p[i].second);
    }
    // FOR(i, 1, n + 1) cout << bit.sum(i) << endl;

    ll ans = 0;
    rep(i, n) {
        int x =
            upper_bound(vec.begin(), vec.end(), vec[i] + d * 2) - vec.begin();
        if(bit.sum(i + 1) > 0) {
            ll A = (bit.sum(i + 1) - 1) / a + 1;
            bit.add(i, -A * a);
            bit.add(x, A * a);
            ans += A;
        }
    }
    cout << ans << endl;
}

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

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

// ========================================================================= //

const int N = 100179;

int main() {
    ios::sync_with_stdio(false);

    int a, b;
    int k;
    cin >> a >> b >> k;
    for (int i = 0; i <= a; ++i)
        for (int j = 0; j <= b; ++j)
            if (k == a*j + b*i - 2*i*j) {
                cout << "Yes\n";
                return 0;
            }
    cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;

class Solver extends Main{
	Solver(){

	}
}

class Main{
	int imax=Integer.MAX_VALUE;
	long lmax=Long.MAX_VALUE;
	public static void main(String[] args) throws FileNotFoundException{
		Scanner sc=new Scanner(System.in);
		int[] num=readlnI(sc," ");
		puts( num[2]>=num[0] && num[2]<=num[1] ? "Yes" : "No" );
		new Solver();
	}	
	
	//utility
	static int[] readlnI(Scanner sc, String dl){
		return Arrays.stream(sc.nextLine().trim().split(dl)).mapToInt(Integer::parseInt).toArray();
	}
	static long[] readlnL(Scanner sc, String dl){
		return Arrays.stream(sc.nextLine().trim().split(dl)).mapToLong(Long::parseLong).toArray();
	}
	static int readI(Scanner sc){
		return Integer.parseInt(sc.nextLine().trim());
	}
	static String[] readS(Scanner sc, String dl){
		return sc.nextLine().trim().split(dl);
	}
	static String nextS(Scanner sc){
		return sc.nextLine().trim();
	}
	@SuppressWarnings("unchecked")
	static <T> void puts(T... args){
		for(int i=0; i<args.length-1; i++){
			System.out.printf("%s ",args[i]);
		}
		System.out.println(args[args.length-1]);
	}
	static void puts(int[] ary){
		for(int i=0; i<ary.length-1; i++){
			System.out.printf("%d ",ary[i]);
		}
		System.out.println(ary[ary.length-1]);
	}
	static void puts(long[] ary){
		for(int i=0; i<ary.length-1; i++){
			System.out.printf("%d ",ary[i]);
		}
		System.out.println(ary[ary.length-1]);
	}
	static void tblSort(int[][] tbl){
		Arrays.sort(tbl, new Comparator<int[]>(){
			@Override
			public int compare(int[] a, int[] b){
				if(a[0]==b[0]){
					return b[1]-a[1];
				}else{
					return b[0]-a[0];
				}
			}
		});
	}
}

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

map<int, int> mp;
int ans = 0;

int main(void){
    // Your code here!
    int N;
    cin >> N;
    int a;
    for(int i = 0; i < N; i++){
        cin >> a;
        mp[a]++;
    }
    
    int evens = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        int j = itr->second;
        if(j % 2 == 0){
            evens++;
            ans += (j-2)/2;
        }else{
            ans += (j-1)/2;
        }
    }
    
    ans += (evens + 1)/2;
    cout << N - ans * 2 << endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)
using namespace std;


const ll N   =  500005;
const ll mod = 1e9 + 7;

int wt[N]; int val[N];
int knapSack(int W,int n) 
{ 
   int i, w; 
   int K[W+1]; 
  	for (int i = 0; i <= W; ++i)
  	{
  	  K[i] = mod;
  	}
  	K[0] = 0;
  for (w = 1; w <= W; w++)  
   { 
       for (i = 0; i < n; i++) 
       { 
           
           if(w-wt[i]>=0)
            K[w] = min({K[w],val[i] + K[w-wt[i]]}); 
        	else K[w] = min(K[w],val[i]);

        
       } 
   }

   return K[W]; 
} 

void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k,W;
  cin>>W>>n;

  for (ll i = 0; i < n; ++i)
  {
  cin>>wt[i]>>val[i];
  }
  c(knapSack(W,n));
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  ll T=1;
  //cin>>T;
  while(T--){
  solve();
  }
  return 0;
}


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

long c2(long n) {
  return n * (n - 1) / 2;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N), cnt(N + 1);
  for (int i = 0, a; cin >> a; i++) A.at(i) = a, cnt.at(a)++;

  long sum = 0;
  for (int i : cnt) sum += c2(i);

  for (int a : A) cout << sum - c2(cnt.at(a)) + c2(cnt.at(a) - 1) << "\n";
}

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

using namespace std;

#define endl '\n'

typedef long long int64;
typedef pair<int64,int64> pii;
typedef vector<int> vi;

const double eps = 1e-9;
const int64 oo = 0x3f3f3f3f3f3f3f3f;
const int mod = 1000000007;

int n;
int64 val[32];

set<pii> x[32][32];

void try_insert(set<pii> &s, pii a){

    while (true){
        auto it = s.lower_bound(a);
        if (it == s.end()) break;

        if (it->second >= a.second)
            s.erase(it);
        else
            break;
    }

    auto it = s.lower_bound(a);

    if (it != s.begin()){
        it--;

        if (a.first >= it->first && a.second >= it->second)
            return;
    }

    s.insert(a);
}

void solve(int a, int b){
    if (!x[a][b].empty())
        return;

    if (b < a){
        x[a][b].insert(pii());
        return;
    }

    for (int i = a; i <= b; ++i){
        solve(a, i - 1);
        solve(i + 1, b);

        for (auto aa : x[a][i - 1]){
            for (auto bb : x[i + 1][b]){
                try_insert(x[a][b], pii(
                    aa.first + aa.second + bb.first + val[i],
                    bb.first + bb.second + aa.second + val[i]
                ));
            }
        }
    }
}

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

    cin >> n;

    for (int i = 1; i <= n; ++i)
        cin >> val[i];

    int64 answer = oo;

    solve(2, n - 1);

    for (auto v : x[2][n - 1]){
        answer = min(answer, v.first + v.second);
    }

    cout << answer + val[1] + val[n] << endl;

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>//printf("%.9f\n",*********);
#include<vector>//文字列.erase(n)
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字) to_string
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

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

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {

	string s;
	cin >> s;

	char cnt = 'a';

	rep(i, 'z' - 'a' + 1) {
		rep(j, s.size()) {
			if (s[j] == cnt) {
				break;
			}
			if (j + 1 == s.size()) {
				cout << cnt << rt;
				return 0;
			}
		}
		cnt++;
	}
	cout << "None" << rt;

	please AC;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N, K;
        int[] v;
        N = in.nextInt();
        K = in.nextInt();
        v = new int[N];
        for (int i = 0; i < N; i++) {
            v[i] = in.nextInt();
        }
        long ans = solve(N, K, v);
        System.out.println(ans);
        in.close();
    }

    static long solve(int N, int K, int[] v) {
        long ans = Long.MIN_VALUE;
        int ops;
        ops = Math.min(N, K);
        for (int left = 0; left <= ops; left++) {
            for (int right = 0; left + right <= ops; right++) {
                ans = Math.max(ans, getJewel(left, right, v, K));
            }
        }
        return ans;
    }

    //左からleft, 右からright個とる
    static long getJewel(int left, int right, int[] v, int K) {
        long ret = 0;
        PriorityQueue<Integer> minValues = new PriorityQueue<>();
        for (int i = 0; i < left; i++) {
            minValues.add(v[i]);
        }
        for (int i = 0; i < right; i++) {
            minValues.add(v[v.length - 1 - i]);
        }
        int M = K - right - left;
        for (int i = 0; i < M; i++) {
            if (!minValues.isEmpty() && minValues.peek() < 0) {
                minValues.poll();
            }
        }
        while (!minValues.isEmpty()) {
            ret += minValues.poll();
        }
        return ret;
    }

}


Measured memory_bytes: 24276
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    #→1,.→0として読み込む
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '#' else 0 for s in read()[:-1]])
    return ret


A, B = read_ints()

for i in range(1, 10**5):
    if A == int(i * 0.08) and B == int(i * 0.1):
        print(i)
        exit()
print(-1)


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


int main() {
    int N, K;
    cin >> N >> K;
    int h[N];
    rep(i, N) cin >> h[i];
    sort(h, h + N, greater<int>());

    int minD = INF;
    rep(i, N-K+1){
        if(minD > abs(h[i] - h[i+K-1])){
            minD = abs(h[i] - h[i+K-1]);
        }
    }
    cout << minD << endl;
}


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

int main() {
    string s;
    cin>>s;
    
    for (int i = 0;i<s.length();i++){
        if (i%2==0){
        cout<<s[i];
        }
    }
  return 0;
}



Measured memory_bytes: 760
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

typedef long long ll;
using namespace std;

int main(){
    int a,b,x,t=0,ans=1;cin>>a>>b;
    while(a--){
        cin>>x;t+=x;if(t<=b) ans++;
    }
    cout<<ans;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<vector<int>> info(N, vector<int>(N, 0));
    rep(i, N) {
        rep(j, N) {
            cin >> info[i][j];
        }
    }
    ll S = 1 << N;
    vector<vector<ll>> dp(N + 1, vector<ll>(S, 0));
    dp[0][0] = 1;
    rep(i, N) {
        rep(j, S) {
            if (__builtin_popcount(j) != i) continue;
            rep(k, N) {
                if (info[i][k] && !(j & (1 << k))) {
                    dp[i + 1][j | (1 << k)] += dp[i][j];
                    dp[i + 1][j | (1 << k)] %= MOD;
                }
            }
        }
    }
    cout << dp[N][S - 1] % MOD << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 377216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(v) (v).begin(), (v).end()

int main()
{
  int A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;

  double concentration = -1.0;
  int ans_w = 0, ans_s = 0;
  for (int a_i = 0; a_i*100*A <= F; ++a_i) {
    for (int b_i = 0; b_i*100*B <= F; ++b_i) {
      int water = a_i*A*100+b_i*B*100;
      if (water == 0) continue;
      int smax = (a_i*A+b_i*B)*E;
      for (int c_i = 0; c_i*C <= smax; ++c_i) {
        for (int d_i = 0; d_i*D <= smax; ++d_i) {
          int sugar = c_i*C+d_i*D;

          if (water > F or
              sugar > smax or
              sugar > water*E/100.0 or
              water+sugar > F) continue;

          double tmpconc = 100.0*sugar/(water+sugar);

          if (concentration < tmpconc) {
            concentration = tmpconc;
            ans_w = water;
            ans_s = sugar;
          };
        }
      }
    }
  }

  cout << ans_w+ans_s << " " << ans_s << endl;
}

Measured memory_bytes: 256
import Control.Monad
main = do
  [n,time] <- map read . words <$> getLine
  cts <- replicateM n (map read . words <$> getLine) :: IO [[Int]]
  let c = foldl (\cost (c:t:_) -> if (t<=time && c<cost) then c else cost) 1001 cts
  if c == 1001 then putStr "TLE" else print c

Measured memory_bytes: 1020
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");

        int count = 0;
        for (int i = 0, j = s.length-1; i < s.length/2; i++, j--) {
            if (!s[i].equals(s[j])) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (b == 1) {
            System.out.println(0);
            System.exit(0);
        }

        for (int i = 1; i < 1_000_000_000; i++) {
            if ((a + (a - 1) * (i - 1)) >= b) {
                System.out.println(i);
                break;
            }
        }

        sc.close();
    }
}


Measured memory_bytes: 23892
# initialization
n = gets.to_i
w = Array.new(n).map { Array.new(n, Float::INFINITY) }
n.times do
  u, k, *v = gets.split
  (0..2 * k.to_i - 1).step(2) { |i| w[u.to_i][v[i].to_i] = v[i+1].to_i }
end

d = Array.new(n, Float::INFINITY)
d[0] = 0
p = Array.new(n, -1)
color = Array.new(n, "WHITE")
u = nil

# dijkstra
while true
  mincost = Float::INFINITY

  (0..n-1).each do |i|
    if color[i] != "BLACK" && d[i] < mincost
      mincost = d[i]
      u = i
    end
  end

  break if mincost == Float::INFINITY
  color[u] = "BLACK"

  (0..n-1).each do |v|
    if color[v] != "BLACK" && w[u][v] != Float::INFINITY
      if d[u] + w[u][v] < d[v]
        d[v] = d[u] + w[u][v]
        p[v] = u
        color[v] = "GLAY"
      end
    end
  end
end

d.each_with_index do |weight, idx|
  puts "#{idx} #{weight}"
end

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

int main(){
	
	int a,b;
	
	cin >> a >> b;
	
	cout << "a" <<" ";
	
	if(a>b){
		cout << ">" ;
	}else if(a<b){
		cout << "<" ;
	}else{
		cout << "==";
	}
	cout << " "<<"b"<<endl;
}

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

using namespace std;
static const int MAX = 200000;

int main(){
  int A[MAX],n;
  int j,v;

  cin >> n;

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

  for(int i = 0;i<n;i++){
    v = A[i];
    j = i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;

  for (int i=0;i<n;i++){
    if(i) cout <<" ";
    cout << A[i];
  }
  cout << endl;

    }
  return 0;
}

Measured memory_bytes: 3080
# include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 2e5+30;
LL a[maxn], b[maxn], ans=0;
int main()
{
    int n, l, r;
    scanf("%d",&n);
    for(int i=0; i<n; ++i) scanf("%lld",&a[i]);
    for(int i=0; i<n; ++i) scanf("%lld",&b[i]);
    for(int i=28; ~i; --i)
    {
        LL s = 1LL<<i, tmp=0;
        for(int j=0; j<n; ++j) a[j]%=(s<<1), b[j]%=(s<<1);
        sort(b,b+n);
        for(int j=0; j<n; ++j)
        {
            l = lower_bound(b,b+n,s-a[j])-b;
            r = lower_bound(b,b+n,(s<<1)-a[j])-b;
            tmp += r-l;
            l = lower_bound(b,b+n,(s<<1|s)-a[j])-b;
            r = lower_bound(b,b+n, (s<<2)-a[j])-b;
            tmp += r-l;
        }
        if(tmp&1) ans |= s;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <cmath>
#define MAXN 200010
using namespace std;
const int maxn = 1010;
typedef long long ll;
int main(){
    ll n, m;
    cin>>n>>m;
    ll ans;
    if(n==1||m==1){
        printf("1\n");
    }else{
        if(n%2==0) ans = m*n/2;
        else{
            ans = m*(n/2);
            if(m%2==0) ans+=m/2;
            else ans+=m/2, ans++;
        }
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    P = 0
    for i in range(1,N+1):
        value = i
        cnt = 0
        while K > value:
            cnt += 1
            value *= 2
        P += 1/N * (1/2)**cnt
    print(P)
            
if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
from heapq import nlargest

X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort()
B.sort()

E = nlargest(K, [a+b for a in A for b in B])
F = nlargest(K, [e+c for e in E for c in C])
#print(F)
print("\n".join(map(str,F)))


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

#define ll long long
#define ld long double
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
const int MOD=1e9+7;

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

int solve(int s){
	vt<ll>dp(s+1,1);
	dp[0]=dp[1]=dp[2]=0;
	for(int i=3;i<=s;i++){
		for(int j=3;j<=i;j++){
			dp[i]=(dp[i]+dp[i-j])%MOD;
		}
	}
	return dp[s];
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;cin>>n;
	if(n<3){cout<<0;return 0;}
	cout<<solve(n);
	return 0;
}


Measured memory_bytes: 3628
def main():
    n = int(input())
    ls = ["".join((sorted(list(input())))) for _ in range(n)]
    ls = sorted(ls)


    i =0
    cnt = 1
    ans = 0
    while 1:
        if ls[i]==ls[i+1]:
            ans += cnt
            cnt +=1
            i +=1
        else:
            cnt = 1
            i += 1
        if i == n-1:
            break
    print(ans)



       
if __name__ == '__main__':
    main()

Measured memory_bytes: 59992
import java.io.InputStream;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {
	public static void main(String args[]) {
		MyInput in = new MyInput();
    int N = in.nextInt();
    int[] lens = new int[N];
    int[] chl = new int[N];
    int checked = 0;
    for(int i = 0; i < N; i++) {
        lens[i] = in.nextInt();
    }
    Arrays.sort(lens);

    long ans = 1;

    int inch = 0;
    int insize = 0;
    boolean chb = false;
    int tmp;

    int len;
    int finc = 0;
    for(int i = N - 1; i >= 0; i--) {
        len = lens[i];
        if(checked == len) {
            checked = 0;
            ans *= len;
            finc++;
        }else {
            checked = len;
        }
        if(finc >= 2) break;
    }

    if(finc >= 2) {
        System.out.println(ans);
    }else{
        System.out.println("0");
    }
	}
}

class MyInput {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr= 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if(ptr < buflen) {
			return true;
		}else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch(IOException e) {
				e.printStackTrace();
			}
			if(buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	public int readByte() { 
		if (hasNextByte()) return buffer[ptr++];
		else return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <=126;
	}

	private void skipUnprintable() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if(!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if(!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if(b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true) {
			if('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			}else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 23360
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var h, dp []int

func main() {
	io := newIo()
	n := io.nextInt()

	h = make([]int, n)
	for i := range h {
		h[i] = io.nextInt()
	}

	dp = make([]int, n)
	for i := range dp {
		dp[i] = -1
	}

	fmt.Println(recDp(n - 1))
}

func recDp(i int) int {
	if i == 0 {
		return 0
	}
	if dp[i] != -1 {
		return dp[i]
	}
	var res int
	k := recDp(i-1) + abs(h[i]-h[i-1])
	if i-2 < 0 {
		res = k
	} else {
		res = min(k, recDp(i-2)+abs(h[i]-h[i-2]))
	}
	dp[i] = res
	return res
}

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

type _io struct {
	reader    *bufio.Reader
	tokens    []string
	nextToken int
}

func newIo() *_io {
	return &_io{
		reader: bufio.NewReader(os.Stdin),
	}
}

func (_io *_io) nextLine() string {
	var buffer []byte
	for {
		line, isPrefix, _ := _io.reader.ReadLine()
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (_io *_io) next() string {
	for _io.nextToken >= len(_io.tokens) {
		line := _io.nextLine()
		_io.tokens = strings.Fields(line)
		_io.nextToken = 0
	}
	r := _io.tokens[_io.nextToken]
	_io.nextToken++
	return r
}

func (_io *_io) nextInt() int {
	i, _ := strconv.Atoi(_io.next())
	return i
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define F first
#define S second
#define pb push_back
mt19937 rnd;


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    double x;
    cin >> x;
    int ans = 0;
    double y = 100;
    while (y < x) {
        y *= 1.01;
        y = ll(y);
        ans++;
    }
    cout << ans << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

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

       int t=1;
       //cin>>t;
       while(t--)
       {
               int n,k;
               cin>>n>>k;
               int a,count=0;
               for(int i=1;i<=n;++i)
               {
                    cin>>a;
                    if(a>=k)
                         count++;
               }
               cout<<count;
       }
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define rep2(i,start,end) for(ll i = start; i < end; i++)
#define dwn(i,n) for(int i = n; i >= 0; i--)
#define dwn2(i,start,end) for(ll i = start; i >= end; i--)
#define pll pair<ll,ll>
#define mk(x,y) make_pair(x,y)
#define pdl pair<double, ll>
const ll N = 4e5 + 200;
const ll INF = 0x3f3f3f3f;
const ll mod = 1e9 + 7;


int main(){
	string a,b;
	cin>>a>>b;
	ll sum = 0;
	ll len = a.length();
	rep(i, len){
		if(a[i] != b[i]){
			sum++;
		}
	}
	cout<<sum<<endl;



	return 0;
}






Measured memory_bytes: 3844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 1;

    char a = s[0];
    for(int i = 0; i < n-1; i++){
        if(s[i+1] == a){
            continue;
        }else{
            ans++;
            a = s[i+1];
        }
    }
    cout << ans << endl;
}


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

int func(int n){
    return (n%2 == 0) ? n/2 : 3*n + 1;
}

int main(){
    int s; cin >> s;
    int ans = 1;
    while(s != 4 && s != 2 && s != 1){
        s = func(s);
        ans += 1;
    }
    cout << ans + 3 << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <bitset>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int x[15][15], y[15][15];
    int a[15];
    rep(i, n) {
        cin >> a[i];
        rep(j, a[i]) {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }
    int ans = 0;
    rep(bit, (1 << n)) {
        int S = 0;
        int T = 0;
        int cnt = 0;
        rep(i, n) {
            if(bit & (1 << i)) {
                cnt++;
                rep(j, a[i]) {
                    if(y[i][j] == 0) T |= (1 << x[i][j]);
                    else S |= (1 << x[i][j]);
                }
            }
        }
        
        bool ok = true;
        rep(i, n) {
            if(bit & (1 << i) && T & (1 << i)) ok = false;
            if(!(bit & (1 << i)) && (S & (1 << i))) ok = false;
            if(S & (1 << i) && T & (1 << i)) ok = false;
        }
        //cout << bitset<4>(bit) << " " << bitset<4>(S) << " " << bitset<4>(T) << " " << ok << endl;
        if(ok) ans = max(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  long sum = 0;
  vector<long> data(N);
  for(int i = 0; i < N; i++){
    cin >> data.at(i);
    sum += data.at(i);
  }
  long left = 0, ans = 10000000000000000;
  for(int i = 0; i < N; i++){
    left += data.at(i);
    ans = min(ans, abs((sum - left) - left));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<set>
using namespace std;
int N,A[1000];
set<int>S;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		for(int j=1;j*j<=A[i];j++)
		{
			if(A[i]%j==0)
			{
				S.insert(j);
				S.insert(A[i]/j);
			}
		}
	}
	S.erase(S.find(1));
	long ans=0;
	for(int s:S)
	{
		long now=0;
		for(int i=0;i<N;i++)
		{
			if(A[i]%s==0)now+=A[i];
		}
		if(ans<now)ans=now;
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 4068
from collections import deque
s=input()
q=int(input())
t=[input() for i in range(q)]
l=deque(list(s))
m=0
for i in range(q):
  if int(t[i][0])==1:
    m+=1
  else:
    if m%2==0:
      if int(t[i][2])==1:
        l.appendleft(t[i][4]) 
      else:
        l.append(t[i][4])
    else:
      if int(t[i][2])==2:
        l.appendleft(t[i][4]) 
      else:
        l.append(t[i][4])
if m%2==1:
  l.reverse()
print(''.join(l))

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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    long long a, b, c, d;
    ist >> a >> b >> c >> d;

    /* ------- 計算 ------- */

    long long max_xy = -pow(10, 18);

    if (a * c >= max_xy)
    {
        max_xy = a * c;
    }
    if (a * d >= max_xy)
    {
        max_xy = a * d;
    }

    if (b * c >= max_xy)
    {
        max_xy = b * c;
    }

    if (b * d >= max_xy)
    {
        max_xy = b * d;
    }

    ost << max_xy << endl;
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


Measured memory_bytes: 3628
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn main() {
    let v = read_vec::<usize>();
    let w = read_vec::<usize>();
    println!("{}",(v[0]-2) / (v[1]-1) + 1);
}


Measured memory_bytes: 6396
#import <Foundation/Foundation.h>
int main(){
    @autoreleasepool {
        char s[7] = {'\0'};
        scanf("%s",s);
        NSString *S = [NSString stringWithFormat:@"%s", s];
        puts([S rangeOfString:@"AC"].location == NSNotFound ? "No":"Yes");
    }
}


Measured memory_bytes: 9496
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++)
			par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
};

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int n, m; cin >> n >> m;
	UnionFind tree(n);

	set<int> s;
	REP(i, m) {
		int a, b; cin >> a >> b;
		s.insert(a - 1);
		s.insert(b - 1);
		tree.unite(a - 1, b - 1);
	}

	map<int, int> cnt;
	for (auto x : s)
		cnt[tree.root(x)]++;

	int maxi = 0;
	for (auto x : cnt)
		maxi = max(maxi, x.second);
	if (m == 0) maxi = 1;
	cout << maxi << '\n';
	return 0;
}

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

using namespace std;

#define ll long long
#define mod 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    int arr[n];
    for(int i = 0; i < n; ++i) cin >> arr[i];
    sort(arr, arr+n, greater<int>());
    ll ans = 0;
    ans += arr[0];
    for(int i = 2; i < n; ++i) ans += (ll)arr[i>>1];
    
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4416
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
	cin >> A >> B;
	if(A <= B) cout << "unsafe";
	else cout << "safe";
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}


int main() {
    ll n; cin >> n;
    auto d = divisor(n);
    ll ans = 100;
    rep(i, d.size()) {
        ll t = n/d[i];
        chmin(ans, (ll)max(to_string(t).size(),to_string(d[i]).size()));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int ans = 0;
		if(K == 1) {
			ans = 0;
		}else {
			ans =  N - K;
		}

		System.out.println(ans);
		sc.close();
	}

}

Measured memory_bytes: 25044
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author rahdirigs
 */

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

template <typename T> void s_max(T& a, T b) {
	if (a < b) {
		a = b;
	}
}

struct segtree {
	int l, r, mid;
	ll val;
	segtree *left, *right;

	segtree(int _l, int _r) {
		l = _l;
		r = _r;
		val = 0;
		mid = l;
		if (l != r) {
			mid = l + (r - l) / 2;
			left = new segtree(l, mid);
			right = new segtree(mid + 1, r);
		}
	}

	void update(int pos, ll v) {
		if (l == r) {
			val = v;
		} else {
			if (pos <= mid) {
				left -> update(pos, v);
			} else {
				right -> update(pos, v);
			}
			val = max(left-> val, right -> val);
		}
	}

	ll query(int ql, int qr) {
		if (ql > r || qr < l) return 0;
		if (ql <= l && qr >= r) return val;
		return max(left -> query(ql, qr), right -> query(ql, qr));
	}
};

class TaskQ {
public:
	void solve(std::istream& in, std::ostream& out) {
		int N;
		in >> N;
		vector<int> h(N), a(N);
		for (int i = 0; i < N; i++) in >> h[i];
		for (int i = 0; i < N; i++) in >> a[i];
		segtree tree = segtree(0, N);
		ll ans = 0;
		for (int i = 0; i < N; i++) {
			ll val = tree.query(0, h[i] - 1) + a[i];
			s_max(ans, val);
			tree.update(h[i], val);
		}
		out << ans;
	}
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	TaskQ solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 23516
k, x = map(int, input().split())

l = x-k+1
r = x+k-1

ans = []
a = ""

if l < -1000000:
    l = -1000000
if r > 1000000:
    r = 1000000
for i in range(l,r+1):
    ans.append(i)
for i in range(len(ans)):
    a += " " + str(ans[i])
print(a)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int n;


int main() {
    cin >> n;

    vector<int> a(n);

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

    map<int, int> m;

    for (int x : a) {
        m[x]++;
    }

    if (m.size() > 2) {
        cout << "No" << endl;
        return 0;
    }

    if (m.size() == 1) {
        if (m.begin()->first <= n / 2 || m.begin()->first == n - 1) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }

        return 0;
    }

    auto p = *m.begin();
    auto q = *next(m.begin());

    if (p.first + 1 == q.first && p.second <= p.first && n - p.first > (p.first - p.second) + 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 5376