akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int T = Integer.parseInt(sc.next());
		int A = Integer.parseInt(sc.next());
		ArrayList<Integer> high = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			high.add(Integer.parseInt(sc.next()));
		}
		sc.close();

		int ans = 0;
		int min = Integer.MAX_VALUE;
		for(int i = 0; i < N; i++) {
			int tmp = T * 1000 - high.get(i) * 6;
			if(Math.min(min, Math.abs(1000 * A - tmp)) == Math.abs(1000 * A - tmp)) {
				min = Math.min(min, Math.abs(1000 * A - tmp));
				ans = i + 1;
			}else {
				continue;
			}
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 22100
// abc137c.cpp : Green Bin
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

	vector<ll> v;
	while (n--){
		string s; cin>>s;
		sort(s.begin(), s.end());
		ll k = 0, power = 1;
		for(int j=9; j>=0; j--){
			k += power * (s[j]-'a');
			power *= 26;
		}
		v.push_back(k);
	}

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

	ll ans = 0, c = 1, d = v[0];
	for(int i=1; i<v.size(); i++){
		if(d==v[i]) c++;
		else{
			if(c>1) ans += c * (c-1) / 2L;
			c = 1;
			d = v[i];
		}
	}
	if(c>1) ans += c * (c-1) / 2L;
	cout<< ans << endl;
}

Measured memory_bytes: 1400
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      mut aa: [i64; n],
    }
    aa.sort();
    if aa.len() == 1 {
        return println!("{}", aa[0]);
    }
    if aa.len() == 2 {
        println!("{}", aa[1] - aa[0]);
        println!("{} {}", aa[1], aa[0]);
        return;
    }

    let mut ps = vec![];
    let mut ms = vec![];
    for a in aa {
        if a>=0 {
            ps.push(a);
        } else {
            ms.push(a);
        }
    }
    ps.sort();
    ms.sort();
    ms.reverse();
    let mut ans = vec![];
    if ms.len() == 0 {
        ms.push(ps[0]-ps[1]);
        ans.push((ps[0], ps[1]));
        ps.remove(0);
        ps.remove(0);
    } else if ps.len() == 0 {
        ps.push(ms[0]-ms[1]);
        ans.push((ms[0], ms[1]));
        ms.remove(0);
        ms.remove(0);
    }

    let m = ms[0];
    let p = ps[0];
    let mut cur = m;
    ms.remove(0);
    ps.remove(0);
    for p in ps {
        ans.push((cur, p));
        cur -= p;
    }
    ans.push((p, cur));
    cur = p - cur;
    for m in ms {
        ans.push((cur, m));
        cur -= m;
    }

    println!("{}", cur);
    for (a,b) in ans {
        println!("{} {}", a, b);
    }
}


Measured memory_bytes: 10492
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

n,k = LI()
f = [-1]*(k+1)
p = 2
while p <= k:
    x = 2*p
    while x <= k:
        f[x] -= f[p]
        x += p
    p += 1
ans = 0
p = [1]
for i in range(1,k+1):
    p.append(pow(k//i,n,mod))
for i in range(1,k+1):
    res = p[i]
    x = 2*i
    j = 2
    while x <= k:
        res += p[x]*f[j]
        x += i
        j += 1
    ans += i*res
    ans %= mod
print(ans%mod)


Measured memory_bytes: 75640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[200005];
int n;
int b[500005];
int main()
{
    scanf("%d",&n);
    int nn=n;
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]);
    int mid=500000/2;
    for(int i=0;i<500005;i++)
        b[i]=-1;
    int flag=-1;
    b[mid]=a[1];
    n--;
    int st=mid;
    int ed=mid;
    int k=1;
    while(n)
    {
        k++;
        if(flag<0)
        {
            ed++;
            b[ed]=a[k];
        }

        else
        {
            st--;
            b[st]=a[k];
        }
        flag=-flag;
        n--;
        //printf("%d",a[k]);
    }
    int cnt=0;
        int c=0;
    //printf("%d\n",nn);
    //printf("%d %d",st,ed);
    n=nn;
    if(n%2==0)
    {
        for(int i=ed; i>=st; i--)
        {
            if(b[i]==-1)
                continue;
            else
            {
                cnt++;
                //p=1;
                if(cnt==n)
                {
                    printf("%d\n",b[i]);
                    break;
                }
                else
                    printf("%d ",b[i]);
                c++;
            }
        }
    }

    else
    {
        for(int i=st; i<=ed; i++)
        {
            if(b[i]==-1)
                continue;
            else
            {
                cnt++;
                if(cnt==n)
                {
                    printf("%d\n",b[i]);
                    break;
                }
                else
                    printf("%d ",b[i]);
                c++;
            }
        }
    }

}

Measured memory_bytes: 4864
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (a, b, c, d, e, f) = (v[0], v[1], v[2], v[3], v[4], v[5]);

    let mut ans_sugar = 0;
    let mut ans_water = 0;
    let mut max_density = -0.1f64;
    for ai in 0..f {
        if a * ai * 100 > f {
            break;
        }
        for bi in 0..f {
            let water = (a * ai + b * bi) * 100;
            if water > f {
                break;
            }
            for ci in 0..f {
                if water + ci * c > f {
                    break;
                }
                if ci * c > water / 100 * e {
                    break;
                }
                let di1 = (f - (water + ci * c)) / d;
                let di2 = (water / 100 * e - ci * c) / d;
                let di = min(di1, di2);
                let sugar = ci * c + di * d;

                let density = 100.0 * sugar as f64 / (sugar as f64 + water as f64);

                // debug!(density, water, sugar);
                if density > max_density {
                    // debug!(density, ci, di);
                    max_density = density;
                    ans_sugar = sugar;
                    ans_water = water;
                }
            }
        }
    }

    println!("{} {}", ans_water + ans_sugar, ans_sugar);
}

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 read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

using namespace std;
using ll = long long;

int main() {
    int A = 0;
    cin >> A;
    int B = 0;
    cin >> B;
    int M = 0;
    cin >> M;
    int ans = 100000000;
    vector<int> a(A,0);
    for(int i = 0; i < A; i++) {
        cin >> a.at(i);
    }
    vector<int> b(B,0);
    for(int i = 0; i < B; i++) {
        cin >> b.at(i);
    }

    int x, y, c;
    for(int i = 0; i < M; i++) {
        cin >> x >> y >> c;
        ans = min(ans,a.at(x - 1) + b.at(y - 1) - c);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    
    cout << min(ans,a.at(0) + b.at(0)) << endl;

    return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define sp ' '
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;
const int mod998 = 998244353;

int N, K, a[100000], res, d[100000];
vector<int>r[100000];
priority_queue<pair<int, int>>q;
void dfs(int x, int dis) {
	d[x] = dis;
	q.push(mkp(dis, x));
	for (int i : r[x]) {
		dfs(i, dis + 1);
	}
}

void dfs2(int x) {
	d[x] = 0;
	for (int i : r[x]) {
		if (d[i])dfs2(i);
	}
}

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	if (a[0] != 1)++res;
	for (int i = 1; i < N; ++i) {
		r[a[i] - 1].push_back(i);
	}
	dfs(0, 0);
	while (!q.empty()) {
		if (d[q.top().second] > K) {
			int t = q.top().second;
			for (int i = 1; i < K; ++i) {
				t = a[t] - 1;
			}
			dfs2(t);
			++res;
		}
		q.pop();
	}
	cout << res << endl;
	return 0;
}

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

int main() {
  ios::ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  vector<int> d1(s.size()), d2(s.size());
  d1[0] = s[0] - '0';
  d2[0] = 10 - d1[0];
  for (int i = 1; i < s.size(); i++) {
    int val = s[i] - '0';
    d1[i] = min(d1[i - 1], d2[i - 1] + 1) + val;
    d2[i] = min(d1[i - 1] + (10 - val), d2[i - 1] + (10 - val - 1));
  }
  cout << min(d1[s.size() - 1], d2[s.size() - 1] + 1) << '\n';
}

Measured memory_bytes: 9116
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    int s0 = s[0] - '0';
    int s1 = s[1] - '0';
    int s2 = s[2] - '0';
    int s3 = s[3] - '0';

    int s01 = 10 * s0 + s1;
    int s23 = 10 * s2 + s3;

    if (1 <= s01 &&  s01 <= 12 && 1 <= s23 && s23 <= 12) {
        cout << "AMBIGUOUS";
    } else if (1 <=s01 && s01 <= 12 ) {
        cout << "MMYY";
    } else if (1 <= s23 && s23 <= 12) {
        cout << "YYMM";
    } else {
        cout << "NA";
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<queue>
#include<set>
#include<string>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORL(i,a,b) for(ll i=(a);i<(b);++i)
#define REPL(i,n) FORL(i,0,n)
#define INFTY (2e+9)

using namespace std;

/*
merge(A, left, mid, right)
n1 = mid - left;
n2 = right - mid;
L[0...n1], R[0...n2] を生成
for i = 0 to n1-1
L[i] = A[left + i]
for i = 0 to n2-1
R[i] = A[mid + i]
L[n1] = INFTY
R[n2] = INFTY
i = 0
j = 0
for k = left to right-1
if L[i] <= R[j]
A[k] = L[i]
i = i + 1
else
A[k] = R[j]
j = j + 1
*/
int merge(int A[], int left, int mid, int right){
	int c = 0, n1, n2;
	n1 = mid - left;
	n2 = right - mid;
	int *L, *R;
	L = new int[n1 + 1];
	R = new int[n2 + 1];
	REP(i, n1){
		L[i] = A[left + i];
	}
	REP(i, n2){
		R[i] = A[mid + i];
	}
	L[n1] = INFTY;
	R[n2] = INFTY;
	int i = 0, j = 0;
	FOR(k, left, right){
		if (L[i] <= R[j]){
			A[k] = L[i];
			i++;
		}
		else{
			A[k] = R[j];
			j++;
		}
		c++;
	}
	delete[] L;
	delete[] R;
	return c;
}
/*
mergeSort(A, left, right)
if left+1 < right
mid = (left + right)/2;
mergeSort(A, left, mid)
mergeSort(A, mid, right)
merge(A, left, mid, right)
*/
int mergeSort(int A[], int left, int right){
	int c = 0, mid;
	if (left + 1 < right){
		mid = (left + right) / 2;
		c += mergeSort(A, left, mid);
		c += mergeSort(A, mid, right);
		c += merge(A, left, mid, right);
	}
	return c;
}

int main(){
	int n, S[500000];
	scanf("%d", &n);
	REP(i, n){
		scanf(" %d", &S[i]);
	}

	int c;
	c = mergeSort(S, 0, n);

	REP(i, n){
		if (i != 0){
			printf(" ");
		}
		printf("%d", S[i]);
	}
	printf("\n%d\n", c);

	return 0;
}


Measured memory_bytes: 6812
#include <bits/stdc++.h>
#define maxn 100005
using namespace std;

int a[maxn];

int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n);
    if(a[n] - a[1] >= 2)
    {
        cout << "No" << endl;
        return 0;
    }
    else if(a[n] - a[1] == 1)
    {
        int cnt = 0;
        for(int i = 1; i <= n; i++)
        {
            if(a[i] == a[1])
            {
                cnt++;
            }
        }
        // cout << cnt << a[n] << endl;
        if(n - cnt >= 2 * (a[n] - cnt) && a[n] - cnt > 0)
        {
            cout << "Yes" << endl;
            return 0;
        }
        else
        {
            cout << "No" << endl;
            return 0;
        }
    }
    else
    {
        if(a[1] == n - 1)
        {
            cout << "Yes" << endl;
            return 0;
        }
        if(a[1] * 2 <= n)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
        
    }
    
}

Measured memory_bytes: 640
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

#[allow(unused_macros)]
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize, k: usize,
        d: [usize; k],
    }
    let mut v = vec![true; 10];
    for i in 0..k {
        v[d[i]] = false;
    }

    'outer: for i in 0..n * 100 {
        if i < n {
            continue;
        }
        let mut x = i;
        while x > 0 {
            let m = x % 10;
            if !v[m] {
                continue 'outer;
            }
            x /= 10;
        }
        println!("{}", i);
        return;
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a,const void *b){
    return *(int*)a-*(int*)b;
}
int main(void){
    int n,i;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    qsort(a,n,sizeof(int),asc);
    printf("%d",a[n/2]-a[n/2-1]);
    return 0;
}

Measured memory_bytes: 892
#include<stdio.h>

int main ()
{
   int a, b, c;

   scanf("%d", &a);
   scanf("%d", &b);
   scanf("%d", &c);

   if (a < b && b < c){
      printf("Yes\n");
   } else {
      printf("No\n");
   }

   return 0;

}

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

int main() {
	// your code goes here
	int n, cnt=0;
	cin >> n;
	
	unsigned long long m[n];
	for(int i=0; i<n; i++) cin >> m[i];
	
	bool hflag = false, mflag = false;
	
	for(int i=0; i<n-1; i++) {
		if(m[i] > m[i+1]) mflag = true;
		else if(m[i] < m[i+1]) hflag = true;
		
		if(mflag && hflag) {
			cnt++;
			mflag = false;
			hflag = false;
		}
	}
	
	cout << cnt + 1 << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

char buff[40010];
int u[10010];
int s[10010];
int n;

int memo[2][10010];

int solve(int now, int us){
  if(now == n){
    if(s[now]){
      if(us == 0) return 3;
      else return 2;
    }else if(u[now]){
      return 1;
    }else{
      return us;
    }
  }

  if(memo[us][now]) return memo[us][now];

  int ret = INT_MAX;

  if(u[now] && s[now]){
    ret = min(ret, 2 + solve(now+1, 0));
    ret = min(ret, 2 + solve(now+1, 1));
  }else if(u[now]){
    ret = min(ret, 1 + solve(now+1, 1));
    ret = min(ret, 1 + solve(now+1, 0));
  }else if(s[now]){
    if(us == 0){
      ret = 2 + solve(now+1, 1);
    }else{
      ret = 1 + solve(now+1, 1);
    }
  }else{
    ret = solve(now+1, us);
  }

  //printf("solve(%d,%d)=%d\n",now,us,ret+1);
  return memo[us][now] = ret + 1;
}

int main(){
  int t;
  scanf("%d",&t);
  while(t --> 0){
    scanf("%d %s",&n,buff);
    u[0] = (buff[0] == 'Y');
    s[0] = (buff[n+n] == 'Y');
    u[n] = (buff[n+n-1] == 'Y');
    s[n] = (buff[n+n+n+n-1] == 'Y');

    REP(i,n-1){
      u[i+1] = ((buff[2*i+1] == 'Y') | (buff[2*(i+1)] == 'Y'));
      s[i+1] = ((buff[n+n+2*i+1] == 'Y') | (buff[n+n+2*(i+1)] == 'Y'));
    }

    //REP(i,n+1) printf("%d ",u[i]); puts("");
    //REP(i,n+1) printf("%d ",s[i]); puts("");

    memset(memo,0,sizeof(memo));
    print(solve(0,0));
  }
  return 0;
}

Measured memory_bytes: 0
n = int(input())
a = sorted(map(int,input().split()))
ruiseki = [0]
for i in range(n):
    ruiseki.append(ruiseki[-1]+a[i])
ruiseki = ruiseki[1:]

ans = 0
for i in range(n)[::-1]:
    eater = ruiseki[i]
    if i==n-1 or eater*2 >= a[i+1]:
        ans +=1
    else:
        break
print(ans)

Measured memory_bytes: 14320
f = open(0)
R, C = map(int, f.readline().split())
ans = [0]*(C+1)
res = []
for line in f.readlines():
    *D, = map(int, line.split())
    for i, v in enumerate(D):
        ans[i] += v
    s = sum(D)
    ans[-1] += s
    res.append(line.strip())
    res.append(" %d\n" % s)
res.append(" ".join(map(str, ans)))
res.append("\n")
open(1, 'w').writelines(res)


Measured memory_bytes: 5628
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<iomanip>
#include<math.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;

int main(){
    double a, b, h, m; cin >> a >> b >> h >> m;
    double pi = M_PI;
    double x = 2*pi*(h+m/60)/12;
    double y = 2*pi*m/60;
    double theta = x-y;
    if(theta < 0) theta = -theta;
    //if(theta > pi) theta -= pi;
    double z = a*a+b*b-2.0*a*b*cos(theta);
    cout << fixed;
    cout << setprecision(10) << sqrt(z) << endl;
}


Measured memory_bytes: 4184
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize,
        x: [u64; n]
    }

    let mut xs = x.clone();
    xs.sort();

    let old_mid = xs[(n+1)/2];
    let old_mid_prev = xs[(n+1)/2-1];

    for i in 0..n {
        if x[i] < old_mid {
            println!("{}", old_mid);
        } else {
            println!("{}", old_mid_prev);
        }
    }
}

Measured memory_bytes: 10364
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int n;
    cin >> n;
    vector<int> v;
    int x=0, y=0;
    for (int i = 0; i < n; ++i) {
        int a=0;
        cin >> a;
        v.push_back(a);
    }
    for (int i = 0; i < n; ++i) {
        int a=0;
        cin >> a;
        if (a<v[i]) {
            x+= v[i];
            y+= a;
        }
    }

    cout << x - y << endl;
    return 0;
}

Measured memory_bytes: 256
'use strict';
function main(input) {
    var args = input.trim().split(' ').map((n) => parseInt(n, 10));
  	let result = '-1 -1 -1'
  	loopout:
  	for(let i=0;i<=args[0];i++) {
    for(let j=0;j<=args[0];j++) {
      if(i+j > args[0]) continue
      const k = args[0] - (i+j)
      if(i+j+k === args[0]){
        if(i*10000+j*5000+k*1000 === args[1]) {
          result = `${i} ${j} ${k}`
          console.log(result)
          break loopout;
        }
      }
    }
    }
    if (result === '-1 -1 -1') console.log(result)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<stdio.h>
int main(void){
   int n, N[5000], sum, max, i, j;
   scanf("%d", &n);
   while ( n ) {
       max = -100000;
       for ( i = 0; i < n; i++ ) {
           scanf("%d", &N[i]);
       }
       for ( i = 0; i < n; i++ ) {
           sum = 0;
           for ( j = i; j < n; j++ ) {
               sum += N[j];
               if ( sum > max ) max = sum;
               /*printf("sum:%d\n", sum);*/
           }
       }
       printf("%d\n", max);
       scanf("%d", &n);
   }
   return 0;
}

Measured memory_bytes: 1816
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,pre=0,x;long long sum=0;scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		if(pre>x){sum+=pre-x,x=pre;}
		pre=x;
	}
	printf("%lld",sum);
	return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
int main(){
  long long X,Y;
  cin>>X>>Y;
  long long cnt=0;
  long long now=X;
  while(now<=Y){
    now*=2;
    cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = str(input())
result =''

for i in range(len(s)):
  if (ord(s[i]) + n <= ord('Z')):
    result = result + chr(ord(s[i]) + n)
  else:
    result = result + chr(ord(s[i]) + n - 26)

print(result)

Measured memory_bytes: 3060
// In the name of Allah. Ya ali!
#include<bits/stdc++.h>
#define double long double
typedef long long ll;
const ll MAX_N = 3000;
const ll MOD = 1e9+7;
using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if (min(a,b)<=c and c<=max(a,b))
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64, i64> P;
#define rep(i, s, e) for (int i = (s); i <= (e); i++)

string s;

vector<int> cou(26,0);
int main(){
  cin >> s;
  for(char c : s){
    cou[c - 'a']++;
  }

  int odd = 0;

  for(int v : cou){
    odd += v % 2;
  }

  cout << min(odd / 2,max(0,odd - 1)) << endl;
}


Measured memory_bytes: 3224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (final Scanner sc = new Scanner(System.in)) {
			Resolver resolver = new Resolver(sc);
			resolver.resolve();
		}
	}
	private static class Resolver
	{
		private final int a,b,t;
		private Resolver(final Scanner sc) {
			this.a = sc.nextInt();
			this.b = sc.nextInt();
			this.t = sc.nextInt();
		}
		private void resolve() {
			int k = t/a;
			System.out.println(b*k);
		}
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(1){
    int n, m;
    cin>>n>>m;
    if(n == 0 && m == 0) break;
    vector<vector<int> > G(n);
    for(int i=0;i<m;i++){
      int u, v;
      cin>>u>>v; u--,v--;
      G[u].push_back(v);
      G[v].push_back(u);
    }

  

    vector<int> type(n, -1);
    function<int(int,int,int)> dfs = [&](int pos,int pre, int col){
      if(type[pos] != -1)  return (int)(type[pos] == col);
      type[pos] = col;

      for(int to:G[pos]){
	if(to == pre) continue;
	if(dfs(to, pos, !col) == 0) return 0;
      }
      return 1;    
    };


    int flag = dfs(0, 0, 0);
    if(flag == 0){
      cout<<0<<endl;
    }
    else{
      int cnt0 = 0;
      for(int i=0;i<n;i++) cnt0 += (type[i] == 0);
      int cnt1 = n - cnt0;
      vector<int> ans;
      if(cnt0%2 == 0) ans.push_back(cnt0/2);
      if(cnt0 != cnt1 && cnt1%2 == 0) ans.push_back(cnt1/2);
      sort(ans.begin(), ans.end());
      cout<<ans.size()<<endl;
      for(int i=0;i<(int)ans.size();i++) cout<<ans[i]<<endl;
    }
  }
  
  return 0;
}



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

int D, G;
int p[10], c[10];
int all[10];
vector<int> ans;

void dfs(string used, int score, int solved, int count)
{
  if (G <= score)
  {
    ans.push_back(solved);
    return;
  }
  if (count == D)
  {
    set<int> st;
    for (int i = 0; i < used.length(); i++)
    {
      if (used[i] != ':')
        st.insert(used[i] - '0');
    }
    for (int i = D - 1; i >= 0; i--)
    {
      if (st.find(i) == st.end())
      {
        int sub = i;
        for (int j = 0; j < p[sub] - 1; j++)
        {
          score += (sub + 1) * 100;
          solved++;
          if (G <= score)
          {
            ans.push_back(solved);
            return;
          }
        }
      }
    }
    return;
  }
  dfs(used + ":" + to_string(count), score + all[count], solved + p[count], count + 1);
  dfs(used, score, solved, count + 1);
}

int main()
{
  cin >> D >> G;
  for (int i = 0; i < D; i++)
    cin >> p[i] >> c[i];
  for (int i = 0; i < D; i++)
    all[i] = (i + 1) * 100 * p[i] + c[i];
  dfs("", 0, 0, 0);
  sort(ans.begin(), ans.end());
  cout << ans[0] << endl;
  return 0;
}

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

using namespace std;

void addEdge(vector<int> adj[], int u, int v){
	adj[u].push_back(v);
}

void DFSUtil(vector<int> adj[], vector<bool> &visited, vector<int> &sort, int u){
	visited[u]=true;
	for(int i=0;i<adj[u].size();i++){
		if(visited[adj[u][i]]==false){
			DFSUtil(adj, visited, sort, adj[u][i]);
		}
	}
	sort.push_back(u);
}

void DFS(vector<int> adj[], int V, vector<int> &sort){
	vector <bool> visited(V,false);
	for(int u=0;u<V;u++){
		if(visited[u]==false){
			DFSUtil(adj, visited, sort, u);
		}	
	}
}


int main(){
	int n;
	int m;
	cin>>n>>m;
	vector <int> adj[n];
	vector <int> sort;
	for(int i=0;i<m;i++){
		int v1;
		int v2;
		cin>>v1>>v2;
		addEdge(adj, v1-1, v2-1);
	}
	DFS(adj,n,sort);
	int max[n];
	for(int i=0;i<n;i++){
		max[i]=0;
	}
	for(int i=1;i<sort.size();i++){
		for(int j=0;j<adj[sort[i]].size();j++){
			if(max[adj[sort[i]][j]]+1>max[sort[i]]){
				max[sort[i]] = max[adj[sort[i]][j]]+1;
			}
		}
	}
	int maximum = 0;
	for(int i=0;i<n;i++){
		if(max[i]>maximum){
			maximum = max[i];
		}
	}
	cout<<maximum;
	return 0;	

}

Measured memory_bytes: 9084
import java.util.Scanner;

public class Main{
	static int gcd(int x,int y){
		if(x%y!=0)
			return gcd(y,x%y);
		else
			return y;
	}

	public static void main(String[] arts){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		System.out.println(gcd(x,y));
	}
}


Measured memory_bytes: 26300
#include<bits/stdc++.h>
using namespace std; 
int main()
{int a,b;
 cin>>a>>b;
 a--;b--;
 if(a==0)
   a=13;
 if(b==0)
   b=13;
 if(a==b)
   cout<<"Draw"<<endl;
 else
   {if(a>b)
      cout<<"Alice"<<endl;
    else
      cout<<"Bob"<<endl;
   }
}

Measured memory_bytes: 256
data = list()
for i in range(int(input())):
    data.append(int(input()))

max_diff = -1000000000
min_data = data[0]
for value in data[1:] :
    max_diff = max(max_diff, value - min_data)
    min_data = min(min_data, value)

print(max_diff) 


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

int n;
string s;

int main(){

    cin >> n >> s;
    vector<char> ans(s.size());
    map<char, int> dict;
    int i;
    for (i=0; i<26; i++){
        char tmp = 'A'+ i;
        dict[tmp] = i;
    }
    for (i=0; i<s.size(); i++){
        int pos = dict[s.at(i)] + n;
        //  アルファベットは26文字なので等号を入れないとpos==26で結果がおかしくなる
        if (pos >= 26){
            ans.at(i) = (char)('A' + pos - 26);
        }
        else{
            ans.at(i) = (char)(s.at(i) + n);
        }
    }

    for (auto x: ans){
        cout << x;
    }
    cout << endl;
    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 ALL(v) (v).begin(),(v).end()

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=200020;

int n;
int p[200020];

int main(){
	cin>>n;
	REP(i,n)cin>>p[i];
	vector<pii> v(n);
	REP(i,n)v[i]=pii(p[i],i);
	sort(v.begin(),v.end());
	int cnt=1;
	int mx=0;
	REP(i,n-1){
		if(v[i].second<v[i+1].second)cnt++;
		else{
			mx=max(mx,cnt);
			cnt=1;
		}
	}
	mx=max(mx,cnt);
	cout<<n-mx<<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#ifdef LOCAL
#define TIMER cerr<<clock()<<"ms\n"
#else
#define TIMER
#endif
#define SZ 666666
typedef pair<ll,ll> pll;
vector<pll> f[SZ];
int n,ch[SZ][2],cw[SZ][2],cur[SZ];
ll S;
void dp(int x)
{
	if(!cur[x])
	{
		f[x].pb(pll(0,0));
		return;
	}
	int c0=ch[x][0],c1=ch[x][1];
	int w0=cw[x][0],w1=cw[x][1];
	dp(c0); dp(c1);
	vector<pll> tmp;
	int s0=f[c0].size(),s1=f[c1].size();
	for(int i=0,j=0;i<s0;i++)
	{
		while(j<s1&&f[c0][i].se+f[c1][j].fi+w0+w1<=S) ++j;
		if(j) tmp.pb(pll(f[c0][i].fi+w0,f[c1][j-1].se+w1));
	}
	for(int i=0,j=0;i<s1;i++)
	{
		while(j<s0&&f[c1][i].se+f[c0][j].fi+w0+w1<=S) ++j;
		if(j) tmp.pb(pll(f[c1][i].fi+w1,f[c0][j-1].se+w0));
	}
	if(!tmp.size()) return;
	sort(tmp.begin(),tmp.end());
	ll tat=1e18*5;
	for(int i=0;i<tmp.size();i++)
	{
		if(tmp[i].se>=tat) continue;
		tat=tmp[i].se; f[x].pb(tmp[i]);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		int a,v;
		scanf("%d%d",&a,&v);
		ch[a][cur[a]]=i;
		cw[a][cur[a]]=v;
		++cur[a];
	}
	ll L=0,R=1e18;
	while(L<R)
	{
		for(int i=1;i<=n;i++) f[i].clear();
		S=(L+R)>>1; dp(1);
		if(f[1].size()) R=S; else L=S+1;
	}
	printf("%lld\n",L);
}


Measured memory_bytes: 44044
import java.util.Scanner;
public class Main{
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	int M1=sc.nextInt();
	int D1=sc.nextInt();
	int M2=sc.nextInt();
	int D2=sc.nextInt();

	if(M1==M2)
	System.out.println(0);
	else
	System.out.println(1);
}
}

Measured memory_bytes: 23764
/**
 * @Author:      WeakestRookie
 * @Email:       1311053296@qq.com
 * @DateTime:    2019-05-19 20:06:44
 * @Description: Description 
 */
#include<bits/stdc++.h>
using namespace std;

#define rep(x, y, z) for(int x = y; x < z; ++x)
#define dwn(x, y, z) for(int x = y; x >= z;--x)
#define mst(a, b) memset(a, b, sizeof(a));
#define clr(a) mst(a, 0);
#define lbit(x) (x & (-x))
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;

const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int MOD = 1e9+7;
const int MAXN = 1e5+10;

string str;

int main(int argc, char const *argv[]) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> str;
    int x = (str[0]-'0')*10+str[1]-'0';
    int y = (str[2]-'0')*10+str[3]-'0';
    if(x > 0 && x < 13 && y > 0 && y < 13)
    	cout << "AMBIGUOUS" << endl;
    else if(x > 0 && x < 13)
    	cout << "MMYY" << endl;
    else if(y > 0 && y < 13)
    	cout << "YYMM" << endl;
    else
    	cout << "NA" << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
const int M = 10000001;
ll a[M];
int main() {
    int N;
    cin >> N;
    fill(a, a + M, 1);
    for (ll i = 2; i < M; i++) {
        for (ll j = 1; i * j < M; j++) {
            a[i * j]++;
        }
    }
    ll ans = 0;
    /*for (ll i = 1; i <= N; i++) {
        ans += i * a[i];
    }*/
        for(long long i=1;i<=N;i++){
        ans += i * a[i];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 81744
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int N, X[1 << 18], Y[1 << 18];
char D[1 << 18];
 
void Rotate() {
	for (int i = 1; i <= N; i++) {
		int cx = Y[i], cy = 200000 - X[i], cz;
		if (D[i] == 'U') cz = 'R';
		if (D[i] == 'R') cz = 'D';
		if (D[i] == 'D') cz = 'L';
		if (D[i] == 'L') cz = 'U';
		X[i] = cx; Y[i] = cy; D[i] = cz;
	}
}
 
vector<pair<int, char>> V1[1 << 19];
vector<pair<int, char>> V2[1 << 19];
 
int solve_01() {
	int Answer = (1 << 24);
	for (int i = 0; i <= 500000; i++) V1[i].clear();
	for (int i = 1; i <= N; i++) {
		if (!(D[i] == 'R' || D[i] == 'U')) continue;
		V1[X[i] + Y[i]].push_back(make_pair(X[i], D[i]));
	}
	for (int i = 0; i <= 500000; i++) {
		sort(V1[i].begin(), V1[i].end());
		for (int j = 0; j < (int)V1[i].size() - 1; j++) {
			if (!(V1[i][j].second == 'R' && V1[i][j + 1].second == 'U')) continue;
			Answer = min(Answer, V1[i][j + 1].first - V1[i][j].first);
		}
	}
	return Answer * 10;
}
 
int solve_02() {
	int Answer = (1 << 24);
	for (int i = 0; i <= 500000; i++) V2[i].clear();
	for (int i = 1; i <= N; i++) {
		if (!(D[i] == 'L' || D[i] == 'R')) continue;
		V2[Y[i]].push_back(make_pair(X[i], D[i]));
	}
	for (int i = 0; i <= 500000; i++) {
		sort(V2[i].begin(), V2[i].end());
		for (int j = 0; j < (int)V2[i].size() - 1; j++) {
			if (!(V2[i][j].second == 'R' && V2[i][j + 1].second == 'L')) continue;
			Answer = min(Answer, V2[i][j + 1].first - V2[i][j].first);
		}
	}
	return Answer * 5;
}
 
int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> X[i] >> Y[i] >> D[i];
 
	int FinalAns = (1 << 24);
	for (int t = 1; t <= 4; t++) {
		int val1 = solve_01(); FinalAns = min(FinalAns, val1);
		int val2 = solve_02(); FinalAns = min(FinalAns, val2);
		Rotate();
	}
	if (FinalAns == (1 << 24)) cout << "SAFE" << endl;
	else cout << FinalAns << endl;
	return 0;
}

Measured memory_bytes: 42724
#include <iostream>
#include <math.h>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	ll x; cin >> x;
	ll a = (x / 11) * 2;
	if (x % 11 != 0) {
		if ((x % 11) > 6 && (x % 11) < 11)  a += 2;
		if ((x % 11) <= 6)  a++;
	}

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace B.Stone_Monument
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = ab[0];
            int b = ab[1];

            //int NSum(int n) => n == 0 ? 0 : n + NSum(n - 1);

            Console.WriteLine(NSum((b - a) - 1) - a);
        }

        static int NSum(int n)
        {
            return n == 0 ? 0 : n + NSum(n - 1);
        }
    }
}


Measured memory_bytes: 13268
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
w = LI()
t = float('inf')
for i in range(n):
    s_1 = sum(w[:i])
    s_2 = sum(w[i:])
    t = min(t, abs(s_1 - s_2))
print(t)


Measured memory_bytes: 9184
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int w = s.nextInt(), h = s.nextInt(), n = s.nextInt();
		
		boolean[][] white = new boolean[h][w];
		for (int i = 0; i < white.length; i++) {
			Arrays.fill(white[i], true);
		}
		for (int i = 0; i < n; i++) {
			int x = s.nextInt(), y = s.nextInt(), a = s. nextInt();
			if (a==1) {
				for (int j = 0; j < h; j++) {
					for (int k = 0; k < x; k++) {
						white[j][k] = false;
					}
				}
			}else if (a==2) {
				for (int j = 0; j < h; j++) {
					for (int k = x; k < w; k++) {
						white[j][k] = false;
					}
				}
			}else if (a==3) {
				for (int j = 0; j < y; j++) {
					for (int k = 0; k < w; k++) {
						white[j][k] = false;
					}
				}
			}else if (a==4) {
				for (int j = y; j < h; j++) {
					for (int k = 0; k < w; k++) {
						white[j][k] = false;
					}
				}
			}
		}
		
		
		int ans = 0;
		for (int i = 0; i < white.length; i++) {
			for (int j = 0; j < white[i].length; j++) {
				if (white[i][j]) {
					ans++;
				}
			}
		}
		System.out.println(ans);
		s.close();
	}
}


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

int main()
{
  int n; cin >> n;
  bool flg = true;
  rep(i, n) {
    int a; cin >> a;
    if (a%2 == 0) {
      if (a%3!=0 && a%5!=0) flg = false;
    }
  }
  if (flg) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;

  return 0;
}


Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                var x1 = int.Parse(line[0]);
                var y1 = int.Parse(line[1]);
                var z1 = int.Parse(line[2]);
                var w1 = int.Parse(line[3]);
                var x2 = int.Parse(line[4]);
                var y2 = int.Parse(line[5]);
                var z2 = int.Parse(line[6]);
                var w2 = int.Parse(line[7]);
                var a1 = x1 * x2 - y1 * y2 - z1 * z2 - w1 * w2;
                var a2 = x1 * y2 + x2 * y1 + z1 * w2 - w1 * z2;
                var a3 = x1 * z2 - y1 * w2 + z1 * x2 + y2 * w1;
                var a4 = x1 * w2 + y1 * z2 - z1 * y2 + w1 * x2;
                Console.WriteLine("{0} {1} {2} {3}", a1, a2, a3, a4);
            }
        }
    }
}



Measured memory_bytes: 17944
#include <bits/stdc++.h>
#define mxn 1003
#define pb push_back

using namespace std;
typedef long long ll;

int N, K, T;
string S;

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

    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    cin >> K >> S;
    K = min(K, (int)S.size());
    for (int i = 0; i < K; i++)
        cout << S[i];
    if ((int)S.size() > K)
        cout << "...";
    cout << "\n";

    return 0;
}

Measured memory_bytes: 3652