akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           ((ll)x.size())
#define hell            (1000000007)
#define inf             ((ll)5e18 + 5)
#define PI              ((double)3.14159265358979323844)
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll h, w, k;
    cin >> h >> w >> k;
    string s;
    ll arr[h][w];
    ll cnt=0;
    rep(i,0,h){
        cin >> s;
        rep(j,0,w){
            if (s[j]=='.')arr[i][j]=0;
            else {
                arr[i][j]=1;
                cnt++;
            }
        }
    }
    cnt=cnt-k;
    ll ans=0;
    rep(i,0,1<<h){
        rep(j,0,1<<w){
            ll temp=0;
            rep(x,0,h){
                if ((1<<x) & i){
                    rep(p,0,w){
                        if (arr[x][p])temp++;
                    }
                }
            }
            rep(y,0,w){
                if ((1<<y) & j){
                    rep(q,0,h){
                        if (arr[q][y] && !((1<<q) & i)){
                            temp++;
                        }
                    }
                }
            }
            if (temp==cnt)ans++;
        }
    }
    cout<<ans<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

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

int main() {
  int k,s,ans=0;
  cin>>k>>s;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      if(s-i-j>=0 &&s-i-j<=k){
        ans++;
      }
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
int main(){
int a=0,b=0,i,j,k,n;
scanf("%d",&n);
for(i=1;i<=n;i++){scanf("%d",&k);
if(k%4==0)a++;
else if(k%2==0)b++;
}
if((a*2+1>=n)||(a*2+b>=n))printf("Yes");
else printf("No");
return 0;
}



Measured memory_bytes: 256
def check(x, y)
  2.times do |z|
    4.times do
      return true if x == y
      a, b, c, d, e, f  = x
      x = z.zero? ? [e, a, c, d, f, b] : [d, b, a, f, e, c]
      c = x
      4.times do
        i, j, k, l, m, n = c
        c = [i, k, m, j, l, n]
        return true if c == y
      end
    end
  end
  false
end

ar = $<.read.split("\n").map(&:split).drop(1)
ar.size.times do |x|
  (x+1).upto(ar.size-1) do |y|
    (puts 'No')^exit if check(ar[x], ar[y])
  end
end
puts 'Yes'

Measured memory_bytes: 9976
#include <iostream>
#include <stack>
#define REP(i,n) for(int i = 1; i < n; i++)

using namespace std;

int main() {
	REP(i,10){
		REP(j,10){
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
}

Measured memory_bytes: 1116
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    ll n,d,x;
    cin>>n>>d>>x;
    V<ll> a(n);
    cinf(n,a);
    ll ans=x;
    rep(i,n){
        ll t=0;
        ll cnt=0;
        while(t*a[i]+1<=d){
            cnt++;
            t++;
        }
        ans+=cnt;
    }
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算の際にオーバーフローに注意せよ！(適切にmodをとれ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
ll ans(ll n)
{
	if(n==1)
	return 1;
	else
	return 1+2*(ans(n/2));
}

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll x;
    cin>>x;
    cout<<ans(x);
    
    
}

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

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define PI          3.14159265358979323846
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ld          long double
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
void tc(){
    ld a, b;
    cin >> a >> b;
    ll ans = a * b;
    cout << ans;
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--) tc();
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 105;
const int MOD = 1e9 + 7;
int dp[N][4][4][4];
void add(int &x, int b) {
    x+=b;
    x%=MOD;
}
int main() {
    int n;
    cin >> n;
    // A G C T
    // 0 1 2 3
    // 0 2 1 3
    // 1 0 2 3
    // 0 1 3 2
    // 0 3 1 2
    for(int l = 3; l <= n; l++) {
        for(int i = 0; i < 4; i++) {
            for(int j = 0; j < 4; j++) {
                for(int z = 0; z < 4; z++) {
                    if(l == 3) {
                        if(i==0 && j==1 && z==2) continue;
                        if(i==0 && j==2 && z==1) continue;
                        if(i==1 && j==0 && z==2) continue;
                        dp[l][i][j][z] = 1;
                        continue;
                    }
                    for(int k = 0; k < 4; k++) {
                        if(j==0 && z==1 && k==2) continue;
                        if(j==0 && z==2 && k==1) continue;
                        if(j==1 && z==0 && k==2) continue;
                        if(i==0 && j==1 && z==3 && k==2) continue;
                        if(i==0 && z==1 && k==2) continue;
                        add(dp[l][j][z][k], dp[l-1][i][j][z]);
                    }
                }
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < 4; i++) {
        for(int j = 0; j < 4; j++) {
            for(int z = 0; z < 4; z++) add(ans, dp[n][i][j][z]);
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n,m;
	scanf("%d",&n);
	scanf("%d",&m);
	
	int ans[3];
	
	switch(n){
		case 1:
			ans[0]=0;
			break;
			
		case 2:
			ans[0]=1;
			ans[1]=0;
			break;
			
		case 3:
			ans[0]=1;
			ans[1]=0;
			ans[2]=0;
			break;
	}
	
	int s,c;
	int count[3]={0,0,0};
	for(int i=0;i<m;i++){
		scanf("%d",&s);
		scanf("%d",&c);
		if(count[s-1]!=0&&ans[s-1]!=c){
			printf("-1");
			return 0;
		}
		ans[s-1]=c;
		count[s-1]++;
	}
	
	if(n!=1&&ans[0]==0){
		printf("-1");
		return 0;
	}
	
	for(int i=0;i<n;i++){
		printf("%d",ans[i]);
	}
	return 0;
}

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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n, k;
string s;

int qp(int a, int b)
{
	int res = 1;
	while (b)
	{
		if (b & 1) res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}

int C(int a, int b)
{
	int res = 1;
	for (int i = a; i > a - b; i -- ) res = res * i;
	for (int i = 1; i <= b; i ++ ) res = res / i;
	return res;
}

int main()
{
	cin >> s >> k;
	n = s.size();
	
	vector<int> num;
	for (int i = 0; i < n; i ++ ) num.PB(s[i] - '0');
	
	int res = 0, last = 0;
	for (int i = 0; i < n; i ++ )
	{
		int x = num[i];
		
		if (x)
		{
			res += C(n - i - 1, k - last) * qp(9, k - last);
			res += (x - 1) * C(n - i - 1, k - last - 1) * qp(9, k - last - 1);
			last ++ ;
		}
		
		if (last == k)
		{
			res ++ ;
			break;
		}
	}
	
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 3628
#!/usr/bin/env python3
import sys
import networkx as nx

def solve(N: int, M: int, H: "List[int]", A: "List[int]", B: "List[int]"):
    G = nx.Graph()

    nodes = [i for i in range(1, N+1)]
    G.add_nodes_from(nodes)

    edges = [(a,b) for a, b in zip(A, B)]
    G.add_edges_from(edges)

    visited = {}
    for i in range(1, N+1):
        if i in visited:
            continue

        neighbors = G.neighbors(i)

        # get best neighbors weight
        best_neighbor = 0
        for n in neighbors:
            best_neighbor = max(best_neighbor, H[n-1])

        if H[i-1] > best_neighbor:
            visited[i] = True
            for n in neighbors:
                visited[n-1] = False
        else:
            visited[i] = False
            
    cnt = 0
    for key, value in visited.items():
        if value: 
            cnt += 1

    print(cnt)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, H, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 170916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int N;
	cin >> N;

	int A[1001][1000];
	rep1(i, N) {
		rep(j, N - 1) cin >> A[i][j];
		A[i][N - 1] = 0;
	}
	int* k[1001];
	rep1(i, N) k[i] = A[i];
	int k2[1001] = {};
	k2[0] = 1e9;
	vector<int> V;
	rep1(i, N) V.pb(i);

	int kotae = 0;
	while (V.size()) {
		kotae++;
		vector<int> kari;
		for (auto v : V) {
			if (k2[v] < kotae) {
				int a = *k[v];
				if (k2[a] < kotae && *k[a] == v) {
					kari.pb(v);
					k[v]++;
					k2[v] = kotae;
					kari.pb(a);
					k[a]++;
					k2[a] = kotae;
				}
			}
		}
		swap(V, kari);
	}

	int OK = 1;
	rep1(i, N) if (k[i] - A[i] != N - 1) OK = 0;
	if (OK) co(kotae - 1);
	else co(-1);

	Would you please return 0;
}

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

bool check(int N, int arr[])
{
    rep(i, N)
    {
        if (arr[i] % 2 != 0)
            return false;
        arr[i] /= 2;
    }
    return true;
}

int main()
{
    int N;
    cin >> N;
    int arr[N];
    rep(i, N)
    {
        cin >> arr[i];
    }
    int j = 0;
    while (check(N, arr))
        j++;

    cout << j << endl;
}


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

using namespace std;

int main() {
  vector<long long> v(3);
  cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(), v.end());
  if(v[0] %2 == 0 || v[1]%2 ==0 || v[2] %2 == 0) {
    cout << 0 << endl;
  } else {
    cout << v[0]*v[1] << endl;
  }
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int r;
	scanf("%d",&r);
	double pi=acos(-1.0);
	printf("%.6f\n",2*pi*r);
	return 0;
}

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


using namespace std;

using ll = long long;


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

    map<ll, ll> len;
    for (ll i = 1; i < N; i++)
        len[i] = 0;

    ll cnt = 0;
    for (ll i = 1; i < N + 1; i++) {
        for (ll j = i + 1; j < N + 1; j++) {
            ll shortcut;
            shortcut = abs(X - i) + abs(Y - j) + 1;
            len[min(shortcut, j - i)]++;
        }
    }
    for (ll i = 1; i < N; i++)
        cout << len[i] << endl;

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reverse_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int mxN = 2e5;
const int mxW = 100;
double a[mxN+3]; int a1[mxN+3],a2[mxN+3];
int s[mxW+3][mxW+3];
int n;

int main()
{
	n = read();
	for(int i=1; i<=n; i++)
	{
		scanf("%lf",&a[i]); a[i] *= 1000000000.0; llong x = (llong)(a[i]+0.5);
		while(x%2==0) {a1[i]++; x/=2;} while(x%5==0) {a2[i]++; x/=5;}
		s[a1[i]][a2[i]]++;
	}
	llong ans = 0ll;
	for(int i=mxW; i>=0; i--) for(int j=mxW; j>=0; j--)
	{
		s[i][j] += s[i+1][j]+s[i][j+1]-s[i+1][j+1];
	}
	for(int i=1; i<=n; i++)
	{
		ans += s[max(0,18-a1[i])][max(0,18-a2[i])];
	}
	ans -= s[9][9];
	printf("%lld\n",ans/2ll);
	return 0;
}

Measured memory_bytes: 6944
N = int(input())
B = [int(_) for _ in input().split()]

A = [0] * N
A[0] = B[0]
A[N - 1] = B[N - 2]
for n in range(1, N - 1):
    A[n] = min(B[n - 1], B[n])
print(sum(A))

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; const ll MOD = 1000000007;
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; }

//---------------------------------------------------------------------------------------------------
void _main() {
    ll N, M, X; cin >> N >> M >> X;
    ll min_c = infl;
    vector<vector<ll>> ability(N+1, vector<ll>(M+2, 0));
    rep(i, 0, N) {
        rep(j, 0, M+1) cin >> ability[i][j];
    }

    rep(i, 0, 1 << N) {
        vector<ll> sum_ability(M+2,0);
        rep(j, 0, N) {
            if (i&(1<<j)) rep(k, 0, M+1) {
                sum_ability[k] += ability[j][k];
            }
        }
        bool res = true;
        rep(j, 1, M+1) {
            if(sum_ability[j] < X) res = false;
        }
        if (res) chmin(min_c, sum_ability[0]);
    }
    if (min_c == infl) min_c = -1;
    cout << min_c << endl;
}

Measured memory_bytes: 3656
#include <iostream>

#define u unsigned
#define s short
#define ll long long
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, a, b) for (int i = (a-1); i >= (b); i--)

using namespace std;

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

    int A[M];
    REP(i, 0, M)
    {
        cin >> A[i];
        N -= A[i];
    }

    cout << (N < 0 ? -1 : N) << "\n";

    return 0;
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    string T;
    cin >> T;
    if(T.length() == 1){
        if(T[0] == '?'){
            T[0] = 'D';
            cout << T << endl;
            return 0;
        }
    }
    if(T[0] == '?'){
        if(T[1] == 'P'){
            T[0] = 'D';
        }else{
            T[0] = 'P';
        }
    }
    for (int i = 1; i < T.size() - 1; i++){
        if(T[i] == '?'){
            if(T[i -1] == 'P'){
                T[i] = 'D';
            }
            else if (T[i + 1] == 'P')
            {
                T[i] = 'D';
            }else{
                T[i] = 'P';
            }
        }
    }
    if (T[T.size()-1] == '?')
    {
        T[T.size()-1] = 'D';
    }
    cout << T << endl;
    return 0;
}



Measured memory_bytes: 3696
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }

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

  unordered_map<char, ull> sss;
  each(i, s.size()) {
    if (sss.count(s[i]) == 0) {
      sss[s[i]] = 1;
    } else {
      sss[s[i]] = sss[s[i]] + 1;
    }
  }

  ull result = 0;
  for (auto& v : sss) {
    if (result == 0) {
      result = (v.second + 1);
    } else {
      result *= (v.second + 1);
      result %= mod;
    }
  }

  cout << (result - 1) % mod << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



template <typename T> T gcd(T a, T b) {if(b == 0) return a;return gcd(b,a%b);}
template <typename T> T extgcd(T a, T b, T& x, T& y){
    T d = a;
    if(b != 0){d = extgcd(b,a%b,y,x); y-=(a/b)*x;}
    else x=1,y=0;
    return d;
}
template <typename T> T modpow(T x, T n, T m) {
    if(n==0) return 1;
    T resp = modpow(x*x%m,n/2,mod);
    if(n&1) resp = resp*x%m;
    return resp;
}
template <typename T> T modinverse(T a, T m) {
    T x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
struct combination {
    ll M = mod;
    vector<ll> fact;vector<ll> ifact;
    combination(ll n):fact(n+1),ifact(n+1){
        fact[0]=1;ifact[0]=1;
        for (ll i = 0; i<n; i++) {fact[i+1] = fact[i]*(i+1) % M;ifact[i+1] = ifact[i]*modpow(i+1, M-2, M) % M;}
    }
    ll com(ll a, ll b){
        if(a == 0 && b == 0)return 1;if(a < b || a < 0)return 0;
        ll tmp = ifact[a-b]* ifact[b] % M;
        return tmp * fact[a] % M;
    }
};



int main()
{
    int N;
    cin >> N;
    vl x(N);
    in(N,x);
    
    
    combination C((ll)N);
    
    vl A(N);
    reps(i,1,N) A[i] = ((C.com(ll(N-1),ll(i)) * C.fact[N-1-i])%mod * C.fact[i-1])%mod;
    
    vl B(N);
    B[0] = 0;
    reps(i,1,N) B[i] = B[i-1]+A[i];
    
    ll ans = 0;
    reps(i,1,N){
        ans += ((x[i]-x[i-1])%mod)*B[i]%mod;
    }
    out(ans%mod);

    //outve(A);
    //outve(B);

    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;
	cin>>a>>b;
	cout<<max(0ll,a-b*2)<<endl;;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = n - 1; i >= 0; --i)

ll cs(ll n){
    return n * (n + 1) / 2;
}

int main(){
    ll n;
    cin >> n;
    cout << cs(n) - cs(n / 3) * 3 - cs(n / 5) * 5 + cs(n / 15) * 15 << endl;
    return 0;
}


Measured memory_bytes: 3636
# include <bits/stdc++.h>
# define ll long long
using namespace std;
const int N = 2e5 + 10;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	long long x, cur = 100, days = 0;
	cin >> x;
	for(days = 1;; days++){
		cur += cur / 100;
		if(cur >= x)break;
	}
	cout << days << '\n';
}

Measured memory_bytes: 3668
import sys
from math import sqrt
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    for n in range(1, N + 1):
        ans = 0
        #print("n={}".format(n))
        for x in range(1, 41):
            # x==yの時
            if n - 2*x*x >= 0:
                z0 = round(sqrt(n - 2*x*x) - x)
                for z in range(z0 - 2, z0 + 3):
                    if (x + z)**2 + 2*x*x == n:
                        if x == z:
                            #print(x, x, x)
                            ans += 1
                        elif x < z:
                            #print(x, x, z)
                            ans += 3
            # x < y <= zの時
            if n - x**2 >= 0:
                upper = round(sqrt((n - x**2) / 3) - x / 3) + 5
                for y in range(x+1, upper):
                    val = x**2 + x*y + y**2
                    if (x + y)**2 - 4 * (val - n) >= 0:
                        z0 = round((-(x+y) + sqrt((x + y)**2 - 4 * (val - n))) / 2)
                        for z in range(z0-2, z0+3):
                            if z**2 + (x + y)*z + val == n:
                                if y == z:
                                    #print(x, y, z)
                                    ans += 3
                                elif y < z:
                                    #print(x, y, z)
                                    ans += 6
        print(ans)




if __name__ == "__main__":
    main()


Measured memory_bytes: 76488
S = input ()
T = S.replace('A', '')
T = T.replace('C', '')
U = T.lower ()
if S[0]=='A' and S.count('A')==1 and S[2:-1].count('C')==1 and S.count('C')==1 and T==U:
  print ('AC')
else:
  print ('WA')

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

void solve_A(){
	int a,b;
	cin >> a >> b;
	if(a>=10||b>=10) cout << "-1" << endl;
	else cout << a*b << endl;
}

void solve_B(){
	bool s[105]={0};
	int n,i,j;
	cin >> n;
	for(i=1;i<=9;i++){
		for(j=1;j<=9;j++){
			s[i*j]=true;
		}
	}
	if(s[n]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void solve_C(){
	long long n,i,m=0;
	cin >> n;
	for(i=1;i*i<=n;i++){
		if(n%i==0) m=i;
	}
	cout << m+n/m-2 << endl;
}

void solve_D(){
	double a,b,x,ans;
	cin >> a >> b >> x;
	x /= a;
	if(x>=a*b/2){
		x -= a*b/2.0;
		x = 2.0*x/a;
		x = b-x;
		ans =atan(x/a);
	} else {
		x = 2.0*x/b;
		ans = atan(b/x);
	}
	ans = ans*180.0/3.1415926535897;
	printf("%.13lf\n",ans);
}


int main() {
	// your code goes here
	//solve_A();
	solve_B();
	//solve_C();
	//solve_D();
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    S = readline().rstrip().decode()
    if S == 'Sunny':
        print('Cloudy')
    elif S == 'Cloudy':
        print('Rainy')
    elif S == 'Rainy':
        print('Sunny')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};

//探索、更新にO(log n)
struct segment_tree{
    in init ; //　空いてる値はこれになる
    in n; //　n個のデータ
    vector<in> data; // データ置き場・n-1~2n-1に元データ

    //(個数、初期値)
    //初期化　nを2の累乗に直す  初期値は最も選ばれない値にする
    segment_tree(in a, in b) : init(b) {
        n = 1;
        while( n < a ) n *= 2;
        data.assign(n * 2 - 1,init);
    }

    //+とかにしてもいい、結合法則はいる
    //選ぶ方の決め方（ここでは小さい方）
    in which(in a, in b){
        if(a > b) return b;
        else return a;
    }

    // k番目をaに更新
    void update(in k, in a){
        k += n-1;
        data[k] = a;

        //下から上に更新
        while( k > 0 ){
            k = (k - 1) / 2;
            data[k] = which( data[k*2+1] , data[k*2+2] );
        }
    }

    // [a, b)の最小値を求める
    // 後ろのほうの引数は、計算の簡単のための引数。
    // kは節点の番号、l, rはその節点が[l, r)に対応づいていることを表す。
    // したがって、外からはquery(a, b, 0, 0, n)として呼ぶ。
    in query( in a, in b, in k, in l, in r){

        // [a, b)と[l, r)が交差しなければ、MAX_in
        if(r <= a || b <= l) return init;

        // [a, b)が[l, r)を完全に含んでいれば、この節点の値
        if(a <= l && r <= b) return data[k];

        // そうでなければ、2つの子の最小値
        in vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        in vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return which( vl, vr );
    }

    // 外から呼ぶとき用
    // [a, b)の最小値を求める
    in query( in a, in b){
        return query( a, b, 0, 0, n);
    }

    // a番目のデータを見る
    // query(a,a+1)で良くね？
    in look(in a){
        return data[a+n-1];
    }
};

int main(){
ios::sync_with_stdio(false);cin.tie(nullptr);
cout << fixed << setprecision(10);
    in n,q;
    cin>>n>>q;
    vector<P> a(q);
    in x,y,z;
    rep(i,q){
        cin>>x>>y;
        y -= 2;
        a[i]=P(x,y);
    } 
    
    segment_tree sg1(n-2,n-2),sg2(n-2,n-2);
    in cnt=(n-2)*(n-2);
    rep(i,q){
        tie(x,y)=a[i];

        if(x==1){
            z=sg1.query(y,n-2);
            cnt -= z;
            if(z>0 && sg2.look(z-1)>y) sg2.update(z-1,y);
        }
        else{
            z=sg2.query(y,n-2);
            cnt -= z;
            if(z>0 && sg1.look(z-1)>y) sg1.update(z-1,y);
        }
    }
    cout<<cnt<<endl;
}/*
./problem.exe
*/

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var num=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            Array.Sort(num);

            for (int i = 0; i < num.Length; i++)
            {
                if (i == 0) Console.Write(""+ num[i]);
                else Console.Write(" " + num[i]);
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9660
#include<stdio.h>
#define N 100000

void partition(int *,int ,int);
int n;
int main(){
  int A[N],p=0,i;
  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    scanf("%d",&A[i]);
  }
  partition(A,p,n-1);
  return 0;
}

void partition(int *A,int p,int r){
  int x,i,j,swap1,swap2;
  x = A[r];
  i = p-1;
  for(j=p ; j<r ; j++){
    if(A[j] <= x){
      i = i+1;
      swap1 = A[j];
      A[j] = A[i];
      A[i] = swap1;
    }
  }
  swap2 = A[i+1];
  A[i+1] = A[r];
  A[r] = swap2;
  
  for(j=0 ; j<i+1 ;j++){
    printf("%d ",A[j]);
  }
  printf("[%d] ",A[i+1]);
  
  for(j=i+2 ; j<n ; j++){
    if(j<n-1) printf("%d ",A[j]);
    else printf("%d\n",A[j]);
  }
  
}



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

int main()
{
    vector<int> a(3);
    for(auto& e: a) cin>>e;
    int res=0;
    for(; sort(begin(a), end(a)), a[0]!=a[2]; ++res)
        a[0]==a[1] ?  a[2]-- : a[0]+=2;
    cout<<res<<endl;
}


Measured memory_bytes: 256
module Enumerable
  def scan(init = 0)
    inject([init]) { |a, n| a << yield(a.last, n) }
  end

  def scan_right(init = 0)
    reverse_each.inject([init]) { |a, n| a.unshift yield(a.first, n) }
  end
end

n = gets.to_i
ns = gets.split.map(&:to_i)

ls = ns.scan(&:gcd)
rs = ns.scan_right(&:gcd)

p Array.new(n) { |i| ls[i].gcd rs[i + 1] }.max


Measured memory_bytes: 11212
A, B, C = map(int, input().split())

if A == 5 and B == 5 and C == 7:
    print("YES")
elif A == 5 and B == 7 and C == 5:
    print("YES")
elif A == 7 and B == 5 and C == 5:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9140
#include<bits/stdc++.h> //Mr_Mandal
#define PI_INT 3.14159265358979323846
#define PI acos(-1.0)
#define LL long long
#define N 100000007
#define MOD 10000007
#define MX numeric_limits<long long>::max();
#define MN numeric_limits<long long>::min();
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define FILL(v, n) fill(v.begin(), v.end(), n);
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PRINT(v) for(int i=0; i<v.size(); i++) cout<<v[i]<<" "; cout<<"\n";
#define RPRINT(v) for(int i=v.size()-1; i>=0; i--) cout<<v[i]<<" "; cout<<"\n";
#define SCAN(v) for(int i=0; i<n; i++) { int temp; cin>>temp; v.push_back(temp); }
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVE(v) reverse(v.begin(), v.end());
#define VECT(v) vector<int>v
#define SCF(f) scanf("%d", &f)
#define PNF(f) printf("%d\n", f)
#define CASEP(v) cout<<"Case "<<c<<": "<<v<<"\n"
#define TPOW(n) 1LL<<n;
 
using namespace std;
 
void solve()
{
	int a, b, c;
	cin >> a >> b >> c;

	int t;

	if(a%b==0) t=a/b;
	else
	{
		t=a/b;
		t++;
	}

	cout<<t*c<<"\n";
}
 
int main()
{
    
// #ifndef ONLINE_JUDGE
//     READ("input.txt");
//     WRITE("output.txt");
// #endif
 
    FAST_IO;
 
        solve();
 
    return 0;
}

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

int main(){
    int N;
    int Aonly = 0;
    int Bonly = 0;
    int AandB = 0;

    long count = 0;
    string s[10002];
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> s[i];
        int slen = s[i].length();
        for(int j=0;j<slen-1;j++){
            if(s[i][j] == 'A' && s[i][j+1] == 'B') count++;
        }
        if(s[i][0] == 'B'){
            if(s[i][slen-1] == 'A'){
                AandB++;
            }
            else{
                Bonly++;
            }
        }
        else{
            if(s[i][slen-1] == 'A'){
                Aonly++;
            }
        }
    }

    if(AandB == 0){
        count += min(Aonly, Bonly);
    }
    else{
        count += (AandB-1);
        if(Aonly != 0 || Bonly !=0){
            count += min(Aonly, Bonly) + 1;
        }
    }
    cout << count << endl;

    return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  if (A%3 == 0 || B%3 == 0 || (A+B)%3 == 0) cout <<"Possible" << endl;
  else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
$f{"A"} = 1;
$f{"C"} = 1;
$f{"G"} = 1;
$f{"T"} = 1;

$cnt = 0;
$max = 0;
for (split(//, <>)){
	if($f{$_} == 1){
		$cnt++;
	}else{
		$cnt = 0;
	}
	$max = $cnt if($cnt > $max);
}

print "$max\n";


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int ans=-1;
    map<int,int>m;
    r(i,n){
      int a;
      cin>>a;
      m[a]++;
      if(m[a]>n/2)ans=a;
    }
    if(ans==-1)cout<<"NO COLOR"<<endl;
    else cout<<ans<<endl;
  }
}


Measured memory_bytes: 4624
import sys

import numpy as np

readline = sys.stdin.buffer.readline


def moving_average(a, n=3) :
    ret = np.cumsum(a, dtype=float)
    ret[n:] = ret[n:] - ret[:-n]
    return ret[n - 1:]

def main():
    N, K = map(int, readline().split())
    p = np.array(readline().split(), dtype=np.int32)
    q = moving_average(p, K)

    print((np.max(q) + K) / 2)


main()


Measured memory_bytes: 22564
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,n,sum=0;
	cin>>h>>n;
	int a[n+1];
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	if(sum>=h) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i,n;cin>>n;
  vector<int> v(n);
  for(i=0;i<n;i++)cin>>v[i];
  sort(v.begin(),v.end());
  cout <<v[n-1]-v[0]<<endl;
  }

Measured memory_bytes: 256
import numpy as np
N, M = map(int, input().split())
d = np.zeros(N+1, dtype = 'int32')
t = 0
f = 0
for i in range(M):
    tmp = input().split()
    p = int(tmp[0])
    S = tmp[1]
    dp = d[p]
    if S == 'AC':
        if dp != -1:
            f += dp
            d[p] = -1
            t += 1
    elif dp != -1:
        d[p] += 1
print(t, f)


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

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, n) for (int i = a; i < n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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;
}

const int MOD = 1000000007;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

using Graph = vector<vector<int>>;

Graph G;

vector<bool> seen;
void dfs(const Graph &G, int v)
{
    seen[v] = true;

    for (auto next_v : G[v])
    {
        if (seen[next_v])
            continue;
        dfs(G, next_v);
    }
}

int main()
{

    ll n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> left_max(n);
    vector<int> right_max(n);

    for (int i = 1; i < n; i++)
    {
        left_max[i] = max(left_max[i - 1], a[i - 1]);
    }
    for (int i = n - 2; i >= 0; i--)
    {
        right_max[i] = max(right_max[i + 1], a[i + 1]);
    }
    rep(i, n)
    {
        cout << max(left_max[i], right_max[i]) << endl;
    }
}


Measured memory_bytes: 3968
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define eb emplace_back

typedef long long ll;
using namespace std;

int main(void){

    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> a(n);
    REP(i,n)cin >> a[i];
    sort(all(a));

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


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


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

	ll N ;
	cin >> N;
	cout << ((N<=999)?("ABC"):("ABD")) << endl;



	//cout << fixed << setprecision(16) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import numpy as np

N,M=list(map(int,input().split()))

A=np.zeros((N,M))

for i in range(N):
    AA=list(map(int,input().split()))
    AA.pop(0)

    for j in AA:
        A[i][j-1]=1

for i in range(N-1):
    A[0]=A[0]*A[i+1]

print(np.sum(A[0]==1))

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

int main(){

    ll N,P;
    cin>>N>>P;
    vector<ll> A(N);
    vector<vector<ll>> dp(50+10,vector<ll>(2,0));
    for(ll i=0; i<N; i++) cin>>A[i];

    dp[0][0] = 1;

    for(ll i=0; i<N; i++){
        if(A[i]%2 == 0){
            dp[i+1][0] = dp[i][0]*2;
            dp[i+1][1] = dp[i][1]*2;   
        }

        else if(A[i]%2 != 0){
            dp[i+1][0] = dp[i][0] + dp[i][1]; 
            dp[i+1][1] = dp[i][0] + dp[i][1];
        }
    }

    cout<<dp[N][P]<<endl;

    return 0;

}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    ans += a-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import itertools
import string


def main():
    h, w = (int(x) for x in input().split())
    table = [input().split() for _ in range(h)]
    snuke = None
    for i, j in itertools.product(range(h), range(w)):
        if table[i][j] == "snuke":
            snuke = i, j
            break
    ans = "{}{}".format(string.ascii_uppercase[snuke[1]], snuke[0] + 1)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4020
#include <iostream>

int main() {
	int num, train, tax;
	int result_a, result_b;
	std::cin >> num >> train >> tax;
	
	result_a = num * train;
	result_b = tax;
	
	if (result_a < result_b) {
		std::cout << result_a;
	} else {
		std::cout << result_b;
	}
	
	
	return 0;
}


Measured memory_bytes: 256
gets.to_i
A = gets.chomp.split(" ").map(&:to_i)

C = Hash.new{|h, k| h[k] = 0}
A.each{|a| C[a] += 1}
tmp = C.keys.sort
ans = tmp.map{|a| C[a-1] + C[a] + C[a+1]}

puts ans.max


Measured memory_bytes: 16272
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define il inline
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define rep0(i, n) for(int i = 0; i < (n); i ++)
#define per0(i, n) for(int i = (n) - 1; i >= 0; i --)
#define ept 1e-9
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
#define ALL(x) (x).begin(), (x).end()
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = 3e5 + 10, inf = 998244353;

int n, sum[N];

int main()
{
	n = read();
	rep(i, 1, n - 1)
	{
		int x = i;
		while(x)
		{
			sum[i] += x % 10;
			x /= 10;
		}
	}
	int ans = inf;
	rep(i, 1, n - 1) ans = min(ans, sum[i] + sum[n - i]);
	printf("%d\n", ans);
	return 0;
}


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

int main(){
  ll n;
  ll k;
  cin >> n >> k;
  vector<int> a(n), f(n);

  rep(i,n) cin >> a[i];
  rep(i,n) cin >> f[i];
  sort(f.begin(), f.end(),greater<int>());
  sort(a.begin(), a.end());
  
  auto ok = [&](ll m){
    ll cnt = 0;
    rep(i,n) {
      ll ret = m / f[i];
      cnt += max(0LL, a[i] - ret);
    }
    return cnt <= k;
  };

  ll l = -1, r = 1e18;
  while (r - l > 1) {
    ll mid = (r + l) / 2;
    if (ok(mid)) r = mid;
    else l = mid;
  }
  cout << r << endl;
  return 0;
} 

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <stack>
#include <math.h>
#include <stdio.h>
#define ll long long
#define anf 0x3f3f3f3f
using namespace std;
//char s[3]={'R','G','B'};
//int main()
//{
//    char str[11000];
//    int t;
//    cin>>t;
//    int n,k;
//    while(t--)
//    {
//        int num=0;
//        int mx=0;
//        cin>>n>>k;
//        for(int i=0;i<n;i++)
//            cin>>str[i];
//        for(int i=0;i<3;i++)
//        {
//            for(int j=0;j<n;j++)
//            {
//                if(j+k>n)
//                    break;
//                num=0;
//                int ii=i;int jj=j;
//                for(int l=0;l<k;l++)
//                {
//                    if(ii==3)
//                        ii=0;
//                    if(s[ii++]==str[jj++])
//                        num++;
//                }
//            mx=max(mx,num);
//            }
//        }
//        cout<<k-mx<<endl;
//    }
//    return 0;
//}
int main()
{
    ll n;
    stack<int>v;
    cin>>n;
    if(n==0)
        cout<<'0';
    while(n)
    {
        int a=abs(n%(-2));
        v.push(a);
        n=(n-a)/(-2);
    }
    while(!v.empty())
    {
        cout<<v.top();
        v.pop();
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i <n; i++)
#define INF 100000000;

int calc(long x, int r, int D){
    return r*x - D;
}

using namespace std;
int main(void){
    int r=0, D = 0;
    long x =0;
    cin >> r >> D >> x;
    rep(i, 10){
        x = calc(x, r, D);
        cout << x << endl;;
    }
    
}

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

long double A, B;
int n;

int main(){
	//freopen("abc169.inp", "r", stdin);
	//freopen("abc169.out", "w", stdout);
	cin>>A>>B;
	long long C = floor (A * B);
	cout<<C;
}	

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n),y(n);
  for(int i=0;i<n;i++){
    cin >> x.at(i) >> y.at(i);
  }
  double z=0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      z+=sqrt((x.at(i)-x.at(j))*(x.at(i)-x.at(j))
                    +(y.at(i)-y.at(j))*(y.at(i)-y.at(j)));
    }
  }
  cout << fixed << setprecision(12);
  cout << 2*z/n << endl;
}

Measured memory_bytes: 256