akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author HARSHAD
 */

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

#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

class AAtCoderCrackers {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n, k; in >> k >> n;
        vector<int> arr(n, 0);
        int i = 0;
        while(k--){
            arr[i]++;
            i = (i+1)%n;
        }
        out << *max_element(arr.begin(), arr.end()) - *min_element(arr.begin(), arr.end());
	}
};


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	AAtCoderCrackers solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g $PROGRAM -o $OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

vector<string> split(char d,string s)
{
	stringstream ss(s);
	string t;
	vector<string> words;
	while(getline(ss,t,d))
	{
		words.pb(t);
	}

	return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
	auto start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int a, b;
	int k;
	cin >> k >> a >> b;
	for (int i = a; i <= b;++i)
	{
		if(i%k==0)
		{
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";

#ifdef LOCAL
	auto end = chrono::high_resolution_clock::now();
	double time_taken =
		chrono::duration_cast<chrono::nanoseconds>(end - start).count();

	time_taken *= 1e-9;

	cerr << "\nTime taken by program is : " << fixed
		 << time_taken << setprecision(9);
	cerr << " sec" << endl;
#endif
	return 0;
}


Measured memory_bytes: 3644
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        int a = sc.nextInt();
        long sum = 0;
        for (int i = 0; i < a; i++) {
           sum += sc.nextInt();
        }

        System.out.println(sum >= h ? "Yes" : "No");
    }
}

Measured memory_bytes: 46488
#include<stdio.h>
int main() {
	long long int n,m, memo = 0;
	long long int a[100005] = {}, sum[100005] = {};
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		sum[i] =sum[i-1]+ a[i];
		memo += i;
	}

	if (sum[n]%memo != 0) { printf("NO"); return 0; }
	m = sum[n] / memo;
	for (int i = 2; i <= n; i++) {
		
		m -= a[i] - a[i - 1] - sum[n] / memo;
		if((a[i]-a[i-1]-sum[n]/memo)%n!=0|| (a[i] - a[i - 1] - sum[n] / memo)>0){ printf("NO"); return 0; }
	}
	if(m<0){ printf("NO"); return 0; }
	printf("YES");
}

Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
	int n,ans=0;
	
	cin >> n;
	
	vector<int> v(2*n);
	
	for(int i=0;i<2*n;i++){
		cin >> v[i];
	}
	
	sort(v.begin(),v.end());
	
	for(int i=0;i<n;i++){
		ans += v[2*i];
	}
	
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
A, B, C, X, Y = tuple(map(int, input().split(" ")))

half = 0
if C * 2 <= A:
    half = X * 2
if C * 2 <= B:
    half = max(Y * 2, half)
if C <= (A + B) // 2:
    half = max(half, min(X, Y) * 2)

cost = half * C
X -= half // 2
Y -= half // 2

if X > 0:
    cost += X * min(A, C * 2)
if Y > 0:
    cost += Y * min(B, C * 2)

print(cost)


Measured memory_bytes: 3064
//n個の区間がある。i(>=0)個目の区間は[a, b)で重さmである。
//ある点xについて、xを含むまたはxと接する区間が151以上になるならNG, ならないならOKと出力。
//考察：
//関係ない点を除く、座標圧縮をする、それだけ。
#include <iostream>
#include <set>
#include <map>
using namespace std;

int n;
int m[100], a[100], b[100];
int timer[2000];

void compress() {
	int i;
	set<int> comp;
	map<int, int> indComp;
	typedef pair<int, int> P;
	
	for (i = 0; i < n; i++) {
		comp.insert(a[i]);
		comp.insert(b[i]);
	}
	
	int ind = 0;
	for (set<int>::iterator it = comp.begin(); it != comp.end(); it++) {
		indComp.insert(P(*it, ind++) );
	}
	
	for (i = 0; i < n; i++) {
		a[i] = indComp[a[i]];
		b[i] = indComp[b[i]];
	}
}

bool in_solve_out() {
	int i;
	cin >> n;
	if (!n) {
		return false;
	}
	
	for (i = 0; i < n; i++) {
		cin >> m[i] >> a[i] >> b[i];
	}
	compress();
	
	for (i = 0; i < n; i++) {
		timer[a[i]] += m[i];
		timer[b[i]] -= m[i];
	}
	for (i = 1; i < 2*n + 10; i++) {
		timer[i] += timer[i-1];
	}
	
	for (i = 0; i < 2*n + 10; i++) {
		if (timer[i] > 150) {
			cout << "NG" << endl;
			return true;
		}
	}
	cout << "OK" << endl;
	return true;
}

void clear() {
	for (int i = 0; i < n*2 + 10; i++) {
		timer[i] = 0;
	}
};

signed main() {
	while (in_solve_out() ) {
		clear();
	}
	return 0;
}

Measured memory_bytes: 1208
N = int(input())
a = input().split(' ')
c = 0


def check(a):
    global c

    for i in a:
        if int(i) % 2 == 1:
            return
    for i in a:
        a[a.index(i)] = int(i)/2
        if int(i)/2 == 1:
            c += 1
            return
    c += 1
    check(a)


check(a)
print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cstdlib>
#include <climits>
#include <cmath>
using namespace std;
using Matrix = vector<vector<long long>>;

constexpr long long INF = INT_MAX; 

int main(){
    while(true){
        int n; cin >> n;
        if(n == 0) break;

        Matrix t(n, vector<long long>(n + 1));
        for(int i = 0; i < n; ++i)
            for(int j = 0; j < n + 1; ++j)
                cin >> t[i][j];

        Matrix dp((1 << n), vector<long long>(n, INF));
        // DP????????????????????????
        for(int bitset = 1, j = 0; bitset < (1 << n); bitset <<= 1, ++j) dp[bitset][j] = t[j][0];

        for(int bitset = 1; bitset < (1 << n); ++bitset){
            for(int current_stage = 0; current_stage < n; ++current_stage){
                if(dp[bitset][current_stage] == INF) continue;

                // ??????DP
                for(int next_stage = 0; next_stage < n; ++next_stage){
                    // ??¢?????°????????????????????????????????°continue
                    if((bitset >> next_stage) % 2 == 1) continue;

                    int next_bitset = bitset | (1 << next_stage);
                    // next_stage???????§??????????????????????????????£??????????£??????§???????°???????????????§????§???§?????????????????????
                    long long edge = t[next_stage][0]; // ?£????????????§????????¢????????????
                    for(int i = 1; i <= n; ++i){
                        // i??????????£????????????£?????????????????°continue
                        if((bitset >> (i-1)) % 2 == 0) continue;
                        edge = min(edge, t[next_stage][i]);
                    }
                    
                    long long next_t = dp[bitset][current_stage] + edge;
                    dp[next_bitset][next_stage] = min(dp[next_bitset][next_stage], next_t);
                }
            }
        }

        long long ans = INF;

        for(const auto& time : dp[(1 << n) - 1])
            ans = min(ans, time);

        cout << ans << endl;
    }

    return EXIT_SUCCESS;
}

Measured memory_bytes: 13588
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main(void){
    int n,q;cin>>n>>q;
    vector<int>V[n];
    int f,t;
    rep(i,n-1){
        cin>>f>>t;
        f--;t--;
        V[f].push_back(t);
        V[t].push_back(f);
    }
    vector<int>C(n,0);
    rep(i,q){
        cin>>f>>t;
        f--;
        C[f]+=t;
    }
    vector<bool>judge(n,true);
    queue<int>Q;Q.push(0);
    judge[0]=false;
    while(!Q.empty()){
        f=Q.front();Q.pop();
        rep(i,V[f].size()){
            t=V[f][i];
            if(!judge[t])continue;
            judge[t]=false;
            C[t]+=C[f];
            Q.push(t);
        }
    }
    rep(i,n){
        cout<<C[i]<<' ';
    }
        
}

Measured memory_bytes: 17904
N=int(input())
A,B=map(int,input().split())
P = list(map(int,input().split()))

P.sort()
cntA=0
cntB=0
cntC=0

for i in P:
    if i<= A:
        cntA += 1
    elif A+1<=i<=B:
        cntB += 1
    elif i>=B:
        cntC += 1

print(min(cntA,cntB,cntC))

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int n;
int a[100000 + 5];
int sum[100000 + 5];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n) {
        cin >> a[i];
    }
    sort(a, a + n);
    rep(i, n) {
        sum[i] = a[i] + sum[max(0LL, i - 1)];
        //cout << sum[i] << endl;
    }
    int ans = 1;
    rrep2(i, n - 2, -1) {
        if (2 * sum[i] < a[i + 1]) break;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <unordered_set>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

int k;
lin a[100001];

int main(void)
{
    scanf("%d", &k);
    rep(i, k)
    {
        scanf("%lld", &a[k - i - 1]);
    }

    lin mn = 2;
    lin mx = 2;

    rep(i, k)
    {
        int aa = a[i];
        lin seedMn = ((mn - 1) / aa + 1) * aa;
        lin seedMx = (mx / aa) * aa;

        if (seedMn > seedMx)
        {
            printf("-1");
            return 0;
        }

        mn = seedMn;
        mx = seedMx + aa - 1;
    }

    printf("%lld %lld", mn, mx);

    return 0;
}


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

int main() {
    int x;
    cin >> x;
    if (x >= 30)
    {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;
#define FOR(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

int main(){
  int n;
  const int max = 2*1e5;
  int p[max + 1];
  cin >> n;
  for(int i = 0; i < n; i++) cin >> p[i];

  const int INF = 1e9;
  int current_min = INF;
  int count;
  for(int i = 0; i < n; i++){
    if(p[i] < current_min) {
      count ++;
      current_min = p[i];
    }
  }
  cout << count << endl;

  return 0;
}

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

using LL = long long;
const LL M = 1e9 + 7;

LL power(LL n, LL m) {
  if(!m) return 1;
  if(m & 1) return n * power(n, m - 1) % M;
  return power(n * n % M, m >> 1);
}

int main() {
  int N, X, Y, Z;
  cin >> N >> X >> Y >> Z;

  int ALL = (1 << (X+Y+Z)) - 1;
  int OK = (1 << (Z-1)) | (1 << (Y+Z-1)) | (1 << (X+Y+Z-1));
  auto include = [](int bit, int sub) {return (bit & sub) == sub;};

  vector<vector<LL>> dp(N+1, vector<LL>(ALL+1));
  dp[0][0] = 1;

  for(int i = 0; i < N; ++i) {
    for(int bit = 0; bit <= ALL; ++bit) if(dp[i][bit]) {
      for(int j = 1; j <= 10; ++j) {
        auto nex = ((bit << j) | (1 << (j-1))) & ALL;
        if(include(nex, OK)) continue;
        dp[i+1][nex] += dp[i][bit];
        dp[i+1][nex] %= M;
      }
    }
  }

  cout << (power(10, N) - accumulate(begin(dp[N]), end(dp[N]), 0ll, [](LL sum, LL x) {return (sum + x) % M;}) + M) % M << endl;
}


Measured memory_bytes: 43392
#include <iostream>
#include <deque>
#define ll long long
using namespace std;

int main(){
  int n; cin>>n;
  deque<ll> v; ll a; cin>>a; v.push_back(a);
  
  int b=-1;
  for(int i=1;i<n;i++){
    cin>>a; b=b*(-1);
    if(b==1){v.push_front(a);}
    else{v.push_back(a);}
  }
  
  if(b==1){for(int i=0;i<n;i++){cout<<v[i]<<' ';}}
  else{for(int i=n-1;i>=0;i--){cout<<v[i]<<' ';}}
  
  return 0;
}

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

int main(){
  int K,S;
  cin>>K>>S;
  int count=0;
  for(int i=0;i<K+1;i++){
    for(int j=0;j<K+1;j++){
      if((S-i-j<=K)&&(S-i-j>=0)){
        count++;
      }
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	string s;
	cin >> s;
	int l = s.length();
	int cnt = 0;
	int ans = 0;
	rep(i, l) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			//cnt++;
			ans = max(ans, ++cnt);
		}
		else {
			//ans = max(ans, cnt);
			cnt = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = InputNumList();
            WriteLine(a.Sum() > 9 ? "error" : a.Sum().ToString());
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}



Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
int main() {
    int n, m;
    ll x[1000], y[1000], z[1000], q=0;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>z[i];
    }
    for(int i=0;i<8;i++){
        P p[1000];
        for(int j=0;j<n;j++){
            ll v=x[j]+y[j]+z[j];
            if(((i>>0)&1)==1){
                v-=x[j]*2;
            }
            if(((i>>1)&1)==1){
                v-=y[j]*2;
            }
            if(((i>>2)&1)==1){
                v-=z[j]*2;
            }
            p[j]=P(v, j);
        }
        
        sort(p, p+n, greater<P>());
        ll a=0, b=0, c=0;
        for(int j=0;j<m;j++){
            int k=p[j].second;
            a+=x[k];
            b+=y[k];
            c+=z[k];
        }
        q=max(q, abs(a)+abs(b)+abs(c));
        
    }
    cout<<q<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		boolean ans = false;
		int i = 0;
		int j = 0;
		if(x % 1000 == 0) {
			x = x / 1000;
			for(i = 0; i < n + 1; i++) {
				for(j = 0; j < n + 1 - i; j++) {
					if(x == i + j * 5 + (n - i - j) * 10) {
						ans = true;
						break;
					}
				}
				if(ans)
					break;
			}
		}
		if(ans) {
			System.out.println((n - i - j) + " " + j + " " + i);
		} else {
			System.out.println(-1 + " " + -1 + " " + -1);
		}
	}

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
int main(){
  string s; cin>>s;
  int n=0;
  rep(i,0,s.size()){
    n += s[i]-'0';
  }
  if(n%9==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define ll long long
#define lli long long int
#define endl "\n"
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dump(a) for (auto a: v) cout << a << " "
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define precision(x, y) cout << fixed << setprecision(y) << x << endl
#define PI 3.1415926535897932384626
#define MOD 1e9+7
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;

void solve() {
    int n, k;
    cin >> n >> k;

    vi prices(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> prices[i];
    }

    sort(prices.begin(), prices.end());

    int ans = 0;

    for (int i = 0; i < k; i++)
        ans += prices[i];
    cout << ans << endl;
}

int main() {
    fastio;
    // int t; cin >> t;
    // while (t--)
    solve();
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VLL a(n+1),b(n);
    REP(i,0,n+1) cin >> a[i];
    REP(i,0,n) cin >> b[i];
    LL ans = 0;
    REP(i,0,n) {
        if (b[i] >= a[i]) {
            ans += a[i];
            b[i] -= a[i];
            ans += min(b[i],a[i+1]);
            a[i+1] -= min(b[i],a[i+1]);
        } else {
            ans += b[i];
        }
    }
    cout << ans << endl;
}


int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    if(a == max({a, b, c})) cout << a*(1<<k) + b + c;
    else if(b == max({a, b, c})) cout << a + b*(1<<k) + c;
    else cout << a + b + c*(1<<k);
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N,x,flag,zero;
  cin >> N;
  flag = 0;
  zero = 0;
  long sum;
  sum = 0;
  vector<int> kari(N);
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> kari.at(i);
    if(kari.at(i) < 0){
      flag ++;
      kari.at(i) = 0 - kari.at(i);
    }
    if(kari.at(i) == 0){
      zero ++;
    }
    vec.at(i) = kari.at(i);
    sum += kari.at(i);
  }
  sort(vec.begin(),vec.end());
  if( flag % 2 == 1 && zero == 0){
     sum = sum - 2 * vec.at(0);
  }
  cout << sum << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int n,a,b,r=0,i,j;
	scanf("%d%d%d",&n,&a,&b);
	for(i=1;i<=n;i++)
	{
		int s=0;
		j=i;
		while(j>0)
		{
			s+=j%10;
			j/=10;
		}
		if(a<=s&&s<=b)
		{
			r+=i;
		}
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
        int n,i,f;
        char s[50];

        scanf("%d",&n);
        scanf("%s",s);
        f=0;

        for(i=0;i<n-2;i++){
                if(s[i]=='A'){
                        if(s[i+1]=='B'){
                                if(s[i+2]=='C'){
                                        f++;
                                }
                        }
                }
        }

        printf("%d",f);
        return 0;
}


Measured memory_bytes: 128
from collections import defaultdict
N = int(input())

fact = [1] * (10**3+1)
for i in range(2, 10**3+1):
    fact[i] = i * fact[i-1]

def nCr(n, r):
    return fact[n] // (fact[r] * fact[n-r])

class Sieve:
    """
    N以下の素数を列挙するエラトステネスのふるいです。
    O(NloglogN)でできます。

    Attributes
    sieveList : その数の素因数のうち最小のものの配列
    primes : N以下の素数のリスト
    """
    def __init__(self, N):
        self.sieveList = [-1 for _ in range(N+1)]
        self.sieveList[1] = 1
        self.primes = []

        for i in range(2, N+1):
            #すでに何らかの数で割られていたらcontinue
            if self.sieveList[i] != -1:
                continue
            self.primes.append(i)
            for j in range(i, N+1, i):
                if self.sieveList[j] != -1:
                    continue
                self.sieveList[j] = i

    def getPrimes(self):
        return self.primes

    def getSieveList(self):
        return self.sieveList

class FastFactorization(Sieve):
    """
    高速素因数分解です。
    与えられたL個の数がすべてA以下の時、
    エラトステネスでO(AloglogA)＋素因数分解でO(LlogA) = O(AloglogA+LlogA)でできます。
    「試し割り」をする必要が無いのではやいです。
    """

    def __init__(self, N):
        """
        前処理でスーパークラスのエラトステネスを使ってN以下の素因数を列挙します。
        """
        super().__init__(N)
        self.N = N
        self.sieveList = self.getSieveList()
        self.factorSet = None
        self.factorDict = None

    def factorize(self, x):
        if x > self.N:
            raise ValueError("与えられた数がエラトステネスのリストの上限を超えている")
        factorDict = defaultdict(int)
        while x > 1:
            divisor = self.sieveList[x]
            x //= divisor
            # factors += 1
            factorDict[divisor] += 1

        self.factorDict = factorDict

    def getFactorSet(self):
        return self.factorSet

    def getFactorDict(self):
        return self.factorDict


ff = FastFactorization(N+1)
ans = 0
for c in range(1, N):
    num = N - c
    # print(num, ff.factorize(num))
    tmp = 1
    if num == 1:
        ans += 1
    else:
        ff.factorize(num)
        factors = ff.getFactorDict()
        for v in factors.values():
            tmp *= nCr(2 + v - 1, v)
        ans += tmp

print(ans)


Measured memory_bytes: 147960
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define LD long double

LL MOD = 1000000007;

int main(void){
    int ans;
    for(int i = 1; i <= 5; ++i){
        int x;
        cin >> x;
        if(x != i){
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
import sys
import math

n = input()
a = map(int, raw_input().split())

for i in xrange(n) :
    tmp = a[i]
    a.pop(i)

    for j in xrange(i) :
        if a[j] > tmp :
            a.insert(j, tmp)
            break
    else :
        a.insert(i, tmp)

    for j in xrange(n) :
        sys.stdout.write(str(a[j]))
        if j < n-1 :
            sys.stdout.write(" ")

    print

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

typedef long long int ll;

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

    ll zero = 0, one = 0;
    for(ll i = 0;i < s.size();i++){
        if(s[i] == '0'){
            zero++;
        }
        else{
            one++;
        }
    }
    ll ans = min(zero, one) * 2;
    cout << ans;

    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void)
{
    int a,b;
    scanf("%d%d",&a,&b);
    int d,r;
    double f;
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %f.5\n",d,r,f);
    return 0;
}


Measured memory_bytes: 2736
n = int(input())
s = input()
can = []
for lead in range(n):
  now = 0
  try:
    if s[lead-1] == 'W' and s[lead] == 'W':
      now = can[-1] + 1
    elif s[lead-1] == 'W' and s[lead] == 'E':
      now = can[-1]
    elif s[lead-1] == 'E' and s[lead] == 'W':
      now = can[-1]
    else:
      now = can[-1] - 1
  except:
    #lead==0
    for i in range(1,n):
      if s[i] == 'E':
        now += 1
  can.append(now)
print(min(can))

Measured memory_bytes: 15520
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> cand(N, 1);
    rep(i, K) {
        int d;
        cin >> d;
        rep(i, d) {
            int a;
            cin >> a;
            --a;
            cand[a] = 0;
        }
    }
    int ans = 0;
    rep(i, N) ans += cand[i];
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3588
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 1010


int main(){
  int N;
  queue<int> que[SIZE];

  cin >> N;

  for (int i=0; i<N; i++) {
    for (int j=0; j<N-1; j++) {
      int a;
      scanf("%d", &a);
      que[i].push(a-1);
    }
  }

  queue<int> ok;

  for (int i=0; i<N; i++) {
    int to = que[i].front();
    if (que[to].front() == i) {
      ok.push(to);
    }
  }

  int ans= 0;
  while(ok.size()) {
    queue<int> ok2;

    while(ok.size()) {
      auto p = ok.front(); ok.pop();

      que[p].pop();
      if (que[p].empty()) continue;
      int to = que[p].front();
      if (que[to].front() == p) {
        ok2.push(to);
        ok2.push(p);
      }
    }

    swap(ok, ok2);
    ans++;
  }

  for (int i=0; i<N; i++) {
    if (!que[i].empty()) {
      puts("-1");
      return 0;
    }
  }

  printf("%d\n", ans);

  return 0;
}


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

using namespace std;

int lowbit(int x) { return x & -x; }

int N;
vector<pair<int, int>> edges;

int main() {
    scanf("%d", &N);
    if (N == lowbit(N)) {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    edges.emplace_back(1, 3);
    edges.emplace_back(3, 2);
    edges.emplace_back(1, N + 2);
    edges.emplace_back(N + 2, N + 3);
    edges.emplace_back(N + 3, N + 1);
    for (int i = 4; i < N; i += 2) {
        edges.emplace_back(1, i + 1);
        edges.emplace_back(i + 1, i);
        edges.emplace_back(1, N + i);
        edges.emplace_back(N + i, N + i + 1);
    }
    if (!(N & 1)) {
        int t = lowbit(N);
        edges.emplace_back(N + t, N);
        edges.emplace_back(N - t + 1, N + N);
    }
    for (const auto &i : edges) printf("%d %d\n", i.first, i.second);
}


Measured memory_bytes: 3952
#include <iostream>
#include <cstdio>

using namespace std;

int n;
int a[] = {3, 9, 2, 4, 8, 10, 6, 12};

int main()
{
    scanf("%d", &n);
    if(n == 3)
    {
        printf("2 5 63");
        return 0;
    }
    if(n % 2 == 1)
    {
        printf("30000 ");
        n--;
    }
    for(int i = 0; i < n; i++)
    {
        printf("%d ", a[i % 8] + i / 8 * 12);
    }
    return 0;
}


Measured memory_bytes: 384
import java.io.*;

class Dice {
	private int[] nums;
	public static final int DICEMAX = 6;
	public static final int[] E = { 1, 4, 6, 3 };
	public static final int[] N = { 1, 2, 6, 5 };
	public static final int[] S = { 1, 5, 6, 2 };
	public static final int[] W = { 1, 3, 6, 4 };
	public Dice( int nums[] ) {
		this.nums = new int[DICEMAX];
		for( int i=0; i<DICEMAX; i++ ) {
			this.nums[i] = nums[i];
		}
	}
	public int getDiceNum( int num ) {
		return this.nums[ num ];
	}
	public void rotate( char c ) {
		int tmp = 0;
		if( 'E' == c ) {
			tmp = this.nums[ E[0]-1 ];
			for( int i=0; i<3; i++ ) {
				this.nums[ E[i]-1 ] = this.nums[ E[i+1]-1 ];
			}
			this.nums[ E[3]-1 ] = tmp;
		} else if( 'N' == c ) {
			tmp = this.nums[ N[0]-1 ];
			for( int i=0; i<3; i++ ) {
				this.nums[ N[i]-1 ] = this.nums[ N[i+1]-1 ];
			}
			this.nums[ N[3]-1 ] = tmp;
		} else if( 'S' == c ) {
			tmp = this.nums[ S[0]-1 ];
			for( int i=0; i<3; i++ ) {
				this.nums[ S[i]-1 ] = this.nums[ S[i+1]-1 ];
			}
			this.nums[ S[3]-1 ] = tmp;
		} else {
			tmp = this.nums[ W[0]-1 ];
			for( int i=0; i<3; i++ ) {
				this.nums[ W[i]-1 ] = this.nums[ W[i+1]-1 ];
			}
			this.nums[ W[3]-1 ] = tmp;
		}
		return;
	}
	
}

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
			int[] nums = new int[ 6 ];
			int i;
			i = 0;
			for( String num:  kb.readLine().split( " " ) ) {
				nums[i++] = Integer.parseInt( num );
			}
			Dice dice = new Dice( nums );
			
			String ensw = kb.readLine();
			int len = ensw.length();
			for( i=0; i<len; i++ ) {
				dice.rotate( ensw.charAt( i ) );
			}
			System.out.println( dice.getDiceNum( 0 ) );

		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}

Measured memory_bytes: 17064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<bool>> graph;
vector<bool> reached;
ll MOD = 1000000007;

int main(){
    int N,M;
    cin >> N >> M;
    if(abs(N-M) >= 2){
        cout << 0 << endl;
        exit(0);
    }
    else{
        ll a=1,b=1;
        for(int i=N;i>1;i--){
            a = a*i%MOD;
        }
        for(int i=M;i>1;i--){
            b = b*i%MOD;
        }
        
        ll ans = a*b%MOD;
        if(abs(N-M) == 0){
            ans = ans*2%MOD;
        }    
        cout << ans << endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
int dp[1001][1001];
int main(){
      string s,t;
      int n;
      cin>>n;
      while(n--){
            cin>>s>>t;
            memset(dp,0,sizeof(dp));
            REP(i,s.size()){
                  REP(j,t.size()){
                        if(s[i]==t[j])dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
                        else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
                  }
            }
            cout<<dp[s.size()][t.size()]<<endl;
      }
}

Measured memory_bytes: 5124
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		System.out.println(Math.max(Math.max(A + B, A - B), A * B));
	}
}


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

int main()
{
    int n,x;
    vector<int> a;

    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>x;
        a.push_back(x);
    }

    sort(a.begin(),a.end());

    for(int i=0; i<(n-1); i++)
    {
        if(a[i] == a[i+1])
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }

    cout<<"YES"<<endl;

    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
    int a,b,f=0;
    cin>>a>>b;
    if(b==100)
    {
        int c=a*1000+b;
        int d=sqrt(c);
        if(d*d==c) f=1;
    }
    else if(b>=10)
    {
        int c=a*100+b;
        int d=sqrt(c);
        if(d*d==c) f=1;
    }
    else
    {
        int c=a*10+b;
        int d=sqrt(c);
        if(d*d==c) f=1;
    }
    //if(a>=10)
    //{
    //    int c=b*100+a;
    //    int d=sqrt(c);
    //    if(d*d==c) f=1;
    //}
    //else
    //{
    //    int c=b*10+a;
    //   int d=sqrt(c);
    //    if(d*d==c) f=1;
    //}

    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

typedef long long ll;

int main(){
    int N;
    cin>>N;
    vector<string> S(N);
    for (int i=0;i<N;i++){
        cin>>S.at(i);
    }

    ll cntM=0;
    ll cntA=0;
    ll cntR=0;
    ll cntC=0;
    ll cntH=0;

    for(int i=0;i<N;i++){
        if(S.at(i).at(0)=='M'){
            cntM++;
        }
        else if(S.at(i).at(0)=='A'){
            cntA++;
        }
        else if(S.at(i).at(0)=='R'){
            cntR++;
        }
        else if(S.at(i).at(0)=='C'){
            cntC++;
        }
        else if(S.at(i).at(0)=='H'){
            cntH++;
        }
    }

    ll ans;
    ans=cntM*cntA*cntR+cntM*cntA*cntC+cntM*cntA*cntH+cntM*cntR*cntC+cntM*cntR*cntH+cntM*cntC*cntH+cntA*cntR*cntC+cntA*cntR*cntH+cntA*cntC*cntH+cntR*cntC*cntH;
    cout<<ans<<endl;

}


Measured memory_bytes: 6144
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]


def f():
    if a == b:
        return True
    for i in range(n - m):
        for j in range(n - m):
            for k in range(m):
                if a[i + k][j:j + m] != b[k]:
                    break
            else:
                return True
    return False

print("Yes" if f() else "No")


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

int main() {
    double ma = -1, mi = 1e9;
    double d;
    while(cin >> d) {
        ma = max(ma, d);
        mi = min(mi, d);
    }
    cout << ma - mi << endl;
}


Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>

using namespace std;
int main() {
  int N;
  cin >> N;
  int L[N] = {0};
  for (int i=0; i<N; i++) {
    cin >> L[i];
  }
  std::sort(L, L + N);
  int c = 0;
  for (int i=0; i<N; i++) {
    for (int j=i+1; j<N; j++) {
      if (L[i] == L[j]) continue;
      for (int k=j+1; k<N; k++) {
        if (L[k] == L[j]) continue;
		if (L[k] < L[i] + L[j]) c++;
      }
    }
  }
  cout << c;
  return 0;
}

Measured memory_bytes: 3608
N, W = map(int, input().split())
w = []
v = []
for _ in range(N):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)
# print(w)
# print(v)

# print(wv)
dp = [[10 ** 12] * 100100 for _ in range(110)]
dp[0][0] = 0

for i in range(N):
    for sum_v in range(100100):

        if v[i] <= sum_v:
            dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v - v[i]] + w[i])

        dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v])
# print(dp[1][:100])
# print(dp[2][:100])


for sum_v in range(100100):
    if dp[N][sum_v] <= W:
        ans = sum_v
print(ans)


Measured memory_bytes: 121672
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
	fast;
	lli a;
	cin>>a;
	cout<<a+(a*a)+(a*a*a);
	
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include<time.h>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<Edge> >;//ll or Edge
using Edge=pair<int,ll>;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++14


struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
   ll n,m,k;cin>>n>>m>>k;
   UnionFind tree(n);
   vector<set<ll>> list(n);
   rep(i,m){
       ll a,b;cin>>a>>b;
       a--;b--;
        tree.merge(a,b);
        list[a].insert(b);
        list[b].insert(a);
   }
    rep(i,k){
        ll a,b;cin>>a>>b;
        a--;b--;
        if(tree.issame(a,b)){
            list[a].insert(b);
            list[b].insert(a);
        }
    }
    rep(i,n){
        cout<<tree.size(i)-list[i].size()-1<<" ";
    }

}

Measured memory_bytes: 26932
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int main(){
	
	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;

	s[k-1] += (32);

	cout<<s<<endl; 

	

	return 0;
}

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

int main(){
    int m,f,r;
    cin >> m >> f >> r;
    while(m != -1||f != -1||r != -1){
        if(m == -1||f == -1){
            cout << "F" << endl; 
        }
        else if(m+f >= 80){
            cout << "A" << endl;
        }
        else if(m+f >= 65){
            cout << "B" << endl; 
        }
        else if(m+f >= 50){
            cout << "C" << endl;
        }
        else if(m+f >= 30){
            if(r >= 50){
                cout << "C" << endl;
            }
            else{
                cout << "D" << endl;
            }
        }
        else {
            cout << "F" << endl;
        }
        cin >> m >> f >> r;
    }
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(LL i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e7 + 9;
const LL INF = 1e9;

void print_a(VI v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

VI v, d;
void prime()
{
    int n = sqrt(MX);
    int c, n1;
    v.PB(0); d.PB(1);
    loop(i,1,MX)
    {
        v.PB(i);
        d.PB(1);
        c = 0;
        while(v[i] % 2 == 0) {v[i]/=2; ++c;}
        d[i] *= (c+1);
    }

    for(int i = 3; i <= n; i += 2)
    {
        if(v[i] == i)
        {
            d[i] = 2; v[i] = 1;
            for(int j = i+i; j < MX; j += i)
            {
                c = 0;
                while(v[j] % i == 0) {v[j]/=i; ++c;}
                d[j] *= (c+1);
            }
        }
    }

    //for(int it : p) cout<<it<<'\n';
    //watch(p.size());

}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    prime();
    int n;
    cin>>n;
    LL ans = 1;

    loop(i,2,n+1)
    {
        if(v[i] != 1) d[i] *= 2;
        //watch(i); watch(d[i]);
        ans += (i * d[i]);
    }

    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n) cin>>a[i];
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n) cin>>a[i];
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 101796