akhauriyash/Code-Regression huggingface dataset:
use std::io::BufRead;

#[derive(Debug, PartialEq, Eq, Clone, Copy)]
struct Pos { y: usize, x: usize }

fn main() {
    let stdin = std::io::stdin();

    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let (h, w) = to_pair(&buf);

    let mut map: Vec<Vec<u8>> = stdin.lock().lines().map(|l| l.unwrap().into_bytes()).collect();
    let mut stk: Vec<Pos> = Vec::new();
    for i in 0..h {
        for j in 0..w {
            if map[i][j] == b'#' {
                stk.push(Pos { y: i, x: j });
            }
        }
    }

    let mut cnt = 0;
    loop {
        let mut changed = false;
        let mut nx_stk = Vec::new();
        while let Some(pos) = stk.pop() {
            for &(dy, dx) in &[(1, 0), (-1, 0), (0, 1), (0, -1)] {
                let nx_y = pos.y as i32 + dy;
                let nx_x = pos.x as i32 + dx;
                if nx_y < h as i32 && nx_y >= 0 && nx_x < w as i32 && nx_x >= 0
                    && map[nx_y as usize][nx_x as usize] == b'.' {
                    changed = true;
                    map[nx_y as usize][nx_x as usize] = b'#';
                    nx_stk.push(Pos { y: nx_y as usize, x: nx_x as usize});
                }
            }
        }
        if changed {
            cnt += 1;
            stk = nx_stk;
        } else {
            break;
        }
        // println!("cnt: {}", cnt);
        // print_map(&map);
    }

    println!("{}", cnt);
}

// fn print_map(map: &Vec<Vec<u8>>) {
//     for v in map.iter() {
//         println!("{}", std::str::from_utf8(v).unwrap());
//     }
// }

fn to_pair(s: &str) -> (usize, usize) {
    let v: Vec<usize> = s.split_whitespace().map(|w| w.parse().unwrap()).collect();
    let (l, r) = (v[0], v[1]);
    (l, r)
}


Measured memory_bytes: 22772
#include <cstdio>

using namespace std;

int main(){

  while(1){


  int ans = 0;

  int n;

  scanf("%d",&n);

  if(n == 0) break;

  n = 1000 - n;

  int k[7] = {500,100,50,10,5,1};

  for(int i = 0;i < 6;i++){
    if(n == 0) break;
    ans += n / k[i];
    n = n % k[i];
  }

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

  }

  return 0;

}


Measured memory_bytes: 1028
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

template <class T>
inline bool chmin(T& a, T b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main(int argc, char const* argv[])
{
    const int SIZE = 1e5 + 10;

    int N;
    ll h[SIZE];
    ll dp[SIZE];

    cin >> N;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> h[i];
    }
    for (int i = 0; i < SIZE; i++) {
        dp[i] = INF;
    }
    dp[0] = 0;

    for (int i = 0; i < N; i++) {
        chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }
    cout << dp[N - 1] << "\n";
    return 0;
}


Measured memory_bytes: 1792
import sys
input=sys.stdin.readline
n=int(input())
a=[int(input()) for _ in range(n)]
if a[0]!=0:
    print(-1)
    exit()

ans=0
for i in range(1,n):
    if a[i]>a[i-1]+1:
        print(-1)
        exit()
    if a[i]<=a[i-1]:
        ans+=a[i-1]
ans+=a[n-1]

print(ans)


Measured memory_bytes: 50396
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b, c) for (int i = (a); i <= (b); i += (c))
#define FORD(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define FORl(i, a, b, c) for (ll i = (a); i <= (b); i += (c))
#define FORDl(i, a, b, c) for (ll i = (a); i >= (b); i -= (c))
using namespace std;
int main () {
	int n, k;
	scanf("%d %d", &n, &k);
	int a = n / k;
	ll ans = 1LL * a * a * a;
	if (k % 2 == 0 && n >= k / 2) {
		int b = (n - k / 2) / k + 1;
		ans += 1LL * b * b * b;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int gcd(int a,int b){
	if(a < b) swap(a,b);
	if(!b) return a;
	return gcd(b,a % b);
}

signed main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	c -= a;
	d -= b;
	if(c < 0) c = -c;
	if(d < 0) d = -d;
	cout << c + d - gcd(c,d) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,K,X,Y; cin >> N >> K >> X >> Y;
    int res =0;
    if(N>K){
        for(int i=0; i<K; ++i) {
            res += X;
        }
        for(int i =0; i<N-K; ++i) {
            res += Y;
        }
    }else{
        for(int i=0; i<N; i++) {
            res += X;
        }
    }
    cout << res << endl;
    
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ll long long

using namespace std;

int main(void)
{
	ll a, b;
	cin >> a >> b;
	if (b % a == 0){
		cout << a+b << endl;
	}else{
		cout << b-a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*
 * src.cpp
 *
 *  Created on: 2016/07/26
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

double a[50];

int main(){
	int i=0;
	while (scanf("%lf",&a[i])!=EOF){
		i++;
	}
	sort(a,a+i);
	cout<<a[i-1]-a[0]<<endl;
	return 0;
}

Measured memory_bytes: 1296
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll r;
  cin >> r;
  string ans;
  if(r < 1200)
    ans = "ABC";
  else if(r < 2800)
    ans = "ARC";
  else
    ans = "AGC";
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
	fast;
	lli x,n;
	cin>>x>>n;
	lli a[n],i;
	map<lli,lli>m;
	fr(i,n)
	{
		cin>>a[i];
		m[a[i]]=1;
	}
	lli mini=mod,ans;
	for(i=-1;i<=101;i++)
	{
		if(m[i]==0&&abs(i-x)<mini)
		{
			mini=abs(i-x);
			ans=i;
		}
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

ll C[2010][2010]={};
void comb(int x,int y){
	C[x][y]=(C[x-1][y-1]+C[x-1][y])%inf;
}

int main(){
	rep(i,0,2010)C[i][0]=1;
	C[1][1]=1;
	rep(i,2,2001)rep(j,1,i+1){
		if(i==j)C[i][j]=1;
		else comb(i,j);
	}
	int n,k;
	cin>>n>>k;
	print(n-k+1);
	int r=n-k;
	rep(i,2,k+1){
		if(i>k)break;
		ll ans=C[r+1][i]*C[k-1][i-1]%inf;
		print(ans);
	}
}

Measured memory_bytes: 30336
N, A, B = list(map(int, input().split()))
S = input()

total = 0
overseas = 0

for si in S:
    if si == 'c':
        print('No')
    elif si == 'a':
        if total < A + B:
            total += 1
            print('Yes')
        else:
            print('No')
    else:
        if total < A + B and overseas + 1 <= B:
            total += 1
            overseas += 1
            print('Yes')
        else:
            print('No')


Measured memory_bytes: 4016
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n,m;
	cin >> n >> m;
	ll a[1010][3] = {0};
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 3; j++){
			cin >> a[i][j];
		}
	}

	ll ans = -(1ll<<60);
	for(int i = 0; i < 8; i++){
		vector<ll> vec;
		for(int j = 0; j < n; j++){
			ll s = 0;
			for(int k = 0; k < 3; k++){
				if(((i+1)/(1<<k)) % 2 == 0) s += a[j][k];
				else s -= a[j][k];
			}
			vec.push_back(s);
		}
		sort(all(vec));
		reverse(all(vec));
		ll sum = 0;
		for(int j = 0; j < m; j++){
			sum += vec[j];
		}
		ans = max(sum,ans);
	}

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long double EPS=1e-10;

template<typename T>
struct BinaryIndexedTree{
    vector<T> dat;
    BinaryIndexedTree(int n):dat(n+1,0){}
    void add(int i,T x){
        if (i==0) return;
        for (;i<=dat.size();i+=(i&-i)) dat[i]+=x;
    }
    T sum(int i){
        T res=0;
        for (;i>0;i-=(i&-i)) res+=dat[i];
        return res;
    }
    T query(int l,int r){ //[l,r)
        return sum(r-1)-sum(l-1);
    }
    int lower_bound(T x){
        if (x<=0) return 0;
        int lb=0,r=1;
        while(r<dat.size()) r<<=1;
        for (;r>0;r>>=1){
            if (lb+r<dat.size()&&dat[lb+r]<x){
                x-=dat[lb+r]; lb+=r;
            }
        }
        return lb+1;
    }
    void add0(int i,T x){add(i+1,x);}
    T sum0(int i){return sum(i+1);}
    T query0(int l,int r){return sum(r)-sum(l);}
};

template<typename T> vector<T> compress(vector<T> v){
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    return v;
}

template<typename T> vector<int> dict(vector<T> v){
    vector<T> cv=compress(v);
    int n=v.size();
    vector<int> res(n);
    for (int i=0;i<n;++i)
        res[i]=lower_bound(cv.begin(),cv.end(),v[i])-cv.begin();
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    struct Line{
        long double A,B,C;
        Line(long double A,long double B,long double C):A(A),B(B),C(C){}
    };
    vector<Line> ls;
    for (int i=0;i<N;++i){
        long double A,B,C; cin >> A >> B >> C;
        ls.emplace_back(A,B,C);
    }
    vector<long double> ans(2);
    int half=(N*(N-1)/2+1)/2;
    for (int _=0;_<2;++_){
        sort(ls.begin(),ls.end(),[](Line a,Line b){
            return a.A/a.B<b.A/b.B;
        });
        vector<long double> X(N);
        set<long double> posX,negX;
        long double lb=-1e9,ub=1e9;
        while(ub-lb>EPS){
            long double mid=(ub+lb)/2.0;
            int cnt=0,sum=0;
            for (int i=0;i<N;++i){
                long double A=ls[i].A,B=ls[i].B,C=ls[i].C;
                X[i]=C/B-A/B*mid;
            }
            vector<int> cX=dict(X);
            BinaryIndexedTree<int> pos(N+1),neg(N+1),neg0(N+1);
            for (int i=N-1;i>=0;--i){
                if (ls[i].B>0){
                    cnt+=pos.sum0(cX[i]);
                    cnt+=neg.sum0(cX[i]);
                    pos.add0(cX[i],1);
                } else {
                    cnt+=neg.sum0(cX[i]);
                    neg.add0(cX[i],1);
                }
            }
            for (int i=0;i<N;++i){
                if (ls[i].B>0) cnt+=sum-(cX[i]>0?neg0.sum0(cX[i]-1):0);
                else neg0.add0(cX[i],1),++sum;
            }
            (cnt>=half?ub:lb)=mid;
        }
        ans[_]=ub;
        for (int i=0;i<N;++i) swap(ls[i].A,ls[i].B);
    }
    cout << fixed << setprecision(15);
    cout << ans[0] << ' ' << ans[1] << '\n';
}

Measured memory_bytes: 5360
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

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...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a;
	string S;
	cin >> a >> S;
	if (a >= 3200)cout << S << endl;
	else cout << "red" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    string S;  cin >> S;
    S.erase(S.begin()+S.size()-1);

    int l = S.size();
    int ans = 0;
    for (int i=1; i <= l/2; ++i) {
        if (S.substr(0, i) == S.substr(i, i)) {
            ans = 2 * i;
        }
    }

    print(ans);
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define LL long long;
#define ULL unsigned long long;
using namespace std;

char c;

int main() {
	cin>>c;
	cout<<(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'?"vowel":"consonant")<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc103/tasks/abc103_d

int main() {
    int N, M; cin >> N >> M;
    vector<P> ab(M);
    REP(i, M) {
        int a, b; cin >> a >> b;
        ab[i] = {b, a};
    }
    sort(ab.begin(), ab.end());

    int now = 0;
    int cnt = 0;
    REP(i, M) {
        int l = ab[i].second;
        int r = ab[i].first;
        if (now <= l) {
            now = r;
            cnt++;
        }
    }

    cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int N, T, A, X;
    cin >> N >> T >> A;
    int H[N];
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    double d, dx;
    d = (T - A)/0.006;
    X = 0;
    dx = fabs(d - H[0]);
    for(int i=1;i<N;i++){
        if(dx > fabs(d-H[i])){
            X = i;
            dx = fabs(d-H[i]);
        }
    }
    cout << X + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

int main(void)
{
    int n;
    string s;
    int i;

    cin >> n >> s;

    if (n % 2 == 1)
    {
        cout << "No" << endl;
        return 0;
    }

    rep(i, 0, n / 2)
    {
        if (s[i] != s[i + n / 2])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

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

int main(void){
    string b;
    cin >> b;
    for(int index = 0; b.size() > index; ++index){
        if(b[index]=='A'){
            cout << 'T';
        }else if(b[index]=='T'){
            cout << 'A';
        }else if(b[index]=='C'){
            cout << 'G';
        }else if(b[index]=='G'){
            cout << 'C';
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

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

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

type Sushi struct {
	x, v int
}

type Sushis []Sushi

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, c := nextInt(), nextInt()
	ss := make(Sushis, n)
	for i := range ss {
		x, v := nextInt(), nextInt()
		ss[i] = Sushi{x, v}
	}

	// 時計回り，反時計回り
	cal1, cal2 := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		var dx int
		if i > 0 {
			cal1[i] = cal1[i-1]
			dx = ss[i].x - ss[i-1].x
		} else {
			dx = ss[i].x
		}
		cal1[i] += ss[i].v - dx
	}
	for i := n - 1; i >= 0; i-- {
		var dx int
		if i < n-1 {
			cal2[i] = cal2[i+1]
			dx = ss[i+1].x - ss[i].x
		} else {
			dx = c - ss[i].x
		}
		cal2[i] += ss[i].v - dx
	}

	mx1, mx2 := make([]int, n), make([]int, n)
	mx1[0], mx2[n-1] = 0, n-1
	for i := 1; i < n; i++ {
		mx1[i] = mx1[i-1]
		if cal1[i] > cal1[mx1[i]] {
			mx1[i] = i
		}
	}
	for i := n - 2; i >= 0; i-- {
		mx2[i] = mx2[i+1]
		if cal2[i] > cal2[mx2[i]] {
			mx2[i] = i
		}
	}

	// 途中で折り返す場合
	turn1, turn2 := 0, 0
	for i := 0; i < n-1; i++ {
		cal := cal1[i] + cal2[mx2[i+1]] - ss[i].x
		turn1 = max(turn1, cal)
	}
	for i := n - 1; i > 0; i-- {
		cal := cal2[i] + cal1[mx1[i-1]] - (c - ss[i].x)
		turn2 = max(turn2, cal)
	}

	puts(max(max(cal1...), max(cal2...), turn1, turn2))
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
struct node
{
    int val,si,tot,fa,ch[2];
}t[N];
int tot,root;
void update(int x)
{
    if(x==0) return;
    t[x].si=t[t[x].ch[0]].si+t[t[x].ch[1]].si+t[x].tot;
}
void Rotate(int x)
{
    int y=t[x].fa,z=t[y].fa,k=t[y].ch[1]==x;
    t[y].ch[k]=t[x].ch[k^1];
    t[t[x].ch[k^1]].fa=y;
    t[x].ch[k^1]=y;
    t[y].fa=x;
    t[x].fa=z;
    t[z].ch[t[z].ch[1]==y]=x;
    update(y);update(x);update(z);
}
void splay(int x,int s)
{
    while(t[x].fa!=s)
    {
        int y=t[x].fa,z=t[y].fa;
        if(z!=s) (t[y].ch[1]==x)^(t[z].ch[1]==y)?Rotate(x):Rotate(y);
        Rotate(x);
    }
    if(s==0) root=x;
}
void Insert(int x)
{
    int u=root,fa=0;
    while(u&&t[u].val!=x)
        fa=u,u=t[u].ch[x>t[u].val];
    if(u) t[u].tot++;
    else
    {
        u=++tot;
        t[u].val=x;
        t[u].si=t[u].tot=1;
        t[u].fa=fa;
        if(fa) t[fa].ch[x>t[fa].val]=u;
        t[u].ch[0]=t[u].ch[1]=0;
    }
    update(u);
    splay(u,0);
}
void Find(int x)
{
    int u=root;
    if(!u) return;
    while(t[u].val!=x&&t[u].ch[x>t[u].val])
        u=t[u].ch[x>t[u].val];
    splay(u,0);
}
int Next(int x,int f)
{
    Find(x);
    int u=root;
    if(t[u].val<x&&!f||t[u].val>x&&f) return u;
    u=t[u].ch[f];
    while(t[u].ch[f^1]) u=t[u].ch[f^1];
    return u;
}
void Delete(int x)
{
    int pre=Next(x,0),bk=Next(x,1);
    splay(pre,0);splay(bk,pre);
    int u=t[bk].ch[0];
    if(!u) return;
    if(t[u].tot>1) t[u].tot--,splay(u,0);
    else
        t[bk].ch[0]=0,update(bk);
}
int main()
{
    Insert(-1);Insert(1e9+1);
    int n;
    scanf("%d",&n);
    while(n--)
    {
        int x;scanf("%d",&x);
        int u=Next(x,0);
        if(t[u].val==-1) Insert(x);
        else
        {
            Delete(t[u].val);
            Insert(x);
        }
    }
    printf("%d\n",t[root].si-2);
}


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

int main(){
    int H, W ,K;
    cin >> H >> W >> K;
    vector<string> s(H);
    for (int i = 0; i < H; ++i){
        cin >> s[i];
    }
    int ans = 0;
    for (int bi = 0; bi < (1<<H); ++bi){
        for (int bj = 0; bj < (1<<W); ++bj){
            int cnt = 0;
            for (int i = 0; i < H; ++i){
                for (int j = 0; j < W; ++j){
                    if (bi & (1 << i)) continue;
                    if (bj & (1 << j)) continue;
                    if (s[i][j] == '#') ++cnt;
                }
            }
            if (cnt == K) ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
long long dp[70][2] = {};
int main(){
	int n;
	cin >> n;
	REP(i, n) {
		long long a;
		cin >> a;
		REP(q, 60) {
			if (((1LL << q) & a) != 0) {
				dp[q][1]++;
			}
			else {
				dp[q][0]++;
			}
		}
	}
	long long ans = 0;
	for (long long i = 0; i < 60; ++i) {
		ans += ((dp[i][0] * dp[i][1])%MAX_MOD * ((1LL << i)%MAX_MOD))%MAX_MOD;
		ans %= MAX_MOD;
	}
	cout << ans << endl;
}

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

int main()
{
	int ans,n,d,x,a[100];
	cin>>n>>d>>x;
	for(int i=0;i<n;++i)
	{
		cin>>a[i];
	}

	ans=x+n;
	for(int i=0;i<n;++i)
	{
	    ans+=((d-1)/a[i]);
	}

	cout<<ans<<endl;

	fflush(stdin);
	getchar();
	return 0;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	int ans=0;
	for(int i = 0;i <s.length()/2;i++){
		if(s[i] != s[s.length()-1 - i]){

			ans +=1;
		}
	}
	cout<<ans;
}

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

using namespace std;

typedef pair<long, size_t> P;

int main() {
    size_t n, m;
    cin >> n >> m;
    long a[n];
    for (auto &ai:a) cin >> ai;
    P cb[m];
    for (auto &cbj : cb) cin >> cbj.second >> cbj.first;
    sort(a, a + n);
    sort(cb, cb + m, greater<P>());

    // for (auto &ai : a) cerr << ai << '\n';
    // for (auto &cbj : cb) cerr << cbj.first << ' ' << cbj.second << '\n';
    size_t j = 0, remain=0;
    long sum = 0;
    for (size_t i = 0; i < n; i++) {
        if (remain == 0) {
            if (i > 0) j++;
            remain = cb[j].second;
        }
        if (j == m || cb[j].first <= a[i]) {
            sum += a[i];
            continue;
        }
        sum += cb[j].first;
        remain--;
    }
    cout << sum << '\n';
    return 0;
}


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

bool possible(string s, int i, int j){
	if(i == 0 && j != 0)return true;
	if(i == 0 && j == 0)return false;
	if(abs(s[i - 1] - '0' - j) <= 1)return true;
	return false; 
}

vector<long long> pos;
void gen(string s){
	for(int i = 0; i < (int)s.size(); i++){
		if(s[i] == '?'){
			for(int j = 0; j <= 9; j++){
				if(possible(s, i, j)){
					s[i] = j + '0';
					gen(s);
					s[i] = '?';
				}
			}
		}
	}
	for(auto i:s)if(i == '?')return ;
	pos.push_back(stoll(s));
	//cout << s << '\n';
}

int main(){
	for(int i = 1; i <= 10; i++){
		string s(i, '?');
		gen(s);
	}
	int k;
	cin >> k;
	cout << pos[k - 1] << '\n';
	//for(int i = 0; i < 20; i++)cout << pos[i] << ' ';
}


Measured memory_bytes: 2420
abck = [int(n) for n in input().split()]
if abck[0] >= abck[3]:
    print(abck[3])
elif abck[0] + abck[1] >= abck[3]:
    print(abck[0])
else:
    print(abck[0] * 2 - abck[3] + abck[1])


Measured memory_bytes: 9176
#include<stdio.h>

int main(void)
{
  int n;
  scanf("%d",&n);

  int a[110],i,j;
  int max=0,min=1100000000;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]>max)
      max = a[i];
    if(a[i]<min)
      min = a[i];
  }

  int ans;
  ans = max-min;

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

Measured memory_bytes: 1736
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <deque>
#include <limits>
#include <numeric>
#include <boost/math/common_factor_rt.hpp>


#define INF 100000000
#define MOD 1000000007

#define ll long long

using namespace std;


int main() {
	int n;
	int a[3] = {};
	cin >> n;

	if (n == 1) {
		cout << "Hello World" << endl;
		return 0;
	}
	else {
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
		}

		cout << a[0] + a[1] << endl;
	}
	
	
	
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iostream>

using namespace std;
int main(void){
	int N,A,B,P[100],a=0,b=0,c=0,ans;

	cin >> N >> A >> B;
	for(int i=0; i<N; i++){
		cin >> P[i];
		if(P[i]<= A)a++;
		else if(P[i] <= B)b++;
		else c++;
	}
	ans = min(min(a,b),c);
	cout << ans << endl;
	return 0;
}

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

int main() {

  int a,b,ten,eight,ans,i;

  cin >> a >> b;
  ans=-1;

  for(i=1;i<1009;i++) {
    eight=i*0.08;
    ten=i*0.1;

    if(eight==a&&ten==b) {
      ans=i;
      break;
    }
  }

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

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        abc: [isize; 3]
    };

    let ans:isize;
    if abc[0] == abc[1] {
        ans = abc[2];
    } else {
        if abc[0] == abc[2] {
            ans = abc[1];
        } else {
            ans = abc[0];
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2148
#include<iostream>
using namespace std;
int main()
{
	int n,t=0,p;
	cin>>n;
	p=n;
	while(p!=0){
		t+=p%10;
		p/=10;
	}
	if(n%t==0)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
n,u,v=map(int,input().split())
u-=1
v-=1
path=[[] for _ in range(n)]
for i in range(n-1):
  a,b = [int(x)-1 for x in input().split()]
  path[a].append(b)
  path[b].append(a)
parent = [-1]*n
rank = [-1]*n
que = []
que.append(v)
rank[v]=0

while(que):
  cur = que.pop()
  for nxt in path[cur]:
    if rank[nxt]==-1:
      rank[nxt]=rank[cur]+1
      parent[nxt]=cur
      que.append(nxt)
up = (rank[u]-1)//2
upto=u
for i in range(up):
  upto = parent[upto]
depth=0
que = [upto]
while(que):
  cur = que.pop()
  if len(path[cur])==1:
    depth = max(depth,rank[cur])
  else:
    for nxt in path[cur]:
      if nxt != parent[cur]:
        que.append(nxt)
print(depth-1)
    


    
  

Measured memory_bytes: 65260
n,m = map(int,input().split())
A = [input() for i in range(n)]
B = [input() for i in range(m)]
if n == m:
    if all(A[i]==B[i] for i in range(n)):
        print("Yes")
        exit()
    else:
        print("No")
        exit()
for i in range(n-m):
    for j in range(n-m):
        bool = True
        for l in range(m):
            if A[i+l][j:j+m] == B[l]:
                continue
            else:
                bool = False
        if bool:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 39664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  int A;
  char T;
  cin >> S;
  A = S.size();
  T = S.at(A-1);
  if(T == 's'){
    cout << S << "es" << endl;
  }
  else{
    cout << S << "s" <<endl;
  }
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#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 E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

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

int main()
{
	fast;
	ll n, a, b;
	cin >> n >> a >> b;
	cout << a * (n / (a + b)) + min(a, n % (a + b));
}

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

typedef pair<int,int> pi;
typedef vector<int> vi;
 
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define pb push_back

template<typename T> void max_self(T &a, T b) { a = max(a,b); return;}
template<typename T> void min_self(T &a, T b) { a = min(a,b); return;}
 
const int nax = 1e6 + 5;
const int mod = 1e9 + 7;

int modExpo(int a,int b,int c){
	if(b == 0) return 1;
	int answer = 1;
	while(b){
		if(b & 1) answer = ((answer % c) * (a % c)) % c;
		a = ((a % c) * (a % c)) % c;
		b /= 2; 
	}
	
	return answer;
}

signed main(){
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int t = 1;
	//cin >> t;
	while(t--){
		int n,k;
		cin >> n >> k;
		
		vector<int> arr(n);
		FOR(i,0,n) cin >> arr[i];
				
		sort(arr.begin(),arr.end());
		
		bool flag = false;
		int cnt = 1;
		for(int i = 0; i < n; ++i){
			if(arr[i] > 0){
				flag = true;
				++cnt;
			}
		}		
		
		if(flag == false){
			if(k & 1){
				int ans = 1;
				for(int i = n - 1; i >= 0; --i){
					ans = (ans * arr[i]) % mod;
					if(ans < 0) ans += mod;
					--k;
					if(k == 0) break;
				}
				
				cout << ans % mod;
			}
			else{
				int ans = 1;
				for(int i = 0; i < n; ++i){
					ans = (ans * arr[i]) % mod;
					if(ans < 0) ans += mod;
					--k;
					if(k == 0) break;					
				}
				
				cout << ans % mod;
			}
			return 0;
		}
		
		int ans = 1;
		int i = 0,j = n - 1;
		while(k){
			if(k == 1){
				ans = (ans * arr[j]) % mod;
				if(ans < 0) ans += mod;
				break;
			}
			
			int val1 = arr[i] * arr[i + 1];
			int val2 = arr[j] * arr[j - 1];
			if(val1 >= val2){
				ans = (ans * (val1 % mod)) % mod;
				if(ans < 0) ans += mod;
				i += 2;
			}
			else{
				ans = (ans * (val2 % mod)) % mod;
				if(ans < 0) ans += mod;
				j -= 2;
			}
			
			k -= 2;
		}
		
		cout << ans % mod;
	}	
	return 0;
}


Measured memory_bytes: 4780
l = [
    1,
    1,
    1,
    2,
    1,
    2,
    1,
    5,
    2,
    2,
    1,
    5,
    1,
    2,
    1,
    14,
    1,
    5,
    1,
    5,
    2,
    2,
    1,
    15,
    2,
    2,
    5,
    4,
    1,
    4,
    1,
    51,
]
K = int(input())

print(l[K - 1])



Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}

LL f(LL a,LL n) {
    LL t = a;
    rep(i,n-1) {
        t *= a;
    }
    return t;
}

int main() {
    LL n;
    cin >> n;
    string s = "";

    do {
        if(n%26 == 0) {
            s += 'z';
            n -= 26;
            n /= 26;
        } else {
            s += (char)('a'+ n%26 - 1);
            n /= 26;
        }
    }while(n > 0);
    REVE(s);
    cout << s << endl;

}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        a--;
    }
    return ans;
}
int main(){
    int a,b,c,d;
    int w,h,n;
    cin >> w >> h >> n;
    a=0;
    b=w;
    c=0;
    d=h;
    rep(i,n){
        int x,y,z;
        cin >> x >> y >> z;
        if(z==1)a=max(a,x);
        if(z==2)b=min(b,x);
        if(z==3)c=max(c,y);
        if(z==4)d=min(d,y);
    }
    if((b-a)<0||(d-c)<0){cout << 0 << endl; return 0;}
    cout << (b-a)*(d-c) << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int n,i,ans=200010;
int black_left[200010];
int white_right[200010];
char stone[200010];
int main()
{
    cin>>n;
    scanf("%s",stone);
    if(stone[0]=='#') black_left[0]=1;
    else black_left[0]=0;
    if(stone[n-1]=='.') white_right[n-1]=1;
    else white_right[n-1]=0;
    for(i=1;i<=n-1;i++){
        if(stone[i]=='#') black_left[i]=black_left[i-1]+1;
        else black_left[i]=black_left[i-1];
    }
    for(i=n-2;i>=0;i--){
        if(stone[i]=='.') white_right[i]=white_right[i+1]+1;
        else white_right[i]=white_right[i+1];
    }

    //for(i=0;i<=n-1;i++) printf("%d ",black_left[i]);
    //cout<<endl;
    //for(i=n-1;i>=0;i--) printf("%d ",white_right[i]);
    //cout<<endl;

    ans=min(white_right[0],black_left[n-1]);
    for(i=0;i<=n-1;i++) ans=min(ans,black_left[i]+white_right[i+1]);
    cout<<ans;
    return 0;
}


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

int main() {
  int N, b, c = 0;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A.at(i);
  
  for (int i = 0; i < N - 1; i++) {
    for (int j = 0; j < N - 1 - i; j++) {
      if (A.at(j) < A.at(j + 1)) {
        b = A.at(j);
        A.at(j) = A.at(j + 1);
        A.at(j + 1) = b;
      }
    }
  }
  
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0)
      c += A.at(i);
    else
      c -= A.at(i);
  }
  
  cout << c;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N, L int

func main() {
	sc.Split(bufio.ScanWords)

	N, L = nextInt(), nextInt()
	S := make([]string, N)
	for i := 0; i < N; i++ {
		S[i] = nextStr()
	}

	sort.Strings(S)
	buf := bufio.NewWriter(os.Stdout)
	for i := 0; i < N; i++ {
		buf.Write([]byte(fmt.Sprintf("%s", string(S[i]))))
	}
	buf.Write([]byte("\n"))
	buf.Flush()
}


Measured memory_bytes: 640
x = int(input())


syo = x // 11
amari = x % 11
PiecesOfUsuedNumbers = 2
if amari == 0:
    ans = syo * PiecesOfUsuedNumbers
elif 0 < amari <= 6:
    ans = syo * PiecesOfUsuedNumbers + 1
else:
    ans = syo * PiecesOfUsuedNumbers + 2


print(ans)

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  bool ans=true;
  if(a[n-1]-a[0]>1){
    ans=false;
  }
  else{
    int small=0;
    for(int i=0;i<n;i++){
      if(a[i]==a[0]){
        small++;
      }
    }
    if(small==n){
      if(a[0]!=n-1&&a[0]>n/2){
        ans=false;
      }
    }
    else{
      if(a[n-1]>small+(n-small)/2||a[n-1]<small+1){
        ans=false;
      }
      if(n-small==1){
        ans=false;
      }
    }
  }
  cout << (ans?"Yes":"No") << endl;
}

Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=1
s=sum(a)-a[-1]
for i in range(n-1):
  if 2*s>=a[n-i-1]:
    ans+=1
    s-=a[n-i-2]
  else:
    break
print(ans)

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

int a, b, c;

int main()
{
	cin >> a >> b;
	c = max(a, b);
	if (c - 1 >= min(a, b)) c = c + c - 1;
	else c = c + min(a, b);
	cout << c;	
	return 0;
}

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

using namespace std;

#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define mod 998244353
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()

typedef vector<lld> vi;
typedef vector<vector<lld>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<lld, lld>> vpi;
typedef long long LL;

//ADD
lld add(lld a, lld b, lld m = MOD) {
    a += b;
    a %= m;
    return a;
}

//SUB
lld sub(lld a, lld b, lld m = MOD) {
    return (a % m - b % m + m) % m;
}

//MUL
lld mul(lld a, lld b, lld m = MOD) {
    return ((a % m) * (b % m) % m);
}

//POW
lld pow(lld a, lld b, lld m = MOD) {
    a %= m;
    lld r = 1;
    while (b) {
        if (b & 1) r = r * a % m;
        b >>= 1;
        a = a * a % m;
    }
    return r;
}

//INV
lld inv(lld a, lld m = MOD) {
    return pow(a, m - 2, m);
}

int main() {
    fast;
    cin.tie(0);
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w" , stdout);
#endif*/
    lld i, n, k;
    cin >> n >> k;
    lld ans = 0;
    for (i = k; i <= n + 1; i++) {
        ans = add(ans, sub(sub(n * (n + 1) / 2, (n - i) * (n - i + 1) / 2), (i * (i - 1) / 2 - 1)));
    }
    cout << ans << endl;

}

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

using namespace std;

int solve(vector<int>& arr, int h) {
	int n = arr.size();
  	
  	vector<int> dp(n);
  	dp[0] = 0;
  
  	for(int i=1;i<n;i++) {
      	dp[i] = dp[i-1] + abs(arr[i]-arr[i-1]);
    	for(int j=2;j<=h;j++) {
          if(i-j>=0)
        	dp[i] = min(dp[i], dp[i-j]+abs(arr[i]-arr[i-j]));
        }
    }
  	
  	
  
  return dp[n-1];
  	
  
  
}


int main() {
	int n,h;
  	cin>>n>>h;
  	vector<int> arr(n);
  	for(int i=0;i<n;i++) {
    	cin>>arr[i];
    }
  	cout<<solve(arr, h);
	return 0;
}





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



int main(int argc, const char * argv[])
{
    int n, r, c;
    int na, nb;
    while(cin >> n >> r){
        if(n % 2 == 0){
            na = n / 2;
            nb = n / 2;
        }else{
            na = (n + 1) / 2;
            nb = (n - 1) / 2;
        }
        
        // カード置き場初期化
        int cards[n], acards[n], bcards[n];
        for(int i = 0; i < n; i++){
            cards[i] = i;
        }
        
        for(int i = 0; i < r; i++){
            cin >> c; // cを読む
            // カード分割
            for(int j = 0; j < nb; j++){
                bcards[j] = cards[j];
            }
            for(int j = 0; j < na; j++){
                acards[j] = cards[nb + j];
            }
            
            int p = 0, pa = 0, pb = 0;
            while(p < n){
                for(int j = 0; j < c; j++){
                    if(pa < na){
                        cards[p] = acards[pa];
                        p++;
                        pa++;
                    }
                }
                
                for(int j = 0; j < c; j++){
                    if(pb < nb){
                        cards[p] = bcards[pb];
                        p++;
                        pb++;
                    }
                }
            }
        }
        cout << cards[n-1] << "\n";
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int a=0;
  if(N/100==1){
    a++;
  }
  if((N%100-N%10)/10==1){
    a++;
  }
  if(N%10==1){
    a++;
  }
  cout << a << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

int main() {
  vector<int> nums = {1,2,3};
  int A, B;
  cin >> A >> B; 
  
  int ans = 0;
  for(auto var : nums)
  {
     if ((A != var) && (B != var)) 
        ans = var;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
n, m, c = gets.chomp.split.map(&:to_i)
arr = gets.chomp.split.map(&:to_i)
arr2 = []
n.times{arr2 << gets.chomp.split.map(&:to_i)}
arr2.sort_by!{|c, w| -w}
sum = 0
arr2.each{|c, w|
    if arr[c-1] > 0
        arr[c-1] -= 1
        sum += w
        m -= 1
        break if m == 0
    end
}
puts sum


Measured memory_bytes: 23044
import math
import numpy as np

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

#print(n)
#print(a)
answer = 0
b=[0]*(n+1)
for i in range(n):
    b[i+1] = b[i]+a[i]
c=np.sort(b)
#print(b)
#print(c)
renzoku = 0
for i in range(1,n+1):
    if c[i-1] == c[i]:
        renzoku += 1
    elif renzoku > 0:
        answer += renzoku*(renzoku+1)//2
#        print(i,renzoku)
        renzoku = 0
if renzoku > 0:
    answer += renzoku*(renzoku+1)//2  
#    print(i,renzoku)
print(answer)


Measured memory_bytes: 34556
#include<iostream>
#include<algorithm>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)

using namespace std;

int main(){
	int n,t;
	cin>>n>>t;
	string name1,name2;
	string canstop[20];
	int stoptime[20];
	char c;
	int h,m,ah,am;
	int cnt=0;
	cin>>h>>c>>m>>name1;
	rep(i,n-1){
		cin>> h>>c>> m>>name1;
		cin>>ah>>c>>am>>name2;
		if(ah*60-h*60+am-m>=t){
			stoptime[cnt]=ah*60-h*60+am-m;
			canstop[cnt++]=name1;
		}
	}
	cin>>h>>c>>m>>name1;
	cout<<cnt<<endl;
	rep(i,cnt){
		cout<<canstop[i]<<" "<<stoptime[i]<<endl;
	}
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
long long c[105],v[105];
long long dp[105][100005];
#define inf 1e9+5
int main(){
	long long n,w;
	cin >> n >> w;
	long long v_sum = 0;
	for(int i = 1; i<=n; i++){
		cin >> c[i] >> v[i];
		v_sum+=v[i];
	}
	for(int i = 0; i<=n; i++){
		for(int j = 0;j<=v_sum; j++){
			dp[i][j]=inf;
		}
	}
//	for(int i = 0; i<=1004s
	for(int i = 0; i<=n; i++){
		dp[i][0]=0;
	}
	for(int i = 1; i<=n; i++){
		for(int j = 1; j<=v_sum; j++){
			if(i-1>=0&&j-v[i]>=0)dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+c[i]);
			else dp[i][j]=dp[i-1][j];
		}
	}
	long long ans = 0;
	
	for(long long i = 1; i<=n; i++){
		for(long long j = 0;j<=v_sum; j++){
//			cout << dp[i][j] << " ";
			if(dp[i][j]<=w){
				ans = max(j,ans);
			}
		}
//		cout << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 82440
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 200
int isEmpty(int);
int main()
{
  int i=0, j, n=0, top=0, S[N];
  char c[N];
  for(i = 1 ; i < N ; i++)
    {
      if(scanf("%s",c)==EOF) break;

      else if(isEmpty(i)==1){     
      if(!strcmp(c,"+")){
	  S[i-2]=S[i-1] + S[i-2];
	i = i - 2;
      }else if(!strcmp(c, "-")){
	  S[i-2] = S[i-2] - S[i-1];
	  i = i - 2;
      }else if(!strcmp(c, "*")){
	  S[i-2] = S[i-2] * S[i-1];
	  i = i - 2;
	}
	else {
	  S[i] = atoi(c);
	}
      }
      else if(isEmpty(i-2)==0) break;
    }
  printf("%d\n",S[1]);
  return 0;
}

int isEmpty(int x){

  if(x == 0) return 0;
  else return 1;
}

Measured memory_bytes: 548