akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if( a == min(a,min(b,c)) ){
      
      cout << max(b,c)-a << endl;
    }
  
  else if( b==min(a,min(b,c)) ){
    
      cout << max(a,c)-b << endl;
    }
  
    else if( c==min(a,min(b,c)) ){
      
      cout << max(a,b)-c << endl;
      
    }
      
}


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

int main() {

  int A,B;
  cin >> A >> B;

  if(B == 1) {
    cout << 0 << endl;
    return 0;
  }


  int ans = 1;
  B -= A;

  
  while(B > 0) {
    ans++;
    B -= (A-1);
  }


  cout << ans << endl;
}




Measured memory_bytes: 256
import heapq

n, k = map(int,input().split())
X = [list(map(int,input().split())) for i in range(n)]

Y = [[j for j in i] for i in X]
Z = [[j for j in i] for i in X]

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

ans = float("inf")
for i in range(n):
    x0 = X[i][0]
    for j in range(n):
        y0 = Y[j][1]
        Q = []
        x1_ind = 0
        for p in range(n):
            if len(Q) == k:
                break
            else:
                if X[p][0] >= x0 and X[p][1] >= y0:
                    heapq.heappush(Q, [-X[p][1], X[p][0], X[p][1]])
                    x1_ind = p
        if len(Q) == k:
            x1 = X[x1_ind][0]
            pop = heapq.heappop(Q)
            y1 = -pop[0]
            heapq.heappush(Q, pop)
            ans = min(ans, (x1-x0) * (y1-y0))
            st = x1_ind
            for p in range(st+1, n):
                if X[p][0] >= x0 and X[p][1] >= y0:
                    heapq.heappush(Q, [-X[p][1], X[p][0], X[p][1]])
                    x1 = X[p][0]
                    heapq.heappop(Q)
                    pop = heapq.heappop(Q)
                    y1 = -pop[0]
                    heapq.heappush(Q, pop)
                    ans = min(ans, (x1-x0) * (y1-y0))
print(ans)

Measured memory_bytes: 60888
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cout << v << " ";                                                          \
  }                                                                            \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vec< int > a(N);
  vec< int > b(N);
  vec< vec< int > > bdig(30, vec< int >(N));
  REP(i, N) { cin >> a[i]; }
  REP(i, N) { cin >> b[i]; }
  REPS(i, 29) {
    REP(j, N) { bdig[i][j] = b[j] % BIT(i); }
    sort(ALL(bdig[i]));
  }
  int ans = 0;
  REPS(i, 29) {
    int p = 0;
    int T = BIT(i - 1);
    REP(j, N) {
      int val = a[j] % BIT(i);
      p += lower_bound(ALL(bdig[i]), 2 * T - val) -
           lower_bound(ALL(bdig[i]), T - val);
      p += lower_bound(ALL(bdig[i]), 4 * T - val) -
           lower_bound(ALL(bdig[i]), 3 * T - val);
      p %= 2;
    }
    ans += p * T;
  }
  print(ans);
}

Measured memory_bytes: 52324
import numpy as np
a = input().split()
b = []
money = 0
for i in range(int(a[0])):
  temp = []
  temp = [int(j) for j in input().split()]
  b.append(temp)
c = np.array(b)
idex=np.lexsort([c[:,0]])
sorted_data = c[idex, :]
n = int(a[1])
for i in range(int(a[0])):
  if sorted_data[i][1] <= n:
    money = money + sorted_data[i][0] * sorted_data[i][1]
    n = n - sorted_data[i][1]
  else:
    money = money + n*sorted_data[i][0]
    break
    
print(money)


Measured memory_bytes: 36072
pub struct Scanner {
    line: Vec<String>,
    idx: usize,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        return Scanner {
            line: vec![],
            idx: 0,
        };
    }
    fn next<T: std::str::FromStr>(&mut self) -> T {
        if self.idx == self.line.len() {
            let mut buffer = String::new();
            std::io::stdin().read_line(&mut buffer).ok();
            let a: Vec<&str> = buffer.trim().split(' ').collect();
            self.line = a.iter().map(|&s| String::from(s)).collect();
            self.idx = 0;
        }
        let ret: T = self.line[self.idx].parse::<T>().ok().expect("Parse error.");
        self.idx += 1;
        ret
    }
    fn next_string(&mut self) -> Vec<char> {
        let s: String = self.next();
        return s.chars().collect::<Vec<char>>();
    }
    fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut v: Vec<T> = Vec::with_capacity(n);
        for _i in 0..n {
            v.push(self.next());
        }
        v
    }
}

fn main(){
    let mut scan = Scanner::new();
    let mut a:i32 = scan.next();
    let b:i32 = scan.next();
    let mut c:i32 = scan.next();
    let d:i32 = scan.next();
    let ans: &str;
    loop {
        c -= b;
        if c <= 0{
            ans = "Yes";
            break;
        }
        a -= d;
        if a <= 0{
            ans = "No";
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2128
A,B,C,D,E,F = list(map(int,input().split()))

tmp = 0
ans = [0,0]
for i in range(31):
  a = A*i
  if a*100 >= F:
    break
  for j in range(31):
    b = B*j
    if a+b == 0:
      continue
    w = (a+b)*100
    if w >= F:
      break
    for k in range(3001):
      c = C*k
      for l in range(3001):
        d = D*l
        s = c+d
        if w + s > F:
          break
        if (c+d) <= (a+b)*E:
          if (s*100)/w >= tmp:
            tmp = (s*100)/w
            ans = [s+w,s]
        else:
          break

print(" ".join(map(str,ans)))

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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define FORR(v, c) for (auto &v : c)
#define F first
#define S second
#define SQ(x) (x)*(x)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define dbg(x) cerr<<#x<<" = " << (x) << endl
#define pnl(x) cout << x << '\n'
#define pns(x) cout << x << ' '
#define read(x) cin >> x
#define read2(x,y) cin >> x >> y
#define read3(x, y, z) cin >> x >> y >> z
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define readv(v) FORR(c,v) read(c)

struct Arrete { int v, c;};
struct Point {int x, y; double distance(Point other) const {return sqrt(SQ(x-other.x)+SQ(y-other.y));}};

typedef	vector<int>	vi;
typedef pair<int,int>	ii;
typedef vector<string>	vs;
typedef vector<ii>	vii;
typedef vector<Arrete>	vg;
typedef vector<long long>	vl;
typedef	long long ll;

const int	NB_D = 4;
const int	DY[] = {-1, 1, 0, 0};
const int	DX[] = {0, 0, -1, 1};

const int MAXN = 1e5;

ll dp[MAXN];

int		main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int N;
	read(N);
	
	vl h(N);
	readv(h);

	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);

	for (int i(2); i < N; ++i)
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));

	pnl(dp[N-1]);
}



Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	int cun = 0;
	for(int i = 0; i < N ; i++) {
		if ((N - i) % 2 == 1) 
			cun++;
	}
	double NN = N;
	double cun2 = cun;
	double ans;
	ans = cun2 / NN;
	cout << ans << "\n";
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
signed main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  double op,om,pp,pm,a,b;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>om>>pm>>op>>pp;
    if(op>=5 && pp>=2) cout<<(om*op+pm*pp)*0.8<<'\n';
    else{
      a=om*op+pm*pp;
      if(op>=5) b=(om*op+pm*2)*0.8;
      else if(pp>=2) b=(om*5+pm*pp)*0.8;
      else b=(om*5+pm*2)*0.8;
      if(a>=b) cout<<b<<'\n';
      else cout<<a<<'\n';
    }
  }
  return(0);
}



Measured memory_bytes: 3312
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define ncr(n,r) fact[n]*modInv(fact[r])*modInv(fact[n-r])
#define modInv(a) binExp(a,mod-2)
#define mod 1000000007
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//#define os_find(k) find_by_order(k)
//#define os_order(k) order_of_key(k)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)

int dp[101][100001];

signed main()
{
    fast

    int n,tw;
    cin>>n>>tw;

    int w[n+1], v[n+1];
    f1(i,1,n) cin>>w[i]>>v[i];

    f1(i,0,n) f1(j,1,100000) dp[i][j] = INT_MAX;
    f1(i,0,n) dp[i][0] = 0;
    
    f1(i,1,n)
    {
        f0(j,0,v[i]) dp[i][j] = dp[i-1][j];
        f1(j,v[i],100000)
        {
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i]);
        }
    }

    f3(i,100000,0)
    {
        if(dp[n][i] <= tw)
        {
            cout<<i;
            break;
        }
    }
}

Measured memory_bytes: 82388
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<lint> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        b[a[i] - 1] = i;
    }
    set<int> used = {-1, n};
    lint ret      = 0;
    for (int i = 0; i < n; ++i) {
        used.insert(b[i]);
        auto it = used.find(b[i]);
        ret += lint(i + 1) * (*next(it) - *it) * (*it - *prev(it));
    }
    cout << ret << "\n";
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double l, ans;
  if (x < (a * a * b) / 2) {
    l = (2.0 * x) / (a * b);
    ans = atan2(b, l);
  } else {
    l = (2 * (a * a * b - x)) / (a * a);
    ans = atan2(l, a);
  }
  ans *= 180;
  ans /= M_PI;
  printf("%.10f\n", ans);
  return 0;
}

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

int main(){
    int N;
    std::cin >> N;
    int x,ans;
    int i = 0;
    std::vector<std::vector<long int>> num(N,std::vector<long int>(21,0));
    
    while(N > 0 && std::cin >> x){
        if(N == 1){
            ans = x;
            break;
        }
        
        if(i == 0){
            ++num[i][x];
            ++i;
            --N;
        }
        else{
            for(int j = 0;j < 21;++j){
                if(num[i-1][j] > 0){
                    if(j+x <= 20){
                        num[i][j+x] += num[i-1][j];
                    }
                    if(j-x >= 0){
                        num[i][j-x] += num[i-1][j];
                    }
                }
            }
            ++i;
            --N;
        }
    }
    
    for(int j = 0;j < 21;++j)
        if(ans == j)
            std::cout << num[i-1][j] << std::endl;
}


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

int main(){
    string s;
    cin >> s;
    int sum = 0;
    for(int i= 0;i<s.length();i++){
        if(s[i] == '+'){
            sum += 1;
        }
        else{
            sum -= 1;
        }
    }
    cout << sum <<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
#define endl "\n"
const int mod=1e9+7;
const int MAX=1e6+7;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
   int n;cin>>n;
   if(n>=30)cout<<"Yes";
   else cout<<"No"; 
   
   
   return 0;
} 

Measured memory_bytes: 3648
import java.io.*;
import java.nio.CharBuffer;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        final int MOD = 1000000007;
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] f = new int[n + 1];
        Arrays.fill(f, -1);
        f[0] = 1;
        for (int i = 0; i < m; ++i) {
            f[scanner.nextInt()] = 0;
        }
        f[1] = f[1] < 0 ? 1 : 0;
        for (int i = 2; i <= n; ++i) {
            f[i] = f[i] < 0 ? (f[i - 1] + f[i - 2]) % MOD : 0;
        }
        writer.println(f[n]);

        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

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

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

int main(){
  string s, t;
  cin >> s >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

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


int main(){
    ll size, ans = 0, ans_tmp = 0;

    string s;
    cin >> size >> s;
    for(int i = 0; i < size; i++){
        if(s[i] == 'I'){
            ans_tmp++;
            ans = max(ans, ans_tmp);
        }else{
            ans_tmp--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool isprime[100001];
int like_2017_acc[100001];

int main(int argc, char *argv[]) {
	for (int i = 2; i < 100001; i++)
		isprime[i] = true;
	for (int i = 2; i < 317 /* sqrt(100001) */; i++)
		for (int j = i + i; j < 100001; j += i)
			isprime[j] = false;
	
	for (int i = 3; i < 100001; i += 2) {
		if (isprime[i] && isprime[(i + 1) / 2])
			like_2017_acc[i] = 1;
	}

	for (int i = 1; i < 100001; i++)
		like_2017_acc[i] += like_2017_acc[i - 1];

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int li, ri;
		cin >> li >> ri;
		cout << like_2017_acc[ri] - like_2017_acc[li - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>

using namespace std;



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    string s,t;
    cin>>s;
    cin>>t;
    int dem=0;
    for (int i=0; i<s.length(); i++)
    {
        if (s[i]==t[i]) dem++;
    }
    cout<<dem;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <tuple>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define f first
#define s second

ll inv(ll a, ll mod){
	ll b = mod, x = 0, y = 1, u = 1, v = 0;
	while(a){
		ll q = b / a, r = b % a;
		tie(x, y, u, v) = make_tuple(u, v, x - u * q, y - v * q);
		b = a, a = r;
	}
	return x + (x < 0) * mod;
}

ll a, x, b, y, c;
ll g, w, h, ia;
vector<pii> v;

bool works(ll f){
	int l = 0, r = v.size() - 1;
	while(r - l > 1){
		int mid = (l + r) / 2;
		if(f * (c - v[mid].s.s) >= y) l = mid;
		else r = mid;
	}
	
	ll dx = v[r].s.f - v[l].s.f, dy = v[r].s.s - v[l].s.s;
	dx /= v[r].f, dy /= v[r].f;
	
	return f * v[l].s.f + (f * (c - v[l].s.s) + dy - y - 1) / dy * dx <= x; 
}

void answer(){
	cin >> a >> x >> b >> y >> c;	
	
	g = __gcd(a, b);
	a /= g, b /= g, c /= __gcd(g, c);
	g = __gcd(a, c);
	a /= g, y /= g, c /= g;
	g = __gcd(b, c);
	b /= g, x /= g, c /= g;
	
	if(c == 1){
		cout << x + y << endl;
		return;
	}
	
	w = c, h = a * inv(b, c) % c, ia = inv(a, c);
	v.assign(1, {1, {0, 0}});
	while(w && h){
		if(w > h){
			ll t = w / h;
			w -= t * h;
			v.push_back({t, {(c - w) * b % c * ia % c, c - w}});
		}else if(h % w){
			h %= w;
		}else{
			v.push_back({1, {c, c}});
			break;
		}
	}
	v.back().s.f += !v.back().s.f * c;
	v.push_back({1, {c, c + 1}});
	
	ll l = y / c, r = x + y + 1;
	while(r - l > 1){
		ll mid = (l + r) / 2;
		if(works(mid)) l = mid;
		else r = mid;
	}
	
	cout << l << endl;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int t;
	cin >> t;
	
	for(int i = 0; i < t; i++) answer();

	return 0;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <random>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define inf (int)(1e9)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> psi;

int h,w,d;
int a[333][333];
int q;

vector<pii> pos;
int tmp[433*433];

int main(void){
  cin>>h>>w>>d;
  int a;
  pos.resize(433*433);
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      scanf("%d",&a);
      pos[a]=pii(i,j);
      tmp[a]=-1;
    }
  }
  int l,r;
  int res;
  for(int i=1;i<=d;i++){
    res=0;
    tmp[i]=0;
    for(int j=i;j<=w*h;j+=d){
      res+=abs(pos[j].first-pos[j+d].first)+abs(pos[j].second-pos[j+d].second);
      if(tmp[j+d]==-1) tmp[j+d]=res;
    }
  }

  cin>>q;
  for(int i=0;i<q;i++){
    scanf("%d %d",&l,&r);
    cout<<tmp[r]-tmp[l]<<endl;
  }

  return 0;
}

Measured memory_bytes: 2944
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

require 'bigdecimal'
require 'bigdecimal/util'

def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

a, b, c = gets_i_list
puts 4 * a * b < (c - a - b) ** 2 && c - a - b > 0 ? "Yes" : "No"

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

#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

struct Th {
	int size;
	int index;
};
bool operator<(Th a, Th b) { return a.size < b.size; }

int main() {
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	int N;
	cin >> N;
	vector<Th> th(N);
	rep(i,0,N) {
		th[i].index = i;
		cin >> th[i].size;
	}
	sort(all(th));
	ll si = th[0].size;
	int resi = 0;
	rep(i,1,N) {
		if (2*si < th[i].size)
			resi = i;
		si += th[i].size;
	}
	cout << N - resi << endl;
	exit(0);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;
int dp[20010][260];

int main()
{
    while (1) {
        int n, m; cin >> n >> m;
        if (!n) break;
        vector<int> C(m), x(n+1, 128);
        loop (m, i) cin >> C[i];
        loop (n, i) cin >> x[i+1];
        fill(dp[0], dp[20009]+260, 1<<29);
        loop (256, i) dp[n+1][i] = 0;

        for (int i = n; i >= 0; i--) {
            for (int j = 0; j < 256; j++) {
                int d = (x[i] - j) * (x[i] - j);
                for (int c : C) {
                    int k = j + c;
                    k = max(k, 0);
                    k = min(k, 255);
                    dp[i][j] = min(dp[i][j], dp[i+1][k] + d);
                }
            }
        }
        cout << dp[0][128] << endl;
    }
    return 0;
}

Measured memory_bytes: 21592
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    int road[50] = {0};
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        road[a]++;
        road[b]++;
    }
    for (int i = 1; i <= n; i++) {
        cout << road[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys

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

#n=5
#a=[2,4,4,0,2]

#n=7
#a=[6,4,0,2,4,0,2]

#n=8
#a=[7,5,1,1,7,3,5,3]

acnt=[0]*n

for i in range(n):
    acnt[a[i]]=acnt[a[i]]+1
    
mod=10**9+7   
if n%2==0:
    for i in range(1,n,2):
        if acnt[i]!=2:
            print(0)
            sys.exit()
    print(pow(2,n//2,mod))
elif n%2==1:
    if acnt[0]!=1:
        print(0)
    else:
        for i in range(2,n,2):
            if acnt[i]!=2:
                print(0)
                sys.exit()
        print(pow(2,n//2,mod))


Measured memory_bytes: 13880
#include<iostream>

int main(){
    int m, f, r;
    
    while(std::cin>>m>>f>>r){
        if (m==-1 && f==-1 && r==-1){
            break;
        }
        
        int sum= m+ f;
        if(m==-1 || f==-1 || sum<30){
            std::cout<< 'F' <<std::endl;
        }else if(sum>=80){
            std::cout<< 'A' <<std::endl;
        }else if(sum>=65 && sum<80){
            std::cout<< 'B' <<std::endl;
        }else if(sum>=50 && sum<65){
            std::cout<< 'C' <<std::endl;
            
        }else if(sum>=30 && sum<50 &&  r<50){
            std::cout<< 'D' <<std::endl;
        }else if(sum>=30 && sum<50 && r>=50){
            std::cout<< 'C' <<std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main()
{
    int n, q;
    queue<pair<string, int> > que, done;

    cin >> n >> q;
    for(int i=0; i<n; i++){
        string name;
        int time;
        cin >> name >> time;
        que.push(make_pair(name, time));
    }

    int total=0;
    while(!que.empty()){
        auto x=que.front(); que.pop();
        if(x.second > q){
            x.second-=q;
            que.push(x);
            total+=q;
        } else{
            total+=x.second;
            done.push(make_pair(x.first, total));
        }
    }

    while(!done.empty()){
        auto x=done.front(); done.pop();
        cout << x.first << " " << x.second << endl;
    }
    return 0;
}

Measured memory_bytes: 6156
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void) {
	bool flag = false;
	int check = 0;
	int count = 0;
	int total = INF;
	string s;
	string p;
	string t;

	cin >> s;
	p = s;
	t = s;

	FOR(i, 0, 25) {
		count = 0;
		check = 0;
		flag = false;
		s = p;
		t = s;
		if (s.size() == 1) {
			total = 0;
			break;
		}
		FOR(u, 0, s.size() - 2) {
			if (t[u] != 'a' + i) {
				break;
			}
			if (u == s.size() - 2) {
				total = 0;
				break;
			}
		}
		while (1) {
			FOR(u, 0, s.size() - 2) {
				if (s[u] == 'a' + i || s[u + 1] == 'a' + i) {
					check++;
					t[u] = 'a' + i;
				}

			}
			count++;
			if (check == 0) {
				break;
			}
			t.pop_back();
			FOR(u, 0, s.size() - 2) {
				if (t[u] != 'a' + i) {
					break;
				}
				if (u == s.size() - 2) {
					flag = true;
				}
			}
			s = t;

			if (flag == true) {
				if (count < total) {
					total = count;
				}
				break;
				s = p;
				t = s;
			}
		}

	}
	cout << total << endl;
	return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    string s; cin >> s;
    ll sum = 0;
    rep(i, (int)s.size()){
        sum += s[i] - '0';
    }
    if(sum%9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7868
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
using namespace std;

class osa_k{
private:
    vector<int> prime_sieve;
    vector<int> set_prime;
    int N;
    void eratosthenes(){
        for(int i=2;i*i<N;i++) {
            if(prime_sieve[i]<i) continue;
            for(int j=i*i;j<N;j+=i){
                if(prime_sieve[j]==j) prime_sieve[j] = i;
            }
        }                
    }

    void setPrimeSet(){
        for(int i=2;i<N;i++){
            if(prime_sieve[i]==i){
                set_prime.emplace_back(i);
            }
        }        
    }
public:    
    osa_k(const int n):N(n){
        prime_sieve.resize(n);
        iota(prime_sieve.begin(),prime_sieve.end(),0);
        eratosthenes();
        setPrimeSet();
    }

    vector<int> get_factor(int i) {
        vector<int> res;
        while(i>1){
            res.emplace_back(prime_sieve[i]);
            i/=prime_sieve[i];
        }
        //素因数の重複なしが欲しいなら、以下のコメントアウトを解除
        sort(res.begin(),res.end());
        decltype(res)::iterator result = unique(res.begin(), res.end());
        res.erase(result, res.end());
        return res;
    }

};



int main(){
    int n;cin>>n;
    osa_k o(1000005);
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    vector<int> s(1000005);
    int co=a[0];
    for(int i=0;i<n;i++){
        co=gcd(co,a[i]);
    }
    if(co!=1){
        cout<<"not coprime"<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        vector<int> tmp=o.get_factor(a[i]);
        for(int j=0;j<tmp.size();j++){
            if(s[tmp[j]]>0){
                cout<<"setwise coprime"<<endl;
                return 0;
            }
            else{
                s[tmp[j]]+=1;
            }
        }
    }
    cout<<"pairwise coprime"<<endl;    

    return 0;
}

Measured memory_bytes: 15324
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
constexpr long long int NINF = std::numeric_limits<long long int>::min();
#define int long long int

void solve() {
  string s;
  cin >> s;

  vector<char> v;
  for (int i = 0; i < 4; i++) {
    v.push_back(s[i]);
  }

  sort(v.begin(), v.end());

  if (v[0] == v[1] && v[2] == v[3] && v[0] != v[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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


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

using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll s;
  cin >> s;
  string S=to_string(s);
  ll a = 0;
  rep(i,S.size()) a += S[i]-'0';
  string ans = "No";
  if(s%a==0) ans="Yes";
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s []byte
	fmt.Scan(&s) // 1905

	ans := "NA"
	a, _ := strconv.Atoi(string(s[:2])) // 19
	b, _  := strconv.Atoi(string(s[2:])) //05
	if a >= 1 && a <= 12 {
		ans = "MMYY"
	}
	if b >= 1 && b <= 12 {
		if  ans == "MMYY" {
			fmt.Println("AMBIGUOUS")
			return
		}
		fmt.Println("YYMM")
		return
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1776
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(" ", $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function printIn($str = "")
    {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner;

$S = $sc->next();
$S = str_split($S);

$AZ = 'abcdefghijklmnopqrstuvwxyz';
$AZ = str_split($AZ);
$bt = [];
for ($i = 0; $i < count($AZ); $i++) {
    $bt[$AZ[$i]] = 0;
}

for ($i = 0; $i < count($S); $i++) {
    if (in_array($S[$i], $bt)) {
        $bt[$S[$i]] ++;
    }
}
if ($ans = array_search(0, $bt)) {
    echo $ans;
}else{
    echo "None";
}



Measured memory_bytes: 10744
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

// ALDS1_4_C
public class Main {
	void run() throws IOException {
		Set<String> dic = new HashSet<String>();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			String[] str = br.readLine().split(" ");
			switch(str[0]) {
			case "insert":
				dic.add(str[1]);
				break;
			case "find":
				if (dic.contains(str[1])) System.out.println("yes");
				else System.out.println("no");
				break;
			default:
				break;
			}
		}
	}
	
	public static void main(String[] args) throws IOException{
		new Main().run();
	}
}



Measured memory_bytes: 190096
import sys
input = sys.stdin.readline
from collections import Counter
def main():
    N = int(input())
    A = list(map(int, input().split()))
    s = [0] * (N+1)
    for i in range(N):
        s[i+1] = s[i] + A[i]
    ans = 0
    for v in Counter(s).values():
        ans += (v * (v-1) // 2)
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 104784
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
// #include <bits/stdc++.h> all

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  ll h,w; cin >> h >> w;
  if(h == 1 || w == 1){
    cout << 1 << endl;
    return 0;
  } else if(h*w%2 == 0){
    cout << (h*w)/2 << endl;
  } else {
    cout << ((h-1)/2)*w + (w+1)/2 << endl;
    return 0;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    ll ans=1LL*s.size()*(s.size()+1)/2;
    auto A=lcp_array(s,suffix_array(s));
    rep(i,A.size()) ans-=A[i];
    cout<<ans;
}

Measured memory_bytes: 15644
import copy

def bubble_sort(array):
    N = len(array)
    unsorted_num_exist = True
    for i in range(N):
        unsorted_num_exist = False
        for j in reversed(range(i, N - 1)):
            if array[j][1] > array[j + 1][1]:
                unsorted_num_exist = True
                array[j], array[j + 1] = array[j + 1], array[j]
        if not unsorted_num_exist:
            break

def selection_sort(array):
    N = len(array)
    for i in range(N):
        min_index = i
        for j in range(i, N):
            if array[j][1] < array[min_index][1]:
                min_index = j
        array[i], array[min_index] = array[min_index], array[i]
 

def putsarray(array):
    for i in range(len(array) - 1):
        print(array[i][0] + str(array[i][1]), end=' ')
    print(array[-1][0] + str(array[-1][1]))

def check_stable(origin, sorted):
    dict_origin = {}
    for e in origin:
        num = e[1]
        if num in dict_origin.keys():
            dict_origin[num].append(e[0])
        else:
            dict_origin[num] = [e[0]]
    dict_sorted = {}
    for e in sorted:
        num = e[1]
        if num in dict_sorted.keys():
            dict_sorted[num].append(e[0])
        else:
            dict_sorted[num] = [e[0]]
    
    return all(dict_origin[key] == dict_sorted[key] for key in dict_origin.keys())

if __name__ == "__main__":
    N = int(input())
    array = input().split()
    array = [[s[0], int(s[1])] for s in array]
    array2 = copy.deepcopy(array)
    array3 = copy.deepcopy(array)
    bubble_sort(array2)
    putsarray(array2)
    print("Stable" if check_stable(array, array2) else "Not stable")
    selection_sort(array3)
    putsarray(array3)
    print("Stable" if check_stable(array, array3) else "Not stable")


Measured memory_bytes: 6356
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
const ll mod = 1e9+7;
const ll INF = 1e18;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;
using V = vector<ll>;
using P = pair<ll,ll>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  rep(i,n) {
    cout << "ACL";
  }
  cout << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    ll l[q], r[q];
    rep(i, q){
        cin >> l[i] >> r[i];
        l[i]--, r[i]--;
    }

    ll mem[n];
    mem[0] = 0;
    for(ll i = 1; i < n; ++i){
        mem[i] = mem[i-1];
        if(s[i-1]=='A' && s[i] == 'C')mem[i]++;
    }
    rep(i, q)cout << mem[r[i]] - mem[l[i]] << endl;

}

Measured memory_bytes: 3456
n = int(input())

if n < 10:
    print(n)
elif 10 <= n < 100:
    print(9)
elif 100 <= n < 1000:
    print(9 + n - 99)
elif 1000 <= n < 10000:
    print(9 + 900)
elif 10000 <= n < 100000:
    print(9 + 900 + n - 9999)
else:
    print(9 + 900 + 90000)


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    string S; cin >> S;
    if(S[0] == S[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
void a()
{
  int a, b;
  cin >> a >> b;
  for(int i = 0; i < 16; i++)
  {
    if(i % 2 == 0)
    {
      a--;
    }else{
      b--;
    }
  }
  if(a <= 0 && b <= 0)
  {
    cout << "Yay" << endl;
  }else{
    cout << ":(" << endl;
  }
}
void b()
{
  int n, d;
  cin >> d >> n;
  if(d == 0)
  {
    if(n == 100)
    {
      cout << 101 << endl;
    }else{
      cout << n << endl;
    }
  }else if(d == 1)
  {
    if(n == 100)
    {
      cout << 10100 << endl;
    }else{
      cout << n * 100 << endl;
    }
  }else{
    if(n == 100)
    {
      cout << 1010000 << endl;
    }else{
      cout << n * 10000 << endl;
    }
  }
}
void c()
{
  int n;
  cin >> n;
  vector<long long int> a(n, 0);
  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  long long int total = 0;
  for(auto e : a)
  {
    if(e % 2 != 0) continue;
    while (e % 2 == 0)
    {
      e /= 2;
      total++;
    }
  }
  cout << total << endl;
}

int main() {
  b();
  return 0;
}


Measured memory_bytes: 764
a, b, c, d = map(int,input().split())

if a>=0 and b>=0:
    if d>=0:
        print(b*d)
    else:
        print(a*d)
elif a<0 and b>=0:
    if c>=0:
        print(b*d)
    else:
        print(max(a*c,b*d))
elif b<0:
    if d<0:
        print(a*c)
    else:
        print(max(a*c,b*c))

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

int n;
int a[200005] = {0};

void solve();

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) cin >> a[i];
  solve();
  cout << endl;
  return 0;
}

void solve() {
  for(int i = n - 1; i >= 0; i -= 2) {
    if(i != n - 1) cout << " ";
    cout << a[i];
  }
  for(int i = n % 2; i < n; i += 2) cout << " " << a[i];
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;
const int MOD = 1e9;

int32_t main()
{
	IOS;
	int n;
    cin>>n;
    set<string> s;

    for(int i=0;i<n;i++)
    {
    	string s1;
    	cin>>s1;
    	s.insert(s1);
    }

    cout<<s.size()<<endl;

	


		return 0;
}

Measured memory_bytes: 19268
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
#define SIZE(v) int(v.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

class Tree {
	int n;
	vector<vector<P>> edge;
	vector<int> dp;
	vector<vector<int>> dpL, dpR;
	int dfs(int i = 0, int p = -1) {
		int res = 0;
		int num = SIZE(edge[i]);
		dpL[i].resize(num + 2);
		dpR[i].resize(num + 2);
		REP(k, num) {
			int w, j;
			tie(w, j) = edge[i][k];
			if (j == p) continue;
			int part = dfs(j, i) + w;
			res = max(res, part);
			dpL[i][k + 1] = res;
			dpR[i][k + 1] = part;
		}
		REPR(k, num) {
			dpR[i][k + 1] = max(dpR[i][k + 1], dpR[i][k + 2]);
		}
		return dp[i] = res;
	}
	void dfs2(int i = 0, int p = -1) {
		int num = SIZE(edge[i]);
		REP(k, num) {
			int w, j;
			tie(w, j) = edge[i][k];
			if (j == p) continue;
			int part = max(dpL[i][k], dpR[i][k + 2]) + w;
			dp[j] = max(dp[j], part);
			int idx = 0;
			while (true) {
				bool end = !dpL[j][idx + 1];
				dpR[j][idx + 1] = max(dpR[j][idx + 1], part);
				if (end) break;
				++idx;
			}
			while (idx < SIZE(edge[j])) {
				dpL[j][idx + 1] = max(dpL[j][idx + 1], part);
				++idx;
			}
			dfs2(j, i);
		}
	}
public:
	Tree(int N) :n(N), edge(N), dp(N), dpL(N), dpR(N) { ; }
	void unite(int i, int j, int w) {
		edge[i].emplace_back(w, j);
		edge[j].emplace_back(w, i);
	}
	int diam() {
		dfs();
		dfs2();
		int res = 0;
		REP(i, n) {
			res = max(res, dp[i]);
		}
		return res;
	}
};

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

	int n;
	cin >> n;
	Tree tree(n);
	REP(i, n - 1) {
		int s, t, w;
		cin >> s >> t >> w;
		tree.unite(s, t, w);
	}
	cout << tree.diam() << endl;
	
	return 0;
}



Measured memory_bytes: 26252
var readline = require('readline');
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
});

let input =[];

rl.on('line', function (line) {
    input.push(line);
});

rl.on('close', function () {
    const arr = input[1].split(' ').map(x => Number(x));
    let sum = 0;
    currentBig = arr[0]; 
    for (let i = 0; i < arr.length; i++) {
        currentBig = Math.max(currentBig, arr[i]);
        sum += currentBig - arr[i];
    }
    console.log(sum);
});



Measured memory_bytes: 49852
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int X, Y;

int main() {
    cin >> X >> Y;
    int ans;
    if (X <= Y) {
        ans = Y-X;
        if (X <= 0 && 0 <= Y) {
            ans = min(ans, 1 + abs(abs(X)-abs(Y)));
        }
    } else {
        if (0 < Y) ans = 2 + (X-Y);
        else if (0 <= X) ans = 1 + abs(abs(X)-abs(Y));
        else ans = 2 + abs(abs(X)-abs(Y));
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;

ll gcd(ll a, ll b){
    if(a % b == 0) return b;
    else return (gcd(b, a % b));
}

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

int main(void){
    int n;
    cin >> n;
    int a[n];

    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int ans = a[0];
    for(int i = 0; i < n; i++){
        ans = lcm(ans, a[i]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef double D;
typedef complex<D> P;
const D EPS = 1e-9;
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)
D dot(P a, P b) {return (conj(a)*b).X; }
D cross(P a, P b) {  return (conj(a)*b).Y;}
P proj(P a1, P a2, P p) {
  return a1 + dot(a2-a1, p-a1)/norm(a2-a1) * (a2-a1);
}
P reflection(P a1, P a2, P p) {
  return 2.0*proj(a1, a2, p) - p;
}
P crosspointLL(P &a1, P &a2, P &b1, P &b2) {
  D d1 = cross(b2-b1, b1-a1);
  D d2 = cross(b2-b1, a2-a1);
  if (EQ(d1, 0) && EQ(d2, 0)) return a1;
  return a1 + d1/d2 * (a2-a1);
}
string s;
int p=0;
typedef struct{
  int x;
  P p1,p2;
} P1;
P1 marge(P1 a,P1 b){
  P1 res;
  res.x=1;
  if(a.x==1&&b.x==2)swap(a,b);
  if(a.x==1&&b.x==1){
    res.x=2;
    res.p1=a.p1;
    res.p2=b.p1;
  }
  else if(a.x==2&&b.x==1){
    res.p1=reflection(a.p1,a.p2,b.p1);
  }
  else{
    res.p1=crosspointLL(a.p1,a.p2,b.p1,b.p2);
  }
  return res;
}
P1 bnf();
P1 get(){
  P1 res;
  res.x=1;
  if(s[p]=='(')p++,res=bnf(),p++;
  else{
    int f=0,g=0;
    double x=0,y=0;
    if(s[p]=='-')f++,p++;
    while(isdigit(s[p]))x=x*10+(s[p++]-'0');
    p++;
    if(s[p]=='-')g++,p++;
    while(isdigit(s[p]))y=y*10+(s[p++]-'0');
    if(f)x-=x*2;
    if(g)y-=y*2;
    res.p1=P(x,y);
  }
  return res;
}
P1 bnf(){
  P1 res=get();
  while(s[p]=='@'){
    p++;
    P1 t=get();
    res=marge(t,res);
  }
  return res;
}
main(){
  while(cin>>s,s!="#"){
    p=0;
    P1 ans=bnf();
    printf("%.9f %.9f\n",ans.p1.X,ans.p1.Y);
  }
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  string s;
  cin >> s;
  ll n = s.length();
  vector<ll> sum(n + 1);
  sum[n] = 0;
  ll d = 1;
  REPR(i, n - 1) {
    sum[i] = (sum[i + 1] + d * (s[i] - '0')) % 2019;
    d *= 10;
    d %= 2019;
  }

  map<ll, ll> mp;
  mp[0]++;
  ll ans = 0;
  REPR(i, n - 1) {
    ans += mp[sum[i]];
    mp[sum[i]]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5116
n = int(input())

'''ans= 0
for i in range(1,  n+1):
  k  = n//i
  ans += k * (k+1) // 2 * i
print(ans)'''

print(
  sum(
    list( (n//i) *(n//i + 1) //2 * i  for i in range(1, n+1))
  )
)

Measured memory_bytes: 404408