akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

long long read_long_long() {
	long long ret=0;char c=getchar();
	while(c<'0' || c>'9') c=getchar();
	while(c>='0' && c<='9') {
		ret=ret*10+c-'0';
		c=getchar();
	}		return ret;
}

const long MAXN=300010;
const long long mod=1000000007;
long n;
long long a[MAXN];
long long zero,one,ans=0,now;

int main() {
	n=read_long_long();
	register long i,j;
	for(i=1;i<=n;++i)
		a[i]=read_long_long();
	
	now=1;
	for(i=1;i<=62;++i) {
		zero=0;one=0;
		for(j=1;j<=n;++j) {
			if(a[j]%2ll==0)
				++zero;
			else ++one;
		}
		ans+=(now*one)%mod *zero % mod;
		ans%=mod;
		
		now<<=1ll;
		now%=mod;
		for(j=1;j<=n;++j)
			a[j]>>=1ll;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


bool cmp(pair<int,int>p,pair<int,int>q) {
    // return p.first>q.first;//descending by first
    // return p.first<q.first;//ascending by first
    // return p.second>q.second;//descending by second
    return p.second<q.second;//ascending by second
}

// bool cmp(int p,int q) {
    // return p>q;//descending
    // return p<q;//ascending
// }

int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    int n;
    cin>>n;
    int det=0;
    while(n!=0) {
        if(n%10==7) {
            ++det;
        }
        n/=10;
    }

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

Measured memory_bytes: 3604
X = [0] * 5

for c in range(5):
    ABC = input()
    X[c] = [int(ABC), int(ABC[-1])]
    if X[c][1] == 0:
        X[c][1] = 10
        X[c].append(X[c][0])
    else:
        X[c].append(X[c][0] + (10 - X[c][1]))

X.sort(reverse=True, key=lambda val:val[1])

ans = sum([X[x][2] for x in range(4)]) + X[4][0]

print(ans)

Measured memory_bytes: 9136
#include "iostream"
#include "random"
#include "string"
#include "bitset"
#include "algorithm"
#include "map"
#include "queue"
#include "list"
#include "set"
#include "climits"
#include "iomanip"
#include "stack"
#include "functional"

using namespace std;
using ll = long long int;
using PII = pair<ll, ll>;



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

	ll n;
	cin >> n;
	vector<ll> a(n), b(n);
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		if (s == "kougekida") a[i] = 0;
		else if (s == "tameru") a[i] = 1;
		else if (s == "mamoru") a[i] = 2;
	}
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		if (s == "kougekida") b[i] = 0;
		else if (s == "tameru") b[i] = 1;
		else if (s == "mamoru") b[i] = 2;
	}

	ll x = 0, y = 0;
	for (int i = 0; i < n; ++i) {
		if (a[i] == 0 && b[i] == 0) {
			if(x == y) {}
			else if (x > y) { cout << "Isono-kun" << endl; return 0; }
			else if (y > x) { cout << "Nakajima-kun" << endl; return 0; }
			x = y = 0;
		}
		else if (a[i] == 0 && b[i] == 1) {
			if (x == 0) cout << "Nakajima-kun" << endl;
			else cout << "Isono-kun" << endl;
			return 0;
		}
		else if (a[i] == 0 && b[i] == 2) {
			if (x == 0) {
				cout << "Nakajima-kun" << endl; return 0;
			}
			else if (x == 5) {
				cout << "Isono-kun" << endl; return 0;
			}
			x = 0;
		}
		else if (a[i] == 1 && b[i] == 0) {
			if (y == 0) { cout << "Isono-kun" << endl; return 0; }
			else { cout << "Nakajima-kun" << endl; return 0; }
		}
		else if (a[i] == 1 && b[i] == 1) {
			x = min(x + 1, 5LL);
			y = min(y + 1, 5LL);
		}
		else if (a[i] == 1 && b[i] == 2) {
			x = min(x + 1, 5LL);
		}
		else if (a[i] == 2 && b[i] == 0) {
			if (y == 0) {
				cout << "Isono-kun" << endl;
				return 0;
			}
			else if(y == 5) {
				cout << "Nakajima-kun" << endl;
				return 0;
			}
			y = 0;
		}
		else if (a[i] == 2 && b[i] == 1) {
			y = min(y + 1, 5LL);
		}
		else if (a[i] == 2 && b[i] == 2) {
			// none
		}
	}

	cout << "Hikiwake-kun" << endl;
}


Measured memory_bytes: 3244
from __future__ import annotations

from dataclasses import dataclass, field
from typing import List
from typing import Tuple


@dataclass
class Tour:
    height: int
    connected_other_tours: List[Tour] = field(default_factory=list)

    def connect(self, other_tour: Tour) -> None:
        self.connected_other_tours.append(other_tour)

    def is_good(self) -> bool:
        """
        展望台 i が良い展望台であるとは、
            ・展望台 i から一本の道を使って辿り着けるどの展望台よりも展望台 i の方が標高が高いことをいいます。
            ・展望台 i から一本の道を使って辿り着ける展望台が存在しない場合も、展望台 i  は良い展望台であるといいます。
        """
        for other_tour in self.connected_other_tours:
            if self.height <= other_tour.height:
                return False

        return True


@dataclass
class Tours:
    values: List[Tour] = field(default_factory=list)

    def add(self, tour: Tour) -> None:
        self.values.append(tour)  # メモリ重視して破壊的変更

    def register_routes(self, ab_list: List[Tuple[int, int]]) -> None:
        for a, b in ab_list:
            tour_a = self.values[a - 1]
            tour_b = self.values[b - 1]

            tour_a.connect(tour_b)
            tour_b.connect(tour_a)

    def count_good_tours(self) -> int:
        return sum([tour.is_good() for tour in self.values])

    @classmethod
    def create(cls, height_list: List[int]) -> Tours:
        return Tours([Tour(height) for height in height_list])


def answer(height_list: List[int], ab_list: List[Tuple[int, int]]) -> int:
    tours = Tours.create(height_list)

    tours.register_routes(ab_list)

    return tours.count_good_tours()


N, M = map(int, input().split())
h_list = list(map(int, input().split()))

ab_list = []
for _ in range(M):
  a, b = list(map(int, input().split()))
  ab_list.append((a, b))

# print(N, M)
# print(h_list)
# print(ab_list)

print(answer(h_list, ab_list))

Measured memory_bytes: 55676
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>vec.at(i);
    }
    sort(vec.begin(),vec.end());
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            for(int k=0;k<j;k++){
                if(vec.at(k)!=vec.at(j)&&vec.at(j)!=vec.at(i)&&vec.at(k)+vec.at(j)>vec.at(i)) ans++;
            }
        }

    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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



int main(void) {
	int i, j, k, tmp;
	int N;
	double sum = 0;
	double ans;
	vector<int> A;

	scanf("%d", &N);
	rep(i, N) {
		scanf("%d", &tmp);
		sum += (double)1 / tmp;
	}
	cout << (double)1 / sum;


	return 0;
}

Measured memory_bytes: 256
// should study DP

#include <iostream>

using namespace std;

int main() {
    long long int N;
    long long int M;
    cin >> N;
    cin >> M;
    long long int a[M + 2];
    a[0] = - 1;
    a[M + 1] = N + 1;
    for(int i = 1; i < M + 1; i++) cin >> a[i];

    //cant arrive goal
    /*long long int con = a[1];
    for(long long int i = 2; i < M + 1; i++) {
        if(con + 1 == a[i]) {
            cout << "0" << endl;
            exit(1);
        }
        con = a[i];
    }*/

    long long int fib[N+1];
    fib[0] = 1;
    fib[1] = 1;
    for(int i = 2; i < N + 1; i++) {
        fib[i] = fib[i-1] + fib[i-2];
        fib[i] %= 1000000007;
    }

    long long int patern = 1;
    long long int steps;
    for(int i = 1; i < M + 2; i++) {
        if((a[i] - a[i-1]) == 1) {
            patern = 0;
            break;
        } else {
            steps = a[i] - a[i - 1] - 2;
            patern *= fib[steps];
            patern %= 1000000007;
        }
    }

    cout << patern << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int cnt[4];
int main()
{
    int n, x;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &x);
        cnt[x % 4]++;
    }
    if (cnt[2] > 0) cnt[2] = 1;
    if (cnt[0] + 1 >= cnt[1] + cnt[3] + cnt[2]) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
def isY(num):
    return True

def isM(num):
    if num <= 12 and num >= 1:
        return True

    return False

def isYYMM(first, second):
    return (isY(first) and isM(second))

def isMMYY(first, second):
    return (isM(first) and isY(second))

line = input()
first = int(line[:2])
second = int(line[2:])

ans = "NA"

if (not isMMYY(first, second)) and isYYMM(first, second):
    ans = "YYMM"

if isMMYY(first, second) and (not isYYMM(first, second)):
    ans = "MMYY"

if isMMYY(first, second) and isYYMM(first, second):
    ans = "AMBIGUOUS"

        
print(ans)



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

int main() {
	// your code goes here
	int n,q,i,j,l,r;
	cin>>n>>q;
	string s;
	cin>>s;
	int ac[n];
	memset(ac,0,sizeof(ac));
	for(int i=1;i<n;i++){
		if(s[i]=='C' && s[i-1]=='A')
			ac[i]=ac[i-1]+1;
		else
			ac[i]=ac[i-1];
	}
	while(q--){
		cin>>l>>r;
		r--;
		l--;
		cout<<ac[r]-ac[l]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(12)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
ll MOD=1000000007;
 
ll gcd(ll a,ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main()
{
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll cnt=0;
	for(ll i=0;i<n;i++)
	{
		if(s[i]!=s[i+1])
		cnt++;
	}
	cout<<cnt;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
bool check(string s)
{
    FOR(i, 0, s.size() / 2)
    {
        if(s[i] != s[s.size() - i - 1]) return 0;
    }
    return 1;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    string s;
    cin >> s;
    int n = s.size();
    if(check(s))
    {
      //  cout << 'aa';
        string t = s.substr(0, (n - 1) / 2);
        if(check(t))
        {
            int st = (n + 3) / 2 - 1;
            string g = s.substr(st, n - st + 1);
            if(check(g))
            {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}


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

int main(){
    char s[1010];
    int a;
    scanf("%s", s);
    a = strlen(s);
    char c = s[a];
    if(s[a-1] != 's'){
        printf("%ss\n", s);
    }else{
        printf("%ses\n", s);
    }
}

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


int N;
vector<int> a, b;


vector<int> kmp(const vector<int> &vt, vector<int> &vp)
{
    int i, q, k;
    int n = vt.size();
    int m = vp.size();
    vector<int> nxt(m);
    vector<int> res;

    for (q = 1, k = 0; q < m; ++q) {
        while (k > 0 && vp[q] != vp[k]) k = nxt[k - 1];
        if (vp[q] == vp[k]) k++;
        nxt[q] = k;
    }

    for (i = 0, q = 0; i < n; ++i) {
        while (q > 0 && vp[q] != vt[i]) q = nxt[q - 1];
        if (vp[q] == vt[i]) q++;
        if (q == N) {
            res.push_back(i - m + 1);
            q = nxt[q - 1];
        }
    }
    return res;
}


void solve()
{
    vector<int> c(2*N-1);
    vector<int> d(N);
    for (int i = 0; i < N - 1; i++) {
        c[i] = a[i] ^ a[i + 1];
        d[i] = b[i] ^ b[i + 1];
    }
    c[N - 1] = a[N - 1] ^ a[0];
    d[N - 1] = b[N - 1] ^ b[0];
    for (int i = N; i < 2*N; i++) c[i] = c[i - N];
    auto pos = kmp(c, d);
    for (int k : pos) cout << k << " " << (b[0] ^ a[k]) << endl;
}


int main()
{
    cin >> N;
    a.resize(N);
    b.resize(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N; i++) cin >> b[i];
    solve();
    return 0;
}


Measured memory_bytes: 8292
x, n = map(int,input().split())
if n != 0:
    p = list(map(int,input().split()))
else:
    print(x)
    quit()

p.sort()
d = 10 ** 9
for i in range(-1000,1000):
    if d > abs(i-x) and i not in p:
        d = abs(i-x)
        ans = i
print(ans)

Measured memory_bytes: 9192
// KnapS

#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main(){
	ll n,w;
	cin >> n >> w;

	ll wt[n];
	ll val[n];
	ll sum = 0;
	for(int i=0 ; i<n ; i++){
		cin >> wt[i] >> val[i];
		sum += val[i];
	}

	//cout << "s" << sum << "\n";
	ll dp[n][sum+1];
	ll ans = 0;
	for(ll i=0 ; i<n ; i++){
		for(ll j=0 ; j<=sum ; j++){
			if(i==0){
				if(val[i] == j){
					dp[i][j] = wt[i];
				}
				else{
					dp[i][j] = INT_MAX;
				}
			}
			else{
				if(j==val[i]){
					dp[i][j] = min(dp[i-1][j],wt[i]); 
				}
				else if(j>val[i]){
					dp[i][j] = (dp[i-1][j] > dp[i-1][j-val[i]] + wt[i])? dp[i-1][j-val[i]] + wt[i] : dp[i-1][j]; 
				}
				else{
					dp[i][j] = dp[i-1][j];
				}
			}
			/*if(dp[i][j] >= INT_MAX){
				cout << "i " ;
			}
			else{
				cout << dp[i][j] << " ";	
			}*/
		}
		//cout << "\n";
	}

	for(int i=0 ; i<n ; i++){
		for(int j=0 ; j<=sum ; j++){
			if(dp[i][j] <= w){
				if(ans < j){
					ans = j;
				} 
			}
		}
	}




	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 78336
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
heapq.heapify(a)
CB=[]
for _ in range(m):
    b, c = map(int, input().split())
    CB.append((c, b))
CB.sort(reverse=True)

for c, b in CB:
    if a[0] >= c:
        break
    for _ in range(b):
        if a[0] >= c:
            break
        heapq.heappushpop(a, c)

print(sum(a))

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

int main(){
  std::string str;
  std::cin>>str;
  /*if(str.substr(0,4) < 2019){
    heisei();
  }else if(str.substr(0,4) > 2019){
    tbd();
  }else{
    if(str.)
  }*/
  if(str <= "2019/04/30"){
    std::cout<<"Heisei"<<std::endl;
  }else{
    std::cout<<"TBD"<<std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

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

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

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

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

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

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

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

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    let n: isize = read();
    let a: isize = read();
    let b: isize = read();
    let m = n / (a + b);
    let ans = m * a + min(n % (a + b), a);
    println!("{}", ans);
}


Measured memory_bytes: 4352
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    ll n,x;
    while(1){
        cin >> n >> x;
        if(n==0 && x==0) break;
        ll cnt= 0;
        FOR(i,1,n-1){
            FOR(j,i+1,n){
                FOR(k,j+1,n+1){
                    if(i+j+k==x) cnt++;
                }
            }
        }
        out(cnt);
    }
    return 0;
}


Measured memory_bytes: 3236
n = int(input())
arr = [list(map(int,input().split())) for _ in range(n-1)]
mod = 10**9+7

graph = [[] for _ in range(n)]
for a,b in arr:
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

parents = [-1] * n
children = [[] for _ in range(n)]
flags = [True] * n; flags[0] = False
stack = [0]
orders = []

while stack:
    index = stack.pop()
    orders.append(index)
    for child in graph[index]:
        if flags[child]:
            parents[child] = index
            children[index].append(child)
            flags[child] = False
            stack.append(child)

fac = [1] * (n+10)
inv = [1] * (n+10)
ifac = [1] * (n+10)
for i in range(2,n+10):
    fac[i]=(fac[i-1]*i)%mod
    inv[i]= -(inv[mod%i]*(mod//i))%mod
    ifac[i]=(ifac[i-1]*inv[i])%mod

size = [1] * n
dp = [1] * n
for parent in orders[::-1]:
    for child in children[parent]:
        size[parent] += size[child]
        dp[parent] = dp[parent] * dp[child] * ifac[size[child]] % mod
    dp[parent] = dp[parent] * fac[size[parent]-1] % mod

size2 = [n-i+1 for i in size]
dp2 = [1] * n
for parent in orders[1:]:
    child = parents[parent]
    dp2[parent] = dp2[parent] * fac[size2[parent]-2] * dp[child] * dp2[child] * fac[size[parent]] * ifac[size2[child]-1] * ifac[size[child]-1] * pow(dp[parent], mod-2, mod) % mod
    
for i in range(n):
    print(fac[n-1] * ifac[size[i]-1] * ifac[size2[i]-1] * dp[i] * dp2[i] % mod)

Measured memory_bytes: 152008
import sys;
import heapq

def iterative(i,j):
    q = []
    heapq.heappush(q,(sumcost,(0,i,j,0,puz)))
    global finding

    while len(q):
        cost, items = heapq.heappop(q)
        c_depth = items[0]
        _i = items[1]
        _j = items[2]
        prev_move = items[3]
        c_puz = items[4]
        _sum_cost = cost - c_depth
        if(_sum_cost == 0):
            finding = 1
            print(c_depth)
            break
        if(cost > depth):
            continue

        c_cost = HS(_i,_j,c_puz[_i*3+_j])

        if(_i != 0 and prev_move != 1):
            swap_puz = swapPuz(c_puz[0:],_i,_j,_i-1,_j)
            n_cost = cost+1+checkCost(c_cost,HS(_i-1,_j,c_puz[(_i-1)*3+_j]),HS(_i,_j,swap_puz[_i*3+_j]),HS(_i-1,_j,swap_puz[(_i-1)*3+_j]))
            if(n_cost <= depth):
                heapq.heappush(q,(n_cost,(c_depth+1,_i-1,_j,2,swap_puz)))
        if(_i != 2 and prev_move != 2):
            swap_puz = swapPuz(c_puz[0:],_i,_j,_i+1,_j)
            n_cost = cost+1+checkCost(c_cost,HS(_i+1,_j,c_puz[(_i+1)*3+_j]),HS(_i,_j,swap_puz[_i*3+_j]),HS(_i+1,_j,swap_puz[(_i+1)*3+_j]))
            if(n_cost <= depth):
                heapq.heappush(q,(n_cost,(c_depth+1,_i+1,_j,1,swap_puz,)))
        if(_j != 0 and prev_move != 3):
            swap_puz = swapPuz(c_puz[0:],_i,_j,_i,_j-1)
            n_cost = cost+1+checkCost(c_cost,HS(_i,_j-1,c_puz[_i*3+_j-1]),HS(_i,_j,swap_puz[_i*3+_j]),HS(_i,_j-1,swap_puz[_i*3+_j-1]))
            if(n_cost <= depth):
                heapq.heappush(q,(n_cost,(c_depth+1,_i,_j-1,4,swap_puz)))
        if(_j != 2 and prev_move != 4):
            swap_puz = swapPuz(c_puz[0:],_i,_j,_i,_j+1)
            n_cost = cost+1+checkCost(c_cost,HS(_i,_j+1,c_puz[_i*3+_j+1]),HS(_i,_j,swap_puz[_i*3+_j]),HS(_i,_j+1,swap_puz[_i*3+_j+1]))
            if(n_cost <= depth):
                heapq.heappush(q,(n_cost,(c_depth+1,_i,_j+1,3,swap_puz)))

def checkCost(c_cost,m_cost,c2_cost,m2_cost):
    return c2_cost - c_cost + m2_cost - m_cost

def sumCost(puz):
    value = 0
    for i in range(3):
        value += HS(i,0,puz[i*3])
        value += HS(i,1,puz[i*3+1])
        value += HS(i,2,puz[i*3+2])
    return value

def HS(i,j,num):
    if(num != 0):
        k = num-1
    else:
        k = 8
    ki = (int)(k/3)
    kj = k - ki*3
    value = abs(i-ki)+abs(j-kj)
    return value


def swapPuz(c_puz, i, j, i2,j2):
    c_puz[i2*3+j2],c_puz[i*3+j] = c_puz[i*3+j],c_puz[i2*3+j2]
    return c_puz

correctPuz = [i+1 for i in range(9)]
correctPuz[8] = 0
puz = [0 for i in range(9)]

i_start = 0
j_start = 0

for i in range(3):
    puz[i*3],puz[i*3+1],puz[i*3+2] = map(int, input().split());
    if(puz[i*3] == 0):
        i_start,j_start = i,0
    elif(puz[i*3+1] == 0):
        i_start,j_start = i,1
    elif(puz[i*3+2] == 0):
        i_start,j_start = i,2

sumcost = sumCost(puz)

finding = 0
depth = 0
while True:
    if(finding == 1):
        break
    iterative(i_start,j_start)
    depth+=1



Measured memory_bytes: 8576
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int64 n;
  cin >> n;
  int ret = 0;
  for (int64 x = 100; x < n; ) {
    x += x / 100;
    ++ret;
  }
  cout << ret << endl;
  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

struct Edge {
  int to;
  ll cost;
};
using Graph = vector<vector<Edge>>;

// Bellman Ford
// 戻り値: goalに行くまでの最小コスト。負の閉路が存在する場合は-INFとなる。
ll bellman_ford(const Graph& G, const int start, const int goal) {
  const int n = G.size();

  // 始点からそこまで行くのにかかるのコスト
  vector<ll> cost(n, INF);
  cost[start] = 0;

  for (int i = 0; i < n; i++) {
    // すべての辺を走査
    for (int from = 0; from < n; from++) {
      for (auto e : G[from]) {
        // 更新
        if (cost[e.to] > cost[from] + e.cost) {
          cost[e.to] = cost[from] + e.cost;
          // 頂点数と同じ回数ループしても更新出来る場合、負の閉路が存在する
          if (i >= n - 1 && e.to == goal) {
            return -INF;
          }
        }
      }
    }
  }
  return cost[goal];
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, m;
  cin >> n >> m;

  Graph G(n + 1);

  rep(i, m) {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    G[a].push_back((Edge){b, -c});
  }

  ll ans = bellman_ford(G, 1, n);
  ans *= -1;

  if (ans == INF) {
    cout << "inf" << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s="No";
  for(int i=1; i<=9; i++){
    for(int j=i; j<=9; j++){
      if(n==i*j) s="Yes";
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
#define foreach(itr,c) for(typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

typedef long long ll;
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
inline ll toll(string s) {ll v; istringstream sin(s);sin>>v;return v;}


int main(){
  int i,j,k,n;
  string in;

  cin >> n;
  while(n--){
    cin >> in;

    sort(in.begin(),in.end());
    ll mini = toll(in);
    reverse(in.begin(),in.end());
    ll maxi = toll(in);

    cout << maxi - mini << endl;
  }

  return 0;
}

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

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

  int k, n;
  cin >> k >> n;
  int a[n];
  int distance[n];
  rep(i, n) cin >> a[i];
  for (int i = 0; i <= n; i++) {
    if (i < n) {
      cin >> a[i];
    }
    if (i > 0) {
      if (i < n) {
        distance[i - 1] = a[i] - a[i - 1];
      } else {
        distance[i - 1] = k + a[0] - a[i - 1];
      }
    }
  }
  sort(distance, distance + n);
  ll dist = 0;
  for (int i = 0; i < n - 1; i++) {
    dist += distance[i];
  }
  cout << dist << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
/*** Template Begins ***/
 
typedef long long   ll;
typedef pair<ll,ll> pll;
typedef long double ld; 
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb           push_back
#define F            first
#define S            second
#define ios          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define hell   1000000007LL
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p){ ll res = 1;x = x % p;while (y > 0) {if (y & 1) res = (res*x) % p;y = y>>1;
  x = (x*x) % p;} return res;} 

const long double PI = acos(-1);
// Debug //
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
ll euclid(ll x,ll y,ll a,ll b){
  return (a-x)*(a-x)+(b-y)*(b-y);
}
void solve()
{
  ll a;
  cin>>a;
  cout<<a+a*a+a*a*a;
}

int main()
{ 
  ios; 
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  ll t=1,i=1;
  // cin>>t;
  while(i<=t)
  {
    solve();
    i++;
  }
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
long long n;
int main()
{
	scanf("%lld",&n);
	long long tr=n/3,fi=n/5,te=n/15;
//	cout<<tr<<" "<<fi<<" "<<te<<" "<<n*(n+1)/2<<" "<<((tr+1)*tr*3)/2<<" "<<endl;
	long long sum=(n*(n+1))/2-((tr+1)*tr*3)/2-((fi+1)*fi*5)/2+((te+1)*te*15)/2;
    printf("%lld\n",sum);
	return 0;
} 

Measured memory_bytes: 3824
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0): # 四捨五入
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def round_up(a): # 切り上げ
    return int(a + 0.9)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    n = int(input())
    p = [x for x in map(int,input().split())]
    num = int(1e9)
    ans = 0
    for i in range(n):
        if p[i] <= num:
            num = p[i]
            ans += 1
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 77132
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;
int main()
{
    long long n, m;
    cin >> n >> m;
    long long ans;
    ans = ((n - m) * 100 + m * 1900) * pow(2, m);
    cout << ans << endl;
    return 0;
}

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

int main(void)
{
    double N;
    cin >> N;

    if ((int)N % 2) {
        cout << setprecision(10) << (N + 1) / (2 * N) << endl;
    } else {
        cout << setprecision(10) << 1.0 / 2 << endl;
    }
}



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


int main()
{
	long long n, m;

	std::cin >> n >> m;

	long long ans = 0;

	ans = std::min(n, m / 2);

	n -= ans;
	m -= ans * 2;

	if (m > 2) {
		ans += m / 4;
	}

	std::cout << ans << std::endl;

    return 0;
}



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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = pow(2, 62);
//const int inf = pow(2, 31) - 10;
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




/* main */
int n, k;
vi arr;

int factorial(int n){
    if(n == 1 or n == 0) return 1;
    return n * factorial(n - 1) % mod;
}

int dp[100][100][260];

int dfs(int i, int cnt, int accum){

    if(i == n){
        if(accum == k) return factorial(cnt);
        else return 0;
    }

    if(dp[i][cnt][accum] > -1) return dp[i][cnt][accum];

    int ans = dfs(i + 1, cnt, accum) % mod;
    ans += dfs(i + 1, cnt + 1, accum ^ arr[i]);
    ans %= mod;

    return dp[i][cnt][accum] = ans;

}



signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);



    cin >> n >> k;

    rep(i,0,n) arr.push_back(input());

    memset(dp, -1, sizeof(dp));

    print(dfs(0, 0, 0));





    

   




    

    

    



    
    



    







    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










Measured memory_bytes: 20608
#include<bits/stdc++.h>
#define int long long
using namespace std;
int N,T,dp[6100];
pair<int,int> A[3100];
signed main(){
  cin>>N>>T;
  for(int i=0;i<=T+3000;i++)dp[i]=0;
  for(int i=0;i<N;i++)cin>>A[i].first>>A[i].second;
  sort(A,A+N);
  for(int i=0;i<N;i++){
    for(int j=T-1;j>=0;j--)dp[j+A[i].first]=max(dp[j+A[i].first],dp[j]+A[i].second);
  }
  int ans=0;
  for(int i=0;i<=T+3000;i++)ans=max(ans,dp[i]);
  cout<<ans<<endl;
}

Measured memory_bytes: 3724
N=int(input())
L_s=input().split()
L=[int(x) for x in L_s]

c=0
while True:
      mx=max(L)
      if mx==0:
         break
      idx=L.index(mx)
      L[idx]-=1
      while True:
         try:
            if L[idx+1]==mx:
               L[idx+1]-=1
               idx+=1
            else:
               break
         except:
            break
      c+=1
print(c)


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int A, B, C;

int first_cnt(int mx){
  int cnt = 0;
  while (mx >= A+2){
    A += 2;
    cnt++;
  }
  while (mx >= B+2){
    B += 2;
    cnt++;
  }
  while (mx >= C+2){
    C += 2;
    cnt++;
  }
  return cnt;
}

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

  cin >> A >> B >> C;
  
  int mx = max(max(A, B), C);
  int ans = first_cnt(mx);
  int diff = mx - A + mx- B + mx - C;
  if (diff%2){
    ans += 2*diff;
  } else {
    ans += diff/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
  
  vector<vector<char>>date(H,vector<char>(W));

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>date.at(i).at(j);
    }
  }
  
  for(int i=0;i<W+2;i++){
    if(i<W+1){
      cout<<'#';
    }
    else{
      cout<<'#'<<endl;
    }
  }
    
  for(int i=0;i<H;i++){
    for(int j=0;j<W+2;j++){
if(j==0){
cout<<'#';
  
}
      else if(j==W+1){
        cout<<'#'<<endl;
      }

      else{
        cout<<date.at(i).at(j-1);
      }
    }
  }
     for(int i=0;i<W+2;i++){
    if(i<W+1){
      cout<<'#';
    }
    else{
      cout<<'#'<<endl;
    }
     }
}

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

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();

//==================================

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

    int k, q;
    cin >> k >> q;
    Vl d(k);
    for (int i = 0; i < k; i++) {
        cin >> d[i];
    }

    Vl m(q), x(q), n(q);
    for (int i = 0; i < q; i++) {
        cin >> n[i] >> x[i] >> m[i];
    }

    Vl dm(k);
    for (int i = 0; i < q; i++) {
        ll out = 0;
        for (int j = 0; j < k; j++) {
            dm[j] = d[j] % m[i];
        }
        for (int j = 0; j < k; j++) {
            if (dm[j] == 0) {
                if (j <= (n[i] - 1) % k - 1)
                    out += (n[i] - 1) / k + 1;
                else
                    out += (n[i] - 1) / k;
            }
        }
        ll a_last = x[i] % m[i];
        for (int j = 0; j < k; j++) {
            if (j <= (n[i] - 1) % k - 1)
                a_last += dm[j] * ((n[i] - 1) / k + 1);
            else
                a_last += dm[j] * ((n[i] - 1) / k);
        }
        out += a_last / m[i];
        cout << n[i] - 1 - out << "\n";
    }

    return 0;
}

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

#define INF INT_MAX

using namespace std;

int main(void){
	int n;
	vector<int> a(100100,0);
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> a[i];
	}
	vector<bool> memo(100100,false);
	int ans = 1;
	int cb = a[1];
	while(true){
		if(cb == 2){
			break;
		}else if(memo[cb]){
			ans = -1;
			break;
		}
		memo[cb] = true;
		cb = a[cb];
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define FORD(i,a,b) for(int i=(a);i>=b;i--)
#define FOR(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
using namespace std;
int main() {
	int a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b));
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 0;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for (int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for (int i = L; i != (int)R; --i)
#define IOS                                                                    \
    cin.tie(nullptr);                                                          \
    cout.tie(nullptr);                                                         \
    ios_base::sync_with_stdio(false);

bool ok(string &s, int L, int R)
{
    while (L <= R)
    {
        if (s[L] != s[R])
        {
            return false;
        }
        ++L;
        --R;
    }
    return true;
}

int main()
{
    IOS;
    string s;
    cin >> s;
    int sz = (int)s.size();
    if (ok(s, 0, sz - 1) && ok(s, 0, (sz - 1) / 2 - 1) &&
        ok(s, (sz + 3) / 2 - 1, sz - 1))
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	long double p1[2];
	long double p2[2];
	long double a,b;
	
	cin>>p1[0]>>p1[1]>>p2[0]>>p2[1];
	a=(p2[0]-p1[0])*(p2[0]-p1[0])+(p2[1]-p1[1])*(p2[1]-p1[1]);
	b=sqrt(a);
	
	cout<<fixed<<b<<endl;
}

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

int main() {
  int A, B;
  cin >> A >> B;

  const int s = A + B;
  if (s >= 10) {
    cout << "error";
  } else {
    cout << s;
  }
  cout << endl;
  return 0;
}


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

int main(){
    string S;
    cin >> S;
    int ca,cb,cc;
    ca = count(all(S),'a');
    cb = count(all(S),'b');
    cc = count(all(S),'c');

    bool ok=true;

    if(abs(ca-cb)>1) ok = false;
    if(abs(cb-cc)>1) ok = false;
    if(abs(cc-ca)>1) ok = false; 

    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;

} 


Measured memory_bytes: 512
#include<stdio.h>
long long int gcd(long long int a,long long int b)
{
	long long int t;
	do
	{
		t=a%b;
		a=b;
		b=t;
	}
	while(t!=0);
	return a;
}
int main()
{
	int n,i,k,l;
	long long int a,j;
	scanf("%d",&n);
	j=1;
	while(n--)
	{
		scanf("%lld",&a);
		j=a/gcd(a,j)*j;
	}
	printf("%lld\n",j);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 15 + 2;
const int MAXM = 1 << 15;

int n, m, ans = 0;
int f[MAXN][MAXM];
int sumv[MAXM];
int edg[MAXN][MAXN];


void init()
{
	for(int j = 0; j < (1 << n); j++)
		for(int x = 0; x < n; x++)
			if((j >> x) & 1)
				for(int y = x + 1; y < n; y++)
					if((j >> y) & 1)
						sumv[j] += edg[x][y];
}

void work()
{
	memset(f, -64, sizeof(f));
	f[0][1 << 0] = 0;
	for(int j = 0; j < (1 << n); j++)
		for(int i = 0; i < n; i++)
			if((j >> i) & 1)
				if(f[i][j] >= 0)
				{
					// cout << i << ' ' << j << ' ' << f[i][j] << endl;
					for(int x = 0; x < n; x++)
						if(~(j >> x) & 1)
							if(edg[i][x])
								f[x][j | (1 << x)] = max(f[x][j | (1 << x)], f[i][j] + edg[i][x]);
					int lef = ((1 << n) - 1) ^ j;
					for(int s = lef; s; s = (s - 1) & lef)
						f[i][j | s] = max(f[i][j | s], f[i][j] + sumv[(1 << i) | s]);
				}
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n >> m;
	for(int i = 1; i <= m; i++)
	{
		int x, y, z;
		cin >> x >> y >> z;
		x = x - 1, y = y - 1;
		edg[x][y] = edg[y][x] = z;
		ans += z;
	}
	init();
	work();

	// cout << ans << endl;
	ans = ans - f[n - 1][(1 << n) - 1];
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 2560