akhauriyash/Code-Regression huggingface dataset:
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

const int inf = 1e9 + 9;

int n;
vector<int> x, y;

void read_input()
{
    cin >> n;
    x.resize(n); y.resize(n);
    for(int i = 0; i < n; ++i)
        cin >> x[i] >> y[i];
}

lli calc1(vector<int> x, vector<int> y)
{
    for(int i = 0; i < n; ++i)
        if(x[i] > y[i]) swap(x[i], y[i]);
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    return (x[n - 1] - x[0]) * 1LL * (y[n - 1] - y[0]);
}

lli calc2(vector<int> x, vector<int> y)
{
    vector<pii> v;
    int mn = inf, mx = -inf;
    multiset<int> ms;
    for(int i = 0; i < n; ++i)
    {
        if(x[i] > y[i]) swap(x[i], y[i]);
        v.push_back(pii(x[i], y[i]));
        mn = min(mn, x[i]);
        mx = max(mx, y[i]);
        ms.insert(x[i]);
    }
    sort(v.begin(), v.end());
    lli res = inf * 1LL * inf;
    for(int i = 0; i < n; ++i)
    {
        ms.erase(ms.find(v[i].fi));
        ms.insert(v[i].se);
        res = min(res, (mx - mn) * 1LL * (*ms.rbegin() - *ms.begin()));
    }
    return res;
}

void solve()
{
    cout << min(calc1(x, y), calc2(x, y)) << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 14320
void main()
{
    long n = rdElem;

    long result = inf;
    for (long i = 1; i * i <= n; ++i)
    {
        if (n % i == 0)
        {
            result = min(result, i+n/i-2);
        }
    }

    result.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <bits/stdc++.h>                                                                                                                                                                                                                                                                                                                                                                                          using namespace std;                                                                                                                                                                                                                                                        int main() {                                                                                                                              string S; cin>>S;                                                                                                                     if(S=="Sunny") cout<<"Cloudy";                                                                                                        if(S=="Cloudy") cout<<"Rainy";                                                                                                        if(S=="Rainy") cout<<"Sunny";                                                                                                     }#include <bits/stdc++.h>


using namespace std;

int main() {
    string S; cin>>S;
    if(S=="Sunny") cout<<"Cloudy";
    if(S=="Cloudy") cout<<"Rainy";
    if(S=="Rainy") cout<<"Sunny";
}


Measured memory_bytes: 256
class UnionFind:

    def __init__(self, n):
        self.p, self.d = [-1] * n, [0] * n

    def find(self, x):
        if self.p[x] < 0:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def isSame(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        if self.isSame(x, y):
            return
        x, y = self.find(x), self.find(y)

        if self.d[x] > self.d[y]:
            self.p[x] += self.p[y]
            self.p[y] = x
        else:
            self.p[y] += self.p[x]
            self.p[x] = y
            if self.d[x] == self.d[y]:
                self.d[y] += 1

    def size(self, x):
        return - self.p[self.find(x)]


N, M, K = map(int, input().split())
Frd, Blk = {i: [] for i in range(N)}, {i: [] for i in range(N)}

uni = UnionFind(N)
for _ in range(M):
    A, B = map(int, input().split())
    uni.unite(A - 1, B - 1)
    Frd[A - 1].append(B - 1)
    Frd[B - 1].append(A - 1)
for _ in range(K):
    C, D = map(int, input().split())
    Blk[C - 1].append(D - 1)
    Blk[D - 1].append(C - 1)

ans = []
for i in range(N):
    nBlk = sum([1 for b in Blk[i] if uni.isSame(i, b)])
    ans.append(str(uni.size(i) - 1 - len(Frd[i]) - nBlk))
print(' '.join(ans))


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

int main() {
  double a, b, c, d;
  cin >> a >> b;
  c = (a+1)/0.08, d = (b+1)/0.1;
  a /= 0.08, b /= 0.1;
  
  int ans = -1;
  for(int i=min(a,b); i<=max(c,d); i++) {
    if(a<=i && i<c && b<=i && i<d) {
      ans = i;
      break;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5,mod=1e9+7;
ll n,ans=1,cur;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(ll i=0;i<n;i++){
        ll x;cin>>x;
        if(2*cur+1>x)ans*=(cur+1),ans%=mod,cur--;
        cur++;
    }
    while(cur>0)ans*=cur,ans%=mod,cur--;
    cout<<ans;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n, m;
  cin >> n >> m;

  vll num(n, 1);
  vector<bool> red(n, false);
  red[0] = true;
  REP(i, m){
    ll x, y;
    cin >> x >> y;
    x--;
    y--;
    if(red[x])
      red[y] = true;

    num[x]--;
    num[y]++;
    if(num[x] == 0)
      red[x] = false;
  }


  ll ans = 0;
  REP(i, n){
    if(red[i])
      ans++;
  }


  cout << ans << endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
	int n;
	cin >> n;
	ll A, B;
	for (int i=0;i<n;i++){
		cin >> A >> B;
		if (A>B) swap(A, B);
		ll C = (ll)sqrt(A*B);
		if (A*B==C*C) C--;
		if(A==B){
			cout << 2*A-2 << endl;
		}else if(A+1==B){
			cout << 2*A-2 << endl;
		}else if(C*(C+1)>=A*B){
			cout << 2*C-2 << endl;
		}else{
			cout << 2*C-1 << endl;
		}
	}
    return 0;
}

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

using namespace std;
 
 


//c++ templte for help............................................................................................................................................



typedef long long ll;

template<typename... T>
void print1(T... t){
	((cout<<t<<" "),...);
}

template<typename... T>
void print2(T... t){
		vector<vector<ll>> ans={t...};
		for(ll i=0;i<(ll)ans.size();i++){
			if(i!=0) cout<<"\t\t";
			else cout<<"\t";
			for(ll j=0;j<(ll)ans[i].size();j++){
				cout<<ans[i][j]<<" ";
			}
			if(i!=(ll)ans.size()-1)
			cout<<endl;
		}
}	
#define deb(...) cout<<" [ "#__VA_ARGS__<<" : "; print1(__VA_ARGS__); cout<<"]"<<endl; 
#define vdeb(...) cout<<" [ "#__VA_ARGS__<<" : "; print2(__VA_ARGS__); cout<<"]"<<endl;


 
//c++ template for help...........................................................................................................................................


string  solve(){
	string s;
	cin>>s;
	
	ll ans=0;
	for(ll i=0;i<(ll)s.size();i++){
		ans+=s[i]-'0';
	}
	
	if(ans%9==0) return "Yes";
	return "No";
}

int main() {
	//stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	//ofstream myfile;
	//myfile.open("output.txt");
	

	//ll testCase;
	//cin>>testCase;
	//for(ll tt=0;tt<testCase;tt++){
		//solve();
		string ans=solve();
		cout<<ans<<endl;
	//}
	//myfile.close();
	return 0;
}


Measured memory_bytes: 3752
import Data.Bool (bool)
import Data.Char (isDigit)
import Data.List (splitAt)

main :: IO ()
main = do
    [a,_] <- readInts
    s <- getLine
    putStrLn $ solve a s

readInts :: IO [Int]
readInts = map read . words <$> getLine

solve :: Int -> String -> String
solve a = toAnswer . valid a

toAnswer :: Bool -> String
toAnswer = bool "No" "Yes"

valid :: Int -> String -> Bool
valid a s = all isDigit l && c == '-' && all isDigit r
  where
    (l,(c:r)) = splitAt a s


Measured memory_bytes: 508
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(
            new InputStreamReader(System.in)); 
        String[] input = br.readLine().split(" ");
        int n = Integer.parseInt(input[0]);
        int m = Integer.parseInt(input[1]);
    
       String[][] imageA = new String[n][n];
       String[][] imageB = new String[m][m];

       for(int i = 0; i < n; i++){
        imageA[i] =br.readLine().split("");
       }
       for(int i = 0; i < m; i++){
        imageB[i] =br.readLine().split("");
       }
       boolean result = false;
       for(int i = 0; i <= n-m; i++){
            for(int j = 0; j<=n-m; j++){

                boolean isSame = true;
                for(int k=0; k<m; k++){
                    for(int l =0; l<m; l++){
                        if(imageA[i+k][j+l].equals(imageB[k][l])){
                            continue;
                        }else{
                            isSame = false;
                        }
                    }
                }
                result = result||isSame;
            }
       }
       if(result){
        System.out.println("Yes");
       }else{
        System.out.println("No");
       }
       br.close();
    }
}

Measured memory_bytes: 23636
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());

        var e = N / 2;
        var o = N / 2 + N % 2;

        var total = e + o;
        var ans = (double)o / (double)total;

        WriteLine(ans);
    }
}


Measured memory_bytes: 27568
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n:usize = sc.read();
    let x:usize = sc.read();
    let v:Vec<usize> = (0..n).map(|_| {
        let y:usize = sc.read();
        if y > x {
            y - x
        }else {
            x - y 
        }
    }).collect();
    let ans = v.iter().fold(v[0],|x,y|gcd(x,*y));
    println!("{}", ans);
}
///a と b の最大公約数を求める
fn gcd(a: usize, b: usize) -> usize {
    if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}

use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
 
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const ll INF=9e18;
int T,cnt;
ll n,a,b,c,d;
map<ll,ll> M;
ll solve(ll x) {
	if (M[x]) return M[x];
	if (!x) return M[x]=0;
	M[x]=INF;
	if (x<INF/d) M[x]=x*d;
	if (x%2==0) M[x]=min(M[x],solve(x/2)+a);
	else M[x]=min(M[x],min(solve(x/2),solve(x/2+1))+a+d);
	ll y;
	if (x%3==0) M[x]=min(M[x],solve(x/3)+b);
	else {
		y=x/3;
		M[x]=min(M[x],min(solve(y)+(x%3)*d,solve(y+1)+(3-x%3)*d)+b);
	}
	if (x%5==0) M[x]=min(M[x],solve(x/5)+c);
	else {
		y=x/5;
		M[x]=min(M[x],min(solve(y)+(x%5)*d,solve(y+1)+(5-x%5)*d)+c);
	}
	cnt++;
	return M[x];
}
int main() {
	//freopen("1.txt","r",stdin);
	read(T);
	while (T--) {
		M.clear();
		read(n); read(a); read(b); read(c); read(d);
		cnt=0;
		printf("%lld\n",solve(n));
		//printf("cnt=%d\n",cnt);
	}
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 4620
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n,a,b;
  std::cin >> n >> a >> b;

  int ans = 0;
  rep(plas, n+1) {
    int tmp = plas, cnt = 0;
    while(tmp > 0) {
      cnt += tmp%10;
      tmp /= 10;
    }
    if(cnt >= a && cnt <= b)
      ans += plas;
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
from collections import deque
k=int(input())
d=deque([1,2,3,4,5,6,7,8,9])
for i in range(k):
  x=d.popleft()
  if x%10!=0:
    d.append(10*x+x%10-1)
  d.append(10*x+x%10)
  if x%10!=9:
    d.append(10*x+x%10+1)
print(x)


Measured memory_bytes: 11908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


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

    multiset<ll> a;
    for(int i = 0; i < n; i++){
        ll t;
        cin >> t;
        a.insert(t);
    }
    for(int i = 0; i < m; i++){
        a.insert(*(--a.end())/2);
        a.erase(--a.end());
    }
    ll ans = 0;
    for(auto x:a){
        ans += x;
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 4992
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
from itertools import accumulate
n,c=map(int,input().split())
X,V=[],[]
for _ in range(n):
    x,v=map(int, input().split())
    X.append(x)
    V.append(v)
V_ret,X_ret=V[::-1],X[::-1]
S,S_ret=list(accumulate(V)),list(accumulate(V_ret))
S[0]-=X[0]
S_ret[0]-=(c-X_ret[0])
for i in range(1,n):
    S[i]=max(S[i-1],S[i]-X[i])
    S_ret[i]=max(S_ret[i-1],S_ret[i]-(c-X_ret[i]))
ans=max(0,max(S),max(S_ret))
for i in range(n-1):
    tmp1=S[i]+S_ret[n-(i+2)]-X[i]
    tmp2=S_ret[i]+S[n-(i+2)]-(c-X_ret[i])
    ans=max(ans,tmp1,tmp2)
print(ans)

Measured memory_bytes: 22260
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    int n;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++)
        cin>>ar[i];
    int nextS[n];
    int preS[n];
    stack<int> s;
    preS[0]=-1;
    s.push(0);
    for(int i=1;i<n;i++)
    {
        while(!s.empty() && ar[i]<=ar[s.top()])
            s.pop();
        if(s.empty())
            preS[i]=-1;
        else
            preS[i]=s.top();
        s.push(i);
    }
    while(!s.empty())
        s.pop();
    nextS[n-1]=n;
    s.push(n-1);
    for(int i=n-2;i>=0;i--)
    {
        while(!s.empty() && ar[i]<ar[s.top()])
            s.pop();
        if(s.empty())
            nextS[i]=n;
        else
            nextS[i]=s.top();
        s.push(i);
    }
    long long ans=0;
    for(int i=0;i<n;i++)
    {
        long long p=(i-preS[i])*ar[i]*(nextS[i]-i);
        ans+=p;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 6528
import java.io.*;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            String line;
            int index = 1;
            while((line = br.readLine()) != null){
                if(line.equals("0")){
                	break;
                }
                System.out.println("Case " + index + ": " + line);
                ++index;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 33440
#include <bits/stdc++.h>
#define fastio (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastio;
    string s;
    cin >> s;
    cout << count(s.begin(), s.end(), '1') << endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	string s = to_string(N);
	int sum = 0;
	rep(i, s.size()) {
		sum += s[i]-'0';
	}
	if (N%sum == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  long long K;
  cin >> S >> K;
  
  long long length;
  long long size;
  
  size = S.size();
  
  length = min(K,size);
  
  long long counter = 0;
  
  for (int i = 0; i < length; i++) {
    if (S.at(i) != '1') {
      break;
    }
    counter++;
    if (i == length-1) {
      counter--;
    }
  }
  
    cout << S.at(counter) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
    int n,w;
    cin >> n >> w;
    vector<int> wei(n);
    vector<int> val(n);
    for(int i=0;i<n;i++){
        int x,y;
        cin >> x >> y;
        wei[i]=x;
        val[i]=y;
    }
    vector<vector<long long>> dp(n+1,vector<long long>(w+1,0));
    
    for(int i=1;i<n+1;i++){
        for(int j=0;j<w+1;j++){
            if(wei[i-1]+j<=w){
                dp[i][wei[i-1]+j] = dp[i-1][j]+val[i-1];
             //   cout<<i<<" "<<wei[i-1]+j<<" "<<dp[i-1][j]<<" "<<val[i-1]<<endl;
            }
            dp[i][j]=max(dp[i-1][j],dp[i][j]);
            
        }
    }
   // cout<<dp[2][3]<<endl;
    cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 80256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) { //No MLE!
		Scanner input = new Scanner(System.in);
		int N = input.nextInt(); 
		long[][] dp;
		long[] arr = new long[N];
		for (int i = 0; i < N; i++) {
			arr[i] = input.nextLong();
		}
		if (N%2==0) {
			dp = new long[N/2][2];
			for (int i = 0; i < N/2; i++) {
				for (int j = 0; j < 2; j++) {
					if (i==0&&j==0) {
						dp[i][j] = arr[i*2+j];
					}
					else if (j==0) {
						dp[i][j] = dp[i-1][j]+arr[i*2];
					}
					else if (i>0){
						dp[i][j] = dp[i][j-1];
						long curNum = arr[i*2+1];
						dp[i][j] = Math.max(dp[i][j], curNum+dp[i-1][j]);
					}else if (i==0) {
						dp[i][j] = Math.max(dp[i][j-1],arr[i*2+1]);
					}	
				}
			}
			/*for (int i = 0; i < N/2; i++) {
				for (int j = 0; j < 2; j++) {
					System.out.print(dp[i][j]+" ");
				}
				System.out.print("\n");
			}*/
			System.out.println(dp[N/2-1][1]);
		}
		else {
			dp = new long[N/2][3];
			for (int i = 0; i < N/2; i++) {
				for (int j = 0; j < 3; j++) {
					if (j==0&&i==0) dp[i][j] = dp[i][j] = arr[0];
					else if (j==0) {
						dp[i][j] = dp[i-1][j]+arr[i*2];
					}
					else if (i==0){
						dp[i][j] = Math.max(dp[i][j-1],arr[i*2+j]);
					}else if (i>0) {
						dp[i][j] = dp[i][j-1];
						long curNum = arr[i*2+j];
						dp[i][j] = Math.max(dp[i][j], dp[i-1][j]+curNum);
					}
				}
			}
			/*for (int i = 0; i < N/2; i++) {
				for (int j = 0; j < 3; j++) {
					System.out.print(dp[i][j]+" ");
				}
				System.out.print("\n");
			}*/
			System.out.println(dp[N/2-1][2]);
		}
	}
}

Measured memory_bytes: 55212
N,H = map(int,input().split())

a_max = 0
b_list = []
count=0

for _ in range(N):
	a, b = map(int, input().split())
	a_max = max(a,a_max)
	b_list.append(b)

b_list.sort(reverse=True)

for b in b_list:
	if b > a_max:
		H -= b
		count += 1
	else:
		break
	if H <= 0:
		print(count)
		exit()

print((H-1)//a_max + 1 +count)



Measured memory_bytes: 7388
#include<stdio.h>
int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    while(a>b||b>c){
        if(a>b){
            int bowl;
            bowl=b;
            b=a;
            a=bowl;
        }
        if(b>c){
            int bowl;
            bowl=c;
            c=b;
            b=bowl;
        }
    }
    printf("%d %d %d\n",a,b,c);
}


Measured memory_bytes: 2148
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int get_gcd(int n, int m) {
	if (n < m) swap(n, m);
	while (m) {
		swap(n, m);
		m %= n;
	}
	return n;
}

int N, M;
int A[100010];

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

	cin >> N >> M;
	int mul = 1;
	bool ok[2] = { false };
	bool out = false;
	rep(i, 0, N)
	{
		cin >> A[i];
		mul = mul / get_gcd(mul, A[i]/2)*A[i]/2;
		if (mul > M)out = true;
	}

	if (out)
	{
		cout << 0 << endl;
	}
	else
	{
		rep(i, 0, N)
		{
			if (mul%A[i] == 0)
			{
				cout << 0 << endl;
				return 0;
			}
		}
		cout << 1 + (M - mul) / (2 * mul) << endl;
	}

	return 0;
}

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

inline int mul(int a, int b) { return (1ll * a * b) % M; };
inline int add(int a, int b)
{
      if ( a + b < 0 ) return a + b + M;
      if ( a + b >= M) return a + b - M;
      return a + b;
}


void solve()
{
      int n;
      cin >> n;
      int arr[n];

      vector<int> pre(n + 1, 0);

      lop(i, 0, n) cin >> arr[i];

      pre[n - 1] = arr[n - 1];
      rlop(i, n - 2, 0) pre[i] = arr[i] + pre[i + 1];

      int ans = 0;

      lop(i, 0, n - 1)
      {
            pre[i + 1] %= M;
            arr[i] %= M;
            int a1 = mul(arr[i], pre[i + 1]);
            ans = add(ans, a1);
      }

      cout << ans << endl;

}

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

      int test = 1;
      // cin >> test;
      while (test--)solve();


}





















Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
#define print printf("==================\n")
#define ll long long
#define pi acos(-1.0)
#define eps 1e-16
#define max3(a,b,c) max(a,max(b,c))
#define mod 1000000007
const ll INF = 1 << 30;
#define mod 1000000007
typedef pair<double, double  > payar;
typedef struct
{
    ll  x, y;
} point;
priority_queue<payar, vector<payar>,  greater<payar> > pq; ///accending
vector< pair<double,payar  > > vpp;
vector < payar >  vp;
string  num;
ll a, b, d, k;
ll DP[10005][105][2];

ll call(ll pos, ll sum, int flag )
{


    if(pos==num.size())
    {

        ll p = sum%d;
        if(p%d==0)
            return 1;

        else
            return 0;
    }

    if(DP[pos][sum][flag] !=-1 )
    {
        return DP[pos][sum][flag] ;
    }

    ll res = 0 ;

    ll lim;

    if(flag==0)
    {
        lim = num[pos]-48;
    }
    else
    {
        lim = 9;
    }
    for(int dgt = 0 ; dgt <=lim ; dgt++)
    {
        ll nf=flag ;
        ll cn=sum%d;
        if(flag==0 and dgt<lim)
            nf=1;
        cn+=dgt;
        cn=cn%d;


        res= (res%mod+call(pos+1,cn,nf))%mod;

    }
    return DP[pos][sum][flag] = res;

}



ll solve()
{

    memset(DP, -1, sizeof(DP));
    ll res = call(0, 0, 0);
    return res;
}

int main ()
{
    getline(cin, num);
    cin>>d;
    ll res = solve();

    cout << (res%mod-1 +mod)%mod << endl;


    return 0;
}


Measured memory_bytes: 17664
#include <iostream>

using namespace std;

int main() {
    
    int n;
    cin >> n;
    
    int ac = 0, wa = 0, tle = 0, re = 0;
    
    string s;
    for (int i = 0; i < n; i++) {
        cin >> s;
        if (s[0] == 'A') {
            ac++;
        }
        if (s[0] == 'R') {
            re++;
        }
        if (s[0] == 'W') {
            wa++;
        }
        if (s[0] == 'T') {
            tle++;
        }
    }
    std::cout << "AC x " << ac << std::endl;
    std::cout << "WA x " << wa << std::endl;
    std::cout << "TLE x " << tle << std::endl;
    std::cout << "RE x " << re << std::endl;
    
    
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

const int MAX = 1e5;
pii table[18][MAX * 2 - 1];

int n;
vector<int> G[MAX];
int id[MAX];

int it = 0;

void dfs(int v, int d) {
	id[v] = it;
	table[0][it++] = { d, v };
	for (auto to : G[v]) {
		dfs(to, d + 1);
		table[0][it++] = { d, v };
	}
}

void init() {
	dfs(0, 0);
	int m = (n << 1) - 1;
	int h = 31 - __builtin_clz(m);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j + (1 << i) < m; j++) {
			table[i + 1][j] = min(table[i][j], table[i][j + (1 << i)]);
		}
	}
}

int lca(int u, int v) {
	u = id[u], v = id[v];
	if (u > v) swap(u, v);
	int b = 31 - __builtin_clz(v + 1 - u);
	return min(table[b][u], table[b][v + 1 - (1 << b)]).second;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int c;
			cin >> c;
			G[i].push_back(c);
		}
	}
	init();
	int q;
	cin >> q;
	while (q--) {
		int u, v;
		cin >> u >> v;
		printf("%d\n", lca(u, v));
	}
	return 0;
}



Measured memory_bytes: 40852
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int a[3][3], c[3][3];
    rep(i, 3)rep(j, 3){
        cin >> a[i][j];
        c[i][j] = 0;
    }
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i, n){
        cin >> b.at(i);
        rep(j, 3)rep(k, 3){
            if(a[j][k] == b.at(i))c[j][k] = 1;
        }
    }
    bool ok = false;
    rep(i, 3){
        if(c[i][0] == 1 && c[i][1] == 1 && c[i][2] == 1)ok = true;
        if(c[0][i] == 1 && c[1][i] == 1 && c[2][i] == 1)ok = true;
    }
    if(c[0][0] == 1 && c[1][1] == 1 && c[2][2] == 1)ok = true;
    if(c[0][2] == 1 && c[1][1] == 1 && c[2][0] == 1)ok = true;
    if(ok)cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define EPS 1e-9
#define INF  1e15 +1    /// 10^15 + 1
#define INF2 ((ll)1)<<63 /// 2^63
#define all(a)  a.begin(),a.end()
#define bit(i,j) ((i)&((ll)1<<j))
#define setbit(i,j) ((i)|((ll)1<<j))
#define forn(i,n) for(int i=0;i<n;i++)
#define fo(i,a,b) for(int i=a;i<b;i++)
#define dbg(x) cout << #x"=" << x << '\n';
#define dbg2(x,y) cout << #x"=" << x << " " << #y"=" << y << '\n';
#define dbg3(x,y,z) cout << #x"=" << x << " " << #y"=" << y << " " << #z"=" << z << '\n';
const int MOD = 1000000007;
const int mod = 998244353;
const int nala5 = 1e5 +5;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector < vi > vvi;
typedef vector < vll > vvll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector < pii > vpii;
typedef vector < pll > vpll;
typedef vector < vpii > vvpii;
typedef vector < vpll > vvpll;
typedef vector < set <int> > vsi;
typedef vector < set <ll> > vsll;

int n,m,a,b,res;
vvi adj;
int dp[nala5], vis[nala5], degree[nala5];

void dfs(int index){
    vis[index] = 1;
    for(int i=0;i<adj[index].size();i++){
        dp[adj[index][i]] = max(dp[adj[index][i]], dp[index] + 1);
        degree[adj[index][i]]--;
        if(!vis[adj[index][i]] && !degree[adj[index][i]]) dfs(adj[index][i]);
    }
}

int main(){
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
    cin>>n>>m;
    adj.resize(n);
    forn(i,m){
        cin>>a>>b;
        adj[a-1].pb(b-1);
        degree[b-1]++;
    }
    forn(i,n){
        if(!vis[i] && !degree[i]){
            dfs(i);
        }
    }
    forn(i,n) res = max(res,dp[i]);
    cout<<res<<'\n';
}	


Measured memory_bytes: 16016
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define lun(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<60);
const int inf=(1<<30);
const int nmax=1e5+50;
const ll mod=1e9+7;
using namespace std;
int n,nr;
ll x,y,d;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n>>d;
    d=d*d;
    while(n--)
    {
        cin>>x>>y;
        if(x*x+y*y<=d)nr++;
    }
    cout<<nr<<'\n';
	return 0;
}


Measured memory_bytes: 3584
N,M,c=map(int, input().split())
blist = list(map(int, input().split()))
s = 0
for n in range(N):
  l = []
  alist = list(map(int, input().split()))
  for m in range(M):
    l.append(blist[m] * alist[m])
  if sum(l) + c > 0:
    s += 1
print(s)

Measured memory_bytes: 3060
import sys

sys.setrecursionlimit(2147483647)

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
x = [(i, xy[i][0]) for i in range(n)]
y = [(i, xy[i][1]) for i in range(n)]

x.sort(key = lambda x:x[1])
y.sort(key = lambda x:x[1])

x_dif = [((x[i][0], x[i+1][0]), abs(x[i+1][1]-x[i][1])) for i in range(n-1)]
y_dif = [((y[i][0], y[i+1][0]), abs(y[i+1][1]-y[i][1])) for i in range(n-1)]

xy_dif = x_dif + y_dif
xy_dif.sort(key = lambda x:x[1])

p = [-1]*n

def root(x):
  if p[x]<0:
    return x
  p[x] = root(p[x])
  return p[x]

ans = 0
for ab, cost in xy_dif:
  a, b = ab
  #print(a, b, p[a], p[b], p)
  if root(a)!=root(b):
    p[root(a)] = root(b)
    ans += cost

print(ans)


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	string n;
	cin >> n;
	for (int i = 0; i < n.size(); i++) {
		if (n[i] == '1') {
			cout << '9';
		} else if (n[i] == '9') {
			cout << '1';
		} else {
			cout << n[i];
		}
	}
	cout << endl;
	return 0;
}


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

using namespace std;

#define ll long long
#define ld long double

mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());

ll INF = (ll) 1e20;
int iINF = (int) 1e20;
ll mod = (ll) 1e9 + 7;

signed main() {
    ll n;
    cin >> n;
    ll ans00 = 1, ans01 = 0, ans10 = 0, ans11 = 0;
    for(int i = 0; i < n; ++i) {
        ll nwans00 = (ans00 * 8) % mod;
        ll nwans01 = (ans01 * 9 + ans00) % mod;
        ll nwans10 = (ans10 * 9 + ans00) % mod;
        ll nwans11 = (ans10 + ans01 + ans11 * 10) % mod;
        ans00 = nwans00;
        ans01 = nwans01;
        ans10 = nwans10;
        ans11 = nwans11;
//        cout << ans00 << ' ' << ans01 << ' ' << ans10 << ' ' << ans11 << '\n';
    }
    cout << ans11;
}

Measured memory_bytes: 3636
import java.text.ParseException;
import java.util.Scanner;

public class Main {

	public static void main(String[] arges) throws ParseException {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String line2 = sc.nextLine();

		String[] k = line.split(" ");
		String[] k2 = line2.split(" ");
		Daice daice1 = new Daice(Integer.parseInt(k[0]),
				Integer.parseInt(k[1]), Integer.parseInt(k[2]),
				Integer.parseInt(k[3]), Integer.parseInt(k[4]),
				Integer.parseInt(k[5]));
		Daice daice2 = new Daice(Integer.parseInt(k2[0]),
				Integer.parseInt(k2[1]), Integer.parseInt(k2[2]),
				Integer.parseInt(k2[3]), Integer.parseInt(k2[4]),
				Integer.parseInt(k2[5]));
		for (int i = 0; i < 4; i++) {
			daice2.south();
			if (daice1.f1 == daice2.f1) {
				break;
			}
			if (i == 3) {
				daice2.west();
			}
		}
		for (int i = 0; i < 4; i++) {
			if (daice1.f1 == daice2.f1) {
				break;
			}daice2.south();
			
		}
		if (daice1.f1 != daice2.f1) {
			System.out.println("No");
		} else {
			for (int i = 0; i < 4; i++) {
				daice2.kaiten();
				if (daice1.f2 == daice2.f2) {
					break;
				}
			}
			if (daice1.f1 == daice2.f1 && daice1.f2 == daice2.f2
					&& daice1.f3 == daice2.f3 && daice1.f4 == daice2.f4
					&& daice1.f5 == daice2.f5 && daice1.f6 == daice2.f6) {
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}
	}

	public static class Daice {
		int f1;
		int f2;
		int f3;
		int f4;
		int f5;
		int f6;

		public Daice(int f1, int f2, int f3, int f4, int f5, int f6) {
			super();
			this.f1 = f1;
			this.f2 = f2;
			this.f3 = f3;
			this.f4 = f4;
			this.f5 = f5;
			this.f6 = f6;
		}

		public void south() {
			int[] fs = new int[] { f1, f2, f3, f4, f5, f6 };
			f6 = fs[1];
			f2 = fs[0];
			f1 = fs[4];
			f5 = fs[5];

		}

		public void west() {
			int[] fs = new int[] { f1, f2, f3, f4, f5, f6 };
			f6 = fs[3];
			f3 = fs[5];
			f1 = fs[2];
			f4 = fs[0];

		}

		public void kaiten() {
			int[] fs = new int[] { f1, f2, f3, f4, f5, f6 };
			f2 = fs[3];
			f3 = fs[1];
			f4 = fs[4];
			f5 = fs[2];
		}

	}
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n+1, -1);
    int s, c;
    for (int i = 0; i < m; ++i) {
        cin >> s >> c;
        if (a[s] != -1 && a[s] != c) {
            cout << -1 << endl;
            return 0;
        }
        a[s] = c;
    }
    if (n > 1 && a[1] == 0) {
        cout << -1 << endl;
        return 0;
    }
    if (n == 1 && a[1] == -1) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 0; i < n; ++i) {
        if (i == 0 && a[i+1] == -1) a[i+1] = 1;
        else if (a[i+1] == -1) a[i+1] = 0;
    }
    for (int i = 0; i < n; ++i) {
        cout << a[i+1];
    }
    cout << endl;
}

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

char a, b;

int main() {
  cin >> a >> b;
  int ia = a - '0';
  int ib = b - '0';
  if (a < b) {
    for (int i = 0; i < ib; ++i) {
      cout << a;
    }
    cout << endl;
  } else {
    for (int i = 0; i < ia; ++i) {
      cout << b;
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
import sys
import bisect
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()
LS = LI()
LS.sort()

res = 0
for i in range(N):
    for j in range(i+1,N):
        upper = LS[i]+LS[j]
        lower = abs(LS[i]-LS[j])

        ui = bisect.bisect_left(LS, upper, j+1)
        li = bisect.bisect_left(LS, lower+1, j+1)
        num = ui-li
        res += num
print(res)


Measured memory_bytes: 47324
#include<iostream>
#include<map>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    ll x;
    cin >> x;
    map<ll,int> m;
    for(ll i = 2; i*i <= x; i++){
        while(x%i == 0) m[i]++, x /= i;
    }
    if(x-1) m[x]++;
    ll ret = 1;
    for(auto p : m){
        ll val = p.first, tim = p.second;
        while(tim >= n){
            ret *= p.first;
            tim -= n;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<string>

#define ll long long
using namespace std;
#define MAX 100000



int N, A[2][MAX],  x;

int main()
{
	cin >> N;
	for(int i=0; i<MAX; ++i)
		A[0][i]=0;
	for(int i=0; i<MAX; ++i)
		A[1][i]=0;
	for(int i=0; i<N; ++i)
	{
		cin>>x;
		++A[i%2][x-1];
	}
	int a1 = max_element(A[0],A[0]+MAX)-A[0];
	int a2 = max_element(A[1],A[1]+MAX)-A[1];
	int x1 = A[0][a1];
	int x2 = A[1][a2];
	if(a1==a2)
	{
		A[0][a1]=0;
		A[1][a2]=0;
		int y1 = *max_element(A[0],A[0]+MAX);
		int y2 = *max_element(A[1],A[1]+MAX);
		if(x1+y2>x2+y1)
			x2=y2;
		else
			x1=y1;
	}
	cout<<N-x1-x2<<endl;
	return 0;
}


Measured memory_bytes: 1024
score = int(input())
souwa = int((score*(score+1))/2)
kou3 = score//3
souwa3 = int((kou3*(kou3+1)*3)/2)
kou5 = score//5
souwa5 = int((kou5*(kou5+1)*5)/2)
kou15 = score//15
souwa15 = int((kou15*(kou15+1)*15)/2)
answer = souwa-souwa3-souwa5+souwa15
print(answer)

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

public class Hello
{
    public static void Main()
    {
        hoge();
        System.Console.ReadLine();
    }

    public static void hoge()
    {
        var line = System.Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        var nums = System.Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        var min = long.MaxValue;
        var ans = 0;
        for(int i = 0; i < nums.Count(); i++)
        {
            if(min >= nums[i])
            {
                ans++;
                min = nums[i];
            }
        }
        System.Console.WriteLine(ans);
    }
}



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

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

    int n;
    cin >> n;

    int arr[n][3];
    for (int i = 0; i < n; i++) {
        cin >> arr[i][0];
        cin >> arr[i][1];
        cin >> arr[i][2];
    }

    int dp[n][3];
    dp[n - 1][0] = arr[n - 1][0];
    dp[n - 1][1] = arr[n - 1][1];
    dp[n - 1][2] = arr[n - 1][2];

    for (int i = n - 2; i >= 0; i--) {
        for (int j = 0; j < 3; j++) {
            int maximum = INT_MIN;
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                maximum = max(maximum, arr[i][j] + dp[i + 1][k]);
            }
            dp[i][j] = maximum;
        }
    }

    cout << max(dp[0][0], max(dp[0][1], dp[0][2]));

}


Measured memory_bytes: 2688
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
mod = 998244353
N,S = map(int,readline().split())
A = list(map(int,readline().split()))
dp = [[0 for _ in range(S+1)] for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
  for j in range(S+1):
    dp[i+1][j] += 2*dp[i][j]
    dp[i+1][j] %= mod
    if j + A[i] <=S:
      dp[i+1][j+A[i]] += dp[i][j]
      dp[i+1][j+A[i]] %= mod
print(dp[N][S]%mod)

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

using namespace std;
const int N = 110;
int _w;

int n;
char a[N], b[N];

bool check( int x ) {
	for( int i = 1; i <= x; ++i )
		if( a[n-x+i] != b[i] )
			return false;
	return true;
}

int main() {
	cin >> n >> (a+1) >> (b+1);
	for( int i = n; i >= 0; --i )
		if( check(i) ) {
			printf( "%d\n", n+n-i );
			break;
		}
	return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.bigint;
import std.typecons;
import std.algorithm;
import std.array;
import std.math;
import std.range;
 
void main() {
    auto R = readln.chomp.to!real;
    auto G = readln.chomp.to!real;
    writeln(G * 2 - R);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
int n,a,b;

int main() {
	read(n);read(a);read(b);
	printf("%d %d",min(a,b),max(a+b-n,0));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int A;
int B;
int X;
int main(){
  rd(A);
  rd(B);
  rd(X);
  if(A<=X && X<=A+B){
    wt_L("YES");
    wt_L('\n');
  }
  else{
    wt_L("NO");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int A, B, X;
// {
//   rd(A,B,X);
//   wt( if[A<=X<=A+B, "YES", "NO"] );
// }


Measured memory_bytes: 384