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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,d,ans,memo[100001];
vector<int> a,b,c;

main() {
    cin >> n;
    rep(i,n) cin >> d,a.pb(d)
    rep(i,n) cin >> d,b.pb(d)
    rep(i,n) cin >> d,c.pb(d)
    sort(all(a));
    sort(all(b));
    sort(all(c));
    rep(i,n) {
        auto itr=upper_bound(all(c),b[i]);
        memo[n-i] = n-(int)(itr-c.begin());
    }
    rep1(i,n) memo[i] += memo[i-1];
    rep(i,n) {
        auto itr=upper_bound(all(b),a[i]);
        ans += memo[n-(int)(itr-b.begin())];
    }
    ct(ans)
}


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

int main() {
  string s;
  cin>>s;
  int n=s.size();
  string ans="AC";
  int big=0;
  for(int i=0;i<n;i++){
    if(i==0) {
      if(s[i]!='A') ans="WA";
    }
    else if(i==1 || i==n-1){
      if(s[i]-'a'<0 || s[i]-'a'>25) ans="WA";
    }
    else{
      if(s[i]-'a'<0 || s[i]-'a'>25){
        big++;
        if(s[i]!='C') ans="WA";
      }
    }
  }
  if(big!=1) ans="WA";
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
<?php
define("MOD", 10**9+7);
fscanf(STDIN, "%d%d", $N, $M);

for($j = 2; $j <= $M; $j++){
    if($M%$j == 0){
        @$map[$j]++;
        $M/=$j;
        $j--;
    }
}
$product = 1;
foreach($map as $prime => $count){
    $product *= nCm($count + $N - 1, $count);
    $product %= MOD;
}
echo $product;

//足し算
function addm($a, $b){
    return ($a + $b) % MOD;
}
//引き算
function subm($a, $b){
    return ($a + MOD - $b) % MOD;
}
//掛け算
function mulm($a, $b){
    return ($a * $b) % MOD;
}
//割り算
function divm($a, $b){
    return mulm($a, powerm($b, MOD - 2));
}
//累乗
function powerm($a, $b){
    if($b == 0)return 1;
    if($b & 1)return (powerm($a, $b>>1)**2 % MOD) * $a % MOD;
    return powerm($a, $b>>1)**2 % MOD;
}
//階乗
function factorialm($a){
    if($a == 0)return 1;
    if(!isset($memo[$a])){
        $memo[$a] = factorialm($a - 1) * $a % MOD;
    }
    return $memo[$a];
}
//順列
function nPm($n, $m){
    static $memo;
    if($m == 0)return 1;
    if(!isset($memo[$n][$m])){
        $memo[$n][$m] = nPm($n, $m - 1) * ($n - $m + 1) % MOD;
    }
    return $memo[$n][$m];
}
//組み合わせ
function nCm($n, $m){
    static $memo;
    if(!isset($memo[$n][$m])){
        $m = min($m, $n-$m);
        $memo[$n][$m] = divm(nPm($n, $m), factorialm($m));
    }
    return $memo[$n][$m];
}

Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
#include <stack>
#include <tuple>
#include <queue>
#include <functional>
#include <unordered_map>
#include <random>
#include <iomanip>
#include <cstdlib>

using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    int k;
    for (int i = 1; i <= n; i++) if (((i * (i + 1)) >> 1) >= n)
    {
        k = i;
        break;
    }
    for (int i = k; i > 0; i--)
    {
        if (n - i >= 0)
        {
            cout << i << endl;
            n -= i;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int a[N];
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int n,ma=0,mi,minn=1e9;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i],ma=max(a[i],ma);
    for(int i=1;i<=n;i++)
        if(abs(a[i]-ma/2)<minn&&a[i]!=ma)minn=abs(a[i]-ma/2),mi=a[i];
    cout<<ma<<" "<<mi;
    return 0 ;
}


Measured memory_bytes: 640
import java.util.*;
import java.io.*;
 
public class Main {
  public static void main(String[] args) throws Exception{
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    new Solution(n);
  }
}

class Solution {
  public Solution(int n) {
    boolean res = false;
    while(n > 0) {
      if(n % 10 == 7) res = true;
      n /= 10;
    }
    if(res) System.out.println("Yes");
    else System.out.println("No");
  }
}



class FastScanner {
  private final InputStream in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  public FastScanner(InputStream source) {
    in = source;
  }

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) return buffer[ptr++];
    else return -1;
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  public boolean hasNext() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) throw new NoSuchElementException();
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public long nextLong() {
    if (!hasNext()) throw new NoSuchElementException();
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public int nextInt() {
    long nl = nextLong();
    if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
      throw new NumberFormatException();
    return (int) nl;
  }

  public double nextDouble() {
    return Double.parseDouble(next());
  }
}

Measured memory_bytes: 32612
n = input().split()
X, LEN = list(map(int, n))

nn = input().split()
nums = list(map(int, nn))

# print(X, LEN, nums)

# 近似値の探索
pos = X
neg = X
result = X

while True:
    if (len(nums) <= 0):
        break
    if (not neg in nums):
        result = neg
        break
    if (not pos in nums):
        result = pos
        break
    neg -= 1
    pos += 1
print(result)

Measured memory_bytes: 9208
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <cstring>
#include <map>
#include <unordered_map>
#include <tuple>

using namespace std;

#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define umap unordered_map
#define uset unordered_set
#define cina(s, n, a) for(int quer = s; quer < n; quer++) cin >> a[quer]
#define couta(s, n, a) for(int quer = s; quer < n; quer++) cout << a[quer] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "YES\n" : "NO\n")
#define mod(a, b) (abs(b) + (a % abs(b))) % abs(b)
#define setp(x) fixed << setprecision(x)
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;

int a[4];

void solve(){
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++) a[i] = -1;
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        if(x == 1 && y == 0 && n > 1){
            cout << -1;
            return;
        }
        if(a[x] == -1) a[x] = y;
        else if(a[x] != y){
            cout << -1;
            return;
        }
    }
    for(int i = 1; i <= n; i++){
        if(a[i] == -1) cout << ((i == 1 && n > 1) ? 1 : 0);
        else cout << a[i];
    }
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for (int i = 1; i <= q; i++) {
        solve();
    }
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize,
        dv: [(usize, usize); n]
    };

    let mut c = 0;
    for (d1, d2) in dv {
        if d1 == d2 {
            c += 1;
        } else {
            c = 0;
        }
        if c == 3 {
            println!("Yes");
            return;
        }
    }
    println!("No");
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2240
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long[] l = new long[n + 1];
		l[0] = 2;
		l[1] = 1;
		int i = 0;
		for(i = 2; i <= n; i++) {
			l[i] = l[i - 1] + l[i - 2];
		}
		System.out.println(l[n]);
	}
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
	int N;
	cin>>N;

	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(j!=i+1)cout<<" ";
			for(int k=0;;k++){
				if((i>>k&1)!=(j>>k&1)){
					cout<<k+1;
					break;
				}
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    int bcnt = 0;

    ll ans = 0;

    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'B'){
            bcnt++;
        } else {
            ans += bcnt;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;


public class Main {
	public static void main(String args[])throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		var st = new StringTokenizer(br.readLine()); 
		int n = Integer.parseInt(st.nextToken()); 
		var dist = Long.parseLong(st.nextToken());
		dist *= dist;
		int counter = 0;
		for(var i = 0; i < n; ++i) {
			st = new StringTokenizer(br.readLine());
			var x = Long.parseLong(st.nextToken());
			var y = Long.parseLong(st.nextToken());
			if((x*x + y*y) <= dist) counter++;
		}	
		pw.println(counter);
		pw.close();
	}

}


Measured memory_bytes: 54072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (int r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
#define mp(a, b) make_pair(a, b)
int main(){
	ll n, d, a;
	cin>>n>>d>>a;
	vector<ll>pre(n, 0);
	vector<pair<ll,ll>>A(n);
	rep(i,0,n)cin>>A[i].first>>A[i].second;
	sort be(A);
	ll x=0, ANS=0;
	d<<=1;
	rep(i,0,n){
		A[i].second-=x;
		if(A[i].second>0){
			ll l=i, r=n-1, ans=i, need=(A[i].second+a-1)/a;
			ANS+=need;
			x+=need*a;
			while(r>=l){
				int m=l+(r-l)/2;
				if(A[i].first+d>=A[m].first){
					ans=m;
					l=m+1;
				}else{
					r=m-1;
				}
			}
			pre[ans]+=need*a;
		}
		x-=pre[i];
	}
	cout<<ANS<<"\n";
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long tmp;
  long long min = 1000000000;
  long long sum = 0;
  int nmin = 0;
  for(int i = 0; i<n; i++){
    cin >> tmp;
    if(tmp < 0) nmin++;
    tmp = abs(tmp);
    sum += tmp;
    if(min > tmp) min = tmp;
  }
  if(nmin%2==1) sum -= min * 2;
  cout << sum << "\n";
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
const long long inf = 1ll<<61;
const double eps = 0.000000000001;
typedef pair<int, int> P;
typedef pair<int ,P> PP;
struct edge { int to; int to2; int cost; };
int t[500];
signed main() {
	int n, l; cin >> n >> l;
	rep(i, n)t[i] = l + i;
	int sum = 0;
	rep(i, n)sum += t[i];
	int mn = inf;
	rep(i, n) {
		if (abs(mn) > abs(t[i]))mn = t[i];
	}
	cout << sum - mn << endl;
}

Measured memory_bytes: 256
max = 50021

primes = (2..Math.sqrt(max)).inject([*2..max]) do |nums, sieve|
  nums.reject { |num| num % sieve == 0 && num != sieve }
end

while line = gets
  n = line.chomp.to_i
  min = primes.take_while { |x| x < n }.max
  max = primes.sort { |a, b| b <=> a }.take_while { |x| x > n }.min
  puts "#{min} #{max}" 
end

Measured memory_bytes: 21468
N, X, Y = map(int, input().split())

ans = [0] * N
for i in range(1, N+1):
    for j in range(i+1, N+1):
        d1 = j-i
        d2 = abs(X-i) + 1 + abs(Y-j)
        d = d1 if d1 <= d2 else d2
        ans[d] += 1

for i in range(1,N):
    print(ans[i])


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];
ll B[100005];
pll C[100005];

int main()
{
    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> A[i] >> B[i];
        C[i] = pll(A[i], B[i]);
    }
    sort(C, C + N, [](pll a, pll b) { return a.first + a.second > b.first + b.second; });

    ll t = 0, a = 0;
    REP(i, N)
    {
        if (i % 2 == 0)
            t += C[i].first;
        else
            a += C[i].second;
    }
    cout << t - a << endl;
    return 0;
}

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

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0) val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator - () const noexcept {
return val ? MOD - val : 0;
}
constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
constexpr Fp& operator += (const Fp& r) noexcept {
val += r.val;
if (val >= MOD) val -= MOD;
return *this;
}
constexpr Fp& operator -= (const Fp& r) noexcept {
val -= r.val;
if (val < 0) val += MOD;
return *this;
}
constexpr Fp& operator *= (const Fp& r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp& operator /= (const Fp& r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
val = val * u % MOD;
if (val < 0) val += MOD;
return *this;
}
constexpr bool operator == (const Fp& r) const noexcept {
return this->val == r.val;
}
constexpr bool operator != (const Fp& r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0) return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

const int MAX_N = 100050;

vector<int> G[MAX_N];

struct DP{
    mint white;
    mint black;
    DP() : white(1),black(1){}
    DP &operator+=(const DP &other) {
        white *= other.white + other.black;
        black *= other.white;
        return *this;
    }
};

DP dfs(int v = 0, int p = -1) {
    DP dp;
    for(int nv : G[v]) {
        if(nv == p) continue;
        dp += dfs(nv,v);
    }
    return dp;
}

int main() {
int N;
cin >> N;
rep(i,N-1) {
    int x,y;
    cin >> x >> y;
    x--; y--;
    G[x].push_back(y);
    G[y].push_back(x);
}
cout << dfs(0).black + dfs(0).white << endl;
return 0;
}


Measured memory_bytes: 12672
#include<bits/stdc++.h>
#define int long long 
using namespace std;

int32_t main(){

	string s,t;
	cin>>s>>t;

	int a,b;
	cin>>a>>b;

	string check;
	cin>>check;
	if (check==s)
		cout<<a-1<<" "<<b;
	else
		cout<<a<<" "<<b-1;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,x,ans=0;
    cin>>a>>b>>c>>x; 
    for(int i=0;i<=a;i++)
    for(int j=0;j<=b;j++)
    for(int k=0;k<=c;k++)
    {
    	if(500*i+100*j+50*k==x) 
		{
			ans++;
		}
	}
    	cout<<ans;
    return 0;
} 

Measured memory_bytes: 256
N = int(input())
t, x, y = [0] * (N+1), [0] * (N+1), [0] * (N+1)


def main():
    for i in range(1, N + 1):
        t[i], x[i], y[i] = map(int, input().split())
    print("Yes" if detect() else "No")


def detect():
    for i in range(1, N+1):
        t_diff = t[i] - t[i-1]
        d_diff = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])
        if d_diff > t_diff or (t_diff - d_diff) % 2 != 0:
            return False
    return True


main()


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
long long five(long long p){
    long long now=p;
    rep(i,4)p*=now;

    return p;
}
int main(){
    long long x;
    cin>>x;

    for(long long  a=-1000;a<=1000;a++){
        for(long long  b=-1000;b<=1000;b++){
            if(five(a)-five(b)==x){
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }
    return 0;

}
/*


*/


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int N, M;
vector<vector<int>> g;
vector<vector<int>> ch;
int dp1[100005];
int dp2[100005];

int dfs1(int v, int p) {
    int ret = 1;
    FORE(w, g[v]) {
        if (w == p) continue;
        ch[v].push_back(w);
        ret *= dfs1(w, v) + 1;
        ret %= M;
    }
    return dp1[v] = ret;
}

void dfs2(int v, int prop) {
    // dump(v, prop);
    int tmp = 1;
    vector<int> left(SZ(ch[v])), right(SZ(ch[v]));
    REP(i, SZ(ch[v])) {
        int w = ch[v][i];
        tmp = (tmp * (dp1[w] + 1)) % M;
        left[i] = (i > 0 ? left[i - 1] : 1) * (dp1[w] + 1) % M;
    }
    dp2[v] = tmp * (prop + 1) % M;
    REPR(i, SZ(ch[v]) - 1) {
        int w = ch[v][i];
        right[i] = (i + 1 < SZ(ch[v]) ? right[i + 1] : 1) * (dp1[w] + 1) % M;
    }

    REP(i, SZ(ch[v])) {
        int w = ch[v][i];
        int L = (i > 0 ? left[i - 1] : 1);
        int R = (i + 1 < SZ(ch[v]) ? right[i + 1] : 1);
        // dump(L, R, prop + 1, w);
        int prop_next = L * R % M * (prop + 1) % M;
        dfs2(w, prop_next);
    }
}

signed main() {
    cin >> N >> M;
    g.resize(N);
    ch.resize(N);

    REP(i, N - 1) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    dfs1(0, -1);
    dfs2(0, 0);
    
    REP(v, N) {
        cout << dp2[v] << endl;
    }
    return (0^_^0);
}



Measured memory_bytes: 22400
from collections import defaultdict
N, M = map(int, input().split())
Ai = list(map(int, input().split()))

#---------------
d = defaultdict(int)
d[0] = 1
total = 0
for i in range(N):
    total = (total + Ai[i]) % M
    d[total] += 1
#-----------------
ans = 0
for k, c in d.items():
    if c > 1:
        ans += c * (c - 1) // 2
print(ans)

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

int main() {
  int N,K,i=0,h=0,x;
  
  cin >> N >> K;
  
  for (i=0;i<N;i++){
    cin >> x;
    if(2*x<K){
      h += 2*x;
    }
    else if(K>x){
      h += 2*(K-x);
    }
    else {
      h += 2*(x-K);
    }
  }
  cout << h << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	class Island
	{
		public List<int> Ships {get;set;}
		public int Distance {get;set;}
	}
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var n = p[0];
		var m = p[1];
		var islands = new Island[n];
		for(int i = 0; i < n; i++)
			islands[i] = new Island(){Ships=new List<int>(), Distance = int.MaxValue};
			
		for(int i = 0; i < m; i++)
		{
			p = Input().ToInt(-1);
			islands[p[1]].Ships.Add(p[0]);
			islands[p[0]].Ships.Add(p[1]);
		}
		
		DFS(0, islands, 0);
		if(islands[n-1].Distance == 2)
		{
			Console.WriteLine("POSSIBLE");
		}
		else
		{
			Console.WriteLine("IMPOSSIBLE");
		
		}
	}
	static void DFS(int index, Island[] islands, int deep)
	{
		if(deep > 3) return;
		if(islands[index].Distance <= deep)
			return;
		islands[index].Distance = deep;
		foreach(var k in islands[index].Ships)
		{
			DFS(k, islands, deep+1);
		}
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 43964
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(1000000)

# INF = float('inf')
INF = int(1e10)

def input():
    return stdin.readline()[:-1]

def main():
    from builtins import int, map
    L = int(input())
    print("{:.10f}".format((L / 3) ** 3))


if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
/*input

*/

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <math.h>
#include <iomanip>
#include <utility>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

ll MOD = 1000000007;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/*********************************START**********************************/
const int N = 100005;

int main()
{
  ifalse;
  ll n, k;
  cin >> n >> k;
  cout << (n - k + 1);
  return 0;
}

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

#define ll long long
#define tc(t) int t;cin >> t; while(t--)
#define pb push_back
#define fi first
#define se second
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll times = n / (a+b);
    ll ans = times * a;
    ll rem = n - times * (a+b);
    ans += min(a, rem);
    cout << ans ;
}

int main() {_
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
const int mod=1e9+7;

int main(){
	int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int l=0,r=0,sum=0,cnt=0,ans=0;
  char f='1';
  while(r<s.size()){
    if(s[r]==f){
    	sum++;
    	r++;
    }
    else if(f=='0'){
      f=s[r];
      sum++;
      r++;
    }
    else{
    	if(cnt<k){
    	  cnt++;
    	  f=s[r];
    	  sum++;
    	  r++;
	    }else{
      	ans=max(ans,sum);
      	f=s[r];
      	sum++;
      	r++;
      	int f2=s[l];
      	while(true){
      		sum--;
      		l++;
        	if(f2=='1')
        		f2=s[l];
        	else if(s[l]=='1')
          	break;
      	}
      }
    }
  }
  ans=max(ans,sum);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
/* basic header */
#include <bits/stdc++.h>
/* define */
#define ll long long
#define pb emplace_back
#define mp make_pair
#define eps 1e-8
#define lson (curpos<<1)
#define rson (curpos<<1|1)
/* namespace */
using namespace std;
/* header end */

const ll mod = 1e9 + 7;
ll n, a, b;

ll qp(ll x, ll b) {
    ll ret = 1, base = x;
    while (b) {
        if (b & 1) ret = ret * base % mod;
        base = base * base % mod;
        b >>= 1;
    }
    return ret;
}

ll C(ll n, ll m) {
    if (!m) return 1LL;
    if (m == 1) return n;
    ll ret = 1, maxx = max(m, (n - m)), minn = min(m, (n - m));
    for (ll i = n; i > maxx; i--) ret = ret * i % mod;
    for (ll i = minn; i >= 1; i--) {
        ll currInv = qp(i, mod - 2);
        ret = ret * currInv % mod;
    }
    return ret;
}

int main() {
    cin >> n >> a >> b;
    ll total = (qp(2, n) % mod - 1 % mod + mod) % mod;
    ll c1 = C(n, a) % mod, c2 = C(n, b) % mod;
    ll ans = ((total - c1 + mod) % mod - c2 + mod) % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

int main() {
    int a,b; cin>>a>>b;
    cout << max(0, a-b-b) << endl;

    return 0;
}


Measured memory_bytes: 256
n = gets().to_i
#sn = []

h = {}
ans = 0

n.times{|i|
	si = gets().chomp.split("").sort.join("")
	if h.has_key?(si)
		ans += h[si]
		h[si] += 1
	else
		h[si] = 1
	end
}

puts ans


Measured memory_bytes: 18460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, k, a[102] = {}, z = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i], z += min(a[i], k - a[i]);
    cout << z + z;
}


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

inline void init(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

int h, w, ch, cw, dh, dw;
const int N = 1e3+5, INF = 1e7;
int lvl[N][N];
string grid[N];
queue<pair<int, int>> q1;
queue<pair<int, int>> q2;

bool valid(int i, int j){
	return (i >= 0) && (j >= 0) && (i < h) && (j < w) && (lvl[i][j] > INF) && grid[i][j] == '.';
}

void bfs() {
	while(!q1.empty()){
		pair<int, int> p = q1.front();
		q2.push(p);
		q1.pop();
		int i, j;
		i = p.first + 1, j = p.second;
		if(valid(i, j)){
			q1.push({i, j});
			q2.push({i, j});
			lvl[i][j] = lvl[p.first][p.second];
		}
		i = p.first - 1, j = p.second;
		if(valid(i, j)){
			q1.push({i, j});
			q2.push({i, j});
			lvl[i][j] = lvl[p.first][p.second];
		}
		i = p.first, j = p.second + 1;
		if(valid(i, j)){
			q1.push({i, j});
			q2.push({i, j});
			lvl[i][j] = lvl[p.first][p.second];
		}
		i = p.first, j = p.second - 1;
		if(valid(i, j)){
			q1.push({i, j});
			q2.push({i, j});
			lvl[i][j] = lvl[p.first][p.second];
		}
	}
	while(!q2.empty()){
		pair<int, int> p = q2.front();
		q2.pop();
		for(int i = p.first - 2; i <= p.first + 2; ++i){
			for(int j = p.second - 2; j <= p.second + 2; ++j){
				if(valid(i,j)){
					q1.push({i, j});
					lvl[i][j] = lvl[p.first][p.second]+1;
				}
			}
		}
	}
}

int main() {
	init();
	memset(lvl, '?', sizeof(int) * N * N);
	cin >> h >> w >> ch >> cw >> dh >> dw;
	--ch, --cw, --dh, --dw;
	for(int i = 0; i < h; ++i)
		cin >> grid[i];
	lvl[ch][cw] = 0;
	q1.push({ch, cw});
	while(!q1.empty()){
		bfs();
	}
	if(lvl[dh][dw] < INF)
		cout << lvl[dh][dw];
	else
		cout << -1;
	return 0;
}


Measured memory_bytes: 8804
n, k = map(int, input().split())
s = list(input())

# 連続で0か1が連なっているリストを作成
# (0or1, 個数)
sum_s = []
cnt = 0
flag = int(s[0])
if flag == 0:
    sum_s.append((1, 0))
flag = int(s[0])
for i in range(n):
    if s[i] == '0':
        if flag == 0:
            cnt += 1
        else:
            sum_s.append((flag, cnt))
            flag, cnt = 0, 1
    else:
        if flag == 0:
            sum_s.append((flag, cnt))
            flag, cnt = 1, 1
        else:
            cnt += 1
sum_s.append((flag, cnt))
#print(sum_s)

# 累積和
rs = [0] * (len(sum_s)+1)
for i in range(1, len(sum_s)+1):
    rs[i] = rs[i-1] + sum_s[i-1][1]

ans = 0

#print(rs)
length = 2*k+1
for i in range(0, len(sum_s)+1, 2):
    ans = max(ans, rs[min(i+length, len(sum_s))] - rs[i])
    #print(ans, min(i+length, len(sum_s)), i)
print(ans)

Measured memory_bytes: 15012
#include<iostream>
#include<cmath>

using namespace std;

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

    cin>>x>>a>>b;

    int A,B;

    A=abs(x-a);
    B=abs(x-b);


    if(A<B) cout<<"A"<<endl;

    else cout<<"B"<<endl;




    return 0;
}


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

int main() {
  int x;
  cin >> x;
  int a = x % 500;
  
  if (x % 5 == 0 ) {
    cout << x / 500 * 1000 + x % 500 << endl;
  }
  
  else if (x % 5 != 0) {
    cout << x / 500 * 1000 + x % 500 / 5 * 5 << endl; 
  }
}

Measured memory_bytes: 256
# coding: utf-8


def solve(*args: str) -> str:
    a, b, m = map(int, args[0].split())
    A = list(map(int, args[1].split()))
    B = list(map(int, args[2].split()))

    XYC = {}
    for x, y, c in map(str.split, args[3:]):
        key = (int(x)-1, int(y)-1)
        XYC[key] = max(XYC.get(key, 0), int(c))

    ret = min(A)+min(B)
    for (x, y), c in XYC.items():
        ret = min(ret, A[x]+B[y]-c)

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 48516
def combination(n, k, mod=10**9+7):
    numer = denom = 1
    for i in range(k):
        numer = (numer * (n-i)) % mod
        denom = (denom * (i+1)) % mod
    return (numer * pow(denom, mod-2, mod)) % mod


X, Y = map(int, input().split())

if (X + Y) % 3 == 0:
    a = (2*Y-X) // 3
    b = (2*X-Y) // 3

    if a >= 0 and b >= 0:
        print(combination(a+b, a))
        exit()
print(0)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	if(a + b > c + d) {
		printf("Left\n");
	}else if (a + b == c + d) {
		printf("Balanced\n");
	}else{
		printf("Right\n");
	}
	return 0;
}

Measured memory_bytes: 256
import numpy as np

N = input()
K = int(input())

dp = np.zeros((len(N)+1, K+1), np.int64)
dp[1, 1] = 1
for d in range(1, len(N)):
    dp[d+1] = dp[d]
    dp[d+1, 1:] += dp[d, :-1]

ans = 0
for i, c in enumerate(N):
    n = len(N)-i
    if c != '0':
        ans += np.sum(dp[:n, K]) * (9 ** K)
        ans += dp[n, K] * (int(c) - 1) * (9 ** (K-1))
        K -= 1
        if K == 0:
            ans += 1
            break

print(ans)

Measured memory_bytes: 21504
;;; Utils

(defmacro read-numbers-to-list ()
  `(read-from-string
    (concatenate 'string "(" (read-line) ")")))


(defmacro read-line-to-array (dimension)
  (if (< dimension 0)
      (error "invalid arguments for dimension.")
      `(make-array ,dimension :initial-contents (read-numbers-to-list))))

(defmacro read-line-to--char-list ()
  `(concatenate 'list (read-line)))

(defmethod make-cumlative-sum ((sequence list))
  (labels ((inner (sequence &optional (acc '(0)))
             (if (null sequence)
                 (reverse acc)
                 (inner (rest sequence) (cons (+ (first sequence)
                                                 (first acc))
                                              acc)))))
    (inner sequence)))





(defmethod princ-for-each-line ((sequence list))
  (labels ((inner (sequence)
             (if (null sequence)
                 nil
                 (progn
                   (fresh-line)
                   (princ (first sequence))
                   (inner (rest sequence))))))
    (inner sequence)))

(defmethod princ-for-each-line ((sequence array))
  (dotimes (i (length sequence))
    (fresh-line)
    (princ (aref sequence i))))



;;; Write code here

(defparameter *mod* (+ (expt 10 9) 7))

(defun sum (xs)
  (declare (list xs))
  (reduce #'+ xs))


(defun solve (xs)
  (declare (list xs))
  (mod (floor (- (* (sum xs)
                    (sum xs))
                 (sum (mapcar (lambda (x)
                                (* x x))
                              xs)))
              2)
       *mod*))

(defun main ()
  (let ((n (read))
        (xs (read-numbers-to-list)))
    (format t "~a~%" (solve xs))))

(main)


Measured memory_bytes: 69824
N = int(input())
a = list(map(int, input().split()))

x = a[0]
y = sum(a[1:])
ans = abs(x - y)

for i in range(1, N - 1):
    x += a[i]
    y -= a[i]
    ans = min(abs(x - y), ans)

print(ans)


Measured memory_bytes: 24832
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    float m;
    cin >> n;
  	if (n==1){
    	cout << 1;
    }
  	else if(n%2==1){
    	m =	(((n-1.0)/2.0)+1.0)/n;
      cout << m;
    }
  	else{
      	cout << 0.5;
    }
  	
    
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
     ll n;
    cin >> n;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    ll m = n;
    vector <ll> sosuu;
    for(ll i = 2;i*i <= m;i++){
        ll cnt = 0;
        while(m%i == 0){
            m /= i;
            cnt++;
        }
        if(cnt != 0)
            sosuu.pb(cnt);
    }
    ll res = 0;
    if(m > 1)
        res++;


    for(int i = 0;i < sosuu.size();i++){
        int r = 1;
        while(sosuu[i] >=0){
            sosuu[i] -= r;
            r++;
        }
            res += (r-2);

    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<cmath>
#include<string>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define INF (int)1e5+5
#define nax (int)1e6+3
#define eps (double)1e-9
#define all(x) x.begin(),x.end()
#define MAX_N (int)1e6+2
#define int long long
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pdbs;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
//void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

// look for  all edge cases
//search for a pattern




	
signed main(){
	fast;

	int n;
	cin >> n;
	cout<< n + n*n + n*n*n;

	return 0;
	
}

	



Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>

using namespace std;

bool fun2(int X, int Y)
{
	int i, j;
	for (i = 0; i <= X; i++)
	{
		j = X - i;
		if (i * 2 + j * 4 == Y)
			return true;
	}
	return false;
}

void Sol2()
{
	int X, Y;
	cin >> X >> Y;
	vector<int>  dp(101,1);

	//bool ret = fun(X, Y,dp);
	bool ret = fun2(X, Y);

	if (ret)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main()
{
    #define endl '\n'
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(0);
    //Sol1();
    Sol2();
    //Sol3();
    //Sol4();
    //Sol5();
    //Sol6();
    //cin.get();
}


Measured memory_bytes: 3128
n = int(input())
vi = list(map(int, input().split()))
vi = sorted(vi)
for i in range(n-1):
  new = (vi[0]+vi[1]) / 2
  vi.append(new)
  vi.remove(vi[0])
  vi.remove(vi[0])
  vi = sorted(vi)
print(vi[0])
  


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

int main() {
    int i, j, h, w, c;
    cin >> h >> w;
    char s[h+1][w+1]={};

    for (j=1; j<h+1; j++) {
        for (i=1; i<w+1; i++) {
            cin >> s[j][i];
        }
    }

    for (j=1; j<h+1; j++) {
        for (i=1; i<w+1; i++) {
            if (s[j][i] == '.') {
                c=0;
                if (s[j-1][i-1]=='#') c++;
                if (s[j-1][i]=='#') c++;
                if (s[j-1][i+1]=='#') c++;
                if (s[j+1][i-1]=='#') c++;
                if (s[j+1][i]=='#') c++;
                if (s[j+1][i+1]=='#') c++;
                if (s[j][i-1]=='#') c++;
                if (s[j][i+1]=='#') c++;
                cout << c;
            } else {
                cout << '#';
            }
        }
        cout << endl;
    }
    cout << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;

#define __int64 long long
#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;

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

    int mind = -1;
    int maxd = n;

    int l, r;
    rep(i, m){
        cin >> l >> r;
        mind = max(mind, l);
        maxd = min(maxd, r);
    }

    cout << max(0, maxd - mind + 1) << endl;
}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...)
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second

struct segment_tree_min
{
    int n;
    vector<pair<int, int>> a;

    segment_tree_min(int n) : n(n), a(2 * n, make_pair(n-2, n-2)) {}

    pair<int, int> merge(pair<int, int> a, pair<int, int> b)
    {
    	vector<int> v = { a.F, a.S, b.F, b.S };
    	sort(v.begin(), v.end());
    	return { v[0], v[1] };
    }

    void update(int p, pair<int, int> v)
    {
        for (a[p += n] = v; p /= 2;)
            a[p] = merge(a[2 * p], a[2 * p + 1]);
    }

    pair<int, int> query(int l, int r)
    {
        pair<int, int> g = { n-2, n-2 };

        for (l += n, r += n; l < r; l /= 2, r /= 2)
        {
            if (l & 1) g = merge(g, a[l++]);
            if (r & 1) g = merge(g, a[--r]);
        }

        return g;
    }
};

struct segment_tree_max
{
    int n;
    vector<pair<int, int>> a;

    segment_tree_max(int n) : n(n), a(2 * n, make_pair(-1, -1)) {}

    pair<int, int> merge(pair<int, int> a, pair<int, int> b)
    {
    	vector<int> v = { a.F, a.S, b.F, b.S };
    	sort(v.begin(), v.end());
    	return { v[3], v[2] };
    }

    void update(int p, pair<int, int> v)
    {
        for (a[p += n] = v; p /= 2;)
            a[p] = merge(a[2 * p], a[2 * p + 1]);
    }

    pair<int, int> query(int l, int r)
    {
        pair<int, int> g = { -1, -1 };

        for (l += n, r += n; l < r; l /= 2, r /= 2)
        {
            if (l & 1) g = merge(g, a[l++]);
            if (r & 1) g = merge(g, a[--r]);
        }

        return g;
    }
};

int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	vector<int> x(n);
	for (auto &i : x) cin >> i;

	vector<pair<int, int>> nxt(n), prv(n);

	segment_tree_max stmax(n+2);
	for (int i = 0; i < n; ++i)
	{
		prv[i] = stmax.query(x[i]+1, n+1);
		stmax.update(x[i], make_pair(i, -1));
	}

	segment_tree_min stmin(n+2);
	for (int i = n-1; i >= 0; --i)
	{
		nxt[i] = stmin.query(x[i]+1, n+1);
		stmin.update(x[i], make_pair(i, n));
	}

	debug(x)
	debug(prv)
	debug(nxt)

	ll ans = 0;
	for (int i = 0; i < n; ++i)
	{
		int a = prv[i].F;
		int b = nxt[i].F;

		if (a != -1)
		{
			ans += (ll)(b - i) * (a - prv[i].S) * x[i];
		}

		if (b != n)
		{
			ans += (ll)(i - a) * (nxt[i].S - b) * x[i];
		}

		debug(i, ans)
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 5376
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cerr<<endl; 
	}
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int a;
		cin>>a;
		double b;
		cin>>b;
		ll int ans = a*(ll int)(100*b+0.5)/100;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3732