akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
    int N,M,L,K,A,H;
    int[] d;
    List<Edge>[] adj;
    int INF = 1000000000;
    List<String> f;

    public static void main(String[] args){
	new Main().solve();
    }

    class Edge{
	int t, c;
	public Edge(int t, int c) {
	    this.t = t;
	    this.c = c;
	}
    }

    @SuppressWarnings("unchecked")
    void solve(){
	Scanner sc = new Scanner(System.in);
	N = sc.nextInt();
	while(N!=0){
	    M = sc.nextInt();
	    L = sc.nextInt();
	    K = sc.nextInt();
	    A = sc.nextInt();
	    H = sc.nextInt();
	    f = new ArrayList<String>();
	    for(int i=0; i<L; i++){
		f.add(sc.nextInt()+"");
	    }
	    f.add(A+"");
	    f.add(H+"");
	    
	    adj = new List[N];
	    for(int i=0; i<N; i++)adj[i] = new ArrayList<Edge>();
	    for(int i=0; i<K; i++){
		int x = sc.nextInt();
		int y = sc.nextInt();
		int t = sc.nextInt();
		adj[x].add(new Edge(y,t));
		adj[y].add(new Edge(x,t));
	    }

	    d = new int[N*(M+1)];

	    dijkstra(A);

	    if(d[H*(M+1)+M]==INF){
		System.out.println("Help!");
	    }else{
		System.out.println(d[H*(M+1)+M]+Math.max(0,d[H*(M+1)+M]-M));
	    }

	    N = sc.nextInt();
	}
    }

    void dijkstra(int s){
	Arrays.fill(d,INF);
	d[s*(M+1)+M] = 0;
	PriorityQueue<Integer> q = new PriorityQueue<Integer>(N, new Comparator<Integer>() {
		public int compare(Integer o1, Integer o2) {
		    return d[o1]-d[o2];
		}
	    });

	q.add(s*(M+1)+M);

	while(!q.isEmpty()){
	    int v = q.poll();
	    int town = v/(M+1);
	    int left = v%(M+1);

	    for(Edge e:adj[town]){
		if(left-e.c<0)continue;
		int w = d[town*(M+1)+left]+e.c;
		if(f.contains(e.t+"") && w<d[e.t*(M+1)+M]){
		    q.remove(e.t*(M+1)+M); 
		    d[e.t*(M+1)+M] = w; 
		    q.add(e.t*(M+1)+M);
		}else if(w<d[e.t*(M+1)+left-e.c]){
		    q.remove(e.t*(M+1)+left-e.c); 
		    d[e.t*(M+1)+left-e.c] = w; 
		    q.add(e.t*(M+1)+left-e.c);
		}
	    }
	}
    }
}

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

struct Problem {

    void Solve() {
        double pi = acos(-1);
        double A, B; cin >> A >> B;
        double H, M; cin >> H >> M;
        M = 2 * pi / 60 * M;
        H = 2 * pi / 12 * H + M / 12;
        double y1 = A * sin(H);
        double y2 = B * sin(M);
        double x1 = A * cos(H);
        double x2 = B * cos(M);
        double dx = x2 - x1;
        double dy = y2 - y1;
        cout << fixed << setprecision(10) << sqrt(dx * dx + dy * dy) << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

bool f(string S) {
    if (S.size() % 2 == 1) return false;
    int N = S.size();
    return S.substr(0, N / 2) == S.substr(N / 2, N);
}

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

    S.pop_back();
    while (!f(S)) {
        S.pop_back();
    }

    cout << S.size() << endl;
}

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


int main(){
  int r,g,b,n,x,y,z,i,j,k;
  cin >> r >> g >> b >> n;
  x=y=z=0;
  int ans=0;
  for(i=0;i<=3000;++i){
    for(j=0;j<=3000;++j){
      if((n-r*i-g*j)%b==0 && (n-r*i-g*j)/b>=0){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import math
def dis(a, b):
    res = 0
    for i in range(len(a)):
        res += math.pow(a[i] - b[i], 2)
    return math.sqrt(res)

def main():
    N, D = [int(n) for n in input().split()]
    points = []
    res = 0
    for _ in range(N):
        points.append([int(a) for a in input().split()])
    for i in range(N):
        for j in range(i+1, N):
            if float.is_integer(dis(points[i], points[j])):
                res += 1
    print(res)
main()

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

int N;
LL K, A[MAXN + 3];

int main() {
    cin >> N >> K;
    for (int i = 1; i <= N; i++)
        cin >> A[i];

    sort(A + 1, A + N + 1);

    LL lo = -1e18, hi = 1e18, mid;
    while (hi >= lo) {
        mid = (lo + hi)/2;

        LL numBelowMid = 0;
        for (int i = 1; i <= N; i++) {
            if (A[i] > 0) {
                int l = i + 1, r = N, m;
                while (r >= l) {
                    m = (l + r)/2;
                    if (A[i] * A[m] <= mid)
                        l = m + 1;
                    else
                        r = m - 1;
                }

                numBelowMid += (r - i);
            } else if (A[i] < 0) {
                int l = i + 1, r = N, m;
                while (r >= l) {
                    m = (l + r)/2;
                    if (A[i] * A[m] > mid)
                        l = m + 1;
                    else
                        r = m - 1;
                }

                numBelowMid += (N - l + 1);
            } else if (A[i] == 0) {
                if (mid >= 0)
                    numBelowMid += (N - i);
            }
        }

        if (numBelowMid < K)
            lo = mid + 1;
        else
            hi = mid - 1;
    }

    cout << lo << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define maxn 1000005
using namespace std;
const int mod = 1000000007;
int n;
vector<int> g[maxn];
int fac[maxn],inv[maxn];
int dp[maxn],sz[maxn],Ans[maxn];
int fastpow(int a,int p)
{
	int ans=1;
	for(;p;p>>=1,a=1ll*a*a%mod)if(p&1)ans=1ll*ans*a%mod;
	return ans; 
}
int C(int x,int y)
{
	return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;
}
void dfs(int u,int f)
{
	dp[u]=1;
	for(int v:g[u])if(v!=f)
	{
		dfs(v,u);
		dp[u]=1ll*dp[v]*dp[u]%mod*C(sz[u]+sz[v],sz[v])%mod;
		sz[u]+=sz[v];
	}
	sz[u]+=1;
}
void dfs2(int u,int f)
{
	for(int v:g[u])if(v!=f)
	{
		int t=1ll*Ans[u]*fastpow(dp[v],mod-2)%mod*fastpow(C(n-1,sz[v]),mod-2)%mod;
		Ans[v]=1ll*Ans[u]*fastpow(C(n-1,sz[v]),mod-2)%mod*C(n-1,sz[v]-1)%mod; 
		dfs2(v,u);
	}
}
int main()
{
	fac[0]=inv[0]=1;
	for(int i=1;i<=1000000;++i)fac[i]=1ll*fac[i-1]*i%mod,inv[i]=fastpow(fac[i],mod-2);
	scanf("%d",&n);
	for(int i=1;i<n;++i)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].push_back(v);g[v].push_back(u);
	}
	dfs(1,0);
	Ans[1]=dp[1];
	dfs2(1,0);
	for(int i=1;i<=n;++i)printf("%d\n",Ans[i]); 
}

Measured memory_bytes: 50932
//テスト
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;


int main(){
    int d;
    cin >> d;
    vector<int> c(26);
    rep(i,26) cin >> c[i];
    vector<vector<int>> s(d,vector<int>(26));
    rep(i,d){
        rep(j,26){
            cin >> s[i][j];
        }
    }
    //答え入れる配列
    vector<int> ans(d);
    //減少
    ll sum=0;
    vector<int> last(26);
    rep(i,d){
        ll nax=-INF;
        ll nax_i;
        rep(j,26){
            ll now_sum=0;
            now_sum+=s[i][j];
            int before_last = last[j];
            last[j]=i+1;
            ll minus=0;
            rep(k,26){
                minus+=c[k]*(i+1-last[k]);
            }
            if(nax<now_sum){
                nax_i = j;
                nax = now_sum;
            }
            last[j]=before_last;
        }
        ans[i] = nax_i+1;
    }  
    rep(i,d){
        cout << ans[i] << endl;
    }
	return 0;   
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n,k;
    cin >> n >> k;
    ll ans = 0;
    for(int i = k; i <= n+1; i++){
        ans  += (ll)(n-i+1)*i+1;
        ans %= mod;
    }
    cout << ans <<  endl;
        
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int p=s.size(),count=0,i;
  for(i=0;i<p;i++){
      if(s[i]!=t[i])count++;
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 3840
#include <stdio.h>

int main(){
  double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2;
  while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&xa1,&ya1,&xa2,&ya2,&xb1,&yb1,&xb2,&\
yb2)!=EOF){
    if (xa2<xb1 || xb2<xa1 || ya2<yb1 || yb2<ya1)
      puts("NO");
    else
      puts("YES");
  }
  return 0;
}

Measured memory_bytes: 612
#include <iomanip>
#include <iostream>

using namespace std;

int n;
long double ans = 0;
long double dp[3000][3000];

int main()
{
  cin >> n;
  
  dp[0][0] = 1;
  
  for (int i = 0; i < n; ++i) {
    long double p;
    cin >> p;
    for (int j = 0; j <= i; ++j) {
      dp[i+1][j+1] += dp[i][j] * p;
      dp[i+1][j] += dp[i][j] * (1-p);
    }
  }
  
  for (int i = n/2+1; i <= n; ++i)
    ans += dp[n][i];
  
  cout << setprecision(15) << ans << endl;
  return 0;
}

Measured memory_bytes: 139008
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline LL ri() {LL x; scanf("%lld", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/


int main() {

  string s;
  cin >> s;
  string t;
  for (char c : s) if (c != 'x') t.push_back(c);
  rep(i, t.size()) if (t[i] != t[t.size() - 1 - i]) {
    cout << -1 << endl;
    return 0;
  }
  if (t.empty()) {
    cout << 0 << endl; 
    return 0;
  }
  int c = 0, cnt = 0;
  while (cnt < t.size() / 2) {
    if (s[c ++] != 'x') cnt ++;
  }
  //cout << c << endl;
  //cout << cnt << endl;
  int l = c;
  //c ++;
  int r = c;
  //cout << l << ' ' << r << endl;
  while (r < s.size() && s[r] == 'x') r ++;
  //cout << l << ' ' << r << endl;
  if (t.size() % 2) {
    l = r;
  } else {
    l --;
    while (l >= 0 && s[l] == 'x') l --;
  }
  //cout << l << ' ' << r << endl;
  int res = 0;
  while (l >= 0 && r < s.size()) {
    if (s[l] != s[r]) {
      if (s[l] == 'x') l --, res ++;
      else if (s[r] == 'x') r ++, res ++;
    } else {
      l --; r ++;
    }
  }
  res += (s.size() - r) + (l + 1);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 640
N,M=map(int,input().split())
from collections import defaultdict
branch=[tuple(map(int,input().split())) for i in range(M)]
def check(x):
    data=defaultdict(set)
    for i in range(M):
        if i==x:continue
        a,b=branch[i]
        data[a]|={b,}
        data[b]|={a,}
    if len(data[1])==0:
        return False
    visited={1,}
    check={1,}
    while len(check)>0:
        now=check.pop()
        for nex in data[now]:
            if nex not in visited:
                visited|={nex,}
                check|={nex,}
    if len(visited)==N:return True
    return False
cnt=0
for i in range(M):
    if not check(i):
        cnt+=1
print(cnt)

Measured memory_bytes: 3444
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("avx")

// timus 219263UI
//    (><)

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define y1 needtrainharder
#define f first
#define s second
#define gg exit(0)
#define sz() size()
#define pb push_back
#define mp make_pair
#define skip continue
#define all(x) x.begin(), x.end()
#define alln(x, y) x, x + y
#define boost ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define file(s) if(fopen(task".in", "r"))freopen(s".in","r",stdin),freopen(s".out","w",stdout);
#define task "sorting"

const int inf = 1e9 + 5;  
const ll infll = 1e18 + 5ll;  
const long double eps = 1e-15;
const int maxn = 1e5 + 100;
const int maxlog = 21;
const int P = 97;
const int mod = 1e9 + 7;

int k;
string n;
bool used[16];
vector<int> v;                

int main(){
  	boost; 
  	// srand(time(NULL));
  	//file(task);  

  	cin >> n >> k;
  	for (int i = 1, x; i <= k; ++i) {
  		cin >> x;
  		used[x] = 1;
  	}       
	for (int i = 0; i <= 9; ++i) {
		if (!used[i])
			v.pb(i);
	}
	bool tr = 0;
	string ans = "";
	for (int i = 0; i < n.sz(); ++i) {
		if (tr) {
			ans = ans + char(v[0] + 48);
			skip;
		}	
		for (int j = 0; j < v.sz(); ++j) {
		 	if ((n[i]-48) <= v[j]) {
				if ((n[i]-48) < v[j]) {
					tr = 1;
				}
				ans = ans + char(v[j] + 48);
				break;
		 	}
		}
	}
	if (atoi(ans.c_str()) < atoi(n.c_str())) {
	    if (v[0] == 0) {
	    	cout << v[1];
	    	for (int i = 0; i < n.sz(); ++i)
	    		cout << v[0];
	    } else {
			for (int i = 0; i <= n.sz(); ++i) {
			 	cout << v[0];
			}
	    }
		
	} else 
		cout << ans;
  return 0; 
}
/*




*/

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

signed
main(){
		int n,m,t,p;
		while(cin >> n >> m >> t >> p && !(n==0 && m==0 && t==0 && p==0))
		{
				vector<vector<int> > z(m, vector<int>(n,1));

				//w,hは更新されていく幅と高さ
				int w = n, h = m;

				for(int i=0;i<t;i++)
				{
						int d,c;
						cin >> d >> c;

						if(d==1)
						{
								vector<vector<int> > tmp(h, vector<int>(w, 0)), tmp2(h, vector<int>(w, 0));
								//tmpの初期化
								for(int a=0;a<h;a++)
								{
										for(int b=0;b<w-c;b++)
										{
											tmp[a][b] = z[a][b+c];
										}
								}


								for(int a=0;a<h;a++)
								{
										for(int b=0;b<c;b++)
										{
											tmp2[a][b] = z[a][c-1-b];
										}
								}

								//最後にtmpの状態をzに適用
								for(int a=0;a<h;a++)
                                {
                                        for(int b=0;b<w;b++)
                                        {
                                        		z[a][b] = 0;
		 									z[a][b] = tmp[a][b] + tmp2[a][b];
										}
                                }

								//wの値を更新
								w = max(w-c,c);

						}
						else if(d==2)
						{
								vector<vector<int> > tmp(h, vector<int>(w, 0)),tmp2(h, vector<int>(w, 0));
								//tmpの初期化
								for(int a=0;a<h-c;a++)
								{
										for(int b=0;b<w;b++)
										{
											tmp[a][b] = z[a+c][b];
										}
								}

								for(int a=0;a<c;a++)
								{
										for(int b=0;b<w;b++)
										{
											tmp2[a][b] = z[c-1-a][b];
										}
								}

								//最後にtmpの状態をzに適用
								for(int a=0;a<h;a++)
                                {
                                        for(int b=0;b<w;b++)
                                        {
                                        		//初期化
                                        		z[a][b] = 0;
		 									z[a][b] = tmp[a][b] + tmp2[a][b];
										}
                                }

								//hの値を更新
								h = max(h-c,c);

						}

						//debug
						/*
						for(int a=0;a<m;a++)
						{
							for(int b=0;b<n;b++)
							{
								cout << z[a][b] << " ";
							}
							cout << endl;
						}
						*/

				}


				int ans = 0;

				for(int i=0;i<p;i++)
				{
						int x,y;
						cin >> x >> y;
						cout << z[y][x] << endl;

				}
		}
}


Measured memory_bytes: 3188
key = [*'a'..'z']
value = Array.new(key.size, 0)
ary = [key,value].transpose
h = Hash[*ary.flatten]
sentences = []
while line = gets
  sentences.push line.chomp.downcase.split("")
end
sentences.flatten!
sentences.each do |s|
  h[s] += 1 if h.has_key?(s)
end
h.each do |i, j|
  puts "#{i} : #{j}"
end

Measured memory_bytes: 8704
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <string>
#include <cstdlib>

using namespace std;

stack <int> st;
int solve(string);

int main(){
    // Your code here!
    string str;
    while(cin>>str){
        if(str=="+" || str=="*" || str=="-"){
            int ans = solve(str);
            st.push(ans);
        }
        
        else{
            st.push(stoi(str));
        }
        
        if(getchar()=='\n'){
            cout<<st.top()<<endl;
            return 0;
        }
        
    }
}

int solve(string str){
    int b=st.top(); st.pop();
    int a=st.top(); st.pop();
    if(str=="+") return a+b;
    else if(str=="-") return a-b;
    else if(str=="*") return a*b;
}




Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define MAX 1002
#define INF 100000000
using namespace std;

int c[MAX][MAX]={},F[MAX]={};

int fib(int n){
  if(n==0||n==1)return 1;
  if(F[n]!=0)return F[n];
  return F[n]=fib(n-1)+fib(n-2);
}

void matrixChain(int p[],int n){
    int l,i,k,j,q;
    for(i=1;i<=n;i++)c[i][i]=0;
    for(l=2;l<=n;l++){
        for(i=1;i<=n-l+1;i++){
            j=i+l-1;
            c[i][j]=INF;
            for(k=i;k<j;k++){
                q=c[i][k]+c[k+1][j]+p[i-1]*p[k]*p[j];
                c[i][j]=min(c[i][j],q);
            }
        }
    }
}

void LCSLength(char *x,char *y){
    int m,n,i,j;
    for(m=0;x[m]!='\0';m++);
    for(n=0;y[n]!='\0';n++);

    // cout<<m<<" "<<n<<endl;
    for(i=0;i<MAX;i++)for(j=0;j<MAX;j++)c[i][j]=0;
    for(i=1;i<=m;i++)c[i][0]=0;
    for(j=0;j<=n;j++)c[0][j]=0;
    for(i=1;i<=m;i++){
        for(j=1;j<=n;j++){
            if(x[i-1]==y[j-1])c[i][j]=c[i-1][j-1]+1;
            else if(c[i-1][j]>=c[i][j-1])c[i][j]=c[i-1][j];
            else c[i][j]=c[i][j-1];
        }
    }
    // for(i=0;i<=m;i++){
    //     for(j=0;j<=n;j++){
    //         cout<<c[i][j];
    //     }
    //     cout<<endl;
    // }
    cout<<c[m][n]<<endl;
}


int main(){
    int n,p[MAX],i,j,k,m,g,count=0;
    char x[MAX],y[MAX];
    cin>>n;
    for(i=0;i<n;i++){
        scanf("%s",x);
        scanf("%s",y);
        LCSLength(x,y);
    }
    
    // matrixChain(p,n);
}

  


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

int main() {
  string S;
  cin>>S;
  int sum=0;
  for (int i=0;i<S.size();i++) {
    if (S.at(i)=='o') {
      sum++;
    }
    else {
      continue;
    }
  }
  
  if (S.size()<=7) {
    cout<<"YES"<<endl;
  }
  
  else {
    int a=15-S.size()+sum;
    if (a>=8) {
      cout<<"YES"<<endl;
    }
    else {
      cout<<"NO"<<endl;
    }
  }

}


Measured memory_bytes: 256
import bisect

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()

ans = 0
C = len(c)

# Bを中心に考える
for i in b:
    ans += (bisect.bisect_right(a,i-1))*(C-bisect.bisect_left(c,i+1))

print(ans)

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

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

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

    if(b < a)
        swap(a, b);
    
    if(a + W < b)
        cout << b - (a + W) << endl;
    else
        cout << 0 << endl;

    return 0;
}

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

using namespace std;

int main() {
  string S;
  cin >> S;
  int zeros = 0, ones = 0;
  for (int i = 0; i < (int)S.size(); ++i) {
    if (S[i] == '1') {
      ones++;
    }
    else {
      zeros++;
    }
  }
  cout << min(ones, zeros) * 2 << endl;
  return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
#define D(x) cerr<<#x<<'='<<x<<'\n';
using namespace std;
typedef long long ll;
int a[105];
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	int ans=0x3f3f3f3f;
	for (int i=a[1];i<=a[n];i++)
	{
		int sum=0;
		for (int j=1;j<=n;j++)
			sum+=(a[j]-i)*(a[j]-i);
		ans=min(ans,sum);
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
 
void solve(){
    ll n;
    cin>>n;
    if(n%2 == 0){
        ld ans = 0.5;
        printPrec(ans);
    }
    else {
        ld ans = (ld)((n/2)+1)/(ld)n;
        printPrec(ans);
    }
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
   
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

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

static const double eps = 10e-6;

int dp[101][101];

int main(){
	int n;
	scanf("%d",&n);

	vector<P> cards;
	memset(dp,0x2,sizeof(dp));
	for(int i=0;i<n;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		cards.push_back(P(a,b));
	}

	for(int i=0;i<=n;i++) dp[i][i]=0;

	for(int len=1;len<n;len++){
		for(int i=0;i<n-len;i++){
			for(int j=i;j<i+len;j++){
				int cost = cards[i].first * cards[j].second * cards[j+1].first * cards[i+len].second;
				dp[i][i+len] = min(dp[i][i+len],dp[i][j] + dp[j+1][i+len] + cost);
			}
		}
	}

	cout << dp[0][n-1] << endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  string str, rstr;
  rep(i, A) {
    str += '1';
    rstr += '0';
  }
  rep(i, W-A) {
    str += '0';
    rstr += '1';
  }
  vector<string> grid(H);
  rep(i, B)
    grid[i] = str;
  for (int i=B; i<H; i++)
    grid[i] = rstr;
  rep(i, H)
    cout << grid[i] << endl;
  return 0;
}

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int r,d;
ll x;
cin>>r>>d>>x;
for(int i=0;i<10;i++){
    x=r*x-d;
    cout<<x<<endl;
}
//system("pause");
return 0;
}

Measured memory_bytes: 256
#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>;
#define PI 3.14159265359
const int INF = 1001001001;
const int MOD = 1000000007;

int counter(ll x)
{
    int count=0;
    while(x>=1)
    {
        x=x/10;
        count++;
    }
    return count;
}
int main()
{
    /*A
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    */
   
    int n;
    cin>>n;
    vector <ll> a(n);
    ll sum=1;
    bool flag = 1;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        {
            flag = 0;
        }
    }
    if(!flag)
    {
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<n;i++)
    {
        ll temp = 1;;
        temp *= sum*a[i];
        if(temp<sum || temp>1000000000000000000)
        {
            cout<<-1<<endl;
            return 0;
        }
        else
        {
            sum=temp;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int d[110],f[110];
int t;
bool visit[110];
vector<vector<int>> vec(110);

void dfs(int a) {
  if(!visit[a]){
    visit[a] = true;
    d[a] = ++t;
    for(auto x: vec[a]) dfs(x);
    f[a] = ++t;
  }
}

int main() {
  int n; cin >> n;
  FOR(i,0,n-1){
    int u,k,v; cin >> u >> k;
    --u;
    FOR(j,1,k){
      cin >> v;
      --v;
      vec[u].PB(v);
    }
  }
  FOR(i,0,n-1) dfs(i);
  FOR(i,0,n-1) cout << i+1 << " " << d[i] << " " << f[i] << "\n";




}




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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h, w, x, y;
  cin >> h >> w >> x >> y;
  cout << (h - x) * (w - y) << endl;
  return 0;
}


Measured memory_bytes: 256
N=int(raw_input())
P=map(int,raw_input().split())
PA=[0]*N
for i in xrange(N):
    PA[P[i]-1]=i
A=[]
B=[]
for i in xrange(N):
    A.append(30000*(i+1)+PA[i])
    B.append(30000*(N-i))
print " ".join(map(str,A))
print " ".join(map(str,B))

Measured memory_bytes: 6740
from math import sqrt
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
# p=1
d = [0.0 for i in range(3)]
var = 0
for i in range(n):
    temp = abs(x[i]-y[i])
    if var < temp:
        var = temp
    for j in range(3):
        d[j]+=temp**(j+1)

for i in range(3):
    print(d[i]**(1/(i+1)))
print(float(var))


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

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


Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){

	double r;
	double a;
	double b;
	
	cin >> r ;
	
	a=M_PI*r*r;
	b=2*M_PI*r;
	
	cout << fixed << setprecision(6) << a << " " << fixed << setprecision(6) << b <<endl;
}

Measured memory_bytes: 3236
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

#include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

vector<double> A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

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

    cin >> N;
    rep(ni,N){
        cin >> dtmp;
        A.push_back(dtmp);
    }   

    double total=0;
    rep(ni,N){
        total += 1.0/A[ni];
    }
    cout << fixed << setprecision(15)  << 1.0/total << endl;


}

Measured memory_bytes: 3812
#include<iostream>
#include<algorithm>
#include<vector>
int main() {
	int a, b;
	while (std::cin >> a >> b) {
		int sum,ans=1;
		sum = a + b;
		for (int i = 10; !(sum / i==0); i*=10) {
			ans += 1;
		}
		std::cout << ans << std::endl;
	}
}

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

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

bool chk(int bit) {
  for (int i = 0; i < N; i++) {
    if (bit >> i & 1) {
      for (pair<int,int> xy : XY.at(i)) {
        int x = xy.first, y = xy.second;
        if ((bit >> x & 1) ^ y) return false;
      }
    }
    else continue;
  }
  return true;
}

int main() {
  cin >> N;
  XY.resize(N);
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    XY.at(i).resize(A);
    for (int j = 0; j < A; j++) {
      cin >> XY.at(i).at(j).first >> XY.at(i).at(j).second;
      XY.at(i).at(j).first--;
    }
  }

  int ans = 0;

  for (int i = 0; i < 2 << N; i++) {
    if (chk(i)) {
      int cnt = 0;
      for (int j = 0; j < N; j++) {
        if (i >> j & 1) cnt++;
      }
      ans = max(ans, cnt);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int n;
    cin>>n;
    vector<int>vec(n);
    for(int i=0;i<n;i++){
        cin>>vec[i];
    }
    map<int,int>mmp;
    bool pd=0;
    for(int i=0;i<n;i++){
        int v=vec[i];
        for(int j=2;j*j<=v;j++){
            int gun=0;
            while(v%j==0) {
                gun++;
                v/=j;
            }
            if(gun){
                if(mmp[j]){
                    pd=1;
                }
                else mmp[j]=1;
            }

        }
        if(v>1){
            if(mmp[v]){
                pd=1;
            }
            else mmp[v]=1;
        }
    }
    if(!pd){
        cout << "pairwise coprime\n";
    }
    else{
        int gc=vec[0];
        for(int i=1;i<n;i++){
            gc=gcd(gc,vec[i]);
        }
        if(gc==1){
            cout << "setwise coprime\n";
        }
        else{
            cout << "not coprime\n";
        }
    }

    return 0;
}
///Alhamdulillah


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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;

int main(){
  string s, t;  cin>> s >> t;
  t.pop_back();
  if(s==t)  puts("Yes");
  else  puts("No");
  return 0;
}

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

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

int main(){
    
    int N,M,L,R;
    int Lmax=1,Rmin=100000;

    scanf("%d%d",&N,&M);

    for(int i=0;i<M;i++){
        scanf("%d%d",&L,&R);
        Lmax = max(Lmax,L);
        Rmin = min(Rmin,R);
    }
    if(Rmin<Lmax)
        printf("%d\n",0);
    else
        printf("%d\n",Rmin-Lmax+1);

    return 0;
}

Measured memory_bytes: 256
h,w,m=map(int, input().split())
r = [0]*max(h,w)
c = [0]*max(h,w)
l=[]

for i in range(m):
    x,y=map(int, input().split())
    r[x-1]+=1
    c[y-1]+=1
    l.append([x,y])

cm = max(c)
rm = max(r)
ci = [i for i, x in enumerate(c) if x == cm]
ri = [i for i, x in enumerate(r) if x == rm]
ans = cm + rm

cnt = 0
#print(l,ci,ri)
for i in range(m):
    if r[l[i][0]-1] == rm and c[l[i][1]-1] ==cm:
        cnt += 1

if cnt == len(ci)*len(ri):
    print(int(ans)-1)
else:
    print(int(ans))

Measured memory_bytes: 82220
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a[3][3], n, b[10];
    bool appear[3][3];
    for (int i=0; i<3; i++){
        for (int j=0; j<3; j++) cin >> a[i][j];
    }
    cin >> n;
    for (int k=0; k<n; k++) cin >> b[k];
    
    for (int i=0; i<n; i++){
        for (int j=0; j<n; j++){
            appear[i][j] = false;
            for (int k=0; k<n; k++){
                if(a[i][j] == b[k]) appear[i][j] = true;
            }
        }
    }
    string ans = "No";
    for (int i=0; i<3; i++) {
        if (appear[i][0] && appear[i][1] && appear[i][2]) ans = "Yes";
    }
    for (int i=0; i<3; i++) {
        if (appear[0][i] && appear[1][i] && appear[2][i]) ans = "Yes";
    }
    if (appear[0][0] && appear[1][1] && appear[2][2]) ans = "Yes";
    if (appear[0][2] && appear[1][1] && appear[2][0]) ans = "Yes";
    
    cout << ans << endl;
    return 0;
}

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

//region Template
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int MOD = 1000000007;
using namespace std;
#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
/*
template<typename... Args>
void print(Args... args) {
	#ifdef LOCAL
	((std::cout << args << " "), ...);
	cout << endl;
	#endif
}
 */
//endregion

/* Notes:
 * Farah </3
 */

const int MAXN = 1e5 + 5;
const int INF = 2e9;

map<pair<int, int>, int> cnt;
int main() {
	//usaco("milkvisits");

#ifdef LOCAL
	setIn("in.txt");
	setOut("out.txt");
#endif

	int n;
	cin >> n;

	for(int i = 1; i <= n; i++){
		int f = i, l = i % 10;
		while(f > 9) f /= 10;

		cnt[{f, l}]++;
	}
	ll ans = 0;
	for(int i = 1; i <= 9; i++){
		for(int j = 1; j <= 9; j++){
			ans += cnt[{i, j}] * cnt[{j, i}];
		}
	}
	cout << ans;
}

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

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

	bool wa = false;
	int sz = S.size();

	if(S[0] != 'A'){
		cout << "WA" << endl;
		return 0;
	}
	bool C = false;
	for (int i = 1; i < sz; ++i) {
		if('A' <= S[i] && S[i] <='Z'){
			if(S[i] =='C' && i>=2 && i < sz-1){
				if(!C){
					C = true;
				}else{
					cout << "WA" << endl;
					return 0;
				}
			}else{
				cout << "WA" << endl;
				return 0;				
			}
		}
	}
	if(!C){
		cout << "WA" << endl;
		return 0;
	}
	
	cout << "AC" << endl;
	return 0;
}


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


int main()
{
  string s;
  cin >> s;
  int l = s.size();
  if(s[l-1]=='s'){
    s = s + "es";
  }else{
    s = s +"s";
  }
  cout << s << endl;
}


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

int main() {
    int a, b, c, d;
    int l[13] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1};
    cin >> a >> b;
    for (int tmp = 0; tmp < 2; tmp++){
        for (int tmp2 = 0; tmp2 < 13; tmp2++){
            if (l[tmp2] == a){
                c = tmp2;
            }
            if (l[tmp2] == b){
                d = tmp2;
            }
        }
    }
    if (c < d){
        cout << "Bob" << endl;
    } else if(a == b){
        cout << "Draw" << endl;
    } else {
        cout << "Alice" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n;
  cin>>n;
  ll ans=3*n*n;
  cout<<ans<<endl;
}


Measured memory_bytes: 888
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    string s, t;
    cin >> s >> t;
    cout << t + s << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;

const int L = 18;

s64 delta;
s64 prePow[L + 1];

s64 solve(int l, bool first, s64 delta)
{
	if (abs(delta) >= prePow[l])
		return 0;
	if (l <= 1)
		return l ? (delta ? 0 : 10) : 1;

	s64 res = 0;
	s64 pow = prePow[l - 1] - 1;
	for (int d = -9; d <= 9; ++d)
		if ((delta - d * pow) % 10 == 0)
			res += solve(l - 2, false, (delta - d * pow) / 10) * (10 - abs(d) - first);

	return res;
}

int main()
{
	cin >> delta;

	prePow[0] = 1;
	for (int i = 1; i <= L; ++i)
		prePow[i] = prePow[i - 1] * 10;

	s64 res = 0;
	for (int i = 1; i <= L; ++i)
		res += solve(i, true, delta);

	cout << res << endl;

	return 0;
}

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

int main() {

  int n, a, b, which;   //whichは差分の変数
  cin >> n >> a >> b;

  which = a * n - b;

  if(which >= 0) {
    cout << b;
  }
  else {
    cout << a * n;
  }
}


Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <random>
#include <chrono>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

class UnionFind {
private:
	vector<int> data;
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }

public:
	UnionFind(int size) : data(size, -1) { }
	bool is_same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return -data[root(x)]; }

	void unify(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
};

int main() {
  int N,M;
cin>>N>>M;
cout<<(N-1)/(M*2+1)+1;
}


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

using namespace std;

int taikakusen(int, int);

int main()
{
	int h, w;
	int target = 0,box=20000;
	int ibox=0, jbox = 0;

	start:

	scanf("%d %d", &h,&w);

	if (h == 0 && w==0) {
		goto finish;
	}

	target = taikakusen(h, w);

	for (int i = 1; i < 150; i++) {
		for (int j = i + 1; j <= 150; j++) {
			if (taikakusen(i, j) < target) continue;
			if (i == h && j == w) continue;
			if (taikakusen(i, j) == target && i < h) continue;
			if ((box - target) > (taikakusen(i, j) - target)) {
				box = taikakusen(i, j);
				ibox = i;
				jbox = j;
			}
		}
	}

	cout << ibox << " " << jbox << endl;

	target = 0;
	box = 20000;

	ibox = 0;
	jbox = 0;

	goto start;

	finish:

	return 0;
}

int taikakusen(int h, int w)
{
	return h * h + w * w;
}


Measured memory_bytes: 3152
#include<stdio.h>
int main()
{
	int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
	if (a>b&&b>c){
		d=(a-b)+(b-c);
		printf("%d\n",d);
	}
	else if (b>a&&a>c){
		d=(b-a)+(a-c);
		printf("%d\n",d);
	}
	else if (c>a&&a>b){
		d=(c-a)+(a-b);
		printf("%d\n",d);
	}
	else if (c>b&&b>a){
		d=(c-b)+(b-a);
		printf("%d\n",d);
	}
	else if (a>c&&c>b){
		d=(a-c)+(c-b);
		printf("%d\n",d);
	}
	else if (b>c&&c>a){
		d=(b-c)+(c-a);
		printf("%d\n",d);
	}
	else if (a>b&&b==c){
		d=(a-b);
		printf("%d\n",d);
	}
	else if (b>c&&c==a){
		d=(b-c);
		printf("%d\n",d);
	}
	else if (c>a&&a==b){
		d=(c-a);
		printf("%d\n",d);
	}
	else if (a<b&&b==c){
		d=(b-a);
		printf("%d\n",d);
	}
	else if (b<c&&c==a){
		d=(c-b);
		printf("%d\n",d);
	}
	else if(c<a&&a==b){
		d=(a-c);
		printf("%d\n",d);
	}
	else if (a==b&&b==c){
		printf("0\n");
	}
}
		

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring> //memset
using namespace std;


//int main()
//{
//	long long N, K;
//	string S;
//
//	cin >> N >> K;
//	cin >> S;
//
//	long long happy = 0, cross = 0;
//
//	// ����happy
//	for (long iN = 0; iN < N; iN++) {
//		if (S[iN] == 'L') {
//			if (iN > 0 && S[iN - 1] == 'L') {
//				happy++;
//			}
//		}
//		else {
//			if (iN < N - 1 && S[iN + 1] == 'R') {
//				happy++;
//			}
//		}
//
//		if (iN < N - 1 && S[iN] != S[iN + 1]) {
//			cross++;
//		}
//	}
//
//	long long cross_pair = cross / 2;
//	bool amari = cross % 2 == 0 ? false : true;
//
//	long long flip = std::min(cross_pair, K);
//	happy += flip * 2;
//
//	if (amari == true && K > cross_pair) {
//		happy += 1;
//	}
//
//	cout << happy << endl;
//}


//int main()
//{
//	unsigned long long N;
//	vector<long long> B;
//
//	cin >> N;
//	for (unsigned long iN = 0; iN < N - 1; iN++)
//	{
//		long long num;
//		cin >> num;
//		B.push_back(num);
//	}
//
//	long long sumA = 0;
//	for (int iA = 0; iA < N; iA++)
//	{
//		if (iA == 0) {
//			sumA += B[0];
//		}
//		else if (iA == N - 1) {
//			sumA += B[N - 2];
//		}
//		else {
//			sumA += std::min(B[iA], B[iA - 1]);
//		}
//	}
//
//	cout << sumA << endl;
//}



int main()
{
	long N;
	long A[55], B[55], C[55];

	cin >> N;

	for (long i = 1; i <= N; i++) {
		cin >> A[i];
	}

	for (long i = 1; i <= N; i++) {
		cin >> B[i];
	}

	for (long i = 1; i <= N - 1; i++) {
		cin >> C[i];
	}

	long result = 0;

	long prev = -1;
	for (long i = 1; i <= N; i++) {
		result += B[A[i]];

		if (A[i] == prev + 1) {
			result += C[A[i] - 1];
		}

		prev = A[i];
	}

	cout << result << endl;
}


//int main()
//{
//	unsigned long long N;
//	vector<long long> B;
//
//	cin >> N;
//
//	cout << N * N * N << endl;
//}



Measured memory_bytes: 256
#include<iostream>
using namespace std;	
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a==b){
		cout<<"Draw";
	}
	else if(a==1){
		cout<<" Alice";
	}
	else if(b==1){
		cout<<"Bob ";
		
	}
	else if(a>b){
		cout<<"Alice ";
	}
	else
	{
		cout<<"Bob ";
	}
}	

Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<unordered_set>

using namespace std;




vector<int> prime_sieve(int n)
{
    int* arr = new int[n+1];
    
    int i, p;
    for (i = 0; i <= n; ++i) {
        arr[i] = i;
    }
    for (i = 2; i <= n; ++i) {
        if (arr[i] != 0) {
            for (p = arr[i] * arr[i]; p <= n; p += arr[i]) {
                arr[p] = 0;
            }
        }
    }
    vector<int> primes;
    for (i = 2; i <= n; ++i) {
        if (arr[i] != 0) {
            primes.push_back(arr[i]);
        }
    }
    return primes;
}


int main()
{
    int n,i,j;
    cin >> n;
    
    vector<int> primes;
    primes = prime_sieve(n);
    

    vector<int> count(primes.size(),0);
    int lol;
    for (lol = 1; lol <= n; ++lol) {
        for (i = 0; i < primes.size(); ++i) {
            int num = lol, c = 0;
            while (num != 0) {
                if (num % primes[i] == 0) {
                    ++c;
                }
                else {
                    break;
                }
                num /= primes[i];
            }
            count[i] += c;

        }
        
    }

    

    long long prod=1;
    int mod = 1000000000 + 7;
    for (i = 0; i < count.size(); ++i) {
        prod = (prod * (count[i] + 1)) % mod;
    }
    cout << prod;
    

   
   
    
}

    




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

using namespace std;

int n;
long long C;

struct line {
  long long m, b;

  line() {}

  line(long long _m, long long _b) : m(_m), b(_b) {}

  long long value(long long x) const {
    return m * x + b;
  }
};

bool bad(const line& a, const line &b, const line& c) {
  return (a.b - b.b) * (c.m - b.m) >= (b.b - c.b) * (b.m - a.m);
}

int main() {
  scanf("%d %lld", &n, &C);
  vector<line> que;
  int ptr = 0;
  for (int i = 0; i < n; i++) {
    long long h;
    scanf("%lld", &h);
    long long best = 0;
    if (i > 0) {
      while ((int)que.size() - ptr > 1 && que[ptr].value(h) > que[ptr + 1].value(h)) {
        ptr++;
      }
      best = que[ptr].value(h) + h * h + C;
    }
    if (i == n - 1) {
      printf("%lld\n", best);
      break;
    }
    line new_line = line(-2 * h, best + h * h);
    while ((int)que.size() - ptr > 1) {
      if (!bad(que.end()[-2], que.end()[-1], new_line)) {
        break;
      }
      que.pop_back();
    }
    que.push_back(new_line);
  }
  return 0;
}

Measured memory_bytes: 6256