akhauriyash/Code-Regression huggingface dataset:
N, M = [int(_) for _ in input().split()]
mod = 10**9+7

if N < M:
	N, M = M, N

if N == M:
	answer = 1
	for i in range(2, N+1):
		answer = answer * i
		answer = answer % mod
	answer = answer**2 * 2 % mod
	print (answer)

elif N == M+1:
	answer = 1
	for i in range(2, M+1):
		answer = answer * i 
		answer = answer % mod
	answer = answer**2 * N % mod
	print(answer)

else:
	print(0)

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

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
//点を表す構造体
class Point {
  public:
  double x,y;
  Point(double x=0,double y=0): x(x),y(y){}

  //各種演算
  Point operator+ (Point p) { return Point(x+p.x,y+p.y); }
  Point operator- (Point p) { return Point(x-p.x,y-p.y); }
  Point operator* (double a) {return Point(a*x,a*y); }
  Point operator/ (double a) {return Point(x/a,y/a); }

  double abs() { return sqrt(norm()); }
  double norm() { return x*x+y*y; }

  bool operator< (const Point &p) const{
    return x!=p.x ? x<p.x : y<p.y;
  }

  bool operator> (const Point &p) const{
    return x!=p.x ? x>p.x : y>p.y;
  }

  bool operator== (const Point &p) const{
    return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
  }
};

//ベクトルを表す構造体
typedef Point Vector;

//線分を表す構造体
struct Segment{
  Segment(Point p1 = Point(), Point p2 = Point()) : p1(p1), p2(p2) {}
  Point p1,p2;
};

//直線を表す構造体
typedef Segment Line;

//円を表すクラス
class Circle{
  public:
  //円の中心
  Point c;
  //半径
  double r;
  Circle(Point c=Point(),double r=0.0): c(c),r(r) {}
};

//多角形の表現
typedef vector<Point> Polygon;

//ベクトルaとbの内積
double dot(Vector a,Vector b){
  return a.x*b.x+a.y*b.y;
}

//ベクトルaとbの外積
double cross(Vector a,Vector b){
  return a.x*b.y-a.y*b.x;
}

//ベクトルaとbの直交判定
bool isOrthogonal(Vector a,Vector b){
  return equals(dot(a,b),0.0);
}
bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
  return isOrthogonal(a1-a2,b1-b2);
}
bool isOrthogonal(Segment s1,Segment s2){
  return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

//ベクトルaとbの平行判定
bool isParallel(Vector a,Vector b){
  return equals(cross(a,b),0.0);
}
bool isParallel(Point a1,Point a2,Point b1,Point b2){
  return isParallel(a1-a2,b1-b2);
}
bool isParallel(Segment s1,Segment s2){
  return equals(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

//線分sに対する点pの射影
Point project(Segment s,Point p){
  Vector base=s.p2-s.p1;
  double r=dot(p-s.p1,base)/base.norm();
  return s.p1+base*r;
}

//線分s1と線分s2の交点(ダメらしい)
Point getCrossPoint(Segment s1,Segment s2){
  Vector base=s2.p2-s2.p1;
  double d1=abs(cross(base,s1.p1-s2.p1));
  double d2=abs(cross(base,s1.p2-s2.p1));
  double t=d1/(d1+d2);
  return s1.p1+(s1.p2-s1.p1)*t;
}


int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int x1,x2,y1,y2;
  cin>>x1>>y1>>x2>>y2;
  Point p1(x1,y1),p2(x2,y2);
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int x,y;
    cin>>x>>y;
    Point p(x,y);
    Line l(p1,p2);
    cout<<fixed<<setprecision(15)<<project(l,p).x<<' '<<project(l,p).y<<'\n';
  }
  
  return(0);
} 


Measured memory_bytes: 3300
#include <bits/stdc++.h>
using namespace std;
const int maxx=2999+10;
int p,a[maxx];
int MOD(int x) { 
	return (x%p+p)%p; 
}
void mod(int &x) {
	x=MOD(x); 
}
int f[maxx],g[maxx],b[maxx];
int ans[maxx];
void asserts() {
	int tmp=1;
	for(int i=1;i<p;i++) tmp=MOD(tmp*i);
	assert(tmp==p-1);
}
void print() {
	for(int i=0;i<p;i++)
		cout<<ans[i]<<" ";
}
int main() {
	cin>>p;
	asserts();
	b[1]=1;
	for (int i=2;i<p;i++)
		b[i]=MOD(-(p/i)*b[p%i]);
	for(int i=0;i<p;i++) cin>>a[i];
	f[0]=1;
	for (int i=0;i<p;i++) {
		memset(g,0,sizeof(g));
		for (int j=0;j<=p;j++) {
			mod(g[j]+=f[j]*i);
			mod(g[j+1]+=f[j]);
		}
		swap(f,g);
	}
	for (int i=0;i<p;i++) 
		if (a[i]) {
			memset(g,0,sizeof(g));
			for(int j=p-1;~j;j--) {
				g[j]=MOD(f[j+1]+i*g[j+1]);
				mod(ans[j]-=g[j]);
			}
		}
	print();
}


Measured memory_bytes: 384
while(True):
  temp = raw_input()
  temp_list = temp.split()
  x = int(temp_list[0])
  y = int(temp_list[1])
  if x == y and x == 0:
    break
  else:
    print(str(min([x, y]) ) + " " + str(max([x, y]) ))


Measured memory_bytes: 4632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fst first
#define snd second
const ll mod = 1000000007;
const ll INF = (1LL << 59);
const int iINF = (1 << 31)-1;
const double dINF = 1000000000000000000.0;
const int MAX_N = 1 << 17;

int main(){
	int n, a[101];
	int al = 0, bo = 0;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n, greater<int>());
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0)al += a[i];
		else bo += a[i];
	}
	cout << al - bo << endl;
	return 0;
}

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

int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int d[n];
	d[0]=0;
	d[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++)
	{
		int m=abs(a[i]-a[i-1]);
		int l=abs(a[i]-a[i-2]);
		if(m+d[i-1]<l+d[i-2])
		{
			d[i]=m+d[i-1];
		}
		else d[i]=l+d[i-2];
	}
	cout<<d[n-1];
	
}

Measured memory_bytes: 1024
n, a = gets.chomp.split(" ").map(&:to_i)
k = gets.chomp.split(" ").map(&:to_i)
j = k.sort.reverse
all = 0
(1..n).each do |i|
    all += k[i-1]
end
count =0
N = (all.to_f / (4 * a.to_f)).ceil
(0..a-1).each do |d|
   count += 1 if j[d] >= N
end
puts count.to_i == a ? "Yes" : "No"

Measured memory_bytes: 1788
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

class Edge
{
public:
    int to;
    ll cost;

    Edge(int to, ll cost)
    {
        this->to = to;
        this->cost = cost;
    }
};

typedef pair<int, int> P;

vll dijkstra(int s, vector<vector<Edge>> &G)
{
    vll d(G.size(), INF);

    priority_queue<P, vector<P>, greater<P>> q;

    d[s] = 0;
    q.emplace(0, s);

    while(!q.empty())
    {
        auto p = q.top(); q.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (auto e : G[v])
        {
            if (d[e.to] > d[v] + e.cost)
            {
                d[e.to] = d[v] + e.cost;
                q.emplace(d[e.to], e.to);
            }
        }
    }

    return d;
}


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

    int N;
    cin >> N;

    vector<vector<Edge>> G(N);
    rep(_, N - 1)
    {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--;
        b--;
        G[a].emplace_back(b, c);
        G[b].emplace_back(a, c);
    }

    int Q, K;
    cin >> Q >> K;
    K--;

    auto d = dijkstra(K, G);

    rep(_, Q)
    {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        cout << d[x] + d[y] << endl;
    }

    return 0;
}

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

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<ll> a(N, 0LL);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    cout << (int)abs(*prev(a.end()) - *a.begin()) << endl;
}

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

int n, m, vc, ans;
const int MAX = 10;
bool G[MAX][MAX], used[MAX];

void dfs(int now){
    used[now] = true;
    vc++;

    if(vc == n){
        ans++;
    }else{
        for(int i = 0; i < n; i++){
            if(!used[i] and G[now][i]){
                dfs(i);
            }
        }
    }
    used[now] = false;
    vc--;

    return;
}



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

    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a][b] = true;
        G[b][a] = true;
    }

    dfs(0);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		int cnt = 0;
		
		
		for(int i = 1; i < a; i++) {
			cnt++;
		}
		
		if(b >= a) {
			cnt++;
		}
		
		System.out.println(cnt);
		
	}

}


Measured memory_bytes: 35656
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	int ans=INF;
	fori(max(x,y)+1){
		int score=0;
		score+=i*2*c;
		if(x-i>0)score+=(x-i)*a;
		if(y-i>0)score+=(y-i)*b;
		ans=min(score,ans);
	}
	cout<<ans;
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair<ii, int>

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define sz(a) (int) a.size()
#define cl(a) a.clear()

#define vi vector<int>
#define vii vector<ii>

#define LOWBIT(x) ( (x) & -(x) )

#define FOR(x,a,b) for (int x=a;x<=b;x++)
#define FOD(x,a,b) for (int x=a;x>=b;x--)
#define REP(x,a,b) for (int x=a;x<b;x++)
#define RED(x,a,b) for (int x=a;x>b;x--)

const int MAX = 1e5 + 10;
const int MAXN = 1e4 + 10;
const ll MOD = 1e9 + 7;
const ll inf = 1e9;
const double pi = acos(-1.0);
const double eps = 1e-6;

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

int main(){
	//freopen("t.txt","r",stdin);
	int a,b;
	cin>>a>>b;
	 if (a+b>=24) cout<<a+b-24;
	 else
	 cout<<a+b;
}


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

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

int main() {
 ll n,x; cin >> n >> x;
 vector<ll> co(n);
 rep(i,n){
   ll xi; cin >> xi;
   co[i]=abs(xi-x);
 }
 ll m;
 for(int i=0;i<n-1;i++){
   m=gcd(co[i],co[i+1]);
   co[i+1]=m;
 }

 cout << co[n-1] << endl;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll inf=1e9+7;
const ll mod=1e9+7;
const int MAX=1010;



signed main(){
    ll ans=0;
    ll n;cin>>n;
    ll ma;cin>>ma;
    rep(i,n-1){
        ll b;cin>>b;
        ans+=max(0LL,ma-b);
        ma=max(ma,b);
    }
    cout<<ans<<endl;
}

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

using namespace std;

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

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main(void){

    int n, k;
    cin >> n >> k;
    vector<double> p(n+1);
    for(int i = 1; i < n+1; ++i){
        int a;
        cin >> a;
        p[i] = (a * (a + 1) / 2) / (double)a;
    }

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

    double ans = 0;
    for(int i = 0; i < n-k+1; ++i){
        ans = max(ans, p[i + k] - p[i]);
    }

    cout << fixed << setprecision(15) << ans << "\n";

    return 0;
}


Measured memory_bytes: 4828
#!/usr/bin/env python3
# 整数の入力
x = int(input())

if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
elif 1800 <= x <= 1999:
    print(1)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int main(){
	fastio();
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]==a[1] && a[0]!=a[2]){
		cout<<"Yes";
		return 0;
	}else if(a[1]==a[2] && a[0]!=a[1]){
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
int main(){
  #define int long
  int n,res=0;
  cin>>n;
  vector<int> a(n),b(n),c(n);
  for(int i=0;i<n;++i)cin>>a[i];
  for(int i=0;i<n;++i)cin>>b[i];
  for(int i=0;i<n;++i)cin>>c[i];
  sort(all(a));
  sort(all(c));
  for(int i=0;i<n;++i){
    int ia=lower_bound(all(a),b[i])-a.begin();
    int ic=c.end()-upper_bound(all(c),b[i]);
    res+=ia*ic;
  }
  cout<<res;
  return 0;
}

Measured memory_bytes: 2560
n,k = [int(i) for i in input().split(" ")]
r,s,p = [int(i) for i in input().split(" ")]
points = {"r":p, "s":r, "p":s}
hand = input()
check = [False]*n
totalpoint = 0

for i in range(n):
	
    # 既に探索済みなら確認する必要なし
    if check[i]:
        continue
    
    now = i
    which = 1
    point = [points[hand[i]],0]
    
    while now+k<n and hand[now]==hand[now+k]:
        
        check[now+k] = True
        point[which]+=points[hand[now+k]]        
        now += k
        which = (which+1)%2
    
    totalpoint += max(point)   

print(totalpoint)

Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N=1e5+10;

int n,m,tot,st,d[N],id[N],nt[N];
ll K;int ans[N],q[N],cnt,vs[N],p[N];

int main(){
	int i,j,x,k;
	scanf("%d",&n);
	for(i=1;i<=n;++i) scanf("%d",&p[i]);
	for(i=2;i<=n;++i) d[i]=p[i]-p[i-1],id[i]=i;
	scanf("%d%lld",&m,&K);
	for(i=1;i<=m;++i){scanf("%d",&x);swap(id[x],id[x+1]);}
	for(i=2;i<=n;++i) nt[id[i]]=i;
	for(i=2;i<=n;++i) if(!vs[i]){
		for(cnt=0,j=i;!vs[j];j=nt[j]){
			q[++cnt]=j;vs[j]=1;
		}
		x=K%cnt;k=x%cnt+1;
		for(j=1;j<=cnt;++j){
			ans[q[k]]=d[q[j]];
			k= k==cnt?1:(k+1);
		}
	}
	ll pos=(ll)p[1];
	for(i=1;i<=n;++i){
		pos+=ans[i];
		printf("%.10lf\n",(db)pos);
	}
	return 0;
}

Measured memory_bytes: 5120
/* ITP1_9_D: Transformation */

#include <iostream>
#include <string>
#include <algorithm>
using std::string;

int main() {
    std::ios::sync_with_stdio(false);

    string str;
    int n_commands;
    std::cin >> str;
    std::cin >> n_commands;

    string command;
    int pos_begin, pos_end;
    for (int i = 0; i < n_commands; i++) {
        std::cin >> command >> pos_begin >> pos_end;
        string::iterator s_begin = str.begin();

        if (command == "print") {
            int length = pos_end - pos_begin + 1;
            std::cout << str.substr(pos_begin, length) << "\n";
        }
        else if (command == "reverse") {
            std::reverse(s_begin + pos_begin, s_begin + pos_end + 1);
        }
        else if (command == "replace") {
            string rep_str;
            std::cin >> rep_str;
            str.replace(s_begin + pos_begin, s_begin + pos_end + 1, rep_str);
        }
    }

    return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int K,A,B;
    cin >> K >> A >> B;
    for(int i=A; i<=B; i++){
        if(i%K==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

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

using namespace std;

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

  string t, h;
  int tp = 0, hp = 0;
  
  for ( int i = 0; i < n; i++ )
    {
      cin >> t >> h;
      if ( t == h )
        {
          tp++;
          hp++;
        }
      else if ( t > h )
        tp += 3;
      else
        hp += 3;
    }
  cout << tp << " " << hp << endl;
  
  return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcdEx(ll a, ll b, ll *x, ll *y) {
    if (!a) {*x = 0; *y = 1; return b;}
    ll x1, y1, gcd = gcdEx(b % a, a, &x1, &y1); *x = y1 - (b / a) * x1; *y = x1; return gcd;
}
ll modI(ll b, ll m)      {ll x, y; gcdEx(b, m, &x, &y); return (x % m + m) % m;}
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define MOD                 1000000007
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(ll)(MOD+((a%MOD)-(b%MOD))%MOD):(ll)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (ll)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {
    ll r = 1; x %= MOD; while (y > 0) {
        if (y & 1) {r = (r * x) % MOD;}
        y = y >> 1; x = (x * x) % MOD;
    } return r;
}
ll max(ll a, ll b) {return (a > b ? a : b);}
ll min(ll a, ll b) {return (a < b ? a : b);}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | "; __f(comma + 1, args...);
}
ll gcd( ll a, ll b )
{
    if (b == 0)
    {
        return a;
    }
    else
    {
        return gcd( b, (a % b) );
    }
}
ll lcm (ll a, ll b)
{
    ll ans = (a  / gcd(a, b)) * b;
    return ans;
}
void solve()
{
    ll ans = 0;
    ll n;
    cin >> n;
    ans = n + (n * n) + (n * n * n);
    cout << ans << "\n";

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}




Measured memory_bytes: 3612
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<int> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    int Odd[100002] = {};
    int Even[100002] = {};
    int n;
    int q;
    int max_odd = 0;
    int max_even = 0;
    int max_odd_i = 0;
    int max_even_i = 0;
    int semi_max_odd = 0;
    int semi_max_even = 0;

    cin >> n;
    REP(i, n){
        cin >> q;
        if(i % 2 == 1){
            Odd[q]++;
            if(Odd[q] < max_odd)continue;
            if(max_odd_i != q)semi_max_odd = max_odd;
            max_odd = Odd[q];
            max_odd_i = q;
        }else{
            Even[q]++;
            if(Even[q] < max_even)continue;
            if(max_even_i != q)semi_max_even = max_even;
            max_even = Even[q];
            max_even_i = q;
        }
    }
    int cnt = 0;
    /*
8
5 3 5 2 5 5 5 5
    */
    sort(Odd, Odd + 100002, greater<>());
    sort(Even, Even + 100002, greater<>());
    if(max_odd_i == max_even_i){
        cnt = min(n - Odd[0] - Even[1], n - Even[0] - Odd[1]);
    }else{
        cnt = n - Odd[0] - Even[0];
    }
    print(cnt);
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
// namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main() {
  string S;
  cin>>S;
  vector<ll> beg;
  vector<ll> ansnum(S.size()+1,0);
  FOR(i,S.size()-1){
    if(S[i]=='>'&&S[i+1]=='<'){
      beg.push_back(i+1);
    }
  }
  if(S[0]=='<'){
    beg.push_back(0);
  }
  if(S[S.size()-1]=='>'){
    beg.push_back(S.size());
  }
  for(ll a:beg){
    for(ll i=a-1,ii=1;i>=0;--i,++ii){
      if(S[i]=='>'){
        if(ansnum[i]<ii){
      	ansnum[i]=ii;
        }
      }else{
        break;
      }
    }
    for(ll i=a+1,ii=1;i<=S.size();++i,++ii){
      if(S[i-1]=='<'){
        if(ansnum[i]<ii){
      	ansnum[i]=ii;
        }
      }else{
        break;
      }
    }
  }
  ll ans = 0;
  for(auto a:ansnum){
    //cout<<a<< " ";
    ans+=a;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 6136
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    else:
        for i in range(H):
            for j in range(W):
                if (i+j)%2==0:
                    print('#',end='')
                else:
                    print('.',end='')
            print()
        print()        



Measured memory_bytes: 7000
n = int(input())
s = []
for i in range(n):
    s.append(input())
sort_s = sorted(s)
x = [0] * n
y = [0] * n
count = 1
ans = []
max_c = 1
for i in range(n-1):
    if sort_s[i] == sort_s[i + 1]:
        count += 1
    else:
        x[i] = sort_s[i]
        y[i] = count
        count = 1
x[n-1] = sort_s[n-1]
y[n-1] = count
m = max(y)
ans = []
for i in range(n):
    if y[i] == m:
        ans.append(i)
for i in ans:
    print(x[i])


Measured memory_bytes: 31704
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

#import sys
#sinput = sys.stdin.readline

a, b = map(int, input().split())

flg =False
for i in range(1,10001):
    if int(i*0.08)==a and int(i*0.1)==b:
        print(i)
        flg=True
        break
if not flg:
    print(-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    // int n, x; cin >> n >> x;
    while(1) {
        int n, x; cin >> n >> x;
        if (n == 0 && x == 0) {
            break;
        }
        int ans = 0;
        repr(i, 1, n-1) {
            repr(j, i+1, n) {
                int c = x - i - j;
                if (c > j && c <= n) {
                    ans += 1;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}
/*
3 0
3 1
3 2
3 3
3 4
3 5
3 6
3 7
30 36
30 27
30 28
30 11
30 12
30 23
30 24
30 30
30 26
40 40
40 40
40 80
40 50
40 30
40 20
40 10
40 60
40 70
40 90
50 55
50 65
50 75
50 85
50 95
50 10
99 120
99 130
99 140
99 150
99 160
100 88
100 56
100 26
100 36
100 116
100 120
100 100
100 186
100 286
100 208
0 0
*/



Measured memory_bytes: 3116
n = int(input())
x = list(map(int, input().split()))

x_sort = sorted(x)

med1_ix = n//2-1
med2_ix = n//2

med1 = x_sort[med1_ix]
med2 = x_sort[med2_ix]

for i in x:
    if i <= med1:
        print(med2)
    else:
        print(med1)

Measured memory_bytes: 26772
#include <stdio.h>

int main()
{
	int n;
	scanf("%d", &n);
	int count = 0, k = 1;
	while(n--)
	{
		int m;
		scanf("%d", &m);
		if(m != k)
			count++;
		else
			k++;
	}
	if(k==1)
		printf("-1\n");
	else
		printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
# 全ての数字を使うという条件を満たしていない
# -->おかしい

import itertools
N = int(input())
n = len(str(N))
lst = [3, 5, 7]

def calc(count, tmp):
    ans = 0
    if count >= 9:
        return 0
    for i in lst:
        tmp += i * (10 ** count)
        # print (i, tmp)
        if tmp <= N:
            # print (tmp)
            if  '7' in str(tmp) and '5' in str(tmp) and '3' in str(tmp):
                ans += 1
        ans += calc(count + 1 ,tmp)
        tmp -= i * (10 ** count)
    return ans

ans = calc(0, 0)
print (ans)



    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


//////////////////////////////////////
#include <iostream>
using namespace std;
#define dp(arg) do { cout << #arg << ":"; dprint(arg); } while(0)

template <typename T> void dprint(T arg) { cout << arg << "\n"; }
template <typename T> void dprint(const vector<T>& arg) { for_each(begin(arg), end(arg), [](T value){ cout << value << " "; }   ); cout << "\n";  }
template <typename T> void dprint(const vector<vector<T>>& arg) { for_each(begin(arg), end(arg), [=](vector<T> arg2){ dprint(arg2); cout << "\n";} );  }

// #define dprint(arg) ;
//////////////////////////////////////

using namespace std;
int main() {

    int n;
    cin >> n;

    int adj[n][n];
    memset(adj, 0, sizeof(int) * n * n);

    int v, k;
    int a;
    REP(i, n) {
        cin >> v >> k;
        REP(j, k){
            cin >> a;
            adj[v-1][a-1] = 1;
        }
    }

    REP(i, n) {
        REP(j, n - 1) {
            cout << adj[i][j] << " ";
        }
        cout << adj[i][n-1] << "\n";
    }

}



Measured memory_bytes: 3100
#include<stdio.h>
#include<stdlib.h>
  
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
  
Node root;
  
Node treeMinimum(Node x){
 
  /*my code beginning*/
  while ( x->left != NIL ){
    x = x->left;
  }
  return x;
  /*my code end*/
 
}
  
Node treeMaximum(Node x){
 
 
}
 
Node treeSearch(Node u, int k){ /*find*/
 
  /*my code beginning*/
  if ( u == NIL || k == u->key ){
    return u;
  }
  if ( k < u->key ){ 
    return treeSearch(u->left,k);
  } else { 
    return treeSearch(u->right,k);
  }
  /*my code end*/
 
}
  
Node treeSuccessor(Node x){
 
  /*my code beginning*/
  Node y;
  if ( x->right != NIL ){ 
    return treeMinimum(x->right);
  }
  y = x->parent;
  while ( y != NIL && x == y->right ){
    x = y;
    y = y->parent;
  }
  return y;
  /*my code end*/
 
}
  
Node treeDelete(Node z){ /*delete*/
  Node y; // node to be deleted
  Node x; // child of y
 
  /*my code beginning*/
  if ( z->left == NIL || z->right == NIL ){ 
    y = z;
  } else {
    y = treeSuccessor(z);
  }
  if ( y->left != NIL ){ 
    x = y->left;
  } else {
    x = y->right;
  }
  if ( x != NIL ){ 
    x->parent = y->parent;
  }
  if ( y->parent == NIL ){ 
    root = x;
  } else if ( y == y->parent->left ){ 
    y->parent->left = x;
  } else {
    y->parent->right = x;
  }
  if (y != z){
    z->key = y->key;
  }
  return y;
  /*my code end*/
 
}
  
  
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  /*my code beginning*/
  while (x!=NIL){
    y=x;
    if (z->key < x->key){ 
      x=x->left;
    } else{
      x=x->right;
    }
  }
  z->parent=y;
  if (y==NIL){ 
    root = z;
  } else if (z->key < y->key){
    y->left=z;
  } else {
    y->right=z;
  }
  /*my code end*/
 
}
  
void inorder(Node u){
 
  /*my code beginning*/
  if (u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
  /*my code end*/
 
}
void preorder(Node u){
 
  /*my code beginning*/
  if (u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
  /*my code end*/
 
}
 
int main(){
  int n, i, x,a[50];
  char com[20];
  scanf("%d", &n);
 
  /*my code beginning*/
  root=NIL;
  /*my code end*/
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  
  return 0;
}



Measured memory_bytes: 20488
#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>;
using vv = vector<vector<ll> >;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const int INF = 2147483647;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(){
    int n;cin >> n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
	cin >> v[i];
    }
    sort(v.rbegin(),v.rend());
    ll ans = v[0];
    for(int i=0;i<n-2;i++){
	ans += v[i/2+1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4048
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n, y;

int main() {
	cin >> n >> y;
	rep(i, n + 1) {
		rep(j, n + 1) {
			int k = n - (i + j);
			if (k >= 0) {
				if (10000 * i + 5000 * j + 1000 * k == y) {
					cout << i << " " << j << " " << k << endl;
					return 0;
				}
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; --i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> s;
  cout << (n >= 3200 ? s : "red") << endl;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int N;
    static int M;
    static Edge[] ES;
    static long[] d;
    static long INF = Long.MAX_VALUE;
    static boolean[] negative;
    static long ans;

    private static void init() {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        M = scanner.nextInt();

        ES = new Edge[M];
        for(int i = 0; i < M; i++) {
            int from = scanner.nextInt() - 1;
            int to = scanner.nextInt() - 1;
            long cost = -scanner.nextLong();
            Edge e = new Edge(from, to, cost);
            ES[i] = e;
        }

        d = new long[N];
        Arrays.fill(d, INF);

        negative = new boolean[N];
        Arrays.fill(negative, false);

        scanner.close();
    }

    private static void bellmanFord(int s) {
        d[s] = 0;

        for(int i = 0; i < N; i++) {
            for(int j = 0; j < M; j++) {
                Edge e = ES[j];
                if(d[e.from] == INF) continue;

                if(d[e.from] + e.cost < d[e.to]) {
                    d[e.to] = d[e.from] + e.cost;
                }
            }
        }

        ans = -d[N - 1];

        for(int i = 0; i < N; i++) {
            for(int j = 0; j < M; j++) {
                Edge e = ES[j];
                if(d[e.from] == INF) continue;

                if(d[e.from] + e.cost < d[e.to]) {
                    d[e.to] = d[e.from] + e.cost;
                    negative[e.to] = true;
                }
                if(negative[e.from]) {
                    negative[e.to] = true;
                }
            }
        }
    }

    public static void main(String args[]) {
        init();
        bellmanFord(0);
        if(negative[N - 1]) {
            System.out.println("inf");
        } else {
            System.out.println(ans);
        }

    }
}

class Edge {
    int from;
    int to;
    long cost;

    public Edge(int from, int to, long cost) {
        this.from = from;
        this.to = to;
        this.cost = cost;
    }
}

Measured memory_bytes: 29192
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
using namespace std;

int main()
{
	int N;
	cin >> N;
	set<string> exist;
	string old = "";
	auto result = true;
	for (auto i = 0; i < N; ++i)
	{
		string w;
		cin >> w;

		if (!result)
		{
			continue;
		}

		if (old.size() == 0)
		{
			exist.insert(w);
			old = w;
		}
		else if(exist.find(w) != exist.end()
			|| old[old.size() - 1] != w[0])
		{
			result = false;
		}
		else
		{
			exist.insert(w);
			old = w;
		}
	}

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

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int main() {
  vector<int> prime;
  int m = 123456*2;
  bool p[m+1];
  fill(p, p+m+1, false);
  for (int i = 2; i <= m; i++) {
    if (!p[i]) {
      prime.push_back(i);
      for (int j = i+i; j <= m; j += i) {
	p[j]  = true;
      }
    }
  }
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    int t =  lower_bound(ISEQ(prime), 2*n) - upper_bound(ISEQ(prime), n);
    cout << max(t, 1) << endl;
  }
}

Measured memory_bytes: 1584
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int  jpy = 0;
    double btc = 0;
    for(int i = 0; i < n; i++){
          double x;
          string u;
          cin >> x;
          cin >> u;
          if(u == "JPY") jpy += x;
          else btc += x;
    }
    
    double ans = jpy + btc*380000.0;
    
    cout << ans;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;

long long const mod = 998244353;


int main(){
    long long n, s;
    cin >> n >> s;
    vector<long long> a(n + 1);
    for(int i = 1; i <= n; ++i) cin >> a[i];

    vector<vector<long long> > d(n + 1, vector<long long>(s + 1));
    for(int i = 0; i <= n; ++i){
        d[i][0] = i + 1;
    }
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= s; ++j){
            if(a[i] <= j && d[i - 1][j - a[i]]){
                d[i][j] = (d[i - 1][j - a[i]] + d[i - 1][j]) % mod;
            }
            else if(d[i - 1][j]) d[i][j] = d[i - 1][j];
        }
    long long ans = 0;
    for(int i = 1; i <= n; ++i) ans = (ans + d[i][s]) % mod;
    cout << ans;
}

Measured memory_bytes: 70784
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

double R;

int main(){
    cin>>R;

    cout<<setprecision(10)<<2.0*3.1415926535*R<<endl;
}

Measured memory_bytes: 3780
import fractions
N,X=map(int,input().split())
x=list(map(int,input().split()))
y=[0]*N
for i in range(N):
  y[i]=x[i]-X
ans=y[0]
for i in range(1,N):
  ans=fractions.gcd(ans,y[i])
print(abs(ans))

Measured memory_bytes: 16240
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;

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

	public void run() throws Exception {
		Scanner sc = new Scanner();
		String str = "0" + sc.next();
		int n = str.length() - 1;
		boolean ok = true;
		for (int i = 0; i < n + 1; ++i) {
			ok &= str.charAt(i) == str.charAt(n - i);
		}
		ok &= str.charAt(0) == '0';
		ok &= str.charAt(1) == '1';
		if (!ok) {
			System.out.println(-1);
			return;
		}
		ArrayList<Integer> list = new ArrayList<>();
		for (int i = 0; i <= n; ++i) {
			if (str.charAt(i) == '1') {
				list.add(i);
			}
		}
		int sz = 1;
		int tail = 1;// 010
		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 1; i < list.size(); ++i) {
			pw.println(tail + " " + (sz + 1));
			++sz;
			tail = sz;
			int diff = list.get(i) - sz;
			for (int j = 0; j < diff; ++j) {
				pw.println(tail + " " + (sz + 1));
				++sz;
			}
		}
		pw.println(tail + " " + (sz + 1));
		pw.close();
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

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

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

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

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

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

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

		public int nextInt() {
			return (int) nextLong();
		}

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

Measured memory_bytes: 44120
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: usize,
        s: chars,
    }
    let b_cnt = s.iter().filter(|&c| c == &'B').count();

    println!("{}", if (n - b_cnt) > b_cnt { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
/* _________________________________________________________________________________________________
  |                                                                                                 |
  |                             Author      : Aditya Ahuja                                          |
  |                             Date        : Thu, 20th Jun 2019                                    |
  |_________________________________________________________________________________________________|
*/
 
#include<bits/stdc++.h>
using namespace std;

// #define int long long

#define pb          push_back
#define F           first
#define S           second
#define rep(i,a,b)  for(int i=a; i<b; i++)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << (x) << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;

#define wa(x)       cout << (#x) << " -------- " << (x) << endl
#define pvi(v)      {for(auto it:v) cout << it << " "; cout << endl;}
#define line1	    printf("---------------------------\n")

// #define wa //
// #define line1 //
// #define pvi //
// #define printf //

void solve();
signed main() {
	//ios_base::sync_with_stdio(false); cin.tie(NULL);
	////cout << fixed << setprecision(10);

	int t=1; 
	//cin>>t;
	while(t--) solve();
	return 0;
}

//___________________________________________________________________________________________________

void solve() {

	int n;
	cin>>n;

	vi r(3,0);
	vii a(n,r);

	rep(i,0,n){
		rep(j,0,3){
			cin >> a[i][j];
		}
	}

	vii dp(n,r);

	dp[0] = a[0];

	rep(i,1,n){
		rep(j,0,3){
			dp[i][j] = max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]) + a[i][j];
		}
	}

	ret(*max_element(all(dp[n-1])));
}


Measured memory_bytes: 11136
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

a,b,x = map(int,input().split())
ans = (b+1) // x - (a-1) // x
if (b+1) % x == 0:
    ans -= 1
# if (a-1) % x == 0:
#     ans -= 1
print(ans)


Measured memory_bytes: 5460