akhauriyash/Code-Regression huggingface dataset:
S=str(input())
n=len(S)
mod=2019
ans=0
mod_set=[0]*mod
mod_set[0]+=1
ten=1
k=0
for i in range(n-1,-1,-1):
    k=(k+ten*int(S[i]))%mod
    mod_set[k]+=1
    ten=(ten*10)%mod

for i in mod_set:
    ans+=i*(i-1)//2
print(ans)


Measured memory_bytes: 9316
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string.h>

int main()
{
    int A[5];
    int r = 10;
    int index;
    for (int i = 0; i < 5; ++i)
    {
        scanf("%d", &A[i]);
        int temp = A[i] % 10;
        if (temp != 0)
        {
            if (temp < r){
            r = std::min(r, temp);
            index = i;}
        }
    }
    if (r == 10){r = 0; index = 0;}
    int ans = 0;
    for (int i = 0; i < 5; ++i)
    {
        if (i != index)
        {
        int p = A[i] % 10;
        if (p != 0)
        {
            ans += (( A[i] / 10 ) + 1 ) * 10;
        }
        else{
            ans += A[i];
        }
        }
    }
    ans += A[index];
    printf("%d\n",ans);
    return 0;
}

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

using namespace std;

int main(){
  int N; cin >> N;
  vector<int> A(N); vector<int> B(N); vector<int> C(N);
  
  for(int i = 0; i < N; i++){
    cin >> A[i];}
  
  for(int i = 0; i < N; i++){
    cin >> B[i];}
  
  for(int i = 0; i < N; i++){
    cin >> C[i];}
  
  sort(A.begin(),A.end()); sort(B.begin(),B.end()); sort(C.begin(),C.end());
  
  long long sum = 0;
  
  for(int i = 0; i < N; i++){
    int b = B[i];
    
    int a = lower_bound(A.begin(),A.end(),b) - A.begin();
    int c = upper_bound(C.begin(),C.end(),b) - C.begin();
    
    sum += (long long) a * ( N - c);}
  
  cout << sum << endl; return 0;}
    

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int a,b,h,m;
	cin >> a >> b >> h >> m;
	double htheta = 2*acos(-1) * double((60 * h + m) % (60*12))/double(60*12);
	double mtheta = 2*acos(-1) * double((60 * h + m) % (60))/double(60);
	double x = a * cos(htheta)  - b * cos(mtheta);
	double y = a * sin(htheta)  - b * sin(mtheta);
	double dist = sqrt(x*x+y*y);
	cout << setprecision(19) << fixed;
	cout << dist << '\n';
}


Measured memory_bytes: 4148
fn main() {
    ioset! { inp, buf }
    macro_rules! scan {
        ($($r:tt)*) => {
            input! { inp, $($r)* }
        }
    }
    macro_rules! print {
        ($($t:expr),*) => {
            write!(buf, $($t),*).unwrap();
        } 
    }

    scan! {
        mut n: chars,
    }
    let mut m9 = 0;
    for c in n {
        m9 = (m9 + c.to_digit(10).unwrap() as usize) % 9;
    }
    print!("{}\n", if m9 == 0 { "Yes" } else { "No" });
}

use std::io::{ stdout, BufWriter, Write };

#[macro_export]
macro_rules! ioset {
    ($inp:ident, $buf:ident) => {
        inset!($inp);
        outset!($buf);
    }
}

#[macro_export]
macro_rules! inset {
    (source = $s:expr, $iter:ident) => {
        let mut $iter = $s.split_whitespace();
    };
    ($iter:ident) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut $iter = s.split_whitespace();
    }
}

#[macro_export]
macro_rules! input {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt, $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input! { $iter, $($r)* }
    };
    ($iter:expr, mut $var:ident : $t:tt, $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input! { $iter, $($r)* }
    };
    ($iter:expr, ($var:expr) : $t:tt, $($r:tt)*) => {
        $var = read_value!($iter, $t);
        input! { $iter, $($r)* }
    };
}

#[macro_export]
macro_rules! read_value {

    // tuple
    ($iter:expr, ( $($t:tt), * )) => {
        ( $(read_value!($iter, $t)), * )
    };
    
    // array
    ($iter:expr, [ $t:tt; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    
    // string
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    
    // any other
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[macro_export]
macro_rules! outset {
    ($buf:ident) => {
        let sout = stdout();
        let mut $buf = BufWriter::new(sout.lock());
    }
}

#[macro_export]
macro_rules! output {
    ($buf:expr, $($t:expr),*) => {
        write!($buf, $($t),*).unwrap();
    }
}

struct Chars<'a>(&'a Vec<char>);

impl<'a> std::fmt::Display for Chars<'a> {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
        write!(f, "{}", self.0.iter().collect::<String>())
    }
}


Measured memory_bytes: 3180
n = int(input())
char_list = input().split()
num_list = list(map(int, char_list))

def is_even(lis):
    return [x for x in lis if x % 2]

mod2_list = is_even(num_list)

i = 0
while mod2_list == []:
    num_list = [x / 2 for x in num_list]
    mod2_list = is_even(num_list)
    i += 1
    
print(i)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep0c(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep1c(i, n) for (int i = 1; i <= (int)(n); i++)
#define repc0(n, i) for (int i = (int)(n); i >= 0; i--)

using namespace std;
typedef long long ll;

ll N, A[100010];

void solve() {
  ll res = 0ll, minv = 2000000002000ll, a = 0ll, minus_count = 0ll, zero_count = 0ll;
  rep(i, N) {
    a = A[i];
    if(a<0) {
      minus_count++;
      a *= -1;
    } else if(a==0) {
      zero_count++;
    }
    res += a;
    minv = min(minv, a);
  }
  if(minus_count%2 == 1 && zero_count == 0) res -= minv*2;
  cout << res << endl;
}

int main() {
  scanf("%lld", &N);
  rep(i, N) scanf("%lld", &A[i]);
  solve();
  return 0;
}

Measured memory_bytes: 1024
func readInt() -> Int {
    return Int(readLine()!)!
}

func result(x: Int, y: Int, z: Int) -> Int {
    return x*x + y*y + z*z + z*y + x*y + x*z
}

func mainC() {
    let N = readInt()

    var score = (0...N).map { _ in return 0 }

    let max = 100
    for i in 1...max {
        for j in 1...max {
            for k in 1...max {
                let res = result(x: i, y: j, z: k)
                if res < score.count {
                    score[res] += 1
                }
            }
        }
    }

    for n in 1...N {
        print(score[n])
    }

}

mainC()

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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  cout << a.back() - a.front() << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, u, v = LI_()
    n += 1
    edg = [[] for i in range(n)]
    for _ in range(n-1):
        a, b = LI_()
        edg[a].append(b)
        edg[b].append(a)
    dist_u = [-1] * n
    dist_u[u] = 0
    dist_v = [-1] * n
    dist_v[v] = 0
    q = deque([u])
    while q:
        p = q.pop()
        dp = dist_u[p]
        for e in edg[p]:
            if dist_u[e] < 0:
                dist_u[e] = dp + 1
                q.append(e)
    q = deque([v])
    while q:
        p = q.pop()
        dp = dist_v[p]
        for e in edg[p]:
            if dist_v[e] < 0:
                dist_v[e] = dp + 1
                q.append(e)
    ans = 0
    while dist_u[v] - dist_u[u] > 2:
        for e in edg[u]:
            if dist_v[e] < dist_v[u]:
                u = e
                continue
        for e in edg[v]:
            if dist_u[v] > dist_u[e]:
                v = e
                continue
        ans += 1
    f = dist_u[v]-dist_u[u] == 2
    ans += f
    q = deque([u])
    dist_u = [-1] * n
    for e in edg[v]:
        dist_u[e] = 1
    dist_u[u] = 0
    while q:
        u = q.pop()
        dp = dist_u[u]
        for e in edg[u]:
            if dist_u[e] < 0 and v != e:
                dist_u[e] = dp + 1
                q.append(e)
    if f and max(dist_u) == 1:
        ans -= 1
    print(max(dist_u)+ ans)

    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 63708
n, d = map(int, input().split())
X = []
for i in range(n):
    x = list(map(int, input().split()))
    X.append(x)
c, ans = 0, 0
for i in range(0, n - 1):
    for j in range(i + 1, n):
        c = 0
        for k in range(d):
            c += (X[i][k] - X[j][k]) ** 2
        if (c ** (1 / 2)) % 1 == 0:
            ans += 1
print(ans)

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    bool flag = true;
    int cnt = 0;
    int tmp = 0;
    while (flag && cnt < N){
        cnt++;
        if (a[tmp] == 2){
            flag = false;
            break;
        }
        else {
            tmp = a[tmp] - 1;
        }
    }
    if (flag) {
        cout << -1 << endl;
    }
    else{
        cout << cnt << endl;
    }
}



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

using namespace std;

#define ll long long
#define vi vector<int>

ll N, buff, ans = 0;
vi vec;

int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> buff;
        vec.push_back(buff);
    }

    sort(vec.begin(), vec.end());
    reverse(vec.begin(),vec.end());

    for(int i = 0; i < N; i++) ans += pow(-1,i) * vec[i];

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main()
{
	int n;
	map<string, int> memo;

	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		memo[s] += 1;
	}

	int maxv = 0;
	for (const auto& x : memo) {
		int v = x.second;
		if (v > maxv) maxv = v;
	}

	for (auto it = memo.begin(); it != memo.end(); it++) {
		if (it->second == maxv) {
			cout << it->first << endl;
		}
	}

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;
typedef unsigned long long ull;

#define F first
#define S second
#define en end()
#define bg begin()
#define rev reverse
#define mp make_pair
#define pb push_back
#define y1 y1234567890
#define um unordered_map
#define all(x) x.bg, x.en
#define sqr(x) ((x) * (x))
#define sz(x) (int)x.size()
#define sqrll(x) ((x) * 1ll * (x))
#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;
const double pi = acos(-1.0);
const double eps = (double)1e-9;

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

const int N = 100500;

int n, cnt[N];
vector < int > v;

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//srand(time(NULL));

	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;

	for (int i = 2; i <= 10000; i++) {
		bool ok = 1;
		for (int j = 2; sqr(j) <= i; j++) {
			if (i % j == 0) {
				ok = 0;
				break;
			}
		}
		if (ok)
			v.pb(i);
	}

	for (int i = 0; i < sz(v); i++) {
		for (int j = i + 1; j < sz(v); j++)
			cnt[v[i] + v[j]] += 2;
		cnt[v[i] + v[i]]++;
	}

	while (cin >> n)
		cout << cnt[n + 1] << endl;

	return 0;
}

Measured memory_bytes: 3224
import math
N, M = map(int, input().split())
yakusuu = [] 
for i in range(int(math.sqrt(M))):
  if M%(i+1) == 0:
    yakusuu +=[i+1]
    yakusuu +=[M//(i+1)]
yakusuu.sort(reverse=1)

for p in yakusuu:
  if p <= M/N:
    print(p)
    break

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;

	vector<int> as(n);
	for (auto& a : as) {
		cin >> a;
	}
	vector<int> bs(n);
	for (auto& b : bs) {
		cin >> b;
	}

	vector<int> ps(n);
	FOR_LE(i, 1, n) {
		ps[i - 1] = i;
	}

	int an = 0;
	int bn = 0;
	int c = 1;
	do {
		if (ps == as) an = c;
		if (ps == bs) bn = c;
		c++;
	} while (next_permutation(ps.begin(), ps.end()));

	cout << abs(bn - an) << endl;

	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

template <typename T> void output(T, int);
template <typename T> T max(T, T);
int gcd(int a, int b);

int main() {
    // source
    int n, k;
    cin >> n >> k;
    double ans = 0;
    double sum = 0;
    if (n >= k) {
        sum += n - k + 1;
    }
    int first = (k + 1) / 2;
    int second = k;
    int loop = 1;
    while (second != 1) {
        if (first > n) {
        } else if (first <= n && n < second) {
            sum += (1 / pow(2, loop)) * (n - first + 1);
        } else if (second <= n) {
            sum += (1 / pow(2, loop)) * (second - first);
        }
        int temp = (first + 1) / 2;
        second = first;
        first = temp;
        loop++;
    }

    ans = (double)sum / n;
    output(ans, 15);
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T max(T a, T b) {

    if (a > b) {
        return a;
    } else {
        return b;
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;


int main() {
    int h, w;
    cin >> h >> w;
    vector<string> dat(h);
    for (int i = 0; i < h; i++) {
        cin >> dat[i];
    }
    bool ret = true;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (dat[i][j] == '.')
                continue;
            bool flag = false;
            flag |= (0 <= i - 1 && dat[i - 1][j] == '#');
            flag |= (0 <= j - 1 && dat[i][j - 1] == '#');
            flag |= (i + 1 < h && dat[i + 1][j] == '#');
            flag |= (j + 1 < w && dat[i][j + 1] == '#');
            if (!flag) {
                ret = false;
                break;
            }



        }
    }

    cout << (ret ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
# include <algorithm>
# include <iostream>
# include <iterator>
# include <vector>
# include <string>
# include <queue>
# include <stack>
# include <cmath>
# include <set>


using namespace std;


int main() {
    float n, d; cin >> n >> d;
    float ansf = n / (2*d+1);

    if (ansf - int(ansf) > 0) cout << int(ansf)+1 << endl;
    else cout << int(ansf) << endl;
    return 0;
}



Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

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

void dfs(int r, int c) {
    stack<int> S;
    S.push(r);
    color[r] = c;
    while( !S.empty()) {
        int u = S.top();
        S.pop();
        for (int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            if (color[v] == NIL){
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor() {
    int id = 1;
    for (int i = 0; i < n; i++) color[i] = NIL;
    for (int u = 0; u < n; u++) {
        if ( color[u] == NIL) dfs(u, id++);
    }
}

int main() {
    int s, t, m, q;
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    assignColor();

    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> s >> t;
        if (color[s] == color[t]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
}


Measured memory_bytes: 8944
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


vector<string> split(string str, string delim)
{
    vector<string> result;
    int cutAt;
    while( (cutAt = str.find_first_of(delim)) != str.npos )
    {
        if(cutAt > 0)
        {
            result.push_back(str.substr(0, cutAt));
        }
        str = str.substr(cutAt + 1);
    }
    if(str.length() > 0)
    {
        result.push_back(str);
    }
	return result;
}

bool range(int x, int y){ return 0 <= x && x < 10 && 0 <= y && y < 10; }

int main()
{
	int field[10][10];
	memset(field, 0, sizeof(field));

	string str;

	while(cin >> str)
	{
		vector<string> v = split(str, ",");
	
		int x = v[0][0] - '0', y = v[1][0] - '0', s = v[2][0] - '0';

		vint dx, dy;
		
		if(s)
		{
			dx.push_back(0); dx.push_back(0); dx.push_back(0); dx.push_back(1); dx.push_back(-1);
			dy.push_back(0); dy.push_back(1); dy.push_back(-1); dy.push_back(0); dy.push_back(0);
			s--;
		}
		if(s)
		{
			dx.push_back(1); dx.push_back(1); dx.push_back(-1); dx.push_back(-1);
			dy.push_back(1); dy.push_back(-1); dy.push_back(1); dy.push_back(-1);
			s--;
		}
		if(s)
		{
			dx.push_back(0); dx.push_back(0); dx.push_back(2); dx.push_back(-2);
			dy.push_back(2); dy.push_back(-2); dy.push_back(0); dy.push_back(0);
			s--;
		}

		int r = 0;

		rep(i, dx.size())
			if(range(x + dx[i], y + dy[i]))
				field[x + dx[i]][y + dy[i]]++;
	}

	int res = 0;
	int blank = 0;

	rep(i, 10) rep(j, 10)
	{
		if(!field[i][j])
			blank++;
		else
			chmax(res, field[i][j]);
	}

	cout << blank << endl << res << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define int long long
#define mod 1e18+10
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int n,k,x;
int32_t main() {
	cin>>n>>k;
	int ans=0;
	while(n--)
	{
		cin>>x;
		ans+=min(x,abs(k-x));
	}
	cout<<2*ans;
	
	
	
}


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

int main() {
  int h,w; cin>>h>>w;
  vector<string> a(h);
  for(int i=0;i<h;i++)
    cin>>a[i];
  
  for(int j=0;j<w+2;j++)
    cout<<'#';
  cout<<endl;
  for(int k=0;k<h;k++)
    cout<<'#'<<a[k]<<'#'<<endl;
  for(int l=0;l<w+2;l++)
    cout<<'#';
  cout<<endl;
  
}

Measured memory_bytes: 3572
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		System.out.print(s[0]);
		System.out.print(s.length-2);
		System.out.print(s[s.length-1]);

	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

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

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N, A, B; cin >> N >> A >> B;
  int ans = min(N * A, B);
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

# D - Teleporter
def show_town(route, k):
	i = 0
	
	for r in route:
		if i == k:
			print(r)
			break
		else:
			i += 1


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

route = dict()
route[1] = a[0]
town = a[0]

while True:
	if town in route.keys():
		break
	else:
		route[town] = a[town-1]
		town = a[town- 1]

minus = 0

for r in route:
	if r != town:
		minus += 1
	else:
		break

if k < minus:
	show_town(route, k)
else:
	loop_count = len(route) - minus
	#print(minus)
	#print(loop_count)

	remainder = (k - minus) % loop_count
	i = 0
	is_start = False

	for r in route:
		if r == town:
			is_start = True
	
		if is_start == True:
			if i == remainder:
				print(r)
				break
			else:
				i += 1

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

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

  bool upper = true;
  
  int keta = str[0]-'0';
  int i=0;
  
  if(keta < str[1]-'0'){
    for(int i=0;i < (int)str.size();i++){
      cout << str[0]-'0'+1;
    }
  }
  else if(keta == str[1] - '0'){
    if(str[0] == str[2]){
      cout << str;
    }
    else if(str[0] < str[2]){
      for(int i=0;i < 3;i++) cout << str[0]-'0'+1;
    }
    else{
      for(int i=0;i < 3;i++) cout << str[0];
    }
  }
  else{
    for(int i=0;i < (int)str.size();i++){
      cout << str[0];
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

ll c,d;

ll f(ll k) {
    ll cc = k / c;
    ll dd = k / d;
    ll ee = k / (c * d / __gcd(c,d));
    return k - (cc + dd - ee);
}

void solve() {
    ll a,b;
    cin >> a >> b >> c >> d;
    cout << f(b) - f(a-1) << endl;
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    char c[250]={0};
    char a[250] ={0};
    int h;
    int i,j,k,m;

    while(1){
        i=0;
        while(1){
            
            scanf("%c",&c[i]);
            if(c[i] == '\n') {
                break;
            }
            i++;
        }
        
        if ( i == 1 && c[0] == '-' ) break;
        
        scanf("%d",&m);
        
        for(j=0;j<m;j++){
            scanf("%d", &h );
            
            for(k=0;k<i-h;k++) {
                a[k] = c[h+k];
            }
            for(k=0;k<h;k++){
                a[i-h+k] = c[k];
            }
            for(k=0; k<i; k++){
                c[k] = a[k];
            }
        }
        for(k=0;k<i;k++) {
            printf("%c",c[k]);
        }
        printf("\n");
        scanf("%c",&c[0]);
    }
    return 0;
}


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

bool cmp(char a, char b){
    return a>b;
}

int main() {
    ios_base::sync_with_stdio(false);
    string s,t;
    cin >> s;
    cin >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),cmp);
    if(s<t){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void YESNO(const bool cond)
{
	OUT(cond ? "YES" : "NO");
}
void YesNo(const bool cond)
{
	OUT(cond ? "Yes" : "No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

// 階乗を計算 O(N) (N=10^7 で O(10^7))
ll factorial(ll n)
{
	for (ll i = n - 1; i > 1; --i)
		n *= i;
	return n;
}

// nCrを計算 O(N) (N=10^7 で O(10^7))
ll comb(const ll n, ll r)
{
	if (r * 2 > n) r = n - r;

	ll dividend = 1, divisor  = 1;

	for (ll i = 1; i <= r; ++i) {
		dividend *= n - i + 1;
		divisor *= i;
	}

	return dividend / divisor;
}

// 素数判定 O(sqrt(N)) (N=10^7 で O(10^3))
bool isprime(const ll num)
{
    if (num < 2) return false;
    if (num == 2) return true;
    if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0) return false;
    }

    return true;
}

// 各桁の和を計算 O(logN) (N=10^7 で O(7))
ll digsum(ll n)
{
	ll sum = 0;
	while(n != 0){
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	instr s;
	inll w;

	for (int i = 0; i < s.size(); i += w)
		cout << s[i];

	cout << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
  var N int
  fmt.Scan(&N)
  
  for i:=0; i <= N/4; i++ {
    for j:=0; j <= N/7; j++ {
      if N == 4 * i + 7 * j {
        fmt.Println("Yes")
        return
      }
    }
  }
  fmt.Println("No")
}

Measured memory_bytes: 512
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College
    Date:24/03/2020
'''

def main():
    
    # for _ in range(ii()):
    n=int(input())
    m={}
    for i in range(n):
        s=input()
        if s not in m:
            m[s]=1
        else:
            m[s]+=1
    maxv=0
    a=[]
    for i in m.keys():
        maxv=max(maxv,m[i])
    for i in m.keys():
        if(m[i]==maxv):
            a.append(i)
    a.sort()
    for i in a:
        print(i)
        
















    
    
if __name__ =="__main__":
    main()

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

typedef long long int ll;
typedef long double ld;

#define Pb push_back
#define Mp make_pair
#define ff first
#define ss second
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define db1(x) cout<<#x<<" : "<<x<<endl;
#define db2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define db3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;

const int  N = 1e4+7;
const int inf = INT_MAX;
const int MOD = 1e9+7;

void solve()
{
   int a,b,c;
   cin >> a >>  b >> c;
   int k;
   cin >> k;
   while(b <= a && k>=1)
   {
      b*=2;
      k--;
   }
   while(c <= b && k>=1)
   {
      c*=2;
      k--;
   }
   if(b>a && c>b)
   {
      cout << "Yes";
   }
   else
   {
      cout << "No";
   }
}

int32_t main()
{
   IOS;
   //freopen("input.txt", "rt", stdin);
   //freopen("output.txt", "wt", stdout);
   int t=1;
   //cin >> t;
   for(int i=1;i<=t;i++)
   {
      //cout<<"Case #"<<i<<": ";
      solve();
   }
   return 0;
}
/*==============================================================================================================================================================*/


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
const double pi=3.1415926535897932384626;

int main(){
    int n;
    std::cin >> n;
    VEC(int,a,n);
    std::vector<int> aa(a);
    sort(all(aa));
    int ma=aa[n-1];
    if(aa[n-1]==aa[n-2]){
        rep(i,n)std::cout << aa[n-1] << std::endl;
    }
    else {
        rep(i,n){
            if(a[i]==ma)std::cout << aa[n-2] << std::endl;
            else std::cout << aa[n-1] << std::endl;
        }
    }
}

Measured memory_bytes: 3200
/**
 *    author:  math2do
 *    created: 04.05.2020 03:18:04 IST
**/

#include <bits/stdc++.h>

using namespace std;

template <typename T>
class graph {
 public:
  struct edge {
    int from;
    int to;
    T cost;
  };
 
  vector<edge> edges;
  vector<vector<int>> g;
  int n;
 
  graph(int _n) : n(_n) {
    g.resize(n);
  }
 
  virtual int add(int from, int to, T cost) = 0;
};

template <typename T>
class undigraph : public graph<T> {
 public:
  using graph<T>::edges;
  using graph<T>::g;
  using graph<T>::n;
 
  undigraph(int _n) : graph<T>(_n) {
  }
 
  int add(int from, int to, T cost = 1) {
    assert(0 <= from && from < n && 0 <= to && to < n);
    int id = (int) edges.size();
    g[from].push_back(id);
    g[to].push_back(id);
    edges.push_back({from, to, cost});
    return id;
  }
};


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector <int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  } 
  undigraph <int> g(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g.add(x, y);
  } 
  int ans = 0;
  for (int u = 0; u < n; u++) {
    bool found = true;
    for (int id : g.g[u]) {
      int v = g.edges[id].from ^ g.edges[id].to ^ u;
      found &= (h[u] > h[v]);
    } 
    ans += found;
  } 
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9968
#include <stdio.h>

typedef long long int llint;

llint gcd(llint a,llint b)
{
    if(a<b)
    {
        int tmp=a;
        a=b;
        b=tmp;
    }
    if(a%b==0)return b;
    else return gcd(b,a%b);
}

int main()
{
    llint a,b;
    scanf("%lld %lld",&a,&b);
    printf("%lld\n",a*b/gcd(a,b));
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int dp[33];
  dp[0] = 0;
  dp[1] = 1;
  dp[2] = 2;
  for(int i = 3 ; i <= 31 ; i++){
    if(i % 2) dp[i] = dp[i-1]*2 + 1;
    else dp[i] = dp[i-2]*3 + 2;
  }

  int n;
  while(cin >> n){
    cout << dp[n] << endl;
  }
  return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  vector<int> A(b);
  for (int i = 0; i < b; i++) {
    A.at(i) = a;
  }
  vector<int> B(a);
  for (int i = 0; i < a; i++) {
    B.at(i) = b;
  }
  
  if (a < b) {
    for (int i = 0; i < b; i++) {
      cout << A.at (i);
    }
	cout << endl;
  }
  else {
    for (int i = 0; i < a; i++) {
      cout << B.at(i) ;
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <algorithm>
#include <math.h>
#include<string>
#include<vector>
using namespace std;
int main()
{
    double r;
    cin >> r;
    cout << double(2.0 * r * M_PI) << endl;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

const int INF = 1001001001;

int		main(void)
{
	int n, x, y;
	cin >> n >> x >> y;
	x--;
	y--;
	vector<int> ans(n);
	for (int sv = 0; sv < n; sv++)
	{
		vector<int> dist(n, INF);
		queue<int> q;
		auto push = [&](int v, int d)
		{
			if (dist[v] != INF)
				return ;
			dist[v] = d;
			q.push(v);
		};
		push(sv, 0);
		while (!q.empty())
		{
			int v = q.front(); q.pop();
			int d = dist[v];
			if (v-1 >= 0)
				push(v-1, d+1);
			if (v+1 < n)
				push(v+1, d+1);
			if (v == x)
				push(y, d+1);
			if (v == y)
				push(x, d+1);
		}
		for (int i = 0; i < n; i++)
			ans[dist[i]]++;
	}
	for (int i = 0; i < n; i++)
		ans[i] /= 2;
	for (int i = 1; i <= n-1; i++)
		cout << ans[i] << endl;
}


Measured memory_bytes: 256
use std::io;

macro_rules! read {
    ($t: ty) => {
        {
            let mut input = String::new();
            io::stdin().read_line(&mut input).expect("could not read input");
            input.trim().parse::<$t>().unwrap()
        };
    };
    ($($t: ty),*) => {
        {
            let mut input = String::new();
            io::stdin().read_line(&mut input).expect("could not read input");
            let mut iter = input.trim().split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()), *)
        };
    }
}
macro_rules! read_vec {
    ($t: ty) => {
        {
            let mut input = String::new();
            io::stdin().read_line(&mut input).expect("could not read input");
            let iter = input.trim().split_whitespace();
            iter.map(|x| x.parse::<$t>().unwrap()).collect::<Vec<$t>>()
        };
    }
}
fn main() {

    let n = read!(u32);

    if n == 1 {
        println!("1");
        return;
    }

    let mut prevprev: u64 = 2;
    let mut prev: u64 = 1;
    let mut ln: u64 = 0;

    for i in 2..n+1 {
        ln = prevprev + prev;
        prevprev = prev;
        prev = ln;
    }
    println!("{}", ln);
}

Measured memory_bytes: 4352
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("YES")  # type: str


def no():
    print("NO")  # type: str


def solve(H: int, W: int, N: int, s_r: int, s_c: int, S: str, T: str):

    winner = "保留"

    cy, cx = s_r, s_c
    for i in range(N):
        # 高橋名人のR,D作戦
        if S[i] == "R":
            cx += 1
        elif S[i] == "D":
            cy += 1

        if H < cy or W < cx:
            winner = "TAKAHASHI"
            break

        # 青木名人のL,U作戦
        if T[i] == "L" and cx > 1:
            cx -= 1
        elif T[i] == "U" and cy > 1:
            cy -= 1

    if winner == "TAKAHASHI":
        no()
        return

    cy, cx = s_r, s_c
    for i in range(N):
        # 高橋名人のL,U作戦
        if S[i] == "L":
            cx -= 1
        elif S[i] == "U":
            cy -= 1

        if cy <= 0 or cx <= 0:
            winner = "TAKAHASHI"
            break

        # 青木名人のR, D作戦
        if T[i] == "R" and cx < W:
            cx += 1
        elif T[i] == "D" and cy < H:
            cy += 1

    if winner == "TAKAHASHI":
        no()
    else:
        yes()
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    s_r = int(next(tokens))  # type: int
    s_c = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(H, W, N, s_r, s_c, S, T)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ' ';  } return os;  }


int main() {
  int h,w,m; cin >> h >> w >> m;
  vector<ll> H(h),W(w);
  set<pair<int, int> > S;
  loop(i,0,m) {
    int y, x; cin >> y >> x;
    y--;x--;
    H[y]++;
    W[x]++;
    S.insert({y, x});
  }

  int max_y = 0, max_x = 0;
  int may = 0;
  loop(i,0,h) {
    if (may < H[i]) max_y = i,may = H[i];
  }
  int ma = 0;
  loop(i,0,w) {
    if (ma < W[i]) max_x = i,ma = W[i];
    else if (ma == W[i]) {
      if (S.count({max_y,max_x})) {
        max_x = i;
      }
    }
  }
  loop(i,0,h) {
    if (H[i] == may) {
      if (S.count({i,max_x}) == 0) {
        max_y = i;
      }
    }
  }

  ll ans = H[max_y]+W[max_x];
  // cout << max_y << " " << max_x << " " << S.count({ max_y, max_x }) << endl;
  if (S.count({max_y, max_x})) ans--;

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


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

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

const int MAX = 2 * 1e5 + 10;
const ll MOD = 1e9 + 7;

int N, a[MAX];

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> a[i];

    vector<int> ans(N + 1);
    for(int i=N;i>0;--i){
        int j = 2;
        int cnt = 0;
        while(i * j <= N){
            if(ans[i * j]) cnt++;
            j++;
        }
        if(cnt % 2) ans[i] = 1 - a[i - 1];
        else ans[i] = a[i - 1];
    }

    int M = 0;
    for(int i=1;i<=N;i++){
        if(ans[i]) M++;
    }

    cout << M << endl;
    for(int i=1;i<=N;i++){
        if(ans[i]) cout << i << " ";
    }
    cout << endl;
}

Measured memory_bytes: 2432
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main (String [] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        ArrayList<Integer> list = new ArrayList();
        for (int i =A ; i < A+ K ; i++){
            if (i > B){
                break;
            }
            list.add(i);
        }
        for (int i = B; i > B -K ; i--){
            if (i < A){
                break;
            }
            if (list.contains(i)){

            }else{
                list.add(i);
            }
        }
        Collections.sort(list);
        for (Integer i : list){
            System.out.println(i);
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
const int inf=1<<30;
vector<int> g[100010];
int dist1[100010],dist2[100010];
bool used1[100010],used2[100010];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a); 
	}
	queue<int> q;
	q.push(1);
	used1[1]=true;dist1[1]=0;
	while(!q.empty()){
		int x=q.front();q.pop();
		for(int i=0;i<g[x].size();i++){
			if(!used1[g[x][i]]){
				q.push(g[x][i]);
				dist1[g[x][i]]=dist1[x]+1;
				used1[g[x][i]]=true;
			}
		}
	}
	q.push(n);
	used2[n]=true;dist2[n]=0;
	while(!q.empty()){
		int x=q.front();q.pop();
		for(int i=0;i<g[x].size();i++){
			if(!used2[g[x][i]]){
				q.push(g[x][i]);
				dist2[g[x][i]]=dist2[x]+1;
				used2[g[x][i]]=true;
			}
		}
	}
	int snuke=0,fennec=0;
	for(int i=1;i<=n;i++){
		//cout<<i<<" "<<dist1[i]<<" "<<dist2[i]<<endl;
		if(dist1[i]>dist2[i])snuke++;
		if(dist2[i]>=dist1[i])fennec++;
	}
	if(fennec>snuke)cout<<"Fennec";
	else cout<<"Snuke";
	return 0;
}

Measured memory_bytes: 6784
N, W = map(int, input().split())
vw = [list(map(int, input().split())) for i in range(N)]

# dp[選択する要素の番号][この重さを超えないレベルで] = 価値の最大値となるような二次元配列
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(N):
    for w in range(W+1):
        value, weight = vw[i]
        # wを超えない重さであれば、前の要素番号まででこの重さを引いた数値の価値と今回の価値を足したものが上回れば今回の価値とする
        if w >= weight:
            dp[i+1][w] = max(dp[i][w], dp[i][w-weight] + value)
        # wを超えるのであれば選択できないので、前の要素番号までの価値と同じ価値
        else:
            dp[i+1][w] = dp[i][w]

print(dp[N][W])


Measured memory_bytes: 25948
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  long double a,b,c;
  cin >> a >> b >> c;
  if(a+2*sqrt(a*b)+b<c){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
string t;
int main(void)
{
	string s;

	cin>>s;

	int n[3]={};

	rep(i, 3){
		n[s[i]-'a']++;
	}

	bool flag=true;

	rep(i, 3){
		if(n[i]==0) flag=false;
	}

	cout<<yn(flag)<<endl;
}



Measured memory_bytes: 256
n, k, q = map(int, input().split())
a = [0 for i in range(n)]
for i in range(q):
    m = int(input())
    a[m-1] += 1

for i in range(n):
    v = k - q + a[i]
    if(v <= 0):
        print('No')
    else:
        print('Yes')


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

using int64 = long long;

struct Tea {
    int64 size, cost;
    bool operator<(const Tea& t) const {
        int64 p1 = cost * (8 / size),
              p2 = t.cost * (8 / t.size);
        return p1 < p2;
    }
};

int main() {
    Tea teas[4];
    for (int i = 0; i < 4; i++) {
        int64 cost;
        cin >> cost;

        teas[i] = {1 << i, cost};
    }

    sort(teas, teas + 4);

    int64 N;
    cin >> N;

    N *= 4;
    int64 ans = 0;
    for (int i = 0; i < 4; i++) {
        ans += teas[i].cost * (N / teas[i].size);
        N %= teas[i].size;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256