akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<int, int>;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

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

void solve() {
  int x;
  std::cin >> x;
  if (x < 1200) {
    cout("ABC\n");
  } else {
    cout("ARC\n");
  }
}


Measured memory_bytes: 256
import sys

N, M = map(int, sys.stdin.readline().split())
H = list(map(int, sys.stdin.readline().split()))
edges = [set() for _ in range(N)]
for _ in range(M):
    a, b = map(int, sys.stdin.readline().split())
    edges[a-1].add(b-1)
    edges[b-1].add(a-1)

ans = 0
for i in range(N):
    h = H[i]
    flag = True
    for j in edges[i]:
        if H[j] >= h:
            flag = False
            break
    if flag:
        ans += 1
print(ans)

Measured memory_bytes: 45992
#include <bits/stdc++.h>
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-12;
const double PI = acos(-1.0);
 
int main() {
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	while(1){
		c -= b; // 高橋攻撃
		if(a <= 0 || c <= 0) break;
		a -= d; // 青木攻撃
		if(a <= 0 || c <= 0) break;
	}
	cout << (c <= 0 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 3628
n, q = map(int, input().split())
query = [list(map(int, input().split())) for _ in range(q)]

ans = (n - 2)** 2
cnt, wh = [n - 2, n - 2], [[None] * (n - 2), [None] * (n - 2)]
for num, x in query:
    num, x = num - 1, x - 2
    if cnt[num] > x:
        wh[num][x:cnt[num]] = [cnt[1 - num]] * (cnt[num] - x)
        cnt[num] = x
    ans -= wh[num][x]
    wh[num][x] = 0
print(ans)


Measured memory_bytes: 120424
n, k = list(map(int, input().split()))
s = input()
count  = point = 0
while(count < n - 1):
	if (s[count] == s[count + 1]):
		point += 1
	count += 1
point += 2 * k
if (point > n - 1):
	print(n - 1)
else:
	print(point)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int INF = 1e18;

int main() {
    ll N, M;
    cin >> N >> M;
    vi H(N);
    rep(i, N) cin >> H[i];
    vi mx(N, 0);

    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        mx[a] = max(mx[a], H[b]);
        mx[b] = max(mx[b], H[a]);
    }

    int res = 0;
    rep(i, N) {
        if(H[i] > mx[i]) res++;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
#define int long long

int pw(int a,int t,int mod){
    int x=1;
    while(t>0){
        if(t&1)x=x*a%mod;
        a=a*a%mod,t>>=1;
    }
    return x;
}
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n;
    string st;
    cin >> n >> st;
    int a[n]={0},cnt=0,ans[n]={0};
    for(int i=0;i<n;i++){
        if(st[i]=='1')cnt++;
    }
    int x=0,y=0;
    for(int i=0;i<n;i++){
        if(st[i]=='0')continue;
        if(cnt>1)x=(x+pw(2,n-1-i,cnt-1))%(cnt-1);
        y=(y+pw(2,n-1-i,cnt+1))%(cnt+1);
    }
    for(int i=0;i<n;i++){
        if(st[i]=='1'){
            if(cnt==1)continue;
            a[i]=(x-pw(2,n-1-i,cnt-1)+(cnt-1))%(cnt-1);
            ans[i]++;
        }
        else{
            a[i]=(y+pw(2,n-1-i,cnt+1))%(cnt+1);
            ans[i]++;
        }
    }
    for(int i=0;i<n;i++){
        int k=0;
        while(a[i]){
            a[i]=a[i]%__builtin_popcount(a[i]);
            k++;
        }
        ans[i]+=k;
    }
    for(int i=0;i<n;i++)
        cout << ans[i] << '\n';
}

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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	int N, A[200000]; cin >> N;
	REP(i, N) cin >> A[i];

	vector<vint> G(N);
	REP(i, N-1){
		int u, v; cin >> u >> v;
		u--; v--;
		G[u].eb(v); G[v].eb(u);
	}

	vint dp(N+10, 2e9);
	stack<pint> sta;
	vint ans(N, 1);
	vector<bool> visit(N, 0); visit[0] = 1;

	auto dfs = [&](auto &&dfs, int pos) -> void {
		int i = lower_bound(ALL(dp), A[pos]) - dp.begin();
		sta.push({i, dp[i]});
		dp[i] = A[pos];
		ans[pos] = lower_bound(ALL(dp), 2e9) - dp.begin();
		for(int nx: G[pos]){
			if(visit[nx]) continue;
			visit[nx] = 1;
			dfs(dfs, nx);
		}
		pint prev = sta.top(); sta.pop();
		dp[prev.first] = prev.second;
	};

	dfs(dfs, 0);

	REP(i, N){
		cout << ans[i] << ln;
	}
}


Measured memory_bytes: 29448
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
int lcm(int a, int b){
  return a / gcd(a,b) * b;
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  vector<mint> two(n+1);
  two[0] = 1;
  rep(i,n) two[i+1] = two[i]*2;
  mint ans;
  rep(i,n){
    int l = i, r=n-1-i;
    mint now = two[r]; //その列の1の数
    if(r != 0) now += two[r-1]*r; //右側の列の1の数
    now *= two[l]; //左側にあるパターン数
    now *= a[i]; //コスト掛ける
    ans += now;
  }
  
  ans *= two[n];
  cout << ans.val << endl;
  
  return 0;
}

Measured memory_bytes: 2560
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*///

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}

ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}


bool isPrime(int n)
{
    if(n==1)
        return false;
    for(int i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+= + n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}

int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);

int n=RD(),ans=3*pow(n,2);
cout<<ans<<"\n";

 }


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int temp;
  temp = n % 10;

  if(temp == 2 || temp == 4 || temp == 5 || temp == 7 || temp == 9){
    cout << "hon" << endl;
  }
  else if(temp == 0 || temp == 1 || temp == 6 || temp == 8){
    cout << "pon" << endl;
  }
  else{
    cout << "bon" << endl;
  }

  return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  rep(i, n-2) {
    if (s.substr(i, 3) == "ABC") ++ans;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
	string id;
	int am, pm;
	int n, money;
	for(int i=0; i < 9; i++){
		cin >> id >> am >> pm;
		money = am * 200 + pm * 300;
		n = am + pm;
		cout << id << ' ' << n << ' ' << money << endl;
	}
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

int inf = std::numeric_limits<int>().max();

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define ll long long
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

int main() {
	int n;
	cin >> n;
	vector<int> v(n); 
	for(int i=0; i<n; i++) {
		cin >> v[i];
	}

	for(int i=n-2; i>=0; i--) {
		if (v[i] > v[i+1]) v[i]--; 
	}

	bool vf = 1;
	for(int i=0; i<n-1; i++) {
		if (v[i] > v[i+1]) vf = 0;	
	}
	if (vf) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

typedef struct{
    char w[32+1];
    int cnt;
}WORD;
typedef struct{
    WORD *W;
    int size;
}FREQ;

//f.Wにwordを含むならその添え字、そうでなければ-1を返す
int containWord(FREQ f,char word[]){
    int i;
    for(i=0;i<f.size;i++){
        if(strcmp(f.W[i].w,word)==0)return i;
    }
    
    return -1;
}

int main(void){
    FREQ f;
    f.size=0;
    
    int freq=0;
    int freqi=-1;
    int max=0;
    int maxi=-1;
    char word[32+1];
    int i;
    
    while(scanf("\n %s \n",word)>0){
        if(f.size==0){
            f.size++;
            f.W=(WORD*)malloc(sizeof(WORD));
            strcpy(f.W[0].w,word);
            f.W[0].cnt=1;
            freq=1;
            freqi=0;
            max=strlen(word);
            maxi=0;
        }else{
            if((i=containWord(f,word))!=-1){
                if(++f.W[i].cnt>freq){
                    freq=f.W[i].cnt;
                    freqi=i;
                }
                
            }else{
                f.size++;
                f.W=(WORD*)realloc(f.W,sizeof(WORD)*f.size);
                strcpy(f.W[f.size-1].w,word);
                f.W[f.size-1].cnt++;
                if(max<strlen(word)){
                    max=strlen(word);
                    maxi=f.size-1;
                }
            }
        }
    }
    
    printf("%s %s\n",f.W[freqi].w,f.W[maxi].w);
    
    return 0;    
}



Measured memory_bytes: 2036
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<regex>
#include<ctype.h>
using namespace std;

int main(void) {
	
	int n, m, k[30], a[30];
	cin >> n >> m;
	int ck[30] = {}, cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			cin >> a[j];
			ck[a[j] - 1]++;
		}
	}

	for (int i = 0; i < m; i++) {
		if (ck[i] == n) cnt++;
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        boolean[] a = new boolean[x+1];
        a[0] = true;
        for (int i = 100; i < 106; i++) {
            for (int j = i; j < x+1; j++) {
                if(a[j-i]){
                    a[j] = true;
                }
            }
        }
        System.out.println(a[x] ? "1" : "0");
        sc.close();

    }

}


Measured memory_bytes: 23380
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;

#define iof freopen("input.txt","r", stdin) ;freopen("output.txt","w", stdout) ;
#define io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define mod 1000000007
#define vec vector<long long>
#define pb push_back
#define ll  long long
#define f(b) for(int i=0;i<b;i++)
#define f2(b) for(int j=0;j<b;j++)
#define f3(b) for(int k=0;k<b;k++)
#define endl '\n'
#define pi pair<int,int>
#define INF 1000000000000000001

long long pow(long long x, long long y){ if (y == 0) return 1; else if (y % 2 == 0) return pow(x, y / 2) * pow(x, y / 2);else return x * pow(x, y / 2) * pow(x, y / 2);}
long long dig(long long n) {return floor(log10(n) + 1);}

int main()
{
	io
	#define int long long
    //int t; cin>>t; while(t--)
    {
        string s;

        int t=0;

        cin>>s;

        f(s.size())
        {
           t+= s[i] - '0';
        }

        if(t%9==0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define mod (1000*1000*1000+7);
typedef long long ll;
const int N = 100001;
vector<int> g[N+1];
int vis[N+1];
ll dp[N+1][2];
void dfs(int u) {
    vis[u] = true;
    dp[u][0] = dp[u][1] = 1;
    for(int i = 0; i < g[u].size(); ++i) {
        if(vis[g[u][i]] == false) {
            dfs(g[u][i]);
            dp[u][0] = (dp[u][0]*dp[g[u][i]][1])%mod;
            dp[u][1] = (dp[u][1]*(dp[g[u][i]][0] + dp[g[u][i]][1]))%mod;
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(vis,false,sizeof(vis));
    int n; cin>>n; 
    for(int i = 1; i <= n-1; ++i) {
        int u,v; cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1);
    ll ans = (dp[1][0] + dp[1][1])%mod;
    cout<<ans<<"\n";
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  long long right = c - a - b;
  long long left = a * b * 4;
  if (right > 0 && right * right > left)
    puts("Yes");
  else
    puts("No");
  return 0;
}


Measured memory_bytes: 256
n, m = map(int,input().split())
li = []
ans = []
#市, 年, 出力順で格納

for i in range(m):
    x = list(map(int,input().split()))
    x.append(i)
    li.append(x)

li.sort()

for i in range(len(li)):
    if i == 0:
        y = 1
    elif li[i][0] == li[i-1][0]:
        y += 1
    else:
        y = 1
    li[i].append(str(li[i][0]).rjust(6,'0') + str(y).rjust(6,'0'))

li.sort(key=lambda x: x[2])

for i in li:
    print(i[3])

Measured memory_bytes: 38852
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t,m,n,i,f=0,j,ans=0,k,x,r;
    cin >> k ;
    for(i=1;i<=k;++i)
    {
        for(j=1;j<=k;++j)
        {
            for(f=1;f<=k;++f)
            {
                ans+=__gcd(i,__gcd(j,f));
            }
        }
    }
    cout << ans ;
    
    return 0;
}

Measured memory_bytes: 3652
while True:
  m,f,r = map(int,input().split())
  if m == -1 and f == -1 and r == -1: exit()

  if m == -1 or  f == -1 or m + f < 30 :  print('F')
  elif m + f >= 80: print('A')
  elif m + f >= 65 and m + f < 80:  print('B')
  elif m + f >= 50 and m + f < 65:  print('C')
  elif m + f >= 30 and m + f < 50:
    if r >= 50:
      print('C')
    else:
      print('D')


Measured memory_bytes: 5596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

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

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

      return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    System.out.println(x + y / 2);
  }
}

Measured memory_bytes: 20692
a = int(input())
b = list(map(int,input().split()))

c = sorted(b, reverse=True)

m = int(a / 2) - 1
anslist = [0] * a
for i, data in enumerate(b):
    if c[m] > data:
        anslist[i] = c[m]
    elif c[m] <= data:
        anslist[i] = c[m + 1]
        
for j in range(a):
    print(anslist[j])

Measured memory_bytes: 30888
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
char in[2100][2100];
bitset<2100>dp[2][2100];
bitset<2100>g[2][2100];
int main(){
	int a;scanf("%d",&a);
	for(int i=1;i<a;i++){
		scanf("%s",in[i]);
	}
	for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		if(i<j)in[i][j]='0'+('1'-in[j][i]);
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			if(in[i][j]=='1'){
				g[0][i][j]=1;
			}
		}
	}
	for(int i=0;i<a;i++){
		dp[0][i][i]=dp[1][i][i]=1;
	}
	for(int I=1;I<a;I++){
		for(int i=0;i+I<a;i++){
			if((g[0][i]&dp[1][i+1]&dp[0][i+I]).count())dp[0][i+I][i]=1;
			if((g[0][i+I]&dp[1][i]&dp[0][i+I-1]).count())dp[1][i][i+I]=1;
		//	if(dp[0][i][i+I])printf("%d %d %d\n",0,i,i+I);
		//	if(dp[1][i+I][i])printf("%d %d %d\n",1,i+I,i);
		//	printf("%d %d %d\n",g[0][i][1],dp[1][1][1],dp[0][2][1]);
		}
	}

	int ret=(dp[1][0]&dp[0][a-1]).count();
	printf("%d\n",ret);
}

Measured memory_bytes: 5888
import math
a, b, h, m = map(int, input().split())

x = h * 30.0 + 0.5 * m - 6.0 * m
theta = min(x, 360.0 - x)
theta = math.radians(theta)

ans = a ** 2 + b ** 2 - 2 * a * b * math.cos(theta)
print(ans ** 0.5)

Measured memory_bytes: 9504
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	int pn = 0;
	if (*ci == '-') {
		pn = 1;
		ci++;
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	if (pn) tmp = -tmp;
	return tmp;
}

ll A[200001];
void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	ll tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	rep1(i, N) {
		A[i] = getint() + A[i - 1];
	}

	pakuri_sort(N + 1, A);

	ll kotae = 0;
	int kazu = 1;
	rep(i, N) {
		if (A[i + 1] != A[i]) kazu = 1;
		else kotae += kazu++;
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 4828
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_N=2e5+3;


const unsigned long long B=1e12+7;


int main(){
    string S;cin>>S;
    if(S[2]==S[3]&&S[4]==S[5])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int A[100000];
int n;

int par(int p,int r){
  int x,i,j,t;
  i=p-1;
  x=A[r];
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;

  return i+1;
}

int main(){
  int i,x,q;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  q=par(0,n-1);
  for(i=0;i<n;i++){
    x=i;
    if(i=x)printf(" ");
    if(i==q)printf("[");
    printf("%d",A[i]);
    if(i==q)printf("]");
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 988
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const int N=1000010,P=924844033;

int n,cnt,G[N],a[N],A[N],B[N];
struct edge{
  int t,nx;
}E[N<<1];

inline void addedge(int x,int y){
  E[++cnt].t=y; E[cnt].nx=G[x]; G[x]=cnt;
  E[++cnt].t=x; E[cnt].nx=G[y]; G[y]=cnt;
}

int dfs(int x,int f){
  int ret=1;
  for(int i=G[x];i;i=E[i].nx){
    if(E[i].t==f) continue;
    int cur=dfs(E[i].t,x);
    a[cur]++; ret+=cur;
  }
  a[n-ret]++;
  return ret;
}

int w[2][N],rev[N],L,m,fac[N],inv[N];

inline int Pow(int x,int y){
  int ret=1;
  for(;y;y>>=1,x=1LL*x*x%P) if(y&1) ret=1LL*ret*x%P;
  return ret;
}

inline void Pre(){
  int g=Pow(5,(P-1)/m);
  w[0][0]=w[1][0]=1;
  for(int i=1;i<m;i++) w[1][i]=1LL*w[1][i-1]*g%P;
  for(int i=1;i<m;i++) w[0][i]=w[1][m-i];

  fac[0]=1; for(int i=1;i<m;i++) fac[i]=1LL*fac[i-1]*i%P;
  inv[1]=1; for(int i=2;i<m;i++) inv[i]=1LL*(P-P/i)*inv[P%i]%P;
  inv[0]=1; for(int i=1;i<m;i++) inv[i]=1LL*inv[i]*inv[i-1]%P;
}

inline void NTT(int *a,int m,int r){
  for(int i=1;i<m;i++) if(rev[i]>i) swap(a[i],a[rev[i]]);
  for(int i=1;i<m;i<<=1)
    for(int j=0;j<m;j+=i<<1)
      for(int k=0;k<i;k++){
	int x=a[j+k],y=1LL*w[r][m/(i<<1)*k]*a[j+k+i]%P;
	a[j+k]=(x+y)%P; a[j+k+i]=(x+P-y)%P;
      }
  if(!r) for(int i=0,inv=Pow(m,P-2);i<m;i++) a[i]=1LL*a[i]*inv%P;
}

inline int C(int x,int y){
  return 1LL*fac[x]*inv[y]%P*inv[x-y]%P;
}

int main(){
  scanf("%d",&n);
  for(int i=1,x,y;i<n;i++)
    scanf("%d%d",&x,&y),addedge(x,y);
  dfs(1,0);
  for(m=1;m<=n;m<<=1,L++); m<<=1; Pre();
  for(int i=1;i<m;i++) rev[i]=(rev[i>>1]>>1)|((i&1)<<L);
  for(int i=1;i<=n;i++) A[i]=1LL*a[i]*fac[i]%P,B[m-i]=inv[i]; B[0]=1;
  NTT(A,m,1); NTT(B,m,1);
  for(int i=0;i<m;i++) A[i]=1LL*A[i]*B[i]%P;
  NTT(A,m,0);
  for(int i=1;i<=n;i++){
    int cur=1LL*n*C(n,i)%P;
    cur=(cur-1LL*inv[i]*A[i])%P;
    printf("%d\n",(cur+P)%P);
  }
  return 0;
}


Measured memory_bytes: 49024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
bool CAN=true;
using namespace std;

int main(){
  ll N,X;
  cin>>N>>X;
  
  if(X==1 || X==2*N-1) CONo;
  else{
    COYe;
    for(ll i=1; i<=2*N-1; ++i){
      ll ans=i+X-N;
      if(ans<=0) ans+=2*N-1;
      if(ans>=2*N) ans-=2*N-1;
      cout<<ans<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1536
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<cmath>
#include<iomanip>
#include<iostream>
using namespace std;

int main() {
	string s;
	cin >> s;
	int t;
	t = s[6] - '0';
	if (s[5] == '1')
		cout << "TBD" << endl;
	else if (t > 4)
		cout << "TBD" << endl;
	else
		cout << "Heisei" << endl;
}





Measured memory_bytes: 760
#include<bits/stdc++.h>
#define ll long long int
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define rep(i,a,n)   for(int i=a;i<n;i++)
#define pb           push_back
#define ff           first
#define ss           second
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define Pi           2*acos(0.0)
#define pii          pair<int,int>
#define pll          pair<ll,ll>
#define mem(a,b)     memset(a, b, sizeof(a))
#define fill_(a,b)   fill(a,a+n,b);
using namespace std;

ll expo(ll a,ll b,ll m = mod){
	a%=mod;
	ll res = 1;
	while(b){
		if(b&1)
			res = (res*a)%m;
		a = (a*a)%m;
		b>>=1;
	}
	return res;
}
ll gcd(ll a,ll b){
	while(b>0){
		ll r = a%b;
		a = b; b = r;
	}
	return a;
}
int main()
{
	 
   boost
   #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	int t=1;
// 	cin>>t;
	while(t--)
	{
	    int n,K;
	    cin>>n>>K;
	    int A[n];
	    rep(i,0,n){
	        cin>>A[i];
	    }
	    bool dp[K+1];
	    mem(dp,false);
	    for(int i=0;i<n;i++){
	        dp[A[i]]=true;
	    }
	    for(int k=1;k<=K;k++){
	        if(dp[k]) continue;
	        for(int i=0;i<n;i++){
	            if(k>=A[i] && !dp[k-A[i]]){
	                dp[k] = true;
	                break;
	            }
	        }
	    }
	    if(dp[K])
	    cout<<"First\n";
	    else cout<<"Second\n";
	}
    return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 55;
int n, m, vis[MX][MX], match[MX * MX], res, bs[MX * MX];
vi adj[MX * MX];
char a[MX][MX];

int num (int i, int j) {
	return i * m + j;
}

bool valid (int i, int j) {
	return i < n && j < m && a[i][j] != '#' && !vis[i][j];
}

bool kuhn (int u) {
	if (bs[u]) return 0;

	bs[u] = 1;

	for (int v : adj[u])
		if (match[v] == -1) {
			match[v] = u;
			return 1;
		}

	for (int v : adj[u])
		if (kuhn(match[v])) {
			match[v] = u;
			return 1;
		}

	return 0;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> m;
	forn (i, n) cin >> a[i];

	forn (i, n) forn (j, m) if (a[i][j] == 'o') {
		ll act = num(i, j);
		res -= i + j;

		memset(vis, 0, sizeof(vis));
		queue<ii> q;

		vis[i][j] = 1;
		q.emplace(i, j);

		while (q.size()) {
			int i = q.front().fi;
			int j = q.front().se;

			q.pop();

			adj[num(i, j)].pb(act); 

			if (valid(i + 1, j)) {
				vis[i + 1][j] = 1;
				q.emplace(i + 1, j);
			}

			if (valid(i, j + 1)) {
				vis[i][j + 1] = 1;
				q.emplace(i, j + 1);
			}
		}
	}

	memset(match, -1, sizeof(match));

	for (int d = n + m; d >= 0; d--)
		forn (i, n) {
			int j = d - i;

			if (0 <= j && j < m) {
				memset(bs, 0, sizeof(bs));

				if (kuhn(num(i, j)))
					res += d;
			}
		}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 4092
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  int array[105];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>array[i];
  }
  
  int cnt=0;
  for(int i=0;i<n-2;i++){
    int a=array[i];
    for(int j=i+1;j<n-1;j++){
      int b=array[j];
      if(a==b)continue;
      for(int k=j+1;k<n;k++){
	int c=array[k];
	if(a==c||b==c)continue;
	if(a+b+c-2*max(a,max(b,c))>0){
	  cnt++;
	}
      }
    }
  }
  
  cout<<cnt<<endl;
  return(0);
}


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

using namespace std;

const int N = 1234;

int a[N][N];
bool alive[N];
int cnt[N], ptr[N];

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", a[i] + j);
      a[i][j]--;
    }
  }
  int low = 1, high = n;
  while (low < high) {
    int mid = (low + high) >> 1;
    for (int i = 0; i < m; i++) {
      alive[i] = true;
      cnt[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      cnt[a[i][0]]++;
      ptr[i] = 0;
    }
    bool found = false;
    for (int it = 0; it < m; it++) {
      int id = -1;
      for (int j = 0; j < m; j++) {
        if (cnt[j] > mid) {
          id = j;
          break;
        }
      }
      if (id == -1) {
        found = true;
        break;
      }
      if (it == m - 1) {
        break;
      }
      alive[id] = false;
      for (int i = 0; i < n; i++) {
        cnt[a[i][ptr[i]]]--;
        while (!alive[a[i][ptr[i]]]) {
          ptr[i]++;
        }
        cnt[a[i][ptr[i]]]++;
      }
    }
    if (!found) {
      low = mid + 1;
    } else {
      high = mid;
    }
  }
  printf("%d\n", low);
  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,D;
  cin>>N>>D;
  vector<vector<int>> A(N,vector<int>(D));
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin>>A[i][j];
    }
  }
  int ans=0;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){ 
      int res=0;
      for(int d=0;d<D;d++){
        int tmp=abs(A[i][d]-A[j][d]);
        res+=tmp*tmp;
      }
      for(int r=1;r<=res;r++){
        if(r*r==res){
          ans++;
        }
      }
      
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<c-(d-b)<<" "<<d+(c-a)<<" "<<a-(d-b)<<" "<<b+(c-a)<<endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long 
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
	reus;
	int n,k,d,x,i,c=0;
	cin>>n>>k;
	int a[n+1]={0};
	while(k--)
	{
		cin>>d;
		while(d--)
		{
			cin>>x;
			a[x]++;
		}
	}
	for(i=1;i<=n;i++)
	{
		if(a[i]==0)
		{
			c++;
		}
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 3644
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

void solve() {
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        ll a, b, x;
        cin >> a >> b >> x;
        cout << b / x + 1 - (a == 0 ? 0 : (a - 1) / x + 1) << endl;

        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(0, min(b, d) - max(a, c));
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int main(){
    ll a[4];
    for(int i=0;i<4;i++) cin>>a[i];
    a[0]*=4;a[1]*=2;
    ll n;cin>>n;
    ll ans=min(*min_element(a,a+3)*n,a[3]*(n/2)+*min_element(a,a+3)*(n%2));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int a[5],i,j,temp;

  scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4]);

  for(i=4;i>0;i--){
    for(j=0;j<i;j++){
      if(a[j]<a[j+1]){
      temp=a[j];
      a[j]=a[j+1];
      a[j+1]=temp;
      }
    }
  }

  printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);

  return 0;

}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

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

    int n;cin>>n;
    vector<string> ans;
    
    if(n==1){
        cout<<"1"<<endl;
        cout<<"0"<<endl;
        return 0;
    }
    if(n==2){
        cout<<2<<endl;
        cout<<"0\n11\n";
        return 0;
    }

    for(int len=n;len>=2;len--){
        string s(len,'1');
        s[0]='0';s[len-1]='0';
        ans.push_back(s);
    }
    cout<<ans.size()<<endl;
    for(auto x: ans) cout<<x<<endl;
    return 0;
}



Measured memory_bytes: 3264
#include<bits/stdc++.h>
#define LL long long
#define MAXN 1000005
#define INF (1<<25)
#define P int(1e9+7)
using namespace std;

int N,K,M;
int NN = 1e6;

LL fac[MAXN], ifac[MAXN];

LL qpow(LL x, int n){
	LL res = 1;
	while(n){
		if(n & 1) res = res * x % P;
		x = x * x % P;
		n /= 2;
	}
	return res;
}

LL comb(int n, int k){
	return fac[n]*ifac[n-k]%P*ifac[k]%P;
}

void init(){
	fac[0] = ifac[0] = 1;
	for(int i=1;i<=NN;i++){
		fac[i] = fac[i-1] * i % P;
		ifac[i] = qpow(fac[i], P-2);
	}
}

int main(){
	
	cin>>N>>M>>K;
	if(M > K) swap(M,K);
	
	init();
	// M < K
	
	LL ans = 0;
	LL n = 1;
	for(int i=0;i<=M+K;i++){
		if(i==0) n = 1;
		else if(i<=M) n = n*2%P;
		else if(i<=K) n = (n*2%P - comb(i-1,M) + P)%P;
		else n = (n*2%P - comb(i-1,i-1-K) - comb(i-1,M) + 2*P)%P;
		ans = (ans + comb(N-1+i,N-1)*qpow(3,M+K-i)%P * n % P) % P;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define for_tests(t, tt) int t; scanf("%d", &t); for(int tt = 1; tt <= t; tt++)
#ifndef ONLINE_JUDGE
#define debug(args...) fprintf(stderr,args)
#else
#define debug(args...)
#endif //ONLINE_JUDGE
template<typename T> inline T abs(T t) { return t < 0? -t : t; }
const ll modn = 998244353;
inline ll mod(ll x) { return x % modn; }
#define IOS() ios::sync_with_stdio(0),cin.tie(0)

const int MAXN = 212345;

int n, m, k;
struct arv{
    ll s, lz;
} tree[MAXN*4];
ll pot[MAXN]; 

ll join(arv a, int sza, arv b, int szb){
    return mod(mod(a.s*pot[szb]) + b.s);
}

void build(int idx, int i, int j){
    tree[idx].lz = 0;
    if(i == j){
        tree[idx].s = 1;
        return ;
    }
    int m = (i+j)/2;
    build(idx*2, i, m);
    build(idx*2+1, m+1, j);
    tree[idx].s = join(tree[idx*2], m-i+1, tree[idx*2+1], j-m);
}

ll som[10][MAXN];

void unlaze(int idx, int i, int j){
    if(tree[idx].lz){
        int d = tree[idx].lz; 
        tree[idx].lz = 0;
        if(i != j){
            int m = (i+j)/2;
            tree[idx*2].lz = d;
            tree[idx*2].s = som[d][m-i+1];
            tree[idx*2+1].lz = d;
            tree[idx*2+1].s = som[d][j-m];
        }
    }
}

void upd(int idx, int i, int j, int l, int r, int d){
    if(i > r || j < l) return;
    unlaze(idx, i, j);
    if(i >= l && j <= r){
        tree[idx].lz = d;
        tree[idx].s = som[d][j -i +1];
        return ;
    }
    int m = (i + j)/2;
    upd(idx*2, i, m, l, r, d);
    upd(idx*2+1, m+1, j, l, r, d);
    tree[idx].s = join(tree[idx*2], m-i+1, tree[idx*2+1], j-m);
}

int main (){
	scanf("%d%d", &n, &m);
    pot[0] = 1;
    for(int a=1;a<=n;a++)
        pot[a] = mod(pot[a-1]*10);
    for(int d=1;d<=9;d++){
        som[d][0] = 0;
        for(int a=1;a<=n;a++){
            som[d][a] = mod(som[d][a-1]*10 + d);
        }
    }
    build(1, 0, n-1);
	for(int a=0;a<m;a++){
        int i, j, k;
        scanf("%d%d%d", &i, &j, &k);
        i--;j--;
        upd(1, 0, n-1, i, j, k);
        printf("%lld\n", tree[1].s);
	}
}



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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> robots(n);
    for (int i = 0; i < n; i++) {
        int x, l;
        cin >> x >> l;
        robots[i] = make_pair(x + l, x - l);
    }
    sort(robots.begin(), robots.end());
    int ans = 0;
    int cur = -1e9;
    auto it = robots.begin();
    while (it != robots.end()) {
        if (cur <= it->second) {
            ans++;
            cur = it->first;
        }
        it++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#a,b=map(int,input().split())
#p_3,p_4=map(int,input().split())
n=int(input())
#g=input()
#recipe=[list(input().split())for _ in range(n)]
#m=int(input())
#have=[list(input().split())for _ in range(m)]
#s=[list(input())for _ in range(n)]
#h=list(map(int,input().split()))
v=list(map(int,input().split()))
#c=list(map(float,input().split()))
#n=int(input())
#s=[list(map(int,input().split()))for _ in range(n)]
#s=[list(input().split())for _ in range(n)]
#s=[input()for _ in range(n)]
v.sort()
ans=v[0]
for i in range(1,n):
    ans=(ans+v[i])/2
print(ans)

Measured memory_bytes: 2940
import numpy as np

N, M=map(int, input().split())

L=1
R=N

for i in range(M):
  temp=list(map(int, input().split()))
  
  if L<temp[0]:
    L=temp[0]
    
  if R>temp[1]:
    R=temp[1]
    
temp=int(R-L+1)
if temp>0:
  print(temp)
else:
  print(0)

Measured memory_bytes: 12504
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = inf + 7;
const int N = (int)2e5 + 5;
void solve(){
	string a,b,c;
	int x,y;
	cin>>a>>b>>x>>y>>c;
	if(c==a)--x;
	if(c==b)--y;
	cout<<x<<" "<<y<<"\n";
}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int n=s.size();
  string a=s.substr(0,(n-1)/2),b=s.substr((n+1)/2,(n-1)/2);
  rep(i,s.size() ){
    if(s[i]!=s[s.size()-1-i]){cout<<"No"<<endl;return 0;}
  }
  rep(i,a.size() ){
    if(a[i]!=a[a.size()-1-i]){cout<<"No"<<endl;return 0;}
  }
  rep(i,b.size() ){
    if(b[i]!=b[b.size()-1-i]){cout<<"No"<<endl;return 0;}
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256