akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> v(100010);
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    string a;
    cin>>a;
    int p=0,d=0;
    for(int i=0;i<a.size();i++){
      if(a[i]=='R'){
        p++;
        swap(p,d);
      }else{
        v[i]+=p;
        v[i-1]+=d;
        p=0;
        d=0;
      }
    }
    p=0;d=0;
    for(int i=a.size()-1;i>=0;i--){
      if(a[i]=='L'){
        p++;
        swap(p,d);
      }else{
        v[i]+=p;
        v[i+1]+=d;
        p=0;
        d=0;
      }
    }
    for(int i=0;i<a.size();i++){
      cout<<v[i]<<" ";
    }
    return 0;
}


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

int main(){
    string s;
    cin>>s;
    bool ok=false;
    int n=s.size();
    for(int i=0;i<=n-7;i++){
        if(s.substr(i,7)=="keyence") ok=true;
    }
    for(int i=1;i<=6;i++){
        if(s.substr(0,i)+s.substr(n-7+i,7-i)=="keyence") ok=true;
    }

    if(ok) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	ll answer = 0;
	while(true){
		sort(a.begin(), a.end(), greater<ll>());
		int m = 0;
		for(; m < n && a[m] >= a[0] - (n - 1); ++m);
		if(m == n || a[0] < 2 * n){ break; }
		const ll s = n - m + 1;
		const ll k = (a[0] - max<ll>(n, a[m])) / s;
		for(int i = 0; i < m; ++i){ a[i] -= k * s; }
		for(int i = m; i < n; ++i){ a[i] += k * m; }
		answer += k * m;
	}
	sort(a.begin(), a.end(), greater<ll>());
	if(a[0] >= 2 * n){
		const ll k = max(0ll, a[0] - (2 * n));
		for(int i = 0; i < n; ++i){ a[i] -= k; }
		answer += k * n;
	}
	while(a[0] >= n){
		a[0] -= n;
		for(int i = 1; i < n; ++i){ ++a[i]; }
		++answer;
		sort(a.begin(), a.end(), greater<ll>());
	}
	cout << answer << endl;
	return 0;
}



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

#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax_v(ary) *max_element(all(ary))
#define vmin_v(ary) *min_element(all(ary))
#define vmax_id(ary) distance((ary).begin(),max_element(all(ary)))
#define vmin_id(ary) distance((ary).begin(),min_element(all(ary)))

using ll = int64_t;
using pll = pair<ll,ll>;
using vl = vector<ll>;

const ll INF=INT64_MAX;
const double EPS=1e-10;
const double PI=acos(-1.0);

void init(){cin.tie(0);ios::sync_with_stdio(false);}
//----------------------------------------------------

int main(){
    init();

    for(int i=1;i<=9;i++){
      for(int j=1;j<=9;j++){
        cout << i << "x" << j << "=" << i*j << endl;
      }
    }

    return 0;
}

Measured memory_bytes: 3068
/*
 * created   : 2019-07-24 23:40:47
 * accepted  : 2019-07-24 23:40:48
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define sz(x) ((int)(x).size())
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].x;
    a[i].y = i;
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  trace(a);
  for (int i = 0; i < n; ++i) {
    if (i == a[0].y) {
      cout << a[1].x << "\n";
    }
    else {
      cout << a[0].x << "\n";
    }
  }
}

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


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20); 
    #endif

    int n, m;
    cin >> n >> m;
    vector <int> p(n), q(m);

    vector <ii> v;

    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        v.app(mp(p[i], 0));
    }
    for (int i = 0; i < m; ++i) {
        cin >> q[i];
        v.app(mp(q[i], 1));
    }

    sort(all(v));

    vector <int> cnt(2);
    int ans = 0;
    for (auto e : v) {
        if (e.s == 0) {
            ans += e.f * (m + 1 - cnt[1]);
        }
        else {
            ans += e.f * (n + 1 - cnt[0]);
        }   

        cnt[e.s]++;

    }   
    cout << ans << endl;
}


Measured memory_bytes: 8976
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ipr pair<ll,ll>
#define ps push_back
#define fs first
#define sc second
#define endl "\n"
#define mod 1000000007
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll a,b,c;
	cin>>a>>b>>c;

	if(c>=a&&c<=b){
		cout<<"Yes\n";
	}
	else if(a>=c&&c>=b){
		cout<<"Yes\n";
	}
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int             long long
#define gcd(a, b)       __gcd(a, b)
#define here            cout<<"here";
#define lcm(a, b)       ((a)*1ll * (b)) / gcd(a, b)
#define pb              push_back
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define nl              "\n"
#define vi              vector<int>
#define vvi             vector<vector<int> >
#define F               first
#define S               second
#define lb              lower_bound
#define ub              upper_bound
#define pii             pair<int,int>
#define w(x)            int x; cin>>x; while(x--)
#define fre(i,a,n)      for (int i = a; i <= n; ++i)
#define fr(i,n)         for (int i = 0; i < n; ++i)
#define rf(i,n,a)       for (int i = n; i >=a; --i)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pqi		   priority_queue<int>
#define pqgi            priority_queue<int,vector<int>,greater<int>>
#define MN              min_element
#define MX              max_element
#define all(x)          x.begin(),x.end()
#define YN(ans)         ans ? cout << "YES" : cout << "NO";
#define d0(x)           cout<<(x)<<" "
#define d1(x)           cout<<(x)<<endl
#define d2(x,y)         cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z)       cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d)     cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e)   cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define max3(a,b,c)     max(max((a),(b)),(c))
#define max4(a,b,c,d)   max(max((a),(b)),max((c),(d)))
int pow(int a, int b, int m) {
	int ans = 1;
	while (b) {
		if (b & 1) ans = (ans * a) % m;
		b /= 2;  a = (a * a) % m;
	}
	return ans;
}
//when m is prime
int modinv(int a, int m)  {return pow(a, m - 2, m);}
void start()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////

const int N = 100005;
int dp[N][3];
int a[N][3];

int fun(int day,int val){
	//base
	if(day<0) return 0;
	//lookup
	if(dp[day][val]!=-1) return dp[day][val];

	//recursion
	int op1=a[day][(val+1)%3]+fun(day-1,(val+1)%3);
	int op2=a[day][(val+2)%3]+fun(day-1,(val+2)%3);
	return dp[day][val]=max(op1,op2);

}




void solve()
{
	int n;cin>>n;
	memset(dp,-1,sizeof dp);
	fr(i,n) fr(j,3) cin>>a[i][j];
	int op1=a[n-1][0]+fun(n-2,0);
	int op2=a[n-1][1]+fun(n-2,1);
	int op3=a[n-1][2]+fun(n-2,2);
	cout<<max3(op1,op2,op3);
}


////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////


int32_t main()
{
	FIO;
	//start();
	solve();
// w(x)    {solve();}
#ifndef ONLINE_JUDGE
	cerr << "\nTime Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
}


Measured memory_bytes: 14524
#include "bits/stdc++.h"
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<stack>
#include<complex>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
	
#define WHATS(var)cout<<__LINE__<<' '<<#var<<"="<<var<<endl;
	
template<class S, class T> ostream& operator <<(ostream &os, const pair<S, T> v){
	os << "( " << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<T> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<vector<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<set<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const map<T,T> &v){
	int i=0;
	for(auto it:v){
		if(i > 0){os << ' ';}
		os << it.first<<' '<<it.second;
		i++;
	} 
	return os;
}
using ll=long long ;
const ll mod=1e9+7;

int main() {
	int L,U,R,D;cin>>L>>U>>R>>D;
	int N;cin>>N;
	vector<pair<int,int>>ps(N);
	for(int i=0;i<N;++i){
		int x,y;cin>>x>>y;
		ps[i]=make_pair(x,y);
	}
	if(L>R){
		swap(L,R);
		swap(U,D);
	}
	if(U>D){
		U=-U;
		D=-D;
		for(auto&p:ps){
			p.second=-p.second;
		}
	}
	assert(L<=R);
	assert(U<=D);
	ld plus=0;
	{
		sort(ps.begin(),ps.end());
		vector<int>vs(N+1,int(1e9));
		vs[0]=U-1;
		for(auto p:ps){
			if(p.first<L||p.first>R)continue;
			else if(p.second<U|| p.second>D)continue;
			else{
				auto it=upper_bound(vs.begin(),vs.end(),p.second);
				
				vs[it-vs.begin()]=min(vs[it-vs.begin()],p.second);
				
			}
		}
		int cnt=0;
		for(int i=0;i<=N;++i){
			if(vs[i]!=1e9){
				cnt=i;
			}
		}
		
		const ld pi=acosl(-1);
		ld xx=-20+20*pi/4;
		plus=xx*(cnt);
		if(cnt==min(D-U+1,R-L+1)){
			plus+=20*pi/4;
		}
	}
	
	ld answer=((D-U)+(R-L))*100ll+plus;
	cout<<setprecision(25)<<fixed<<answer<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 2e5 + 555;
const int MOD = 1e9 + 7;
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    cout << fixed;
    int a, b;
    cin >> a >> b;
    int c = b - a * 2;
    if (c < 0 || c % 2 != 0 || a * 4 < b || a * 2 > b) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


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

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define rep(i,a,b) for(int i = (a) ; i <= (b) ; i++)
#define per(i,a,b) for(int i = (a) ; i >= (b) ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const int INF = 1e9;
const LL mod = 1e9 + 7;
const int maxn = 2e5 + 7;

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

int main() {
    int n;
    while(~sd(n)) {
        int ans = 0;
        rep(i,1,n) {
            rep(j,1,n) {
                rep(k,1,n) {
                    ans += gcd(gcd(i,j),k);
                }
            }
        }
        pd(ans);
    }
    return 0;
}


Measured memory_bytes: 3232
n, k = map(int, input().split())
V = list(map(int, input().split()))

# 取り出しの計算量を下げるために累積和を計算しておく
V_rui_left = [0]
V_rui_right = [0]
for i in range(n):
    V_rui_left.append(V_rui_left[-1]+V[i])
    V_rui_right.insert(0, V_rui_right[0]+V[n-i-1])
V_rui_right = V_rui_right[::-1]

# 取り出す操作の回数 i
# 最大(k-i) 回の入れる操作が可能
ans = 0
for i in range(k+1):
    # 取り出し方をすべて見る
    score = 0
    if i >= n:
        Get = V
        score = V_rui_left[-1] - V_rui_left[0]
        Get = sorted(Get)

        # print(Get)
        
        ans = max(ans, score)
        for j in range(min(k-i, len(Get))):
            if Get[j] < 0:
                score -= Get[j]
            ans = max(ans, score)
    # x個左から取り出し、i-x個は右から取るとする
    else:
        for x in range(i+1):
            get = 0
            get += V_rui_left[x] - V_rui_left[0]
            get += V_rui_right[i-x] - V_rui_right[0]
            Get = []
            Get = V[:x] + V[n-(i-x):]
            
            Get = sorted(Get)
            # print(Get)

            score = get
            ans = max(ans, score)
            # 入れる操作
            for j in range(min(k-i, len(Get))):
                if Get[j] < 0:
                    score -= Get[j]
                ans = max(ans, score)

print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

class RollingHash {
    template <int B, int M>
    class RollingHashPart {
      private:
        size_t len;
        std::vector<int> pow_b, hash;

      public:
        RollingHashPart() {}
        template <typename T>
        RollingHashPart(const T &s) : len(s.size()), pow_b(s.size() + 1), hash(s.size() + 1) {
            pow_b[0] = 1;
            hash[0]  = 0;
            for (int i = 0; i < len; i++) {
                pow_b[i + 1] = (ll)pow_b[i] * B % M;
                hash[i + 1]  = ((ll)hash[i] * B + s[i]) % M;
            }
        }
        // [l, r)
        int get(int l, int r) const {
            int res = (hash[r] - (ll)hash[l] * pow_b[r - l]) % M;
            if (res < 0)
                res += M;
            return res;
        }
    };

  public:
    using HashData = pair<int, int>;
    RollingHashPart<1033, 1000000007> rh1;
    RollingHashPart<6037, 999999937> rh2;

    RollingHash() {}
    template <typename T>
    RollingHash(const T &s) : rh1(s), rh2(s) {}
    // [l, r)
    HashData get(int l, int r) const { return HashData{rh1.get(l, r), rh2.get(l, r)}; }
    // [l1, r1), [l2, r2)
    int lcp(const RollingHash &rhs, int l1, int r1, int l2, int r2) const {
        int lb = 0, ub = std::min(r1 - l1, r2 - l2) + 1;
        while (ub - lb > 1) {
            int md                                               = (lb + ub) >> 1;
            (get(l1, l1 + md) == rhs.get(l2, l2 + md) ? lb : ub) = md;
        }
        return lb;
    }
};

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    RollingHash rh(s);
    int ok     = 0;
    int ng     = n;
    auto check = [&](int m) {
        for (int i = 0; i < n; ++i) {
            for (int k = i + m; k < n - m + 1; ++k) {
                if (rh.get(i, i + m) == rh.get(k, k + m)) {
                    return true;
                }
            }
        }
        return false;
    };
    while (ok + 1 != ng) {
        int mid = (ok + ng) / 2;
        if (check(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << "\n";
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
	char b;
	int a,c;
	scanf("%d %c %d",&a,&b,&c);
	if(b=='+')
	{
		printf("%d\n",a+c);
	}
	if(b=='-')
	{
		printf("%d\n",a-c);
	}
return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include<string.h>


int main(){
    int a,b;

    scanf("%d",&a);
    if(a < 1200){
        printf("ABC");
    }
    else if(1200 <= a){
        if(a < 2800){
            printf("ARC");
        }
        else printf("AGC");
    }

    return 0;
}

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

using namespace std;

char str[4];
int letters[27];

int main()
{
    cin >> str;
    for(int i = 0; i < 4; i++)
        letters[str[i] - 'A']++;

    bool twoAndTwo = true;
    for(int i = 0; i < 27; i++)
        if(letters[i] != 2 && letters[i] != 0)
            twoAndTwo = false;

    cout << (twoAndTwo ? "Yes\n" : "No\n");
    return 0;
}


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

void solve(){
	int n,sum=0;
	cin>>n;
	bitset<2000005> bi;bi[0]=true;
	for(int i=0;i<n;++i){
		int a;cin>>a;sum+=a;
		bi|=(bi<<a);
	}
	for(int i=(sum+1)/2;i<=sum;++i){
		if(bi[i]){
			cout<<i<<endl;
			exit(0); 
		}
	}
}
int main(){
	solve();
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

const ll INF = 1e18;
const int MAX_V = 1050;
int V, m;
vector<pair<int, ll> > adj[MAX_V];

vl bellmanFord() {
	vl upper(V, INF);
	vi parent(V);
	parent[0] = 0;
	upper[0] = 0;
	for(int iter = 0; iter < V-1; ++iter) {
		for(int here = 0; here < V; ++here) 
			for(int i=0; i<adj[here].size(); ++i) {
				int there = adj[here][i].F;
				ll cost = adj[here][i].S;
				if(upper[there] > upper[here] + cost) {
					upper[there] = upper[here] + cost;
					parent[there] = here;
				}
			}
	}
	vector<bool> path(V, false);
	int here = V-1;
	while(here != 0) {
		if(path[here]) break;
		path[here] = true;
		here = parent[here];
	}
	bool updated = false;
	for(int here = 0; here < V; ++here) {
		for(int i=0; i<adj[here].size(); ++i) {
			int there = adj[here][i].F;
			ll cost = adj[here][i].S;
			if(upper[there] > upper[here] + cost) {
				upper[there] = upper[here] + cost;
				if(path[there]) {
					updated = true;
				}
			}
		}
	}
	if(updated) upper.clear();
	return upper;
}

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> V >> m;
	rep(i,0,m) {
		int a, b;
		ll c;
		cin >> a >> b >> c;
		a--; b--;
		adj[a].pb(mp(b,-c));
	}
	auto ret = bellmanFord();
	if(ret.empty()) {
		cout << "inf" << '\n';
	} else {
		cout << -ret.back() << '\n';
	}
	return 0;
}


Measured memory_bytes: 384
n = int(input())
l = [11,31,41,61,71]
if n == 5:
    print(*l)
    exit()
for i in range(81,60000,10):
    check = True
    for j in range(3,int(i**0.5)+1):
        if i % j == 0:
            check = False
    if check:
        l.append(i)
    if len(l) == n:
        print(*l)
        exit()

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt(),b = scanner.nextInt();
		if(a + b > 24){
			System.out.println((a + b) % 24);
		}else if(a + b == 24){
			System.out.println(0);
		}else{
			System.out.println(a + b);
		}
	}
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 100000

using namespace std;

const ll M = (ll)(1e18);
unsigned ll v[maxn+5];

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  int i, j, z;
  double sum = 0, lim = log2(M);
  for (i = 1; i <= n; i++) {
    cin >> v[i];
    sum += log2(v[i]);
  }
  if ((*min_element(v+1,v+n+1)) == 0) cout << 0;
  else if (sum > lim || sum < 0) cout << -1;
  else {
    unsigned ll ans = 1;
    for (i = 1; i <= n; i++) ans *= v[i];
    if (ans >= 0 && ans <= M) cout << ans;
    else cout << -1;
  }
  return 0;
}


Measured memory_bytes: 4548
#include<stdio.h>
int main(){
	
     int n,i,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
        k=i;
        if(i%3==0){
            printf(" %d",i);
        
        }else{
            while(k>0){
                if(k%10==3){
                    printf(" %d",i);
                    break;
                }
                k/=10;
            }
        }
    }
    printf("\n");
	return 0;
   
}



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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

// π M_PI
// deg = rad*180/M_PI

int main() {
    int64_t x, n;
    cin >> x >> n;

    std::vector<int64_t> a(n);
    int64_t xx = 0;
    rep(i, n) {
        cin >> a[i];
        if ( a[i] == x ) {
            xx = 1;
        }
    }

    if ( n == 0 || !xx ) {
        cout << x << endl;
        return 0;
    }

    /*
    int64_t ans;
    int64_t num = 200;
    rep2(i, 200) {
        chmin(num, abs(x-i) );
        ans = i;
    }
    cout << ans << endl;*/
    int64_t ans = 0;
    rep2(i, max(x, 100-x)) {
        if ( !find_num(a, x-i) ) {
            ans = x-i;
            break;
        } else if ( !find_num(a, x+i) ) {
            ans = x+i;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define Max(a,b)    ((a)>(b)?(a):(b))
#define Min(a,b)    ((a)<(b)?(a):(b))
#define rep(i,a,b)  for (__typeof((b)) i=(a);i<(b);i+=1)
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define debug(a)    cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
using namespace std;

void solve(){
    int N,M;
    cin>>N>>M;
    vector<pair<int,bool>>x(N);
    rep(i,0,N){
        x[i]=mp(1,false);
    }
    x[0].S=true;
    bool isTaken=false;
    rep(j,0,M){
        int a,b;
        cin>>a>>b;
        if(a==1)isTaken=true;
        a--;
        b--;
        x[a].F--;
        x[b].F++;
        x[b].S=x[b].S|x[a].S;
        if(x[a].F==0)x[a].S=false;
        /*rep(i,0,N){
            cerr<<i+1<<" "<<x[i].F<<" "<<x[i].S<<endl;
        }*/
    }
    if(!isTaken){
        cout<<1;
    }
    else{
        int ans=0;
        rep(i,0,N){
            if(x[i].S && x[i].F>0)ans++;
        }
        cout<<ans;
    }

}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
 
int n, a[10009], sum;
 
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		while (a[i] % 2 == 0) { a[i] /= 2; sum++; }
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 760
h,w = gets.split.map(&:to_i)
INFI = 10000000

black = []
dmap = Array.new(h) { Array.new(w,INFI) }

h.times do |hi|
  gets.chomp.each_char.with_index do |c,wi|
    if c == '#'
      black.unshift([hi,wi])
      dmap[hi][wi] = 0
    end
  end
end

step = 0
while not black.empty?
  #hb,wb = black.shift
  n = []
  step += 1

  black.each do |hb,wb|
    if hb > 0
      if dmap[hb-1][wb] == INFI
        dmap[hb-1][wb] = step
        n << [hb-1,wb]
      end
    end

    if hb < h - 1
      if dmap[hb+1][wb] == INFI
        dmap[hb+1][wb] = step
        n << [hb+1,wb]
      end
    end

    if wb > 0
      if dmap[hb][wb-1] == INFI
        dmap[hb][wb-1] = step
        n << [hb,wb-1]
      end
    end

    if wb < w -1
      if dmap[hb][wb+1] == INFI
        dmap[hb][wb+1] = step
        n << [hb,wb+1]
      end
    end
  end

  black = n

end

puts step-1


Measured memory_bytes: 86140
#include <iostream>
#include<math.h>
using namespace std;
const int N=2e3+10;
int a[N],b[N];
int dp[N][N];
const int mod=1e9+7;
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1; i<=n; i++) cin>>a[i];
    for(int j=1; j<=m; j++) cin>>b[j];
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
          dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]) % mod;
                if(a[i]==b[j])
                    dp[i][j] = (dp[i][j] + dp[i-1][j-1]) % mod + 1;
                dp[i][j]%=mod;
        }
    }
     cout<<(dp[n][m]+mod)%mod+1<<endl;
    return 0;
}


Measured memory_bytes: 16000
N = str(input())
a = ['R','U','D']
b = ['L','U','D']
c = 0
for i in range(0, len(N)):
    if i % 2 == 0:
        if N[i] in a:
            c += 1

    else:
        if N[i] in b:
            c += 1


if c == len(N):
    print('Yes')
else:
    print('No')

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

N, M = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 1000000000 + 7
sub = 0
for i in range(N - 1):
    sub += (i + 1) * (N - i - 1) * (X[i + 1] - X[i])
    sub %= MOD
ans = 0
for i in range(M - 1):
    ans += (i + 1) * (M - i - 1) * (Y[i + 1] - Y[i])
    ans %= MOD
ans *= sub
print(ans % MOD)


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

int isPrime(int n)
{
    int i;
    for (i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main(void)
{
    int n;
    while (1)
    {
        scanf("%d", &n);
        if (n == 0)
            break;
        int ans = 0;
        int i;
        for (i = n + 1; i <= 2 * n; i++)
        {
            if (isPrime(i))
                ans++;
        }
        printf("%d\n", ans);
    }

    return 0;
}


Measured memory_bytes: 2048
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto n = lread();
    long[] tmp = [1, 2, 4, 8, 16, 32, 64];
    long ans = -1;
    foreach (i; 0 .. tmp.length)
    {
        if (n >= tmp[i])
        {
            // writeln(tmp[i]);
            ans = max(ans, tmp[i]);
        }
    }
    writeln(ans);

}

long func(long n)
{
    long cnt;
    while (n % 2 == 0)
    {
        n /= 2;
        cnt += 1;
    }
    return cnt;
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3636
fun main() {
    val input = readLine()!!.split(' ').map { it.toInt() }
    val map = mutableMapOf<Int, Int>()

    repeat(input[1]) {
        readLine()
        readLine()!!.split(' ').map { it.toInt() }.forEach {
            map[it] = (map[it] ?: 0) + 1
        }
    }

    println(input[0] - map.size)
}

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

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

vector<int> to[100005];
int dp[100005], dag[100005];

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

    rep(i, 100005) {
        dp[i] = 0; // 距離
        dag[i] = 0; // 入次数
    }

    rep(i, M) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        to[x].push_back(y);
        dag[y]++;
    }

    queue<int> que;
    rep(i,N) {
        if (dag[i] == 0) {
            que.push(i);
        }
    }

    while(!que.empty()) {
        int v = que.front(); que.pop();

        for (int nv : to[v]) {
            dag[nv]--;
            if (dag[nv] == 0) {
                que.push(nv);
                dp[nv] = max(dp[nv], dp[v] + 1);
            }
        }
    }

    int res = 0;
    rep(i, N) {
        res = max(res, dp[i]);
    }
    cout << res << endl;

    return 0;
}


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

int main()
{
		int N, X;
		int L[100];
		int r = 0;
		int count = 1;

		cin >> N;
		cin >> X;
		for (int i = 0; i < N; i++)
		{
			cin >> L[i];
			r = r + L[i];
			if (r <= X)
			{
				count = count + 1;
			}
		}
		cout << count;

	return 0;
}

Measured memory_bytes: 256
/*
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<ll> vll;
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

void solve(int test_case) {
	string s;
	cin>>s;
	bitset<26> b;
	for(char c:s)b[(int)(c-'a')]=1;
	int i = 0;
	for(;i<26;i++) {
		if(!b[i]){break;}
	}
	if(i<26)cout<<(char)(i+'a'); else cout<<"None";
}

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: 3748
import bisect
n = int(input())
a = [int(input()) for _ in range(n)]
LIS = [a[0]]
for i in range(n):
    if a[i] > LIS[-1]:
        LIS.append(a[i])
    else:
        LIS[bisect.bisect_left(LIS,a[i])] = a[i]
print(len(LIS))



Measured memory_bytes: 10360
#include<bits/stdc++.h>
#define ll long long
#define int long long int
#define MOD 1000000007
#define mkp make_pair
#define maxn 100005
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
using namespace std;
const int infi=1e15+7;
void printVector(vector<int> v){
    for(int i=0;i<(int)v.size();i++)
        cout<<v[i]<<" ";
    out endl;
}

void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
cout<<endl;
}
 set<pair<int,int>> primeset;
 vi prime_number;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
           primeset.insert(mkp(p,1));
}
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
//for making unordered_map with pair
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
int32_t main()
{
fastio;
int t;in t;
set<string> has;
while(t--){
    string s;in s;
    has.insert(s);
}
out has.size();
    return 0;
}

/*
google kick start
  cout << "Case #" << tt << ": "<<ans<<endl;
*/


Measured memory_bytes: 19236
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    int c0= 0;
    int c1= 0;
    int c2 = 0;
    int c3 = 0;
  
    cin >> N;

    for(int i = 0; i < N; i++){
        string S;
        cin >> S;

        if(S == "AC"){
            c0++;
         }else if(S == "WA"){
             c1++;
        }else if(S == "TLE"){
             c2++;
        }else if(S == "RE"){
             c3++;
        }
         
    }

    cout << "AC x " << c0 << endl;
    cout << "WA x " << c1 << endl;
    cout << "TLE x " << c2 << endl;
    cout << "RE x " << c3 << endl;
    



}



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

int main(){
  ll a,b,c;
  vector<ll> v;
  cin>>a>>b>>c;
  v.push_back(a);
  v.push_back(b);
  v.push_back(c);
  sort(v.begin(),v.end());
  ll m=v[2];
  if(m%2==0){
    cout<<0<<endl;
  } else {
    ll x=v[0]*v[1];
    cout<<x<<endl;
  }
  return 0;
}


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


def solve(N: int, M: int, Q: int, L: "List[int]", R: "List[int]", p: "List[int]", q: "List[int]"):
    matrix = [[0]*(N+1) for _ in range(N+1)]

    for i in range(M):
        matrix[L[i]][R[i]] += 1

    ruisekiwa = [[0]*(N+1) for _ in range(N+1)]
    for i in range(N):
        for j in range(N):
            ruisekiwa[i+1][j+1] = ruisekiwa[i][j+1] + ruisekiwa[i+1][j] - ruisekiwa[i][j] + matrix[i+1][j+1]
    for j in range(Q):
        qq = q[j]
        pp = p[j]
        answer = ruisekiwa[qq][qq] - ruisekiwa[qq][pp-1] - ruisekiwa[pp-1][qq] + ruisekiwa[pp-1][pp-1]

        print(answer)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    L = [int()] * (M)  # type: "List[int]"
    R = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        L[i] = int(next(tokens))
        R[i] = int(next(tokens))
    p = [int()] * (Q)  # type: "List[int]"
    q = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        p[i] = int(next(tokens))
        q[i] = int(next(tokens))
    solve(N, M, Q, L, R, p, q)

if __name__ == '__main__':
    main()


Measured memory_bytes: 29716
import Foundation

func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}

func main() {
    var nk = readWords { Int($0)! }.makeIterator()
    let n = nk.next()!
    let k = nk.next()!

    // 13 5
    // LRRLRLRRLRLLR
    // LRRLRLLLLRLLR
    // LRRLRRRRRRLLR
    // LRRLLLLLLLLLR
    // LRRRRRRRRRRRR (if LLRLLLLLLLL... then +1)

    let S = Array(readLine()!)
    var count = 0
    for i in 0..<n-1 {
        if S[i] == S[i+1] {
            count += 1
        }
    }

    print(min(count+k*2, n - 1))
}

main()

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

int main(){
	string n;
	cin>>n;
	string s=n.substr(0,1);
	bool a=true;
	for(int i=1;i<n.size();i++){
		a=a&&n[i]=='9';
	}
  	if((int)n.size()==1){
      puts(n);
      return 0;
    }
      
	if(a){
		puts(9*(int)n.size()-9+stoi(s));
		return 0;
	}
	if(stoi(s)==1)puts(9*(int)(n.size()-1));
	else puts(9*(int)(n.size()-1)+stoi(s)-1);
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>


#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define vint vector<int>
#define INF 1e9

using namespace std;
typedef long long  ll;

bool isOK(vint& skills, int x){
    for(int skill : skills){
        if(skill < x){ return false;}
    }

    return true;
}


int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(a >= k){
        p(k);
        return 0;
    }
    else if (a + b >= k){
        p(a);
        return 0;
    } else {
        p(a - (k - a - b));
    }
    return 0;
}


Measured memory_bytes: 3580
N = gets.to_i
P = '0'*(N-1)
n = -1
until (10**N-1) < n+=1
	s = "#{P}#{n}"[-N,N]
	x = '/'.ord
	i = (0...N).find{|i|
		y = s[i].ord
		x = y if y == x+1
		next x < y
	}
	if i
		(i...N).each{|j|
			s[j] = '9'
		}
		n = s.to_i
		next
	end
	puts s.tr('0-9','a-j')
end


Measured memory_bytes: 3068
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

import java.util.*;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        int N = in.nextInt();
        int M = in.nextInt();
        int Q = in.nextInt();
        int[][] map = new int[N][N];
        for (int i=0;i<M;i++) {
            int L = in.nextInt()-1;
            int R = in.nextInt()-1;
            map[L][R]++;
        }

        // y-coodinate ruiseki
        int[][] ruiseki = new int[N][N];
        for (int i=0;i<N;i++) {
            ruiseki[i][0] = map[i][0];
        }
        for (int i=0;i<N;i++) {
            for (int j=1;j<N;j++) {
                ruiseki[i][j] = map[i][j]+ruiseki[i][j-1];
            }
        }
        for (int i=0;i<Q;i++) {
            int p = in.nextInt()-1;
            int q = in.nextInt()-1;
            int ans = 0;
            for (int j=p;j<=q;j++) {
                if (p==0) {
                    ans += ruiseki[j][q];
                } else {
                    ans += ruiseki[j][q]-ruiseki[j][p-1];
                }
            }
            out.println(ans);
        }

        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


Measured memory_bytes: 67224
/**
*	  Name: Ajay Subhash Jadhav
*	  Institute: International Institute of Technology Hyderabad 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void inputread()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}
int gcd(int a,int b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
int main(){
      
  fastio();
  int n,m,i,j;
  cin>>n>>m;

  int x;
  
  cin>>x;
  int g=abs(x-m);
  for(i=1;i<n;i++)
  {
  	int x;
  	cin>>x;

  	g=gcd(g,abs(x-m));
  }
  cout<<g;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
rates=list(map(int,input().split()))
colors=[]
over3200=0
for n in range(0,N):
    color=rates[n]//400
    if color<8:
        if not color in colors:
            colors.append(color)
    else:
        over3200+=1
if len(colors)==0:
    Min=1
else:
    Min=len(colors)
Max=len(colors)+over3200
print(Min,Max)


Measured memory_bytes: 3060
n, y = gets.split(" ").map(&:to_i)

(0..n).each do |i|
  (0..n).each do |j|
    if i + j <= n && ((i * 10000) + (j * 5000) + (n - i - j) * 1000) == y
      puts "#{i} #{j} #{n - i - j}"
      exit
    end
  end
end

puts "-1 -1 -1"

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

using namespace std;

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	int pos = 0;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		if (x == 1) pos = i;
	}
	int ans = 1e9;
	//
	int foo = n - 1 - pos;
	int bar = pos;
	int res = k - foo - 1;
	int cnt = 1;
	for (int j = pos - res; j > 0; j = j - k + 1) {
		cnt++;
	}
	ans = min(ans, cnt);
	res = k - bar - 1;
	cnt = 1;
	for (int j = pos + res; j < n - 1; j = j + k - 1) {
		cnt++;
	}
	ans = min(ans, cnt);
	cnt = 0;
	for (int i = pos; i < n - 1; i = i + k - 1) {
		cnt++;
	}
	for (int i = pos; i > 0; i = i - k + 1) {
		cnt++;			
	}
	ans = min(ans, cnt);
	if (foo == bar) {
		int v = k / 2;	
		cnt = 1;
		for (int i = pos + v; i < n - 1; i = i + k - 1) {
			cnt++;
		}
		for (int i = pos - v; i > 0; i = i - k + 1) {
			cnt++;			
		}
		ans = min(ans, cnt);
	} 
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
haveThree::Int->Bool
haveThree x = elem 3 $ map (`mod`10) $ takeWhile (>0) $map (x`div`) $ map ((^) 10) [0,1..]


main=do
n <- getLine
putStrLn $ (:) ' ' . unwords . map show $ takeWhile (<=(read n::Int)) $ filter (\x->x`mod`3==0||haveThree x) [1,2..]

Measured memory_bytes: 4104
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int n;
vector<vector<int>> g;

int dfs(int r) {
    vector<int> v;

    v.push_back(0);

    for (int to : g[r]) {
        int t = dfs(to);
        v.push_back(t);
    }

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

    for (int i = 0; i < (int)v.size() - 1; i++) {
        v[i + 1] = max(v[i], v[i + 1]) + 1;
    }

    return v.back();
}

int main() {
    cin >> n;

    g.resize(n);

    for (int i = 0; i < n - 1; i++) {
        int a;
        cin >> a;

        g[a - 1].push_back(i + 1);
    }

    cout << dfs(0) << endl;
}


Measured memory_bytes: 18176
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
	}else if(a>b){
		cout<<"a > b"<<endl;
	}else{
		cout<<"a == b"<<endl;
	}
    return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define fin freopen("E:/in.txt", "r", stdin)
#define fout freopen("E:/out.txt", "w", stdout)
#define ms(a, x) memset(a, x, sizeof(a))
#define rep(i, a, n) for(int i = a; i <= n; i++)
#define per(i, a, b) for(int i = n; i >= a; i--)
typedef long long ll;
typedef long double ld;
const int maxn = 1e5+5;
const int mod = 1e9+7;
using namespace std;
typedef pair<int, int> pii;
struct node{
    int len, tm;
    node(int x, int y) : len(x), tm(y){}
    bool operator < (const node & b){
        return len < b.len;
    }
};
vector<node> p;
int main(){
    int n, t;
    cin >> n >> t;
    rep(i, 1, n){
        int len, tm;
        cin >> len >> tm;
        if(tm <= t) p.push_back(node(len, tm));
    }
    if(p.size() == 0){
        cout << "TLE" << endl;
        return 0;
    }
    sort(p.begin(), p.end());
    cout << p[0].len << endl;
    return 0;    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
const int mod=924844033;
const int G=5;
const int invG=554906420;
int n,cnt_edge;
int head[maxn],size[maxn],cnt[maxn];
struct edge{int to,nxt;}e[maxn<<1]; 
inline int read()
{
    char c=getchar();int res=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')res=res*10+c-'0',c=getchar();
    return res*f;
}
inline void add_edge(int u,int v)
{
	e[++cnt_edge]=(edge){v,head[u]};
	head[u]=cnt_edge;
}
void dfs(int x,int fa)
{
	size[x]=1;
	for(int i=head[x];i;i=e[i].nxt)
	{
		int y=e[i].to;
		if(y==fa)continue;
		dfs(y,x);size[x]+=size[y];
		cnt[size[y]]++;
	}
	cnt[n-size[x]]++;
}
int fac[maxn],invfac[maxn];
inline int power(int x,int k)
{
	int res=1;
	while(k)
	{
		if(k&1)res=1ll*res*x%mod;
		x=1ll*x*x%mod;k>>=1;
	}
	return res;
}
inline int C(int n,int m){return 1ll*fac[n]*invfac[n-m]%mod*invfac[m]%mod;}
int pos[maxn<<2],f[maxn<<2],g[maxn<<2];
inline void NTT(int* a,int len,int op)
{
    int lim=1,cnt=0;
    while(lim<len)lim<<=1,cnt++;
    for(int i=0;i<lim;i++)pos[i]=(pos[i>>1]>>1)|((i&1)<<(cnt-1));
    for(int i=0;i<lim;i++)if(i<pos[i])swap(a[i],a[pos[i]]);
    for(int l=1;l<lim;l<<=1)
    {
        int wn=power(op==1?G:invG,(mod-1)/(l<<1));
        for(int i=0;i<lim;i+=l<<1)
        {
            int w=1;
            for(int j=0;j<l;j++,w=1ll*w*wn%mod)
            {
                int x=a[i+j],y=1ll*w*a[i+l+j]%mod;
                a[i+j]=(x+y)%mod;a[i+l+j]=(x-y+mod)%mod;
            }
        }
    }
    if(op==1)return;
    int inv=power(lim,mod-2);
    for(int i=0;i<lim;i++)a[i]=1ll*a[i]*inv%mod;
}
int main()
{
	n=read();
	for(int i=1;i<n;i++)
	{
		int u=read(),v=read();
		add_edge(u,v),add_edge(v,u);
	}
	dfs(1,0);
	fac[0]=1;for(int i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mod;
	invfac[n]=power(fac[n],mod-2);
	for(int i=n;i;i--)invfac[i-1]=1ll*invfac[i]*i%mod;
	for(int i=1;i<=n;i++)f[i]=1ll*cnt[i]*fac[i]%mod;
	reverse(f,f+n+1);
	for(int i=0;i<=n;i++)g[i]=invfac[i];
	int lim=1;
	while(lim<(n<<1))lim<<=1;
	NTT(f,lim,1),NTT(g,lim,1);
	for(int i=0;i<lim;i++)f[i]=1ll*f[i]*g[i]%mod;
	NTT(f,lim,-1);
	reverse(f,f+n+1);
	for(int i=1;i<=n;i++)printf("%d\n",(1ll*n*C(n,i)-1ll*invfac[i]*f[i]%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 26496
#include<iostream> //cinなど
#include<string>　//文字列
#include<algorithm>　//sort など
#include<math.h> //paw(冪乗など)
#include<set>　// 集合
#include<map>　//写像
#include<stdio.h>　//printf
#include<stack>

using namespace std;
int main(){
  int a,b,h;
  int c;
  cin>>a>>b>>h;
  c = (a+b)*h/2;
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int arr[11]={0};
long long fff(char *arr)
{
    long long sum=0;
	long long q=0;
    for(int i=0;i<strlen(arr);i++)
    {
        if(arr[i]=='+')
        {
           sum+=q;
           q=0;
        }
        else
            q=q*10+arr[i]-'0';
 
    }
    return sum+q;
}
int main()
{
	char a[11],p[22];
	cin>>a;
	int n=strlen(a)-1;
	long long sum=0;
	int t;
	while(1)
	{
		t=0;
        for(int i=0;i<n;i++)
        {
            arr[i+1]+=arr[i]/2;
            arr[i]%=2;
        }
        if(arr[n]==1)
            break;
        for(int i=0;i<n;i++)
        {
            p[t++]=a[i];
            if(arr[i]==1)
               	p[t++]='+';
        }
        p[t++]=a[n];
        p[t]='\0';
        sum+=fff(p);
        arr[0]++;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256