akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve();
void precalc();
clock_t start;
//int timer = 1;

int testNumber = 1;

bool todo = true;

int main() {
#ifdef AIM
    freopen("/home/alexandero/ClionProjects/ACM/input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    start = clock();
    int t = 1;
    cout.sync_with_stdio(0);
    cin.tie(0);
    precalc();
    cout.precision(10);
    cout << fixed;
    //cin >> t;
    int testNum = 1;
    while (t--) {
        //cerr << testNum << endl;
        //cout << "Case #" << testNum++ << ": ";
        solve();
        ++testNumber;
        //++timer;
    }

#ifdef AIM
    cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif

    return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
    if (!w)
        return 1 % mod;
    if (w & 1)
        return q * 1LL * binpow(q, w - 1, mod) % mod;
    return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
    while (w) {
        q %= w;
        swap(q, w);
    }
    return q;
}
template<typename T>
T lcm(T q, T w) {
    return q / gcd(q, w) * w;
}

void precalc() {

}

#define int li

//const int mod = 1000000007;

bool more(int mn, int mins, int mx, int maxes, int n) {
    for (int i = 0; i < mins; ++i) {
        if (n < mn) {
            return true;
        }
        n = (n - 1) / mn + 1;
    }
    for (int i = 0; i < maxes; ++i) {
        if (n < mx) {
            return true;
        }
        n = (n - 1) / mx + 1;
    }
    return n <= 1;
}

void solve() {
    int n, A;
    cin >> n >> A;
    int res = n;
    for (int x = 2; x <= 60; ++x) {
        int L = x - 1, R = 1e9;
        while (L + 1 < R) {
            int M = (L + R) / 2;
            int min_val = M / x;
            int max_val = min_val + 1;
            int maxes = M - min_val * x;
            int mins = x - maxes;
            if (more(min_val, mins, max_val, maxes, n)) {
                R = M;
            }
            else {
                L = M;
            }
            //cout << x << ' ' << L << ' ' << R << endl;
        }
        res = min(res, R + (x - 1) * A);
    }

    cout << res << "\n";
}


















































Measured memory_bytes: 384
import itertools
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def op(n):
    return '+' if n == 0 else '-'

a, b, c, d = list(readline().decode().rstrip())

for l in list(itertools.product([0, 1], repeat=3)):
    s = str(a + op(l[0]) + b + op(l[1]) + c + op(l[2]) + d)
    if eval(s) == 7:
        print(s+'=7')
        exit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n; cin >> n;
    vector<long long> vec(n);
    for(long long i = 0; i < n; i ++){
        cin >> vec[i];
    }
    ll count = 0;
    rep(i, n){
        ll minj = i;
        for(ll j = i; j < n; j++){
            if(vec[j] < vec[minj]){
                minj = j;
            }
        }
        swap(vec[i], vec[minj]);
        if(i != minj){
            count ++;
        }
    }
    rep(i,n){
        cout << vec[i];
        (i != n-1) ? cout << " " : cout << endl;
    }
    cout << count << endl;

}


Measured memory_bytes: 3092
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

long long int factr(int n){
	if(n==1) return 1;
	return (long long int)n*factr(n-1);
}

int main(){
	int n;
	cin >> n;
	cout << factr(n) << endl;
	return 0; 
}

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

int N, Y;
int main() {
    std::cin >> N >> Y;
    for(int i=0; i<=N; ++i) {
        for(int j=0; i+j<=N; ++j) {
            int k = std::max(0, N-i-j);
            if((i+j+k) == N && (10000*i + 5000*j + 1000*k) == Y) {
                std::cout << i << " " << j << " " << k << std::endl;
                return 0;
            }
        }
    }
    std::cout << "-1 -1 -1" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

   int n, q, m, i, left, right, mid;

   m = 0;

   scanf("%d", &n);

   int S[n];

   for(i = 0; i < n; i++) {
      scanf("%d", &S[i]);
   }

   scanf("%d", &q);

   int T[q];

   for(i = 0; i < q; i++) {
      scanf("%d", &T[i]);
   }


   for(i = 0; i < q; i++) {
   left = 0;
   right = n;
   while(left < right){
        mid = (left + right) / 2;
        if (S[mid] == T[i]){
            m++;
            break;
        } else if (T[i] < S[mid]){
            right = mid;
        } else {
            left = mid + 1;
        }
   }
   }

   printf("%d\n", m);

   return 0;
}


Measured memory_bytes: 2364
#define _DEBUG

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

using ll = long long;

const string YES = "yes";
const string NO = "no";

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size());
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

void solve(std::string S) {
  bool result;

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

  result = true;
  char p;
  for (char c : S) {
    if (p == c) {
      result = false;
      break;
    }
    p = c;
  }

  if (result) {
    cout << YES << endl;
  } else {
    cout << NO << endl;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? (a=b,1) : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    int a, b, c;
    cin >>a >> b >> c;

    c -= a - b;

    cout << max(0, c) << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define debug(x) cerr<<#x<<" "<<x<<endl;
#define f(i,n) for(ll i=0; i<n; i++)
#define f1(i,n) for(ll i=1; i<=n; i++)
#define fr(i,n) for(ll i=n-1; i>=0; i--)
#define f1r(i,n) for(ll i=n; i>0; i--)
#define mst(arr,val) memset(arr,val,sizeof(arr))
#define all(x) x.begin(),x.end()

typedef long long int ll;
typedef pair<ll,ll> pii;
ll M=1e9+7;
ll M2=998244353;
void show(vector<ll> v)
{
    for(int i=0; i<v.size(); i++)
        cout<<v[i]<<" ";
    cout<<"\n";
}
void showrev(vector<ll> v)
{
    for(int i=0; i<v.size(); i++)
        cout<<v[v.size()-i-1]<<" ";
    cout<<"\n";
}
void showarr(ll arr[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
}
void showpv(vector<pair<ll,ll> > v)
{
    f(i,v.size())
        cout<<"("<<v[i].ff<<","<<v[i].ss<<")"<<" ";
    cout<<"\n";
}
void showmap(map<ll,ll> m)
{
    for(auto i:m)
        cout<<" ("<<i.ff<<","<<i.ss<<") ";
    cout<<"\n";
}
int main()
{
    IOS
    ll T = 1,Q=1;
    //cin>>T;

    while(T--)
    {
        ll n;   cin>>n;
        ll a[n+1];
        f(i,n)
            cin>>a[i+1];
        ll dp[n+1][n+1];    mst(dp,0);
        f1(i,n)
            dp[i][i] = a[i];
        f1(len,n-1)
        {
            for(ll i=1; i+len<=n; i++)
            {
                ll j=i+len;
                dp[i][j] = max(a[j]-dp[i][j-1],a[i]-dp[i+1][j]);
            }
        }
        cout<<dp[1][n];
    }
    return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Tenki | diff Tenki.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Tenki.cpp && ./a.out

/*
 
 9/1/2019
 
 5:00-
 
 */

string S,T;

void solve() {
  int res=0;
  REP(i,3) res+=(S[i]==T[i]);
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>S>>T;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
N=int(input());t=[0]*(N+1);x=[0]*(N+1);y=[0]*(N+1);flag=1
for i in range(N):t[i+1],x[i+1],y[i+1]=map(int,input().split())
for i in range(N):
    dl=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    dt=t[i+1]-t[i]
    if dl>dt or (dl-dt)%2 == 1:
        flag = 0
        break
print("Yes" if flag else "No")


Measured memory_bytes: 11636
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
 
int main()
{
    int n, x = 0, a1, a2, a3, a4, a5, a6, a7, a8;
    std::cin >> n;
    
    x += n / 100000000;
    a1 = n / 100000000;
    x += n / 10000000 - a1 * 10;
    a2 = n / 10000000 - a1 * 10;
    x += n / 1000000 - a1 * 100 - a2 * 10;
    a3 = n / 1000000 - a1 * 100 - a2 * 10;
    x += n / 100000 - a1 * 1000 - a2 * 100 - a3 * 10;
    a4 = n / 100000 - a1 * 1000 - a2 * 100 - a3 * 10;
    x += n / 10000 - a1 * 10000 - a2 * 1000 - a3 * 100 - a4 * 10;
    a5 = n / 10000 - a1 * 10000 - a2 * 1000 - a3 * 100 - a4 * 10;
    x += n / 1000 - a1 * 100000 - a2 * 10000 - a3 * 1000 - a4 * 100 - a5 * 10;
    a6 = n / 1000 - a1 * 100000 - a2 * 10000 - a3 * 1000 - a4 * 100 - a5 * 10;
    x += n / 100 - a1 * 1000000 - a2 * 100000 - a3 * 10000 - a4 * 1000 - a5 * 100 - a6 * 10;
    a7 = n / 100 - a1 * 1000000 - a2 * 100000 - a3 * 10000 - a4 * 1000 - a5 * 100 - a6 * 10;
    x += n / 10 - a1 * 10000000 - a2 * 1000000 - a3 * 100000 - a4 * 10000 - a5 * 1000 - a6 * 100 - a7 * 10;
    a8 = n / 10 - a1 * 10000000 - a2 * 1000000 - a3 * 100000 - a4 * 10000 - a5 * 1000 - a6 * 100 - a7 * 10;
    x += n - a1 * 100000000 - a2 * 10000000 - a3 * 1000000 - a4 * 100000 - a5 * 10000 - a6 * 1000 - a7 * 100 - a8 * 10;

    if(n % x == 0){
        std::cout << "Yes";

        return 0;
    }
    std::cout << "No";

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;

int main(){
  string s,t;
  cin >> s >> t;
  rep(i,3){
    if(s[i]!=t[2-i]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

ll cnt[200010];
vector<vi> e;
void rec(int c, int p){
	for(int i : e[c]) if(i != p){
		cnt[i] += cnt[c];
		rec(i, c);
	}
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, q; cin >> n >> q;
	e.resize(n);
	rep(i, n - 1){
		int a, b; cin >> a >> b; a--; b--;
		e[a].pb(b);
		e[b].pb(a);
	}
	while(q--){
		int p, x; cin >> p >> x;
		cnt[p - 1] += x;
	}
	rec(0, 0);
	rep(i, n) cout << cnt[i] << (i==n-1?"\n":" ");
	
	return 0;
}

Measured memory_bytes: 24320
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	vector<ll>count(n+1,0);
	repp(i, 1, n + 1) {
		++count[i%k];	//kで割ったときの余りの数をそれぞれ数える
	}
	repp(i, 1, n + 1) {
		int a = i % k;
		int b= (k-a)%k ;//a+bがkの倍数の時、aの余りとbの余りの和がkになる
		int c = (k -a)%k;
		//ここまででa+b,c+aがkの倍数は満たされている。
		if ((b + c) % k == 0)ans += count[b] * count[c];
	}
	cout << ans << endl; return 0;
}

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

using namespace std;
using Graph = vector<vector<int>>;

int main(void)
{
    int N;
    cin >> N;
    Graph G(N+1);
    int a;

    for(int i = 2;i <= N; i++) {
        cin >> a;
        G[a].push_back(1);
    }

    for(int i = 1; i <= N; i ++) {
        cout << G[i].size() << endl;
    }
    return 0;
}

Measured memory_bytes: 14304
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

######################################################

N,X=mint()
ans=0
size=[0]*51
size[0]=(1,1)
for i in range(1,51):
    size[i]=(2*size[i-1][0]+3, 2*size[i-1][1]+1)

def rec(L):
    global X,ans
    if X==0:
        return
    if L==0:
        X-=1
        ans+=1
    else:
        X-=1
        if X<size[L-1][0]:
            rec(L-1)
        else:
            X-=size[L-1][0]
            ans+=size[L-1][1]
        if X==0:
            return
        X-=1
        ans+=1
        if X<size[L-1][0]:
            rec(L-1)
        else:
            X-=size[L-1][0]
            ans+=size[L-1][1]
        if X==0:
            return
        X-=1
    
rec(N)
print(ans)

Measured memory_bytes: 69928
#include<stdio.h>

int main()
{
int N, i, a, b, c, max;

scanf("%d", &N);

for(i=0; i<N; i++){
scanf("%d %d %d", &a, &b, &c);

if(a<=b && b<=c){
max = c;
if(c*c==a*a+b*b){
puts("YES");
}else{
puts("NO");
}
}
else if(a<=c && c<=b){
max = b;
if(b*b==a*a+c*c){
puts("YES");
}else{
puts("NO");
}
}
else if(b<=c && c<=a){
max = a;
if(a*a==b*b+c*c){
puts("YES");
}else{
puts("NO");
}
}
else if(b<=a && a<=c){
max = c;
if(c*c==a*a+b*b){
puts("YES");
}else{
puts("NO");
}
}
else if(c<=a && a<=b){
max = b;
if(b*b==a*a+c*c){
puts("YES");
}else{
puts("NO");
}
}
else if(c<=b && b<=a){
max = a;
if(a*a==b*b+c*c){
puts("YES");
}else{
puts("NO");
}
}

}

return 0;
}

Measured memory_bytes: 1748
#include<iostream>
using namespace std;
int main()
{
   int a,b,sum;
   char c;
   cin>>a>>c>>b;
   if(c=='+')
   {
       sum=a+b;
   }
    else if(c=='-')
    {
        sum=a-b;
    }

   cout<<sum<<endl;



return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;

    ll cnt = s.size();
    ll ans = 0;

    for(ll i = 0; i < cnt; i++)
    {
        if (s[i] == '+') {
            ans++;
        }
        else
        {
            ans--;
        }
    }

    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

ll n,m;
vector<P> vp;

int main(){
	cin >> n >> m;
	rep(i,m){
		ll a, b;
		cin >> a >> b;
		vp.push_back(P(b,a));
	}
	sort(ALL(vp));
	ll now = vp[0].first;
	ll ans = 1;
	rep(i,m){
		int s = vp[i].second;
		int e = vp[i].first;
		if(s < now)continue;
		ans++;
		now = e;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    ll n,ans = 0;
    cin >> n;
    vector<ll> a(n * 3);
    rep0(i, n * 3)cin >> a[i];
    sort(all(a),greater<>());
    rep1(i, n * 2){
        ans += a[i];
        ++i;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    ll a,b,c; cin >> a >> b >> c;
    if((a*b*c) %2 == 0) cout << 0 << endl;
    else cout << min(a*b, min(b*c, c*a)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;

int main()
{
  int n, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++)
  {
    if (i % 2 == 0)
      continue;
    int c = 0;
    for (int j = 1; j <= i; j++)
    {
      if (i % j == 0)
        c++;
    }
    if(c == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

#include <algorithm>
struct Product {long w, v;};

int main(){
  int N, W;
  
  cin >> N >> W;
  vector<Product> p(N);
  for (Product& i : p){
    int w, v;
    cin >> w >> v;
    i.w = w;
    i.v = v;
  }

  vector<vector<long> > table(N+1, vector<long>(W+1,0));
  for (int i=0; i<N+1; i++){
    table[i][0] = 0;
  }
  for (int i=0; i<N;i++){
    for (int j=0; j<=W; j++){
      if (j-p[i].w >=0){
	table[i+1][j] = max(table[i][j], table[i][j-p[i].w] +p[i].v );
      }
      else {
	table[i+1][j] = table[i][j];
      }
    }
  }

  cout << table[N][W] << endl;
  return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int N,A,B,C,V; 
vector<int> L;

int dfs(int depth, int a, int b, int c){
    if(depth==N){
        if(a==0 || b==0 || c==0) return INF;
        return abs(A - a) + abs(B - b) + abs(C - c) - 30;
    }

    int tmp0=dfs(depth+1,a,b,c);
    int tmp1=dfs(depth+1,a+L[depth],b,c)+10;
    int tmp2=dfs(depth+1,a,b+L[depth],c)+10;
    int tmp3=dfs(depth+1,a,b,c+L[depth])+10;

    return min({tmp0,tmp1,tmp2,tmp3});
}

int main() {
    cin >> N >> A >> B >> C;
    L.resize(N);
    rep(i,N) cin >> L[i];

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

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 100000 + 10;
long long x2, y2, x3, y3;
void san(long long &a, long long &b, long long cheng)
{
	a = 1, b = 1;
	long long kf = sqrt(cheng + 0.5);
	for (long long i = 2; i <= kf; i++)
	{
		if (cheng % i == 0)
		{
			a *= i;
			cheng  /= i;
			if (a >= cheng)	break;
		}
	}
	b = cheng;
}
void Solve()
{
	long long S;	scanf("%lld", &S);
	long long tmp = sqrt(S + 0.5);
	if (tmp * tmp == S)
	{
		x3 = y2 = tmp;
		x2 = y3 = 0;
		printf("%lld %lld %lld %lld %lld %lld\n", 0, 0, x2, y2, x3, y3);
	}
	else
	{
		x3 = y2 = tmp + 1;
		san(x2, y3, x3 * y2 - S);
		// x2 = 1;
		// y3 = S - x3 * y2;
		printf("%lld %lld %lld %lld %lld %lld\n", 0, 0, x2, y2, x3, y3);
	}
	// if (x3 * y2 - x2 * y3 == S && x2 <= 1e9 && x3 <= 1e9 && y2 <= 1e9 && y3 <= 1e9)
	// {
	// 	printf("YES\n");
	// }
	// else printf("NO\n");
}

int main()
{
	// while (1)
	Solve();
	return 0;
}

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

using namespace std;

string pref[]={"pon","pon","hon","bon","hon","hon","pon","hon","pon","hon"};

int main(){
    int n;
    cin>>n;
    n=n%10;
    cout<<pref[n]<<"\n";
    return 0;
}

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

int main(void){
    using namespace  std;
    int N, M;
    cin >> N >> M;

    int p;
    string S;
    vector<vector<int>> ret(N, vector<int>(2, 0));
    for (int i = 0; i < M;i++){
        cin >> p >> S;
        if(ret[p-1][0] == 0){
            if(S == "AC")
                ret[p - 1][0] = 1;
            else
                ret[p - 1][1]++;
        }
    }

    long succeeded = 0, failed = 0;
    for (int i = 0; i < N;i++){
        succeeded += ret[i][0];
        failed += ret[i][0] == 0 ? 0 : ret[i][1];
    }

    cout << succeeded << " " << failed << endl;

    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 58;
const int MOD = 1000000007;
const int MAX_N = 200100;

int dp[1000010][2];
signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    string N;
    cin >> N;
    dp[0][0] = 0;
    dp[0][1] = 1;
    REP(i, N.size())
    {
        int c = N[i] - '0';
        dp[i + 1][0] = dp[i][0] + c;
        dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + 1 + c);
        dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + (10 - c));
        if (c == 9)
        {
            dp[i + 1][1] = dp[i][0] + 1;
            dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + 1 + 1);
            dp[i + 1][1] = min(dp[i + 1][1], dp[i][1]);
        }
        else
        {
            dp[i + 1][1] = dp[i][0] + (c + 1);
            dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + 1 + c + 1);
            dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + (10 - c) - 1);
        }
    }
    cout << dp[N.size()][0] << endl;

    return 0;
}

Measured memory_bytes: 17028
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;

int main(){
    int N,M;
    cin >>N>>M;
    vi X(M);
    rep(i,M) cin >>X[i];
    ll ans=0;
    if(N>=M){
        cout <<ans <<endl;
    }
    else{ 
        sort(all(X));
        vi dX(M-1);
        rep(i,M-1) dX[i]=X[i+1]-X[i];
        sort(all(dX));
        rep(i,M-N) ans += dX[i];
        cout <<ans<<endl; 
    }
}

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

#define MOD  998244353
const long long nmax = 1e7+1;

using namespace std;

int n;
long long thr[nmax], tw[nmax], fr[nmax];

long long mul(long long a, long long b)
{
    return (a * b) % MOD;
}

long long add(long long a, long long b)
{
    return (a + b) % MOD;
}

long long sub(long long a, long long b)
{
    long long o = a - b;

    while (o < 0) o += MOD;
    return o;
}

long long Pow(long long a, long long b)
{
    if (b == 1) return a;
    long long o = Pow(a, b/2);

    if (b % 2 == 1) return mul(mul(o, o), a);
    return mul(o, o);
}

long long Ckn(long long a, long long b)
{
    return mul(fr[b], Pow(mul(fr[a], fr[b-a]), MOD - 2));
}

void Input()
{
    ios_base::sync_with_stdio(0);       cin.tie(0);

//    freopen("abc.txt", "r", stdin);

    cin >> n;   thr[0] = tw[0] = fr[0] = 1;
    for (int i=1; i<=n; i++)
    {
        thr[i] = mul(thr[i-1], 3);
        tw[i] = mul(tw[i-1], 2);
        fr[i] = mul(fr[i-1], i);
    }
}

void Process()
{
    long long ans = 0;
    for (int i=n/2+1; i<=n; i++)
        ans = add(ans, mul(Ckn(i, n), tw[n-i+1]));

//    cout << Ckn(2, n) << endl;
//    cout << ans << endl;

    cout << sub(thr[n], ans);
}

int main()
{
    Input();
    Process();
    return 0;
}


Measured memory_bytes: 234624
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
int a,b;
string s,t,u;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s>>t>>a>>b;
    cin>>u;
    if (u==s){
        cout<<a-1<<' '<<b;
    }
    else {
        cout<<a<<' '<<b-1;
    }
}

Measured memory_bytes: 896
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  																						   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;	
const int mod = 1e9+7;																							   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS//////////////////////////////////////////////////////


///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int a, b;
	cin >> a >> b;
	
	if(b % a == 0){
		cout << a + b << endl;
	}
	else cout << b - a << endl;

	
	
	
	

						
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long a , b , c ;
    cin>>a>>b>>c ;
    long long ans = 0 ;
    if(c <= (a+1))
        cout<<c+b<<"\n";
    else
    {
        ans = a ;
        c -= a ;
        if(c <= b)
            cout<<ans + c+b<<"\n";
        else
            cout<<ans + b+b+1<<"\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define endl '\n'
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define line cout<<"----------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
#define bug(x) cerr << "[" << #x << "] = ["<<x<<"]"<<'\n'
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    cout<<(a+b-1)/b<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

int N;

int ans=1;

signed main()
{
    cin >> N;

    if(N<105)
    {
        cout << 0 << endl;
        return 0;
    }

    int cnt=2;

    for(int i=106;i<=N;i++)
    {
        if(i%2==0)continue;



        for(int j=3;j<=i/2;j++)
        {
            if(i%j==0)
            {
                cnt++;
            }
        }

        if(cnt==8)ans++;

        cnt=2;

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;

int N;
vector<vector<int>> G;
ll num[110], nmx[60];
bool looked[110];
vector<int> vs;
int par[110], depth[110];

void bfs(){
	for(int i=1; i<=N; ++i) looked[i]=0;
	for(int i=0; i<vs.size(); ++i){
		par[vs[i]]=depth[vs[i]]=0;
		looked[vs[i]]=1;
	}
	while(vs.size()>0){
		vector<int> nx;
		for(int i=0; i<vs.size(); ++i){
			ll cnt=0;
			for(int j=0; j<G[vs[i]].size(); ++j){
				if(!looked[G[vs[i]][j]]){
					nx.emplace_back(G[vs[i]][j]);
					depth[G[vs[i]][j]]=depth[vs[i]]+1;
					par[G[vs[i]][j]]=vs[i];
					looked[G[vs[i]][j]]=1;
					++cnt;
				}
			}
			num[vs[i]]=cnt;
		}
		vs.swap(nx);
	}
}

ll count_leaves(){
	for(int i=0; i<60; ++i) nmx[i]=1;
	for(int i=1; i<=N; ++i){
		nmx[depth[i]]=max(nmx[depth[i]], num[i]);
	}
	ll res=1;
	for(int i=0; i<60; ++i) res *= nmx[i];
	return res;
}

int main() {
	cin >> N;
	G.resize(N+1);
	for(int i=1; i<N; ++i){
		int a, b;
		cin >> a >> b;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
	}
	vs={1};
	bfs();
	int mx=1;
	for(int i=2; i<=N; ++i){
		if(depth[mx]<depth[i]) mx=i;
	}
	vs={mx};
	bfs();
	int mx2=1;
	for(int i=2; i<=N; ++i){
		if(depth[mx2]<depth[i]) mx2=i;
	}
	int cent=mx2, diam=depth[mx2];
	for(int i=0; i<diam/2; ++i) cent=par[cent];
	if(diam%2==1){
		vs={cent, par[cent]};
		bfs();
		cout << (diam+1)/2 << ' ' << count_leaves()*2 << endl;
	}else{
		vs={cent};
		bfs();
		ll ans=count_leaves();
		for(int i=0; i<G[cent].size(); ++i){
			vs={cent, G[cent][i]};
			bfs();
			ans=min(ans, count_leaves()*2);
		}
		cout << diam/2+1 << ' ' << ans << endl;
	}
	return 0;
}

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

int main()
{
 string str;

 cin>>str;
 int counter=0;

 if(str[0]=='A'){
        int index;
 if(str[str.size()-1]=='C'|| str[1]=='C'){cout<<"WA"; return 0;}

        for(int i=2;i<str.size()-1;i++){

            if(str[i]=='C') {counter++; index=i;}
        }

        if(counter>1 || counter==0){cout<<"WA"; return 0;}

 for(int i=0;i<str.size();i++){

       if(i!=0 && i!=index && !islower(str[i])) {cout<<"WA"; return 0;}

    }
    }



else {cout<<"WA"; return 0;}
cout<<"AC";


    return 0;
}

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

int main()
{
    cin>>n;
    double head[n];
    for(int i=0;i<n;i++)
    {
        cin>>head[i];
    }
    double dp[n+1][n+1];
    for(int i=0;i<=n;i++)
        for(int j=0;j<=n;j++)
            dp[i][j]=0;
    dp[1][0]=1-head[0];
    for(int i=2;i<=n;i++)
    {
        dp[i][0]=dp[i-1][0]*(1-head[i-1]);
    }
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            dp[i][j]=dp[i-1][j-1]*head[i-1]+dp[i-1][j]*(1-head[i-1]);
            //cout<<fixed<<dp[i][j]<<' ';
        }
        //cout<<'\n';
    }
    double ans=0;
    for(int i=(n+1)/2;i<=n;i++)
    {
        ans+=dp[n][i];
    }
    cout<<fixed<<setprecision(12)<<ans;
}

Measured memory_bytes: 70528
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int L = 0;
        int R = 0;
        int Lmax = 0;
        int Rmin = 100000;

        for (int i = 0; i < M; i++) {
            L = sc.nextInt();
            if (L > Lmax) {
                Lmax = L;
            }
            R = sc.nextInt();
            if (R < Rmin) {
                Rmin = R;
            }
        }
        int judge = Rmin - Lmax + 1;
        if (judge < 0) {
            judge = 0;
        }
        System.out.println(judge);
        sc.close();
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using v = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#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)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

inline ll inl() {
    ll x;
    cin >> x;
    return x;
}

inline string ins() {
    string x;
    cin >> x;
    return x;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        ll n = inl();
        ll ans = 0;
        rep(i, n) {
            ll l, r;
            cin >> l >> r;
            ans += (r - l) + 1;
        }
        cout << ans << endl;
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N;
  cin >> N;

  vll x1(N);
  vll x2(N);
  rep(i, N) {
    ll a;
    cin >> a;
    x1[i] = a;
    x2[i] = a - (i + 1);
  }

  SORT(x2);

  ll index = N / 2;
  ll b = x2[index];
  ll ans = 0;
  rep(i, N) {
    ans += abs(x1[i] - b - (i + 1));
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>
typedef long long LL;

using namespace std;



int main(void) {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int count = 1;
	LL ans = 0;
	for (int i = 0; i < n - 1; i++) {
		//cout << a[i] << " " << a[i + 1] << endl;
		if (a[i] == a[i + 1]) {
			count++;
		}
		else {
			ans += count / 2;
			count = 1;
		}
		if (i == n - 2) {
			ans += count / 2;
			count = 1;
		}
	}
	cout << ans;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

struct bomb { ll x, y; };

int main() {
  ll H, W, M; cin >> H >> W >> M;
  bomb b[M]; rep(i,M) { cin >> b[i].x >> b[i].y; b[i].x--; b[i].y--; }

  ll xb[H] = {}, yb[W] = {}; rep(i,M) { xb[b[i].x]++; yb[b[i].y]++; }
  ll mx = *max_element(xb,xb+H), my = *max_element(yb,yb+W);
  ll cx = 0; rep(i,H) cx += xb[i] == mx;
  ll cy = 0; rep(i,W) cy += yb[i] == my;
  // debug(xb,xb+H); debug(yb,yb+W);

  ll count = cx * cy;
  rep(i,M) {
    bool b1 = xb[b[i].x] == mx, b2 = yb[b[i].y] == my;
    if (b1&&b2) count--;
  }
  ll result = count ? mx + my : mx + my - 1;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 13012
#include <stdio.h>

int N;
int a[114514];

char visited[114514];

int main(void) {
	int i;
	int count = 0;
	int current = 1;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &a[i]) != 1) return 1;
	}
	for (;;) {
		if (visited[current]) {
			puts("-1");
			return 0;
		}
		if (current == 2) {
			printf("%d\n", count);
			return 0;
		}
		visited[current] = 1;
		current = a[current];
		count++;
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
int r, g, b, n;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> r >> g >> b >> n;
    ll ans = 0;
    for(int i = 0; ;i++) {
        if(i * r > n) break ;
        for(int j = 0; ;j++) {
            if(i * r + j * g > n) break ;
            int tot = n - i * r - j * g;
            if(tot % b == 0) ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, j;
	j=1;
	while(1){
	scanf("%d",&i);
	if(i==0)
	{break;
	}
	else
	{
	printf("Case %d: %d\n",j,i);
	j++;
	}
	}
	return 0;
}

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

int main() {
	int k;cin>>k;
	string s;cin>>s;
	if(s.size()<=k)cout<<s<<endl;
	else{
		string f="";
		for(int i=0;i<k;i++)f+=s[i];
		f+="...";
		cout<<f<<endl;
	}
	return 0;
}

Measured memory_bytes: 3560