akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
ll digits(ll x){
  ll length = 0;
  while (x > 0){
    x /= 10;
    length++;
  }
  return length;
  if (x == 0) return 0;
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);
  ll ans;
  //string ans;

  ans = 6;
  int a, b; cin >> a >> b;
  ans -= a + b;

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

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

template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }

  ll x = 1;

  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

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

  ll n;

  std::cin>>n;

  std::vector<ll> temp(n,-1);

  ll side;

  rep(i,0,n+1){
    ll a;
    std::cin>>a;
    a--;
    if(temp[a]>=0){
      side=temp[a]+(n-i);
      break;
    }
    temp[a]=i;
  }

  std::vector<ll> conv(n+2),conv_side(side+1);
  conv[0]=1;conv_side[0]=1;

  rep(i,1,n+2){
    conv[i]=(((conv[i-1]*(n+2-i))%MOD)*pow_mod(i,MOD-2,MOD))%MOD;
  }

  rep(i,1,side+1){
    conv_side[i]=(((conv_side[i-1]*(side+1-i))%MOD)*pow_mod(i,MOD-2,MOD))%MOD;
  }

  rep(i,1,n+2){
    if(i-1<=side)std::cout<<(conv[i]-conv_side[i-1]+MOD)%MOD<<"\n";
    else std::cout<<conv[i]<<"\n";
  }

  return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ul unsigned long long int
#define vi vector<int>
#define vl vector<int64_t>
#define all(x) x.begin(),x.end()
#define pb push_back
#define fo(x,a,b) for(int x=a; x<b; x++)
#define rfo(x,a,b) for(int x=a; x>=b; x--)
#define fi first
#define sec second
#define mp make_pair
int sgn(int x) { return x>0 ? 1 : ( x<0 ? -1 : 0); }
typedef pair<int,int> pairs;
double pi = 3.14159265358979323846;
ll mod = 1000000007;
void solve()
{
    string s = "ACL";
    int k;
    cin>>k;
    fo(i,0,k) cout<<s;
    cout<<"\n";
    return;
}
int main()
{
#ifdef _DEBUG
    freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t;
    //cin>>t;
    //while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3616
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll x;
    cin >> x;
    ll a = 2;
    while (true) {
        if (a / 2 * 6 + a / 2 * 5 >= x) {
            break;
        }
        a *= 2;
    }
    ll ok = 0;
    ll ng = a;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        ll s;
        ll b = a - mid;
        if (mid % 2) {
            s = (b / 2 + 1) * 6 + b / 2 * 5;
        } else {
            s = b / 2 * 6 + b / 2 * 5;
        }
        if (s >= x) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << a - ok << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    set<int> st{111, 222, 333, 444, 555, 666, 777, 888, 999};
    for(auto x : st){
        if(x-n>=0){
            cout << x << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int read() {
	int x=0, f=1; char ch=' ';
	while(!isdigit(ch)) {ch=getchar(); if(ch=='-') f=-1;}
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48), ch=getchar();
	return x*f;
}
ll a[200005], b[200005], n, m, k, ans;
int main() {
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++) a[i]=a[i-1]+read();
	for(int i=1;i<=m;i++) b[i]=b[i-1]+read();
	ll now=0;
	while(b[now]<=k&&now<=m) now++;
	now--;
	ans=now;
	for(int i=1;i<=n;i++) {
		if(a[i]>k) break;
		while(a[i]+b[now]>k) now--;
		ans=max(ans, i+now);
	}
	cout<<ans;
}


Measured memory_bytes: 6716
from queue import Queue
from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())

S = []
for _ in range(H):
    S.append(list(input()))

path = dict()
cache = set()

Score = [[-1 for _ in range(W)] for __ in range(H)]

Cur = (Cw-1, Ch-1)
Q = deque()
Q.appendleft(Cur)
Score[Cur[1]][Cur[0]] = 0

# path[Cur] = 0
G = (Dw-1, Dh-1)

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

wdx = []
wdy = []

while not len(Q) == 0:

    node = Q.popleft()
    cx, cy = node

    # move
    for di in range(4):
        nx = cx + dx[di]
        ny = cy + dy[di]

        if W > nx >= 0 and H > ny >= 0 and S[ny][nx] == '.' and (Score[ny][nx] == -1 or Score[ny][nx] > Score[cy][cx]):
            nt = (nx, ny)
            Q.appendleft(nt)
            Score[ny][nx] = Score[cy][cx]
    
    # warp
    for wdx in range(-2, 3, 1):
        for wdy in range(-2, 3, 1):
            if wdx == wdy == 0:
                continue

            nx = cx + wdx
            ny = cy + wdy
            nt = (nx, ny)

            if W > nx >= 0 and H > ny >= 0 and S[ny][nx] == '.' and (Score[ny][nx] == -1 or Score[ny][nx] > Score[cy][cx] + 1):
                nt = (nx, ny)
                Q.append(nt)
                Score[ny][nx] = Score[cy][cx] + 1

print(Score[G[1]][G[0]])

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

int main()
{
	int n,m;
	cin >> n >> m;
	if(n >= m)
	{
		cout << 0; 
		return 0;
	}
	vector<int> a(m);
	for(int i=0;i<m;++i)
		cin >> a[i];
	sort(a.begin(),a.end());	
	vector<int> d(m);
	for(int i=0;i<m-1;++i)
	{
		d[i] = a[i+1] - a[i];
	}
	
	sort(d.rbegin(),d.rend());
	int ans = a[m-1] - a[0];
	for(int i=0;i<n-1;++i)
	{
		ans -= d[i];
	}
	
	cout << ans;
}


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

int main()
{
	int inputA, inputB, inputC;

	scanf("%d""%d""%d", &inputA, &inputB, &inputC);

	if (inputA == inputB && inputB == inputC)
	{
		printf("No \n");
	}
	else if (inputA == inputB || inputA == inputC)
	{
		printf("Yes \n");
	}
	else if (inputB == inputA || inputB == inputC)
	{
		printf("Yes \n");
	}
	else
	{
		printf("No \n");
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

int bit[200009];
void update(int a,int k,int N)
{
  for (;a <= N; a += a&-a)
  {
    bit[a] = max(bit[a],k);
  } 
}
int query(int a){
  int res = 0;
  for (; a > 0; a -= a& -a)
  {
    res = max(res,bit[a]);
  }
  return res;
  
}

void solve(void)
{
  int N;cin>>N;
  vector<int> H (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>H[i];
  }
  vector<int> A (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>A[i];
  }
  for (int i = 0; i < N; i++)
  {
    update(H[i],query(H[i]) + A[i],N);
  }
  cout<<query(N)<<endl;
  

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v) reverse(v.begin(),v.end())
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

#define P pair<int,int>
#define Pll pair<ll,ll>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

struct UnionFind{
	vector<int> par; //データiが属する親の番号
	vector<int> sizes; //根ノードiの木に含まれるデータの数

	// 最初は全てのデータiがグループiに存在するものとして初期化
	UnionFind(int n):par(n),sizes(n, 1){
		REP(i,n) par[i] = i;
	}

	// 根を張り替えながら再帰的に根ノードを探す
	int find(int x){
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}

	// 2つのデータx, yが属する木をマージする
	void unite(int x, int y) {
		// データの根ノードを得る
		x = find(x);
		y = find(y);

		// 既に同じ木に属しているならマージしない
		if (x == y) return;

		// xの木がyの木より大きくなるようにする
		if (sizes[x] < sizes[y]) swap(x, y);

		// xがyの親になるように連結する
		par[y] = x;
		sizes[x] += sizes[y];
		sizes[y] = 0;  // sizes[y]は無意味な値となるため
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// データxが含まれる木の大きさを返す
	int size(int x) {
		return sizes[find(x)];
	}
};
int gcd(int n,int m){
	if(m>n) return gcd(m,n);
	if(m==0) return n;
	else return gcd(m,n%m); 
}

int main(void){
	int A,B;
	cin>>A>>B;
	if(A<=5) print(0);
	else if(A<=12) print(B/2);
	else print(B);
	return 0;
}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
    
using namespace std;

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

int gcd(int a, int b){
    if(a<b) swap(a, b);

    int r=a%b;
    if(r==0){
        return b;
    }
    else{
        return gcd(b, r);
    }
}

int32_t main(){
    int n;
    cin >> n;
    vector<int> v(n);
    REP(i, n) cin >> v[i];
    SORT(v);
    
    int ans=v[0];
    FOR(i, 1, n){
        ans=ans/gcd(ans, v[i])*v[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second

using namespace std;

int main(){
	DRI(n);
	VI a(n);
	map<int,int> d;
	REP(i,n) {
		RI(a[i]);
	}
	int nbp=0;
	sort(a.rbegin(),a.rend());
	REP(i,n) {
		bool ndone=false;
		LL j=(LL)1<<31;
		while (j>a[i]){
			if (d.find(j-a[i])!=d.end()){
				nbp++;
			//	cout<<a[i]<<" "<<j-a[i]<<endl;
				d[j-a[i]]--;
				if (!d[j-a[i]]) d.erase(j-a[i]);
				ndone=true;
				break;
			}
			j>>=1;
		}
		if (not ndone) d[a[i]]++;
	}
	printf("%d\n",nbp);
}


Measured memory_bytes: 10368
import random
def is_prime(q,k=50):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True
X = int(input())
for i in range(X, 100004):
    if is_prime(i):
        print(i)
        break


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

using namespace std;

set<string> answer;

void solve(int J, int Y, int j = 0, int y = 0, string s = "") {
  if(J < j || Y < y) return;
  if(j == J && y == Y) {
    answer.insert(s);
    return;
  }
  if(j == 5 && y <= 3) return;
  if(y == 5 && j <= 3) return;
  if(j == 5 && y == 5) return;
  solve(J, Y, j + 1, y, s + "A");
  solve(J, Y, j, y + 1, s + "B");
}

int main() {
  int j, y;
  cin >> j >> y;
  solve(j, y);
  for(auto i: answer) cout << i << endl;
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#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() {
    ll n,W;
    cin >> n >> W;

    ll sumV = 0;
    vector<int> w(n),v(n);
    rep(i,n){
        cin >> w[i] >> v[i];
        sumV += v[i];
    }
    vector<ll> dp(sumV + 1, 1e9+10); 
    dp[0] = 0;
    rep(i,n){
        for ( int j = sumV - v[i]; 0 <= j; --j ) {
            dp[j+v[i]] = min( dp[j+v[i]], dp[j] + w[i]);
        }
    }

    ll ans = 0;
    rep (i,sumV+1) {
        if(dp[i] <= W){
            ans = i;
        } 
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	static int height = 0;
	static int weight = 0;

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		boolean zeroFlag = true;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();

		while (zeroFlag) {
			String[] nyuryokuStr = line.split("[\\s]+");
			height = Integer.parseInt(nyuryokuStr[0]);
			weight = Integer.parseInt(nyuryokuStr[1]);
			if (height == 0 && weight == 0) {
				zeroFlag = false;
			} else {
				for (int h = 0; h < height; h++) {
					for (int w = 0; w < weight; w++) {
						if( (w == 0 || h == 0) ||
							 (w == weight - 1 || h == height - 1)) {
								System.out.print("#");

						} else {
							System.out.print(".");
						}
					}
					System.out.println();
				}
				System.out.println();
			}
			line = br.readLine();
		}
	}
}

Measured memory_bytes: 32680
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

int main(void)
{
    int a, b;

    cin >> a >> b;

    cout << 6 - a - b << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<ll>h(n);
  rep(i,n) cin >> h[i];
  reverse(h.begin(), h.end());
  
  int res = 0;
  int ans = 0;
  rep(i,n-1){
    if(h[i]<=h[i+1]) res++;
    else res = 0;;
    ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.io.IOException;
import java.util.Scanner;

//

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scan = new Scanner (System.in);
		int num = scan.nextInt();

		boolean[] [] cards = new boolean[4] [13];

		for (int i = 0; i < num; i++) {
			String design = scan.next();
			int cardNumber = scan.nextInt();

			int designNumber = 0;

			if (design.equals("S")) {
				designNumber = 0;
			} else if (design.equals("H")) {
				designNumber = 1;
			} else if (design.equals("C")) {
				designNumber = 2;
			} else if (design.equals("D")) {
				designNumber = 3;
			}
			cards[designNumber][cardNumber - 1] = true;
		}
		for (int i = 0; i < 4; i++ ) {
			for (int j = 0; j < 13; j++) {
				if (cards[i][j] == false) {
					if (i == 0) {
						System.out.print("S");
					} else if (i == 1) {
						System.out.print("H");
					} else if (i == 2) {
						System.out.print("C");
					} else if (i == 3) {
						System.out.print("D");
					}
					System.out.println(" " + (j + 1));
				}
			}
		}
	}
}

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

int main() {
	int W,H,N;
	scanf("%d%d%d", &W, &H, &N);
	
	int X,Y;
	int nx ,ny;
	scanf("%d%d",&nx, &ny);
	
	int ans = 0;
	for(int i=1; i<N; i++){
		scanf("%d%d", &X, &Y);
		if((nx >= X && ny <= Y)|| (nx <= X && ny >= Y)){
			int a;
			a = X - nx;
			ans += abs(a);
			a = Y - ny;
			ans += abs(a);
			nx = X;
			ny = Y;
		} else {
			while(!(nx == X && ny == Y)){
				if(nx < X){
					nx++;
				} else if(nx > X){
					nx--;
				}
				if(ny < Y){
					ny++;
				} else if(ny > Y){
					ny--;
				}
				ans++;
			}
		}
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[100005];
bool cmp(const int &a,const int&b){
	if(a<0 && b>=0) return true;
	if(a>=0 && b<0) return false;
	if(a<0 && b<0) return -a > -b;
	return a < b;
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+n,cmp);
	ll cur = 0;
	ll ans = -1e18;
	rep(i,n)cur+=a[i];
	for(int i=0;i<=n;i++){
		if(i%2 == 0) ans = max(ans,cur);
		if(i == n) break;
		cur -= a[i];
		cur -= a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String ans = "No";

		for(int i = 1; i < 10; i++){
			for(int j = 1; j < 10; j++){
				if(N == i * j){
					ans = "Yes";
					break;
				}
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 21972
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}



int main(){
    ll r;
    cin>>r;
    cout<<3*r*r<<endl;
    
    
    return 0;
}


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

int main() {
int N , A , B , count , foreign;
cin >> N >> A >> B;
count = 0, foreign = 0;
vector<char> c(N);
for(int i = 0; i < N; i++){
    cin >> c[i];
    if (count < A + B){
      if(c[i] == 'a'){
        count++;
        cout << "Yes" <<  endl;
      }
      else if(c[i] == 'b'){
        if(foreign < B){
          count++;
          foreign++;
          cout << "Yes" << endl;
        }
        else{
          cout << "No" << endl;
        }
      }
      else{
        cout << "No" << endl;
    }
      }
      else{
        cout << "No" << endl;
      }

      
    }
}


Measured memory_bytes: 768
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

X, K, D = map(int, input().split())


def solve(X, K, D):
    X = abs(X)

    cnt = X // D
    
    if cnt > K:
        return abs(X - D * K)
    else:
        X -= cnt * D
        K -= cnt
    
        if K % 2 == 0:
            return X
        else:
            return abs(X - D)


print(solve(X, K, D))

Measured memory_bytes: 9688
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int H, W, N;
	cin >> H >> W >> N;
	int big = max(H, W);
	int ans = (N + big - 1) / big;
	cout << ans << endl;
}

Measured memory_bytes: 256
N = gets.to_i
MOD = (10**9) + 7

STRING = %w(A G C T)
BLACK3 = %w(AGC GAC ACG)
BLACK = {
  /.AG/ => 'C',
  /.AC/ => 'G',
  /.GA/ => 'C',
  /A.G/ => 'C',
  /AG./ => 'C'
}

STRING_3 = STRING.repeated_permutation(3).map(&:join).reject { |s| BLACK3.include?(s) }
STRING_3_WITH_NEXT = STRING_3.each_with_object({}) { |str3, obj|
  obj[str3] = STRING - BLACK.each_with_object([]) {
    |(reg, str), obj|
    obj << str if reg === str3
  }
}

dp = Array.new(N+1) { Hash.new(0) }

STRING_3.each { |str| dp[3][str] = 1 }

4.step(N) do |i|
  STRING_3_WITH_NEXT.each do |str, next_strs|
    ts = str[1..2]
    next_strs.each do |next_str|
      dp[i][ts+ next_str] = (dp[i - 1][str] + dp[i][ts + next_str])%MOD
    end
  end
end

puts (dp[N].values.reduce(:+)%MOD)

Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,char>;
using ll=long long;

int main() {
  int N;
  cin >> N;
  vector<int> A(N), V(2, 0);
  
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  A.push_back(0);
  int s=1;
  for (int i=0; i<N; i++) {
    if (A[i]==A[i+1]) {
      s++;
    }
    else {
      int a=A[i];
      int n=s/2;
      //cout << N << endl;
      for (int j=0; j<n; j++) {
        V.push_back(a);
      }
      s=1;
    }
  }
  ll p=V[V.size()-1], q=V[V.size()-2];
  
  sort(V.begin(), V.end());
  cout << p*q << endl;
}
 

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

const int N=405;
const int M=1e6+5;
int n,m,fa[M];
pair<int,int> p[M];
int dx[5]={0,0,-1,1};
int dy[5]={-1,1,0,0};
char s[N][N];

int col(int x,int y)
{
	return (x-1)*m+y;
}

int getfa(int x)
{
	if(fa[x]!=x) fa[x]=getfa(fa[x]);
	return fa[x];
}

int main()
{
	int i,j,k;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i) scanf("%s",s[i]+1);
	for(i=1;i<=n;++i)
		for(j=1;j<=m;++j)
			fa[col(i,j)]=col(i,j);
	for(i=1;i<=n;++i)
		for(j=1;j<=m;++j)
		{
			if(s[i][j]=='#')
			{
				for(k=0;k<4;++k)
				{
					int nowx=i+dx[k],nowy=j+dy[k];
					if(s[nowx][nowy]=='.')
					{
						int fx=getfa(col(i,j));
						int fy=getfa(col(nowx,nowy));
						if(fx!=fy) fa[fx]=fy;
					}
				}
			}
			else
			{
				for(k=0;k<4;++k)
				{
					int nowx=i+dx[k],nowy=j+dy[k];
					if(s[nowx][nowy]=='#')
					{
						int fx=getfa(col(i,j));
						int fy=getfa(col(nowx,nowy));
						if(fx!=fy) fa[fx]=fy;
					}
				}
			}
		}
	for(i=1;i<=n;++i)
		for(j=1;j<=m;++j)
			if(s[i][j]=='.') ++p[getfa(col(i,j))].first;
			else ++p[getfa(col(i,j))].second;
	long long ans=0;
	for(i=1;i<=n*m;++i) ans+=1LL*p[i].first*p[i].second;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5760
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};
pub struct Comb {
    max: usize,
    m: i64,
    fac: Vec<i64>,
    finv: Vec<i64>,
}
const MOD: i64 = 1_000_000_000;

fn main() {
    let a: f64 = read();
    let b: f64 = read();
    let n: usize = read();
    let mut ans = 0;

    let ans = ((a * min(b as i64 - 1, n as i64) as f64) / b) as i64
        - (a as i64 * (min(b as i64 - 1, n as i64) as f64 / b) as i64) as i64;
    println!("{}", ans);
}


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

int main() {

	ll N, K;
	cin >> N >> K;
	vector<pair<ll,ll>> big(N);
	REP(i, N) cin >> big[i].first >> big[i].second;

	sort(big.begin(), big.end());
	for(auto x : big) {
		if(x.second < K)
			K -= x.second;
		else {
			cout << x.first << endl;
			break;
		}
	}

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
ll mod=1e9+7;
using P=pair<int,int>;
struct op{int a,b,c,d;};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,C;cin>>N>>C;
    int d[30][30],t[3][30];
    rep(i,C)rep(j,C)cin>>d[i][j];
    rep(i,3)rep(j,30)t[i][j]=0;
    rep(i,N)rep(j,N){
        int x;cin>>x;
        t[(i+j)%3][x-1]++;
    }
    int ans=1<<30;
    rep(i,C)rep(j,C){
        if(i==j)continue;
        rep(k,C){
            if(i==k||j==k)continue;
            int tt=0;
            rep(l,C)tt+=d[l][i]*t[0][l];
            rep(l,C)tt+=d[l][j]*t[1][l];
            rep(l,C)tt+=d[l][k]*t[2][l];
            if(ans>tt)ans=tt;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX_N 1000010
bool prime[MAX_N], dp[MAX_N];
int main(){
	for(int i=0;i<=MAX_N;i++){
		prime[i] = true;
	}
	prime[0] = prime[1] = false;
	for(int i=2;i*i<MAX_N;i++){
		if(prime[i]){
			for(int j=i*2;j<=MAX_N;j+=i)prime[j] = false;
		}
	}

	int n, x, menu[30];
	while(1){
                cin >> n >> x;
                if(n==0&&x==0)break;
		for(int i=0;i<=x;i++){
			dp[i] = false;
		}

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

		int ans = 0;

		dp[0] = true;
		for(int i=1;i<=x;i++){
			for(int j=0;j<n;j++){
				if(i-menu[j] >= 0 && dp[i-menu[j]]){
					dp[i] = true;
				}
			}
			if(dp[i] && prime[i]){
				ans = i;
			}
		}

		if(ans != 0){
			cout << ans << endl;
		}else{
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
  ll k;
  cin >> k;
  vector<ll> a(k);
  for(int i = 0; i < k; i++){
    cin >> a[i];
  }

  vector<ll> l(k),r(k);

  l[k-1] = 2,r[k-1] = 2;
  for(int i = k-2; i >= -1; i--){
    ll x = ceil((double)l[i+1]/a[i+1]) * a[i+1];
    ll y = (r[i+1]/a[i+1])*a[i+1];

    //cout << x << " " << y << endl;

    if((l[i+1]/a[i+1])*a[i+1] + a[i+1] > r[i+1] && l[i+1] % a[i+1] != 0){
      cout << -1 << endl;
      return 0;
    }

    if(i == -1){
      cout << x << " " << y + a[i+1] - 1 << endl;
      return 0;
    }

    l[i] = x;
    r[i] = y + a[i+1] - 1;

    //cout << l[i] << " " << r[i] << endl;
  }

  //cout << l[0] << " " << r[0] << endl;

  return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int ans = 0, n = 0;
    n = s.size();
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - i; j++) {
            if (i + j < n - 1 && (s[i + j] == 'A' || s[i + j] == 'C' || s[i + j] == 'G' || s[i + j] == 'T')) {
                ;
            }
            else if (i + j == n - 1 && (s[i + j] == 'A' || s[i + j] == 'C' || s[i + j] == 'G' || s[i + j] == 'T')) {
                if (ans < j + 1) {
                    ans = j + 1;
                }
            }
            else if (i + j <= n - 1 && (s[i + j] != 'A' && s[i + j] != 'C' && s[i + j] != 'G' && s[i + j] != 'T')) {
                if (ans < j) {
                    ans = j;
                }
                break;
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 200005;

int n;
int a[N];

int main() {

	FAST;

	cin >> n;
	int maxx1 = 0, cnt = 0, maxx2 = 0;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		maxx1 = max(maxx1, a[i]);
	}
	for (int i = 1; i <= n; i ++) {
		if (a[i] != maxx1) {
			maxx2 = max(maxx2, a[i]);
		} 
	}
	for (int i = 1; i <= n; i ++) {
		if (a[i] == maxx1) cnt ++;
	}
	for (int i = 1; i <= n; i ++) {
		if (a[i] != maxx1) cout << maxx1 << '\n';
		else {
			if (cnt > 1) cout << maxx1 << '\n';
			else cout << maxx2 << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 2432
#include<iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){

  int h,w;

  while(true){
    cin >> h >> w;
    if(h==0&&w==0)break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cout << "#";
      }
      cout <<endl;
    }
    cout <<endl;
  }

}



Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int x = Integer.parseInt(scan.next());
        int y = Integer.parseInt(scan.next());
        scan.close();

        int min = 2 * x;
        int max = 4 * x;

        if (min <= y && y <= max && y % 2 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 35740
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
s=input()
t=input()
y=[]
import re
for i in range(len(s)-len(t)+1):
 x=s[:i]
 r=0
 for j in range(len(t)):
   if s[i+j]!="?" and s[i+j]!=t[j]:
      r=1
   else:
      x+=t[j]
 if r==0:
  if i+len(t)<=len(s)-1:
   x+=s[i+len(t):]
       
  y.append(x.replace("?","a"))
y.sort()
if len(y):
 print(y[0])
else:
 print("UNRESTORABLE")

Measured memory_bytes: 38404
from numba import njit


@njit
def main(N, K, h):
    dp = [10**10] * (N+1)
    dp[0] = 0

    for i in range(1, N):
        for j in range(min(i, K)):
            dp[i] = min(dp[i], dp[i-j-1]+abs(h[i]-h[i-j-1]))

    return dp[N-1]


if __name__ == "__main__":
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    print(main(N, K, h))


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

int N,K;
int ind;

int main() {
  cin >> N >> K;
  int n;
  rep(i, N) {
    cin >> n;
    if(n == 1) ind = i+1;
  }
  int remain;
  remain = (ind-1)%(K-1) + (K-ind-1)%(K-1);
  cout << (int)(remain >= K) + ceil((double)(N-1)/(K-1)) << 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);
		String s = sc.nextLine();
		StringBuilder sb = new StringBuilder();
		sb.append("2018");
		sb.append(s.substring(4, s.length()));
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 21972
import java.io.*;
public class Main {
public static void main (String[]args) {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try {
 String s = br.readLine();
 String t = br.readLine();
 if((t.substring(0,t.length()-1).equals(s))) {
    System.out.println("Yes");
 }
 else{
    System.out.println("No");
 }

    }catch (Exception e) {
       }
       }
   }

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

using namespace std;

int main(){
    int64_t n,a,b,ans = 0;
    cin >> n >> a >> b;
    ans += n/(a + b)*a;
    if(n%(a + b) < a){
        ans += n%(a + b);
    }else{
        ans += a;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (int)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

//modでの累乗(繰り返し二乗法)
ll modpow(ll x, ll y, ll m)
{
    if (y == 0)
        return 1;
    ll res = modpow(x, y / 2, m);
    return res * res % m * (y & 1 ? x : 1) % m;
}

//modでの割り算
ll modinv(ll x, ll m) { return modpow(x, m - 2, m); }

//modでの安全な引き算
ll modsub(ll x, ll y, ll m){ return(x + m - y) % m; }

//二項係数を求める
ll binom(ll n, ll k, ll m)
{
    ll den = 1, num = 1;
    for (int i = 1; i <= k; ++i){
        den *= i;
        num *= (n + 1 - i);
        den %= m;
        num %= m;
    }
    return num * modinv(den,m);
}

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

    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = modpow(2, n, MOD);
    ans = modsub(ans, binom(n, a, MOD), MOD);
    ans = modsub(ans, binom(n, b, MOD), MOD);
    ans = modsub(ans, 1, MOD);

    print(ans);

    return 0;
}

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

// #define  part ..
#define listi vector<int > 
#define listll vector<long long >
#define pii pair<int ,int > 
#define pll pair<long long ,long long >
#define heap priority_queue<long long >

#define pb(a) push_back(a)
#define mod 998244353
#define maxx 200006
#define ll long long 
#define quick   ios_base::sync_with_stdio(NULL),cin.tie(0);
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// #define test int t;cin>>t;while(t--)
// end of #define 

// define globals ...




 int Main()
{ 

  long a;
  cin>>a;
  cout<<a+a*a+a*a*a<<endl;



  
  return 0;
}























// main function..
int main(){

   
    Main();
    
    
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
 
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> pa;

int main(int argc, char const *argv[])
{
  ll n;
  cin >> n;
  vector<pa> a(n);
  ll res = 0;
  for (ll i = 0; i < n; i++){
    ll tmp;
    cin >> tmp;
    a[i] = make_pair(tmp-(i+1),i+1);
  }
  sort(ALL(a));
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (ll i = 0; i < n/2; i++){
    pa left = a[i];
    pa right = a[n-i-1];
    res += abs(left.first-right.first);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3328
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define INF 1e18
#define N 1000100
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%MOD;
    if(b&1)
        ans=(a*ans)%MOD;
    return ans;
}
ll inv(ll a)
{
    return power(a,MOD-2,MOD);
}
//code begins



signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    cin.sync_with_stdio(false);
    ll t;
    t=1;
//    cin>>t;
    while(t--)
    {
        ll n,d,a;cin>>n>>d>>a;
        vector<pll> v;
        for(ll i=0;i<n;i++)
        {
            ll x,h;cin>>x>>h;
            v.push_back({x,h});
        }
        sort(v.begin(),v.end());
        queue<pll> bombs;
        ll ans=0,runsum=0;
        for(ll i=0;i<n;i++)
        {
            while(bombs.size()!=0 && bombs.front().first<v[i].first)
            {
                runsum-=bombs.front().second*a;
                bombs.pop();
            }
            v[i].second=max(0ll,v[i].second-runsum);
            if(v[i].second==0)continue;
            ll cur=ceil(v[i].second*1.0/a*1.0);
            ans+=cur;
            runsum+=cur*a;
            bombs.push({v[i].first+2*d,cur});
        }
        cout<<ans<<endl;
    }
}


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

public class Hiryo
{
    public int t { get; set; }
    public int x { get; set; }
    public int y { get; set; }
}
public struct Plant
{
    public int x { get; set; }
    public int y { get; set; }
}
public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var w = int.Parse(line[0]);
        var h = int.Parse(line[1]);
        var p = int.Parse(Console.ReadLine().Trim());
        var hiryos = new List<Hiryo>();
        for (int i = 0; i < p; i++)
        {
            string[] line2 = Console.ReadLine().Trim().Split(' ');
            hiryos.Add(new Hiryo { x = int.Parse(line2[0]), y = int.Parse(line2[1]), t = int.Parse(line2[2]) });
        }
        var d = new Dictionary<Plant, int>();
        for (int i = 0; i < h; i++)
        {
            string[] line3 = Console.ReadLine().Trim().Split(' ');
            for (int j = 0; j < w; j++)
                if (line3[j] == "1") d[new Plant { x =j , y = i }] = 0;
        }
        foreach (var hi in hiryos)
        {
            var te = new Plant { x = hi.x, y = hi.y };
            if (d.ContainsKey(te)) d[te]++; 
        }
        var ans = d.Sum(x => x.Value);
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 9860
import sys
from collections import deque

H, W = map(int, sys.stdin.readline().split())
cy, cx = map(int, sys.stdin.readline().split())
gy, gx = map(int, sys.stdin.readline().split())

cy -= 1
cx -= 1
gy -= 1
gx -= 1

grid = []
for _ in range(H):
    grid.append(sys.stdin.readline().strip())

q = deque()
q2 = set()
# x, y, 累積移動距離, ブロック通過数, ワープ利用数
q.append((cx, cy, 0))
# visited = {}
visited = [[float("inf") for _ in range(W)] for _ in range(H)]
# visited[(cx, cy)] = 0
visited[cy][cx] = 0
ans = float("inf")
# 01 BFS
while q:
    while q:
        x, y, c = q.popleft()
        # if (x, y) in visited and visited[(x, y)] < c:
        if visited[y][x] < c:
            # print("here1")
            continue
        # print(x, y, c, d, e)
        for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            nx = x + dx
            ny = y + dy
            if 0 <= nx < W and 0 <= ny < H:
                if grid[ny][nx] == "#":
                    q2.add((x, y, c))
                else:
                    # if (nx, ny) in visited and visited[(nx, ny)] < c + 1:
                    if visited[ny][nx] <= c:
                        # print("here2")
                        continue
                    # visited[(nx, ny)] = c
                    visited[ny][nx] = c
                    if nx == gx and ny == gy:
                        continue
                    q.append((nx, ny, c))

    for x, y, c in q2:
        for dx in range(-2, 3):
            for dy in range(-2, 3):
                if abs(dx) == 1 and dy == 0 or abs(dy) == 1 and dx == 0:
                    continue
                nx = x + dx
                ny = y + dy
                # print("warp", dx, dy)
                if 0 <= nx < W and 0 <= ny < H and grid[ny][nx] != "#":
                    # print("warp append")
                    # if (nx, ny) in visited and visited[(nx, ny)] < c + 1:
                    if visited[ny][nx] < c + 1:
                        # print("here3")
                        continue
                    # visited[(nx, ny)] = c + 1
                    visited[ny][nx] = c + 1
                    if nx == gx and ny == gy:
                        continue
                    q.append((nx, ny, c+1))
    q2 = set()

# print(visited)
if visited[gy][gx] == float("inf"):
    print(-1)
else:
    print(visited[gy][gx])

Measured memory_bytes: 138528
#include<stdio.h>

#define MIN(a,b) ((a)<(b)?(a):(b))

void run(void){
  int n,a,b;
  scanf("%d%d%d",&n,&a,&b);
  int cnt[3]={0};
  while(n--){
    int p;
    scanf("%d",&p);
    if(p<=a){
      cnt[0]++;
    } else if(p<=b){
      cnt[1]++;
    } else {
      cnt[2]++;
    }
  }
  printf("%d\n",MIN(cnt[0],MIN(cnt[1],cnt[2])));
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define mov(i,a,b) for(int i = a; i < b; i++)
#define MOD 1000000007
#define INF 1e9+5
typedef long long ll;
using namespace std;
bool isPowerOfTwo(ll n){
	return (ceil(log2(n)) == floor(log2(n)));
}
long long binpow(long long a, long long b){
	long long res = 1;
	while(b>0){
		if(b&1) res *= a;
		a = a*a;
		b >>= 1;
	}
	return res;
}

int main(){
	
	ll a,b,c;
	cin>>a>>b>>c;
	ll rem = c-b;
	if(rem > 0){
		if((rem-a) > 0) cout<<a+b+b+1<<"\n";
		else cout<<b+(rem)+b<<"\n";
	}
	else cout<<c+b<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n;scanf("%d",&n);
    int a[100000];
    int sum=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i]-1;
    }
    printf("%d\n",sum);
    return 0;
}

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

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

    auto adjacency_list = vector<map<int, int>>(N);
    auto queue = std::queue<pair<int, int>>();
    for (auto i = 0; i < 2*(N-1); i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;

        adjacency_list[a][b]++;
        adjacency_list[b][a]++;

        if (adjacency_list[a][b] == 2)
            queue.push({a, b});
    }

    auto representatives = vector<int>(N);
    iota(begin(representatives), end(representatives), 0);

    const function<int(int)> find = [&](const int i)
    {
        if (representatives[i] != i)
            representatives[i] = find(representatives[i]);
        return representatives[i];
    };

    auto size = N;
    while (!queue.empty())
    {
        int a, b; tie(a, b) = queue.front(); queue.pop();
        a = find(a); b = find(b);

        if (adjacency_list[a].size() > adjacency_list[b].size())
            swap(a, b);

        representatives[a] = b;

        adjacency_list[a].erase(b);
        adjacency_list[b].erase(a);

        for (const auto i : adjacency_list[a])
        {
            const auto v = i.first, x = i.second;
            adjacency_list[v].erase(a);
            adjacency_list[v][b] += x;
            adjacency_list[b][v] += x;
            if (x != 2 && adjacency_list[b][v] == 2)
                queue.push({b, v});
        }

        size--;
    }

    cout << (size == 1 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 24320
import sys
from collections import deque
s = deque(list(input()))


q = int(input())
rev = 0
for _ in range(q):
    query = list(input().split())
    if len(query) == 1:
        rev += 1
    else:
        if query[1] == "1":
            if rev % 2 == 0:
                s.appendleft(query[2])
            else:
                s.append(query[2])

        else:
            if rev % 2 == 1:
                s.appendleft(query[2])
            else:
                s.append(query[2])

s = "".join(s)
if rev%2 == 1:
    s = s[::-1]

print(s)


Measured memory_bytes: 75624