akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;i<=b;i++)
#define _inline __inline__ __attribute__((always_inline))
#include<math.h>
#define ll long long
using namespace std;
template<class T> _inline void read(T &x){
	T res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
template<class T> inline void print(T x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
ll h;
int main(){
	read<ll>(h);
	ll x=floor(log(h)/log(2));
	print<ll>(pow(2,x+1)-1);
	puts("");
	exit(0);//ans=(long long)(pow(2,floor(log(h)/log(2)+1)-1) 
}

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

void percolate(long cur, long par, vector<vector<long>> &G, vector<long> &Val) {

  if (par >= 0)
    Val[cur] += Val[par];

  if (G[cur].empty())
    return;

  for(auto itr : G[cur]) {
    percolate(itr, cur, G, Val);
  }
}

int main(int argc, char **argv) {
  int i;

  int N, Q;
  cin >> N >> Q;

  vector<vector<long>> G(N);
  int a, b;
  for (int i = 0; i < N - 1; i++) {
    cin >> a >> b;
    a--; b--;
    if (a < b)
      G[a].push_back(b);
    else
      G[b].push_back(a);
  }

  vector<long> Val(N, 0);
  int p, x;
  for (int i = 0; i < Q; i++) {
    cin >> p >> x;
    p--;
    Val[p] += x;
  }

  percolate(0, -1, G, Val);

  for (int i = 0; i < N; i++)
    cout << Val[i] << " ";

  cout << endl;

  return 0;
}


Measured memory_bytes: 24320
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int dp[100010][3];
int g[100010][3];

int main(){
  int n; cin >> n;
  rep(i,n){
    rep(j,3){
      cin >> g[i][j];
      dp[i][j]=g[i][j];
    }
  }
  rep(i,n){
    rep(j,3){
      rep(k,3){
        if(j!=k) chmax(dp[i+1][j],g[i+1][j]+dp[i][k]);
      }
    }
  }
  int ans=0;
  rep(i,3){
    chmax(ans,dp[n][i]);
  }
  cout << ans << endl;
  /*
  rep(i,n){
    rep(j,3){
      cout << dp[i][j];
    }cout << endl;
  }*/
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

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

	ll n, a, b;
	cin >> n >> a >> b;
	ll d = b-a;

	if (d % 2 == 0) cout << d/2 << '\n';
	else {
		ll off1 = a + (d-1)/2;
		ll off2 = (n+1-b) + (d-1)/2;
		cout << min(off1, off2) << '\n';
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int n, sum, r, k;

int main() {
scanf("%d", &n);
if (n == 3) {
	printf("2 5 63\n");
	return 0;
}
printf("2");
r = 1;
k = 3;
sum = 2;
while (k + 6 <= 30000 && r + 2 < n) {
	printf(" %d %d", k, k + 6);
	sum += k;
	sum += k + 6;
	r += 2;
	k += 12;
}
k = 4;
while (r + 1 < n && k <= 30000) {
	printf(" %d", k);
	sum += k;
	r++;
	k += 2;
}
while ((sum + k) % 3 != 0) {
	k += 2;
}
printf(" %d\n", k);
r++;
//printf("%d\n", r);
return 0;
}



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

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, PII> PIP;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

vector<PIP> E;

class BITree{
public:
    static const int SIZE = 100010, BIAS = 5;
    long long u[SIZE];
    void clear(){
        memset(u,0,sizeof(u));
    }
    void modify(int x, long long v){
        for(x+=BIAS;x<SIZE;x+=x&-x) u[x]+=v;
    }
    long long getsum(int x){
        long long s=0;
        for(x+=BIAS;x;x-=x&-x) s+=u[x];
        return s;
    }
} honoka;

int ans[MAXN];

void solve(int casi){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++){
		int x, y;
		scanf("%d%d", &x, &y);
		E.push_back(PIP(y, PII(-1, x)));
	}
	ans[1] = 0;
	for(int i = 2; i <= m; i++){
		ans[i] = 0;
		for(int j = 0; j < m; j += i){
			E.push_back(PIP(min(j + i - 1, m), PII(i, j + 1)));
		}
	}
	sort(E.begin(), E.end());
	for(int i = 0; i < E.size(); i++){
		if (E[i].second.first < 0){
			honoka.modify(-1, 1);
			honoka.modify(E[i].second.second+1, -1);
		}
		else{
			ans[E[i].second.first] += honoka.getsum(E[i].second.second);
		}
	}
	for(int i = 1; i <= m; i++)
		printf("%d\n", n - ans[i]);
}

void printans(){

}


int main(){
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}




Measured memory_bytes: 25064
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



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

	cin >> a;
	vector<bool> ans(a + 1);
	ans[1] = 1;

	rep(i, 2, a + 1) {
		int num = i * i;
	 	while (num <= a) {
			ans[num] = 1;
			num *= i;
		}
	}
	rrep(i, a, 1) {
		if (ans[i]) {
			cout << i << endl; 
			return 0;
		}
			
	}
	
}
	

Measured memory_bytes: 256
s=input()
n=int(input())
ss=s+s
tmp1=0
tmps=""
for i in s:
    if tmps==i:
        tmp1+=1
        tmps=""
    else:
        tmps=i
tmp2=0
tmps=""
for i in ss:
    if tmps==i:
        tmp2+=1
        tmps=""
    else:
        tmps=i
sss=s+s+s
tmp3=0
tmps=""
for i in sss:
    if tmps==i:
        tmp3+=1
        tmps=""
    else:
        tmps=i

sa1=tmp2-tmp1
sa2=tmp3-tmp2
if n%2==1:
    print(tmp1+(sa1+sa2)*(n//2))
else:
    print(tmp1+(sa1+sa2)*(n//2-1)+sa1)

Measured memory_bytes: 3064
#![allow(unused_imports)]
#![allow(dead_code)]
use datastructure::*;
use grapth::*;
use input_scanner::*;
use math::*;
use string_algorithm::*;
use util::*;

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};

fn main() {
    let mut scan = Scanner::new();
    let a: i32 = scan.next();
    println!("{}", a+a*a+a*a*a);
}

mod datastructure {}
mod grapth {}
mod math {}
mod string_algorithm {}
mod util {}
mod input_scanner {
    pub struct Scanner {
        bytes: Vec<u8>,
        begin: usize,
        end: usize,
    }

    impl Scanner {
        pub fn new() -> Self {
            use std::io::Read;
            let mut buffer: Vec<u8> = Vec::new();
            std::io::stdin().read_to_end(&mut buffer).unwrap();
            let end = (0..buffer.len())
                .find(|i| buffer[*i].is_ascii_whitespace())
                .unwrap_or(buffer.len());
            Scanner {
                bytes: buffer,
                begin: 0,
                end: end,
            }
        }
        pub fn next<T: std::str::FromStr>(&mut self) -> T {
            let s: &str =
                unsafe { std::str::from_utf8_unchecked(&self.bytes[self.begin..self.end]) };
            let ret: T = s.parse::<T>().ok().expect("Parse error.");
            self.skip();
            ret
        }
        pub fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
        pub fn next_word(&mut self) -> Vec<u8> {
            let r = Vec::from(&self.bytes[self.begin..self.end]);
            self.skip();
            r
        }
        fn skip(&mut self) {
            self.begin = (self.end..self.bytes.len())
                .find(|i| !self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
            self.end = (self.begin..self.bytes.len())
                .find(|i| self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
        }
    }
}


Measured memory_bytes: 2080
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {

            var n = int.Parse(Console.ReadLine());
            var ta = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var t = ta[0];
            var a = ta[1];
            var h = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var result = 0;
            var sa = 200000.0;

            for (int i = 0; i < n; i++)
            {
                var s = Math.Abs(t - h[i] * 0.006 - a);
                if (s < sa)
                {
                    result = i;
                    sa = s;
                }
            }
            Console.WriteLine(result+1);
    }
}





Measured memory_bytes: 13340
mod = int(1e9+7)
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
    #A, B = [int(x) for x in raw_input().split()]
    N = int(raw_input())
    
    temp = []
    
    while N > 0:
        #print(N)
        ch = ' '
        if N % 26 == 0:
            ch = 'z'
        else:
            ch = chr(ord('a') + (N % 26) - 1)
        temp.append(ch)
        N = (N - 1) // 26
    
    ans = ''.join(reversed(temp))
    
    print(ans)
    
    

main()

Measured memory_bytes: 85044
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define INF 1000000000001
using namespace std;


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

  ll n,k;
  cin>>n>>k;
  ll a[n+1];
  for(ll i=1;i<=n;i++)
  {
    cin>>a[i];
  }
  ll dp[n+1];
  dp[1]=0;
  dp[2]=abs(a[2]-a[1]);
  if(k>=n)
  {
    for(ll i=3;i<=n;i++)
    {
      ll mi=1000000000001;
      for(ll j=1;j<i;j++)
      {
        mi=min(mi,dp[i-j]+abs(a[i]-a[i-j]));
      }
      dp[i]=mi;
    }
    cout<<dp[n];
    exit(0);
  }


  for(int i=3;i<=k;i++)
  {
    ll mi=1000000000001;
    for(ll j=1;j<i;j++)
    {
      mi=min(mi,dp[i-j]+abs(a[i]-a[i-j]));
    }
    dp[i]=mi;
  }
  for(ll i=k+1;i<=n;i++)
  {
    ll mi=1000000000001;
    for(ll j=1;j<=k;j++)
    {
      mi=min(mi,dp[i-j]+abs(a[i]-a[i-j]));
    }
    dp[i]=mi;
  }
  cout<<dp[n];


}


Measured memory_bytes: 1920
import itertools
N = input()
L = list(map(int, input().split()))
def triangle(a, b, c):
    # 三角形が存在するか確認
    if a+b > c and b+c > a and c+a > b:
        # 直角三角形
        if a**2 == b**2 + c**2:
            return 0
        # 鋭角三角形
        elif a**2 < b**2 + c**2:
            return 1
        # 鈍角三角形
        elif a**2 > b**2 + c**2:
            return 2
    else:
        # 三角形が存在しない
        return 3
count = 0
for trio in itertools.combinations(L,3):
    if trio[0]==trio[1] == trio[2]:
        count += 0
    elif trio[0]==trio[1]:
        count += 0
    elif trio[0]==trio[2]:
        count += 0
    elif trio[2]==trio[1]:
        count += 0
    elif triangle(trio[0], trio[1], trio[2]) != 3:
        count += 1
    
print(count)

Measured memory_bytes: 9236
#include<cstdio>
int main(){
    char s[101],t[]="keyence";
    scanf("%s",s);
    int slen=0;
    while(s[slen]!='\0')slen++;
    for(int cutp=0;cutp<=7;cutp++){
        bool flag=true;
        for(int i=0;i<cutp;i++){
            if(s[i]!=t[i]){
                flag=false;
                break;
            }
        }
        if(!flag)continue;
        for(int i=cutp;i<7;i++){
            if(s[slen-7+i]!=t[i]){
                flag=false;
                break;
            }
        }
        if(flag){
            printf("YES");
            return 0;
        }
    }
    printf("NO");
    return 0;
}

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

int main(){
  ll a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  c = c*2;
  if (a + b <= c){
    cout << a*x +b*y << endl;
  }
  else if (a + b > c){
    if (x > y){
      ll sum1 = a * (x-y) + c * y;
      ll sum2 = c * x;
      cout << min(sum1,sum2) << endl;
    }
    else {
      ll sum1 = b * (y-x) + c * x;
      ll sum2 = c * y;
      cout << min(sum1,sum2) << endl;
    }
  }
}

Measured memory_bytes: 256
#include<string>
#include<cctype>
#include<stdio.h>
using namespace std;
int ex(char **b);
int te(char **b);
int fu(char **b);
int num(char **b);
int main(){
	int n;
	char s[1000];
	scanf("%d\n",&n);
	while(n--){
		scanf("%s",s);
		char *p = s;
		printf("%d\n",ex(&p));
	}
}


//和差
int ex(char **b){
	int r=te(b);
	for(;;){
		if(**b=='+')r+=te(&(++*b));
		else if(**b=='-')r-=te(&(++*b));
		else break;
	}
	return r;
}
//乗除
int te(char **b){
	int r=fu(b);
	for(;;){
		if(**b=='*')r*=fu(&(++*b));
		else if(**b=='/')r/=fu(&(++*b));
		else break;
	}
	return r;
}
//数字
int num(char **b){
	int r=0,cnt=0;
	while(isdigit(**b)){
		r*=10;
		r+=**b-'0';
		++*b;
		cnt++;
	}
	return r;
}
//括弧
int fu(char **b){
	if(**b=='('){
		int r=ex(&(++*b));
		++*b;
		return r;
	}
	else return num(b);
}

Measured memory_bytes: 1024
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

void main(){
    int N, A, B;
    readVars(N, A, B);
    auto v = readln.split.to!(long[]);

    auto h1 = new long[](N/2 + 1);
    auto c1 = new long[](N/2 + 1);
    auto h2 = new long[](N - N/2 + 1);
    auto c2 = new long[](N - N/2 + 1);
    dfs(v, 0, N/2, 0, 0, h1, c1);
    dfs(v, N/2, N, 0, 0, h2, c2);

    long max_v = 0, max_num = 0;
    long cnt = 0;

    foreach(i ; 0 .. h1.length){
        foreach(j ; 0 .. h2.length){
            if (A <= (i + j) && (i + j) <= B) {
                auto tot = h1[i] + h2[j];

                if (max_v == 0){
                    max_v = tot;
                    max_num = i + j;
                    cnt = c1[i] * c2[j];
                    continue;
                }

                if (max_v * (i + j) < tot * max_num){
                    cnt = c1[i] * c2[j];
                    max_v = tot;
                    max_num = i + j;
                } else if (max_v * (i + j) == tot * max_num){
                    cnt += c1[i] * c2[j];
                }
            }
        }
    }

    auto ans = 1. * max_v / max_num;
    writefln("%.10f", ans);
    writeln(cnt);
}

void dfs(long[] v, int idx, int end, int cnt, long tot, long[] h, long[] c){
    if (idx == end) {
        if (h[cnt] < tot) {
            h[cnt] = tot;
            c[cnt] = 1;
        } else if (h[cnt] == tot) {
            c[cnt]++;
        }
        return;
    }

    dfs(v, idx + 1, end, cnt + 1, tot + v[idx], h, c);
    dfs(v, idx + 1, end, cnt, tot, h, c);
}

void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

bool is_palidrome(const string &s) {
  string r(s.rbegin(), s.rend());
  return s == r;
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  string S;
  while (cin >> S) {
    int N = S.size();
    bool res = is_palidrome(S) && is_palidrome(S.substr(0, (N - 1) / 2));
    cout << (res ? "Yes" : "No") << endl;
  }
  return 0;
}


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

int main()
{
    string str;
    getline(cin, str);
    for (int i = 0; i < str.length(); i++)
    {
        if (!isalpha(str[i]))
        {
            cout << str[i];
        }
        else if (islower(str[i]))
        {
            cout << char(toupper(str[i]));
        }
        else
        {
            cout << char(tolower(str[i]));
        }
    }
    cout << endl;
}



Measured memory_bytes: 3180
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>

using namespace std;

inline int gi()
{
    int f = 1, x = 0;
    char c = getchar();
    while (c < '0' || c > '9')
    {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9')
    {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return f * x;
}

string s;
bool fl = false, f = false;

int main()
{
	cin >> s;
	int ans = (s[0] - '0') * 10 + s[1] - '0', sum = (s[2] - '0') * 10 + s[3] - '0';
	if (ans >= 1 && ans <= 12) fl = true;
	if (sum >= 1 && sum <= 12) f = true;
	if (fl && !f) puts("MMYY");
	else if (f && !fl) puts("YYMM");
	else if (f && fl) puts("AMBIGUOUS");
	else puts("NA");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		long k = sc.nextLong();
		sc.close();

		if (s.length() == 1) {
			System.out.println(k / 2);
			return;
		}

		long change = 0;
		char first = s.charAt(0);
		char before = s.charAt(0);
		boolean isDuplicate = false;
		boolean isAllSame = true;
		int i = 1;
		while (i < s.length()) {
			char now = s.charAt(i);
			if (isAllSame && before != now) {
				isAllSame = false;
			}
			if (before == now) {
				change++;
				if (i + 1 < s.length() && s.charAt(i + 1) == now) {
					i++;
				}
			}
			before = now;
			i++;
		}
		if (isAllSame) {
			long len = s.length();
			System.out.println((len * k) / 2);
			return;
		}

		boolean isSame = true;
		int sameLen = 0;
		int j = 0;
		char now = s.charAt(0);
		while (isSame && j < s.length()) {
			char next = s.charAt(j);
			if (now == next) {
				sameLen++;
			} else {
				isSame = false;
			}
			now = next;
			j++;
		}

		isSame = true;
		int sameLen2 = 0;
		j = 0;
		now = s.charAt(s.length() - 1);
		while (isSame && j < s.length()) {
			char next = s.charAt(s.length() - j - 1);
			if (now == next) {
				sameLen2++;
			} else {
				isSame = false;
			}
			now = next;
			j++;
		}
		if (first == s.charAt(s.length() - 1) && sameLen / 2 + sameLen2 / 2 != (sameLen + sameLen2) / 2) {
			isDuplicate = true;
		}

		long returnLong = change * k;
		if (isDuplicate) {
			returnLong = returnLong + k - 1;
		}
		System.out.println(returnLong);
	}
}

Measured memory_bytes: 23252
from itertools import combinations

while True:
    n, x = [int(i) for i in input().split()]
    
    if n == x == 0:
        break
    
    count = 0
    for i, j, k in combinations(range(1, n+1), 3):
        if i + j + k == x:
            count += 1
            
    print(count)


Measured memory_bytes: 5644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

const ll d[8][2] = {{0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}};

void dfs(const vector<vector<ll>> &c, vector<vector<ll>> &g, ll x, ll y, ll root) {
    if (g[y][x] != -1) return;
    if (c[y][x] == 0) return;
    g[y][x] = root;
    rep(i, 8) {
        ll nx = x + d[i][0];
        ll ny = y + d[i][1];
        if ((nx < 0) || (nx >= sz(c[0])) || (ny < 0) || (ny >= sz(c))) continue;
        dfs(c, g, nx, ny, root);
    }
}

void solve(ll w, ll h) {
    vector<vector<ll>> c(h, vector<ll>(w)), g(h, vector<ll>(w, -1));
    rep(i, h) rep(j, w) cin >> c[i][j];
    set<ll> s;
    rep(i, h) {
        rep(j, w) {
            dfs(c, g, j, i, i * w + j);
            if (g[i][j] >= 0) s.insert(g[i][j]);
        }
    }
    cout << sz(s) << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    while(true) {
        ll w, h;
        cin >> w >> h;
        if ((w == 0) && (h == 0)) break;
        solve(w, h);
    }
    return 0;
}



Measured memory_bytes: 3308
n,k=map(int,input().split())
ans = float("INF")
t=[0]*n
for i in range(n):
  t[i]=int(input())
t.sort()
for i in range(n-k+1):
  d=t[i+k-1]-t[i]
  ans=min(ans,d)
print(ans)

Measured memory_bytes: 7472
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  private void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int heapSize = Integer.parseInt(br.readLine());
      String[] keys = br.readLine().split(" ");
      int[] heap = new int[heapSize+1];
      for(int i=1; i<=heapSize; i++)
        heap[i] = Integer.parseInt( keys[i-1] );

      StringBuilder buf = new StringBuilder();
      for(int i=1; i<=heapSize; i++){
        buf.append("node " + i + ": key = " + heap[i] + ", ");
        if( i != 1 ) buf.append("parent key = " + heap[i/2] + ", ");
        if( i*2 <= heapSize) {
          buf.append("left key = " + heap[i*2] + ", ");
          if( i*2+1 <= heapSize) {
            buf.append("right key = " + heap[i*2+1] + ", ");
          }
        }
        buf.append("\n");
      }

      System.out.print(buf);
    } catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}


Measured memory_bytes: 24324
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    if (abs(a - c) <= d || (abs(a - b) <= d && abs(c - b) <= d)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
//import java.awt.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    InputStream inputStream;
    if (args.length > 0 && args[0].equals("devTesting")) {
      try {
        inputStream = new FileInputStream(args[1]);
      } catch(FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    } else {
      inputStream = System.in;
    }
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskB solver = new TaskB();
    solver.solve(1, in, out);
    out.close();
  }
  
  static class TaskB {
    int n;
    int[] a;
    
    void solve(int testNumber, InputReader in, PrintWriter out) {
      n = in.nextInt();
      a = new int[n];
      for (int i = 0; i < n; ++i) {
        a[i] = in.nextInt();
      }
      long ans = 0L, acc = 0L;
      for (int i = 0; i < n; ++i) {
        if (a[i] != 0) {
          acc += a[i];
        } else {
          ans += acc / 2;
          acc = 0L;
        }
      }
      ans += acc / 2;
      out.println(ans);
    }

  }
      
  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }
    
    public String nextLine() {
      try {
        return reader.readLine();
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
    
    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public boolean hasInput() {
      try {
        if (tokenizer != null && tokenizer.hasMoreTokens()) {
          return true;
        }
        reader.mark(1);
        int ch = reader.read();
        if (ch != -1) {
          reader.reset();
          return true;
        }
        return false;
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }
    
  }
}


Measured memory_bytes: 20336
n, k = map(int, input().split())
p = list(map(int, input().split()))
p = [x-1 for x in p]
c = list(map(int, input().split()))

visited = [False for _ in range(n)]
lp = []
lp_cum = []

ans = -10**9
for i in range(n):
	if not visited[i]:
		lp.append([i])
		lp_cum.append([0, c[i]])
		visited[i] = True
		while not visited[p[lp[-1][-1]]]:
			lp[-1].append(p[lp[-1][-1]])
			lp_cum[-1].append(lp_cum[-1][-1] + c[lp[-1][-1]])
			visited[lp[-1][-1]] = True
		t_sum, t_num = lp_cum[-1][-1], len(lp[-1])
		for x in range(1, len(lp_cum[-1])):
			for y in range(x):
				r_sum, r_num = lp_cum[-1][x] - lp_cum[-1][y], x-y
				if t_sum <= 0:
					if r_num <= k:
						ans = max(ans, r_sum)
				else:
					if r_num <= k:
						ans = max(ans, r_sum + t_sum * ((k - r_num) // t_num))
				if x < len(lp_cum[-1])-1 or y > 0:
					r_sum, r_num = lp_cum[-1][-1] - lp_cum[-1][x] + lp_cum[-1][y], len(lp[-1])-x+y
					if t_sum <= 0:
						if r_num <= k:
							ans = max(ans, r_sum)
					else:
						if r_num <= k:
							ans = max(ans, r_sum + t_sum * ((k - r_num) // t_num))

print(ans)

Measured memory_bytes: 69504
// C - Go to School
#include <stdio.h>

int main(void){
    int n;
    scanf("%d", &n);
    int num, a[n];
    for(int i=0; i<n; i++){scanf("%d", &num), a[num-1]=i+1;}
    for(int i=0; i<n; i++){printf("%d ",a[i]);}
    puts("");
    return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

int main()
{
    lint mod = 1e9 + 7;
    lint n;
    cin >> n;
    lint ans=0, tmp,sum_a=0;
    vector<lint> a(n);
    REP(i, n){
        cin >> a[i];
        sum_a += a[i];
        sum_a %= mod;
    }
    REP(i,n){
        lint x = sum_a + mod - a[i];
        ans = ans + x * a[i];
        ans%=mod;
    }

    ans = (ans * modinv(2, mod)) % mod;
    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 4832
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#include <utility>
#include <stack>
#include <vector>

using namespace std;
bool ary[6010][6010];
int x1[1010],x2[1010],yy1[1010],y2[1010];
vector<int> X,Y;
set<int> sx,sy;
stack<pair<int,int> > st;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
int xmx,ymx;

int main(){
	int W,H,N,stx,sty,gox,goy,cnt;
	pair<int,int> pa;
	set<int>::iterator it;
	while(true){
		X.clear();
		Y.clear();
		sx.clear();sy.clear();
		for(int i=0;i<6010;i++){
			memset(ary[i],0,sizeof(ary[i]));
		}
		cin>>W>>H;
		if(H==0&&W==0) break;
		cin>>N;
		for(int i=0;i<N;i++){
			cin>>x1[i]>>yy1[i]>>x2[i]>>y2[i];
			sx.insert(x1[i]);
			if(x1[i]>0)sx.insert(x1[i]-1);
			if(x1[i]<W)sx.insert(x1[i]+1);
			sx.insert(x2[i]);
			if(x2[i]>0)sx.insert(x2[i]-1);
			if(x2[i]<W)sx.insert(x2[i]+1);
			sy.insert(yy1[i]);
			if(yy1[i]>0)sy.insert(yy1[i]-1);
			if(yy1[i]<H)sy.insert(yy1[i]+1);
			sy.insert(y2[i]);
			if(y2[i]>0)sy.insert(y2[i]-1);
			if(y2[i]<H)sy.insert(y2[i]+1);
		}
		sx.insert(0);
		sx.insert(W);
		sy.insert(0);
		sy.insert(H);
		for(it=sx.begin();it!=sx.end();it++) X.push_back(*it);
		for(it=sy.begin();it!=sy.end();it++) Y.push_back(*it);
		for(int i=0;i<N;i++){
			stx=lower_bound(X.begin(),X.end(),x1[i])-X.begin();
			gox=lower_bound(X.begin(),X.end(),x2[i])-X.begin();
			sty=lower_bound(Y.begin(),Y.end(),yy1[i])-Y.begin();
			goy=lower_bound(Y.begin(),Y.end(),y2[i])-Y.begin();
			for(int j=stx;j<gox;j++){
				for(int k=sty;k<goy;k++){
					ary[j][k]=true;
				}
			}
		}
		cnt=0;
		//??¢?´¢
		xmx=lower_bound(X.begin(),X.end(),W)-X.begin();
		ymx=lower_bound(Y.begin(),Y.end(),H)-Y.begin();
		for(int i=0;i<xmx-1;i++){
			for(int j=0;j<ymx-1;j++){
				if(ary[i][j]==false){
					st.push(make_pair(i,j));
					while(!st.empty()){
						pa=st.top();st.pop();
						ary[pa.first][pa.second]=true;
						for(int i=0;i<4;i++){
							if(pa.first+dx[i]>=0&&pa.second+dy[i]>=0&&pa.first+dx[i]<xmx-1&&pa.second+dy[i]<ymx-1&&ary[pa.first+dx[i]][pa.second+dy[i]]==false){
								st.push(make_pair(pa.first+dx[i],pa.second+dy[i]));
							}
						}
					}
					cnt++;
				}
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}

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

bool isEightDivisor(int num) {
  int divisor = 0;
  for (int i = 1; i <= num; i++) {
    if (num % i == 0) divisor++;
  }

  return divisor == 8;
}

int main() {
  int N;
  cin >> N;
  int ans = 0;

  for (int i = 1; i <= N; i += 2) {
    if (isEightDivisor(i)) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>

#define MAX 100

int selection(int *,int);

int main(){
  int i,j;
  int seq[MAX],len,cnt=0,temp,num;

  scanf("%d",&len);
  for(i=0;i<len;i++) scanf("%d",&seq[i]);

  /* for(i=0;i<len;i++){
    num=i;
    for(j=i+1;j<len;j++){
      if(seq[num]>seq[j]){
	num=j;
      }
    }
    temp=seq[num];
    seq[num]=seq[i];
    seq[i]=temp;
    if(seq[i]!=seq[num]) cnt++;
    }*/

  cnt=selection(seq,len);

  for(i=0;i<len-1;i++) printf("%d ",seq[i]);
  printf("%d\n",seq[i]);
  printf("%d\n",cnt);
  
  return 0;
}

//kannsuuka
int selection(int *seq,int len){
  int cnt=0,min,temp;
  int i,j;

  for(i=0;i<len-1;i++){
    min=i;
    for(j=i;j<len;j++){
      if(seq[j]<seq[min]) min=j;
    }
    temp=seq[i];
    seq[i]=seq[min];
    seq[min]=temp;
    if(min!=i)cnt++;
  }
  return cnt;
}





Measured memory_bytes: 2112
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<ctime>
#include<queue>
#include<vector>
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define rint register int
typedef long long ll;
using namespace std;
deque<int> q;
int a[200001];
int main()
{   //freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	bool b=true;
	int n;
	cin>>n;
	for(rint i=1;i<=n;i++) cin>>a[i];
	for(rint i=1;i<=n;i++)
	{	if(b) q.push_front(a[i]),b=false;
		else q.push_back(a[i]),b=true;
	}
	if(n%2==1)
	{	while(!q.empty())
		{	cout<<q.front()<<" ";
			q.pop_front();
		}
	}
	else
	{	while(!q.empty())
		{ cout<<q.back()<<" ";
			q.pop_back();
		}
	}
	return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define int long long
#define deb(x) cout<<#x<<" = "<<x<<"\n";
using namespace std;
 
signed main()
{
//	freopen("input.txt", "r", stdin);
	
	int k, n; cin>>k>>n;
  
  	for(int i = n-k+1; i<n+k; i++) cout<<i <<" ";
	
	
}

Measured memory_bytes: 256
int main(){
    int N;
    scanf("%d",&N);

    int a[N];
    for(int i=0;i<N;i++){
        scanf("%d",&a[i]);
    }

    int temp,min;
    for(int i=-100;i<=100;i++){
      int sum=0;
      for(int j=0;j<N;j++){
        sum+=(a[j]-i)*(a[j]-i);
      }
      if(i==-100){
        min=sum;
        temp=sum;
      }else{
        temp=sum;
      }
      if(temp<min){
        min=temp;
      }
    }
    printf("%d\n",min);
    return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

char s[N];

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	scanf("%s",s);

	if(s[0]=='R' && s[1]=='R' && s[2]=='R') puts("3");
	else if((s[0]=='R'&&s[1]=='R')||(s[1]=='R'&&s[2]=='R')) puts("2");
	else if(s[0]=='R' || s[1]=='R' || s[2]=='R') puts("1");
	else puts("0");


    return 0;
}

Measured memory_bytes: 3756
#include<stdio.h>
int main(void){
  int a,b,c,d,ti=0;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(a<c){
    if(b<d){
      ti = b -c;
    }else{
      ti = d - c;
    }
  }else{
    if(b<d){
    ti = b - a;
  }else{
    ti = d - a;
    }
  }
  if(ti<=0){
    printf("0");
  }else{
    printf("%d",ti);
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n];

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
    }

    long f = 0;

    for (int i = 0; i < n; i++) {
      f += a[i]-1;
    }

    System.out.println(f);

  }

}


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

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, p, q, a[500500], b[500500];

signed main() {
	cin >> n >> p >> q;
	rep(i,n) {
		cin >> a[i];
		b[i] = a[i] + i*p;
	}
	int s = accumulate(a,a+n,0ll);
	sort(b,b+n);
	rep(i,n-1) b[i+1] += b[i];
	int res = s;
	repst(k,1,n) chmax(res, s + k*q*p + k*(k-1)*p - b[k-1]);
	cout << res << ln;
}


Measured memory_bytes: 11000
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

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

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

mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}

mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}


int main() {
    int n; cin >> n;
    ld a = 0.0;
    rep(i,n){
        double m; cin >> m;
        a += 1 / m;
    }
    cout << setprecision(20);
    cout << 1 / a << endl;
}

Measured memory_bytes: 256
input_li = [int(input()) for _ in range(5)]
rest_li = [_ % 10 for _ in input_li]
rest_li = [_ for _ in rest_li if _ != 0]

if len(rest_li) != 0:
    min_li = min(rest_li)
    del rest_li[rest_li.index(min_li)]
    total = 0

    for i in  rest_li:
        if i != 0:
            total += 10 - i

    print(sum(input_li) + total)

else:
    print(sum(input_li))

Measured memory_bytes: 3060
N = int(input())
X = list(map(int, input().split()))

ave = sum(X) // len(X)

ans1 = 0
ans2 = 0
for i in range(N):
    ans1 += (X[i] - ave)**2
ave += 1
for i in range(N):
    ans2 += (X[i] - ave)**2

print(min(ans1, ans2))



Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i=0; i < n; i++)
using namespace std;

int main(){
	int n;
	cin >> n;
	int tmp;
	vector<int> integers;
	rep(i, n) {
		cin >> tmp;
		integers.push_back(tmp);
	}

	int max_profit= -pow(10, 10);
	int min_price = pow(10, 10);
	rep(i, n) {
		max_profit = max(integers.at(i) - min_price, max_profit);
		min_price = min(min_price, integers.at(i));		
	}
	cout << max_profit << endl;
}




Measured memory_bytes: 3896
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long ll;
const int maxn = 1e5+100;
int main()
{
    int n;
    cin >> n;
    cout << (1000- n % 1000)%1000 << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> key;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        int s = 0;
        rep(j, b) {
            int c;
            cin >> c;
            --c;
            s |= 1<<c;
        }
        key.emplace_back(s,a);
    }
    vector<int> dp(1<<n, 1e8);
    dp[0] = 0;
    rep(s, 1<<n) {
        rep(i, m) {
            int t = s | key[i].first;
            int cost = dp[s] + key[i].second;
            dp[t] = min(dp[t], cost);
        }
    }
    int ans = dp.back();
    if ( ans == 1e8 ) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int h,w;
int map[100][100];
int qtx[800000],qty[800000],qkx[800000],qky[800000];
int ql[800000];
int tail,head;
int ans;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
bool vis[60][60][60][60];
bool bend;
void BFS(int tx,int ty,int kx,int ky,int len){
	if(len==100)return;
	if(tx==kx&&ty==ky){
		ans=len;
		bend=true;
		return;
	}
	for(int i=0;i<4;i++){
		bool mt=false,mk=false;
		if(tx+dx[i]>=0&&tx+dx[i]<w&&ty+dy[i]>=0&&ty+dy[i]<h){
			if(map[ty+dy[i]][tx+dx[i]]==0){
				mt=true;
			}
		}
		if(kx-dx[i]>=0&&kx-dx[i]<w&&ky-dy[i]>=0&&ky-dy[i]<h){
			if(map[ky-dy[i]][kx-dx[i]]==0){
				mk=true;
			}
		}
		qtx[tail]=tx+mt*dx[i],qty[tail]=ty+mt*dy[i];
		qkx[tail]=kx-mk*dx[i],qky[tail]=ky-mk*dy[i];
		ql[tail]=len+1;
		tail++;
	}
}
int main(){
	while(true){
	cin>>w>>h;
	if(w==0&&h==0)break;
	for(int i=0;i<60;i++){
		for(int j=0;j<60;j++){
			for(int k=0;k<60;k++){
				for(int r=0;r<60;r++){
					vis[i][j][k][r]=false;
				}
			}
		}
	}
	int tx,ty,kx,ky;
	cin>>tx>>ty>>kx>>ky;
	tx--,ty--,kx--,ky--;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>map[i][j];
		}
	}
	ans=869121;
	qtx[0]=tx,qty[0]=ty,qkx[0]=kx,qky[0]=ky;
	ql[0]=0;
	tail=1,head=0;
	bend=false;
	while(true){
		if(tail==head)break;
		if(!vis[qtx[head]][qty[head]][qkx[head]][qky[head]]){
		vis[qtx[head]][qty[head]][qkx[head]][qky[head]]=true;
		BFS(qtx[head],qty[head],qkx[head],qky[head],ql[head]);
		}
		if(bend)break;
		head++;
	}
	if(ans==869121)cout<<"NA"<<endl;
	else cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 29116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for(auto v:(V))cout<<v<<" "<<endl
inline int GCD(int a, int b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;

int main()
{
    int N, M, C;
    cin >> N >> M >> C;
    vi B(M);
    rep(i, M)
    {
        cin >> B.at(i);
    }
    vvi A(N, vi(M));
    rep(i, N)
    {
        rep(j, M)
        {
            cin >> A.at(i).at(j);
        }
    }
    int ans = 0;
    rep(i, N)
    {
        int sum = 0;
        rep(j, M)
        {
            sum += A.at(i).at(j) * B.at(j);
        }
        sum += C;
        if (sum > 0)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

using int64 = long long;


int N, L, Q, X[100000];
int step[21][100000];

int main() {

  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> X[i];
  }
  cin >> L >> Q;

  int ptr = 0;
  for(int i = 0; i < N; i++) {
    while(ptr < N && X[i] + L >= X[ptr]) ++ptr;
    step[0][i] = ptr - 1;
  }
  for(int i = 1; i < 21; i++) {
    for(int j = 0; j < N; j++) {
      step[i][j] = step[i - 1][step[i - 1][j]];
    }
  }
  while(Q--) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    if(x > y) swap(x, y);
    int ret = 0;
    for(int i = 20; i >= 0; i--) {
      if(step[i][x] < y) {
        ret |= 1 << i;
        x = step[i][x];
      }
    }
    cout << ret + 1 << endl;
  }

}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int r, g;
  cin >> r >> g;
  cout << g * 2 - r;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>

void sort(void);

int i,j,p,irekae,n=0;
int a[200];

int main(void){
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	
	sort();
	
	for(i=0;i<n;i++){
		if(i!=0)printf(" ");
		printf("%d",a[i]);
	}
	printf("\n%d\n",irekae);
	
	return 0;
}

void sort(void){
	int t=0;
	
	for(p=0;p<n;p++){
		for(i=n-1,j=n-2;j>=p;i--,j--){
			if(a[i]<a[j]){
				t=a[i];
				a[i]=a[j];
				a[j]=t;
				irekae=irekae+1;
			}
		}
	}
	return;
}


Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Long[] array = new Long[6];
		int x = sc.nextInt();
		int flag=0;
		if(x==2) {
			System.out.println(2);
			System.exit(0);
		}
		for(int i=x;10000000>i;i++) {
			for(int j=2;i>j;j++) {
				if(i%j==0) {
					break;
				}
				if(j+1==i)
					flag=1;
			}
			//System.out.println(i);
			if(flag==1) {
			System.out.println(i);
			System.exit(0);
			}
		}
	}
}

Measured memory_bytes: 23124