akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    vector<ll> Lucas(2);
    Lucas[0] = 2;
    Lucas[1] = 1;
    ll N;
    cin >> N;
    REP(i,N){
        Lucas.pb(Lucas[i+1] + Lucas[i]);
    }
    cout << Lucas[N] << "\n";
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int h, w;
bool a[100][100];
bool b[100][100];
signed main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < w; j++) {
			if (s[j] == '#') a[i][j] = 1;
			else a[i][j] = 0;
		}
	}
	b[0][0] = 1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (b[i][j]) {
				if (a[i + 1][j] && a[i][j + 1]) {
					cout << "Impossible\n";
					return 0;
				}
				if (a[i + 1][j]) {
					b[i + 1][j] = 1;
				}
				if (a[i][j + 1]) {
					b[i][j + 1] = 1;
				}
			}
			else if (a[i][j]) {
				cout << "Impossible\n";
				return 0;
			}
		}
	}
	cout << "Possible\n";
}

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

using namespace std;

#define ll long long
//#define mx 0
#define mn 1e9
#define vec(dt) vector<dt>
#define pr(x, y) pair<x,y>
#define loop(x, n) for(ll x = 0; x < n; x++)
#define in_arr(n) loop(i,n){cin>>a[i];}
#define out_arr(n) loop(i,n){cout<<a[i];}

inline void boost() {
    cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0);
}

const int N = 1e5 + 5;

int main() {

    boost();
    int n;
    cin>>n;
    vector<int> a(n);
    in_arr(n);
    int c = 1;
    int cnt = 0;
    for(int i=0;i<a.size();i++)
    {
        if (a[i]!=c)
        {
            cnt++;
        } else
        {
            c++;
        }
    }
    if (cnt==n)
    {
        cout<<-1;
        return 0;
    }
    cout<<cnt;


}

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

using namespace std;

int main(){
  int q,a,b;
  string str,s;

  cin >> str >> q;
  while(q--){
    cin >> s >> a >> b;
    if(s == "replace"){
      cin >> s;
      str.replace(str.begin()+a, str.begin()+b+1, s);
    }else if(s == "reverse"){
      reverse(str.begin()+a, str.begin()+b+1);
    }else{
      cout << str.substr(a, b-a+1) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1220
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <tuple>
#include <complex>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL MAXN = 100001;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	
	LL a, b, c;
	cin >> a >> b >> c;

	LL ans;

	if ((a % 2 == 0) || (b % 2 == 0) || (c % 2 == 0))
		cout << 0;
	else
	{
		VLL x;
		x.push_back(a);
		x.push_back(b);
		x.push_back(c);
		sort(ALL(x));
		ans = x[0] * x[1];
		cout << ans;
	}

	//cin >> a;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		
		if(a<b)System.out.println("a < b");
		if(a>b)System.out.println("a > b");
		if(a==b)System.out.println("a == b");
	}
}

Measured memory_bytes: 26112
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    int x;
    cin >> x;
    cout << x + x * x + x * x * x;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include<algorithm>
#include <set>
#include <stdlib.h>

using namespace std;

int main()
{
    int n,q,r=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>q;
        if(q%2!=0 &&i%2!=0)
            r++;
    }
    cout<<r;

    return 0;
}


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

int x,a,b;
int main()
{
	cin>>a>>b;
	for(x=1;x<=10000/8;x++)
	{
		if(floor(x*0.08)==a&&floor(x*0.1)==b)
		{
		  cout<<x;
		  return 0;
		} 
	}
	cout<<"-1"<<endl;
	return 0;
}

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

using namespace std;

int main() {
	int M, K;
	cin >> M >> K;
	int max = 1;
	for (int i = 0; i < M; i++) {
		max *= 2;
	}

	//max >= Kの時、M桁目の数がxorにより1になることはないので構成不可
	if (max <= K) {
		cout << -1 << endl;
		return 0;
	}

	//M == 0
	if (M == 0) {
		cout << "0 0" << endl;
		return 0;
	}
	//M == 1
	if (M == 1) {
		if (K == 0) cout << "0 0 1 1" << endl;
		else cout << "-1" << endl;
		return 0;
	}

	//M >= 2であれば解を構成できる
	vector<int> ans(2 * max);
	for (int i = 0; i < max; i++) {
		if (i == K) continue;
		if (i < K)	ans[i] = i;
		else ans[i - 1] = i;
	}
	ans[max-1] = K;
	for (int i = 0; i < max; i++) {
		if (i == K) continue;
		if (i < K)	ans[2 * max - 2 - i] = i;
		else ans[2 * max - 1 - i] = i;
	}

	ans[2 * max -1] = K;

	for (int i : ans) {
		cout << i << " ";
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 2816
X,Y,A,B,C=map(int,input().split())

P=list(map(int,input().split()))
Q=list(map(int,input().split()))
R=list(map(int,input().split()))
    
P.sort(reverse=True)
Q.sort(reverse=True)

S=P[:X]+Q[:Y]+R
S.sort(reverse=True)

print(sum(S[:X+Y]))


Measured memory_bytes: 111724
n = gets.chomp.to_i

n.times do
  stack = Array.new(3, 0)
  score, out = 0, 0
  while out < 3
    case gets.chomp
    when 'HIT' then
      score += stack.shift
      stack << 1
    when 'HOMERUN' then
      score += stack.select { |x| x == 1 }.size + 1
      stack = Array.new(3, 0)
    when 'OUT' then
      out += 1
    end
  end

  puts score
end

Measured memory_bytes: 8680
#pragma GCC optimize("Ofast", "unroll-loops")

#pragma GCC target("popcnt,abm,mmx,tune=native")

#include <bits/stdc++.h>

#define ll int64_t

#define fi first

#define se second

#define pb push_back

#define sqr(x) (ll)(x)*(x)

#define inf LLONG_MAX

#define mod 1000000007

using namespace std;

ll n, m, i, x, ans;

main()
{
    [=]()
    {
        ios_base :: sync_with_stdio(false);

        cin.tie(nullptr);
    }
    ();

    cin >> n >> m;

    multiset < ll > a;

    for (; i<n; i++) cin >> x, a.insert(x);

    while (m--)
    {
        x=*--a.end();

        a.erase(--a.end());

        a.insert(x/2);
    }

    for (i:a) ans+=i;

    cout << ans;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b;
  int x[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
  
  if(x[a]==x[b]) co("Yes");
  else co("No");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,c=1,t,s=0,cont=0;
    bool b=false;
    string a;
    list <int> l;
    list <int>::iterator it=l.begin();
    list <int>::reverse_iterator it2=l.rbegin();
    cin>>t;
    t++;
    for(j=0;j<t;j++){
        getline(cin,a);
        i=a.size()-1;
        while(a[i]!=' '){
            if(j>0&&a[i]=='t'){
                b=true;
                break;
            }
            else if(j>0&&a[i]=='1')s+=1*c;
            else if(j>0&&a[i]=='2')s+=2*c;
            else if(j>0&&a[i]=='3')s+=3*c;
            else if(j>0&&a[i]=='4')s+=4*c;
            else if(j>0&&a[i]=='5')s+=5*c;
            else if(j>0&&a[i]=='6')s+=6*c;
            else if(j>0&&a[i]=='7')s+=7*c;
            else if(j>0&&a[i]=='8')s+=8*c;
            else if(j>0&&a[i]=='9')s+=9*c;
            i--,c*=10;
        }
        //cout<<s<<"\n";
        if(b==false){
            if(a[0]=='i')l.push_front(s),cont++;
            else if(a[0]=='d'){
                while(it!=l.end()){
                    if(*it==s){
                        l.erase(it),cont--;
                        it=l.begin();
                        break;
                    }
                    it++;
                }
            }
        }
        else{
            if(a[6]=='F')l.pop_front(),cont--;
            else if(a[6]=='L')l.pop_back(),cont--;
        }
        s=0,c=1,b=false,it=l.begin();
    }
    while(it!=l.end()){
        if(cont>1)cout<<(*it)<<" ";
        else cout<<(*it2)<<endl;
        it++,cont--;
    }
    return 0;
}



Measured memory_bytes: 34284
import sys
input = sys.stdin.readline
r1, c1, r2, c2 = map(int, input().split())
mod = 10 ** 9 + 7

class Factorial:
  def __init__(self, n, mod):
    self.mod = mod
    self.f = [1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod
  def permi(self, n, k):
    return self.f[n] * self.i[n - k] % self.mod

n = max(r1, c1, r2, c2)
f = Factorial(n * 2 + 1, mod)
res = 0
for i in range(r1, r2 + 1):
  res += f.combi(c2 + i + 1, i + 1) - f.combi(c1 + i, i + 1)
  res %= mod
print(res)

Measured memory_bytes: 213036
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 30000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 998244353LL
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long powering(long long now,long long now_go){
	long long ans = 1;
	while (now_go != 0) {
		if (now_go % 2 == 1) {
			ans *= now;
			ans %= MAX_MOD;
		}
		now *= now;
		now %= MAX_MOD;
		now_go /= 2;
	}
	return ans;
}
vector<long long> calc(vector<long long> a, vector<long long> b) {
	long long k = sqrt(a.size());
	vector<long long> ans;
	for (int i = 0; i < k; ++i) {
		for (int q = 0; q < k; ++q) {
			long long geko = 0;
			for (int t = 0; t < k; ++t) {
				geko += a[i * k + t] * b[t * k + q];
				geko %= MAX_MOD;
 			}
			ans.push_back(geko);
		}
	}
	return ans;
}
vector<long long> powered(vector<long long> a, long long n) {
	vector<long long> ans = a;
	n--;
	while (n != 0) {
		if (n % 2 == 1) {
			ans = calc(ans, a);
		}
		a = calc(a, a);
		n /= 2;
	}
	return ans;
}
long long inv(long long now) {
	return powering(now, MAX_MOD - 2LL);
}
int main() {
#define int long long
	int n;
	cin >> n;
	vector<long long> geko;
	REP(i, n) {
		long long a;
		cin >> a;
		geko.push_back(a);
	}
	sort(geko.begin(), geko.end());
	vector<pair<long long, long long>> moves;
	while (geko.size() > 2 &&geko[geko.size() - 2] > 0) {
		moves.push_back(make_pair(geko[0], geko[geko.size() - 1]));
		geko[0] -= geko[geko.size() - 1];
		geko.pop_back();
	}
	for (int q = 0; q < geko.size() - 1; ++q) {
		moves.push_back(make_pair(geko[geko.size() - 1], geko[q]));
		geko[geko.size() - 1] -= geko[q];
	}
	cout << geko[geko.size() - 1] << endl;
	REP(i, moves.size()) {
		cout << moves[i].first << " " << moves[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 4336
#include<iostream>

using namespace std;
typedef long long ll;

int N;
ll K, A[100000];
int bit_cnt[41];

int main(){
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        for(int j = 0; j < 41; j++){
            ll tmp = 1;
            if((tmp << j) & A[i])bit_cnt[j]++;
        }
    }
    bool f = true;//f:trueは上限に引っかかる可能性がある　falseは引っかかる可能性がない
    ll ans_X = 0;
    for(ll i = 40; i >= 0; i--){
        ll tmp = 1;
        if(f){
            //cout << i << endl;
            if(K & (tmp << i)){
                 if(bit_cnt[i] * 2 < N){
                    //このけたは1にする
                    ans_X += (tmp << i);
                   }else {
                    //このけたは0にする
                    f = false;
                }
            }
        }else {
            if(bit_cnt[i] * 2 < N){
                //このけたは1にする
                ans_X += (tmp << i);
            }else {
                //このけたは0にする
                
            }  
        }
    }
    ll ans = 0;
    // (1 << j)だと比較がバグる？　ll tmp = 1; (tmp << j)で対処したけど
    for(int i = 0; i < N;i++){
        ans += (ans_X ^ A[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int S, W;
  cin >> S >> W;

  if (S <= W) cout << "unsafe" << endl;
  else cout << "safe" << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;

int digit_sum(int a){
	int x=a;
	int sum=0;
	while(x>0){
		sum += x%10;
		x /= 10;
	}
	return sum;
}

int main(){
	int n;
	cin >> n;
	cout << min(digit_sum(n-1)+digit_sum(1), digit_sum(n/2)+digit_sum(n-n/2)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
typedef int TInt;
typedef std::vector<TInt> TList;

TList Input()
{
    int Count;
    std::cin >> Count;
    TList List(Count);
    for(int i = 0; i < Count; ++i){
        std::cin >> List[i];
    }
    return List;
}
int insertionSort(TList& A, int g)
{
    int cnt = 0;
    for(int i = g; i < A.size(); ++i){
        TInt v = A[i];
        int j = i - g;
        while(j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j+g] = v;
    }
    return cnt;
}
TList GetG(int Max)
{
    TList G;
    int h = 1;
    while(h <= Max){
        G.push_back(h);
        h = 3 * h + 1;
    }
    // Reverse(G);
    std::reverse(G.begin(), G.end());
    return G;
}
int shellSort(TList& A, const TList& G)
{
    int cnt = 0;
    for(TList::const_iterator It = G.begin();
        It != G.end();
        ++It){
        cnt += insertionSort(A, *It);
    }
    return cnt;
}
void OutputLine(const TList& List)
{
    TList::const_iterator It = List.begin();
    std::cout << *(It++);
    for(; It != List.end(); ++It){
        std::cout << " " << *It;
    }
    std::cout << std::endl;
}
void Output(const TList& List)
{
    TList::const_iterator It = List.begin();
    // std::cout << *(It++);
    for(; It != List.end(); ++It){
        std::cout << *It << std::endl;
    }
}
int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    TList A = Input();
    TList G = GetG(A.size());
    int cnt = shellSort(A, G);
    std::cout << G.size() << std::endl;
    OutputLine(G);
    std::cout << cnt << std::endl;
    Output(A);
    return 0;   
}

Measured memory_bytes: 6800
#include<cstdio>

using namespace std;

int n, m;
int s[200000], t[200000];

int check(){
	for(int i = 1; i < n - 1; i++) if(s[i] == 1 && t[i] == 1) return 1;
	return 0;
}

int main(){
	scanf("%d %d", &n, &m);
	for(int i = 0; i < m; i++){
		int a, b; scanf("%d %d", &a, &b); a--; b--;
		if(a == 0) s[b] = 1;
		if(b == n - 1) t[a] = 1;
	}
	puts(check() ? "POSSIBLE" : "IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

long long GCD(long long a, long long b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}

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

    long double A, B, C, D;
    cin >> A >> B >> C >> D;
    long double E = LCM(C, D);

    debug(A, B, C, D, E);
    long double ac, bc, ad, bd, ae, be;
    ac = A / C;
    bc = B / C;
    ad = A / D;
    bd = B / D;
    ae = A / E;
    be = B / E;

    ll all = B - A + 1;
    ll c_dividable = floor(bc) - ceil(ac) + 1;
    ll d_dividable = floor(bd) - ceil(ad) + 1;
    ll e_dividable = floor(be) - ceil(ae) + 1;
    debug(bc, floor(bc), ac, ceil(ac));
    debug(bd, floor(bd), ad, ceil(ad));
    debug(be, floor(be), ae, ceil(ae));
    debug(all, c_dividable, d_dividable, e_dividable);
    cout << all - (c_dividable + d_dividable - e_dividable) << endl;

    return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3
n = int(input())
ans = 0


def gcd(n, m):
    a, b = n, m
    if a > b:
        a, b = b, a
    while a != 0:
        a, b = b % a, a
    return b


for i in range(1, n + 1):
    for j in range(1, n + 1):
        for k in range(1, n + 1):
            ans += gcd(k, gcd(i, j))
print(ans)


Measured memory_bytes: 74128
def main():
	line = input()
	vector = [int(x) for x in line.split()]
	a = vector[0]
	b = vector[1]
	if a >= 13:
		print(b)
	if a >= 6 and a <= 12:
		print(b // 2)
	if a <= 5:
		print(0)







if __name__ == "__main__":
	main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

map<string, int> m =
{
    {"SUN", 7},
    {"MON", 6},
    {"TUE", 5},
    {"WED", 4},
    {"THU", 3},
    {"FRI", 2},
    {"SAT", 1},
    
};
int main()
{
    string s;
    cin >> s;
    cout << m[s];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
int main() {
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  int n;
  cin >> n;
  vector<int> A(n), B(n), C(3 * n);
  for (auto &i : A) cin >> i;
  for (auto &i : B) cin >> i;
  for (int i = 0; i < n; ++i) {
    int l = lower_bound(B.begin(), B.end(), A[i]) - B.begin();
    if (l == n || B[l] != A[i]) continue;
    int r = upper_bound(B.begin(), B.end(), A[i]) - B.begin() - 1;
    if (i <= l) {
      C[l - i]++;
      C[r - i + 1]--;
    } else if (i > r) {
      C[n - i + l]++;
      C[n - i + r + 1]--;
    } else {
      C[0]++;
      C[r - i + 1]--;
      C[n - i + l]++;
    }
  }
  for (int i = 1; i < n; ++i) C[i] += C[i - 1];
  for (int i = 0; i < n; ++i)
    if (C[i] == 0) {
      cout << "Yes\n";
      for (int j = 0; j < n; ++j) cout << B[(i + j) % n] << " ";
      cout << "\n";
      return 0;
    }
  cout << "No";

  return 0;
}
//2020.09.13 21:03:42


Measured memory_bytes: 7148
n=int(input())
A=list(map(int,input().split()))
def gcd(a,b):
    if b>a:
        return gcd(b,a)
    if b==0:
        return(a)
    else:
        return gcd(b,a%b)
g=A[0]
seki=A[0]
for i in range(1,n):
    g=gcd(g,A[i])
    seki*=A[i]
lcm=seki//(g**(n-1))
cnt=0
for j in range(n):
    cnt += (lcm-1) % A[j]
print(cnt)

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

int D;
int N;
long long val[200010];

long long cal(int s,int t){ // [s,t]
	if( s > t ){ t += N; }
	return val[t] - (s?val[s-1]:0);
}
int cut(int x,long long lim){
	int D = x+N;
	long long subval = x ? val[x-1] : 0;
	int idx1 = lower_bound(val+x,val+D,lim+subval) - val;
	if( idx1 >= D ) return 0;
	int idx2 = lower_bound(val+x,val+D,val[idx1]+lim) - val;
	if( idx2 >= D ) return 0;
	
	return val[D-1] - val[idx2] >= lim;
}
int main(){
	cin >> N;

	for(int i = 0 ; i < N ; i++) cin >> val[i], val[i+N] = val[i];
	for(int i = 1 ; i < 2*N ; i++) val[i] += val[i-1];
	long long answer = 0;
	for(int i = 0 ; i < N ; i++){
		long long le = 1;
		long long ri = 1e15;
		while( le != ri ){
			long long mi = (le+ri+1) / 2;
			if( cut(i,mi) ){
				le = mi;
			}else{
				ri = mi-1;
			}
		}
		answer = max(answer,le);
	}
	cout << answer << endl;
}

Measured memory_bytes: 2724
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<cstring>
#include<vector>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<functional>
#include<unordered_map>
#define io ios::sync_with_stdio(false)
#define inf 0x3f3f3f3f
#define ll long long
#define P pair<int,int>
#define lc rt*2
#define rc rt*2+1
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
const double PI = 3.1415926536;

using namespace std;



int main()
{
	io;
	int a, b;
	cin >> a >> b;
	for (int i = 0; i <= 100000; ++i)
	{
		if ((int)(i*0.08) == a && (int)(i*0.1) == b)
		{
			cout << i;
			break;
		}
		if (i == 100000)
			cout << -1;
	}
	return 0;
}


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

int main(){
  int N,M,C=0;
  cin >> N >> M;
  vector<vector<int>> s(M);
  vector<int> k(M),p(M);
  for(int i=0; i<M; i++){
    cin >> k.at(i);
    for(int j=0; j<k.at(i); j++){
      int ss;
      cin >> ss;
      s.at(i).push_back(ss);
    }
  }
  for(int i=0; i<M; i++){
    cin >> p.at(i);
  }
  
  for(int i=0; i<(1<<N); i++){
    bool a=1;
    for(int j=0; a&&j<M; j++){
      int sum=0;
      for(int l=0; l<k.at(j); l++){
        sum+=i%(1<<s.at(j).at(l))/(1<<(s.at(j).at(l)-1));
      }
      if(sum%2!=p.at(j)){
        a=0;
      }
    }
    if(a){
      C++;
    }
  }
  
  cout << C << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
struct Node
{
	int key;
	Node* parent;
	Node* left;
	Node* right;
};
Node* root;
void insert(int val)
{
	Node* x = new Node();
	x->key = val;
	x->left = nullptr;
	x->right = nullptr;
	Node *q = nullptr;
	Node *p = root;
	while (p != nullptr)
	{
		q = p;
		if (x->key < p->key)
			p = p->left;
		else
			p = p->right;
	}
	x->parent = q;
	if (q == nullptr)
		root = x;
	else if (x->key < q->key)
		q->left = x;
	else
		q->right = x;
}
Node* find(Node* root,int x)
{
	while (root != nullptr&&root->key != x)
	{
		if (x < root->key)
			root = root->left;
		else
			root = root->right;
	}
	return root;
}
Node* treeMin(Node* x)
{
	while (x->left != nullptr)
		x = x->left;
	return x;
}
Node* treeSuccessor(Node* x)
{
	if (x->right != nullptr)
		return treeMin(x->right);
	Node* p = x->parent;
	while (p != nullptr&&x == p->right)
	{
		x = p;
		p = p->parent;
	}
	return p;
}
void deleteNode(Node* x)
{
	Node* p;
	Node* c;
	if ((x->left == nullptr) || (x->right == nullptr))
		p = x;
	else
		p = treeSuccessor(x);
	if (p->left != nullptr)
		c = p->left;
	else
		c = p->right;
	if(c!=nullptr)
		c->parent = p->parent;
	if (p->parent == nullptr)
		root = c;
	else if (p == p->parent->left)
		p->parent->left = c;
	else
		p->parent->right = c;
	if (p != x)
		x->key = p->key;
	delete p;
}
void inorder(Node* root)
{
	if (root == nullptr)
		return;
	inorder(root->left);
	printf(" %d", root->key);
	inorder(root->right);
}
void preorder(Node* root)
{
	if (root == nullptr)
		return;
	printf(" %d", root->key);
	preorder(root->left);
	preorder(root->right);
}
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string s;
		int t;
		cin >> s;
		if (s[0] == 'i')
		{
			cin >> t;
			insert(t);
		}
		else if (s[0] == 'p')
		{
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
		else if (s[0] == 'f')
		{
			cin >> t;
			cout << (find(root,t) ? "yes" : "no") << endl;
		}
		else if (s[0] == 'd')
		{
			cin >> t;
			deleteNode(find(root, t));
		}
	}
}


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

int main(int argc, char *argv[]){
  std::string S;
  std::cin >> S;
  int upper = atoi(S.substr(0,2).c_str());
  int lower = atoi(S.substr(2,2).c_str());

  if(0 < upper && upper < 13){
    if(0 < lower && lower <13){
      std::cout << "AMBIGUOUS" << '\n';
    }else{
      std::cout << "MMYY" << '\n';
    }
  }else{
    if(0 < lower && lower < 13){
      std::cout << "YYMM" << '\n';
    }else{
      std::cout << "NA" << '\n';
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    ll N;
    cin >> N;

    vector<ll> x(N), L(N);
    vector<P> p(N);
    REP(i, N) {
        cin >> x[i] >> L[i];
        p[i].first = x[i] - L[i];
        p[i].second = x[i] + L[i];
    }

    sort(p.begin(), p.end(), [](pair<ll, ll> x, pair<ll, ll> y) { return x.second < y.second;});

    //REP(i, N) cout << p[i].first << " " << p[i].second << endl;
    int ans = 0;
    ll tmp = p[0].second;
    REP(i, N){
        if (i == 0) continue;
        if (tmp <= p[i].first){
            tmp = p[i].second;
        }
        else ans++;
    }

    cout << (N-ans) << endl;
    return 0;
}


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

int main() {
    int H,W;
    cin >> H >> W;
    vector<string> S(H);
    for(int i=0;i<H;i++){
        cin >> S.at(i);
    }
    vector<vector<int> > map(H, vector<int>(W, 0));
    for(int h=0;h<H;h++){
        for(int w=0;w<W;w++){
            if(S[h].at(w) == '#'){
                for(int i=h-1;i<h+2;i++){
                    for(int j=w-1;j<w+2;j++){
                        if(0<=i && i<H && 0<=j && j<W){
                            map.at(i).at(j)++;
                        }
                    }
                }
            }
        }
    }
    for(int h=0;h<H;h++){
        for(int w=0;w<W;w++){
            if(S[h].at(w) != '#'){
                S[h].at(w) = map.at(h).at(w) + '0';
            }
        }
    }
    for(int h=0;h<H;h++){
        cout << S[h] << endl;
    }

    return 0;
}

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

int main(){
    int min = 0, kaisuu = 0;
    cin >> kaisuu;
    for ( int i = 0; i < kaisuu; i++ ){
        int count = 0, num = 0;
        cin >> num;
        while( !(num % 2) ){
            num = num / 2;
            count++;
        }
        if( !i || min > count )
            min = count;
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
const int MAX_N = 100010;

// input
int N;
long long h[MAX_N];

// DP table
long long dp[MAX_N];

int main()
{
  int N; cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }

  // Initialize to INF because minimization problem
  for (int i = 0; i < MAX_N; i++) {
    dp[i] = INF;
  }

  // Initial conditions
  dp[0] = 0;

  for (int i = 1; i < N; i++) {
    chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
    if (i > 1) {
      chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
  }

  // output
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1792
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

n,x,y=LI()
edge = [[] for i in range(n)]
for i in range(n-1):
  edge[i].append([1,i+1])
  edge[i+1].append([1,i])
edge[x-1].append([1,y-1])
edge[y-1].append([1,x-1])

ans=[0]*n
for i in range(n):
  a=dijkstra_heap(i,edge)
  # print(a)
  for x in a[i:]:
    ans[x]+=1

for x in ans[1:]:
  print(x)


Measured memory_bytes: 111064
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-03 17:48:16
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n; cin >> n;
  vector<string> s(n); cin >> s;

  // x : BxxxxA
  // y : Bxxxxx
  // z : XXXXXA

  int cnt = 0, x = 0, y = 0, z = 0;

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < (int) s[i].size() - 1; ++j) {
      cnt += s[i].substr(j, 2) == "AB";
    }
    if (s[i][0] == 'B' && s[i].back() == 'A') {
      ++x;
    } else if (s[i][0] == 'B') {
      ++y;
    } else if (s[i].back() == 'A') {
      ++z;
    }
  }

  int ans = cnt;
  debug(ans, x, y, z);
  ans += max(0, x - 1);
  if (y > 0 && x > 0) {
    ++ans; --y;
  }
  if (z > 0 && x > 0) {
    ++ans; --z;
  }

  if (y > 0 && z > 0) ans += min(y, z);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 896
#include<cstdio>
#include<algorithm>
using namespace std;
int n,i;
double ans,a[55];
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	scanf("%lf",&a[i]);
	sort(a+1,a+n+1);
	for (ans=a[1],i=2;i<=n;i++)
	ans=(ans+a[i])/2;
	printf("%lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
def main():
    x, y = map(int, input().split())
    flag = False
    if 2 * x <= y <= 4 * x:
        if (4 * x - y) % 2 == 0:
            if (y - 2 * x) % 2 == 0:
                flag = True
                
    if flag:
        print('Yes')
    else:
        print('No')
            

if __name__ == '__main__':
    main()

Measured memory_bytes: 9064
# 2020/01/10

from itertools import permutations

n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))

P=sorted(list(permutations(range(1,n+1))))


ans=0
for idx,e in enumerate(P,1):
    if e==p:
        ans+=idx
    if e==q:
        ans-=idx
    
print(abs(ans))

Measured memory_bytes: 8308
#include<bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long n,a,b,x[100005],dp[100005][2];
vector<long long>g1,g2;
int main()
{
	cin>>n>>a>>b;
	x[1]=-(1LL<<62);
	x[n+2]=(1LL<<62);
	g1.push_back(2);
	g2.push_back(2);
	for(int i=2;i<=n+1;i++)
	{
		cin>>x[i];
		if(x[i]-x[i-1]<a)g1.push_back(i);
		if(x[i]-x[i-1]<b)g2.push_back(i);
	}
	dp[1][0]=1;
	dp[1][1]=1;
	for(int i=2;i<=n+1;i++)
	{
		int p1=upper_bound(x,x+n+3,x[i+1]-a)-x-1;
		if(p1==i)p1--;
		int p2=upper_bound(g2.begin(),g2.end(),i)-g2.begin()-1;
		p2=g2[p2]-1;
		if(p1>=p2)dp[i][0]=(dp[p1][1]-dp[p2-1][1]+md)%md;
		dp[i][0]=(dp[i][0]+dp[i-1][0])%md;
		p1=upper_bound(x,x+n+3,x[i+1]-b)-x-1;
		if(p1==i)p1--;
		p2=upper_bound(g1.begin(),g1.end(),i)-g1.begin()-1;
		p2=g1[p2]-1;
		if(p1>=p2)dp[i][1]=(dp[p1][0]-dp[p2-1][0]+md)%md;
		dp[i][1]=(dp[i][1]+dp[i-1][1])%md;
	}
	cout<<(dp[n+1][0]+dp[n+1][1]-dp[n][0]-dp[n][1]+md*2)%md<<endl;
	return 0;
}

Measured memory_bytes: 4332
n,m,x = gets.chomp.split(' ').map(&:to_i)
 arr ={}
 (n+2).times{|t| arr[t] = 0}
 a = gets.split(' ').map(&:to_i)
a.each{ |s|  arr[s] += 1}
a = arr.values.inject(:+)
b = 0
(x+1).times{|v| b += arr[v]}
ans = [a-b,b]
puts ans.min

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll long long
#define fastio  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD=1000000007;
#define PI acos(-1)
using namespace std;
ll gcd(ll x, ll y)
{                     
        return (x==0)? y : gcd(y % x, x);
}

int main(){
    int x ; cin >> x ;
    if( x == 7 || x == 5 || x == 3){
    	cout << "YES" << endl;
	}
	else cout << "NO" << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
vector<int>v[100005],v2[100005];
stack<int>s;
int visit[100005];
void dfs(int node)
{
	visit[node]=1;
	for(int i=0;i<v[node].size();i++)
	{
		if(!visit[v[node][i]])
			dfs(v[node][i]);
	}
	s.push(node);
}
int main()
{
	int i,j,k;
	int n,m;
	sd(n);
	sd(m);
	while(m--)
	{
		sd(i);
		sd(j);
		sd(k);
		v[i].pb(j);
		v2[i].pb(k);
	}
	for(i=1;i<=n;i++)
	{
		if(!visit[i])
			dfs(i);
	}
	for(i=1;i<=n;i++)
		visit[i]=-1;
	while(!s.empty())
	{
		int x=s.top();
		if(visit[x]==-1)
			visit[x]=1;
		s.pop();
		for(i=0;i<v[x].size();i++)
		{
			if(visit[x]+v2[x][i]==visit[v[x][i]]||visit[v[x][i]]==-1)
				visit[v[x][i]]=visit[x]+v2[x][i];
			else
			{
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;
}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int n; cin >> n;
  vi v(n);

  rep(i, n) cin >> v[i];
  int sum = accumulate(all(v),0);

  rep(i, n) {
    if (v[i] >= sum - v[i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int A, B;
    cin >> A >> B;
    if (B % A == 0)
        cout << B + A;
    else
        cout << B - A;
    cout << endl;
    return 0;
};


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

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

const int INF = 1 << 24;
const int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};

typedef unsigned long long ull;

std::vector<int> C[20], D[20];// D[i][j]: 種類iでj個選ぶときの最大価格
int G[20];

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

    std::fill(G, G+20, 0);

    REP(i, N){
        int c, g;
        std::cin >> c >> g;

        C[g].push_back(c);
        G[g]++;
    }

    FOR(i, 1, 11){
        std::sort(C[i].begin(), C[i].end(), std::greater<int>());

        D[i].push_back(0);

        int sum = 0;

        //printf("%d: ", i);

        REP(j, G[i]){
            int t = j + 1;
            sum += C[i][j];

            D[i].push_back(sum + t * (t-1));
            //printf("%d, ", sum + t * (t-1));
            //std::cout << i << "," << sum << std::endl;
        }
        //puts("");
    }

    int dp[20][2010];
    REP(i, 20){
        REP(j, 2010){
            dp[i][j] = -INF;
        }
    }

    FOR(i, 1, 11){
        dp[i][0] = 0;
    }

    FOR(i, 1, G[1]+1){
        dp[1][i] = D[1][i];
    }

    FOR(i, 2, 11){
        REP(j, K+1){
            dp[i][j] = dp[i-1][j];

            FOR(k, 1, G[i]+1){
                if(j - k >= 0){
                    dp[i][j] = std::max(dp[i][j], dp[i-1][j-k] + D[i][k]);
                }
            }
        }
    }

    // FOR(i, 1, 4){
    //     REP(j, K+1){
    //         printf("%d, ", dp[i][j]);
    //     }
    //     puts("");
    // }

    std::cout << dp[10][K] << std::endl;
}

Measured memory_bytes: 1404
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pll         pair<long long,long long>
#define vll          vector<long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (long long)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main(){
	int n;cin>>n;
	cout<<n*n*n<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  string s,t;
  cin>>s>>t;
  if(t.size()-s.size()!=1){cout<<"No"<<endl;return 0;}
  for(ll i=0;i<s.size();i++){
    if(s.at(i)!=t.at(i)){cout<<"No"<<endl;return 0;}
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
using namespace std;
int N, K, L; 
int par[200010] = {}; 
long long int par1[200010] = {}; 
int depth[200010] = {}; 
map<long long int, int> A = {}; 
int find(int x){
	if(par[x] == x){
		return x;
	}
	else{
		return par[x] = find(par[x]); 
	}
}
void unite(int x, int y){
	x = find(x); 
	y = find(y); 
	if(x == y) return;
	else if(depth[x] < depth[y]){
		par[x] = y; 
	}else{
		par[y] = x; 
		if(depth[x] == depth[y]) depth[x] ++; 
	}
}
bool same(int x, int y){
	return find(x) == find(y); 
}
int main(){
	cin >> N >> K >> L; 
	for(int i = 1; i <= N; i++){
		par[i] = i, depth[i] = 0; 
	}
	for(int i = 0; i < K; i++){
		int p, q; 
		cin >> p >> q;
		unite(p, q); 
	}
	for(int i = 1; i <= N; i++){
		find(i); 
	}
  	for(int i = 1; i <= N; i++){
		par1[i] = (long long) 200010 * par[i]; 
    		par[i] = i, depth[i] = 0; 
  	}
	for(int i = 0; i < L; i++){
		int p, q; 
		cin >> p >> q;
		unite(p, q); 
	}
	for(int i = 1; i <= N; i++){
		find(i); 
	}
	for(int i = 1; i <= N; i++){
		par1[i] += (long long) par[i];
		A[par1[i]] ++; 
	}
	for(int i = 1; i <= N; i++){
		cout << A[par1[i]] << " "; 
	}
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
#define pi 3.1415926535897932384

int main(){
  int N; cin >> N;
  int A[N]; rep(i,N) cin >> A[i];
  int cnt = 0;

  rep(i,N){
    bool flag = true;
    for (int j=2;j<=(int)sqrt(A[i]);j++){
      if (A[i]%j==0){
        flag = false;
        break;
      }
    } 
    cnt += flag;
  }
  
  cout << cnt << endl;

  return 0;
}

 


Measured memory_bytes: 3132
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		String message = "Odd";
		if(a % 2 == 0 || b % 2 == 0) {
			message = "Even";
		}
		System.out.println(message);
	}
}


Measured memory_bytes: 21844
#import sys
#input = sys.stdin.readline

n, x = map(int,input().split())
ls = list(map(int,input().split()))
ls.append(0)
ans = 0

for i in range(n):
    if ls[i] != 0:
        if x < ls[i]+ls[i+1] :
            ans += (ls[i]+ls[i+1]) - x
            ls[i+1] = max(x - ls[i],0)
print(ans)

Measured memory_bytes: 14252