akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <queue>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}

int main(){
    int a,b,c,d,e ;
    cin >> a >> b >> c >> d >> e ;
    if (a == 0)
    {
        cout << 1 << endl ;
        return 0 ;
    }
    if (b == 0)
    {
        cout << 2 << endl ;
        return 0 ;
    }
    if (c == 0)
    {
        cout << 3 << endl ;
        return 0 ;
    }
    if (d == 0)
    {
        cout << 4 << endl ;
        return 0 ;
    }
    if (e == 0)
    {
        cout << 5 << endl ;
        return 0 ;
    }
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e5+10;
#define PI acos(-1)
int main()
{
    double a,b;
    int h ,w;
    cin >> a >> b >> h >> w;
    double a1 = w*PI/60.0*2;
    double a2 = h*PI/12.0*2+w*PI/360.0;
   // cout << fixed << setprecision(9) << a1 << endl <<a2 <<endl;
    double c = a1>=a2?a1-a2:a2-a1;
    double ans = a*a+b*b-2.0*a*b*cos(c);
    ans = sqrt(ans);
    cout << fixed << setprecision(9) << ans << "\n";
    return 0;
}


Measured memory_bytes: 4224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ARC094D {
    class Program {
        static void Main(string[] args) {
            int Q = int.Parse(Console.ReadLine());
            for(int i = 0; i < Q; i++) {
                int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                Array.Sort(input);
                long A = input[0];
                long B = input[1];
                long mul = A * B;
                long N = (long)Math.Floor(Math.Sqrt(mul));
                long ans = -1;
                if(N * N == mul) {
                    ans = (N - 1) * 2;
                    if(A < N) {
                        ans--;
                    }
                } else {
                    ans = N * 2 - 2;
                }
                if(N * (N + 1) < mul) {
                    ans++;
                }
                Console.WriteLine(ans);
            }
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
using namespace std;
 
int main(){
 
  int n;
 
  while(cin>>n, n){
    int m[100], p[100][100], k, l[100], c=0, x;
    for(int i=0;i<n;i++){
      cin>>m[i];
      for(int j=0;j<m[i];j++) cin>>p[i][j];
    }
    cin>>k;
    for(int j=0;j<k;j++) cin>>l[j];
    for(int i=0;i<n;i++){
      if(m[i]<k) continue;
      int j;
      for(j=0;j<k;j++){
        int h;
        for(h=0;h<m[i];h++){
          if(l[j]==p[i][h]){
            //cout<<l[j]<<endl;
            break;
          }
        }
        if(h==m[i]) break;
      }
      if(j==k){
        c++;
        x=i;
      }
    }
    if(c==1) cout<<x+1<<endl;
    else cout<<-1<<endl;
  }
 
  return 0;
}

Measured memory_bytes: 3068
#http://nihaoshijie.hatenadiary.jp/entry/2018/02/03/115759
N,M=map(int,input().split())
P=10**9+7
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
def inv(x):
    return egcd(x,P)[0]
Z=2*10**5
Fact=[0 for i in range(Z+1)]
Finv=[0 for i in range(Z+1)]
Fact[0]=1
Finv[0]=1
for i in range(Z):
    Fact[i+1]=(Fact[i]*(i+1))%P
    Finv[i+1]=inv(Fact[i+1])%P
def C(n,k):
    return (Fact[n]*(Finv[k]*Finv[n-k])%P)%P
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
D=factorize(M)
ans=1
for seq in D:
    k=seq[1]
    ans=ans*C(k+N-1,N-1)
    ans=ans%P
print(ans)


Measured memory_bytes: 57292
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);ios::sync_with_stdio(false);

signed main()
{
    ll n, c, cal = 0, walk = 0, ans = 0;
    cin >> n >> c;
    vector<ll> x(n), v(n);
    vector<PL> r(n + 1, {0, 0}), l(n + 1, {0, 0}),r2(n + 1, {0, 0}), l2(n + 1, {0, 0});

    ll gdc = 0, gdw = 0;
    rep(i, n)
    {
        cin >> x[i] >> v[i];
        walk = x[i];
        cal += v[i];
        if (cal - walk > gdc - gdw)
        {
            gdc = cal;
            gdw = walk;
        }
        r[i + 1].fi = gdc;
        r[i + 1].se = gdw;
    }

    gdc = 0, gdw = 0;
    cal=0;
    rep(i, n)
    {
        walk = 2*x[i];
        cal += v[i];
        if (cal - walk > gdc - gdw)
        {
            gdc = cal;
            gdw = walk;
        }
        r2[i + 1].fi = gdc;
        r2[i + 1].se = gdw;
    }

    gdc = 0, gdw = 0;
    cal = 0;
    for (int i = n - 1; 0 <= i; i--)
    {
        walk = c - x[i];
        cal += v[i];
        if (cal - walk > gdc - gdw)
        {
            gdc = cal;
            gdw = walk;
        }
        l[i].fi =gdc;
        l[i].se = gdw;
    }

    gdc = 0, gdw = 0;
    cal = 0;
    for (int i = n - 1; 0 <= i; i--)
    {
        walk = 2*(c - x[i]);
        cal += v[i];
        if (cal - walk > gdc - gdw)
        {
            gdc = cal;
            gdw = walk;
        }
        l2[i].fi = gdc;
        l2[i].se = gdw;
    }

    rep(i, n+1)
    {
        ll res = r[i].fi + l2[i].fi - r[i].se-l2[i].se;
        ans = max(ans, res);
        //cout<<res<<endl;
    
        res=r2[i].fi + l[i].fi - r2[i].se-l[i].se;
        ans = max(ans, res);

        //cout<<res<<endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 8064
#include<iostream>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;
int main() {
	int n, m;
	cin >> n >> m;
	int a[105];
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	double x = (double)sum / (m * 4);
	ll count = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] >= x) {
			count++;
		}
	}
	if (count >= m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define inf 10000000000000007
#define eps 1e-8
#define PI 3.14159265359
#define sp printf(" ")
#define vi vector<int>
#define vl vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pcc pair<char, char>
#define mp make_pair
#define FF first
#define SS second
#define pb(x) push_back(x)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define sld(x) scanf("%ld", &(x))
#define pld(x) printf("%ld", (x))
#define pldn(x) printf("%ld\n", (x))
#define slf(x) scanf("%lf", &(x))
#define plf(x) printf("%.9lf", (x))
#define plfn(x) printf("%.4lf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define ios ios::sync_with_stdio(false); cin.tie(0) ; cout.tie(0)
#define endl '\n'
using namespace std;
int dp[4002][2002],at[2003][2],v[4003],col[4004],w[4002][2003],w1[4003][2003],t[2003][2];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=2*n;i++)
    {
        char c;
        cin>>c>>v[i];
        if(c=='W')col[i]=1;
        else col[i]=0;
        at[v[i]][col[i]]=i;
    }
    for(int i=2*n;i>=1;i--)
    {
        if(col[i]==1)
        {
            for(int j=1;j<=n;j++)w[i][j]+=w[i][j-1]+t[j][1-col[i]];
            for(int j=1;j<=n;j++)w1[i][j]+=w1[i][j-1]+t[j][col[i]];
        }
        else
        {
            for(int j=1;j<=n;j++)w[i][j]+=w[i][j-1]+t[j][1-col[i]];
            for(int j=1;j<=n;j++)w1[i][j]+=w1[i][j-1]+t[j][col[i]];
        }
        t[v[i]][col[i]]=1;
    }
    dp[1][1]=abs(1-at[1][1]);
    dp[1][0]=abs(1-at[1][0]);
    for(int i=2;i<=2*n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            dp[i][j]=100000000;
            if(i-j>n)continue;
            if(i>j)
            {
                int k=at[i-j][0];
                int pos=w[k][j]+k+w1[k][i-j-1];
                dp[i][j]=min(dp[i][j],abs(pos-i)+dp[i-1][j]);
            }
            if(j!=0)
            {
                int k=at[j][1];
                int pos=w[k][i-j]+k+w1[k][j-1];
                dp[i][j]=min(dp[i][j],abs(pos-i)+dp[i-1][j-1]);
            }

        }
    }
    cout<<dp[2*n][n]<<endl;


    

    
   
}

Measured memory_bytes: 94336
#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
#include <cctype>
#include <cstdio>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI 3.141592653
#define rep(i, n) for(ll i = 0; i < n; i++)


int main(){
  ll n, m;
  cin >> n >> m;
  vll v(m);
  rep(i, m){
    cin >> v[i];
  }
  sort(v.begin(), v.end());

  ll sum = 0;
  rep(i, m-1){
    sum += v[i];
  }

  
  if(sum >= v[m-1]){cout << 0 << endl;}
  else{cout << v[m-1]-sum-1 << endl;}
}


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

int main() {
  int a, b;
  cin >> a >> b;

  if (a % 3 == b % 3 && b % 3 != 0) {
    cout << "Impossible" << endl;
  }
  else {
    cout << "Possible" << endl;
  }
}


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

using namespace std;

long long pw(long long a, int n)
{
    long long res = 1;
    for(int i = 0; i < n; i++)
        res *= a;
    return res;
}

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

    long long n;
    cin >> n;
    int l = 1;
    long long cur = 26;
    while(cur < n)
    {
        l++;
        cur *= 26;
        cur += 26;
    }
    long long s = cur / 26, e = cur;
    long long diff = n - s;
    string ans = "";
    for(int i = 0; i < l; i++)
    {
        long long k = pw(26LL, l - i - 1);
        ans += ('a' + diff / k);
        diff %= k;
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
int main(void)
{
    int a,b;

    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    } else if(a>b) {
        printf("a > b\n",a,b);
    } else {
        printf("a == b\n",a,b);
    }
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
//答え見た
int main() {
  int n,d;
  cin >> n >> d;
  if( n%(2*d+1) == 0){
    cout << n/(2*d+1) << endl;
  }else{
    cout << n/(2*d+1)+1 << endl;
  }
  return 0;
}


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

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    ll n;
    cin >> n;
    ll a,b,tt;
    vector<ll> t(n);
    for(ll i = 0;i < n;i ++){
        cin >> t.at(i);
    }

    b = t.at(0);

    for(ll i = 1;i < n;i ++){
        a = b;
        tt = t.at(i);
        while(a != 0 && tt != 0){
            if(a < tt){
                tt = tt % a;
            }else{
                a = a % tt;
            }
        }

        b = b / max(a,tt) * t.at(i);
    }

    cout << b << endl;
}

Measured memory_bytes: 256
H,W=list(map(int,input().split()))

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

S_=[]
for h in range(H):
    for w in range(W):
        if S[h][w]=='.':
            continue
        try:
            S_left=S[h-1][w]
        except:
            S_left='.'
        try:
            S_right=S[h+1][w]
        except:
            S_right='.'
        try:
            S_up=S[h][w-1]
        except:
            S_up='.'
        try:
            S_down=S[h][w+1]
        except:
            S_down='.'
            
        S__=[S_left,S_right,S_up,S_down]
        S_.append(S__)

ans='Yes'
for s_ in S_:
    if '#' not in s_:
        ans='No'
        break
print(ans)

Measured memory_bytes: 67496
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
As=[0]*(N+1)+[float('inf')]
Bs=[0]*(M+1)+[float('inf')]
Amax=N
Bmax=M
for i in range(1,N+1):
    As[i]=As[i-1]+A[i-1]
    if As[i]>K:
        Amax=i
        break
for i in range(1,M+1):
    Bs[i]=Bs[i-1]+B[i-1]
    if Bs[i]>K:
        Bmax=i
        break

b=0
ans=0
for i in range(Amax,-1,-1):
    while As[i]+Bs[b]<=K:
        b+=1
    ans=max(ans,i+b-1)
print(ans)

Measured memory_bytes: 42192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

int main(){
  int n; cin >> n;
  string s; cin >> s;
  int ans = 0;
  for(int i = 1; i < n-1; i++){
    vector<char> a,b;
    for(int j = 0; j < n; j++){
      if(i < j){
        a.push_back(s[j]);
      }else{
        b.push_back(s[j]);
      }
      sort(a.begin(), a.end());
      sort(b.begin(), b.end());
      a.erase(unique(a.begin(), a.end()), a.end());
      b.erase(unique(b.begin(), b.end()), b.end());
      int cnt = 0;
      for(char c: a){
        for(char ch: b){
          if(c == ch){
            cnt++;
            break;
          }
        }
      }
      ans = max(cnt, ans);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

namespace tst
{
    class Program
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            char[] text = new char[n];
            for(int i=0; i<n; i++)
            {
                text[i] = s[i];
            }
            int cnt = 0;
            for(int i=0; i<n-2; i++)
            {
                if (text[i] == 'A' && text[i + 1] == 'B' && text[i + 2] == 'C')
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }

    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll dp[3100][3100];
bool done[3100][3100];
vector<ll> A;
int n;
ll rec(int left, int right) {
    if (done[left][right]) return dp[left][right];
    if (left == right) return A[left];
    ll res = 0;
    res = max(A[left] - rec(left + 1, right), A[right] - rec(left, right - 1));
    done[left][right] = true;
    return dp[left][right] = res;
}
int main() {
    cin >> n;
    A.resize(n);
    for (int i = 0; i < n; i++) cin >> A[i];
    for (int i = 0; i < 3100; i++) for (int j = i + 1; j < 3100; j++)
            done[i][j] = false;
    ll ans = rec(0, n - 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 59676
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(0, 0); }
	V<V<pin>> qab(2);
	int sz = ab.size();
	qab[0].reserve(sz/2);
	qab[1].reserve(sz/2);
	for (pin& x : ab) {
		qab[x.second & 1].push_back(mkp(x.first>>1, x.second>>1));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first>>1, (x.second + 1)>>1)); }
	}
	int c = 0;
	for (pin& x : qab[0]) {
		int qc = 2 * x.first + x.second;qc%=3;
		c ^= (qc+1);
	}
	if (!c) {
		pin ans = solve(qab[1], ex - 1);
		ans.first *= 2; ans.second *= 2; ans.second++;
		return ans;
	}
	pin ans = solve(qab[0], ex - 1);
	c = 0;
	int d = 0;
	for (pin& x : qab[1]) {
		int w = ans.second - x.second - 1;
		if ((w & x.first) == w) { c ^= 1; }
		w++;
		if ((w & x.first) == w) { d ^= 1; }
	}
	ans.first *= 2; ans.second *= 2;
	ans.first += (c | d); ans.second -= c;
	return ans;
}
signed main() {
	cin.tie(0); ios::sync_with_stdio(false);
	long long inf = 1e17;
	int n; cin >> n;
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; cin >> a >> b;
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 59);
	cout << ret.first - inf << " " << ret.second - inf << "\n";
}

Measured memory_bytes: 8168
//তুমি চেয়ে আছো তাই, আমি পথে হেঁটে যাই
//হেঁটে হেঁটে বহুদুর বহুদুর যেতে চাই 
//I FAILED BADLY AND VERY PUBLICLY
//THAT'S WHAT I DESERVE 

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define pii pair <int, int>
#define pll pair <long long, long long >
#define PI 2 * acos(0.0) 
const long long M = 5e5 + 10, oo = 1e9 + 7;
int dp[3010][3010], way[3010][3010];
vector < int > adj[M], indegree(M, 0), vis(M, 0), dist(M, 0);
void dfs (int u) {
    if (indegree[u] || vis[u]) return;
    vis[u] = 1;
    for (auto v : adj[u]) {
        dist[v] = max(dist[v], dist[u] + 1);
        indegree[v]--;
        dfs(v);
    }
}
int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    for (int i = 0, u, v; i < m; i++) {
        cin >> u >> v;
        adj[u].pb(v);
        indegree[v]++;
    }
    for (int i = 1; i <= n; i++) dfs(i);
    int ans = 0;
    for (int i = 1; i <= n; i++) ans = max(ans, dist[i]);
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 24704
from fractions import gcd
from functools import reduce

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

ans = 1
for i in make_divisors(a[0]):
    cnt = 0
    for j in a[1:]:
        if j%i:
            cnt += 1
            if cnt >1:
                break
    if cnt < 2:
        ans = max(ans, i)
ans = max(ans, reduce(gcd, a[1:]))
print(ans)

Measured memory_bytes: 16120
#include <stdio.h>
#include <math.h>

int main(){
    double x1 , x2 , y1 ,y2;
    double dis=0;
    
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    dis=((x1 - x2)*(x1 - x2)+(y1 - y2)*(y1 - y2));
    dis= sqrt(dis);
    printf("%f\n",dis);
    
return 0;
}

Measured memory_bytes: 652
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
 
typedef long long lld;
typedef vector<lld> vlld;
typedef pair<lld,lld> pi;
typedef tuple<lld,lld,lld> tup;
const lld mod=(lld)1e9+7;
 
lld solve(lld a[],lld n)
 {
    
    lld dp[n]={0};
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    for(lld i=2;i<n;i++)
    {
    	lld l1,l2;
    	  l1=abs(a[i]-a[i-1])+dp[i-1];
          l2=abs(a[i]-a[i-2])+dp[i-2];
       dp[i]=min(l2,l1);
    }

   return dp[n-1];

 }
 

int main() {

	lld n;
	cin>>n;
	lld a[n];

	forn(i,n)
	cin>>a[i];

	cout<<solve(a,n);
  
  return 0;
}

Measured memory_bytes: 5128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n;
	cin >> n;
	ll x[n+1];
	rep(i, 1, n){
		cin >> x[i];
	}
	rep(i, 1, n-1){
		x[i] = x[i+1]-x[i];
	}
	
	ll mul[n], rmul[n];
	mul[1] = 1;
	rep(i, 2, n-1){mul[i] = i*mul[i-1]; mul[i] %= MOD;}
	rmul[n-1] = n-1;
	rrep(i, n-2, 1){rmul[i] = i*rmul[i+1]; rmul[i] %= MOD;}
	//printa(mul, 1, n)
	//printa(rmul, 1, n)
	ll a[n];
	a[1] = rmul[2];
	a[n-1] = mul[n-2];
	rep(i, 2, n-2){
		a[i] = mul[i-1]*rmul[i+1];
		a[i] %= MOD;
	}
	//printa(a, 1, n-1)
	rep(i, 2, n-1){
		a[i] += a[i-1];
		a[i] %~ MOD;
	}
	//printa(a, 1, n-1)
	ll ans = 0;
	rep(i, 1, n-1){
		ans += a[i]*x[i];
		ans %= MOD;
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 3328
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    ans=0
    for i in 1:n
        if i%3!=0 && i%5!=0
            ans+=i
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 158164
h,w,n,*a=map(int,open(0).read().split())
b=[]
for i in range(n):
    b+=[i+1]*a[i]
for i in range(0,h*w,w):
    if i//w%2==1:
        print(*b[i:i+w])
    else:
        print(*b[i:i+w][::-1])

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

ll fact[10003];
 
template<typename T> void factorial(T m){
    fact[0] = 1;
    fact[1] = 1;
    for(int i=2; i <= 10000; ++i){
        fact[i] = fact[i-1] * i % m;
    }
}
template<typename T> T Pow(T x, T n, T m){
    if(n == 0) return 1;
    if(n % 2 == 0) return Pow(x * x % m, n / 2, m);
    else return x * Pow(x, n - 1, m) % m;
}
template<typename T> T combination(T n, T k, T m){
    return fact[n] * Pow<T>(fact[k], m-2, m) % m * Pow<T>(fact[n-k], m-2, m) % m;
}

int main(){
    ll n, k; cin >> n >> k;
    factorial<ll>(MOD);
    REP(i, k){
        if(n-k+1 >= i){
            cout << combination<ll>(n-k+1, i, MOD) * combination<ll>(k-1, i-1, MOD) % MOD << endl;
        }else cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 384
a,b,k=gets.chomp.split.map(&:to_i);
for x in 1..k
  if x.odd?  
    a=a-1 if a.odd?
    b=b+a/2
    a=a/2
  else
    b=b-1 if b.odd?
    a=a+b/2
    b=b/2
  end
end
puts "#{a} #{b}"

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

int main() {
    int n;
    cin >> n;
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[n-1] << endl;
}

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

int main()
{
    unsigned long long int a,b,x;
    scanf("%llu %llu %llu",&a,&b,&x);
    if(a%x==0)
        printf("%llu",(b/x)-(a/x)+1);
    else
        printf("%llu",(b/x)-(a/x));
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

ll n, k,  md[200010], ans;

int main() {
	cin >> n >> k;
	for (int i = 1;i <= n;i++) {
		md[i%k]++;
	}
	for (int i = 1;i <= n;i++) {
		if (i%k == 0) {
			ans += md[0]*md[0];
		}
		else {
			if (i%k == k - i % k)ans += md[i%k] * md[k - i % k];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
int main() {
  int n, k;
  cin >> n >> k;

  vector<int> a(n);

  int rec;

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 1) rec = i;
  }

  //全部1にする
  n--;
  k--;

  cout << ceil(double(n) / k) << endl;
}

Measured memory_bytes: 3868
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[100010];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	sort(A,A+N);
	int a=A[N/2-1],b=A[N/2];
	cout<<b-a<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    string S, T;
    cin >> S >> T;
    int N = int(S.size());
    int M = int(T.size());
    vector<vector<int>> dp(N + 1, vector<int>(M + 1, 0));

    for (int i = 0; i < N; i++)
        for (int j = 0; j < M; j++) {
            dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);

            if (S[i] == T[j])
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
        }

    string answer;
    int a = N, b = M;

    while (a > 0 && b > 0) {
        if (S[a - 1] == T[b - 1]) {
            answer += S[a - 1];
            a--;
            b--;
            continue;
        }

        if (dp[a][b] == dp[a][b - 1])
            b--;
        else
            a--;
    }

    reverse(answer.begin(), answer.end());
    cout << answer << '\n';
}


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


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define For(i,start,end) for(i64 i = start; i < end; i++)
#define newline std::cout<<'\n';
#define newlinedx(num) for(int i=0;i<num;i++)std::cout<<'\n';
using namespace std;
typedef long long ll;
typedef unsigned long ul;

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ui = uint64_t;

//----------------library in this time--------------------------------
template <class T>
T gcd(const T a,const T b) {
    return (b == 0) ? a : gcd (b, a % b);
}
template <class T>
T lcm(const T a, const T b) {
    return a * b / gcd(a,b);
}
template <class T>
inline T ave(const T a, const T b) {
    return (a + b) / 2.0f;
}

long long squareTwo(const long long a,const long long b) {
    return (b == 1) ? a : squareTwo(a * 2, b - 1);
}


//------------------------main function-------------------------------
void Main(){
    int n; cin >> n;
    vector<int> p(n);
    int ans = 0;
    rep(i, n) {
        cin >> p[i];
        if(p[i] != i + 1) ans ++;
    }
    if(ans == 2 || ans ==0){
        cout << "YES" << endl;
    }else{
        cout <<"NO"<< endl;
    }
    
}

//--------------------------------------------------------------------
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    
    Main();
    return 0;
}




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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int count = 0;
  for (int i = a; i < b + 1; i++) {
    if (c % i == 0) count++;
  }
  cout << count << endl;
}


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

int main() {
  string s;
  cin >> s ;
  int cnt=0;
  for(int i=0;i<s.length();i++){
   	if(s.substr(i,1)=="1"){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
s = input()
s2 = list(reversed(s))
def calc(s):
    i = 0
    ans = 0
    p = ""
    while True:
        if i >= len(s):
            return ans
        n = s[i]
        if p == n:
            if i == len(s) - 1:
                return ans
            n = s[i] + s[i+1]
            i += 1
        p = n
        i += 1
        ans += 1
print(max(calc(s), calc(s2)))


Measured memory_bytes: 4840
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<vector>

using namespace std;

#define N 200100
#define ll long long
#define RG register
#define MOD 924844033
const double Pi=acos(-1);

inline int read(){
    RG int x=0,o=1; RG char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=((x<<3)+(x<<1))+ch-'0',ch=getchar();
    return x*o;
}

inline int Plu(const int &x,const int &y) { return x+y>=MOD?x+y-MOD:x+y; }
inline int Pow(int x,int y){ int ans=1;
	while(y) { if(y&1) ans=1LL*ans*x%MOD; x=1LL*x*x%MOD,y>>=1; }
	return ans;
}
struct NTT{
	int n,r[N<<2],a[N<<2],b[N<<2],W[N<<2];
	inline void Pre(){
		int to=n<<1,l=0;
		for(n=1;n<=to;n<<=1) ++l; --l;
		for(RG int i=0;i^n;++i) r[i]=(r[i>>1]>>1)|((i&1)<<l);
	}
	inline void Trans(int *P,int op){
		for(RG int i=0;i^n;++i) if(i<r[i]) swap(P[i],P[r[i]]);
		for(RG int i=1;i<n;i<<=1){
			int w=Pow(5,(MOD-1)/(i<<1));
			if(op==-1) w=Pow(w,MOD-2); W[0]=1;
			for(RG int k=1;k^i;++k) W[k]=1LL*W[k-1]*w%MOD;
			for(RG int p=i<<1,j=0;j<n;j+=p)
				for(RG int k=0;k^i;++k){
					int X=P[j+k],Y=1LL*P[i+j+k]*W[k]%MOD;
					P[j+k]=Plu(X,Y),P[i+j+k]=Plu(X,MOD-Y);
				}
		}
		if(op==-1)
			for(RG int i=0,Inv=Pow(n,MOD-2);i^n;++i)
				P[i]=1LL*P[i]*Inv%MOD;
	}
}   F;

int n,top,first[N],siz[N],num[N],sum[N];
struct mona { int nxt,en; } s[N<<1];
inline void Insert(int x,int y) { s[++top]=(mona) { first[x],y },first[x]=top; }
inline void Dfs(int k,int fa){
	siz[k]=1;
	for(RG int i=first[k];i;i=s[i].nxt){
		int en=s[i].en; if(en==fa) continue ;
		Dfs(en,k),siz[k]+=siz[en],++num[siz[en]];
	}   ++num[n-siz[k]];
}

int main(){
	n=read(),F.n=n+1,F.Pre(),sum[0]=1;
	for(RG int i=1;i<=n;++i) sum[i]=1LL*sum[i-1]*i%MOD;
	for(RG int i=1;i^n;++i){
		int x=read(),y=read(); Insert(x,y),Insert(y,x);
	}   Dfs(1,0);
	for(RG int i=0;i<=n;++i) F.a[i]=1LL*sum[i]*num[i]%MOD;
	for(RG int i=0;i<=n;++i) F.b[i]=Pow(sum[n-i],MOD-2);
	F.Trans(F.a,1),F.Trans(F.b,1);
	for(RG int i=0;i^F.n;++i) F.a[i]=1LL*F.a[i]*F.b[i]%MOD;
	F.Trans(F.a,-1);
	for(RG int i=1;i<=n;++i) printf("%d\n",Plu(1LL*n*sum[n]%MOD*Pow(1LL*sum[i]*sum[n-i]%MOD,MOD-2)%MOD,
											   MOD-1LL*F.a[i+n]*Pow(sum[i],MOD-2)%MOD));
}


Measured memory_bytes: 24832
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define PI 3.14159265358979

using namespace std;

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

  cin >> a >> b >> x;

  x /= a;

  if (x > a*b/2){
    printf("%.8lf\n", 180/PI*atan(2*(a*b - x)/a/a));;
  }
  else
    printf("%.8lf\n", 180/PI*atan(b*b/2/x));



  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
A = sorted(map(int, input().split()))
C = []
for _ in range(m):
    b, c = map(int, input().split())
    C += [[-c, b]]
C = sorted(C)
p = 0
for cb in C:
    c, b = -cb[0], cb[1]
    for _ in range(b):
        if (p >= n) | (A[min(p, n-1)] >= c):
            break
        else:
            A[p] = c
            p += 1
print(sum(A))

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

int main() {
    using namespace std;

    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;

    if (S.length() != (A + B + 1)) {
        cout << "No" << endl;
        return 0;
    }

    for (int i=0; i<A; i++) {
        char s = S[i];
        if (!isdigit(s)) {
            cout << "No" << endl;
            return 0;
        }
    }

    if (S[A] != '-') {
        cout << "No" << endl;
        return 0;
    }

    for (int i=0; i<B; i++) {
        char s = S[A + i + 1];
        if (!isdigit(s)) {
            cout << "No" << endl;
            return 0;
        }
    }


    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;

int n;
string s;

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

    int ans = 0;
    REP(i,n) {
        FOR(j,ans + 1,n) {
            string target = s.substr(i,j);
            //cout<<target<<endl;
            if (s.find(target, i+j) != -1) {
                ans++;
                //cout<<ans<<" "<<target<<endl;
            } else {
                break;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


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

using namespace std;

int main() {
  string S;
  cin >> S;
  vector<int> alp(26, 0);
  for (int i = 0; i < S.size(); ++i) {
    alp[S[i] - 'a']++;
  }
  string res = "None";
  for (int i = 0; i < 26; ++i) {
    if (alp[i] == 0) {
      res = i + 'a';
      break;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/


void Calc() {


  int a, b;
  in, a, b;
  cout << ((a + b) % 24) << endl;
}


Measured memory_bytes: 256
N = int(input())

if N%2==1:
    print(0)
    exit()
    
two = 0
p = 1

while 2**p<=N:
    two += N//2**p
    p += 1

five = 0
p = 1

while 2*5**p<=N:
    five += N//(2*5**p)
    p += 1

print(min(two, five))

Measured memory_bytes: 38384
from math import ceil
Q = int(input())
AB = [list(map(int, input().split())) for i in range(Q)]

for a, b in AB:
    a, b = min(a, b), max(a, b)
    C = int((a*b)**0.5)
    if a == b:
        print(2*a-2)
        continue

    if a + 1 == b:
        print(2*a-2)
        continue

    if C**2 == a * b:
        C -= 1
    if C * (C+1) < a * b:
        print(2*C-1)
    else:
        print(2*C-2)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    
    int N, K;
    int p[1000];
    int min[1000];
    int posi[1000];
    
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> p[i];
        min[i] = 1001;
        posi[i] = -1;
    }
    
    for(int i = 0; i < K; i++){
        for(int j = 0; j < N; j++){
            if(min[i] > p[j]){
                min[i] = p[j];
                posi[i] = j;
            }
        }
        p[posi[i]] = 1001;
    }
    
    int ans = 0;
    for(int i = 0; i < K; i++){
        ans += min[i];
        //cout << min[i] << endl;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3164
#include<iostream>
using namespace std;
#define RENT 100000
int main(){
    int n;
    while(cin>>n){
        int ans=0;
        for(int a=0;a<10;a++){
            for(int b=0;b<10;b++){
                for(int c=0;c<10;c++){
                    for(int d=0;d<10;d++){
                        if(a+b+c+d==n)ans++;
                    }
                }
            }
        }
         
        cout<<ans<<endl;
    }
}

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

int main(){
    string s,t,u;
    cin >> s >> t;
    u = s + t;
    
    int n = stoi(u);
    
    bool flag = 0;
    for(int i = 1; i <=10000; i++) {
        if(i*i == n) flag = 1;
    }
    
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3580
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;
void solve(){
    int X,N;
    cin>>X>>N;
    vector<int> numbers(101,0);
   for(int i=0;i<N;i++){
       int a;
       cin>>a;
       numbers[a] = 1;
   }
   int start = X;
   while((start>=0) && (start<=100) && numbers[start]){
       start--;
   }
   int start1 = X;
   while((start1>=0) && (start1<=100) && numbers[start1]){
       start1++;
   }
   if(abs(X-start)<=abs(X-start1)){
       cout<<start<<'\n';
   }
   else{
       cout<<start1<<'\n';
   }
}
int main()
{
    
    
    solve();
    return 0;
}


Measured memory_bytes: 3596
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int n;

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	vector<ll> st;
	for (int i = 0; i < n; ++i) {
		ll x;
		cin >> x;
		while (true) {
			if (st.size() <= 1) {
				st.push_back(x);
				break;
			}
			else {
				ll a = st[st.size() - 2];
				ll b = st[st.size() - 1];
				if (b >= a && b >= x) {
					st.pop_back();
					st.pop_back();
					x += a - b;
				}
				else {
					st.push_back(x);
					break;
				}
			}
		}
	}
	int l = 0;
	int r = st.size() - 1;
	ll ans = 0;
	int sgn = 1;
	while (l <= r) {
		if (st[l] >= st[r])
			ans += sgn * st[l], ++l;
		else
			ans += sgn * st[r], --r;
		sgn *= -1;
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int A, B, X;
    
    scanf("%d %d %d", &A, &B, &X);
    
    if(X >= A && X-A <= B)
        printf("YES\n");
    else
        printf("NO\n");
    
    //system("pause");
    return 0;
}

Measured memory_bytes: 128
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#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 <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

#define grater cout<<"GREATER"<<endl;
#define lesser cout<<"LESS"<<endl;
#define eq cout<<"EQUAL"<<endl;

int main(){
 
    string A,B;
    cin>>A;
    cin>>B;

    if(A.size()>B.size()){
        grater;
        exit(0);
    }
    if(A.size()<B.size()){
        lesser;
        exit(0);
        
    }
    REP(i,A.size()){
        if(A[i]>B[i]){
            grater;
        exit(0);
        }
        else if(A[i]<B[i]){
            lesser;
        exit(0);
        }
    }
    eq;


}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <fstream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define DEBUG 1
#define ll         long long
#define REP(i, n) for (long long i = 0; i < (n); i++) 
const int MOD = 1000000007;

//10 100
//7 10 4 5 9 3 6 8 2 1

//高橋くんは、 4-9 か 3-8を行う
//どちらかわからないので、青木くんは9と8のコストを下げる

//右から見ていって、最大の差を求めればよい
//最大の差を求めた後は、

int main(){
    int N,T;
    cin >> N >> T;
    vector <int> a(N);
    REP(i,N)cin >> a[i];
    vector <vector<pair<int,int>>> sa(N);

    //(左から見ていって)現状の最小値
    int be_min = MOD;

    int sa_max = 0;
    for(int i = 0; i < N; ++i)
    {
        if(be_min < a[i])continue;
        be_min = a[i];
        for(int j = i + 1; j < N; ++j)
        {
            if(sa_max > a[j] - a[i])continue;
            sa_max = max(sa_max, a[j] - a[i]);
            sa[i].push_back({a[j] - a[i], j});
        }
    }

    vector <int> cost(N, 0);
    for(int i = 0; i < N; ++i)
    {
        if(sa[i].size() == 0)continue;
        sort(sa[i].rbegin(),sa[i].rend());

        for(int j = 0; j < sa[i].size(); ++j)
        {
            if(sa_max == sa[i][j].first)cost[sa[i][j].second] = 1;
            else
            {
                break;
            }
        }
    }

    int res = 0;
    for(int i = 0; i < N; ++i)
    {
        if(cost[i] == 1)++res;
    }
    cout << res << endl;
    return 0;

}

Measured memory_bytes: 4992