akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define N 100000

struct Node{
  int p;
  int left;
  int right;
};

struct Node T[N];
int count =0;
int depth(int);
void degree(int);

int main(){
  int i,j,n,k,left,right,node,m,c;
  
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].left = T[i].right = -1;
  for(i=0;i<n;i++){
    scanf("%d%d",&node,&m);
    for(j=0;j<m;j++){
      scanf("%d",&c);
      T[c].p = node;
      if(j!=0) T[left].right = c;
      else T[node].left = c;
      left = c;
    }
  }
  
  for(i=0;i<n;i++){
    count = 0;
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,depth(i));
    if(T[i].p == -1) printf("root, [");
    else if(T[i].left == -1) printf("leaf, [");
    else  printf("internal node, [");
    count = 0;
    degree(T[i].left);
    printf("]\n");
  }
  return 0;
}
  
int depth(int id){
  if(T[id].p==-1){
 return count;
  }
  else{
    count++;
    return  depth(T[id].p);
  }
}

void degree(int id){
  if(id!=-1){
    if(count!=0){
      printf(", ");
    }
    printf("%d",id);
    count++;
    degree(T[id].right);
  }
}

Measured memory_bytes: 1784
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)

	_s := strings.Split(s, "")

	var ans int

	var ansFormat string
	var _ansFormat []string

	var i, j uint
	for i = 0; i < (uint(1) << uint(len(_s)-1)); i++ {
		ansFormat = ""
		for j = 0; j < uint(len(_s)); j++ {
			ansFormat = ansFormat + _s[j]
			if i>>j&1 == 1 {
				ansFormat = ansFormat + "+"
			}
		}
		_ansFormat = strings.Split(ansFormat, "+")
		for n := 0; n < len(_ansFormat); n++ {
			var a, _ = strconv.Atoi(_ansFormat[n])
			ans = ans + a
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
 
  int N , M ;
  cin >> N >> M ;
  vector<int> A(N) ;
  rep(i,N) A.at(i) = -1 ;
  rep(i,M){
    int c , s ;
    cin >> c >> s ;
    c-- ;
    if( A.at(c) != -1 ){
      if(A.at(c) == s ) continue  ;
      else{
        cout << -1 << endl;
        return 0 ;
      }
    }
    else A.at(c) = s ;
  }
  if(A.at(0) == 0 && N >= 2 ){
    cout << -1 << endl;
    return 0 ;
  }
  if( N == 1 && M == 0 ){
    cout << 0 << endl;
    return 0 ;
  }
  if(A.at(0) == -1 ) A.at(0) =  1 ;
  for(int i = 0 ; i < N ; i++ ){
    if( A.at(i) == -1 ) A.at(i) = 0 ;
    cout << A.at(i) ;
  }
}

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

ll f(ll b,ll n){
  if(n<b)return n;
  else return f(b,n/b)+(n%b);
}

int main(){
  ll n,s;
  cin>>n>>s;
  
  for(ll i=2;i*i<=n;i++){
    ll v = f(i,n);
    if(v==s){
      cout<<i<<endl;
      return 0;
    }
  }
  // a+b == s
  // ax + b == n
  // ax-a == n-s
  // a(x-1) == n-s
  // a<x
  // b<x

  if(n==s){
    cout<<n+1<<endl;
    return 0;
  }else if(n<s){
    cout<<-1<<endl;
    return 0;
  }

  ll INF=(1LL<<60);
  ll ans=INF;
  
  ll target=n-s;
  for(ll i=1;i*i<=target;i++){
    if(target%i!=0)continue;

    ll a=i;
    ll b=s-a;
    ll x=(n-b)/a;

    if(1<x && f(x,n) == s && 0<a&&a<x&&0<=b&&b<x){
      ans=min(ans,x);
    }

    a=target/i;
    b=s-a;
    x=(n-b)/a;
    if(1<x && f(x,n) == s && 0<a&&a<x&&0<=b&&b<x){
      ans=min(ans,x);
    }
  }
  if(ans==INF)ans=-1;
  cout<<ans<<endl;
  return 0;
}


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

int main(){
	int N;
	cin >> N;
	for(int i = 9; i >= 0; i--){
		if(N % i == 0){
			if(0 < (N / i) && (N / i) < 10){
				cout << "Yes" << endl;
			}else{
				cout << "No" << endl;
			}
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
struct pos {
  int row;
  int column;
};
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
int main(void) {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> bridges;
  bridges.resize(M);
  rep(i, M) { cin >> bridges[i].second >> bridges[i].first; }

  Sort(bridges);

  int last = -1;
  int count = 0;
  rep(i, M) {
    if (last < 0 || bridges[i].second >= last) {
      last = bridges[i].first;
      count++;
    }
  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>

using namespace std;

typedef complex<double> Point;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()
const double eps = 1e-10;

template<typename T>
inline void uniq(T& c){sort(all(c)); c.erase(unique(all(c)), c.end());}

namespace std {
    bool operator<(const Point& a, const Point& b){
        return make_pair(a.real(), a.imag()) < make_pair(b.real(), b.imag());
    }
    bool operator==(const Point& a, const Point& b){
        return abs(a - b) < eps;
    }
};

inline double cross(const Point& a, const Point& b){
    return imag(conj(a) * b);
}

inline double dot(const Point& a, const Point& b){
    return real(conj(a) * b);
}

int ccw(Point a, Point b, Point c){
    b -= a; c -= a;
    if(cross(b, c) > eps)return 1;
    if(cross(b, c) < -eps)return -1;
    if(dot(b, c) < 0)return 2;
    if(norm(b) < norm(c))return -2;
    return 0;
}

struct Line : vector<Point> {
    Line(const Point& a, const Point& b):vector<Point>{a, b}{}
};

inline bool interSS(const Line& s, const Line& t){
    return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
           ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}

Point xptLL(const Line& l, const Line& m){
    double d = cross(l[1] - l[0], m[1] - m[0]);
    if(abs(d) < eps)return Point(~0, ~0);
    return m[0] + (m[1] - m[0]) * cross(l[1] - l[0], l[1] - m[0]) * (1. / d);
}

inline bool eq(const double a, const double b){
    return abs(a - b) < eps;
}

int solve(vector<Line>& ls){
    int res = 1;
    rep(i, (int)ls.size()){
        vector<Point> ps;
        rep(j, i){
            if(!interSS(ls[i], ls[j]))continue;
            Point xpt = xptLL(ls[i], ls[j]);
            if(eq(abs(xpt.real()), 100) || eq(abs(xpt.imag()), 100))continue;
            ps.push_back(xpt);
        }
        uniq(ps);
        res += (int)ps.size() + 1;
    }
    return res;
}

int main(){
    int n;
    while(cin >> n, n){
        vector<Line> ls;
        rep(i, n){
            int x1, y1, x2, y2;
            cin >> x1 >> y1 >> x2 >> y2;
            ls.emplace_back(Point(x1, y1), Point(x2, y2));
        }
        cout << solve(ls) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int H, W;
    cin >> H >> W;

    map<int, int> currToStart; //! map from current pos to the right-most start pos to reach the current pos
    multiset<int> costs; //! multisets of horizontal move costs

    for (int x = 1; x <= W; ++x) {
        currToStart[x] = x;
        costs.insert(0);
    }

    rep(i, H) {
        int A, B;
        cin >> A >> B;
        int maxStart = -1;
        auto it = currToStart.lower_bound(A);
        while (it != currToStart.end() && it->first <= B+1) {
            int curr = it->first;
            int start = it->second;
            maxStart = max(maxStart, start);
            costs.erase(costs.find(curr-start));
            currToStart.erase(it++);
        }
        if (B < W && maxStart != -1) {
            int newCurr = B+1;
            int newStart = maxStart;
            currToStart[newCurr] = newStart;
            costs.insert(newCurr-newStart);
        }

        if (costs.empty()) {
            cout << -1 << endl;
        } else {
            cout << i+1+(*costs.begin()) << endl;
        }
    }

    return 0;
}


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

int h, w, a, b;
ll t[1 << 17], d[1 << 17];

int main()
{
    cin >> h >> w >> a >> b;
    int ans = h * w;
    cout << (h % a) * w + (w % b) * h - (h % a) * (w % b) << endl;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll a,b; cin>>a>>b;
	if((a+b)%2==0) cout<<(a+b)/2<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
	
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    int n;cin>>n;
    int *arr=new int[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    int ans=1e18;
    int cnt=0;
    for(int i=0;i<(n-1);i++)
    {
        cnt+=arr[i];
        int rem=sum-cnt;
        ans=min(ans,abs(rem-cnt));
    }
    cout<<ans;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N, M, T;
  cin >> N >> M >> T;
  map< int, vector< pair< int, int > > > ev;
  ev[T] = {};
  for(int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --b;
    ev[a].emplace_back(b, c);
  }
  set< int > exist;
  unordered_map< int, int > mp[100000];
  int pv = 0;
  for(auto &latte : ev) {
    for(auto &p : exist) {
      for(auto &q : exist) {
        if(p != q) mp[p][q] += latte.first - pv;
      }
    }
    for(auto &p : latte.second) {
      if(p.second == 1) exist.emplace(p.first);
      else exist.erase(p.first);
    }
    pv = latte.first;
  }

  for(int i = 0; i < N; i++) {
    int tap = 0, id = i == 0;
    for(auto &p :mp[i]) {
      if(tap < p.second || (tap == p.second && p.first < id)) {
        tap = p.second;
        id = p.first;
      }
    }
    cout << id + 1 << "\n";
  }
}




Measured memory_bytes: 219788
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int N,X,sum = 0;
  int ans = 200000;
  cin >> N >> X;
  vector<int> m(N);
  for(int i = 0; i < N; i++){
    cin >> m[i];
    sum = sum + m[i];
    ans = min(ans, m[i]);
  }

  int ans2 = X - sum;
  /*cout << sum << " " << ans << endl;
  cout << ans2 << endl;*/
  int count = 0;
  for(int i = ans; i <= ans2; i+=ans){
    /*cout << i << endl;*/
    count = count + 1;
  }
  cout << count + N << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const int MOD=1e9+7;
int modinv(ll a)
{
  ll b=MOD,u=1,v=0;
  while(b)
  {
    ll t=a/b;
    a-=t*b;swap(a,b);
    u-=t*v;swap(u,v);
  }
  u%=MOD; 
  if(u<0)u+=MOD;
  return u;
}
int main()
{
  ll answer=0,N;
  cin>>N;
  vector<ll> s(N,0);
  for(int i=0;i<N;i++) cin>>s.at(i);
  for(int i=0;i<N-1;i++) answer+=((s.at(N-1)-s.at(i))*modinv(i+1))%MOD;
  for(int i=1;i<N;i++) answer=(answer*i)%MOD;
  cout<<answer<<endl;
}

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

#define gcu getchar_unlocked
static inline int in()
{
	int c, n = 0;
	while ((c = gcu()) >= '0' && c <= '9')
		n = 10 * n + (c - '0');
	return n;
}

#define pcu putchar_unlocked
static inline void out(int n)
{
	static char buf[20];
	char *p = buf;
	bool minus = false;
	if(n < 0)
		minus = true, n *= -1;
	if (!n)
		*p++ = '0';
	else
		while (n)
			*p++ = n % 10 + '0', n /= 10;
	if (minus)
		*p++ = '-';
	while (p != buf)
		pcu(*--p);
}

static inline void out(const char *s) {
	while (*s)
		pcu(*s++);
}

typedef vector<int> v;
typedef v::iterator vi;
struct node { int p = -1, d = -1; v c; };
typedef vector<node> vn;

int depth(vn &n, int id) {
	if (n[id].d > 0)
		return n[id].d;
	else if (n[id].p == -1)
		return 0;
	else {
		int res = 1 + depth(n, n[id].p);
		n[id].d = res;
		return res;
	}
}

int main()
{
	int n = in();
	vn nodes(n);

	while (n--) {
		int id = in();
		nodes[id].c.resize(in());
		for (int &x: nodes[id].c) {
			x = in();
			nodes[x].p = id;
		}
	}

	int id = 0;
	for (node u: nodes) {
		int d = depth(nodes, id);
		out("node ");
		out(id++);
		out(": parent = ");
		out(u.p);
		out(", depth = ");
		out(d);
		out(", ");
		out(d == 0 ? "root" : u.c.size() ? "internal node" : "leaf");
		out(", [");
		for (int &x: u.c) {
			if (&x != &u.c[0])
				out(", ");
			out(x);
		}
		out("]\n");
	}
}


Measured memory_bytes: 6224
total = 0
count = 0
rows = 0

while True:
    try:
        at,n = map(int, raw_input().split(","))
    except EOFError as e:
        break
    total += at * n
    count += n
    rows += 1

print("%d" % (total,))
print("%d" % (round(count/float(rows)),))

Measured memory_bytes: 4252
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >>n;
    for(int i=0;i<=25;i++){
        for(int j=0;j<=15;j++){
            if(4*i+7*j==n){
                cout <<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout <<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define PI 3.14159265358979323846264338327950L
 
int main(){
 
  int a,b;
  int h,m;
  scanf("%d%d%d%d",&a, &b, &h, &m);
 
  long double angle =  30*h + 0.5*m - m * 6 ;
  long double rad;
    //rad = (angle /180)* M_PI;
 
  //printf("%.10f ",h);
  long double ans = a*a + b*b - (2*a*b)*cosl(angle * (PI / 180));
  printf("%20.20Lf\n",sqrtl(ans));
 
  return 0;
}

Measured memory_bytes: 2540
H, W = map(int, input().split())
A = [list(input()) + ['#'] for i in range(H)]
A.append(['#'] * (W + 1))
MOD = 10 ** 9 + 7

P = [[0] * (W + 1) for i in range(H + 1)]
P[0][0] = 1

for h in range(H):
    for w in range(W):
        if A[h + 1][w] != '#':
            P[h + 1][w] += P[h][w]
            P[h + 1][w] %= MOD

        if A[h][w + 1] != '#':
            P[h][w + 1] += P[h][w]
            P[h][w + 1] %= MOD

print(P[-2][-2] % MOD)


Measured memory_bytes: 50488
N = int(input())
S = input()
DP = [[0]*(N+1)for i in range(N+1)]
ans = 0
for i in range(N):
    for j in range(N):
        if S[i] == S[j] :
            DP[i+1][j+1] = DP[i][j]+1
            if j-DP[i+1][j+1]-i < 0:
                DP[i+1][j+1] = 0
print(max([max(i) for i in DP]))
        

Measured memory_bytes: 230292
#include <iostream>
using namespace std;
int main() {
	int N, i,mochi, ans;
	int flag[101] = {};
	ans = 0;
	cin >> N;
	for (i=0;i < N;i++) {
		cin >> mochi;
		flag[mochi] = 1;
	}
	for (i = 0;i < 101;i++) {
		ans += flag[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef vector <int> ivector;

int seive(ivector &A, int n){
	ivector num(n+1,1);
	num[0]=0;
	num[1]=0;
	int count=1, limit=int(sqrt(n));
	for (int i=3; i<=n; i+=2)
		if (num[i]){
			count++;
			if (i<=limit)
				for (int j=3*i; j<=n; j+=2*i) num[j]=0;
		}

	A.resize(count);
	A[0] = 2;
	int j=1;
	for (int i=3; i<=n; i+=2)
		if (num[i]==1) A[j++]=i;
	return 0;
}

int main(void){
	ivector primes;
	int max_num=10000;
	seive(primes, max_num);

	int n, n0, lim, count;
	cin >> n;
	count = n;
	for (int i=0; i<n; i++){
		cin >> n0;
		lim = int(sqrt(n0));
		for (int j=0; j<(int)primes.size(); j++){
			int tmp=primes[j];

			if (tmp *tmp > n0)break;
			if (n0 % tmp == 0){
				count--;
				break;
			}
		}
	}
		cout<<count<<endl;
		return 0;
}

Measured memory_bytes: 1240
a,b,c,=map(int,input().split())
lis_1=[list(map(int,input().split())) for i in range(a)]
lis_2=[list(map(int,input().split())) for j in range(b)]
ans=[[0 for k in range(c)] for l in range(a)]
d=0
for i in range(a):#ansの行の変化
    for l in range(c):#ansの列をずらす
        for k in range(b):#lis_1の列をずらす
            d+=lis_1[i][k]*lis_2[k][l]
        ans[i][l]=d
        d=0
for z in range(a):
    for x in range(c-1):
        print(ans[z][x],end=" ")
    print(ans[z][c-1])


Measured memory_bytes: 7076
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#pragma GCC optimize(3 , "Ofast" , "inline")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
ll in()
{
  ll x = 0 , f = 1 ;
  char ch = getchar() ;
  while(!isdigit(ch)) {if(ch == '-') f = -1 ; ch = getchar() ;}
  while(isdigit(ch)) x = x * 10 + ch - 48 , ch = getchar() ;
  return x * f ;
}
vector<ll> a , b ;
ll c[N] , n , k ;
int main()
{
  n = in() , k = in() ;
  for(int i = 1, x ; i <= n ;i ++ )
   {
     c[i] = x = in() ;
     if(x > 0) a.push_back(x) ;
     else b.push_back(-x) ;
   }
   if(n == k)
    {
      ll ans = 1 ;
      for(int i = 1; i <= n ;i ++ )
       ans = (ans * c[i] % mod + mod )  % mod ;
      cout << (ans % mod + mod) % mod << endl ;
      return 0 ;
    }
   sort(a.begin() , a.end()) ;
   sort(b.begin() , b.end()) ;
   ll ans = 1 ;
   int p1 = a.size() - 1 , p2 = b.size() - 1 ;
   if(k % 2)
    {
      if(a.size())
         ans = a[p1 --] ;
       else {
         for(int i = 0 ;i < k ;i ++ )
          ans = (ans * (- b[i]) % mod + mod) % mod ;
         cout << (ans % mod + mod) % mod << endl ;
         return 0 ;
       }
    }
    for(int i = 0 ;i < k / 2 ;i ++ )
     {
       ll left = 0 , right = 0 ;
       if(p1 >= 1)
          left = 1ll * a[p1] * a[p1 - 1] ;
       if(p2 >= 1)
          right = 1ll * b[p2] * b[p2 - 1] ;
       if(left > right)
         left %= mod, ans = (ans * left % mod) , p1 -= 2 ;
       else right %= mod , ans = (ans * right % mod) % mod , p2 -= 2;
     }
    cout << (ans % mod + mod) % mod << endl ;
  return 0 ;
}
/*
*/


Measured memory_bytes: 6396
n = int(input())
a = list(map(int,input().split()))

def gcd(a,b):
    while b != 0:
        a,b = b,a%b
    return a

right_gcd = [0]*(n)
left_gcd = [0]*(n)
right_gcd[n-1] = a[n-1]
left_gcd[0] = a[0]

for i in range(n-1,0,-1):
    right_gcd[i-1] = gcd(right_gcd[i],a[i-1])

for i in range(n-1):
    left_gcd[i+1] = gcd(left_gcd[i],a[i+1])

except_gcd = [0]*n
for i in range(n):
    if i == 0:
        except_gcd[i] = right_gcd[1]
    elif i == n-1:
        except_gcd[i] = left_gcd[n-2]
    else:
        except_gcd[i] = gcd(left_gcd[i-1],right_gcd[i+1])

print(max(except_gcd))


Measured memory_bytes: 14584
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, W; cin >> N >> W;
	vector<int>dp(W + 1, 0);
	vector<int> v(N), w(N); rep(i, 0, N) { cin >> v[i] >> w[i]; }
	rep(i, 0, N)rrep(j, w[i], W + 1)
		chmax(dp[j], dp[j - w[i]] + v[i]);
	cout << dp[W] << endl;
	return 0;
}

Measured memory_bytes: 3196
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        while (true){
            int n = scanner.nextInt();
            if (n==0) break;

            List<Island> islands = new ArrayList<>();
            for (int i =0; i<n; i++){
                islands.add(new Island(scanner.nextInt(),scanner.nextInt()));
            }

            Collections.sort(islands);
            int sum = 0;
            boolean isOverLoad = false;
            for (int i=0; i<n; i++){
                sum += islands.get(i).treasure;
                if (sum > islands.get(i).amountBridge){
                    isOverLoad = true;
                    break;
                }
            }
            if (isOverLoad){
                System.out.println("No");
            }else {
                System.out.println("Yes");
            }


        }
    }
}

class Island implements Comparable<Island>{
    int treasure;
    int amountBridge;

    public Island(int treasure, int amountBridge) {
        this.treasure = treasure;
        this.amountBridge = amountBridge;
    }


    @Override
    public int compareTo(Island o) {
        return amountBridge-o.amountBridge;
    }
}



Measured memory_bytes: 32712
b1=b2=b4=0
readline()
for a=map(x->parse(Int,x),split(readline()))
  if a%4==0
    b4+=1
  elseif a%2==0
    b2+=1
  else
    b1+=1
  end
end
println(b4+(b2==0)>=b1 ? "Yes" : "No")

Measured memory_bytes: 124168
#include <iostream>
#include <string>
using namespace std;
int main() {
  const double rate = 380000.0;
  int N;
  cin >> N;
  
  if (N < 1)
    return -1;
  
  string unit;
  double amount;
  double total = 0.0;
  for (int i = 0; i < N; i++)
  {
    cin >> amount >> unit;
    if (unit.compare("JPY") == 0)
      total += amount;
    else
      total += amount * rate;
  }

   cout << total << endl;

  return 0;
}

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

int min_sirokuro(string S){
    int i;
    int min1=0,min2=0;

    //cout << S.length() << endl;

    for(i=0;i<S.length();i++){
      //  cout << "i " << i << " S " << S[i] << endl;
      //  cout << i%2 << endl;
        if(S[i]== '1' && i%2==0){
            min1++;
        }
        else if(S[i]== '0' && i%2==1){
            min1++;     
        }
        //cout << S[i];
    }
    for(i=0;i<S.length();i++){
        if(S[i]== '1' && i%2==1){
            min2++;
        }
        else if(S[i]== '0' && i%2==0){
            min2++;
          //  cout << i << endl;
        }
        //cout << S[i] << endl;
    }
 //   cout << "min1 " << min1 << " min2 " << min2 << endl;
    return min(min1,min2);
}



int main(){
    string S;
    cin >> S;

    cout << min_sirokuro(S) <<endl;

    return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> xs(n);
    for (auto& x : xs) {
        cin >> x.first;
    }
    for (auto& x : xs) {
        cin >> x.second;
    }
    sort(xs.begin(), xs.end(), [](auto& p1, auto& p2) { return p1.second < p2.second; });
    vector<pair<int, int>> as(n);
    vector<int> bs(n);
    for (int i = 0; i < n; ++i) {
        as[i].first = xs[i].first;
        as[i].second = i;
    }
    for (int i = 0; i < n; ++i) {
        bs[i] = xs[i].second;
    }
    sort(as.begin(), as.end());
    sort(bs.begin(), bs.end());
    vector<int> perm(n);
    int state = 1;
    for (int i = n-1; i >= 0 && state > 0; --i) {
        int a = as[i].first, p = as[i].second;
        if (a > bs[i]) {
            state = 0;
        } else if (i - 1 >= 0 && a <= bs[i - 1]) {
            state = 2;
        }
        perm[p] = i;
    }
    if (state == 0) {
        cout << "No" << endl;
    } else if (state == 1) {
        int x = 0;
        for (int i = 0;i < n-1; ++i) {
            x = perm[x];
            if (x == 0) {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main()
{
    int ret=false;
    string s;
    cin >> s;
    if (s[0]==s[1]||s[1]==s[2]||s[2]==s[3]) {
        ret=true;
    } else {
        // nothing
    }
    if (ret) {
        cout << "Bad";
    } else {
        cout << "Good";
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
struct Color {char s[8]; int R, G, B; double d;};
Color t[8] = {{"black", 0, 0, 0}, {"blue", 0, 0, 255}, {"lime", 0, 255, 0}, {"aqua", 0, 255, 255}, {"red", 255, 0, 0}, {"fuchsia", 255, 0, 255}, {"yellow", 255, 255, 0}, {"white", 255, 255, 255}};
int main()
{
	char s[8];
	int R, G, B, i, r;
	double rd;
	while (scanf("%8s", s))
	{
		if (strcmp(s, "0") == 0) break;
		sscanf(s, "#%2x%2x%2x", &R, &G, &B);
		rd = 500.0;
		for (i = 0; i < 8; i++)
		{
			t[i].d = sqrt((double)(R - t[i].R)*(R - t[i].R) + (double)(G - t[i].G)*(G - t[i].G) + (double)(B - t[i].B)*(B - t[i].B));
			if (rd >= t[i].d)
				rd = t[i].d, r = i;
		}
		printf("%s\n", t[r].s);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define PI 2 * acos(0)
#define FAST ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define MAX 300000
#define debug cout << "asfasf" << endl;
#define READ freopen("input.txt", "r", stdin)
#define PRINT freopen("output.txt", "w", stdout);
#define MOD 1e7
#define print(a, b) printf("Case %d: %d\n", a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
/*................OMI.................*/

bool isPrime(ll n)
{
   if (n <= 1)
      return false;
   if (n <= 3)
      return true;

   if (n % 2 == 0 || n % 3 == 0)
      return false;

   for (ll i = 5; i * i <= n; i = i + 2)
      if (n % i == 0)
         return false;

   return true;
}
ll gcd(ll a, ll b)
{
   if (a == 0)
      return b;
   return gcd(b % a, a);
}

ll lcm(ll a, ll b)
{
   ll g = gcd(a, b);
   ll ans = (a * b) / g;
   return ans;
}

///palindrome check!
bool palindrome(string s)
{
   for (ll i = 0; i < s.length() / 2; i++)
   {
      if (s[i] != s[s.length() - i - 1])
         return 0;
   }
   return 1;
}
/// divisors->>
void printDivisors(int n)
{
   for (int i = 1; i <= sqrt(n); i++)
   {
      if (n % i == 0)
      {
         if (n / i == i)
            printf("%d ", i);

         else
            printf("%d %d ", i, n / i);
      }
   }
}
/// string to INT
int convert_number(string s)
{
   int n;
   stringstream(s) >> n;
   return n;

   // int v=atoi(ss.c_str());
   // atoi is better than this function in case of complexity
}

///prime storage>>>

vector<ll> prime;

void primes(ll m)
{

   bool isprime[m];
   for (int i = 0; i <= m; i++)
      isprime[i] = true;

   for (int i = 3; i * i <= m; i++)
   {
      if (isprime[i])
      {

         for (int j = i * i; j <= m; j += i)
            isprime[j] = false;
      }
   }
   prime.push_back(2);
   for (int i = 3; i <= m; i += 2)
      if (isprime[i])
         prime.push_back(i);
}

/************MAIN_FUNCTION***********/

int main(int argc, char *argv[])
{
   FAST;
   int n;
   cin >> n;
   string s;
   map<string, int> M;
   while (n--)
   {
      cin >> s;
      M[s]++;
   }
   cout << "AC"
        << " x " << M["AC"] << endl;
   cout << "WA"
        << " x " << M["WA"] << endl;
   cout << "TLE"
        << " x " << M["TLE"] << endl;
   cout << "RE"
        << " x " << M["RE"] << endl;
   return 0;
}

Measured memory_bytes: 3572
n,k = gets.chomp.split.map(&:to_i)
a = Array.new(n)

for i in 0..n-1
  a[i] = Array.new(2)
  a[i][0],a[i][1] = gets.chomp.split.map(&:to_i)
end

a.sort_by! { |i| i[0]}

for i in 0..n-1
  k = k - a[i][1]
  if k <= 0
    puts a[i][0]
    break 
  end
end

Measured memory_bytes: 12664
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define db double
 
const int MAXN = (1 << 17 | 3);
const int MAXE = 400400;
const int INF = 0x3f3f3f3f;
 
template<typename T> inline void CheckMax(T &A, T B) {
	A < B ? A = B : A;
}
 
template<typename T> inline void CheckMin(T &A, T B) {
	A > B ? A = B : A;
}
 
template <typename T> inline void read(T &x) {
    int c = getchar();
    bool f = false;
    for (x = 0; !isdigit(c); c = getchar()) {
        if (c == '-') {
            f = true;
        }
    }
    for (; isdigit(c); c = getchar()) {
        x = x * 10 + c - '0';
    }
    if (f) {
        x = -x;
    }
}

struct Edge {
    int u, v, w;
    Edge(int _u, int _v, int _w) : u(_u), v(_v), w(_w) {}
};

vector<Edge>ans;

#define lowbit(x) (x & -x)

signed main() {
    int L;
    scanf("%d",&L);
    for(int i = 19; i > 1; i--) {
        ans.push_back(Edge(i, i+1, 0));
        ans.push_back(Edge(i, i+1, (1 << (20 - i - 1))));
    }
    while(L) {
        int p = int(log2(lowbit(L)));
        if(p == 19) {
            ans.push_back(Edge(1, 2, 0));
            ans.push_back(Edge(1, 2, 1 << 18));
        }
		else ans.push_back(Edge(1, 20 - p, L ^ lowbit(L)));
        L ^= lowbit(L);
    }
    printf("%d %d\n", 20, (int) ans.size());
    for(int i = 0; i < (int) ans.size(); i++)
        printf("%d %d %d\n", ans[i].u, ans[i].v, ans[i].w);
    return 0;
}

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

int main()
{
    int n;
    while (cin >> n && n != 0) {
        vector<int> s(n);
        for (auto &e : s) cin >> e;
        
        double a = accumulate(s.begin(), s.end(), 0.0) / n;
        double v = 0.0;
        for (int i = 0; i < n; i++) {
            v += pow(a - s[i], 2);
        }
        printf("%.10lf\n", sqrt(v/n));
    }
}



Measured memory_bytes: 3156
from collections import defaultdict

def main():
    N = int(input())
    S = list(input())
    d = []
    c = [0,0,0]
    R = 0
    G = 0
    B = 0
    for i in range(N-1,-1,-1):
        if S[i] == 'R':
            R += 1
        if S[i] == 'G':
            G += 1
        if S[i] == 'B':
            B += 1
        d.append([R,G,B])
            
    d.reverse()
    ans = 0
    for i in range(N):
        if S[i] == 'R':
            ans += d[i][1] * d[i][2]
        if S[i] == 'G':
            ans += d[i][0] * d[i][2]
        if S[i] == 'B':
            ans += d[i][0] * d[i][1]
        for k in range(N):
            if i + 2 * k >= N:
                break
            if S[i] == 'R':
                if S[i + k] == 'G' and S[i + 2 * k] == 'B':
                    ans -= 1
                if S[i + k] == 'B' and S[i + 2 * k] == 'G':
                    ans -= 1 
            if S[i] == 'G':
                if S[i + k] == 'R' and S[i + 2 * k] == 'B':
                    ans -= 1
                if S[i + k] == 'B' and S[i + 2 * k] == 'R':
                    ans -= 1 
            if S[i] == 'B':
                if S[i + k] == 'R' and S[i + 2 * k] == 'G':
                    ans -= 1
                if S[i + k] == 'G' and S[i + 2 * k] == 'R':
                    ans -= 1 

    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 69624
X, K, D = map(int, input().split())

X = abs(X)
if X >= K*D:
    print(X-K*D)
    exit()

div = (X // D)
K -= div
if K%2 == 1:
    print(abs(X-(div+1)*D))
else:
    print(abs(X-(div*D)))

Measured memory_bytes: 9064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

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

    vector<long long> v(N);
    for(int i = 0; i < N; i++) cin >> v[i];

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

    long long ans = 999999999;
    int idx = -1;
    for(int i = 0; i < N-1; i++)
    {
        long long nv = abs((long long)v[N-1] - 2*((long long)v[i]));
        if(ans > nv)
        {
            ans = nv;
            idx = i;
        }
    }

    cout << v[N-1] << " " << v[idx] << endl;

    return 0;
}

Measured memory_bytes: 1024
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

bool cmp(pair<int,int> &a,pair<int,int> &b){
	return a.F<b.F;
}

void solve(int test_case) {//234 Coloring Colorfully
	int n;
	cin>>n;
	double sum = 0;
	REP(i,0,n-1) {
		double a;
		cin>>a;
		sum+=1/a;
	}
	sum = 1/sum;
	printf("%.6lf",sum);
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std; 
#define int long long int
#define loop for(int i=0;i<n;i++)
#define pb push_back	
int32_t main()
{
int k,a,b,c;
cin>>a>>b>>c>>k;
if(k<=a)
cout<<k<<endl;
else if(k<=(a+b))
cout<<a<<endl;
else 
cout<<a-(k-(a+b))<<endl;
}
		
		
				
			
			
		

		
				


Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;
int main() {
    ll N;
    cin >> N;

    vector<ll> P(N + 1);
    for (ll i = 0; i < N; i++)
    {
        ll ai;
        cin >> ai;
        P[i + 1] = ai;
    }

    vector<ll> DP1(N + 1);
    vector<ll> DP2(N + 1);
    
    DP1[1] = P[1];
    DP2[N] = P[N];

    for (size_t i = 2; i <= N; i++)
    {
        DP1[i] = __gcd(DP1[i - 1], P[i]);
    }
    for (size_t i = 2; i <= N; i++)
    {
        DP2[N - i + 1] = __gcd(DP2[N - i + 2], P[N - i + 1]);
    }

    ll ans = 0;
    for (size_t i = 1; i <= N; i++)
    {
        if (i == 1) {
            ans = max(ans, DP2[i + 1]);
            continue;
        }
        if (i == N) {
            ans = max(ans, DP1[i - 1]);
        }
        ans = max(ans, __gcd(DP1[i - 1], DP2[i + 1]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 5620
//                                                   ¯\_(ツ)_/¯
  #pragma GCC optimize("Ofast")
 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
#define pi pair<int,int>
const int N=3e7+5,MOD=998244353;

using namespace std;

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


	scanf("%d",&n);

	std::vector<int> a(n);

	for(int i = 0 ;i<n;i++)scanf("%d",&a[i]);

	std::vector<int> dp(n+1,2e9);
	dp[0]=0;
	for(int i =0;i<n-1;i++){

		dp[i+1]=min(dp[i+1],dp[i]+abs(a[i]-a[i+1]));
		dp[i+2]=min(dp[i+2],dp[i]+abs(a[i]-a[i+2]));
	}

	printf("%d\n",dp[n-1]);
	

}

Measured memory_bytes: 1024
let n = Int(readLine()!)!
let a = readLine()!.split(separator: " ").lazy.map(String.init).lazy.map { Int($0)! }

var acc = 0
var min = 0

for num in a {
  if min > num {
    acc = acc &+ (min - num)
  } else {
    min = num
  }
}

print(acc)


Measured memory_bytes: 21308
// Atcoder
  // Practice Problems
  // A - Buttons
  #include <bits/stdc++.h>
  #include <iostream>
  #include <map>
  #include <queue>
  #include <set>
  #include <string>   
  #include <vector>
  #include <numeric>
  using namespace std;
  typedef long long int ll;
  typedef pair<ll, int> PLI;
  typedef pair<int, int> PII;
  const ll mxsize = 1e5 + 5;
  #define fastIO                                                                 \
    ios_base::sync_with_stdio(false);                                            \
    cin.tie(NULL);                                                               \
    cout.tie(NULL);
  
  /******************************************* IMPORTANT CODE SNIPPETS ************************************************/ 
  
  ll pow(ll x, ll n) {
    if (n == 0)
      return 1ll;
    ll temp;
    temp = pow(x, n / 2);
    if (n % 2 == 0)
      return temp * temp;
    else
      return x * temp * temp;
  }

  ll gcd(ll a, ll b) {
    if (b == 0)
      return a;
    return gcd(b, a % b);
  }

  int sum_digit(int val) {
    if (val < 0)
      return -1;
    if (val == 0)
      return 0;
    int ans = 0;
    while (val > 0) {
      ans = ans + val % 10;
      val = val / 10;
    }
    return ans;
  }

  ll count_div(ll l, ll r, ll val) {
    if (l % val == 0)
      return (((r / val) - (l / val)) + 1);
    else
      return ((r / val) - (l / val));
  }

  int powmod(int x, int y, int m) {
    int res = 1;
    // x = x % mod;
    while (y > 0) {
      if (y & 1)
        res = (res * x) % m;
      cout << res << endl;
      y = y / 2;
      cout << x << endl;
      x = (x * x) % m;
    }
    // cout << res << endl;
    return res;
  }
  /******************************************** CODE STARTS FROM HERE *************************************************/ 
  
  int main()
  {
    int A , B;
    cin >> A >> B;
    if(A != B) cout << 2 * max(A , B) - 1 << endl;
    else cout << 2 * A <<endl;
  }

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        int K = ni();
        HashSet<Integer> D = new HashSet<>();
        for (int i = 0; i < K; i++) {
            D.add(ni());
        }
        int ans = 1000000;
        for (int i = N; i <= 1000000; i++) {
            int c = i;
            boolean feasible = true;
            while(c>0){
                int digit = c % 10;
                if (D.contains(digit)) feasible = false;
                c = (c-digit)/10;
            }
            if(feasible){
                 ans = i;
                 break;
            }
        }
        out.println(ans);
    }

    final int mod = 1000000007;
    int mul(int x, int y){
        return (int)((x * 1L * y) % mod);
    }
    int add(int x, int y) {
        x += y;
        return x >= mod ? (x - mod) : x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        return x >= mod ? (x - mod) : x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 32936
N, M = map(int, input().split())

A = []

for i in range (0, M):
	A.append(int(input()))


if N == 1:
	print(1)
	exit()
elif N ==2:
	if len(A) ==1:
		print(1)
	else:
		print(2)
	exit()

DP = [0]*N

if A.count(1)==0:
	DP[0] = 1

if A.count(2)==0:
	if A.count(1)==0:
		DP[1] = 2
	else:
		DP[1] = 1

for i in range (0, M):
	DP[A[i]-1] = -1

for i in range (0, 2):
	if DP[i] == -1:
		DP[i] = 0

for i in range (2, N):
	if DP[i] ==-1:
		DP[i] = 0
	else:
		DP[i] = DP[i-1] + DP[i-2]

print(DP[-1]%(1000000007))

Measured memory_bytes: 465364
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if X == (i*500 + j*100 + k*50):
                ans += 1

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n,p=0;
double ans=0;
cin>>n;
for(int i=1;i<=n;i++)
{
ans+=(double)(i/2.0)*floor((double)(n/i))*floor((double)(1+(n/i)));
}
p=ans;
cout<<p<<endl;
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int K,T;
priority_queue< P > Q;

int main(){
  cin>>K>>T;
  for(int i=0;i<T;i++){
    int a;
    cin>>a;
    Q.push(P(a,i));
  }

  int last=-1,ans=0;
  while(K--){
    P p=Q.top();
    if(p.second!=last){
      Q.pop();
      p.first--;
      if(p.first)Q.push(p);
      last=p.second;
    }else{
      
      if(Q.size()==1){
        ans++;
        Q.pop();
        p.first--;
        if(p.first)Q.push(p);
        last=p.second;
      }else{
        Q.pop();
        P q=Q.top();
        Q.pop();
        q.first--;
        Q.push(p);
        if(q.first)Q.push(q);
        last=q.second;
      }
    }
  }

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    VL a(n);
    REP(i,n) a[i] = in();
    sort(ALL(a));

    VL p(n), q(n);
    REP(i,n-1){
        if (i % 2 == 0){
            p[i]--;
            p[i+1]++;
            q[i]++;
            q[i+1]--;
        }else{
            p[i]++;
            p[i+1]--;
            q[i]--;
            q[i+1]++;
        }
    }
    sort(ALL(p));
    sort(ALL(q));
    ll s1 = 0, s2 = 0;
    REP(i,n){
        s1 += p[i] * a[i];
        s2 += q[i] * a[i];
    }
    cout << max(s1, s2) << endl;

    return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    int N;
    cin >> N;
    V<int> A(N + 2);
    rep(i, N) cin >> A[i + 1];
    ll s = 0;
    rep(i, N + 1) { s += abs(A[i + 1] - A[i]); }
    for (int i = 1; i <= N; ++i) {
        cout << s - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) +
                    abs(A[i - 1] - A[i + 1])
             << endl;
    }
    return 0;
}

Measured memory_bytes: 1664