akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int,int> P;
int main(void){
  int n,i,u,v,w;
  vector<P> g[100010];
  cin >> n;
  for (i=0;i<n;i++){
    cin >> u >> v >> w;
    g[u].push_back(P(v,w));
    g[v].push_back(P(u,w));
  }
  
  int p,co[100010]={};
  bool uo[100010]={false};
  queue<int> que;
  que.push(1);
  while (!que.empty()){
    p=que.front();
    que.pop();
    uo[p]=true;
    for (i=0;i<g[p].size();i++){
      if (g[p][i].second % 2) co[g[p][i].first]=1-co[p];
      else co[g[p][i].first]=co[p];
      if (!uo[g[p][i].first]) que.push(g[p][i].first);
    }
  }
  for (i=1;i<=n;i++) cout << co[i] << endl;
  return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1e9+7;
const int INF=1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin>>n;
    set<int> s;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(s.find(a)!=s.end()){
            cout<<"NO"<<endl;
            return 0;
        }
        s.insert(a);
    }
    cout<<"YES"<<endl;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, odd = 0, four = 0;
	cin >> n;

	for(int i = 0; i < n; i++) {
		int num;
		cin >> num;
		if(num % 2) {
			odd++;
		} else if(num % 4 == 0) {
			four++;
		}
	}
	if(n % 2) {
		if(odd - 1 <= four) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else {
		if(odd <= four) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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 argc, char const *argv[]) {
  int a,b;
  cin >> a >> b ;
  cout << max(max(a+b,a+a-1),b+b-1) << endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A_str=map(str,A)
string=" ".join(A_str)
print(string)
for i in range(1,N):
    v=A[i]
    j=i-1
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j-=1
    A[j+1]=v
    A_str=map(str,A)
    string=" ".join(A_str)
    print(string)



Measured memory_bytes: 5600
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define ll long long
using namespace std;
struct node{
    ll t,l,h;
};
bool cmp(node a,node b){
    if(a.t!=b.t){
        return a.t<b.t;
    }else{
        return a.l<b.l;
    }
}
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int num[3]={a,b,c};
    sort(num,num+3);
    if((num[0]==num[1]&&num[1]!=num[2])||(num[0]!=num[1]&&num[1]==num[2])){
        cout<< "Yes"<<endl;
    }
	else 
    cout<< "No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  ll K;
  cin >> K;
  vector<ll> a(K,0);

  ll ans;

  if (K % 2 == 0 || K % 5 == 0) cout << -1 << endl;

  else {
   ll amr = 7;
   int cnt = 1;
   rep(i,K+1){
     amr = amr % K;
     if(a[amr] == 0) a[amr] = cnt;
     else{
       ans = cnt -a[amr];
       break;
     }
     cnt++;
     amr = amr * 10 + 7;
   }
   cout << ans << endl;
 }
}


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

using namespace std;

int main(){
	int N, a, b;
	while(cin >> N >> a >> b){
		--a; --b;
		vector<long long> x(N), y(N);
		set<int> rest;
		for(int i=0;i<N;i++){
			if(i != a) rest.insert(i);
		}
		for(int i=0;i<N;i++){
			long long p, q; cin >> p >> q;
			x[i] = p-q;
			y[i] = p+q;
		}
		int targetD = max(abs(x[a]-x[b]), abs(y[a]-y[b]));
		map<long long, set< pair<int, int> > > h, v;
		map<long long, vector<int> > hAll, vAll;
		for(int i=0;i<N;i++){
			h[x[i]].insert(make_pair(y[i], i));
			v[y[i]].insert(make_pair(x[i], i));
			hAll[x[i]].push_back(y[i]);
			vAll[y[i]].push_back(x[i]);
		}
		for(auto it=hAll.begin();it!=hAll.end();it++){
			sort(it->second.begin(), it->second.end());
		}
		for(auto it=vAll.begin();it!=vAll.end();it++){
			sort(it->second.begin(), it->second.end());
		}
		long long res = 0;
		queue<int> qu; qu.push(a);
		while(!qu.empty()){
			int pos = qu.front(); qu.pop();
			auto checkH = [&](int checkX, int centerY){
				auto itF = lower_bound(hAll[checkX].begin(), hAll[checkX].end(), centerY-targetD);
				auto itE = lower_bound(hAll[checkX].begin(), hAll[checkX].end(), centerY+targetD+1);
				if(itF == itE) return;
				res += distance(itF, itE);
				auto itF2 = h[checkX].lower_bound(make_pair(centerY-targetD, 0));
				auto itE2 = h[checkX].lower_bound(make_pair(centerY+targetD+1, 0));
				for(auto it=itF2;it!=itE2;it++){
					auto it2 = rest.find(it->second);
					if(it2 != rest.end()){
						qu.push(it->second);
						rest.erase(it2);
					}
				}
				h[checkX].erase(itF2, itE2);
			};
			auto checkV = [&](int centerX, int checkY){
				auto itF = lower_bound(vAll[checkY].begin(), vAll[checkY].end(), centerX-targetD+1);
				auto itE = lower_bound(vAll[checkY].begin(), vAll[checkY].end(), centerX+targetD);
				if(itF == itE) return;
				res += distance(itF, itE);
				auto itF2 = v[checkY].lower_bound(make_pair(centerX-targetD+1, 0));
				auto itE2 = v[checkY].lower_bound(make_pair(centerX+targetD, 0));
				for(auto it=itF2;it!=itE2;it++){
					auto it2 = rest.find(it->second);
					if(it2 != rest.end()){
						qu.push(it->second);
						rest.erase(it2);
					}
				}
				itF2 = v[checkY].lower_bound(make_pair(centerX-targetD, 0));
				itE2 = v[checkY].lower_bound(make_pair(centerX+targetD+1, 0));
				v[checkY].erase(itF2, itE2);
			};
			checkH(x[pos]-targetD, y[pos]);
			checkH(x[pos]+targetD, y[pos]);
			checkV(x[pos], y[pos]-targetD);
			checkV(x[pos], y[pos]+targetD);
		}
		cout << res/2 << endl;
	}
}



Measured memory_bytes: 61440
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <math.h>
#include <string.h>

using std::endl;
using std::string;

#define ll long long int
#define LEP(a, n) for(ll a = 0; a < n; ++a)
#define INF 123456789012345
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std

ll N, X, ans = 0;
ll data[123];

int main()
{
	IN >> N >> X;
	LEP(a, N)
	{
		IN >> data[a];
	}

	std::sort(data, data + N);

	LEP(a, N - 1)
	{
		X -= data[a];
		if (X < 0)
		{
			break;
		}
		ans++;
	}

	if (X == data[N - 1])ans++;

	OUT << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import Counter


N = int(input())
S = []
for i in range(N):
    S.append(input())

C=Counter(S).most_common()
L=len(C)

D=[]

D.append(C[0][0])

for i in range(1,L):
    if C[0][1]==C[i][1]:
        D.append(C[i][0])
D.sort()
M=len(D)

for i in range(M):
    print(D[i])

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

int main()//TLE?
{
  int n;
  cin >> n;
  vector<int> a(n+1);
  for(int i=1;i<=n;++i){
    cin >> a.at(i);
  }
  
  int m=0;
  int c=0;
  vector<int> b(n+1,0);
  for(int i=n;i>0;--i){
    for(int j=i*2;j<=n;j+=i){
      if(b.at(j)==c){
        c=0;
      }else{
        c=1;
      }
    }
    if(a.at(i)!=c){
      b.at(i)=1;
      ++m;
    }
    c=0;
  }
  
  cout << m << endl;
  for(int i=1;i<=n;++i){
    if(b.at(i)){
      cout << i << " ";
    }
  }
  return 0;
}

Measured memory_bytes: 2432
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define c1 __builtin_popcount
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS

vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
// g++ -std=c++17 -O2 -Wall template.cpp -o template
int32_t main()
{
IOS
int n;
cin>>n;
vector<int> v(n+1);
map<int,int> mp;

FOR(i,1,n+1) cin>>v[i],mp[v[i]]++;
int ans=0;
for(auto it = mp.begin();it!=mp.end();it++) {
    int v = it->second;
    ans+= v*(v-1)/2;
}
for(int i=1;i<=n;i++) {
cout<<ans-(mp[v[i]]-1)<<endl;
}
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 11136
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

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

// 1 <= k <= n <= 10^7
#define CNKMAX 100001
class CNK1 {
    std::vector<long long> fac, finv, inv;
    int MOD;
public:
    CNK1(int mod = 1000000007): MOD(mod), fac(CNKMAX), finv(CNKMAX), inv(CNKMAX) {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < CNKMAX; 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;
        }
    }
    int get(const int &n, const int &k) const {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
};

void solve() {
    LL n,k;
    cin >> n >> k;
    CNK1 cnk;
    REP(i,1,k+1) {
        if (i > n - k + 1) {
            cout << 0 << endl;
            continue;
        }
        cout << (1LL * cnk.get(i+n-k-(i-1), i) * cnk.get(k-i+i-1, i-1)) % MOD << endl;
    }
}

int main() {
    solve();
    
    return 0;
}

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


typedef complex<double> P;
const double EPS = 1e-10;

struct Circle{
  double r;
  P c;
};

namespace std {
  bool operator < (const P&a, const P&b) {
    return fabs( real(a) - real(b) ) < EPS ? imag(a) < imag(b) : real(a) < real(b);
  }
}

vector<P> getIntersectCC(Circle C1,Circle C2){
  vector<P> res;
  double r1 = C1.r, r2 = C2.r, d;
  P p1 = C1.c, p2 = C2.c;
  d = abs( p1 - p2 );
  
  if( d < EPS && abs( r1 - r2 ) < EPS ) return res;
  if( r1 + r2 < d - EPS || d + EPS < abs( r1 - r2 ) ) return res;
  double a = ( r1 * r1 - r2 * r2 + d * d ) / (2 * d);
  double h = sqrt(max(r1 * r1 - a * a, 0.0) );
  P tmp1 = p1 + a / d * (p2 - p1);
  P tmp2 = h / d * (p2 - p1);

  if( abs( tmp2 ) < EPS ) res.push_back( tmp1 );
  else {
    res.push_back( P(real(tmp1) - imag(tmp2), imag(tmp1) + real(tmp2)) );
    res.push_back( P(real(tmp1) + imag(tmp2), imag(tmp1) - real(tmp2)) );    
  }
  return res;
}

bool inCircle(Circle C,P p){//in point
  if( abs(C.c - p) < C.r + EPS ) return true;
  return false;
}

int N;
Circle X[11];

int main(){
  while( cin >> N && N ){
    for(int i=0;i<N;i++)
      cin >> X[i].c.real() >> X[i].c.imag() >> X[i].r;
    
    double st = 0.0, ed = 10000.0;
    while(  ed - st  > EPS ){
      double h = (ed + st)/2.0;
      vector<Circle> nc;
      bool f = true;
      for(int i=0;i<N;i++){
        nc.push_back( X[i] );
        nc[i].r = X[i].r * X[i].r - h * h;
        if( nc[i].r < EPS ) {
          f = false;
          break;
        }
        nc[i].r = sqrt(nc[i].r);
      }
      if( !f ) {
        ed = h;
        continue;
      }
      vector<P> pos;
      for(int i=0;i<N;i++){
        pos.push_back( nc[i].c );
        for(int j=i+1;j<N;j++){
          vector<P> ret = getIntersectCC(nc[i],nc[j]);
          for(int k=0;k<(int)ret.size();k++) pos.push_back( ret[k] );
        }
      }
      f = false;
      // cout << "h : " <<h << endl;
      for(int i=0;i<(int)pos.size();i++){
        // cout <<pos[i] << endl;
        bool kf = true;
        for(int j=0;j<N;j++){
          if( !inCircle( nc[j], pos[i] ) ) kf = false;
        }
        if( kf ){
          f = true;
          //cout << "ok"<< endl;
          break;
        }
      }
      if( f ) st = h;
      else ed = h;
    }
    printf("%.10lf\n",st);
  }
}

Measured memory_bytes: 1276
a, b = map(int, input().split())
s = list(map(int,input().split( )))
c=a-b
e = 10000000000
if a==b:
  e=s[b-1]-s[0]+min(abs(s[b-1]),abs(s[0]))
else:
  for j in range(0,c+1):
    if e>s[j+b-1]-s[j]+min(abs(s[j+b-1]),abs(s[j])):
      e=s[j+b-1]-s[j]+min(abs(s[j+b-1]),abs(s[j]))
print(e)

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

#define ll long long
#define mod 1000000007

ll dp[1001][1001];
int h,w;
char ch[1001][1001];

ll func(int i,int j)
{

    if(i==h && j==w) return 1;

    if(dp[i][j]!=-1)return dp[i][j];

    int re=0,re1=0;

    if(i+1<=h && ch[i+1][j]=='.')re+=func(i+1,j)%mod;
    if(j+1<=w && ch[i][j+1]=='.')re1+=func(i,j+1)%mod;

    return dp[i][j]=(re+re1)%mod;
}


int main()
{
    scanf("%d%d",&h,&w);
    memset(dp,-1,sizeof dp);

    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
           scanf(" %c",&ch[i][j]);

    printf("%lld\n",func(1,1));

    return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;
  vector<vi> d(n, vi(n, -1));
  rep(i, n - 1) rep2(j, i + 1, n) {
    int a = abs(i - j);
    int b = abs(i - x) + abs(j - y) + 1;
    d[i][j] = min(a, b);
  }
  map<int, int> mp;
  rep(i, n - 1) rep2(j, i + 1, n) mp[d[i][j]]++;
  rep2(i, 1, n) cout << mp[i] << endl;
}

Measured memory_bytes: 16000
class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None

parent_node = None

        
def getParent():
    tmp_node = Nodes
    while Nodes.parent != None:
        tmp_node = tmp_node.parent
    return tmp_node    

def printPreorder(u):
    if u == None:
        return
    print(" ", u.key, sep="", end="")
    printPreorder(u.left)
    printPreorder(u.right)
    
def printInorder(u):
    if u == None:
        return
    printInorder(u.left)
    print(" ", u.key, sep="", end="")
    printInorder(u.right)

def find(u, num):
    while u != None and u.key != num:
        if num < u.key:
            u = u.left
        else:
            u = u.right
    if u != None:
        print("yes")
    else:
        print("no")

n = int(input())

# メモリの確保
Nodes = []
for i in range(n):
    tmp_node = Node(0)
    Nodes.append(tmp_node)

for i in range(n):
    cmd = input().split()
    if cmd[0] == 'insert':
        key = int(cmd[1])

        insert_node = Nodes[i]
        insert_node.key = key
        key_parent = None
        x = parent_node
            
        while x != None:
            key_parent = x
            if insert_node.key < x.key:
                x = x.left
            else:
                x = x.right
        insert_node.parent = key_parent
            
        if key_parent == None:
            parent_node = insert_node
        elif insert_node.key < key_parent.key:
            key_parent.left = insert_node
        else:
            key_parent.right = insert_node
    # プリント
    elif cmd[0] == 'print':
        printInorder(parent_node)
        print("")
        printPreorder(parent_node)
        print("")
    # サーチ
    else:
        key = int(cmd[1])
        find(parent_node, key)


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

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

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

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

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

bool kaibun(int X){
    if(X/10000 != X%10) return false;
    X %= 10000; X /= 10;
    if(X/100 != X%10) return false;
    return true;
}
int main(void){
    int A,B; cin >> A >> B;
    int ans = 0;
    FOR(i,A,B+1){
        if(kaibun(i)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const long double pi=3.1415926535897932384626433832795;
int n,l,t[3030];
long double sumx,sumy,x,y;
int main()
{
	scanf("%d %d",&n,&l);
	for(int i=1;i<=n;++i)scanf("%d",&t[i]);
	int cnt;
	for(int i=1;i<=n;++i)
	{
		cnt=-1;
		for(int j=i+1;j<=n;++j)
		{
			++cnt;
			x=cos(pi*(t[i]+t[j])/l);
			y=sin(pi*(t[i]+t[j])/l);
			sumx+=(n-cnt-2-cnt)*x;
			sumy+=(n-cnt-2-cnt)*y;
		}
	}
	sumx=sumx*6/n/(n-1)/(n-2);
	sumy=sumy*6/n/(n-1)/(n-2);
	printf("%.15Lf %.15Lf",sumx,sumy);
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <math.h>
using namespace std;


double p[60][2];
double cx = 0, cy = 0;
int f;

int main(void){
	int n, i;
	cin >> n;
	for(i = 0; i < n; i++){
		cin >> p[i][0] >> p[i][1];
	}
	cx = (p[0][0] + p[n/2][0]) / 2;
	cy = (p[0][1] + p[n/2][1]) / 2;
	if(n%2) f=1;
	else for(i = 1; i < n/2; i++){
		if(fabs((p[i][0] + p[i + n/2][0]) / 2 - cx) <= 0.0000001 && fabs((p[i][1] + p[i + n/2][1]) / 2 - cy) <= 0.0000001) continue;
		f = 1;
		break;
	}
	if(f) cout << "NA" << endl;
	else printf("%.9lf %.9lf\n", cx , cy);

	return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& vec) {
    out << "[";
    for (int x : vec) out << x << ", ";
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
    #define dbg_var(x) cerr << #x << ": " << x << endl;
#endif

int main() {
    int a, b; cin >> a >> b;
    if(a + b == 15) cout << "+";
    else if(a * b == 15) cout << '*';
    else cout << 'x';
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
/*! if g++ -g alds_1_6_a.cpp -o alds_1_6_a.out; then ./alds_1_6_a.out < alds_1_6_a.test; fi
 */

#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iterator>
#include <numeric>
#include <functional>
#include <climits>



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

int main(int argc, char *argv[]){
  size_t n;
  cin >> n;
  vector<int> a(n);
  for (size_t i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> c(10010, 0);
  for (size_t i = 0; i < n; i++) {
    c[a[i]]++;
  }
  for (size_t i = 1; i < c.size(); i++) {
    c[i] += c[i-1];
  }
  vector<int> ret(n);
  for (int i = n-1; i >= 0; i--) {
    ret[c[a[i]]-1] = a[i];
    c[a[i]]--;
  }
  for (size_t i = 0; i < n-1; i++) {
    cout << ret[i] << " ";
  }
  cout << ret[n-1] << endl;


  return 0;
}

Measured memory_bytes: 16768
fn main() {
  let n = read_num();
  let v = read_nums();
  let c = read_nums();

  let mut result = 0;
  for i in 0..n as usize {
    let d = v[i] - c[i];
    if d > 0 {
      result += d;
    }
  }
  println!("{}", result)
}

fn read_line() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().to_string()
}

fn read_num() -> i32 {
    read_line().parse().unwrap()
}

fn read_nums() -> Vec<i32> {
    read_line()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double h = sc.nextDouble();
		double a = sc.nextDouble();
		sc.close();
		double r = h/a;
		System.out.println((int)Math.ceil(r));
	}
}

Measured memory_bytes: 23252
S=input()
a=len(S)
ans=1
if S[0:a//2]!=S[a//2+1:a][::-1]:
  ans=0
b=(a-1)//2
A=S[0:a//2]
B=S[a//2+1:a]
if A!=A[::-1]:
  ans=0
if B!=B[::-1]:
  ans=0
if ans==1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
//package Beginner122;

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String str = s.next();
        int i = 0;
        HashSet<Character> set = new HashSet<>();
        set.add('A');
        set.add('T');
        set.add('G');
        set.add('C');
        int max = Integer.MIN_VALUE;
        while(i < str.length()) {
            int j = i;
            int count = 0;
            while(j < str.length() && set.contains(str.charAt(j))) {
                j++;
                count++;
            }

            max = Math.max(max, count);
            if(count == 0) {
                i++;
            } else {
                i = j;
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1000000000

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

	vector<pair<int,int>> Pbefore,Pafter;
	int did=0;

	int dx[2]={1,0},dy[2]={0,1};
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			for(int k=0;k<2;k++){
				if(i+dy[k]<0 || i+dy[k]>=h || j+dx[k]<0 || j+dx[k]>=w) continue;//枠外

				if(a[i][j]%2==1){
					a[i][j]--;
					a[i+dy[k]][j+dx[k]]++;
					did++;
					Pbefore.push_back(make_pair(i,j));
					Pafter.push_back(make_pair(i+dy[k],j+dx[k]));
				}
			}
		}
	}

	cout<<did<<endl;
	for(int i=0;i<Pafter.size();i++){
		cout<<Pbefore[i].first+1<<" "<<Pbefore[i].second+1<<" ";
		cout<<Pafter[i].first+1<<" "<<Pafter[i].second+1<<endl;
	}

	return 0;
}

Measured memory_bytes: 5228
ans = 0
x, y = map(int, input().split())
if x * y < 0:
    ans = abs(x + y) + 1
elif x == 0:
    ans = abs(y) + int(y < 0)
elif y == 0:
    ans = abs(x) + int(x > 0)
elif x < y:
    ans = y - x
else:
    ans = x - y + 2
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main() {
 	int count = 0, x, y;
 	scanf("%d %d", &x, &y);

	for (int i = 0; i < y; i++) {
		for (int j = 0; j < y; j++) {
			if (i * 2 + j * 4 == y && i + j == x) {
				count += 1;
			}
		}
	}
  	
  	if (count >= 1) {
      	printf("Yes");
    }
  	else {
      	printf("No");
    }
  
  	return 0;
}

Measured memory_bytes: 1732
function Main(input) {
    input = input.split(' ');
    const a = input.map(x => parseInt(x, 10))

    if (a[0] + a[1] >= a[2]) {
        console.log('Yes');
    }
    else {
        console.log('No');
    }
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  REP(i, h) cin >> s[i];
  int ans = INF;
  REP(i, 1 << h) {
    vi b(h);
    REP(j, h) if (i & (1 << j)) b[j] = 1;
    int cnt = 1;
    vi v;
    FOR(j, 1, h) {
      if (b[j] != b[j - 1]) {
        v.push_back(cnt);
        cnt = 1;
      } else {
        cnt++;
      }
    }
    v.push_back(cnt);

    int tmp = 0;
    vi c(v.size());
    REP(l, w) {
      int sum = 0;
      vi d(v.size());
      REP(j, v.size()) {
        REP(a, v[j]) {
          d[j] += s[sum + a][l] - '0';
        }
        sum += v[j];
      }
      vi e(v.size());
      REP(i, v.size())e[i] = c[i] + d[i];
      if (*max_element(ALL(d)) > k) {
        tmp = INF;
      }
      else if (*max_element(ALL(e)) > k) {
        tmp++;
        c = d;
      }
      else {
        c = e;
      }
    }
    chmin(ans, tmp + (int)v.size() - 1);
  }

  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <bitset>
#include <functional>
#include <queue>
#include <utility>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long LL;

using namespace std;

// union_set(x, y) : x が入っている集合と y が入っている集合を併合する。
// find_set(x, y) ; x と y が同じ集合に入っているかどうかを判定する。
// make_set(x) : x のみが入る集合 {x} を作る。
struct UnionFind {
	vector<LL> par;	// par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 (根のみ負値で木の大きさが保存される)
	vector<LL> rank;	// 木の高さ(低い方を高い方に繋げるようにする)

	// 最初は全てが根であるとして初期化
	UnionFind(LL N) : par(N, -1), rank(N, 0) {}

	// データxが属する木の根を再帰で得る : root(x) = {xの木の根}
	LL root(LL x) {
		if (par[x] < 0) {				// 根
			return x;
		}
		return par[x] = root(par[x]);	// 経路圧縮
	}

	// xとyの木を併合
	void unite(LL x, LL y) {
		LL rx = root(x);	// xの根をrx
		LL ry = root(y);	// yの根をry
		if (rx == ry) return;	// xとyの根が同じ時(=同じ木にある時)はそのまま

		// xとyの根が同じでない時(=同じ木にないとき)
		// 木の高さが高い方に低い方を繋げるようにする
		if (rank[rx] < rank[ry]) swap(rx, ry);
		par[rx] += par[ry];
		par[ry] = rx;

		if (rank[rx] == rank[ry]) {
			rank[rx]++;
		}
	}

	// 2つのデータ(x, y)が属する木が同じならtrueを返す
	bool same(LL x, LL y) {
		LL rx = root(x);
		LL ry = root(y);
		return rx == ry;
	}
	
	// xが属するグループと同じグループに属する葉の数を得る
	LL size(LL x) {
		return -par[root(x)];
	}
};

int main(void)
{
	LL N, M;
	LL A[100001], B[100001];

	cin >> N >> M;
	FOR(i, 0, M) {
		cin >> A[i] >> B[i];
	}

	UnionFind tree(N);	// 島の情報
	vector<LL> inc;
	inc.push_back(N * (N - 1) / 2);

	// 島に橋の情報を追加
	for (int i = M - 1; i >= 0; i--) {
		// もし島と島がつながっていれば
		if (tree.same(A[i] - 1, B[i] - 1)) {
			// 不便さはそのまま
			inc.push_back(inc.back());
		}
		else {
			// 繋がっていなければ、AとBの島の繋がっている数を掛けたものを引いた値になる
			inc.push_back(inc.back() - tree.size(A[i] - 1) * tree.size(B[i] - 1));
		}
		tree.unite(A[i] - 1, B[i] - 1);
	}


	for (int i = M - 1; i >= 0; i--) {
		cout << inc[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 5364
n = int(raw_input())
a = []
b = []
for i in range(n):
    ca, cb = map(int, raw_input().split())
    a.append(ca)
    b.append(cb)

added = 0
for i in range(n-1, -1, -1):
    ca = a[i] + added
    cb = b[i]
    need = cb - (ca % cb)
    need = need % cb
    added += need

print added


Measured memory_bytes: 12208
n = int(input())
a = {}
for _ in range(n):
    s = input()
    if s in a:
        a[s] += 1
    else:
        a[s] = 1
m = int(input())
for _ in range(m):
    s = input()
    if s in a:
        a[s] -= 1
    else:
        a[s] = -1
ans = 0
for i in a:
    ans = max(ans,a[i])
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void){
    int i, N, V[30], C[30], PROFIT[30];
    scanf("%d", &N);
    for(i=0; i<N; i++) scanf("%d", V+i);
    for(i=0; i<N; i++) scanf("%d", C+i);
    for(i=0; i<N; i++) PROFIT[i] = V[i] - C[i];
    int ANS=0;
    for(i=0; i<N; i++){
        if(PROFIT[i] > 0) ANS += PROFIT[i];
    }
    printf("%d\n", ANS);
    return 0;
}


Measured memory_bytes: 128
import math
a,b=map(int,input().split())
cmin=a/0.08
cmax=(a+1)/0.08
dmin=b/0.1
dmax=(b+1)/0.1

#print(cmin,cmax)
#print(dmin,dmax)
if (cmin>=dmax or cmax<=dmin):
  print(-1)
else:
  if (cmin<dmin):
    print(math.ceil(dmin))
  elif (dmin<=cmin):
    print(math.ceil(cmin))

Measured memory_bytes: 3064
"""
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np
"""

def main():
	s=input()

	n=len(s)

	l=0
	r=n-1

	ans=0

	while l<r:

		if s[l]==s[r]:
			l+=1
			r-=1

		elif s[l]=="x":
			ans+=1
			l+=1

		elif s[r]=="x":
			ans+=1
			r-=1

		else:
			print(-1)
			exit()

	print(ans)
	return

if __name__ == "__main__":
	main()


Measured memory_bytes: 9244
#include <cstdio>
#include <map>
#include <algorithm>

int main()
{
  int n;
  char s[101];
  std::map<char, int> a, b;
  scanf("%d %s", &n, s);
  for (char *p = s; *p; ++p)
  {
    a[*p]++;
  }
  int ans = 0;
  for (char *p = s; *p; ++p)
  {
    b[*p]++;
    a[*p]--;
    int count = 0;
    for (char c = 'a'; c <= 'z'; ++c)
    {
      if (a[c] > 0 && b[c] > 0) ++count;
    }
    if (ans < count) ans = count;
  }
  printf("%d\n", ans);
  return 0;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()

template<typename T>
struct Prim{
  struct edge{
    int to;
    T cost;
    bool operator < (const edge &e)const
    {
      return cost < e.cost;
    };
  };

  int V;
  std::vector<std::vector<edge>> Edges;
  Prim(int V):V(V), Edges(V){}

  void add_edge(int f, int t, T cost){
    Edges[f].push_back({t, -cost});
    Edges[t].push_back({f, -cost});
  }

  T execution(){
    std::priority_queue<edge>que;
    std::vector<bool>used(V,false);
    que.push({0, 0});
    T ret = 0;
    while(!que.empty()){
      T cost = que.top().cost;
      int v = que.top().to;
      que.pop();
      if(used[v])continue;
      used[v] = true;
      ret += cost;
      for(auto e:Edges[v]){
	que.push(e);
      }
    }
    return -ret;
  }
};
int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  ll v,e;std::cin>>v>>e;
  Prim<int>prim(v);
  for(int i=0;i<e;i++){
    ll a,b,c;std::cin>>a>>b>>c;
    prim.add_edge(a,b,c);
  }
  std::cout<<prim.execution()<<std::endl;
  return 0;
}



Measured memory_bytes: 7972
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mpcy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 100005;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = - 1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, S, X[MAXN], dir;
LL p[MAXN], ans;

void init() {
	read(n); read(S);
	for (int i = 1; i <= n; ++i) {
		read(X[i]); read(p[i]);
	}
}

void solve() {
	int l = 1, r = n;
	while (1) {
		if (X[l] >= S) {
			ans += X[r] - S;
			break;
		}
		if (X[r] <= S) {
			ans += S - X[l];
			break;
		}
		if (p[l] >= p[r]) {
			if (dir != 1) {
				ans += X[r] - X[l];
				dir = 1;
			}
			p[l] += p[r--];
		} else {
			if (dir != -1) {
				ans += X[r] - X[l];
				dir = -1;
			}
			p[r] += p[l++];
		}
	}
	printf("%lld\n", ans);
}

int main() {
	init();
	solve();
	return 0;
}


Measured memory_bytes: 4876
#include<cstdio>
#include<cctype>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e5+100,M=2e5+100,INF=0x7fffffff/2;
bool vis[N],flag;
int n,m,dis[N];
struct Graph{
	int tot,tail[N];
	struct edge{
		int v,w,last;
	}e[M<<1];
	void clear(){tot=0;memset(tail,0,sizeof tail);} 
	void add(int x,int y,int w){
		e[++tot]=(edge){y,w,tail[x]};
		tail[x]=tot;
	}
}G;
void SPFA_DFS(int h)
  {
       if(flag) return ;
       register int p,v,w;
       vis[h]=true;
       for(p=G.tail[h];p;p=G.e[p].last)
       {
           v=G.e[p].v,w=G.e[p].w;
           if(dis[v]>dis[h]+w)
          {
              if(vis[v]){flag=true;return ;}
              dis[v]=dis[h]+w;
              SPFA_DFS(v);
              if(flag) return ;
          }    
      }
      vis[h]=false;
  }
int main()
{
	register int i,l,r,d;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;++i){
		scanf("%d%d%d",&l,&r,&d);
		G.add(l,r,d),G.add(r,l,-d);
	}
	for(i=1;i<=n;++i){
		SPFA_DFS(i); 
	}
	if(flag) printf("No");
	else printf("Yes");
	return 0;
} 

Measured memory_bytes: 9856
ls = []
def onoff(n):
    global ls
    if len(n) == 10:
        ls.append(n)
    else:
        onoff(n + '0')
        onoff(n + '1')
onoff('0')
onoff('1')
del ls[0]
n = int(input())
f = [list(map(str,input().split())) for x in range(n)]
p = [list(map(int,input().split())) for x in range(n)]
ans = -99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
for i in range(1023):
    check = 0
    for j in range(n):
        count = 0
        for k in range(10):
            if ls[i][k] == f[j][k] and ls[i][k] == '1':
                count += 1
        check += p[j][count]
    ans = max(ans,check)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
int main(){
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    string x,s;
    cin>>x>>s;
    for(int i=0;i<x.size();i++){
        cout<<x[i]<<s[i];
    }
    return 0;
}



Measured memory_bytes: 384
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    val m = sc.nextLong()
    println(problem090c(n, m))
}

fun problem090c(n: Long, m: Long): Long {
    return Math.abs((m - 2) * (n - 2))
}

Measured memory_bytes: 31128
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string.h>

using namespace std;

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

int main() {

	char S[123456];
	scanf("%s", S);
	int a = 0, b = 0, c = 0, l = 0;
	for (int i = 0; S[i] != '\0'; i++) {
		l++;
		switch (S[i])
		{
		case 'a':
			a++;
			break;
		case 'b':
			b++;
			break;
		case 'c':
			c++;
			break;
		default:
			break;
		}
	}

	if (max({ max(a, b) - min(a, b), max(b, c) - min(b, c), max(c, a) - min(c, a) }) <= 1) printf("YES\n");
	else printf("NO\n");

	return 0;
}

Measured memory_bytes: 256
defmodule Main do
  def main do
    _n = IO.gets("") |> String.trim() |> String.to_integer()

    arr =
      IO.gets("")
      |> String.trim()
      |> String.split()
      |> Enum.map(&String.to_integer/1)

    case Enum.find(arr, fn x -> x == 0 end) do
      0 ->
        IO.puts(0)

      nil ->
        Main.list_multi(arr, 1)
    end
  end

  def list_multi([first | []], acc) do
    if acc * first <= 1_000_000_000_000_000_000 do
      IO.puts(acc * first)
    else
      IO.puts(-1)
    end
  end

  def list_multi([first | rest], acc) do
    if acc > 1_000_000_000_000_000_000 do
      IO.puts(-1)
    else
      new_acc = acc * first
      list_multi(rest, new_acc)
    end
  end
end

Measured memory_bytes: 57332
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;
    
    vector<vector<pair<ll, ll>>> G(n);
    rep(i, n-1) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;  b--;
        G[a].pb(make_pair(b, c));
        G[b].pb(make_pair(a, c));
    }

    ll q, K;
    cin >> q >> K;
    K--;
    
    vl dist(n, -1);  // dist[i] : 頂点iの根からの距離
    queue<ll> Q;

    const ll root = K;
    dist[root] = 0;
    Q.push(root);
    while(!Q.empty()) {
        ll v = Q.front();
        Q.pop();
        for(auto p : G[v]) {
            ll u = p.first;
            ll cost = p.second; 
            if(dist[u] != -1) {
                continue;
            }
            dist[u] = dist[v] + cost;
            Q.push(u);
        }
    }

    vl ans(q);
    rep(i, q) {
        ll x, y;
        cin >> x >> y;
        x--;  y--;
        ans[i] = dist[x] + dist[y];
    }

    rep(i, q) {
        out(ans[i]);
    }
    
    re0;
}

Measured memory_bytes: 10752
import java.util.Scanner;

public class Main{

	public static void main(String []args) {
		Scanner sc = new Scanner(System.in);
		
		int k = Integer.parseInt(sc.next());
		
		int p = 7%k;
		
		if((k % 10) % 2 == 0) {
			System.out.println(-1);
			return;
		}
		if((k%10)== 5) {
			System.out.println(-1);
			return;
		}
		
		long cnt = 1;
		
		while(cnt <= k) {
			if(p == 0) {
				break;
			}
			cnt++;
			p = (p*10+7)%k;
		}
		if(cnt == k+1) {
			System.out.println(-1);
			return;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 35612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
const ll inf = 1001001001;
const ll mod = 1000000007;
 
int main() {
    int n;
    cin >> n;
    vector<ll>v(n+1);
    rep(i, 0, n+1)cin >> v[i];
    if(n==0){
        if(v[0]==1){
            cout << 1 << endl;
            return 0;
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    if(v[0]!=0){
        cout << -1 << endl;
        return 0;
    }
    ll tot=0;
    rep(i, 0, n+1)tot += v[i];
    ll root = 1;
    ll ans = 1;
    rep(i, 1, n+1){
        root *= 2;
        if(root<v[i]){
            cout << -1 << endl;
            return 0;
        }
        ans += min(tot, root);
        root = min(tot, root) - v[i];
        tot -= v[i];
    }
    cout << ans << endl;
}

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

class C {
 public:
  int x;
  C(int x) { this->x = x; }
};

int operator|(const C& s, const C& t) {
  return abs(s.x - t.x);
}

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  int distance_a = C(x) | C(a);
  int distance_b = C(x) | C(b);
  if (distance_a <= distance_b) {
    cout << "A" << endl;
  } else {
    cout << "B" << endl;
  }
}


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

long long int getgcd(long long int n,long long int m)
{
  long long int r;
  if (n > m) {
    long long int t = m;
    m = n;
    n = t;
  }
  while ((r = m % n) != 0) {
    m = n;
    n = r;
  }
  return n;
}


int main(){
  long long int N,X,i;
  scanf("%lld", &N);
  scanf("%lld", &X);

  long long int x[N];
  for(i = 0; i < N; i++)
    scanf("%lld",&x[i]);

  long long int tmp = llabs(x[0]-X);
  for(i = 1; i < N; i++){
    tmp = getgcd(tmp, llabs(x[i]-X));
  }
  printf("%lld\n",tmp);
  return 0;

}

Measured memory_bytes: 896
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <math.h>
#include <stdio.h>
#include <deque>

using namespace std;

#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define REV(v) for (auto itr = v.rbegin(); itr != v.rend(); itr++)
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a));
#define MINUS(a) memset(a,-1,sizeof(a));
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pi pair<int, int>
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define VL(v,n) vector<ll> v(n);
#define Read_VL(v,n) vector<ll> v(n);REP(i,0,n)cin>>v[i];
#define sumV(v,n) Vl(acm,n) REP(i,0,n) acm[i] = v[i] + ( i == 0 ? 0 : acm[i - 1]);
#define EPS (1e-10)
#define INF 1000000000000LL

void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}


template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		REP(i,0,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};


bool length_cmp( string &a, string &b ){
  return a.size() < b.size();
}

ll StoLL( string s )
{
	ll num=0;
  REP( i, 0, s.size() ){
    num = num * 10 + ( s[i] ^ 48 );
  }
  return num;
}

ll CtoLL( char c )
{
	if( 'a' <= c && c <= 'z'){
		return (ll)( c ^ 96 ) ;
	}
	else if( 'A' <= c && c <= 'Z'){
		return (ll)( c ^ 64 );
	}
  return 0;
}


ll mod=1000000007;
ll dx[4] = { 1, 0, -1, 0 };
ll dy[4] = { 0, 1, 0, -1 };
//I ASCII code: '0' = 48; 'A' = 65; 'a' = 97

#include <chrono>
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    LIN(n)
    vector< string > w(n);
    map< string, ll > mp;
    bool correct = 1;

    REP( i, 0, n ){
      cin>>w[i];
      mp[ w[i] ]++;
    }

    for( auto x:mp ){
      if(x.second > 1) correct = 0;
    }

    if( correct ){
      REP( i, 0, n-1 ){
        set<char> st;
        st.insert( LAST(w[i]) );
        st.insert( w[i+1][0] );
        if( st.size() > 1 ) correct = 0;
      }
    }

    Yn( correct );
    return 0;
}


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

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  int a;
  if (n % max(h,w) == 0){
      a = n / max(h,w);
  }else{
      a = n / max(h,w) + 1;
  }
  cout << a << endl;
}


Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as V
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

readInt :: IO Int
readInt = fst . fromJust . C.readInt <$> C.getLine

main :: IO ()
main = do
  n <- readInt
  print $ g n

f :: Int -> V.Vector (Int,Int)
f n = V.fromList [(x, n-x) | x <- [1..((n+1) `div` 2)]]

sod
  :: Int -> Int
sod n
  | q == 0 = r 
  | otherwise = r + sod q
  where
    (q,r) = quotRem n 10

sod2
  :: Int -> Int -> Int
sod2 x y = sod x + sod y

g :: Int -> Int
g = V.minimum . V.map (uncurry sod2) . f

Measured memory_bytes: 892