akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


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

  vector <ll> X(N), Y(M);
  for (int i = 0; i < N; i++) cin >> X[i];
  for (int i = 0; i < M; i++) cin >> Y[i];

  vector <ll> W(N - 1), H(M - 1);
  for (int i = 0; i < N - 1; i++){
    W[i] = X[i + 1] - X[i];
    W[i] %= nmax;
  }
  for (int i = 0; i < M - 1; i++){
    H[i] = Y[i + 1] - Y[i];
    H[i] %= nmax;
  }

  ll x = 0, y = 0;
  for (int i = 0; i < N - 1; i++){
    ll now = (i + 1) * (N - 1 - i) % nmax;
    x += W[i] * now % nmax; x %= nmax;
  }
  for (ll i = 0; i < M - 1; i++){
    ll now = (i + 1) * (M - 1 - i) % nmax;
    y += H[i] * now % nmax; y %= nmax;
  }

  cout << (x * y) % nmax << endl;

  return 0;
}

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

#define N 100010

int* Eratosthenes(){
    int* arr = new int[N];

    for(int i = 0; i < N; i++){
        arr[i] = 1;
    }
    for(int i = 2; i < sqrt(N); i++){
        if(arr[i]){
            for(int j = 0; i * (j + 2) < N; j++){
                arr[i *(j + 2)] = 0;
            }
        }
    }
    return arr;
}

int main() {

    int X;
    cin >> X;

    int* arr;
    arr = Eratosthenes();
    for (int i = X; i < 100010; i++) {
        if (arr[i]) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 640
a = int(input())
b = int(input())
c = int(input())
x = int(input())
inc =0

for i in range(a+1):
    for ii in range(b+1):
        for iii in range(c+1):
            if (i*500 + ii*100 + iii*50) == x:
                inc +=1

print(inc)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
ll n, m, d;
/******* define variable end *******/
int solve() {
	cin >> n >> m >> d;
	long double ans;
	if(d == 0){
		long double tmp = 1.0 + (1-d)/n;
		ans = pow(tmp, m-2) * (m-1) * (n-d) / n / n;
	}else{
		long double tmp = 1.0 + (1-d)/n;
		ans = pow(tmp, m-2) * 2 * (m-1) * (n-d) / n / n;
		//cout << ue << " " << sita << endl;
	}
	cout << ans << endl;
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

const long long INF = 1LL << 60;

int main() {
    int N, M, S;
    std::cin >> N >> M >> S;

    std::vector<std::vector<std::pair<int, int>>> g(N);
    std::vector<int> A(M);
    std::vector<long long> B(M);
    int A_max = 0;
    for (int i = 0; i < M; i++) {
        int U, V;
        std::cin >> U >> V >> A[i] >> B[i];
        U--;
        V--;
        g[U].push_back(std::make_pair(V, i));
        g[V].push_back(std::make_pair(U, i));
        A_max = std::max(A_max, A[i]);
    }

    std::vector<int> C(N);
    std::vector<long long> D(N);
    for (int i = 0; i < N; i++)
        std::cin >> C[i] >> D[i];

    int s_max = A_max * (N - 1);

    std::vector<
        std::vector<long long>
    > dist(N, std::vector<long long>(s_max + 1, INF));

    std::priority_queue<
        std::pair<long long, std::pair<int, int>>,
        std::vector<std::pair<long long, std::pair<int, int>>>,
        std::greater<std::pair<long long, std::pair<int, int>>>
    > que;

    {
        int r = std::min(s_max, S);

        dist[0][r] = 0;

        que.push(
            std::make_pair(
                0,
                std::make_pair(0, r)
            )
        );
    }

    while (!que.empty()) {
        auto p = que.top();
        que.pop();

        int t = p.first;
        int u = p.second.first;
        int s = p.second.second;

        for (auto q : g[u]) {
            int v = q.first;
            int i = q.second;

            if (s < A[i]) continue;

            int r = s - A[i];

            if (dist[u][s] + B[i] < dist[v][r]) {
                dist[v][r] = dist[u][s] + B[i];

                que.push(
                    std::make_pair(
                        dist[v][r],
                        std::make_pair(v, r)
                    )
                );
            }
        }

        {
            int r = std::min(s_max, s + C[u]);

            if (dist[u][s] + D[u] < dist[u][r]) {
                dist[u][r] = dist[u][s] + D[u];

                que.push(
                    std::make_pair(
                        dist[u][r],
                        std::make_pair(u, r)
                    )
                );
            }
        }
    }

    for (int i = 1; i < N; i++) {
        long long ans = INF;

        for (int j = 0; j <= s_max; j++)
            ans = std::min(ans, dist[i][j]);

        std::cout << ans << "\n";
    }
}

Measured memory_bytes: 6156
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<numeric>

using namespace std;

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

    if(a + b + c > 21) cout << "bust";
    else cout << "win";

}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define up(l,r,i) for(int i=l;i<=r;i++)
#define dn(l,r,i) for(int i=l;i>=r;i--)
#define jdg(x) (P[x]>=t)
//若某个数大于等于t,为1;否则为0
//因此随着t增大0越多 
using namespace std;

typedef long long LL;
const int INF =2147483647;
int qread(){
	int w=1,c,ret;
	while((c=getchar())> '9'||c< '0')
	w=(c=='-'?-1:1); ret=c-'0';
	while((c=getchar())>='0'&&c<='9')
	ret=ret*10+c-'0';
	return ret*w;
}
const int MAXN =2e5+3;
int P[MAXN],n,p=0,k=1;
bool chk(int t){
//	printf("%d ",t);up(1,n*2-1,i) printf("%d ",jdg(i)); puts("");
	up(1,n-1,i){
		if(jdg(n-i+1)==jdg(n-i)) return jdg(n-i+1);
		if(jdg(n+i-1)==jdg(n+i)) return jdg(n+i-1);
	}
	return jdg(1);
}
int calc(){
	while(k){
		if(chk(p+k)) p+=k,k<<=1;
		else k>>=1;
	}
	return p;
}
int main(){
	n=qread();
	up(1,2*n-1,i) P[i]=qread();
	printf("%d\n",calc());
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
const int maxn = 1005;
const int maxV = 5005;
const int INF = 0x3f3f3f3f;
using namespace std;
struct E{
	int to, nxt;
}e[maxn];
int head[maxn], tot = 0;
void addedge(int u, int v){
	e[++tot].to = v, e[tot].nxt = head[u];
	head[u] = tot;
}
int n, res[maxn], x[maxn];
int f[maxV];
void dfs(int cur){
	for (int i = head[cur]; i; i = e[i].nxt) dfs(e[i].to);
	for (int i = 0; i <= x[cur]; i++) f[i] = INF; f[0] = 0;
	for (int i = head[cur]; i; i = e[i].nxt){
		int v = e[i].to;
		for (int j = x[cur]; j >= 0; j--){
			int tmp = INF;
			if (j >= res[v]) tmp = min(tmp, f[j - res[v]] + x[v]);
			if (j >= x[v]) tmp = min(tmp, f[j - x[v]] + res[v]);
			f[j] = tmp;
		}
	}
	for (int i = 0; i <= x[cur]; i++) res[cur] = min(res[cur], f[i]);
}
int main(){
	scanf("%d", &n); memset(res, 0x3f, sizeof res);
	for (int f, i = 2; i <= n; i++){
		scanf("%d", &f); addedge(f, i);
	}
	for (int i = 1; i <= n; i++) scanf("%d", x + i);
	dfs(1);
	if (res[1] != INF) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
    ll n, m, ans = 0;
    scanf("%lld%lld", &n, &m);
    vector<ll> a(n + 1);
    map<ll, ll> d;
    ++d[0];
    for (ll i = 1; i <= n; ++i) scanf("%lld", &a.at(i)), a.at(i) += a.at(i - 1), ++d[a.at(i) % m];
    for (auto i = d.begin(); i != d.end(); ++i) ans += (*i).second * ((*i).second - 1) / 2;
    printf("%lld\n", ans);
    return 0;
}


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

int N, P;
int main() {
  scanf("%d%d", &N, &P);
  bool odd = false;
  for(int i = 0; i < N; ++i) {
    int A; scanf("%d", &A);
    if(A % 2 == 1) odd = true;
  }
  if(P == 1 && !odd) printf("0\n");
  else if(!odd) printf("%lld\n", 1LL << N);
  else printf("%lld\n", 1LL << (N - 1));
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

template<typename T>
struct Point {
  typedef Point<T> this_t;
  T x, y;
  Point(){}
  Point(T x, T y) : x(x), y(y) {}
  void read(const char* fs){ scanf(fs, &x, &y); }
  inline T dist(const this_t& a) const { return sq(x - a.x) + sq(y - a.y); }
};
typedef Point<int> Pi;

int bruteForse(Pi* P, int n)
{
  int mini = 1 << 30;
  for (int i = 0; i < n; i++){
    for (int j = i + 1; j < n; j++){
      mini = min(mini, P[i].dist(P[j]));
    }
  }
  return mini;
}
int stripClosest(Pi* strip, int n, int d)
{
  int mini = d;
  sort(strip, strip + n, [](const Pi& a, const Pi& b){ return a.y < b.y; });
  for (int i = 0; i < n; i++){
    for (int j = i + 1; j < n; j++){
      if (strip[j].y - strip[i].y >= mini) break;
      mini = min(mini, strip[i].dist(strip[j]));
    }
  }
  return mini;
}
int closestUtil(Pi* P, int n){
  if (n <= 3) return bruteForse(P, n);
  int mid = n >> 1;
  auto midp = P[mid];
  int L = closestUtil(P, mid);
  int R = closestUtil(P + mid, n - mid);
  int d = min(L, R);
  Pi strip[n];
  int sl = 0;
  for (int i = 0; i < n; i++){
    if (abs(P[i].x - midp.x) < d){
     strip[sl] = P[i];
     sl++;
    }
  }
  return min(d, stripClosest(strip, sl, d));
}
int closest(Pi* P, int n)
{
  sort(P, P + n, [](const Pi& a, const Pi& b){ return a.x < b.x; });
  return closestUtil(P, n);
}

Pi Pn[500500];
int main()
{
  int N = in();
  for (int i = 0; i < N; i++) Pn[i].read("%d%d");
  cout << closest(Pn, N) << endl;
  return 0;
}

Measured memory_bytes: 6184
import sys
input = sys.stdin.readline
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
d = {}
for i in range(n):
    d[int(input())] = 1

cand = [
    [[0, 0], [0, 1], [0,2]],
    [[1,0],[1,1],[1,2]],
    [[2,0],[2,1],[2,2]],
    [[0,0],[1,0],[2,0]],
    [[0,1],[1,1],[2,1]],
    [[0,2],[1,2],[2,2]],
    [[0,0],[1,1],[2,2]],
    [[0,2],[1,1],[2,0]],
]

f = 0
for item in cand:
    t = 0
    for x, y in item:
        if a[x][y] in d:
            t += 1
    if t == 3:
        f = 1
if f:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3188
#include<iostream>
#include<climits>

int count;

void merge(int*, int, int, int);
void mergeSort(int*, int, int);

using namespace std;

int main(){
  int i, n, s_in;
  int l, m, r;
  int S[500000];
  cin >> n;
  for(i=0;i<n;++i) cin >> S[i];
  mergeSort(&S[0], 0, n);

  for(i=0;i<n;++i){
    cout << S[i];
    if(i != n-1) cout << " ";
  }
  cout << "\n" << count << "\n";
  
  return 0;
}

void merge(int* A, int left, int mid, int right){
  int i, j;
  int n1 = mid - left, n2 = right - mid;
  int L[n1], R[n2];
  for(i=0;i < n1;++i) L[i] = A[left+i];
  for(i=0;i < n2;++i) R[i] = A[mid+i];
  L[n1] = INT_MAX, R[n2] = INT_MAX;
  
  i=0, j=0;
  for(int k=left;k < right;++k){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }else{
      A[k] = R[j];
      j++;
    }
    count++;
  }
}

void mergeSort(int* A, int left, int right){
  int mid;
  if(left+1 < right){
    mid = (left+right)/2;
    mergeSort(&A[0], left, mid);
    mergeSort(&A[0], mid, right);
    merge(&A[0], left, mid, right);
  }
}



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

typedef long long ll;
typedef vector<int> vi;

const double PI=acos(-1.0);

string S;
int input()
{   
    cin>>S;
}

int solve()
{   
    int N=S.length();
    int zero=0; int one=0;
    for(int i=0;i<N;++i){
        if(i%2){
            if(S[i]!='1') zero++;
            else one++;
        } else {
            if(S[i]!='0') zero++;
            else one++;
        }
    }
    cout<<min(zero,one)<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
  int main(void) {
   int A[2];
   int B[2];
   int C[2];
    for(int i=0;i<=2;i++){
      cin >> A[i];
    }
    
    B[0]=A[1];
    B[1]=A[0];
    B[2]=A[2];
    
    C[0]=B[2];
    C[1]=B[1];
    C[2]=B[0];
    
    //for(int j=0;j<=2;j++){
    //cout << B[j];
    //}
    
    cout<<C[0]<<" " <<C[1] <<" " <<C[2]<<" " ;

  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define ull unsigned long long int
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 1200005
#define MOD 1000000007
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define precise cout<<fixed<<setprecision(6)
using namespace std;
const double PI = atan(1.0)*4;
const int64_t INF=100000000000000003;
const int32_t LOG=21;
const int BIG=pow(2,20);
int32_t main(){
        // getFaster;
        int a,b;
        cin>>a>>b;
        if(a<=9 && b<=9)
        cout<<a*b<<endl;
        else
        cout<<-1<<endl;  
         return 0;
}

Measured memory_bytes: 256
import fractions
n,m = map(int,input().split())
a = list(map(int,input().split()))
g = a[0]
flag = 1
x = 0
y = 0

for i in range(n-1):
    z = fractions.gcd(g,a[i+1])
    x = g/z
    y = a[i+1]/z
    if x%2==1 and y%2==1:
        g = x*y*z
    else:
        print(0)
        flag = 0
        break

if flag==1:
    print(round((m+1)/g))

Measured memory_bytes: 16284
num = int(input())
arr = list(map(int,input().split()))
count = 0
ans = 1
for i in range(num):
    if arr[i] > ans:
        ans = arr[i]
    
    elif arr[i] == ans:
        pass
    
    elif ans - arr[i] >=2:
        count +=1
        break

if count ==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdlib>
#define ll long long
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define per(i, b, a) for(int i = (b); i >= (a); i--)
using namespace std;
const int N = 505, M = 250005;
int n, sum, b[N], ans[M], ssum[N];
struct node{
    int pl, num;
}a[N];
bool cmp(node x, node y){
    return x.num == y.num ? x.pl < y.pl : x.num < y.num;
}
int main(){
    scanf("%d", &n);
    rep(i, 1, n){
        scanf("%d", &b[i]);
        a[i].pl = i, a[i].num = b[i];
    }
    sort(a + 1, a + n + 1, cmp);
    rep(i, 1, n){
        sum += a[i].pl;
        if(a[i].num < sum || a[i].num == a[i-1].num) {
            printf("No\n");
            return 0;
        }
    }
    sum = 0;
    per(i, n, 1){
        sum += n - a[i].pl + 1;
        if(n * n - a[i].num + 1 < sum) {
            printf("No\n");
            return 0;
        } 
    }
    rep(i, 1, n){
        int num = a[i].pl - 1;
        ans[a[i].num] = a[i].pl, ssum[a[i].pl]++;
        rep(j, 1, a[i].num - 1) {
            if(!num) break;
            if(!ans[j]) ans[j] = a[i].pl, num--, ssum[a[i].pl]++;
        }
    }
    rep(i, 1, n) rep(j, b[i] + 1, n * n) {
        if(ssum[i] == n) break;
        if(!ans[j]) ans[j] = i, ssum[i]++;
    }
    printf("Yes\n");
    rep(i, 1, n * n) printf("%d ", ans[i]);
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <map>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  int n;
  cin >> n;
  map<string, int> mp;
  char before = '0';
  rep(i, n){
    string s;
    cin >> s;
    if(i == 0){
      mp[s] = 1;
      before = s[s.size()-1];
      continue;
    }
    if(before != s[0] || mp[s] > 0){
      cout << "No" << endl;
      return 0;
    }
    mp[s] = 1;
    before = s[s.size()-1];
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxx 100010
using namespace std;
int x,k,peso[maxx],dp[maxx];

int main() {
	cin >> x >> k;
	for(int i = 0; i < x; i++){
		cin >> peso[i];
		dp[i] = 1e9;
	}
	dp[0] = 0;
	dp[1] = abs(peso[1] - peso[0]);
	
	for(int i = 2; i < x; i++){
		for(int j = 1; j <= min(k,i); j++){
			dp[i] = min(dp[i-j] + abs(peso[i]-peso[i-j]),dp[i]);
		}
	}
	cout << dp[x-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
/*input
81
*/
/**
    Author: Kristopher Paul
    Date Created: 27-10-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int n;
    cin >> n;
    FOR(i,1,10){
        FOR(j,1,10){
            if(i*j == n){
                cout << "Yes" << endl;
                return;
            }
        }
    }
    cout << "No" << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 256
const main = (s) => {
const val = s.split("")
const base ='ATCG'
var count = 0
var hit = 0
val.forEach((ele,index) =>{
    if(base.includes(ele)){
    	count++
        if(val.length >= index){
          hit = count > hit?count:hit
        }
    }else{
      	hit = count > hit?count:hit
    	count = 0
    }
})
console.log(hit)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())

Measured memory_bytes: 7372
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from fractions import gcd

def readln():
    _res = list(map(int,str(input()).split(' ')))
    return _res

def readpic(n):
    res = [[0 for j in range(0,n)]for i in range(0,n)]
    for i in range(0,n):
        t = str(input())
        for j in range(0,n):
            if t[j] == '#':
                res[i][j] = 1
            else:
                res[i][j] = 0
    return res

def test(x,y):
    for i in range(0,m):
        for j in range(0,m):
            if b[i][j] != a[i+x][j+y]:
                return False
    return True

a = readln()
n,m = a[0],a[1]
a = readpic(n)
b = readpic(m)
ans = "No"
for i in range(0,n-m+1):
    for j in range(0,n-m+1):
        if test(i,j):
            ans = "Yes"
print(ans)


Measured memory_bytes: 5584
#include <iostream>
#include <vector>
#include <limits.h>
using namespace std;

int main(int argc, const char * argv[]) {
  int N;
  int minn=INT_MAX;
  int maxn=INT_MIN;
  int tmp;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>tmp;
    minn=min(minn,tmp);
    maxn=max(maxn,tmp);
  }
  cout<<maxn-minn;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main(){
  ll a,b,c,ab;
  cin >> a >> b >> c;
  ab = a+b;
  if (ab >= c) {
    cout << b+c;
  } else {
    cout << b + ab + 1;
  }
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

ll modpow(ll b, ll i){
  ll s=1;
  while(i){
    if(i%2) s=(s*b)%MOD;
    b=(b*b)%MOD; i/=2;
  }
  return s;
}
ll nCr(ll n, ll r){
  ll m1=1,m2=1; r=min(r,n-r);
  for(int i=0; i<r; i++){
    m1=(m1*(n-i))%MOD; m2=(m2*(r-i))%MOD;
  }
  return (m1*modpow(m2,MOD-2))%MOD;
}

void solve(){
  int n,k; cin >>n >>k;
  for(int i=0; i<k; i++){
    if(n-k<i) cout <<0<<endl;
    else cout <<nCr(k-1,i)*nCr(n-k+1,i+1)%MOD<<endl;
  }
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  solve();
return 0;}

Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>

int compf(const void *a, const void *b){
	return (*(int*)a - *(int*)b);
}

int main(){
  int n, k, input, sum = 0;
  scanf("%d %d", &n, &k);
  int list[n];
  
  for(int i = 0; i < n; i++)
  	scanf("%d", list+i);
  	
  qsort(list, n, sizeof(int), compf);
  
  for(int i = 0; i < k; i++)
  	sum += list[i];
  	
  printf("%d\n", sum);
    
  return 0;
}


Measured memory_bytes: 1744
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
map<int, int> factor(int m) {
	map<int, int>res;
	for (int i = 2; i*i <= m; i++) {
		while (m%i == 0) {
			res[i]++;
			m /= i;
		}
	}
	if (m != 1)res[m]++;
	return res;
}

/*--------Library Zone!--------*/

struct edge { int to, cost; };

int n, m, st, en;
vector<edge>yen[100005], snuke[100005];
int dye[100005], dsnu[100005];
void dijkstra() {
	//yen
	fill(dye, dye + n, inf);
	prique(P) yeque;
	dye[st] = 0;
	yeque.push({ 0,st });
	while (yeque.size()) {
		P p = yeque.top();
		yeque.pop();
		int v = p.second;
		if (dye[v] < p.first)continue;
		rep(i, yen[v].size()) {
			edge e = yen[v][i];
			if (dye[e.to] > dye[v] + e.cost) {
				dye[e.to] = dye[v] + e.cost;
				yeque.push({ dye[e.to],e.to });
			}
		}
	}
	//snuke
	fill(dsnu, dsnu + n, inf);
	prique(P)snuque;
	dsnu[en] = 0;
	snuque.push({ 0,en });
	while (snuque.size()) {
		P p = snuque.top(); snuque.pop();
		int v = p.second;
		if (dsnu[v] < p.first)continue;
		rep(i, snuke[v].size()) {
			edge e = snuke[v][i];
			if (dsnu[e.to] > dsnu[v] + e.cost) {
				dsnu[e.to] = dsnu[v] + e.cost;
				snuque.push({ dsnu[e.to],e.to });
			}
		}
	}
}
signed main() {
	cin >> n >> m >> st >> en;
	st--; en--;
	rep(i, m) {
		int from, t, y, s;
		cin >> from >> t >> y >> s;
		yen[from - 1].push_back({ t - 1,y });
		yen[t - 1].push_back({ from - 1,y });
		snuke[from - 1].push_back({ t - 1,s });
		snuke[t - 1].push_back({ from - 1,s });
	}
	dijkstra();
	prique(P)que;
	rep(i, n)que.push({ dye[i] + dsnu[i],i });
	rep(i, n) {
		P p;
		while (1) {
			p = que.top();
			if (p.second >= i)break;
			que.pop();
		}
		cout << (int)(pow(10, 15)) - p.first << endl;
	}
	endre;
}

Measured memory_bytes: 19904
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

bool solve(vector<int> v) {
  int minv = *min_element(v.begin(), v.end());
  int maxv = *max_element(v.begin(), v.end());

  if (minv < maxv - 1) {
    return false;
  }

  int cnta, cntb;
  cnta = cntb = 0;
  for (int x : v) {
    if (x == maxv) {
      cntb++;
    } else {
      cnta++;
    }
  }

  if (cnta >= maxv) {
    return false;
  }

  if (cnta == 0 && cntb == maxv + 1) {
    return true;
  }

  int b_cols = maxv - cnta;
  int min_cntb = b_cols * 2;
  return cntb >= min_cntb;
}

int main() {
#ifdef LOCAL
  freopen("b.in", "r", stdin);
  freopen("b.out", "w", stdout);
#endif

  int n;
  while (scanf("%d", &n) == 1) {
    vector<int> v(n);
    for (int &x : v) {
      scanf("%d", &x);
    }
    bool res = solve(v);
    printf("%s\n", res ? "Yes" : "No");
  }

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int A[200001],B[100001];
long long w,w1,w2;
int main() {
	int a,i,j;
	cin>>a;
	for(i=1;i<=a;i++)cin>>A[i],w+=A[i],A[i+a]=A[i];
	for(i=2;i<=a;i+=2)w1+=2*A[i];
	for(i=1;i<=a;i+=2)B[i]=w-w1,w1-=2*A[i+1],w1+=2*A[i+a];
	for(i=3;i<=a+1;i+=2)w2+=2*A[i];
	for(i=2;i<=a;i+=2)B[i]=w-w2,w2-=2*A[i+1],w2+=2*A[i+a];
	for(i=1;i<=a;i++)cout<<B[i]<<" ";
}

Measured memory_bytes: 2432
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, m) = (v[0], v[1]);
    let mut k = vec![Vec::new(); n];
    for i in 0..n {
        k[i] = read_vec::<usize>().into_iter().skip(1).collect::<Vec<_>>();
    }
    let mut speaker_dict = HashMap::new();
    for i in 0..n {
        for j in 0..k[i].len() {
            speaker_dict.entry(k[i][j]).or_insert(Vec::new()).push(i);
        }
    }

    let mut que = std::collections::VecDeque::new();
    que.push_back(0);
    let mut checked = vec![false; n];
    let mut lang_checked = HashSet::new();

    while let Some(cur_speaker) = que.pop_front() {
        checked[cur_speaker] = true;
        for j in 0..k[cur_speaker].len() {
            let lang = k[cur_speaker][j];
            if lang_checked.contains(&lang) {
                continue;
            }
            lang_checked.insert(lang);
            for &speaker in speaker_dict[&lang].iter() {
                if !checked[speaker] {
                    que.push_back(speaker);
                }
            }
        }
    }

    if checked.iter().all(|&x| x) {
        println!("YES");
    } else {
        println!("NO");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 17716
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		if (a+b >= 10){
			System.out.println("error");
	    }
	    else {
			System.out.println(a+b);
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main()
{   
    int n,k;
    cin >> n >> k;
    vector<bool> people(n,false);
    for(int i=0;i<k;i++){
        int d;
        cin >> d;
        for(int j=0;j<d;j++){
            int p;
            cin >> p;
            people[p-1]=true;
        }
    }
    
    int cnt=0;
    for(int p=0;p<n;p++){
        if(!people[p]){
            cnt++;
        }
    }

    cout << cnt;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;

int main() {
	string S, T;
	cin >> S >> T;
	map<char, int>Sa, Ta;
	int sp = 1, tp = 1;
	for (size_t i = 0; i < S.size(); i++)
	{
		if (!Sa[S.at(i)]) {
			Sa[S.at(i)] = sp;
			sp++;
		}
		if (!Ta[T.at(i)]) {
			Ta[T.at(i)] = tp;
			tp++;
		}
		S.at(i) = Sa.at(S.at(i));
		T.at(i) = Ta.at(T.at(i));
	}
	if (S == T)cout << "Yes";
	else cout << "No";
}

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

int main()
{
    int ac = 0, wa = 0, tle = 0, re = 0, n, i;
    string s;

    cin >> n;

    for (i = 0; i < n; i++)
    {
        cin >> s;

        if (s == "AC")
        {
            ac++;
        }
        else if (s == "WA")
        {
            wa++;
        }
        else if (s == "TLE")
        {
            tle++;
        }
        else
        {
            re++;
        }
    }

    for (i = 0; i < 4; i++)
    {
        if (i == 0)
        {
            cout << "AC x " << ac << "\n";
        }
        else if (i == 1)
        {
            cout << "WA x " << wa << "\n";
        }
        else if (i == 2)
        {
            cout << "TLE x " << tle << "\n";
        }
        else
        {
            cout << "RE x " << re << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    string s, t; cin >> s;
    for(int i = s.size()-1; i >= 0; i--){
        char c = s[i];
        if(s[i] == 'b') c = 'd';
        if(s[i] == 'd') c = 'b';
        if(s[i] == 'p') c = 'q';
        if(s[i] == 'q') c = 'p';
        t += c;
    }
    cout << (s == t ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3744
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;



int main(void)
{
	//変数の宣言
	int r,g,b,n;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;



	//データの読み込み


	scanf("%d %d %d %d",&r,&g,&b,&n);
//	scanf_s("%d %d %d %d",&r,&g,&b,&n);


	//	scanf("%s",&s);
	//	scanf_s("%s",&s,200010);

//	scanf("%c",&dummy);
//	scanf_s("%c",&dummy);


/*	for(i=0;i<n;i++){
//		scanf("%d",&s[i]);
		scanf_s("%d",&s[i]);
	}*/

/*	for(i=0;i<n;i++){
//		scanf("%c",&t[i]);
		scanf_s("%c",&t[i]);
	}*/

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	for(i=0;i*r<=n;i++){
		for(j=0;i*r+j*g<=n;j++){
			if((n-i*r-j*g)%b==0){
				ans++;
			}
		}
	}

	
	//	printf("計算部分終了\n");

	//出力

	printf("%d",ans);

//C	printf("\nL=%d,R=%d,D=%d,U=%d\n",L,R,D,U);

	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 256
function Main(input) {
	console.log(input.split("\n")[0].indexOf("YAKI")===0?"Yes":"No");
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int a, b, q;
    cin >> a >> b >> q;
    vector<int> s(a + 2), t(b + 2);
    s[0] = -INF, s[a + 1] = INF, t[0] = -INF, t[b + 1] = INF;
    rep(i, a) cin >> s[i + 1];
    rep(i, b) cin >> t[i + 1];
    rep(i, q)
    {
        int x;
        cin >> x;
        int num1 = upper_bound(all(s), x) - s.begin(), num2 = upper_bound(all(t), x) - t.begin();
        int d1[2] = {s[num1], s[num1 - 1]}, d2[2] = {t[num2], t[num2 - 1]};
        int ans = INF;
        rep(j, 2) rep(k, 2)
        {
            int tmp = min(abs(x - d1[j]) + abs(d1[j] - d2[k]), abs(x - d2[k]) + abs(d1[j] - d2[k]));
            ans = min(ans, tmp);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 2944
#!/usr/bin/env python3
import sys
from collections import deque

rl = sys.stdin.buffer.readline
INF = sys.maxsize

X = int(rl())
SS = [c for c in rl().strip()]

W = ord(b'W')
R = ord(b'R')

WP = []
RP = []
for i in range(len(SS)):
  if SS[i] == W:
    WP.append(i)
  elif SS[i] == R:
    RP.append(i)

RP.reverse()

WP = deque(WP)
RP = deque(RP)

sc = 0
while len(WP) != 0 and len(RP) != 0:
  w = WP.popleft()
  r = RP.popleft()
  if w < r:
    sc += 1

print(sc)

Measured memory_bytes: 97760
#include <iostream>
#include <cstring>

using namespace std;

const int D = 1e3;

int main() {
    int n, c;
    cin >> n >> c;
    int d[c][c];
    for (int i = 0; i < c; i++) {
        for (int j = 0; j < c; j++) {
            cin >> d[i][j];
        }
    }

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

    int cnt[3][c];
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cnt[(i+j)%3][a[i][j]]++;
        }
    }

    int ans = D * n * n;
    for (int x = 0; x < c; x++) {
        for (int y = 0; y < c; y++) {
            for (int z = 0; z < c; z++) {
                if (x != y && y != z && z != x) {
                    int cur = 0;
                    for (int t = 0; t < c; t++) {
                        cur += cnt[0][t] * d[t][x] * (t != x);
                        cur += cnt[1][t] * d[t][y] * (t != y);
                        cur += cnt[2][t] * d[t][z] * (t != z);
                    }

                    ans = cur < ans ? cur : ans;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1280
# -*- coding: utf-8 -*-
def main():
    StringS,StringT = input().split();
    StringA,StringB = input().split();
    StringU = input();

    wkA=int(StringA);
    wkB=int(StringB);
    if StringU == StringS :
        wkA = wkA - 1;
    else:
        wkB = wkB - 1;
    print(wkA);
    print(wkB);

main()


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;

int main(void){
    int N,K;
    int d;
    cin >> N >> K;
    vector<int> sunuke(N,0);
    for(int i =0; i < K; i++){
        cin >> d;
        for(int j = 0; j < d; j++){
            int tmp;
            cin >> tmp;
            sunuke[tmp -1]++;
        }
    }
    int sum = 0;
    for(int i = 0; i < sunuke.size();   i++){
        if(sunuke[i] == 0) sum++;
    }
    cout << sum << endl;
    return 0;

}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define ll long long

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

    ll n;
    cin >> n;
    ll res = 0, m = 1;
    while (n) {
        n >>= 1;
        res += m;
        m <<= 1;
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,x,r=1<<29;
    for(scanf("%d",&n);n>0;n--)
	{
        int r0=0;
        scanf("%d",&x);
        while(x%2<1)
		{
			r0++;
			x/=2;
		}
        if(r>r0)
		{
			r=r0;
		}
    }
    printf("%d\n",r);
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll X;
  IN(X);

  ll H500=0, H5=0;
  H500 = X/500;
  X -= H500 * 500;
  H500 *= 1000;
  H5 = X/5;
  H5 *= 5;
  OUT(H5+H500);

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
 
	// ??°????????\???????????°
	int height, width;
 
	// ???????????????
	while(1) {
 
		scanf("%d %d", &height, &width);
 
		if(height == 0 && width == 0)
			break;
 
		for(int line = 1; line <= height; line++) {
			
			if(line == 1 || line == height) {
				
				for(int column = 1; column <= width; column++) {
					
					if(column == width) {
						
						printf("#\n");
						
					} else {
						
						printf("#");
					}
				}
				
			} else {
				
				printf("#");
 
				for(int column = 1; column <= width-2; column++) {

					printf(".");
 
				}
 
				printf("#\n");
			}
		}
		printf("\n");
	}
  	return 0;
}

Measured memory_bytes: 1784
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
/*ll mod(ll a) 
{ 
    ll m=1000000007;
    cout << (a%m + m) % m; 
}*/
int main()
{
    ll k=1000000007;
    ll r,c; cin >> r >> c;
    ll dp[r][c];
    char a[r][c];
    memset(dp,-1,sizeof(dp));
    for(ll i=0;i<r;i++)
    {
        for(ll j=0;j<c;j++)
        {
            cin >> a[i][j];
            if(a[i][j]=='#')
            {
                dp[i][j]=0;
            }
        }
    }
    dp[0][0]=1;
    for(ll i=1;i<r;i++)
    {
        if(dp[i][0]!=0)
        {
            dp[i][0]=dp[i-1][0]%k;
        }
    }
    for(ll i=1;i<c;i++)
    {
        if(dp[0][i]!=0)
        {
            dp[0][i]=dp[0][i-1]%k;
        }
    }
    for(ll i=1;i<r;i++)
    {
        for(ll j=1;j<c;j++)
        {
            if(dp[i][j]!=0)
            {
                ll sum=dp[i-1][j]+dp[i][j-1];
                dp[i][j]=sum%k;
            }
        }
    }
    cout << dp[r-1][c-1];
    /*if(dp[r-1][c-1]<k)
    {
        cout << dp[r-1][c-1];
    }
    else
    {
         mod(dp[r-1][c-1]);
    }*/
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 3e6 + 5;
const int mod = 1e9 + 7;
int a[maxn];
int main(){
	string s;
	int n;
	cin >> n;
	int ans = 1;
	cin >> s;
	for (int i = 1; i < s.size(); i++){
		if (s[i] != s[i - 1]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
A = list(input().upper())
B = list(input().upper())
C = list(input().upper())
card = {'A':A, 'B':B, 'C':C}

def play(player, card):
    next_player = card[player].pop(0)
    return next_player, card


player = 'A'
while True:
    player, card = play(player, card)
    if not card[player]:
        print(player)
        break

Measured memory_bytes: 3064
def main():
    S = input()
    le = len(S) - 1
    while le > 0:
        if len(S[:le]) % 2 == 0:
            mid = le // 2
            if S[:mid] == S[mid:le]:
                break
        le -= 1

    print(le)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  string s;
  int k;
  cin >> s >> k;

  char past;
  int cnt = 1;
  int ans = 0;
  int right = -1, left = -1;

  int i = 0;
  while(s[i] == s[0]){
    i++;
    right++;
  }
  i = s.size()-1;

  while(s[s.size()-1] == s[i]){
    i--;
    left++;
  }

  int res = 0;
  if(s[s.size()-1] == s[0] && right == s.size()-1){
    cout << (right+1)*k/2 << endl;
    return 0;
  }else if(s[s.size()-1] == s[0]){
    cnt = right+left+2;
    res = cnt/2*(k-1);
    res += (right+1)/2;
    res += (left+1)/2;
  }else{
    cnt = right+1;
    ans += cnt/2;
    cnt = left+1;
    ans += cnt/2;
  }
  cnt = 1;


  for(i = right; i < s.size()-left; i++){
    if(i >= s.size()-left) break;

    if(i == right){
      past = s[i];
      continue;
    }

    if(s[i] == past){
      cnt++;
    }else{
      ans += cnt/2;
      cnt = 1;
    }
    past = s[i];
  }

  cout << ans*k+res << endl;

  return 0;
}

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

void solve(long long N, std::vector<long long> H){
  long long cnt = 0;
  unordered_map<long, long> m1, m2;
  // I < J, I = i + H[i], J = j - H[j]を満たすi, jを探せば良い
  for (long long i=0; i<N; i++) {
    cnt += m1[i+H[i]];
    cnt += m2[i-H[i]];
    m2[i+H[i]]++;
    m1[i-H[i]]++;
  }
  cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> H(N);
    for(long long i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, std::move(H));
    return 0;
}


Measured memory_bytes: 35604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
 
int main() {
  REP(i, 5) {
    int x;
    cin >> x;
    if(x==0) {
      cout << i+1 << endl;
      break;
    }
  }
}


Measured memory_bytes: 3564
import math
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
d1 = 0
d2 = 0
d3 = 0
dmax = 0
for i in range(n):
  d1 += abs(x[i] - y[i])
  d2 += abs(x[i] - y[i])**2
  d3 += abs(x[i] - y[i])**3
  if dmax < abs(x[i] - y[i]):
    dmax = abs(x[i] - y[i])
print(d1)
print(math.sqrt(d2))
print(d3**(1.0/3.0))
print(dmax)


Measured memory_bytes: 5692