akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
struct p {
	int x, y;
	int indx;
};
const int N = 1e5 + 5;
p points[N];
int n;
int par[N];
int get(int n) {
	if (par[n] == n) return n;
	return par[n] = get(par[n]);
}
vector<int> g[N];
void solve() {
	for (int i = 0; i < N; i++)
		par[i] = i;
	vector<pair<int, pair<int, int> >> edg;
	for (int i = 0; i < n; i++) {
//		g[i].clear();
//		g[i].resize(n);
		for (int j = 0; j < g[i].size(); j++) {
//			g[i][j] = j;
			int v = g[i][j];
			ll c = min(abs(points[i].x - points[v].x),
					abs(points[i].y - points[v].y));
			edg.push_back(make_pair(c, make_pair(i, v)));
		}
	}
	sort(edg.begin(), edg.end());
	ll ans = 0;
	for (int i = 0; i < edg.size(); i++) {
		int u = edg[i].second.first;
		int v = edg[i].second.second;
		int r1 = get(u);
		int r2 = get(v);
		if (r1 == r2) continue;
		//cout << u << "  " << v << endl;
		ans += edg[i].first;
		par[r1] = r2;
	}
	cout << ans << endl;
}
void gen(vector<pair<int, int> > &a, vector<pair<int, int> > &b) {

	sort(b.begin(), b.end());

	for (int i = 0; i < a.size(); i++) {

		auto it = lower_bound(b.begin(), b.end(), make_pair(a[i].first, -1));
		if (it != b.end()) {
			g[a[i].second].push_back(it->second);
			g[it->second].push_back(a[i].second);
		}
		if (it != b.begin()) {
			it--;

			g[a[i].second].push_back(it->second);
			g[it->second].push_back(a[i].second);
		}
	}
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	vector<pair<int, pair<int, int> > > v;
	for (int i = 0; i < n; i++) {
		cin >> points[i].x >> points[i].y;
		points[i].indx = i;
		v.push_back(make_pair(points[i].x, make_pair(points[i].y, i)));
	}
	sort(v.begin(), v.end());
	vector<pair<int, int> > last, cur;
	for (int i = 0; i < n;) {
		int X = v[i].first;
		while (i < n && v[i].first == X) {
			cur.push_back(v[i].second);
			i++;
		}
		if (last.size()) gen(last, cur);
		last = cur;
		cur.clear();
	}
	for (int i = 0; i + 1 < n; i++) {
		int u = v[i].second.second;
		int V = v[i + 1].second.second;
		g[u].push_back(V);
		g[V].push_back(u);
	}
	for (int i = 0; i < n; i++)
		swap(v[i].first, v[i].second.first);
	last.clear();
	sort(v.begin(), v.end());
	for (int i = 0; i < n;) {
		int X = v[i].first;

		while (i < n && v[i].first == X) {
			cur.push_back(v[i].second);
			i++;
		}
		if (last.size()) gen(last, cur);
		last = cur;
		cur.clear();
	}
	for (int i = 0; i + 1 < n; i++) {
		int u = v[i].second.second;
		int V = v[i + 1].second.second;
		g[u].push_back(V);
		g[V].push_back(u);
	}

	solve();
	return 0;
}


Measured memory_bytes: 39144
#include<bits/stdc++.h>
            #define REP(i,n) for(int i=0;i<n;i++)
            #define LOOP(i,x,n) for(int i=x;i<n;i++)
            #define ALL(v) (v).begin(),(v).end()
            #define PB push_back
            #define MP make_pair
            #define FIR first
            #define UB upper_bound
            #define LB lower_bound
            #define int long long
            using namespace std;
            const int MOD=1000000007;
            const int INF=1000000009;
             
            signed main(){
              int n,k;
              cin>>n>>k;
              vector<int> a(n+1),b(n+1);
             
              int tmp=1;
              REP(i,n){
                int a=tmp*2;
                int b=tmp+k;
                tmp=min(a,b);
              }
              cout<<tmp<<endl;
              return 0;
            }

Measured memory_bytes: 256
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

int n, r;

int main() {
  init_ios();
  cin >> n >> r;
  if (n >= 10) {
    cout<<r<<"\n";
    return 0;
  }
  cout<<r+100*(10-n)<<"\n";
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	int a = (n / 10) % 111;
	int b = n % 1000 % 111;
	if (a == 0 || b == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def makeFibonacci(n):
    if n <= 1:
        return str(1)
    F = [None]*(n+1)
    F[0] = 1
    F[1] = 1
    for i in range(2, n+1):
        F[i] = F[i-1] + F[i - 2]
    return str(F[n])

n = int(input())
print(makeFibonacci(n))

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int cnt[4][3][10];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    rep(i,n){
        int b,f,r,v; cin>>b>>f>>r>>v;
        b--; f--; r--;
        cnt[b][f][r]+=v;
    }
    rep(i,4){
        if (i!=0) cout<<"####################\n";
        rep(j,3){
            rep(k,10) cout<<" "<<cnt[i][j][k];
            cout<<"\n";
        }
    }
    return 0;
}



Measured memory_bytes: 3180
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

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

int main() {
    ll A,B;
    cin >> A >> B;
    map<ll,ll> mp;
    vector<ll> v;
    ll a = A;
    ll out = 1;
    while(a!=1){
        for(ll i=2;i<=sqrt(A);i++){
            if(a%i==0){
                a /= i;
                if(!mp.count(i)){
                    mp.emplace(i,i);
                    v.push_back(i);
                }
                break;
            }else if(i==(ll)sqrt(A)){
                if(!mp.count(a)){
                    mp.emplace(a,a);
                    v.push_back(a);
                }
                a /= a;
                break;
            }
        }
    }
    rep(i,v.size()){
        if(B%mp[v[i]]==0) out++;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
H = [int(i) for i in input().split()]

K=min(K,N-1)
dp = [10**10]*N
dp[0] = 0
for i in range(1,K):
  for j in range(0,i):
    dp[i] = min(dp[i],dp[j]+abs(H[i]-H[j]))
for i in range(K,N):
  for j in range(i-K,i):
    dp[i] = min(dp[i],dp[j]+abs(H[i]-H[j]))
print(dp[-1])


Measured memory_bytes: 52448
#include<iostream>
#include<algorithm>
#define LL long long 
LL H, W, A, B;
LL mod = 1000000007;
LL mul[200010];
LL dis[200010];
LL ans;
LL fermat(LL x, LL y) {
	//std::cout << y << std::endl;
	if (y == 0) return 1;
	if (y == 1)	return x;
	if (y % 2 == 1) {
		LL F = fermat(x, y / 2);
		F *= F;
		F%=mod;
		return F*x%mod;
	}
	if (y % 2 == 0) {
		LL F = fermat(x, y / 2);
		F *= F;
		return F%mod;
	}
}

int main() {
	std::cin >> H >> W >> A >> B;
	mul[1] = 1;
	mul[0] = 1;
	for (LL i = 1; i <= H + W - 2; i++) {
		mul[i] = mul[i - 1] * i;
		mul[i]%=mod;
	}
	dis[H + W - 2] = fermat(mul[H + W - 2], mod - 2);
	for (LL i = H + W - 3; i > 0; i--) {
		dis[i] = dis[i + 1] * (i + 1);
		dis[i] %= mod;
	}
	dis[0] = 1;
	for (LL i = B; i < W; i++) {
		LL plus = mul[H - A + i - 1] * dis[i];
		plus %= mod;
		plus *= dis[H - A - 1];
		plus %= mod;
		LL plus2 = mul[W + A - i - 2] * dis[A - 1];
		plus2 %= mod;
		plus2 *= dis[W - i - 1];
		plus2 %= mod;
		ans += plus*plus2;
		ans %= mod;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
#include<math.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
int main(){
    int n,d; cin >> n >> d;
    int x[n][d];
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin >> x[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            int sum=0;
            for(int k=0;k<d;k++){
                sum += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            int l=sqrt(sum);
            if(l*l == sum) ans++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>

using namespace std;

int main()
{
	int n;
	long long m;

	scanf("%lld %d", &m, &n);

	long long sum = 0;

	for (int i = 0; i < n; i++)
	{
		long long input;

		scanf("%lld", &input);

		sum += input;
	}

	if (m >= sum)
	{
		printf("%lld\n", m - sum);
	}

	else
	{
		printf("-1\n");
	}

	return 0;
}

Measured memory_bytes: 1728
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a>=1 && a<=100) && (b>=1 && b<=100) &&  (c>=1 && c<=100) )
       {




    if(a!=b && a!=c && b!=c)
    {
        cout<<"3";
    }
    else if((a==b && b!=c) || (a==c && b!=c))
    {
         cout<<"2";

    }
    else if((b==c && b!=a) )
    {
         cout<<"2";

    }
    else if(a==b && b==c)
    {
         cout<<"1";

    }

       }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong(); 
		long sum = 0;
		for(long i = 1; i <= n; i++) {
			if (i % 3 != 0 && i % 5 != 0)sum += i;
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 35724
#include <iostream>
#include <stdio.h>
#include <string.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define MIN(a,b) ((a)>(b)?(b):(a))
#define MAX(a,b) ((a)>(b))?(a):(b)
using namespace std;
int n,m=0,s[105],f[2][100005];
int duyet(bool ok, int S){
    if (S==0){
        if (ok) return 0;
        return 1;
    }
    if (f[bool(ok)][S]!=-1) return (f[bool(ok)][S]);
    int mi=1, ma=0,x;
    FOR(i,0,m)
        if (S>=s[i]){
            x=duyet(!ok,S-s[i]);
            mi=MIN(mi,x);
            ma=MAX(ma,x);
        }
    if (ok) return (f[bool(ok)][S]=ma);
    else return (f[bool(ok)][S]=mi);
}
int main()
{
    cin>>m>>n;
    for(int i=0;i<m;i++) cin>>s[i];
    memset(f,255,sizeof(f));
    if (duyet(true,n)==1) cout<<"First";
    else cout<<"Second";
    return 0;
}


Measured memory_bytes: 10368
def examB():
    N, M = LI()
    cur = [0]*N
    for i in range(M):
        a, b = LI()
        cur[a-1] +=1
        cur[b-1] +=1
    ans = "YES"
    for j in cur:
        if j%2==1:
            ans = "NO"
            break
    print(ans)


import sys,copy,bisect,itertools,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 4592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

vector<ll> enum_div(int n)//nの約数を列挙
{
	vector<ll> ret;
	for(ll i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N;
	cin >> N;
	if(N==1){
		cout << "Hello World" << endl;
	}else{
		ll a,b;
		cin >> a >> b;
		cout << a+b << endl;
	}

}

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

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int w, a, b;
	cin >> w >> a >> b;
	if(a + w <= b){
		cout << max(0, b - (a + w)) << endl;
	}else{
		cout << max(0, a - (b + w)) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    cunt_b=0
    ans=0
    for ss in s:
        if ss=='B':
            cunt_b+=1
        else:
            ans+=cunt_b
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 40048
def divide(L):
    ans = []
    prev = 0
    for i in range(len(L)):
        if L[i] == 0:
            ans.append(L[prev:i])
            prev = i + 1
    ans.append(L[prev:])
    return ans


def extract(L, v):
    for i in range(len(L)):
        L[i] -= v
    return L


def ans(L):
    if L == [0] * len(L):
        return 0
    count = 0
    divided = divide(L)
    for l in divided:
        if len(l) == 0:
            continue
        m = min(l)
        count += m
        extracted = extract(l, m)
        count += ans(extracted)
    return count


N = int(input())
h = list(map(int, input().split()))
print(ans(h))


Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
	// your code goes here
	int a,b;
	scanf("%d%d",&a,&b);
	if(a+b==24 )
	printf("0");
	else if(a+b>24)
	printf("%d",b-24+a);
	else
	printf("%d",b+a);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong h, w;
llong a[100][100];
llong b[100][100];
llong v[100][100];
llong u[100][100];
bool dp[100][100][26000];
llong offset = 13000;

int main() {
    cin >> h >> w;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> b[i][j];
        }
    }

    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            v[i][j] = a[i][j] - b[i][j];
            u[i][j] = b[i][j] - a[i][j];
        }
    }

    dp[0][0][offset] = true;
    dp[0][1][offset] = true;
    dp[1][0][offset] = true;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            for (int k = 0; k < 26000; k++) {
                if (dp[i - 1][j][k] == true) {
                    dp[i][j][k + v[i][j]] = true;
                    dp[i][j][k + u[i][j]] = true;
                }
                if (dp[i][j - 1][k] == true) {
                    dp[i][j][k + v[i][j]] = true;
                    dp[i][j][k + u[i][j]] = true;
                }
            }
        }
    }

    llong ans = 1ll << 60ll;
    for (int k = 0; k < 26000; k++) {
        if (dp[h][w][k] == true) {
            ans = min(ans, llabs(k - offset));
        }
    }

    cout << ans << endl;

    return 0;
}


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

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

    ll sum = 0;
    rep(i,n){
        if(i%3!=0 && i%5!=0){
            sum+=i;
        }
    }

    cout << sum << endl;

    return 0;
}

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

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

    vector<int> a(N+2,0);
    int total=0;
    for(int i=1;i<=N;i++){
        cin>>a[i];
        total+=abs(a[i]-a[i-1]);
    }
    total+=abs(a[N]);

    for(int i=1;i<=N;i++){
        int ans=total-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]);
        cout<<ans<<endl;

    }
    return 0;
}



Measured memory_bytes: 1664
#include <stdio.h>

int main(){
  int W, H, x, y;
  scanf("%d %d %d %d", &W, &H, &x, &y);
  double res;
  res=(double)W*(double)H/(double)2.0;
  printf("%lf", res);
  if(W%2==0&&H%2==0&&x==W/2&&y==H/2){
    printf(" %d", 1);
  }
  else{
    printf(" %d", 0);
  }
}

Measured memory_bytes: 128
#include <iostream>

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

struct Node {
  int value;
  Node *parent, *left, *right;

  Node(int k, Node *p, Node *l, Node *r) {
    value = k;
    parent = p;
    left = l;
    right = r;
  }
};

Node *root = nullptr;

void insert(Node *n, int k) {
  Node *t = new Node(k, n, nullptr, nullptr);

  if (n == nullptr) {
    t->parent = nullptr;
    root = t;
    return;
  }
  if (k < n->value) {
    if (n->left == nullptr) {
      n->left = t;
    } else {
      delete t;
      insert(n->left, k);
    }
  } else {
    if (n->right == nullptr) {
      n->right = t;
    } else {
      delete t;
      insert(n->right, k);
    }
  }
}

void inorder(Node *n) {
  if (n == nullptr) return;
  inorder(n->left);
  std::cout << ' ' << n->value;
  inorder(n->right);
}

void preorder(Node *n) {
  if (n == nullptr) return;
  std::cout << ' ' << n->value;
  preorder(n->left);
  preorder(n->right);
}

int main() {
  int n;
  std::cin >> n;
  std::string com;
  int key;

  rep(i, n) {
    std::cin >> com;
    if (com == "insert") {
      std::cin >> key;
      insert(root, key);
    } else {
      inorder(root);
      std::cout << '\n';
      preorder(root);
      std::cout << '\n';
    }
  }
  return 0;
}



Measured memory_bytes: 26668
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int abs(int x){
    if(x>0)return x;
    else return (-1)*x;
}

int main(){
    int n;
    scanf("%d",&n);
    int a[n+1];
    int i,max=-1,maxn=0;
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(abs(a[i])>max){
            max=abs(a[i]);
            maxn=i;
        }
    }
    printf("%d\n",2*n-1);
    for(i=1;i<=n;i++)printf("%d %d\n",maxn,i);
    if(a[maxn]>=0){
        for(i=1;i<=n-1;i++)printf("%d %d\n",i,i+1);
    }else{
        for(i=n;i>=2;i--)printf("%d %d\n",i,i-1);
    }
    return 0;
    
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
#define N 100005
#define ll long long
#define MOD 1000000007
#define INF 0x3f3f3f3f
int n;
int a[N],cnt[10],tot,num[10];
int main()
{
	//freopen("circle.in","r",stdin);
	//freopen("circle.out","w",stdout);
	int T=1;//scanf("%d",&T);
	while(T--)
	{
		bool f=0;
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&a[i]);
			if(a[i]!=0) f=1;
		}
		if(f==0)
		{//全部都是0 
			puts("Yes");
			continue;
		}
		sort(a+1,a+n+1);
		a[0]=INF;
		for(int i=1;i<=n;i++)
		{
			if(a[i]!=a[i-1])
				cnt[++tot]++,num[tot]=a[i];
			else cnt[tot]++;
			if(tot>3)
			{
				puts("No");
				f=0;//混用变量
				break; 
			}
		} 
		if(f==0) continue;
		//int ans=num[1]^num[2]^num[3];
		//if(ans==0) puts("*");
		//printf("%d\n",ans);
		//for(int i=1;i<=3;i++)
		//	printf("%d %d\n",num[i],cnt[i]);
		if(n%3==0)
		{
			if(tot==3&&(num[1]^num[2]^num[3])==0&&cnt[1]==n/3&&cnt[2]==n/3&&cnt[3]==n/3)
			{
				puts("Yes");
				continue;
			}
			if(tot==2&&num[1]==0&&cnt[1]==n/3&&cnt[2]==n/3*2)
			{
				puts("Yes");
				continue;
			}
		}
		puts("No");
	}
    return 0;
}

Measured memory_bytes: 640
if __name__=='__main__':
    in_src = input()
    in_str = in_src.split(' ')
    in_num = []
    for i in in_str:
        in_num.append(int(i))
    if in_num[0]%3==0:
        print('Possible')
    elif in_num[1]%3==0:
        print('Possible')
    elif (in_num[0]+in_num[1])%3==0:
        print('Possible')
    else:
        print('Impossible')


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

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 main() {
  int x, y;
  cin >> x >> y;
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  REP(i, a) cin >> p[i];
  REP(i, b) cin >> q[i];
  REP(i, c) cin >> r[i];
  sort(p.rbegin(), p.rend());
  sort(q.rbegin(),q.rend());
  vector<int> d;
  REP(i, x) d.push_back(p[i]);
  REP(i, y) d.push_back(q[i]);
  REP(i, c) d.push_back(r[i]);
  sort(d.rbegin(), d.rend());
  ll ans = 0;
  REP(i, x+y) ans += d[i];
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3572
n=int(input())
li = list(map(int,input().split()))
ans = [-1,10**7]

for i in range(1,101):
    a = 0
    for j in range (len(li)):
        a += (li[j]-i)**2
    if a <= ans[1]:
        ans[0] = i
        ans[1] = a
    
print(ans[1])

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N, x; cin >> N >> x;
  ll a[N]; rep(i,N) cin >> a[i]; sort(a,a+N);
  repr(i,1,N) a[i] += a[i-1];
  int pos = lower_bound(a,a+N,x) - a;
  if (pos==N) pos--;
  int result = x==a[pos] ? pos+1 : pos;
  cout << result << endl;
  return 0;
}

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

int main(){
  long long num;
  long long kekka=1;
  
  cin >> num;
  
  long long tmp1 = 2;
  long long tmp2 = 1;
  for(int i = 1; i < num; i++){
    kekka = tmp1 + tmp2;
    tmp1 = tmp2;
    tmp2 = kekka;
  }
  
  cout << kekka;
}

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

using namespace std;
typedef long long LL;
const LL inf=0x3f3f3f3f3f3f3f3fll;
const int MX=200005;
int n,m,x,y;LL ad,f[MX],ans;
LL f1[MX],f2[MX];
void add1(int x,LL k){for(;x<=n&&k<f1[x];x+=x&-x)f1[x]=k;}
LL que1(int x){LL k=inf;for(;x;x-=x&-x)k=min(k,f1[x]);return k;}
void add2(int x,LL k){for(;x&&k<f2[x];x-=x&-x)f2[x]=k;}
LL que2(int x){LL k=inf;for(;x<=n;x+=x&-x)k=min(k,f2[x]);return k;}
void wk(){
	y=x,cin>>x;
	LL v=min(que1(x)+x,que2(x)-x)+ad;ad+=abs(x-y);
	if(v-ad<f[y])f[y]=v-ad,add1(y,f[y]-y),add2(y,f[y]+y);
}
int main(){
	int i;
	cin>>n>>m>>x>>y;
	for(i=1;i<=n;i++)f[i]=f1[i]=f2[i]=inf;
	for(f[y]=0,add1(y,-y),add2(y,y);m--;)wk();
	for(ans=inf,i=1;i<=n;i++)ans=min(ans,f[i]);
	cout<<ans+ad<<endl;
	return 0;
}

Measured memory_bytes: 4992
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

var nmax = int(2*1e5 + 1)
var mod = 998244353
var fac = make([]int, nmax)
var inv = make([]int, nmax)
var finv = make([]int, nmax)

// inverse element, 逆元
func initComb() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	for i := 2; i < nmax; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

// 繰り返し2乗法
func powMod(x, i int) int {
	if i == 0 {
		return 1
	}

	y := 1
	if i&1 != 0 {
		y = x
		i--
	}

	t := powMod(x, i>>1)
	return y * t % mod * t % mod
}

func main() {
	n, m, k := readInt(), readInt(), readInt()

	initComb()

	ans := 0
	for i := 0; i <= k; i++ {
		// m * (m-1)^(n-i-1) * kHn-i-1
		ans += m * powMod(m-1, n-i-1) % mod * fac[n-1] % mod * finv[n-i-1] % mod * finv[i] % mod
		ans %= mod
	}

	fmt.Println(ans)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


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



const int N = 1e5 + 5, INF = 2e9;


int n, w;
long long dp[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> w;
    memset(dp, 63, sizeof(dp));
    dp[0] = 0;
    for(int i = 1; i <= n; i++){
        int x, y;
        cin >> x >> y;
        for(int j = N - 1; j - y >= 0; j--){
            if(dp[j - y] != -1){
                dp[j] = min(dp[j], dp[j - y] + x);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(dp[i] <= w){
            ans = i;
        }
    }
    cout << ans;
}


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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!

//

void solve(long long N, std::vector<long long> X) {
  ll sum = 0;
  rep(i,N) sum+=X[i];
  int mean = (int)((double)sum/N);
  ll ret = numeric_limits<ll>::max();
  rep(i,-1,2){
    ll held = mean + i;
    ll cost = 0;
    rep(j,N){
      cost += (held-X[j]) * (held-X[j]);
    }
    if(cost<ret) ret = cost;
  }
  cout << ret << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long N;
  std::cin >> N;
  std::vector<long long> X(N);
  for (int i = 0; i < N; i++) {
    std::cin >> X[i];
  }
  solve(N, std::move(X));
  return 0;
}


Measured memory_bytes: 3616
N = int(input())
A = list(map(int,input().split()))
p = 1
if A.count(0)>0:
    p = 0
for i in range(N):
    p = p * A[i]
    if p > 10**18:
        p=-1
        break
    if p == 0:
        break
print(p)


Measured memory_bytes: 21472
#include<stdio.h>

#define Max 1000000
#define SqrtMax 1000

typedef struct Result {
    int count, last;
} Result;

int m, n;

int cave[SqrtMax][SqrtMax];
int itoy[Max + 1];
int itox[Max + 1];
int notPrime[Max + 1];
Result memo[SqrtMax][SqrtMax];

void makeCave() {
    int dy[4] = {0, -1, 0, 1};
    int dx[4] = {1, 0, -1, 0};
    int i;
    int y, x;
    int direction;
    y = x = SqrtMax / 2;
    direction = 0;
    cave[y][x] = 1;
    itoy[1] = y;
    itox[1] = x;
    for(i = 1; i < Max; i++) {
        y += dy[direction];
        x += dx[direction];
        cave[y][x] = i + 1;
        itoy[i + 1] = y;
        itox[i + 1] = x;
        if(!cave[y + dy[(direction + 1) % 4]][x + dx[(direction + 1) % 4]]) direction = (direction + 1) % 4;
    }
}

void makePrime() {
    int i, j;
    notPrime[0] = notPrime[1] = 1;
    for(i = 2; i <= Max; i++) {
        for(j = i << 1; j <= Max; j += i) {
            notPrime[j] = 1;
        }
    }
}

int inRange(int y, int x) {
    if(y < 0 || SqrtMax <= y) return 0;
    if(x < 0 || SqrtMax <= x) return 0;
    if(cave[y][x] > m) return 0;
    return 1;
}

Result dfs(int y, int x) {
    int dy[3] = {1, 1, 1};
    int dx[3] = {-1, 0, 1};
    int i;
    Result result;
    if(memo[y][x].count != -1) return memo[y][x];
    if(!notPrime[cave[y][x]]) {
        result.count = 1;
        result.last = cave[y][x];
    } else {
        result.count = 0;
        result.last = 0;
    }
    for(i = 0; i < 3; i++) {
        int ny = y + dy[i];
        int nx = x + dx[i];
        Result r;
        if(!inRange(ny, nx)) continue;
        r = dfs(ny, nx);
        if(result.count > !notPrime[cave[y][x]] + r.count) {
            continue;
        } else if(result.count == !notPrime[cave[y][x]] + r.count) {
            result.last = (result.last > r.last ? result.last : r.last);
        } else {
            result.count = !notPrime[cave[y][x]] + r.count;
            result.last = r.last;
        }
    }
    return memo[y][x] = result;
}

int main(void) {
    makeCave();
    makePrime();
    while(scanf("%d %d", &m, &n), m | n) {
        int i, j;
        for(i = 0; i < SqrtMax; i++) for(j = 0; j < SqrtMax; j++) {
            memo[i][j].count = -1;
            memo[i][j].last = 0;
        }
        Result answer = dfs(itoy[n], itox[n]);
        printf("%d %d\n", answer.count, answer.last);
    }
    return 0;
}

Measured memory_bytes: 24144
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

bool is_prime(vector<int>& primes, ll x) {
    for(int i = 0; i < primes.size(); i++) {
        ll p = primes[i];
        if (p*p > x) break;
        if (x % p == 0) return false;
    }
    return true;
}

int main() {
    int q, l, r;
    const int ARR_SIZE = 100005;
    vector<bool> prime_bool(ARR_SIZE, false);
    vector<bool> similar(ARR_SIZE, false);
    vector<int> primes = {2, 3, 5};
    prime_bool[2] = prime_bool[3] = prime_bool[5] = true;
    for(int i = 7; i < ARR_SIZE; i+=2) {
        if (is_prime(primes, i)) {
            prime_bool[i] = true;
            primes.push_back(i);
        }
    }
    for(int i = 2; i < ARR_SIZE; i++) {
        if (prime_bool[i] && prime_bool[(i+1)/2])
            similar[i] = true;
    }
    vector<int> ans(ARR_SIZE+1, 0);
    for(int i = 1; i < ARR_SIZE; i++) {
        if (similar[i])
            ans[i] = ans[i-1] + 1;
        else
            ans[i] = ans[i-1];
    }
    cin >> q;
    while(q--) {
        cin >> l >> r;
        cout << ans[r] - ans[l-1] << endl;
    }
    return 0;
}




Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  cin>>a>>b;
  string t, r;
  for(int i = 0; i < a; ++i){
    r += b + '0';
  }
  for(int i = 0; i < b; ++i){
    t += a + '0';
  }
  if(t <= r){
    cout<<t<<endl;
  }
  else{
    cout<<r<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    string S;
    cin >> S;
    int i;
    for(i=0;i<3;i++){
        if(S[i]=='7'){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
const int N=2e5+5,mo=1e9+7;
int n,a[N],b1[N],b2[N],f1[N],f2[N],f22[N],all=1,i,ans,inv[N];
struct pii{
	int x,y;
	inline pii(int _x=0,int _y=0):x(_x),y(_y){}
	inline pii operator+(const pii&rhs)const{return pii(1ll*x*rhs.x%mo,(1ll*y*rhs.x+rhs.y)%mo);}
};
int bi[N];
inline void add(int x){for(;x<=n;x+=x&-x)bi[x]++;}
inline int ask(int x){int ans=0;for(;x;x-=x&-x)ans+=bi[x];return ans;}
struct node{
	int lb,rb,md;
	int pi,s1,s2;
}t[N<<2];
void build(int i,int l,int r){
	t[i].lb=l;t[i].rb=r;t[i].md=l+r>>1;
	if(l==r){
		t[i].pi=b2[l];
		return;
	}
	build(i<<1,l,t[i].md);build(i<<1|1,t[i].md+1,r);
	t[i].pi=1ll*t[i<<1].pi*t[i<<1|1].pi%mo;
}
pii ask1(int i,int k){
	if(t[i].rb<=k)return pii(t[i].pi,t[i].s1);
	if(k<=t[i].md)return ask1(i<<1,k);else return pii(t[i<<1].pi,t[i<<1].s1)+ask1(i<<1|1,k);
}
pii ask2(int i,int k){
	if(k<=t[i].lb)return pii(t[i].pi,t[i].s2);
	if(k<=t[i].md)return pii(t[i<<1|1].pi,t[i<<1|1].s2)+ask2(i<<1,k);else return ask2(i<<1|1,k);
}
void mdy(int i,int k){
	if(t[i].lb==k && t[i].rb==k){
		t[i].s1=(t[i].s1+f2[k])%mo;
		t[i].s2=(t[i].s2+b2[k])%mo;
		return;
	}
	if(k<=t[i].md)mdy(i<<1,k);else mdy(i<<1|1,k);
	t[i].s1=(1ll*t[i<<1].s1*t[i<<1|1].pi+t[i<<1|1].s1)%mo;
	t[i].s2=(1ll*t[i<<1|1].s2*t[i<<1].pi+t[i<<1].s2)%mo;
}
int main(){
	for(i=1;i<N;++i)inv[i]=i==1?1:1ll*(mo-mo/i)*inv[mo%i]%mo;
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",a+i),++b1[a[i]];
	b1[n+1]=1;for(i=n;i;--i)ans=(ans+1ll*b1[i]*(b1[i]-1)/2)%mo,b1[i]+=b1[i+1]-1,all=1ll*all*b1[i]%mo;
	if(!all)return puts("0"),0;
	ans=1ll*inv[2]*ans%mo;
	for(i=1;i<=n;++i){
		b2[i]=1ll*inv[b1[i]]*(b1[i]-1)%mo;
		f1[i]=(1ll*b2[i]*f1[i-1]+inv[b1[i]])%mo;
		f2[i]=(1ll*inv[b1[i]]*f1[i-1]+(b1[i]<3?0:1ll*inv[b1[i]]*(b1[i]-2)%mo)*f2[i-1])%mo;
	}
	build(1,1,n);
	for(i=1;i<=n;++i){
		if(a[i]>1)ans=(ans+1ll*ask1(1,a[i]-1).y*b2[a[i]])%mo;
		if(a[i]<n)ans=(ans+1ll*mo+(i-1-ask(a[i]))-1ll*f2[a[i]]*ask2(1,a[i]+1).y%mo)%mo;
		mdy(1,a[i]);add(a[i]);
	}
	ans=1ll*ans*all%mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 21248
/**
       **********    ************
	  Author : Avi J Patel
	  University : DAIICT
       **********    ************
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 10000000000000001
#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    if(a.second < b.second) return true; 
    else if(a.ss==b.ss) return a.ff<b.ff;
	else return false;
}
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.first<b.first) return true;
	else if(a.first==b.first) return a.second<b.second;
	else return false;
} 
ull powr(ull x1, ull n1) {
    if(x1==0)
    {
        return 0;
    }
    ull result=1;
    while(n1>0)
    {
        if(n1&1)
        {
            result=(result*x1);
        }
        n1=n1>>1;
        x1=(x1*x1);
    }
    return result;
}   
int main()
{
	FAST
	ll n;
	cin>>n;
	if(n%2==1)
	{
		cout<<0;
	}
	else
	{
		ll ans=0;
		n/=2;
		ll r=5;
		while(n/r>0){
			ans+=(n/r);
			r*=5;
		}
		n/=10;
		//ans-=n;
		cout<<ans;
	}
	return 0;
}















Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cmath>
#include <list>
#include <algorithm>
#include <iostream>

using namespace std;

int main(void)
{
    int k;
    string s;
    cin >> k >> s;
    //cout << s.length();
    
    if (k >= s.length()) {
        cout << s;
    } else {
        cout << s.substr(0, k) << "...";
    }
}


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

using namespace std;

int main() {
    string S, T;

    cin >> S >> T;

    int ans = 0;

    for(int i = 0; i < S.size(); i++) {
        if(S[i] != T[i]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3916
# 097a

a, b, c, d = map(int, input().split())  # a,b,c,dを代入

if (a - b) >= 0:
    ab = a - b  # aとbの距離abを代入
else:
    ab = (a - b) * -1   # 距離が負の場合は-1を掛けて正の値にする

if (a - c) >= 0:
    ac = a - c
else:
    ac = (a - c) * -1

if (b - c) >= 0:
    bc = b - c
else:
    bc = (b - c) * -1

if ac <= d:
    print('Yes')
elif ab <= d and bc <= d:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9072
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e5 + 7;
int lst[Max];

int main()
{
	int n;
	cin >> n;
	int g = 2;
	for (int i = 1; i <= n; i++)
	{
		lst[g]++;
		g *= 2;
		if (g >= 100) break;
	}
	for (int i = n; i >= 2; i--)
	{
		if (lst[i])
		{
			g = i;
			break;
		}
	}
	if (n == 1)cout << 1;
	else
	cout << g;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int A, B, C, D; 
    cin>>A>>B>>C>>D;
    int t_count = (C-1) / B + 1;
    int a_count = (A-1) / D + 1;
    
    cout << ((t_count > a_count) ? "No" : "Yes") << endl;
}

Measured memory_bytes: 3636
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
int A,B,C;
int main(){
	cin>>A>>B>>C;
	printf("%d\n",max(0,C-(A-B)));
	return 0;
}

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


int main() {

	int k, n;
	cin >> k >> n;

	vector<int> A(n);
	for (int i = 0;i < n;i++) {
		cin >> A.at(i);
	}
	
	int len = 0;
	for (int i = 0;i < n;i++) {
		if (i == n - 1) {
			len = max(len, abs(A.at(i) - k-A.at(0)));
		}
		else {
			len = max(len, abs(A.at(i) - A.at(i+1)));
		}		
	}

	cout << k - len;
}


Measured memory_bytes: 1024
coordinates = list(map(int,input().split()))
s = []
t = []

for i in range(len(coordinates)):
    if i < 2:
        s.append(coordinates[i])
    else:
        t.append(coordinates[i])

# print(s)
# print(t)

dx = t[0] - s[0]
dy = t[1] - s[1]

route = ""

# print("dx: ", dx)
# print("dy: ", dy)

# 経路パターン１
# 行き
for i in range(dx):
    route += "R"
for i in range(dy):
    route += "U"

# 帰り
for i in range(dx):
    route += "L"
for i in range(dy):
    route += "D"

# 経路パターン２（パターン１の外側を通る）
# 行き
route += "D"

for i in range(dx+1):
    route += "R"
for j in range(dy+1):
    route += "U"

route += "L"
route += "U"

for i in range(dx+1):
    route += "L"
for i in range(dy+1):
    route += "D"

route += "R"


# 解答出力
print(route)

Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int D = 365;
vector<int> c(27);
vector<vector<int>> s(D + 1);

ll calc_score(vector<int> &t) {
    ll satisfy = 0;
    vector<int> last(27, 0);
    for (int i = 1; i <= D; ++i) {
        int con = t[i];
        // add satisfy
        satisfy += s[i][con];
        // update last
        last[con] = i;
        // sub satisfy
        for (int j = 1; j <= 26; ++j) {
            satisfy -= c[j] * (i - last[j]);
        }
    }
    return satisfy;
}

int main() {
    clock_t start = clock();

    cin >> D;
    for (int i = 1; i <= 26; ++i) cin >> c[i];
    for (int i = 1; i <= D; ++i) {
        vector<int> v(27);
        for (int j = 1; j <= 26; ++j) cin >> v[j];
        s[i] = v;
    }

    // output
    vector<int> ans(D + 1);
    vector<int> last(27, 0);
    ll satisfy = 0;
    for (int i = 1; i <= D; ++i) {
        ll best_contest = 0;
        ll best_score = -999999999;
        vector<int> c_last = last;
        for (int j = 1; j <= 26; ++j) {
            ll tmp_satisfy = satisfy;
            int con = j;
            // add satisfy
            tmp_satisfy += s[i][j];
            // update last
            c_last[con] = i;
            // sub satisfy
            for (int j = 1; j <= 26; ++j) {
                tmp_satisfy -= c[j] * (i - c_last[j]);
            }
            if (tmp_satisfy > best_score) {
                best_contest = j;
                best_score = tmp_satisfy;
            }
        }
        // actual update
        int con = best_contest;
        last[con] = i;
        ans[i] = con;
    }

    // random
    // clock_t end = clock();
    // double time = static_cast<double>(end-start) / CLOCKS_PER_SEC * 1000.0;
    ll best_score = calc_score(ans);
    random_device rd{};
    for (int i = 0; i < 10000; ++i) {
        // random
        ll day = rd() % 365 + 1;
        ll con = rd() % 26 + 1;
        vector<int> c_ans = ans;
        c_ans[day] = con;
        ll score = calc_score(c_ans);
        if (score > best_score) ans = c_ans;
        // end = clock();
        // time = static_cast<double>(end-start) / CLOCKS_PER_SEC * 1000.0;
    }

    // output
    for (int i = 1; i <= D; ++i) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3712
from decimal import Decimal
import decimal

a,b = map(Decimal, input().split())
# 3.141592653589793

sum=a*b
val_pi_d = decimal.Decimal(sum)

# decimal型による切り捨て
val_floor_d = val_pi_d.quantize(decimal.Decimal('0.001'), rounding=decimal.ROUND_FLOOR)
print(int(val_floor_d))


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

int main(){
	bool prime[100010];
	prime[0]=0;prime[1]=0;prime[2]=1;
	for(int i=3;i<100010;i++){
		if(i%2==0)prime[i]=0;
		else prime[i]=1;
	}
	for(long long i=3;i<100010;i+=2){
		if(prime[i]){
			for(long long j=i*i;j<100010LL;j+=i){
				prime[j]=0;
			}
		}
	}
	int x;
	scanf("%d",&x);
	for(int i=x;i<100010;i++){
		if(prime[i]){
			printf("%d",i);
			return 0;
		}
	}
}


Measured memory_bytes: 384
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define elif else if
#define lli long long int
#define ld long double
#define vec vector
#define forn(a) for(lli a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define deb(x) cerr<<#x<<" = "<<x<<endl

using namespace std;

int main(){
  IOS;

  int a, b, c;
  cin>>a>>b>>c;

  if((a<c && c<b) || (b<c && c<a))
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 256
from collections import deque
N,K=map(int,input().split())
a=list(map(int,input().split()))
A=deque([str(i) for i in range(10) if i not in a])
B=[str(i) for i in range(10) if i not in a]
while True:
  s=A.popleft()
  if int(s)>=N:
    print(s)
    exit()
  A.extend([s+i for i in B])

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

int main(){
  string s , t;
  cin >> s >> t ;
  int count=0;
  int a = s.size();
  
  for(int i=0;i<a;i++){
    if(s[i]!=t[i]){
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3848