akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<int> A(N), B(N);
	cat SA =0, SB =0;
	for(int i =0; i < N; i++) {
		cin >> A[i];
		SA +=A[i];
	}
	for(int i =0; i < N; i++) {
		cin >> B[i];
		SB +=B[i];
	}
	
	cat cnt =SB-SA;
	if(cnt < 0) {
		cout << "No\n";
		return 0;
	}

	cat addA =cnt, addB =cnt;
	for(int i =0; i < N; i++) {
		if((A[i]-B[i])%2 != 0) {
			B[i]++;
			addB--;
		}
		if(B[i] > A[i]) {
			int x =(B[i]-A[i])/2;
			addA -=x;
			A[i] +=x*2;
		}
		else {
			int x =A[i]-B[i];
			addB -=x;
			B[i] +=x;
		}
	}

	if(addA < 0 || addB < 0) {
		cout << "No\n";
		return 0;
	}

	if(addA*2 != addB) cout << "No\n";
	else cout << "Yes\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 384
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;
using ll = long long;

struct C {
    vector<string> v_{};
    explicit C(vector<string> v) {
        v_.reserve(v.size());
        for(auto& a : v) {
            std::sort(a.begin(), a.end());
            v_.emplace_back(a);
        }
    }
    ll resolve() {
        ll N = v_.size();
        std::sort(v_.begin(), v_.end());
//        v_.erase(std::unique(v_.begin(), v_.end()), v_.end());

        ll count{};
        string prev{};
        bool found_dup = false;
        ll count_group{};
        v_.emplace_back("999999999999999999999999999999999999");
        for(ll i=0; i < N+1; ++i) {
            if (prev == v_[i]) {
                if (found_dup) {
                    ++count_group;
                } else {
                    found_dup = true;
                    count_group = 2;
                }
            } else {
                if (found_dup) {
                    count += ( count_group > 1 ? count_group * (count_group -1) / 2 : 1);
                    count_group=0;
                    found_dup = false;
                }
            }
            prev = move(v_[i]);
        }
        return count;
    }
};

int main() {
    ll N;
    cin >> N ;
    vector<string> v{};
    for (int i=0; i < N; ++i) {
        string x;
        cin >> x;
        v.emplace_back(x);
    }
    C c{move(v)};
    cout << c.resolve() << endl;
    return 0;
}


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

int main()
{
  char a,b;
  cin >> a>>b;
  if(a=='H'&&b=='H' || a=='D'&&b=='D')
    cout << 'H' << endl;
    else if(a=='D'&&b=='H' ||  a=='H'&&b=='D')
      cout << 'D' << endl;


}


Measured memory_bytes: 256
s = input()
n = len(s)
n2 = (n-1)//2
flag = 1
for i in range(n2):
  if not((s[i] == s[n-i-1]) and (s[i] == s[n2-1-i]) and (s[i] == s[n2+i+1])):
    flag = 0
if flag == 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
vector<ll> b(51), p(51);

ll f(ll n, ll x) {
	if (x == 0) return 0;
	if (n == 0) return 1;
	if (x <= 1 + b[n-1]) return f(n - 1, x - 1);
	else return p[n-1] + 1 + f(n - 1, x - 2 - b[n-1]);
}

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

	b[0] = p[0] = 1;
	REP(i, 50) {
		p[i+1] = p[i] * 2 + 1;
		b[i+1] = b[i] * 2 + 3;
	}
	cout << f(n, x) << '\n';
    return 0;
}


Measured memory_bytes: 3548
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        long h = Long.parseLong(sc.next());

        // 主処理
        long count = 0;
        long result = 0;
        if (1 < h) {
            h = (long) Math.ceil(h / 2);
            count++;
            result += count;
            while (1 < h) {
                h = (long) Math.ceil(h / 2);
                count *= 2;
                result += count;
            }
            h = (long) Math.ceil(h / 2);
            count *= 2;
            result += count;
        } else {
            result++;
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 23764
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

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

const double pi = M_PI;
const Int MOD = 1000000007;

vector<int> a, b, c, d;

int calc_ans(int q, vector<int> &A) {
    int ret = 0;

    for (int i = 0; i < q; i++) {
        if (c[i] == (A[b[i] - 1] - A[a[i] - 1])) {
            ret += d[i];
        }
    }

    return ret;
}

void rec(int n, int m, int q, int val, vector<int> A, int &ans) {
    A.push_back(val);

    if (A.size() == n) {
        // calc ans
        ans = max(ans, calc_ans(q, A));
        return;
    } else {
        for (int i = A[A.size() - 1]; i <= m; i++) {
            rec(n, m, q, i, A, ans);
        }
    }
}

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

    int n, m, q;
    cin >> n >> m >> q;
    int aa, bb, cc, dd;
    for (int i = 0; i < q; i++) {
        cin >> aa >> bb >> cc >> dd;
        a.push_back(aa);
        b.push_back(bb);
        c.push_back(cc);
        d.push_back(dd);
    }

    int ans = 0;
    for (int i = 1; i <= m; i++) {
        vector<int> A;
        rec(n, m, q, i, A, ans);
    }

    cout << ans << endl;

    return 0;
}

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

#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define drng(i,a,b) for(int i=int(a);i>int(b);i--)
typedef long long LL;


void test_case(){
	
}
int main() {
    fastio
    LL a;
    cin>>a;
    LL x = 10000000000000;
    for(LL i = 1; i*i<=a; i++){
    	if(a%i == 0){
    		LL xn = i + (a/i);
    		x = min(x,xn);
    	}
    }
    cout<<x-2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
main(){
  long long a,b, v,w, t;
  scanf("%lld %lld %lld %lld %lld", &a,&v,&b,&w,&t);
  if(v<=w){
    printf("NO");
    return 0;
  }
  double dt = (double)fabs(a-b)/(double)(v-w);
  if(dt <= t) 
    printf("YES");
  else
    printf("NO");
  return 0;
}

Measured memory_bytes: 2152
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    string S;
    constexpr ll MOD = 1e9 + 7;
    cin >> N >> S;
    vector<ll> num(26, 1);
    for (char c : S) {
        num[c - 'a']++;
    }
    ll ans = 1;
    for (ll i = 0; i < 26; i++) {
        (ans *= num[i]) %= MOD;
    }

    cout << (ans + MOD - 1) % MOD << endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
#define ll long long int
int main() {
	ll n;
	cin>>n;
	ll ans=0;
	ll plus;
	ll x=n;
	for(int i=1;i<=x;i++)
	{
	  plus=(((n/i)*((n/i)+1))/2);
	  ans=ans+(plus*i);
	 }
	 cout<<ans<<endl;
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int P[505050];
int D[505050];
int S[505050];
int Z[505050];
int ZL[505050];
ll fact[505050];
ll mo=1000000007;

template<class V, int ME> class BIT {
public:
	V bit[1<<ME];
	V operator()(int e) {V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
	V add(int e,V v) { e++; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
};
BIT<int,20> bt;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	
	cin>>N;
	FOR(i,N) D[i]=1;
	FOR(i,N) {
		cin>>P[i];
		P[i]--;
		if(P[i]>=0) D[P[i]]--;
		else Z[i]++;
	}
	FOR(i,N) {
		S[i]=(i?S[i-1]:0)+D[i];
		ZL[i]=(i?ZL[i-1]:0)+Z[i];
	}
	fact[0]=1;
	FOR(i,505000) fact[i+1]=fact[i]*(i+1)%mo;
	
	ll T=0;
	ll TZ=0;
	FOR(i,N) if(D[i]==1) T=(T+i)%mo;
	
	int K=ZL[N-1];
	ll ret=fact[K];
	FOR(i,N) {
		ll pat;
		
		if(P[i]>=0) {
			pat = fact[K]*P[i]%mo;
			pat += (i?ZL[i-1]:0)*(mo-S[P[i]]*fact[K-1]%mo)%mo;
			pat += bt(P[i])*(mo-fact[K])%mo;
			bt.add(P[i],1);
			(TZ += S[N-1]-S[P[i]])%=mo;
		}
		else {
			pat = T*fact[K-1]%mo;
			pat += (i?ZL[i-1]:0)*(mo-1LL*K*(K-1)/2%mo*fact[K-2]%mo)%mo;
			pat += mo-TZ*fact[K-1]%mo;
		}
		
		ret += pat%mo*fact[N-1-i]%mo;
	}
	cout<<ret%mo<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 16000
N,K=map(int,input().split())
list=[0]*(N+1)
mod=10**9+7
list[1]=1
list[0]=1
for i in range(1,N):
  list[i+1]=list[i]*(i+1)%mod
def c(a,b):
    ans=list[a]*pow(list[b],mod-2,mod)*pow(list[a-b],mod-2,mod)%mod
    return ans

for i in range(1,K+1):
  if i>N-K+1:
    print(0)
  else:
    an=c(K-1,i-1)*c(N-K+1,i)%mod
    print(an)

Measured memory_bytes: 9188
// インクルード
#include <bits/stdc++.h>

// 名前空間省略
using namespace std;

// メイン関数
int main()
{
    // 標準入出力　高速化
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string w;
    cin >> w;

    vector<int> c(27,0);
    for(int i=0;i<w.length();i++){
        c[w[i]-'a']+=1;
    }
    for(int i=0;i<27;i++){
        if(c[i]%2==1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

const ll mod=1e9+7;

ll modpow(ll a,ll n){
    if(n==0) return 1;
    if(n==1) return a;
    else if(n%2) return a*modpow(a*a%mod,(n-1)/2)%mod;
    else return modpow(a*a%mod,n/2);
}

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(all(a));
    bool flag=1;
    if(n%2){
        rep(i,n){
            if(i==0){
                if(a[i]!=0) flag=0;
            }else{
                if(a[i]!=(i+1)/2*2) flag=0;
            }
        }
    }else{
        rep(i,n){
            if(a[i]!=(i+2)/2*2-1) flag=0;
        }
    }
    if(flag) cout<<modpow(2,n/2)<<endl;
    else cout<<0<<endl;
    return 0;
}

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


temp = []

for i in range(a,a+k):
    temp.append(i)
    if i== b:
        break

for i in range(b-k+1,b+1):
    if i < a:
        continue
    if i in temp:
        continue
    temp.append(i)

for i in temp:
    print(i)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main() {
	int W = 0;
	int H = 0;
	int N = 0;
	int w = 0;
	int h = 0;
	cin >> W >> H >> N;
	vector<int> x(N);
	vector<int> y(N);
	vector<int> a(N);
	rep(i, N) {
		cin >> x.at(i) >> y.at(i) >> a.at(i);
	}
	rep(i,N){
		switch (a.at(i)) {
		case 1 :
			if (x.at(i) > w) {
				w = x.at(i);
			}
			break;
		case 2 :
			if (x.at(i) < W) {
				W = x.at(i);
			}
			break;
		case 3 :
			if (y.at(i) > h) {
				h = y.at(i);
			}
			break;
		case 4 :
			if (y.at(i) < H) {
				H = y.at(i);
			}
			break;
		}

		if (W - w <= 0 || H - h <= 0) {
			cout << 0 << endl;
			break;
		}
	}
	if ((H - h) > 0 &&  (W - w) > 0) {
		cout << (H - h) * (W - w) << endl;
	}
	return 0;
}

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


int keta(ll x)
{
    int count = 0;
    while(x)
    {
        x/=10;
        count++;
    }
    return count;
}

int main()
{
    /*ABC144 B
    int x;
    cin>>x;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            if(x==i*j)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    */
    /*ABC150 B
    int n;
    string s;
    cin>>n>>s;
    int count = 0;
    for(int i=0;i<n-2;i++)
    {
        if(s[i]=='A')
        {
           if(s[i+1]=='B')
           {
               if(s[i+2]=='C')
               {
                   count++;
               }
           }
        }
    }
    cout<<count<<endl;
    */

    /*ABC136 B
    int n;
    cin>>n;
    int count = 0;
    for(int i=1;i<=n;i++)
    {
        int even=0;
        int num = i;
        while(num)
        {
            num/=10;
            even++;
        }
        if(even%2!=0)
        {
            count++;
        }
    }
    cout<<count<<endl;
    */
    /*ABC106 B
    int n;
    cin>>n;
    int count=0;
    for(int i=10;i<=n;i++)
    {
        int num = i;
        int yakusu=0;
        for(int j=1;j<=num;j++)
        {
            if(j%2==0)
            {
                continue;
            }
            if(num%j==0)
            {
                yakusu++;
            }    
        }
        if(yakusu==8)
        {
            count++;
        }
    }    
    cout<<count<<endl;
    */
    /*ABC120 B
    int a,b,k;
    cin>>a>>b>>k;
    int count=0;
    for(int i=100;i>=1;i--)
    {
        if(a%i==0 && b%i==0)
        {
           count++;
        }
        if(count==k)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    */
    /*ABC057 C
    ll n;
    cin>>n;
    int ans = keta(n);
    for(ll i=1;i*i<=n;i++)
    {
        int cur=0;
        if(n%i==0)
        {
            ll b = n/i;
            cur = max(keta(i),keta(b));
        }
        else continue;

        if(cur<ans)
        {
            ans = cur;
        }
    }

    cout<<ans<<endl;
    */

    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int ab=2*c;
    int cost = a*x+b*y;
    for(int i=0;i<=100000;i++)
    {
        int temp=0;
        temp +=i*ab+max(x-i,0)*a+max(y-i,0)*b;
        cost = min(temp,cost);
    }
    cout<<cost<<endl;
    return 0;
}

Measured memory_bytes: 3528
N = int(input())
if N <= 2:
    print(1)
else:
    xy = []
    for _ in range(N):
        xy.append(list(map(int, input().split())))
    
    xy.sort()

    max_dup = 0
    for i in range(N-1):
        curr_i = xy[i]
        for j in range(i+1, N):
            curr_j =xy[j]
            p, q = curr_j[0] - curr_i[0], curr_j[1] - curr_i[1]
            
            cnt = 0
            for n in range(N):
                if n == 0:
                    continue
                if [xy[n][0]-p, xy[n][1]-q] in xy:
                # (xy[n][0]-xy[n-1][0] == p) and (xy[n][1]-xy[n-1][1] == q):
                
                    cnt += 1
            max_dup = max(max_dup, cnt)
    print('{}'.format(N-max_dup))

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

#define LL long long
#define MOD 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define print(a, n) for(LL e=0; e<n; e++) cout<<a[e]<<" "; cout<<"\n"
#define prints(a) for(auto i: a) cout<<i<<" "; cout<<"\n"
#define read(a, n) for(LL e=0; e<n; e++) cin>>a[e]

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

	string ans = "";
	while(n){
		int r = n%26;
		n /= 26;
		if(r==0){
			n -= 1;
			r = 26;
		}

		ans += char(r+'a'-1);
	}

	reverse(ans.begin(), ans.end());
	cout<<ans<<"\n";

	exit(0);
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  ll now = 1000;
  vector<ll> dp(n, 0);
  dp[0] = 1000;
  rep(i, n-1) {
    for(int j = i+1; j < n; ++j) {
      chmax(dp[j], (dp[i]/a[i])*a[j] + dp[i]%a[i]);
    }
    chmax(dp[i+1], dp[i]);
  }
  cout << dp[n-1] << endl;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

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

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

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, l; std::cin >> n >> l;
  vector<string> vec(n); rep(i, n) std::cin >> vec[i];
  sort(rng(vec));
  rep(i, n) std::cout << vec[i] << (i+1 < n ? "" : "\n");
}


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

int main(){
    int a;
    cin >> a;
    vint weight(a);
    vint value(a);
    map<string,int> time;
    rep(i,a){
        string b;
        cin >> b;
        time[b]++;
    }
    int ma = 0;
    for(auto p:time){
        auto key = p.first;
        auto value = p.second;
        ma = max(ma,p.second); 
    }
    priority_queue<string,vector<string>,greater<string>> pq;
    for(auto p:time){
        auto key = p.first;
        auto value = p.second;
        if(ma == p.second)
            pq.push(p.first); 
    }
    while(!pq.empty()){
        cout << pq.top() << endl;
        pq.pop();
    }
}
    

Measured memory_bytes: 28404
#include <iostream>
#include <cmath>
using namespace std;
int a, b, t;
int main() {
	cin>>a>>b;
	t = b;
	while(t) a*=10, t/=10;
	a += b;
	t = sqrt(a);
	cout<<(t*t==a ? "Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

ll gcd(ll a, ll b) {
    while (b) {
        ll c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int main() {
    ios::sync_with_stdio(false);
    //x,x+d,x+2d,x+3d,x+4d
    //0x:[0,0]d,1x:[0,4]d,2x:[1,7]d,3x:[3,9]d,4x:[6,10]d,5x:[10,10]d
    //mx=cd
    //10x+197d=20x+190d
    //10x+198d=20x+191d
    //10x+945d=20x+938d=30x+931d=40x+924d
    ll n, x, d, l[200005] = {}, r[200005] = {}, z = 0;
    cin >> n >> x >> d;
    if (d == 0) {
        if (x == 0) cout << 1;
        else cout << n + 1;
        return 0;
    }
    for (ll i = 1; i <= n; i++) l[i] = (i - 1) * i / 2, r[i] = (n + n - i - 1) * i / 2;
    for (int i = 0; i <= n; i++) z += r[i] - l[i] + 1;
    ll g = gcd(abs(x), abs(d)), m = d / g, c = x / g;
    if (m < 0) m = -m, c = -c;
    for (ll i = 0; i < m; i++) {
        vector<ll> a, b;
        for (ll j = i; j <= n; j += m) a.push_back(l[j]), b.push_back(r[j]);
        for (int j = 0; j + 1 < b.size(); j++) {
            //[a[j]-c,b[j]-c]&[a[j+1],b[j+1]]
            z -= max(0ll, min(b[j] - c, b[j + 1]) - max(a[j] - c, a[j + 1]) + 1);
        }
    }
    cout << z;
}


Measured memory_bytes: 9712
#include<stdio.h>

int main(){
  int N,i,flag=1,j,A[100],c=0;
  scanf("%d",&N);
  for(j=0;j<N;j++)scanf("%d",&A[j]);
  while(flag){
    flag=0;//交換がおきなかったなら、ソート完了であるという判定
    for(j=N-1;j>0;j--){
      if(A[j]<A[j-1]){
	i=A[j];
	A[j]=A[j-1];
	A[j-1]=i;
	c++;
	flag=1;
      }
    }
  }
  for(j=0;j<N;j++)if(j!=N-1)printf("%d ",A[j]);else printf("%d\n",A[j]);
  printf("%d\n",c);
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <tuple>
#include <unordered_map>
#include <map>
#include <cmath>

/*

1
7
5 2 3 1 4 6 7

 */

#define endl "\n"
#define eb emplace_back
#define ll long long

using namespace std;

bool v[100001];
int dp[100001];

void dfs(vector<vector<int>>& conn, int curr) {
    if (v[curr])
        return;
    v[curr] = true;

    for (int i = 0; i < conn[curr].size(); i++) {
        int next = conn[curr][i];
        if (!v[next])
            dfs(conn, next);
        dp[curr] = max(dp[curr], 1+dp[next]);
    }
}

int main() {

    cin.tie(nullptr); cout.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    fill(v, v+n+1, false);

    vector<vector<int>> conn(n+1);
    for (int i = 0; i < n+1; i++) {
        vector<int> temp;
        conn[i] = temp;
    }

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        conn[a].eb(b);
    }

    fill(dp, dp+n+1, 0);

    for (int i = 1; i <= n; i++) {
        dfs(conn, i);
    }

    cout << *max_element(dp, dp+n+1) << endl;

    return 0;

}

Measured memory_bytes: 12588
//written by libra9z
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <valarray>
#include <utility>
#include <numeric>
#include <memory>
#include <functional>
#include <stdexcept>
#include <typeinfo>
#include <limits>
#include <complex>
#include <locale>
using namespace std;
#define Debug(x) cerr << #x << " = " << x << endl
#define Debug22(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<endl;
#define Debug2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define Debug3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<")\n";
#define Debug_arr(v,n) for(int i=0;i<n;++i) cerr<<#v<<"["<<i<<"]"<<" = "<<v[i]<<endl;
#define SET(p,v) fill((__typeof(**p)*)p,(__typeof(**p)*)p+sizeof(p),v);
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define prl cerr << "called: " << __LINE__ << endl
#define all(s) s.begin(),s.end()int A[SIZE],B[SIZE];
int A[100005],B[100005];
int n,k;
int main()
{
	scanf("%d %d",&n,&k);
	for (int i=0;i<n;i++) 
	{
		scanf("%d %d",&A[i],&B[i]);
	}
	long long ret=0;
	for (int i=0;i<n;i++)
	{
		if ((k|A[i])==k) ret+=B[i];
	}
	for (int i=0;i<=30;i++)
	{
		if (!(k>>i&1)) continue;
		long long now=0;
		for (int j=0;j<i;j++)
		{
			now|=1<<j;
		}
		for (int j=i+1;j<=30;j++)
		{
			if (k>>j&1) now|=1<<j;
		}
		long long sum=0;
		for (int j=0;j<n;j++)
		{
			if ((now|A[j])==now) sum+=B[j];
		}
		ret=max(ret,sum);
	}
	printf("%lld\n",ret);
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli n,m,x;
    cin>>n>>m>>x;
    lli i,j,k,c[n+1],a[n+1][m+1],ans=1e18;
    
    for(i=0;i<n;i++)
    {
        cin>>c[i];
        for(j=0;j<m;j++) cin>>a[i][j];
    }
    
    for(i=0;i<=(1<<n);i++)
    {
        lli cur[m]={0},cost=0;
        
        for(j=0;j<n;j++)
        {
            if(i&(1<<j))
            {
                cost+=c[j];
                for(k=0;k<m;k++)
                {
                    cur[k]+=a[j][k];
                }
            }
        }
        
        lli flag=1;
        for(j=0;j<m;j++)
        {
            if(cur[j]<x) flag=0;
        }
        
        if(flag)
        ans=min(ans,cost);
    }
    
    if(ans==1e18) cout<<-1;
    else    cout<<ans;
    return 0;
}

Measured memory_bytes: 3660
def main():
    array = [int(input()) for _ in range(5)]

    min_ones_place = 10
    for i in range(5):
        ones_place = array[i]%10
        temp = 10 - ones_place
        if temp ==10:
            continue
        array[i] += temp
        min_ones_place = min(min_ones_place, ones_place)
    print(sum(array)-(10-min_ones_place))


if __name__ == '__main__':
    main()


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

int f[10][10], a[10];
int debug = 0;
int dfs(int pos, bool odd, bool lead, bool top)
{
    if (pos < 0) 
    {
        // if (odd) printf("count: %d\n", debug);
        return odd ? 1 : 0;
    }
    
    int res = 0;

    int ub = 9;
    if (top) ub = a[pos];

    for (int i = 0; i <= ub; ++i) 
    {
        if (lead && i == 0) 
        {
            odd = (pos - 1) & 1;
        }
        debug *= 10;
        debug += i;

        res += dfs(pos  - 1, odd, lead && i == 0, top && i == ub);
        
        debug -= i;
        debug /= 10;   
    }

    return res;
}

int main() 
{
    int n, len = 0;
    scanf("%d", &n);

    while (n) 
    {  
        a[len++] = n % 10;
        n /= 10;
    }

    int res = dfs(len - 1, len & 1, true, true);

    printf("%d\n", res - 1);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

template<ll mod, ll primitive_root>
class NTT {
  void bit_reverse(vector<ll>& a){
    int N = a.size();
    int i = 0;
    for(int j=1; j<N-1; j++){
      for(int k=N>>1; k>(i^=k); k>>=1);
      if(j < i) swap(a[i], a[j]);
    }
  }
  ll extgcd(ll a, ll b, ll &x, ll &y){
    ll d = a;
    if(b!=0){
      d = extgcd(b,a%b,y,x);
      y -= (a/b)*x;
    }else{
      x = 1; y = 0;
    }
    return d;
  }
  ll mod_inv(ll a){
    ll x, y;
    extgcd(a, mod, x, y);
    return (mod + x % mod) % mod;
  }
  ll mod_pow(ll x, ll n){
    if(n==0) return 1;
    ll res = mod_pow(x * x % mod, n / 2);
    if(n & 1) res = res * x % mod;
    return res;
  }
  
  void _calc(vector<ll>& a, int sign){
    int N = a.size();
    ll g = primitive_root;

    ll tmp = (mod - 1) * mod_inv(N) % mod;
    ll h = mod_pow(g, tmp);
    if(sign == -1) h = mod_inv(h);

    bit_reverse(a);
    
    for(int m=1; m<N; m<<=1){
      ll _base = mod_pow(h, N/(2*m));
      ll _w = 1;
      for(int x=0; x<m; x++){
        for(int s=x; s<N; s+=(2*m)){
          ll u = a[s];
          ll d = (a[s+m] * _w) % mod;
          a[s] = (u+d) % mod;
          a[s+m] = (u-d+mod) % mod;
        }
        _w = (_w * _base) % mod;
      }
    }
  }

  void ntt(vector<ll>& in){ _calc(in, 1); }
  void intt(vector<ll>& in){
    _calc(in, -1);
    ll n_inv = mod_inv(in.size());
    for(int i=0; i<in.size(); i++){
      in[i] = (in[i] * n_inv) % mod;
    }
  }

public:
  NTT(){}

  long long get_mod() const { return mod; }

  vector<ll> conv(const vector<ll>& a, const vector<ll>& b){
    vector<ll> _a = a, _b = b;
    int m = a.size() + b.size() - 1;
    int n = 1; while(n < m) n <<= 1;
    _a.resize(n, 0);
    _b.resize(n, 0);
    ntt(_a);
    ntt(_b);
    for(int i=0; i<n; i++) _a[i] = (_a[i] * _b[i]) % mod;
    intt(_a);
    _a.resize(m);
    return _a;
  }
};

NTT<998244353,3> ntt;

vector<ll> dfs(const vector<int>& v, int S, int l, int r){
  if(l+1 == r){
    vector<ll> x(min(v[l],S)+1,0);
    x[0] = 2;
    if(v[l]<=S) x[v[l]] = 1;
    return x;
  }

  int m = (l+r)/2;
  vector<ll> lhs = dfs(v, S, l, m);
  vector<ll> rhs = dfs(v, S, m, r);

  vector<ll> res = ntt.conv(lhs, rhs);
  if(res.size() > S){
    res.resize(S+1);
  }
  return res;
}

int main(){
  int N, S;
  cin >> N >> S;
  
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }
  sort(ALLOF(v));

  vector<ll> ret = dfs(v, S, 0, N);
  
  cout << ret[S] << endl;

  return 0;
}



Measured memory_bytes: 4292
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int n = S.length();
    rep(i, n + 1) {
        
        rep(j, n + 1) {
            string T;
            if(i > j) continue;
            rep(k, n) {
                if(i <= k && k <= j) continue;
                T += S[k];
            }
            //cout << T << endl;
            if(T == "keyence") {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 3564
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=110;
int n,m,x,y;
int a[maxn],b[maxn];
int main() {
    scanf("%d%d%d%d",&n,&m,&x,&y);
    for (int i=0;i<n;i++) scanf("%d",&a[i]);
    sort(a,a+n);
    for (int i=0;i<m;i++) scanf("%d",&b[i]);
    sort(b,b+m);
    bool f=false;
    for (int i=x+1;i<=y;i++) {
        if (i<=b[0] && i>a[n-1]) {
            f=true;
            break;
        }
    }
    printf("%s\n", f?"No War":"War");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll                 long long int
#define mod                9000000000000000000
#define pi                 3.14159265358979323846264338327950288419716939937510
#define setbit(x)          __builtin_popcountll(x)
#define db                 long double
#define pp(x)              pair<x,x>
#define ff                 first
#define ss                 second
#define FIO                ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc                 ll tc; cin>>tc; for(ll number = 1 ; number <= tc ; number ++ )
#define vv(x)              vector<x>
#define pb                 push_back
#define pob                pop_back
#define pf                 push_front
#define pof                pop_front
#define endl               "\n"
#define pq                 priority_queue
#define dbg(x)             { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)          { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define bp                 ll kkk; cin >>kkk;
#define dbgArr(a,n)        cout<<"Array "<<#a<<endl; for(ll i=0 ; i<n ; i++) cout<<a[i]<<" "; cout<<endl;
#define maxE(a,n)          *max_element(a,a+n);
#define minE(a,n)          *min_element(a,a+n);
#define forn(i,s,n)        for(ll i=s ; i<n ; i++)
#define fornr(i,e,s)       for(ll i=e-1 ; i>=s ; i--)
#define arr(a,n)           for(ll i=0;i<n;i++){ cin>>a[i]; }
#define arr1(a,n)          for(ll i=1;i<=n;i++){ cin>>a[i]; }
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define print cout<<"Case #"<<number<<": "
#define all(x) x.begin(), x.end()
ll power(ll x, ll b) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= mod;} b >>= 1; x *= x; x %= mod;} return p % mod;}
using namespace std;
# define INF 1e15
struct lex_compare {
    bool operator() (const pair<db,ll>  p1, const pair<db,ll> p2){
        return (p1.first ==  p2.first) ? p1.ss < p2.ss : p1.first > p2.first;
    }
};

int main(){
    FIO;
    ll t; t = 1;
	while(t--){
	    ll n; cin >> n;
	    string s = "";
	    while( n > 0){
	        //cout << n%26 << endl;
	        n -= 1;
	        {
	            s = char('a' + n%26 ) + s;
	            n = n/26;
	        }
	    }
	    cout << s << endl;
	}
	return 0;
    return 0;
}


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

int main(){
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	vector<vector<int>> a(h+2, vector<int>(w+2));
	rep(i, h) cin >> s.at(i);
	rep(i, h+2) rep(j, w+2){
		a.at(i).at(j) = 0;
	}
	rep(i, h) rep(j, w){
		if(s.at(i).at(j) == '#'){
			a.at(i+1).at(j+1) = -1;
		} 
	}
	rep(i, h){
		rep(j, w){
			if(a.at(i+1).at(j+1) == 0){
				int sum = 0;
				if(a.at(i+1-1).at(j+1-1) == -1) sum++;
				if(a.at(i+1-1).at(j+1  ) == -1) sum++;
				if(a.at(i+1-1).at(j+1+1) == -1) sum++;
				if(a.at(i+1  ).at(j+1-1) == -1) sum++;
				if(a.at(i+1  ).at(j+1+1) == -1) sum++;
				if(a.at(i+1+1).at(j+1-1) == -1) sum++;
				if(a.at(i+1+1).at(j+1  ) == -1) sum++;
				if(a.at(i+1+1).at(j+1+1) == -1) sum++;
				cout << sum;
			}else{
				cout << '#';
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// Name: Kanisht Agarwal Copyright Think before u copy //
//Connect with me at LinkedIn

#include <bits/stdc++.h>
#define mod 1000000007
#define ull unsigned ll
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.1415926535897932
#define nui 100
#define INF 100000000000
using namespace std;

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

ll fermat_inv(ll y) {return binpow(y, mod - 2);}

clock_t time_p = clock();

void TLE()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

struct point
{
    int x; int y;
};
bool segment(point p, point q, point r)
{
    if (q.x <= max(p.x, r.x) && q.y <= max(p.y, r.y) && q.x >= min(p.x, r.x) && q.y >= min(p.y, r.y))
        return true;

    return false;
}
int orientation(point p, point q, point r)
{
    int o = (r.x - q.x) * (q.y - p.y) - (r.y - q.y) * (q.x - p.x);
    if (o == 0)return 0;
    return (o > 0) ? 1 : 2;
}
bool intersection(point p, point q, point r, point s)
{
    int o1 = orientation(p, q, r);
    int o2 = orientation(p, q, s);
    int o3 = orientation(r, s, p);
    int o4 = orientation(r, s, q);
    if (o1 != o2 && o3 != o4)return true;
    if (o1 == 0 && segment(p, r, q))return true;
    if (o2 == 0 && segment(p, s, q))return true;
    if (o3 == 0 && segment(r, p, s))return true;
    if (o4 == 0 && segment(r, q, s))return true;

    return false;
}

bool prime[10000001];
vector<ll>v;
void seive()
{
    memset(prime, 1, sizeof(prime));
    for (ll i = 2; i * i <= 10000001; i++)
    {
        if (prime[i] == 1)
        {
            for (ll j = i * i; j <= 10000001; j += i)
            {
                prime[j] = 0;
            }
        }
    }
    for (ll i = 2; i <= 10000001; i++)
    {
        if (prime[i])
        {
            v.pb(i);
        }
    }

}

ll dp[100001];
int main()
{



    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //Standard stair case problem
    int n, k;
    cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    dp[1] = 0;
    for (int i = 1; i < k; i++)
    {
        dp[i + 1] = abs(h[0] - h[i]);
    }
    int mini;
    for (int i = k; i < n; i++)
    {
        mini = abs(h[i] - h[i - 1]) + dp[i];
        for (int j = i; j > i - k; j--)
        {
            int k = abs(h[i] - h[j - 1]) + dp[j];
            mini = min(k, mini);
        }
        dp[i + 1] = mini;
    }
    cout << dp[n] << "\n";


    return 0;
}



Measured memory_bytes: 4828
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(ll i = 0;i < (n); ++i)
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    ll n,count=1,ans=0;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        if(a[i] == count){
            count++;
        }else{
            ans++;
        }
    }
    if(a.size() != ans) cout << ans << endl;
    else cout << "-1" << endl;
}

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

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
  #define DFUNC(fname, ...) fname(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DFUNC(fname, ...)
#endif

ll N, M;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> N >> M;
  ll left = 1;
  ll right = N;
  for (ll i = 0; i < M; i++) {
    ll l, r;
    cin >> l >> r;
    if (left < l)  left = l;
    if (r < right)  right = r;
  }
  ll answer = max(0LL, right - left + 1);
  cout << answer << endl;

  return 0;
}



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


int main(){
    int n,k,s=0,i;
    cin>>n>>k;
    int c[n+1]={0};
    while(k--){
        int d;
        cin>>d;
        while(d--){
            int m;
            cin>>m;
            c[m]++;
        }
    }
    for(i=1;i<=n;i++){
        if(c[i]==0)
        s++;
    }
        cout<<s;
    }

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll N,M;
  cin>>N>>M;
  map<ll,ll> S;
  for(ll i=0;i<N;i++) {
    ll K;
    cin>>K;
    for(ll j=0;j<K;j++) {
      ll A;
      cin>>A;
      S[A]++;
    }
  }
  ll ans=0;
  for(auto x:S) {
if(x.second==N) {
ans++;
}
  }
  
  
  cout<<ans<<endl;
}

  


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n;
  cin>>n;
  vi v(n);
  REP(i,n)cin>>v[i];
  sort(ALL(v));
  v.erase(unique(ALL(v)),v.end());
  cout<<v.size()<<endl;
  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
int dfs(string n,int N){
    int res=0;
    if (stoll(n)>N)return 0;
    bool flg=true;
    for (auto &&it : {'3','5','7'}){
        if(n.find(it)==string::npos)flg=false;
    }
    res = flg;

    for(auto &&it : {'3','5','7'}){
        res +=dfs(n+it,N);
    }
    return res;
}

int main(void){
    int n;
    cin >> n;
    int res;
    res=dfs("0",n);
    cout << res << endl;
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	while(cin>>n,n){
		int ans=0;
		loop(i,2,n+1){
			loop(j,1,n){
				int sum=i*j+i*(i-1)/2;
				if(sum==n)ans++;
				if(sum>n)break;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int main(void)
{
    int i,j,k;

    int grid[3][3];
    bool goal[3][3];

    for(i = 0; i < 3; i++)
    {
        for(j = 0; j < 3; j++)
        {
            cin>>grid[i][j];
            goal[i][j] = 0;
        }
    }
    int num;
    cin>>num;
    int val[num];

    for(i = 0; i < num; i++)
    {
        cin>>val[i];
    }

    for(i = 0; i < 3; i++)
    {
        for(j = 0; j < 3; j++)
        {
            for(k = 0; k < num; k++)
            {
                if (val[k] == grid[i][j])
                    goal[i][j] = 1;
            }
        }
    }

    for(i = 0; i < 3; i++)
    {
        int m = 0, n = 1, o = 2;
        if(goal[i][m] && goal[i][n] && goal[i][o])
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    for(i = 0; i < 3; i++)
    {
        int m = 0, n = 1, o = 2;
        if(goal[m][i] && goal[n][i] && goal[o][i])
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    if(goal[0][0] && goal[1][1] && goal[2][2])
    {
        cout<<"Yes\n";
        return 0;
    }
    if(goal[2][0] && goal[1][1] && goal[0][2])
    {
        cout<<"Yes\n";
        return 0;
    }
    cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
 
public class Main {
 
    public static void main(String[] args) {
        try {
            //Input
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            int N = Integer.parseInt(br.readLine());
            for (int i = 0; i < N; i++) {
                String A = br.readLine();
                String B = br.readLine();
                if ((A.length() > 80)|| (B.length() > 80)) {
                    System.out.println("overflow");
                } else {
                    BigInteger P = new BigInteger(A);
                    BigInteger Q = new BigInteger(B);
                    BigInteger R = new BigInteger("0");
 
                    R = R.add(P); R = R.add(Q);
                    String total = R.toString();
 
                    if (total.length() > 80) {
                        System.out.println("overflow");
                    } else {
                        System.out.println(total);
                    }
 
                }
 
            }
        } catch (Exception e) {
            System.out.println("error");
        }
    }
 
}

Measured memory_bytes: 24132
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
using namespace std;

#define rep(i,N) for(int i=0; i<N; i++)
#define revrep(i,N) for(int i=N-1; i>=0; i--)
#define coutline cout<<"------------ ("<<__LINE__<<")"<<endl;

typedef long long ll;

int main(void)
{
    int A,B,T;
    cin >> A >> B >> T;

    int ret = 0;
    for(int i = 1; i <= T+0.5; i++) {
        if (i%A == 0) {
            ret += B;
        }
    }

    cout << ret << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
using namespace std;


int main(){
	string s; cin >> s;
	ll count = 0;
	ll ans = 0;
	for (int i = 0; i < s.length(); ++i){
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
			count++;
		}
		else{
			ans = max(ans, count);
			count = 0;
		}
	}
	cout << max(ans,count) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MAXN 100010
#define INF 1000000010

using namespace std;

ll n, dp[MAXN], h[MAXN];

void init(){
    for(int i=1; i<=n; i++) dp[i]=INF;
    dp[1]=0;
    h[0]=INF;
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n;

    for(int i=1; i<=n; i++) cin>>h[i];

    init();

    for(int i=2; i<=n; i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }

    cout<<dp[n];

return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
        int one = 0;
        int two = 0;
        int th = 0;
        int i;
        int n;
        for (i = 0; i < 10; i++)
        {    
                scanf("%d\n", &n);
                if (one <= n)
                {   
                        th = two;
                        two = one;
                        one = n;
                }   
                else if(two <= n)
                {   
                        th = two;
                        two = n;
                }   
                else if(th <= n)
                        th = n;
        }   
        printf("%d\n", one);
        printf("%d\n", two);
        printf("%d\n", th);
        return(0);
}



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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    vector<pair<ll, ll>> aim;
    ll ulim = sqrt(N);
    for(ll i = 1; i <= ulim; i++){
        if(N%i == 0){
            aim.push_back(make_pair(i, N/i));
        }
    }
    ll ans = LLINF;
    rep(i, aim.size()){
        ans = min(ans, abs(aim[i].first - 1) + abs(aim[i].second - 1));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
n,m,x=map(int,input().split())
l=list(map(int,input().split()))
ans1=0
ans2=0
for i in range(x+1,n):
    for j in range(m):
        if l[j]==i:
            ans1+=1
for i in range(0,x):
    for j in range(m):
        if l[j]==i:
            ans2+=1
print(min(ans1,ans2))

Measured memory_bytes: 3064