akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;main(){int a[5],i,b=99;cin>>a[0];for(i=4;i;--i){cin>>a[i];--a[i];}for(i=a[0];i;--i)b=min(b,abs(a[1]%i-a[2]%i)+abs(a[1]/i-a[2]/i)+abs(a[3]%i-a[4]%i)+abs(a[3]/i-a[4]/i));cout<<b<<endl;}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int m=1e5+9;

int main() {
    int x;
    cin >> x;
    vector<int> p;
    for (int i=2;i<m;i++) {
        bool flag=true;
        for (int j=0;j<p.size();j++) {
            if (p[j]>sqrt(i)+1) break;
            if (i%p[j]==0) {
                flag=false;
                break;
            }
        }
        if (flag) p.push_back(i);
    }
    int ans;
    for (int i=0;i<p.size();i++) {
        if (p[i]>=x) {
            ans=p[i];
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
"""
Created on Sun Sep  1 20:24:28 2019

@author: Yamazaki Kenichi
"""

N = int(input())
H = list(map(int,input().split()))

ans = 0
counta = 0
tmp = H[0]
for i in range(1,N):
#    print(tmp,i,counta)
    if H[i] <= tmp:
        counta += 1
    else:
        if counta > ans:
            ans = counta
        counta = 0
    tmp = H[i]
if counta > ans:
    ans = counta
print(ans)

Measured memory_bytes: 15020
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const ll MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }
template<int mod>
struct ModInt {
    using ll = long long; ll x;
    ModInt() : x(0) {}
    ModInt(int y) : x(y >= 0 ? ll(y % mod) : (ll)((mod - (-y) % mod))) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
    ModInt &operator+=(const ModInt &rhs) { if((x += rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &rhs) { if((x += mod - rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &rhs) { x = x * rhs.x % mod; return *this; }
    ModInt &operator/=(const ModInt &rhs) { *this *= rhs.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(const ModInt &rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(const ModInt &rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(const ModInt &rhs) const { return ModInt(*this) /= rhs; }
    ModInt operator==(const ModInt &rhs) const { return x == rhs.x; }
    ModInt operator!=(const ModInt &rhs) const { return x != rhs.x; }
    friend ostream &operator<<(ostream &os, const ModInt &rhs) { return os << rhs.x; }
    friend istream &operator>>(istream &is, ModInt &rhs) { ll t; is >> t; rhs = ModInt<mod> (t); return (is); }
private:
    ModInt inverse() const { ll a = x, u = 1LL, v = 0LL, t, b = (ll)mod; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return  ModInt(u); }
};
using mint = ModInt<MOD>;

int main() {
    vector<int> a(4), b(4);
    rep(i, 4) cin >> a[i];
    rep(i, 4) cin >> b[i];
    cout << max(accumulate(all(a), 0), accumulate(all(b), 0)) << endl;
    return 0;
}


Measured memory_bytes: 3100
K, S = map(int, input().split())

ans = 0
for x in range(K + 1):
    for y in range(x, K + 1):
        z = S - (x + y)
        if y <= z and z <= K:
            if x == y and y == z:
                ans += 1
            elif x == y or y == z or z == x:
                ans += 3
            else:
                ans += 6

print(ans)

Measured memory_bytes: 3064
#include <iostream>

int main () {

    int64_t N, K;
    std::cin >> N >> K;

    N = N % K;
    while (true) {
        int64_t before = N;
        int64_t after = std::abs(N - K);
        if (before > after) N = after;
        else if (before == after) break;
        else if (before < after) break;
    }

    std::cout << N << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <map>

using namespace std;
float a[110];

int main()
{
   double n;
   double x;
   while(cin>>n)
   {
       if(n==0)break;
      double sum=0;
       for(int i=0;i<n;i++)
       {
           cin>>a[i];
           //scanf("%d",&a[i]);
           sum+=a[i];
       }
       x=sum/n*1.0;
       //cout<<sum<<endl;
       //printf("sum=%lf\n",sum);
//       printf("n=%d\n",n);
       //printf("x=%lf\n",x);
       //cout<<x<<endl;

       double minn=abs(a[0]-x);
      // cout<<minn<<endl;
       int ans=0;
       for(int i=0;i<n;i++)
       {
           a[i]=abs(a[i]-x);
         //  cout<<a[i]<<" " ;
          // printf("a[%d]=%lf\n",i,a[i]);
           if(a[i]<minn)
           {
               minn=a[i];
               ans=i;
           }
       }
       //printf("%d\n",ans);
       cout<<ans<<endl;
   }
    return 0;
}


Measured memory_bytes: 256
<?php
list($n, $m) = ints();
list($s) = strs();
list($t) = strs();
$l = lcm($n, $m);
for ($i = 0; $i < $n; $i++) $x[$i * intdiv($l, $n)] = $s[$i];
for ($i = 0; $i < $m; $i++) {
    if (isset($x[$i * intdiv($l, $m)]) && $x[$i * intdiv($l, $m)] !== $t[$i]) exit('-1');
}
echo $l;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
// 最大公約数（2つ）
function gcd($m, $n)
{
    if (!$n) return $m;
    return gcd($n, $m % $n);
}

// 最大公約数（3つ以上）
function gcdAll($arr)
{
    $gcd = array_pop($arr);
    foreach ($arr as $a) {
        $gcd = gcd($gcd, $a);
    }
    return $gcd;
}

// 最小公倍数（2つ）
function lcm($m, $n)
{
    return (int) ($m / gcd($m, $n) * $n); // オーバーフローしないように先に割り算
}

// 最小公倍数（3つ以上）
function lcmAll($arr)
{
    $lcm = array_pop($arr);
    foreach ($arr as $a) {
        $lcm = lcm($lcm, $a);
    }
    return $lcm;
}


Measured memory_bytes: 23248
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String a = sc.next();
        String b = sc.next();

        long x = Long.parseLong(a + b);

        for (long i = 1; i < x; i++) {
            if ((i * i) == x) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 21332
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let x: i64 = sc.cin();
    let mut r = 100;
    for i in 0..1000000 {
        r += r / 100;
        trace!(i, r);
        if r >= x {
            put!(i + 1);
            return;
        }
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 2160
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc141/tasks/abc141_c>
 問題文============================================================
 C - Attack Survival
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N,K,Q; cin >> N >> K >> Q;
    vector<int> A(Q); for(auto& in:A) cin >> in;
    
    vector<int> score(N);
    for(int i = 0; i < Q;i++){
        score[A[i]-1]++;
    }
    
    
    for(int i = 0; i < N;i++){
        if(K  + score[i] - Q > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, Q;
    string s;
    cin >> N >> Q >> s;
    vector<int> t(N+1, 0);
    for(int i=0; i<N-1; i++)
        t.at(i+1) = t.at(i) + ((s.at(i)=='A' && s.at(i+1)=='C') ? 1 : 0);
    int l, r;
    for(int i=0; i<Q; i++){
        cin >> l >> r;
        cout << t.at(r-1) - t.at(l-1) << endl;
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; i++) cin >> h[i];
  vector<int> dp(N, 1000000000);
  dp[0] = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int j = 1; j <= 2; j++) {
      if (i + j == N) break;
      dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
  }
  cout << dp[N - 1] << endl;
}

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

using namespace std;

const int N = 2e5 + 5;

int n ;

int main()
{
    cin>>n;
    int ii = 0;
    for(int i = 0;i<n;i++)
    {
        int t;
        cin>>t;
        if(t==ii+1)
        {
            ii++;
        }
    }
    if(ii==0)
        cout<<-1;
    else
        cout<<n -ii;
    return 0;
}


Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())
ans = 0
if X <= Y:
    if A + B <= 2*C:
        ans += (A + B)*X
    else:
        ans += 2*C*X
    ans += min(B, 2*C)*(Y - X)
else:
    if A + B <= 2*C:
        ans += (A + B)*Y
    else:
        ans += 2*C*Y
    ans += min(A, 2*C)*(X - Y)

print(ans)


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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main (int argc, char*argv[]) {
  int n, T;
  cin >> n >> T;
  vector<int> t;
  for(int i=0; i<n; i++) {
    int tmp;
    cin >> tmp;
    t.push_back(tmp);
  }

  ll sum = 0;
  ll curr = -1;
  for(auto i : t) {
    if(curr > i) {
      sum += T - (curr-i);
    } else {
      sum += T;
    }
    curr = i + T;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>
#include <string.h>

int main(){
	char str [222];
scanf ("%s", str ) ;
int n= strlen (str ) ;
for (int i=n -2; i; i -=2) {
if( strncmp (str , str +i/2 , i/2) ==0) {
printf ("%d\n" ,i) ;
return 0;}
}
return 0;
}


Measured memory_bytes: 128
import itertools
n, m = map(int, input().split())
list_c = [list(map(int, input().split())) for _ in range(n)]

sign = list(itertools.product([1, -1], repeat=3))
cand = []
for sx, sy, sz in sign:
  sub_c = [sx*x+sy*y+sz*z for x, y, z in list_c]
  sub_c.sort(reverse=True)
  cand.append(sum(sub_c[:m]))
print(max(cand))

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;


using Weight = int;
using Capacity = int;
struct Edge {
	int src, dst; Weight weight; Capacity cap;
	Edge(int s, int d, Weight w, Capacity c) : src(s), dst(d), weight(w), cap(c) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

struct Dinic {
	int n, s, t;
	vector<int> level, prog, que;
	vector<vector<Capacity>> cap, flow;
	vector<vector<int>> g;
	Capacity inf;
	Dinic(const Graph &graph)
		: n(graph.size()),
		cap(n, vector<Capacity>(n)), flow(n, vector<Capacity>(n)),
		g(n, vector<int>()), inf(numeric_limits<Capacity>::max() / 8) {
		for(int i = 0; i < n; i++) {
			for(auto &e : graph[i]) {
				int u = e.src, v = e.dst;
				Capacity c = e.cap;
				cap[u][v] += c; cap[v][u] += c; flow[v][u] += c;
				g[u].push_back(v); g[v].push_back(u);
			}
		}
	}
	inline Capacity residue(int u, int v) { return cap[u][v] - flow[u][v]; }
	Capacity solve(int s_, int t_) {
		this->t = t_, this->s = s_;
		que.resize(n + 1);
		Capacity res = 0;
		while(levelize()) { prog.assign(n, 0); res += augment(s, inf); }
		return res;
	}
	bool levelize() {
		int l = 0, r = 0;
		level.assign(n, -1); level[s] = 0; que[r++] = s;
		while(l != r) {
			int v = que[l++]; if(v == t) break;
			for(const int &d : g[v]) if(level[d] == -1 && residue(v, d) != 0) {
				level[d] = level[v] + 1; que[r++] = d;
			}
		}
		return level[t] != -1;
	}
	Capacity augment(int v, Capacity lim) {
		Capacity res = 0;
		if(v == t) return lim;
		for(int &i = prog[v]; i < (int)g[v].size(); i++) {
			const int &d = g[v][i];
			if(residue(v, d) == 0 || level[v] >= level[d]) continue;
			const Capacity aug = augment(d, min(lim, residue(v, d)));
			flow[v][d] += aug; flow[d][v] -= aug;
			res += aug; lim -= aug;
			if(lim == 0) break;
		}
		return res;
	}
};


const int INF = 1 << 25;
int wf[100][100];
int A[10000];
int B[10000];
int D[10000];
int P[100];
int K[100];

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

	int N, M, L;
	while(cin >> N >> M >> L) {
		for(int i = 0; i < N; i++)
			for(int j = 0; j < N; j++)
				wf[i][j] = i == j ? 0 : INF;

		for(int i = 0; i < M; i++) {
			cin >> A[i] >> B[i] >> D[i];
			A[i]--, B[i]--;
			wf[A[i]][B[i]] = wf[B[i]][A[i]] = D[i];
		}
		for(int i = 0; i < N; i++) {
			cin >> P[i];
		}
		for(int i = 0; i < N; i++) {
			cin >> K[i];
		}

		for(int k = 0; k < N; k++)
			for(int i = 0; i < N; i++)
				for(int j = 0; j < N; j++)
					wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);

		Graph G(N + N + 2);
		int S = N + N, T = N + N + 1;
		for(int i = 0; i < N; i++) {
			G[i].push_back(Edge(S, i, 0, P[i]));
			G[N + i].push_back(Edge(N + i, T, 0, K[i]));
			for(int j = 0; j < N; j++) {
				if(wf[i][j] < L) {
					G[i].push_back(Edge(i, N + j, 0, P[i]));
				}
			}
		}

		Dinic dinic(G);
		cout << dinic.solve(S, T) << endl;
	}
}

Measured memory_bytes: 3520
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, u, w, N, M, adj[701][701] = {};
	scanf("%d %d", &N, &M);
	for (i = 1; i <= M; i++) {
		scanf("%d %d", &u, &w);
		adj[u][w] = 1;
		adj[w][u] = 1;
	}
	
	int k, flag[701] = {}, size[701], q[701], head, tail;
	for (i = 1, k = 0; i <= N; i++) {
		if (flag[i] != 0) continue;
		size[++k] = 1;
		flag[i] = 1;
		q[0] = i;
		for (head = 0, tail = 1; head < tail; head++) {
			for (u = q[head], w = 1; w <= N; w++) {
				if (w != u && adj[u][w] == 0) {
					if (flag[w] == 0) {
						flag[w] = -flag[u];
						size[k] += flag[w];
						q[tail++] = w;
					} else if (flag[w] == flag[u]) break;
				}
			}
			if (w <= N) break;
		}
		if (head < tail) break;
		size[k] = abs(size[k]);
	}
	if (i <= N) {
		printf("-1\n");
		fflush(stdout);
		return 0;
	}
	
	int j, dp[701][1401] = {};
	for (i = 1, dp[0][N] = 1; i <= k; i++) {
		for (j = size[i]; j <= N * 2 - size[i]; j++) {
			dp[i][j+size[i]] |= dp[i-1][j];
			dp[i][j-size[i]] |= dp[i-1][j];
		}
	}
	
	for (i = N; i >= 0; i--) if (dp[k][i] == 1) break;
	for (j = N; j <= N * 2; j++) if (dp[k][j] == 1) break;
	j = (N - i > j - N)? j - N: N - i;
	printf("%d\n", ((N + j) * (N + j - 2) + (N - j) * (N - j - 2)) / 8);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 5888
public class Main{
public static void main(String[ ]args){
int k = 0;
for(int i = 1 ; i<10 ;i++){
for(int j = 1 ; j < 10 ; j++){
k = i * j;
System.out.println(i + "x" + j + "=" + k);
}
}
}
}

Measured memory_bytes: 16852
#include<stdio.h>
#include<iostream>
#include<queue>

using namespace std;

void func (int []);
int enc(int []);
void dec(int [],int);
int zero(int []);
void init(void);

#define MM 256*256*256
unsigned char f[MM];
int tona[8][3]={{1,4,-1},{0,2,5},{1,3,6},{2,7,-1},{0,5,-1},{1,4,6},{2,5,7},{3,6,-1}};
int main(void)
{
	int s[8];
	init();
	while(scanf("%d %d %d %d %d %d %d %d",&s[0],&s[1],&s[2],&s[3],&s[4],&s[5],&s[6],&s[7])!=EOF)	{
		func(s);
	}
	return 0;
}
int enc(int s[])
{
	int i,suu;
	suu=s[0];
	for(i=1;i<8;i++)	{
		suu=suu<<3;
		suu=suu|s[i];
	}
	return suu;
}
void dec(int s[],int suu)
{
	int i;
	for(i=7;i>=0;i--)	{
		s[i]=suu&7;
		suu=suu>>3;
	}
}
int zero(int suu[])
{
	int i;
	for(i=0;i<8;i++)	{
		if(suu[i]==0)	{
			return i;
		}
	}
}
void func(int s[])
{
	int i,cnt=0;
	int suu,s2,s3,buf[8],z,wk,tonari;
	bool flg;

	suu=enc(s);
	printf("%d\n",f[suu]);

}

void init(void)
{
	int i,cnt=0;
	int suu,s2,s3,buf[8],z,wk,tonari;
	bool flg;
	queue <int> qu;
	int sinit[8]={0,1,2,3,4,5,6,7};
	
	suu=enc(sinit);
	for(i=0;i<MM;i++)	{
		f[i]=255;
	}
	qu.push(suu);
	f[suu]=0;
	cnt++;
	while(qu.size()!=0)	{
		s2=qu.front();

		qu.pop();

		dec(buf,s2);
		z=zero(buf);
		for(i=0;i<3;i++)	{
			tonari=tona[z][i];
			if(tonari>=0)	{
				wk=buf[tonari];
				buf[tonari]=buf[z];
				buf[z]=wk;
				s3=enc(buf);
				if(f[s3]==255)	{
					qu.push(s3);
					f[s3]=f[s2]+1;
					cnt++;
				}
				wk=buf[tonari];
				buf[tonari]=buf[z];
				buf[z]=wk;
			}
		}
	}
}


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

using namespace std;

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

const int MOD = 998244353;

ll modpow(ll b, ll e, ll m) {
	ll r = 1;
	while(e) {
		if(e&1) {
			r *= b;
			r %= m;
		}
		b *= b;
		b %= m;
		e /= 2;
	}
	return r;
}

ll fact[1000000];
ll invfact[1000000];

ll combo(int n, int k) {
	 ll ret = fact[n];
	 ret *= invfact[k];
	 ret %= MOD;
	 ret *= invfact[n-k];
	 ret %= MOD;
	 return ret;
}

int main() {
	ll n, a, b, k;
	scanf("%lld%lld%lld%lld", &n, &a, &b, &k);
	fact[0] = 1;
	for(int i = 1; i <= n; i++) {
		fact[i] = fact[i-1] * i;
		fact[i] %= MOD;
	}
	invfact[n] = modpow(fact[n], MOD-2, MOD);
	for(int i = n-1; i >= 0; i--) {
		invfact[i] = invfact[i+1] * (i+1);
		invfact[i] %= MOD;
	}
	ll ret = 0;
	for(int i = 0; i <= n; i++) {
		ll left = k - i*a;
		if(left < 0 || left%b || left/b > n) continue;
		int j = left/b;
		ret += combo(n, i) * combo(n, j);
		ret %= MOD;
	}
	printf("%lld\n", ret);
}

Measured memory_bytes: 8448
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,datetime,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))

N = int(input())
Als = inpl()
sm = 0
for item in Als:
    sm = sm^item

anls = []
for item2 in Als:
    anls.append(str(sm^item2))

print(' '.join(anls))


Measured memory_bytes: 109280
#include <bits/stdc++.h>
using namespace std;
#define MAX 200005
typedef long long ll;
ll N, A[MAX];

ll func(ll x){
	ll ret = 0;
	for(int i = 1; i <= N; i++){
		ret += abs(A[i] - (x + i));
	}
	return ret;
}

int main(){
	scanf("%lld", &N);
	for(int i = 1; i <= N; i++){
		scanf("%lld", A + i);
	}
	ll l = -2e9, r = 2e9;
	while(l <= r){
		ll mid = (l + r) / 2;
		if(func(mid) < func(mid + 1)){
			r = mid - 1;
		}
		else{
			l = mid + 1;
		}
	}
	printf("%lld\n", func(l));
	return 0;
}

Measured memory_bytes: 1792
fn read() -> (i32, i32) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let vec: Vec<i32> = s.split_whitespace().map(|x| x.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (a, b) = read();
    if a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 {
        println!("Possible");
    } else {
        println!("Impossible");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <climits>
using ll=long long;
using namespace std;

typedef struct Edge{
    int v;
    int fare;
    ll time;
    Edge(int x,int y,int z){
        v=x;
        fare=y;
        time=z;
    }
}Edge;

int main(){
    int N,M,S;
    cin>>N>>M>>S;

    vector<vector<Edge>> rail(N+1);
    int u,v,a,b;
    for(int i=0;i<M;i++){
        cin>>u>>v>>a>>b;
        rail[u].emplace_back(v,a,b);
        rail[v].emplace_back(u,a,b);
    }

    vector<pair<int,int>> change(N+1);
    for(int i=1;i<N+1;i++){
        cin>>change[i].first>>change[i].second;
    }

    int maxS=50*N;
    vector<vector<ll>> tdist(N+1,vector<ll>(maxS,-1));
    S=min(maxS-1,S);
    using ppp=pair<ll,pair<int,int>>;
    priority_queue<ppp,vector<ppp>,greater<>> q;
    q.push({0,{1,S}});
    while(!q.empty()){
        auto node=q.top();
        q.pop();
        ll t=node.first;
        v=node.second.first;
        int m=node.second.second;
        //cout<<"(t,v,m)=("<<t<<","<<v<<","<<m<<")"<<endl;
        if(tdist[v][m]<0){
            tdist[v][m]=t;
            for(auto p:rail[v]){
                if(m>=p.fare){
                    q.push({t+p.time,{p.v,m-p.fare}});
                }
            }
            if(m+change[v].first<maxS){
                q.push({t+change[v].second,{v,m+change[v].first}});
            }
        }
    }
    /*
    for(int i=0;i<N+1;i++){
        for(int j=0;j<maxS;j++){
            cout<<tdist[i][j]<<" ";
        }
        cout<<endl;
    }
    //*/

    for(int i=2;i<N+1;i++){
        ll tmin=LLONG_MAX;
        for(int j=0;j<maxS;j++){
            if(tdist[i][j]>0){
                if(tmin>tdist[i][j]){
                    tmin=tdist[i][j];
                }
            }
        }
        cout<<tmin<<endl;
    }

    return 0;
}

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

using namespace std;

int main(){
  int N ,Y ;

  cin >> N >> Y ;

  int money = Y;
  int sum = N;
  int cnt = 0;

  for(int i = 0;i <= sum;  i++){
    for(int j = 0; j <= sum-i; j++){
      for(int k = 0; k <= sum-i-j ; k++){
        //cout << "test " << i << " " << j << " " << k << endl;
        if(i * 10000 + j * 5000 + k * 1000 == money && i + j + k == sum){

          cout << i << " " << j << " " << k << endl;
          cnt++;
          goto finish;
        }

      }

    }

  }
  finish :
  if(cnt == 0){
    cout << -1 << " " << -1 << " " << -1 << endl;

  }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define MOD 1000000007
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }
ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __int128
ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}
ll inv(ll x){return power(x,MOD-2);}


void __sol(){

    ll x; cin >> x;
    vector<int> v;
    for(ll i=0;;i++){
        if( i*i*i*i>x ) break;
        else v.eb(i*i*i*i*i);
    }
    int n = v.size();
    forr(i,n){
        forr(j,n){
            if(v[i]-v[j]==x){
                cout << i << " " << j;
                return;
            }
            else if(v[i]+v[j]==x){
                cout << i << " " << -j;
                return;
            }
            else if(-v[i]+v[j]==x){
                cout << j << " " << i;
                return;
            }
            else if(-v[i]-v[j]==x){
                cout << -i << " " << j;
                return;
            }
        }
    }
    cout << "-1 -1";
    return;
}


int main(){
    fastio
    ll tc=1; //cin >> tc;
    while(tc--) __sol();
    return 0;
}

Measured memory_bytes: 3648
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include<bits/stdc++.h>
using namespace std;

class BCraneAndTurtle {
public:
	void solve(std::istream& in, std::ostream& out) {
//        ios_base::sync_with_stdio(false);
//        in.tie(nullptr), out.tie(nullptr);
        int x, y;
        in >> x >> y;
        for(int i = 0; i < 300; i++){
            for(int j = 0; j < 300; j++){
                if(i + j == x && i * 2 + j * 4 == y){
                    out << "Yes" << "\n";
                    return;
                }
            }
        }
        out << "No" << "\n";
	}
};


int main() {
	BCraneAndTurtle solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main()
{
    int A, B, C, X, Y;

    cin >> A >> B >> C >> X >> Y;
    int min = INT_MAX;
    for (int i = 0; i <= max(X,Y); i++)
    {
        int a = A;
        int price = i * C * 2;
        if (i<X) price += (X - i)*A;
        if (i<Y) price += (Y - i)*B;

        if (min > price) min = price;
    }
    cout << min << endl;
}

Measured memory_bytes: 256
import sys

n = int(input())
A = list(map(int, input().split()))
A.sort()

if len(A) == 1:
    print(1)
    sys.exit(0)

box = [False] * (A[-1] + 1)
for a in A:
    box[a] = True

for idx, a in enumerate(A):
    if A[idx] == A[idx - 1]:
        box[a] = False
    for j in range(2, A[-1]//a + 1):
        box[a * j] = False

count = 0
for d in box:
    if d:
        count += 1
print(count)


Measured memory_bytes: 121872
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
using namespace std;
 
int main() {
    long long A,V,B,W,T;
    cin>>A>>V;
    cin>>B>>W;
    cin>>T;
    long long d=abs(A-B);
    long long d2=(V-W)*T;
    
    if(d<=d2){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
    return 0;
}

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

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const int MAX_N = 100000;

int solve(vector<vector<bool> >& grids, const int H, const int W) {
    vector<vector<int> > distances(H, vector<int>(W, INT_MAX));
    priority_queue<pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >, greater<pair<int, pair<int, int> > > > que;
    REP(i,0,H) {
        REP(j,0,W) {
            if (grids[i][j]) {
                distances[i][j] = 0;
                que.push({0, {i, j}});
            }
        }
    }
    vector<vector<int> > didjs{{-1,0}, {+1, 0}, {0, -1}, {0, +1}};
    int answer = 0;
    while (!que.empty()) {
        auto el = que.top();
        que.pop();
        int distance = el.first;
        int i = el.second.first, j = el.second.second;
        for (const auto didj : didjs) {
            int di = didj[0];
            int dj = didj[1];
            if (i+di < 0 || i+di >= H || j+dj < 0 || j+dj >= W) continue;
            if (!grids[i+di][j+dj] && distances[i+di][j+dj] > distance+1) {
                distances[i+di][j+dj] = distance+1;
                que.push({distance+1, {i+di, j+dj}});
            }
        }
    }

    REP(i,0,H) {
        REP(j,0,W) {
            answer = max(distances[i][j], answer);
        }
    }

    return answer;
}

signed main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    int H, W;
    cin >> H >> W;
    vector<vector<bool> > grids(H, vector<bool>(W, false));
    REP(i,0,H) {
        REP(j,0,W) {
            char grid;
            cin >> grid;
            grids[i][j] = grid == '#';
        }
    }
    cout << solve(grids, H, W) << "\n";
    return 0;
}



Measured memory_bytes: 17264
#include <stdio.h>

int main(void) {
    int w, h, x, y, r;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    
    if(0 <= x-r && x+r <= w && 0 <= y-r && y+r <= h) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 584
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <list>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

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

int m, n;
vvi field;

bool isProperXY(int x, int y) {
	return 0 <= x && x < m && 0 <= y && y < n;
}

int dfs(int x, int y) {
	int turn = 0;
	REP(d, 4) {
		int nx = x + dx[d], ny = y + dy[d];
		if (isProperXY(nx, ny) && field[ny][nx] == 1) {
			field[ny][nx] = 0;
			turn = max(turn, dfs(nx, ny));
			field[ny][nx] = 1;
		}
	}
	return turn+1;
}

int main() {
	while (cin >> m >> n, m) {
		field = vvi(n, vi(m));

		REP(i, n) {
			REP(j, m) {
				cin >> field[i][j];
			}
		}

		int ans = 0;
		REP(y, n) {
			REP(x, m) {
				if (field[y][x] == 1) {
					field[y][x] = 0;
					ans = max(ans, dfs(x, y));
					field[y][x] = 1;
				}
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 1292
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	
	int n,m,ans=0,max=0;
	string a[100],b[100];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	cin>>m;
	for(int j=0;j<m;j++){
		cin>>b[j];
	}
	
	for(int i=0;i<n;i++){
		ans=0;
		for(int t=0;t<n;t++){
			if(a[i]==a[t]){
				ans=ans+1;
			}
		}
		for(int j=0;j<m;j++){
			if(b[j]==a[i]){
				ans--;
			}
		}
		if(max<ans){
			max=ans;
		}
	}
	cout<<max<<endl;
	
}


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

const int INF = 2e9;

int main(){
    int x;
    cin >> x;
    bool ok = false;
    for(int i = -200;i < 200;i++){
        for(int j = -200;j < 200;j++){
            ll s = pow(i,5);
            ll t = pow(j,5);
            if (x == (s-t)){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4024
#include <iostream>
#include <vector>
#include <tuple>
#include <queue>
#include <map>

using namespace std;
 
class range {
private:
  struct Iterator {
    int val;
    int operator*() {return val;}
    bool operator!=(Iterator &itr) {return val < itr.val;}
    void operator++() {++val;}
  };
  Iterator i, n;
public:
  range(int n) : i({0}), n({n}) {}
  range(int i, int n) : i({i}), n({n}) {}
  Iterator &begin() {return i;}
  Iterator &end() {return n;}
};
 
template<class T> T at(vector<T> v, int i) {return v[(i % (int)v.size() + v.size()) % v.size()];}
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
 
int main() {
  while (true) {
    int m, n;
    cin >> m >> n;
    if (m == 0 && n == 0) break;
    int p[n][m];
    for (int i : range(n)) for (int j : range(m)) cin >> p[i][j];
    vector<pair<int, int>> house;
    for (int i : range(n)) for (int j : range(m)) if (p[i][j] == 1) house.emplace_back(i, j);
    int s[n][m];
    for (int i : range(n)) for (int j : range(m)) s[i][j] = -1;
    for (int i : range(house.size())) s[house[i].first][house[i].second] = i;
    queue<tuple<int, int, int>> que;
    for (int i : range(n)) for (int j : range(m)) if (p[i][j] == 2) que.push(make_tuple(i, j, (1 << house.size()) - 1));
    int res = 0;
    map<tuple<int, int, int>, int> mp;
    ++mp[que.front()];
    while (!que.empty()) {
      auto now = que.front(); que.pop();
      int y = get<0>(now);
      int x = get<1>(now);
      int bit = get<2>(now);
      //cerr << y << " " << x << " ";
      //for (int i : range(7)) cerr << (bit >> i & 1);
      //cerr << " " << mp[now] << endl;
      for (int i : range(4)) {
        int yy = y + dy[i];
        int xx = x + dx[i];
        while (true) {
          if (yy < 0 || n <= yy) break;
          if (xx < 0 || m <= xx) break;
          if (p[yy][xx] == 1 && (bit & 1 << s[yy][xx])) {
            auto t = make_tuple(yy, xx, bit ^ 1 << s[yy][xx]);
            if (!mp.count(t)) que.push(t);
            mp[t] += mp[now];
            break;
          }
          if (p[yy][xx] == 2 && bit == 0) res += mp[now]; 
          yy += dy[i];
          xx += dx[i];
        }
      }
      mp.erase(now);
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 15516
#include<iostream>
#include<cstdio>
#include<cstdlib>

using namespace std;
#define N 600
#define NIL -2100000000
int key[N];

int parent(int i){
  return i/2;
}

int leftc(int i){
  return 2*i;
}

int rightc(int i){
  return 2*i+1;
}

int main(){
  int n,data;

  scanf("%d",&n);
  for(int i=0;i<N;i++) key[i]=NIL;
  for(int i=1;i<=n;i++){
    scanf("%d",&data);
    key[i]=data;
  }
 
  for(int i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,key[i]);
    if(key[parent(i)]!=NIL) printf("parent key = %d, ",key[parent(i)]);
    if(key[leftc(i)]!=NIL) printf("left key = %d, ",key[leftc(i)]);
    if(key[rightc(i)]!=NIL) printf("right key = %d, ",key[rightc(i)]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(a, n);
    }
    static void getAns(int[] a, int n)
    {
        var p = n - 2;
        while (p > 0)
        {
            if (a[p] >= a[p + 1] + 2) { Console.WriteLine("No"); return; }
            if (a[p] == a[p + 1] + 1) a[p]--;
            p--;
        }
        Console.WriteLine("Yes");
        return;
    }
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

template <typename T1, typename T2>
inline bool chmin(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(const Args&... args) const { print(args...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { std::cout << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { std::cout << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

class UnionFind {
    using i64 = std::int64_t;

private:
    std::vector<i64> par;
    std::vector<i64> sz;

public:
    UnionFind(i64 N) : par(N), sz(N, 1) {
        for (i64 i = 0; i < N; ++i) par[i] = i;
    }
    i64 root(i64 x) {
        return par[x] == x ? x : par[x] = root(par[x]);
    }
    bool same(i64 x, i64 y) {
        return root(x) == root(y);
    }
    void unite(i64 x, i64 y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (sz[x] < sz[y]) std::swap(x, y);
        par[y] = x;
        sz[x] += sz[y];
    }
    i64 size(i64 x) {
        return sz[root(x)];
    }
    void reset(i64 N) {
        par.resize(N);
        for (i64 i = 0; i < N; ++i) par[i] = i;
        sz.assign(N, 1);
    }
};

void solve() {
    ll N, Q;
    cin >> N >> Q;
    UnionFind uf(N);
    while (Q--) {
        int query;
        cin >> query;
        if (query == 0) {
            int a, b;
            cin >> a >> b;
            uf.unite(a, b);
        }
        else {
            int a, b;
            cin >> a >> b;
            bool t = uf.same(a, b);
            prints()(t);
        }
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(nullptr), cout.tie(nullptr);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 6240
n,l = map(int,input().split())

a = [0]*n

for i in range(n):
	a[i] = l+i

min = 10000
check = 0

for i in range(n):
	#3print(i)
	if min > abs(a[i]):
		#print(i)
		min = abs(a[i])
		check = a[i]

print( sum(a)-check )
		
		


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

// mod付きコンビネーション
const int MAX = 1100000;
const int MOD = 1000000007;

Int fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
Int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    COMinit();
    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    Int sum = accumulate(all(a), (Int)0);
    sum %= mod;
    Int res = 0;
    for (Int i = 0; i < n; i++) {
        res += a[i] * (sum - a[i] + mod) % mod;
        res %= mod;
    }
    print(res * inv[2] % mod);
    return 0;
}


Measured memory_bytes: 30648
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <numeric>
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
const int maxn = 1e5+5;
 
int main() {
 
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n; cin >> n;
    ll ans = n+1;
    for (int i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            ans = min(ans, i + n/i);
        }
    }
    cout << ans-2 << endl;
}
 

Measured memory_bytes: 256
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Split(bufio.ScanLines)
	n := readInt()
	var sum float64
	for i := 0; i < n; i++ {
		x := readFloat()
		u := read()
		if u == "BTC" {
			sum += 380000 * x
		} else {
			sum += x
		}
	}
	fmt.Println(sum)
}

//便利関数群
var sc = bufio.NewScanner(os.Stdin)

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

func readInt() int {
	i, _ := strconv.Atoi(read())
	return i
}

func readFloat() float64 {
	i, _ := strconv.ParseFloat(read(), 64)
	return i
}

func max(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func min(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

func abs(x, y int) int {
	if x-y > 0 {
		return x - y
	}
	return -(x - y)
}

type XY struct {
	x, y int
}

type Points []XY

func (p Points) Len() int {
	return len(p)
}
func (p Points) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}
func (p Points) Less(i, j int) bool {
	return p[i].x < p[j].x
}
func (p Points) remove(i int) Points {
	if i >= len(p) {
		return p
	}
	return append(p[:i], p[i+1:]...)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e2+9;
int main()
{
    FASTINOUT;
    int x,k;
    cin>>x>>k;
    int y[x];
    for (int i=0;i<x;i++){
        cin>>y[i];
    }
    sort(y,y+x);
    ll sum=0;
    for (int i=x-1;i>=x-k;i--)
        sum+=y[i];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using i64 = long long;

std::vector<std::vector<int>> g;
std::vector<int> val, state, loop;

int calc(const std::set<int> &s, const int max) {
    int ret = max;
    for (int i = max; i >= 0; i--) {
        if (!s.count(i)) ret = i;
    }
    return ret;
}

int calc_grundy(const int v, const std::vector<int> &val) {
    std::set<int> s;
    for (const int to : g[v]) {
        if (val[to] >= 0) s.insert(val[to]);
    }
    for (int i = 0; ; i++) if (!s.count(i)) return i;
}

bool dfs(const int v) {
    if (state[v] == 2) return val[v] == -1;
    if (state[v] == 1) return true;
    bool ret = false;
    state[v] = 1;
    for (const int to : g[v]) {
        if (dfs(to)) ret = true;
    }

    if (!ret) val[v] = calc_grundy(v, val);
    else loop.push_back(v);

    state[v] = 2;

    return ret;
}

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

    g.resize(n); val.resize(n, -1); state.resize(n);
    for (int i = 0; i < n; i++) {
        int p;
        std::cin >> p;
        --p;
        g[p].push_back(i);
    }

    for (int i = 0; i < n; i++) dfs(i);

    if (loop.empty()) {
        std::cout << "POSSIBLE" << std::endl;
        return 0;
    }

    const int s = loop.front();

    std::vector<int> cands;

    {
        std::set<int> ss;
        for (const int to : g[s]) ss.insert(val[to]);
        for (int i = 0; cands.size() < 2; i++) {
            if (!ss.count(i)) cands.push_back(i);
        }
    }

    bool ret = false;
    for (const int c : cands) {
        auto v(val);
        v[s] = c;

        for (int i = 1; i < loop.size(); i++) v[loop[i]] = calc_grundy(loop[i], v);

        std::vector<int> has(c + 1);
        for (const int to : g[s]) if (0 <= v[to] && v[to] <= c) has[v[to]] = 1;

        if (std::all_of(has.begin(), has.end() - 1, [](const int i) { return i > 0; }) && !has.back()) ret = true;
    }

    std::cout << (ret ? "POSSIBLE" : "IMPOSSIBLE") << std::endl;

    return 0;
}


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

int main() {
	int b, tc, a[100001], i; map<int, int>aa;
	while (cin >> tc) {
		aa.clear();
		for (i = 0; i < tc; i++)cin >> a[i], aa[a[i]]++;
		int ans = 0;
		for (auto it = aa.begin(); it != aa.end(); it++) {
			if (it->second > it->first)ans += (it->second - it->first);
			else ans += (it->second == it->first ? 0 : it->second);
		}
		cout << ans << "\n";
	}
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int main(){
  int p,q;
  cin>>p>>q;
  q/=__gcd(p,q);
  for(int i=2;i*i<=q;i++){
    if(q%i)continue;
    while(q%i==0)q/=i;
    q*=i;
  }
  cout<<q<<endl;
  return 0;
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C>> D;
  bool frag = true;
  while( A>0 || C>0){
    if(frag){
      C -= B;
      frag = false;
      continue;
    }
    else{
      A -= D;
      frag = true;
    }
  }
  if(frag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3624