akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;


ll func(int x){
  ll r = 0;
  for(int i=1;i<=sqrt(x)+1;++i){
    for(int j=1;j<=i;++j){
      for(int k=1;k<=j;++k){
        if(i*i+j*j+k*k+i*j+j*k+k*i==x){
          if(i==j && j==k){ ++r; }
          else if(i==j || j==k){ r += 3;}
          else{ r += 6;}
        }
      }
    }
  }
  return r;
}

int main(){
  int N; cin>>N;
  for(int i=1;i<=N;++i){
    cout << func(i) << "\n";
  }
}

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





class Solution {
  int n, m, C;
public:
  void run() {
    cin >> n >> m >> C;
    vector<int> B(m);
    vector<vector<int>> A(n, vector<int>(m));
    for (int i = 0; i < m; ++i) cin >> B[i];
    for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
      cin >> A[i][j];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      int cur = C;
      for (int j = 0; j < m; ++j) {
        cur += A[i][j] * B[j];
      }
      ans += cur > 0;
    }
    cout << ans << '\n';
  }
};

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


Measured memory_bytes: 256
def ok(p,l,k):
    c=1
    c1=0
    for i in l:
        if i>p:
          return False
        elif c1+i>p:
            c+=1
            c1=i
        else:
            c1+=i
    if c>k:
        return False
    else:
        return True
def nibutan(list1,k,n):
    l=0
    h=n*10000
    while l+1<h:        
        m=int((l+h)/2)
        if ok(m,list1,k):
            h=m
        else:
            l=m
    return h
n,k=map(int,input().split())
l=[]
for i in range(n):
    l.append(int(input()))
print(nibutan(l,k,n))


Measured memory_bytes: 9556
#include <bits/stdc++.h>
#define pb push_back
#define sc1(n) scanf("%lld",&n)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define MX 100000
using namespace std;

typedef long long int ll;
typedef unsigned long long ul;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll n;
double arr[3005];
double dp[3005][3005];
double solve(ll pos,ll tail)
{
    if(2*tail>=n)
    {
        return 0.0;
    }
    if(pos>n)
    {
        return 1.0;

    }
    if(dp[pos][tail]!=-1.0){
        return dp[pos][tail];
    }

    double ret1=1.0;
    double ret2=1.0;
    ret1=ret1*arr[pos]*solve(pos+1,tail);
    ret2=ret2*(1.0-arr[pos])*solve(pos+1,tail+1);
    //cout<<ret1<<endl;
    //cout<<ret2<<endl;

    return dp[pos][tail]=ret1+ret2;
}
int main()
{

    sc1(n);
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=n;j++)
        {
            dp[i][j]=-1.0;
        }
    }
    for(ll i=1;i<=n;i++)
    {
        cin>>arr[i];
        //cout<<arr[i]<<endl;
    }
    double ans=solve(1,0);
    cout<<setprecision(12)<<ans<<endl;
    //printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 70912
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

type pair struct {
	fi int
	se int
}

var data [3][30]int
var d [][]int
var c [][]int

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	//予備
	n := iScan()
	d := iScan()
	x := make([]int, n)
	y := make([]int, n)
	ans := 0
	for i := 0; i < n; i++ {
		x[i] = iScan()
		y[i] = iScan()
		if d*d >= x[i]*x[i]+y[i]*y[i] {
			ans++
		}
	}
	fmt.Println(ans)
}

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

int main(){
  int n;
  cin>>n;
  int a[200005];
  rep(i,n) cin>>a[i];
  int x=0;
  ll ans=0;
  for(int l=0,r=0;l<n;l++){
    while(r<=n){
      if(r==n||(x^a[r])!=x+a[r]) break;
      x^=a[r];
      r++;
    }
    ans+=r-l;
    x^=a[l];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int H, W;
    cin >> H >> W;
    char maze[H][W];
    int ans = 0;
    for(int i = 0; i < H; i++) {
        string S;
        cin >> S;
        for(int j = 0; j < W; j++) {
            maze[i][j] = S[j];
            if(maze[i][j] == '.') ans++;
        }
    }

    int d[H][W];
    for(int i = 0; i < H; i++)
        for(int j = 0; j < W; j++) d[i][j] = -1;
    d[0][0] = 0;
    queue<pair<int, int>> q;
    q.push({0, 0});
    while(!q.empty()) {
        pair<int, int> before = q.front();
        q.pop();
        int x = before.first, y = before.second;
        if(x > 0) {
            if(maze[x - 1][y] == '.' && d[x - 1][y] == -1) {
                d[x - 1][y] = d[x][y] + 1;
                q.push({x - 1, y});
            }
        }
        if(x < H - 1) {
            if(maze[x + 1][y] == '.' && d[x + 1][y] == -1) {
                d[x + 1][y] = d[x][y] + 1;
                q.push({x + 1, y});
            }
        }
        if(y > 0) {
            if(maze[x][y - 1] == '.' && d[x][y - 1] == -1) {
                d[x][y - 1] = d[x][y] + 1;
                q.push({x, y - 1});
            }
        }
        if(y < W - 1) {
            if(maze[x][y + 1] == '.' && d[x][y + 1] == -1) {
                d[x][y + 1] = d[x][y] + 1;
                q.push({x, y + 1});
            }
        }
    }
    if(d[H - 1][W - 1] == -1)
        cout << -1 << "\n";
    else
        cout << ans - d[H - 1][W - 1] - 1 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	long long n,k,t=0;
	cin >>n >> k;
  	vector<long long> a(n);
  	rep(i, n) {
    	cin >> a[i];
    }
  	sort(a.begin(), a.end());
  	rep(i, n-k) {
    	t += a[i];
    }
	cout << t << endl;
	
}


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

int main(){
  long long a,b,c;
  cin >> a >> b >> c;
  
 
  
  if(a%2==0||b%2==0||c%2==0){
    cout << 0 << endl;
  }
  else{
    cout << min(a*b,min(b*c,c*a)) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int N = 1e5 + 5;
int n, a[N], cnt[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &a[i]);
  int x = 0, y = 0, z = 0, ans = 0;
  for (int i = 1; i <= n; i += 2)
    if (++cnt[a[i]] > x)
      x = cnt[a[i]], z = a[i];
  memset(cnt, 0, sizeof cnt);
  for (int i = 2; i <= n; i += 2)
    if (a[i] != z) y = max(y, ++cnt[a[i]]);
  ans = n - x - y;
  memset(cnt, 0, sizeof cnt);
  x = 0, y = 0, z = 0;
  for (int i = 2; i <= n; i += 2) 
    if (++cnt[a[i]] > y)
      y = cnt[a[i]], z = a[i];
  memset(cnt, 0, sizeof cnt);
  for (int i = 1; i <= n; i += 2)
    if (a[i] != z) x = max(x, ++cnt[a[i]]);
  cout << min(ans, n - x - y);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
int main(){
    int n;
    cin>>n;
    int x[n];
    REP(i,n){
        cin>>x[i];
    }
    ll ans=1000000000;
    ll sum=0;

    for (int i = 1; i < 101; i++)
    {
        /* code */
        for (int j = 0; j < n; j++)
        {
            /* code */
            sum+=(x[j]-i)*(x[j]-i);

        }
        ans=min(sum,ans);
        sum=0;
        
    }
    cout<<ans<<endl;
    


}


Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

s = str(input())
for i in range(len(s)):
    if s[i] == "A":
        start = i
        break

for i in reversed(range(len(s))):
    if s[i] == "Z":
        end = i
        break
print(end-start+1)


Measured memory_bytes: 7748
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	int A, B;
	cin >> A >> B;
	if (A * B % 2) cout << "Yes" << endl;
	else cout << "No" << endl;

ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}




Measured memory_bytes: 504
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let s: String = read();

    let cv: Vec<char> = s.chars().collect();

    let mut stack: Vec<u32> = Vec::new();

    let mut r: u32 = 0;

    let mut sum: u32 = 0;

    let mut lakes: Vec<(u32, u32)> = Vec::new();

    for c in cv {
        if c == '\\' {
            stack.push(r);
        } else if c == '/' {
            if let Some(l) = stack.pop() {
                let mut tmp = r - l;
                sum += tmp;
                while !lakes.is_empty() {
                    let (i, w) = lakes.pop().unwrap();
                    if i < l {
                        lakes.push((i, w));
                        break;
                    } else {
                        tmp += w;
                    }
                }
                lakes.push((l, tmp));
            }
        }
        r += 1;
    }

    println!("{}", sum);

    print!("{}", lakes.len());
    for (_, w) in lakes {
        print!(" {}", w);
    }
    println!("");
}



Measured memory_bytes: 5036
# coding: utf-8
n = int(input())
A = map(int, input().split())

l = []
i = 1
for a in A:
    if a == i:
        l.append(a)
        i += 1
if len(l) == 0:
    print(-1)
else:
    print(n - len(l))
        

Measured memory_bytes: 26012
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   cin>>n;
   int x[n],y[n];
   
   for(int i=0;i<n;i++)
   {
       cin>>x[i]>>y[i];
   }
   
   double a,s=0;
   for(int i=0;i<n-1;i++)
   {
       for(int j=i+1;j<n;j++)
       {
           a=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
       
           s+=a;
       }
       
   }
   
   double ans;
   ans=(s*2)/n;
   cout<<fixed<<setprecision(6)<<ans;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

int main() {
    string S;
    cin >> S;
    ll sa = INF;
    ll s = S.size();
    rep(i,s - 2){
        ll num = (S[i] - '0') * 100 + (S[i + 1] - '0') * 10 + S[i + 2] - '0';
        sa = min(sa,abs(num - 753));
    }
    cout << sa << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define repf(i, n) for(int i=1; i<(int)(n+1); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

bool isPrime(int a){
    if(a == 2) return true;
    else if(a%2 == 0 || a <= 2) return false;
    else{
        int i=3;
        double range = sqrt(a);
        while(i <= range){
            if(a%i == 0) return false;
            i += 2;
        }
    }
    return true;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    int x;
    cin >> x;
    while(!isPrime(x)) x++;
    cout << x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  stack<int> st;
  char a[2];
  int b,c;
  while( scanf("%s",a) != EOF){
    if(a[0]=='+'||a[0]=='-'||a[0] =='*'){
      c = st.top();
      st.pop();
      b = st.top();
      st.pop();
      if(a[0] == '+') st.push(b+c);
      else if(a[0] == '-') st.push(b-c);
      else if(a[0] == '*') st.push(b*c);
    }
    else st.push(atoi(a));
  }
  cout << st.top() << endl;
  return 0;
}

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

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

  n = N % 1000;

  if (N % 1110 <= 9) {
    cout << "Yes" << endl;
  }
  else if (n % 111 == 0 || n == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3616
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U>
inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U>
inline void cmin(T& a, U b) { if (a > b) a = b; }

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cerr << fixed << setprecision(15);
  }
} io_setup;

constexpr char el = '\n';
#line 3 "../../library/modint.hpp"

template <ll Mod>
struct ModInt {
  ll n;

  ModInt(const ll x = 0) : n(x) {
    while (n < 0) n += Mod;
    n %= Mod;
  }

  inline constexpr ModInt operator+(const ModInt r) const noexcept { return ModInt(*this) += r; }
  inline constexpr ModInt operator-(const ModInt r) const noexcept { return ModInt(*this) -= r; }
  inline constexpr ModInt operator*(const ModInt r) const noexcept { return ModInt(*this) *= r; }
  inline constexpr ModInt operator/(const ModInt r) const noexcept { return ModInt(*this) /= r; }
  inline constexpr ModInt &operator+=(const ModInt r) noexcept {
    n += r.n;
    if (n >= Mod) n -= Mod;
    return *this;
  }
  inline constexpr ModInt &operator-=(const ModInt r) noexcept {
    if (n < r.n) n += Mod;
    n -= r.n;
    return *this;
  }
  inline constexpr ModInt &operator*=(const ModInt r) noexcept {
    n = n * r.n % Mod;
    return *this;
  }
  inline constexpr ModInt &operator/=(const ModInt r) noexcept { return *this *= r.inv(); }

  inline constexpr ModInt pow(ll x) const noexcept {
    ModInt<Mod> ret(1), tmp(*this);
    while (x) {
      if (x&1) ret *= tmp;
      tmp *= tmp;
      x >>= 1;
    }
    return ret;
  }
  inline constexpr ModInt inv() const noexcept { return pow(Mod-2); }

  friend ostream& operator<<(ostream& os, const ModInt& obj) { return os << obj.n; }
  friend istream& operator>>(istream& is, ModInt& obj) {
    ll t;
    is >> t;
    obj = ModInt(t);
    return is;
  }
};

constexpr ll mod = 1000000007;
using mint = ModInt<mod>;
mint operator"" _mi(unsigned long long n) { return mint(n); }
#line 3 "f.cpp"

using modint = ModInt<998244353>;

int main() {
  ll n, s;
  cin >> n >> s;
  vl a(n);
  rep(i, n) {
    cin >> a[i];
  }

  modint ans;
  vector<modint> dp(s+1);
  vector<modint> next(s+1);

  rep(i, n) {
    dp[0] += modint(1);
    next.assign(s+1, modint());

    rep(j, s+1) {
      next[j] += dp[j];
      if (j+a[i] <= s) {
        next[j+a[i]] += dp[j];
      }
    }

    copy(all(next), dp.begin());
    ans += dp[s];
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int n;
int count=0;

void merge(int *A,int left,int mid,int right){
  int *L,*R;
  L=malloc(sizeof(int)*(mid-left+1));
  R=malloc(sizeof(int)*(right-mid+1));
  
  int i;
  for(i=0;i<mid-left;i++) L[i]=A[left+i];
  L[mid-left]=1000000001;
  for(i=0;i<right-mid;i++) R[i]=A[mid+i];
  R[right-mid]=1000000001;
  
  int l,r;
  l=0;
  r=0;
  for(i=0;i<right-left;i++){
    count+=1;
    if(L[l] <= R[r]){
      A[left+i]=L[l];
      l+=1;
     }
    else{
      A[left+i]=R[r];
      r+=1;
    }
  }
  free(L);
  free(R);
}




void mergesort(int *A,int left,int right){
  if(left +1 < right){
    int mid;
    mid=(left+right)/2;
    mergesort(A,left,mid);
    mergesort(A,mid,right);
    merge(A,left,mid,right);
  }
}



int main(){
  int *A;
  scanf("%d",&n);
  A=malloc(n*sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",&A[i]);

  mergesort(A,0,n);
  
  printf("%d",A[0]);
  for(i=1;i<n;i++) printf(" %d",A[i]);
  printf("\n%d\n",count);
  return 0;
}
  




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

int rect(int h, int w){
  for (int k = 0; k < h; k++) {
    for (int i = 0; i < w; i++) {
      cout << "#";
    }
    cout << endl;
  }

  cout << endl;
  return 0;
}

int main() {
  int a, b;
  for (;;) {
    cin >> a >> b;
    if (a == 0 && b == 0) break;

    rect(a, b);
  }

  return 0;
}



Measured memory_bytes: 3080
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};


int main(){
    ll N,a;
    cin >> N;
    vector<ll> A;
    llrep(i,N){
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(), A.end());
    ll cnt=1;
    ll prev=A[0];
    ll ans=0;
    llRep(i,A.size()-1){
        if (A[i]==prev){
            cnt++;
        }else{
            if (cnt%2==1){
                ans++;
            }
            cnt=1;
        }
        prev = A[i];
        if (i==A.size()-1 && cnt%2==1){
                ans++;
            }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main() {

	string str; cin >> str;

	int ch[26] = { 0, };

	for (char c : str)
		ch[c - 'a']++;

	bool ok = true;

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

		if (ch[i] == 0) continue;

		if (ch[i] % 2 == 1) ok = false;

	}

	if (ok) cout << "Yes";
	else cout << "No";

	return 0;
	
}

Measured memory_bytes: 256
($n,$q)=glob<>;
$R=0;
$A[0]=1;$A[1]=1;
for(1..$q){
    <>=~$";
    ($A[$`-1],$A[$'-1])=($A[$'-1],$A[$`-1]);
    $R=($R==$`-1)?$'-1:$`-1 if($R==$`-1or$R==$'-1);
    $A[$R-1]=1 if($R>0);
    $A[$R+1]=1 if($R<$n);
}
print$k=grep{$_}@A;

Measured memory_bytes: 4480
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2,tune=native")

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++)
	cin >> A[i];
    int res = __gcd(A[0], A[1]);
    for (int i = 2; i < N; i++) res = __gcd(res, A[i]);
    cout << res;
    return 0;
}

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

typedef long long ll;
const int N=2e5+10;
int n;
int a[N],pre_xor[N];
int l,r;
ll ans,cur,pre_sum[N];

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",a+i);
	pre_xor[1]=pre_sum[1]=a[1];
	for(int i=1;i<n;i++){
		pre_sum[i]=pre_sum[i-1]+a[i];
		pre_xor[i]=pre_xor[i-1]^a[i];
	}
	cur=0;
	for(l=0;l<n;l++){
		while(r<n&&!(cur&a[r])){
			cur^=a[r];
			r++;
		}
		ans+=(ll)r-l;
		cur^=a[l];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
int main(){
  int i,a,n,v[20],c,r=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&v[i]);
  for(i=0;i<n;i++){
    scanf("%d",&c);
    a=v[i]-c;
    if(a>0)r+=a;
  }
  printf("%d",r);
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String args[]) {


        Scanner scan = new Scanner(System.in);

        String s = scan.next();

        if (Character.isUpperCase(s.charAt(0))) {
            System.out.println("A");
        } else {
            System.out.println("a");
        }
    }
}

Measured memory_bytes: 35448
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trv(a) cerr<<#a<<":\n";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define mod 1000000007ll
#define inf 9999999999999999ll


void solve()
{
    int n,m;
    cin>>n>>m;
    vi a(m,0);
    int sum = 0;
    for(int i = 0 ; i < m ; i++)
    {
        int temp = 0;
        cin>>temp;
        sum += temp;
    }
    if(sum > n)
    cout<<-1<<endl;
    else
    {
        cout<<n-sum<<endl;
    }
    
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    // cin>>t;
    t = 1;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3652
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)



def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

N=II()

print((N//2) +N%2)


Measured memory_bytes: 12444
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        # xが根だったら自分自身をreturnする
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループかどうか
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]


def main():
    N, M = map(int, input().split())

    A = [None] * M
    B = [None] * M

    for i in range(M):
        A[i], B[i] = map(int, input().split())

    uni = UnionFind(N)
    ans = [None] * M
    ans[M-1] = N * (N - 1) // 2
    for i in range(M - 1, 0, -1):
        x = A[i] - 1
        y = B[i] - 1
        # 辺でつなげても元々同じグループに属していた場合、変化はしない
        if uni.is_same(x, y):
            ans[i - 1] = ans[i]
        else:
            ans[i - 1] = ans[i] - (uni.get_size(x) * uni.get_size(y))
        uni.union(x, y)


    for a in ans:
        print(a)

main()

Measured memory_bytes: 102744
### INPUT
# array = [*1..q].map { |_| gets.split.map(&:to_i) }
# n = gets.split.map(&:to_i)
### SNIPPET
# [].all?(&:even?)
# a = [*1..m].repeated_combination(n).to_a
# 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
# 3.upto(6) do |i|, 6.downto(3) do |i|
# 公約数125.gcd(100)、公倍数125.lcm(100)
# PI = Math::PI
# 高さh = a * Math.sin(w / 180.0 * Math::PI)
# 底辺 = a * Math.cos(w / 180.0 * Math::PI)
INF = Float::INFINITY
### DP
def chmin(a, b) a < b ? a : b end
# def chmax(a, b) a > b ? a : b end


n = gets.to_i
h = gets.split.map(&:to_i)

h.unshift(0)
dp = [INF] * (n+1)


dp[1] = 0

1.upto(n-1) do |i|
  dp[i+1] = chmin(dp[i+1], dp[i] + (h[i+1] - h[i]).abs)
  dp[i+1] = chmin(dp[i+1], dp[i-1] + (h[i+1] - h[i-1]).abs) if i >= 1
end


puts dp[n]

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

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

int main() {
  int n;
  cin >> n;
  vector<P> p(n);
  rep(i, n) cin >> p[i].second >> p[i].first;
  sort(p.begin(), p.end());

  ll t = 0;
  rep(i, n) {
    t += p[i].second;
    if (t > p[i].first) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=998244353;

signed main(){
        llin(n);
        ll k=0;
        FOR(i,1,n){
                if(i*i<n){
                        if(n%i==0&&i<n/i-1){
                                k+=n/i-1;
                        }
                }else{
                        break;
                }
        }
        sal(k)
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
int main(void) {
    string s, t;
    cin >> s >> t;
    int a, b; cin >> a >> b;
    string u; cin >> u;
    if(s==u){
        printf("%d %d\n",a-1,b);
    }
    else{
        printf("%d %d\n",a,b-1);
    }
}


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

int main() {
	int N;
	scanf("%d", &N);
	int a = 0, b = 0, c = 0;
	while (N--) {
		int x;
		scanf("%d", &x);
		if (x % 2)
			a++;
		else if (x % 4)
			b++;
		else
			c++;
	}
	puts(a - c <= !b ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<vector<int>> Cij(3, vector<int>(3));
  
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> Cij.at(i).at(j);
    }
  }
  
  int T = 1;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 3; j++) {
      if (Cij.at(i).at(0) - Cij.at(i+1).at(0) != Cij.at(i).at(j) - Cij.at(i+1).at(j)) {
        T = 0;
        break;
      }
    }
  }
  for (int j = 0; j < 2; j++) {
    for (int i = 0; i < 3; i++) {
      if (Cij.at(0).at(j) - Cij.at(0).at(j+1) != Cij.at(i).at(j) - Cij.at(i).at(j+1)) {
        T = 0;
        break;
      }
    }
  }
  if (T == 1) {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" << endl;
  }
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define b begin()
#define e end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];
	
	cin>>n>>m>>k;
	
	(m-n==k-m)?cout<<"YES"<<endl:cout<<"NO"<<endl;
	
	
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define mp make_pair
#define fi first
#define se second
#define pb push_back

int a,b,c;

int main(){
	
	cin >> a >> b >> c;
	if ( a > b ) swap(a,b);
	if ( b > c ) swap(b,c);
	if ( a > b ) swap(a,b);
	
	if ( a == b && b != c ) cout << "Yes\n";
	else if ( a != b && b == c ) cout << "Yes\n";
	else cout <<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fi first
#define se second
#define endl '\n'
#define fn(i,x) for(i=0;i<x;i++)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define vii vector<int>
#define vll vector<ll>
#define mx 1e18
#define mod 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define sii set<int>
#define sll set<ll>
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{io
int k;cin>>k;ll ans=0;
for(int i=1;i<=k;i++)
{
	for(int j=1;j<=k;j++)
	{
		
		for(int p=1;p<=k;p++)
		{
		 ans+=	__gcd(i,__gcd(j,p));
		}
	}
}
cout<<ans;

	


 
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
 
 
int main() {
 	long long a,b,c ;
 
  cin >> a >> b >>c;
 
   
  if(4*a*b< (c-a-b)*(c-a-b) && c-a-b>0){
  cout << "Yes" << endl;
  }
  else {
    cout << "No"<< endl;
  }
}
  
 

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
  

int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(rALL(a));
  ll ans = a[0];
  rep(i, n-2) ans += a[i/2 + 1];
  
  cout << ans << endl;
}

Measured memory_bytes: 4848
#include<stdio.h>
int main (void)
{
  int n,h,m,s;
  scanf("%d",&n);
  h=n/3600;
  n-=h*3600;
  m=n/60;
  n-=m*60;
  s=n;
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N, K, Q;
    cin >> N >> K >> Q;
    vector<long long> vc(N + 1, 0);
    for (int i = 0; i < Q; ++i)
    {
        long long tmp;
        cin >> tmp;
        vc[tmp]++;
    }
    long long counta = 0;
    for (int i = 1; i <= N; ++i)
    {
        if (K - (Q - vc[i]) > 0)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;using std::queue;using std::priority_queue;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;using std::swap;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::vector<int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}

namespace ndifix{
template<class T> void sort(T &v){std::sort(v.begin(),v.end());}
template<class T> void rsort(T &v){std::sort(v.rbegin(),v.rend());}

}

int main(){
  int a,b;cin>>a>>b;
  if(a==2 || b==2)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;  
  return 0;
}


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

 int main(){

  int a,b,c,d;
  cin>>a>>b>>c>>d;

  if((a==b && c==d) || (a==c &&b==d) || (a==d &&c==b)  )    cout<<"yes"<<endl;
  else cout<<"no"<<endl;

  return 0;
  }



Measured memory_bytes: 3080
input = readline()

function func(in)
    ary =  parse.(split(in))

    if ary[1] + ary[2] < ary[3] + ary[4]
        println("Right")
    elseif ary[1] + ary[2] > ary[3] + ary[4]
        println("Left")
    else
        println("Balanced")
    end
end


func(input)


Measured memory_bytes: 174712
#include<iostream>
#include <algorithm>
using namespace std;
#define INF 1000000000

int main() {
    int n;
    int dp[100001];
    cin >> n;
    fill(dp, dp + n, INF);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        *lower_bound(dp, dp + n, a) = a;
    }
    cout << lower_bound(dp, dp+n, INF) - dp << endl;
}



Measured memory_bytes: 3476
'use strict'

const main = input => {
	const args = input.split('\n')
	const n = parseInt(args[0], 10)
	const a = parseInt(args[1], 10)

	if (n % 500 <= a) console.log('Yes')
	else console.log('No')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include<iostream>
#include<utility>
#include<vector>

#define MOD 998244353
long long mod_div(long long a, long long b)
{
	if(a % b == 0)
	{
		return a / b;
	}
	long long tmp = MOD - 2, c = b, ret = 1;
	while(tmp > 0)
	{
		if(tmp & 1)//tmp%2==1
		{
			ret *= c;
			ret %= MOD;
		}
		c *= c;
		c %= MOD;
		tmp >>= 1;
	}
	return a * ret % MOD;
}

#define MAX_K 333333
long long combination(long long n, long long r)
{
	if(n < r || n < 0 || r < 0)
	{
		return -1;
	}
	static std::vector<long long>kaijo(MAX_K);
	if(kaijo[0] != 1)
	{
		kaijo[0] = 1;
		for(long long i = 1; i < MAX_K; i++)
		{
			kaijo[i] = (kaijo[i - 1] * i) % MOD;
		}
	}
	long long numerator = kaijo[n];
	long long denominator = (kaijo[r] * kaijo[n - r]) % MOD;
	return mod_div(numerator, denominator);
}

signed main()
{
	long long n, a, b, k;
	std::cin >> n >> a >> b >> k;
	std::vector<std::pair<long, long>>pairs;
	pairs.reserve(n);
	for(long long x = 0; x <= n; x++)
	{
		if((k - a * x) % b == 0)
		{
			long long y = (k - a * x) / b;
			if(0 <= y && y <= n)
			{
				pairs.push_back(std::make_pair(x, y));
			}
		}
	}
	long long ans = 0;
	for(auto i : pairs)
	{
		ans += combination(n, i.first) * combination(n, i.second) % MOD;
		ans %= MOD;
	}
	std::cout << ans << std::endl;
	return 0;
}

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

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

  int64_t a, b, c;
  cin >> a >> b >> c;
  if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
    cout << 0 << endl;
    return 0;
  }

  cout << min({a * b, b * c, c * a}) << endl;




  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
//debugger
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//debugger
vector<int> thief;
int main()
{
    FASTIO;
    int n,k,x,ans=0;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        thief.push_back(x);
    }
    sort(thief.begin(),thief.end());
    //debug(thief);
    for(int i=0;i<k;i++)
    {
        ans+=thief[i];
    }
    cout<<ans<<endl;
}

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

int main(){

    while(1){
        int n, m; cin >> n >> m;
        if(!n) break;
        vector<int> max_score(n, 0);
        vector<int> min_score(n, 0);

        for(int i = 0; i < m; i++){
            int s, k; cin >> s >> k;
            vector<int> c(k);
            for(int j = 0; j < k; j++){
                cin >> c[j];
                c[j]--;
                max_score[c[j]] += s;
            }
            
            if(k == 1){
                min_score[c[0]] += s;
            }
        }

        int ans = 0;

        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(i == j) continue;

                ans = max(ans, max_score[i] - min_score[j] + 1);
            }
        }
    
    cout << ans << endl;
    }
    return 0;
}


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

int main() {
    int m, t, f, sum;
    while (true) {
        cin >> m >> t >> f;
        if (m == -1 && t == -1 && f == -1) {
            break;
        }
        if (m != -1) {
            sum = m;
        } else {
            cout << "F" << endl;
            continue;
        }

        if (t != -1) {
            sum += t;
        } else {
            cout << "F" << endl;
            continue;
        }

        if (sum >= 80) {
            cout << "A" << endl;
        } else if (sum < 80 && sum >= 65) {
            cout << "B" << endl;
        } else if (sum < 65 && sum >= 50) {
            cout << "C" << endl;
        } else if (sum >= 30 && sum < 50) {
            if (t != -1) {
                if (f >= 50) {
                    cout << "C" << endl;
                } else {
                    cout << "D" << endl;
                }
            } else {
                cout << "D" << endl;
            }
        } else {
            cout << "F" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3032