akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))


int main(){
    
    int n, m;   cin >> n >> m;
    vector<vector<char>> g1(n, vector<char>(n)), g2(m, vector<char>(m));

    REP(i, n) REP(j, n) cin >> g1[i][j];
    REP(i, m) REP(j, m) cin >> g2[i][j];

    string ans="No";
    REP(i, n-m+1){
        REP(j, n-m+1){
            bool flag=true;
            FOR(p, i, i+m){ 
                FOR(q, j, j+m){
                    if(g1[p][q]==g2[p-i][q-j]) continue;
                    flag = false;
                }
            }
            if(flag) ans = "Yes";
        }
    }
    cout << ans << endl;

}

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;

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int n,m;
    cin>>n>>m;

    vector<pair<long long int,long long int>> mise(n);
    REP(i,n){
        cin>>mise[i].first>>mise[i].second;
    }

    sort(mise.begin(),mise.end());
    long long int result=0;
    for(pair<long long int,long long int> &x:mise){
        result+=x.first*min(x.second,m);
        m-=min(x.second,m);
        if(m<=0){
            break;
        }

    }
        
    cout<<result<<endl;
    

    return 0;
}


Measured memory_bytes: 1792
// https://atcoder.jp/contests/dp/tasks/dp_b

#include <bits/stdc++.h>

using namespace std;

#define ll long long 
#define REP1(i,n) for(ll i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 1000010;
static const ll INFTY = 1e12;
static const ll NUMMAX = 1000000007;
static const ll MOD = 1000000007;
#define LOOP 10000000
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 入力
int H, W;
vector<string> field;
int result = 100;
int dfs_res = 0;

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; }

ll dp[101][100001];
 
int main() {
 
    int N;
    cin >> N >> W;
    ll dp[N+1][W+1];
    vector<int> weight(N), value(N);

    REP(i, N+1)REP(j, W+1) dp[i][j] = 0;

    REP(i, N){
        cin >> weight[i] >> value[i];
    }

    REP(i, N){
        REP(j, W+1){
            chmax(dp[i+1][j], dp[i][j]);
            if(weight[i] <= j) chmax(dp[i+1][j], dp[i][j-weight[i]] + value[i]);
        }
    }

    //REP(i, N+1){
    //    REP(j, W+1){
    //        cout << dp[i][j] << " ";
    //    } cout << endl;
    //}
    cout << dp[N][W] << endl;




 
    return 0;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/




Measured memory_bytes: 79104
import numpy as np
zeroarr = np.array([[0, 0, 0], [0, 0, 0], [0, 0, 0]])
l1= list(map(int, input().split()))
l2= list(map(int, input().split()))
l3=list(map(int, input().split()) )
bing = np.array([np.array(l1), np.array(l2), np.array(l3)])
n=int(input())
x=[]
for _ in range(n):
  l=int(input())
  x.append(l)
def check(ls, b, dd):
    for i in ls:
        if i in b:
            xxx=np.argwhere(b==i)
            for m in xxx:
                dd[m[0], m[1]]=1
check(x, bing, zeroarr)
def matrixsum(a):
    ans="No"
    if a[0,0]+a[0,1]+a[0,2]==3:
        ans="Yes"
    if a[1,0]+a[1,1]+a[1,2]==3:
        ans="Yes"
    if a[2,0]+a[2,1]+a[2,2]==3:
        ans="Yes"
    if a[0,0]+a[1,0]+a[2,0]==3:
        ans="Yes"
    if a[0,1]+a[1,1]+a[2,1]==3:
        ans="Yes"
    if a[0,2]+a[1,2]+a[2,2]==3:
        ans="Yes"
    if a[0,0]+a[1,1]+a[2,2]==3:
        ans="Yes"
    if a[0,2]+a[1,1]+a[2,0]==3:
        ans="Yes"
    return ans
print(matrixsum(zeroarr))

Measured memory_bytes: 27280
#include <bits/stdc++.h>
using namespace std;
int n, m;
const int MOD = 1000000007;
struct mat
{
    int data[4][4];
    mat () {memset(data, 0, sizeof data);}
} P, Q, I, O, A;
mat operator * (mat a, mat b)
{
    mat c;
    for (int i = 0; i < 4; ++ i)
        for (int j = 0; j < 4; ++ j)
            for (int k = 0; k < 4; ++ k)
                c.data[j][k] = (c.data[j][k] + 1ll * a.data[j][i] * b.data[i][k]) % MOD;
    return c;
}
mat operator ^ (mat a, int b)
{
    mat c = I;
    for (; b; b >>= 1, a = a * a)
        if (b & 1) c = c * a;
    return c;
}
int i_P[][4] =
{
    {2, 1, 1, 1},
    {1, 1, 0, 1},
    {1, 0, 1, 1},
    {1, 0, 0, 1}
};
int i_Q[][4] =
{
    {1, 1, 1, 1},
    {0, 1, 0, 1},
    {0, 0, 1, 1},
    {0, 0, 0, 1}
};
int main()
{
    for (int i = 0; i < 4; ++ i) I.data[i][i] = 1;
    cin >> n >> m;
    for (int i = 0; i < 4; ++ i)
        for (int j = 0; j < 4; ++ j)
            P.data[i][j] = i_P[i][j],
            Q.data[i][j] = i_Q[i][j];

    A = I;
    for (int i = 1, l = 0; i <= m + 1; ++ i)
    {
        int x;
        if (i == m + 1) x = n + 1;
        else cin >> x;
        A = A * (P ^ (x - l - 1)); l = x;
        if (i != m + 1) A = A * Q;
    }
    cout << A.data[0][3];
}


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

int main() {
  int n; cin >> n;
  vector<int> flower(n);
  for (int i = 0; i < n; i++) cin >> flower[i];
  
  int ans = 0;
  int max = *max_element(flower.begin(), flower.end());
  
  while (max > 0) {
    for (int i = 0; i < n; ) {
      if (flower[i] > 0) {
        ans++;
        int last;
        for (int j = i; j < n; j++) {
          if (flower[j] != 0) last = j + 1;
          else break;
        }
        for (int j = i; j < last; j++) flower[j]--;
        i = last;
      }
      i++;
    }
    max = *max_element(flower.begin(), flower.end());
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
int main() {
 int64_t Q,H,S,D,N;
 cin>>Q>>H>>S>>D>>N;
 cout<<min({4*Q,2*H,S})*(N%2)+N/2*min(2*min({4*Q,2*H,S}),D)<<endl;
 return 0;}

Measured memory_bytes: 384
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr int INF = 1001001000;
constexpr ll MOD = 1000000007LL;

int bit[200010];
int dp[1 << 26];

// generate binary string (not less than k-digit)
string to_binString(int n, int k) {
    string ret = "";
    while(n) ret += ('0' + (n&1)), n >>= 1;
    while(ret.length() < k) ret += '0';
    reverse(ret.begin(), ret.end());
    return ret;
}

int main() {
    string s; cin >> s;
    int len = s.length();
    rep(i,0,len) {
        bit[i+1] = bit[i];
        bit[i+1] ^= (1 << (s[i] - 'a'));
    }

    fill(dp, dp+(1<<26), INF);
    dp[0] = 0;
    rep(i,0,len) {
        int bt = bit[i+1], opt = INF;
        rep(k,-1,26) {
            int nbit = (k < 0 ? bt : bt ^ (1 << k));
            chmin(opt, dp[nbit] + 1);
        }
        chmin(dp[bt], opt);
        if(i == len-1) cout << max(dp[bt], 1) << endl;
    }
    return 0;
}

Measured memory_bytes: 263556
// Problem: E - Dist Max
// Contest: AtCoder - AtCoder Beginner Contest 178
// URL: https://atcoder.jp/contests/abc178/tasks/abc178_e
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
 
using namespace std;
#define int long long
#define ll long long
const int N = 2e5+5;
const int mod = 1e9;
#define ld long double
#define PI 3.14159265358979323846
#pragma GCC optimize("-O2")
const int INF = 10000000;

int getIInput() {
	cout.flush();
	#ifdef LOCAL
	return generateLocalInputOrAnythingYouWant();
	#else
	int x;
	cin>>x;
	return x;
	#endif
}

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(9);
}
 
//3. Structure or classes
//3. Ends here
 
//1. Data structures declaration here
//1. Ends here
 
//2. Extra Functions here
//2. Ends here
 
 
void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}
 
 
 
void solve()
{
	int n;
	cin>>n;
	set<int>st1;
	set<int>st2;
	
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		st1.insert(x+y);
		st2.insert(x-y);
	}
	
	auto z = st1.end();
	z--;
	int a = (*(z));
	z = st1.begin();
	int b = (*(z));
	
	auto zz = st2.end();zz--;
	int a1 = (*(zz));
	zz = st2.begin();
	int b1 = (*(zz));
	cout<<max(a-b,a1-b1);
    return;
}
// how r u bro

Measured memory_bytes: 22356
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;

int main(){
    int x, y;
    cin >> x >> y;
    
    if(((4*x-y) % 2 == 0) && ((y-2*x) % 2 == 0) && ((4*x-y) / 2.0 >= 0)&&((y-2*x) / 2.0 >= 0) ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1e18
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int n,m;
ll l;
ll d[300][300],e[300][300];

void warshall_floyd() {
  
}

int main(){
    cin>>n>>m>>l;
    rep(i,300)rep(j,300){d[i][j]=INF;e[i][j]=INF;}
    rep(i,300){
        d[i][i]=0;
        e[i][i]=0;
    }
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        ll c;
        cin>>c;
        d[a][b]=c;
        d[b][a]=c;
    }
    for (int k = 0; k < n; k++){       // 経由する頂点
        for (int i = 0; i < n; i++) {    // 始点
            for (int j = 0; j < n; j++) {  // 終点
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    rep(i,n){
        rep(j,n){
            if(d[i][j]<=l)e[i][j]=1;
        }
    }
    for (int k = 0; k < n; k++){       // 経由する頂点
        for (int i = 0; i < n; i++) {    // 始点
            for (int j = 0; j < n; j++) {  // 終点
                e[i][j] = min(e[i][j], e[i][k] + e[k][j]);
            }
        }
    }
    int q;
    cin>>q;
    rep(i,q){
        int s,t;
        cin>>s>>t;
        s--;t--;
        if(e[s][t]!=INF)cout<<e[s][t]-1<<endl;
        else cout<<-1<<endl;
    }
}


Measured memory_bytes: 5004
#include <algorithm>            // https://cpprefjp.github.io/reference/algorithm.html
#include <ios>                  // https://cpprefjp.github.io/reference/ios.html
#include <iostream>             // https://cpprefjp.github.io/reference/iostream.html
#include <map>                  // https://cpprefjp.github.io/reference/map.html
#include <set>
#include <string>               // https://cpprefjp.github.io/reference/string/basic_string/find.html
#include <vector>               // https://cpprefjp.github.io/reference/vector/vector.html
#include <utility>              // https://cpprefjp.github.io/reference/utility.html

#include <cmath>                // https://cpprefjp.github.io/reference/cmath.html
#include <cassert>              // https://cpprefjp.github.io/reference/cassert/assert.html

using namespace std;

typedef long long ll;

#define GCD(a, b) __gcd((a), (b))
#define LCM(a, b) ((a) / GCD((a), (b)) * (b))
#define POPCOUNT(x) __builtin_popcount((x))

#ifdef AT_DEBUG
#define dp(s) (cout << s)
#define dpln(s) (cout << s << endl)
#define dpln_col(c) { for (const auto& x : c) dpln(x); }
#else  // AT_DEBUG
#define dp(s)
#define dpln(s)
#define dpln_col(c)
#endif // AT_DEBUG

int main (int argc, char** argv)
{
	string S;

	cin >> S;

	if ((S.at(2) == S.at(3)) && (S.at(4) == S.at(5))) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
#ifdef AT_DEBUG
#endif  // AT_DEBUG

	return 0;
}

// Dec Hex    Dec Hex    Dec Hex  Dec Hex  Dec Hex  Dec Hex   Dec Hex   Dec Hex
//   0 00 NUL  16 10 DLE  32 20    48 30 0  64 40 @  80 50 P   96 60 `  112 70 p
//   1 01 SOH  17 11 DC1  33 21 !  49 31 1  65 41 A  81 51 Q   97 61 a  113 71 q
//   2 02 STX  18 12 DC2  34 22 "  50 32 2  66 42 B  82 52 R   98 62 b  114 72 r
//   3 03 ETX  19 13 DC3  35 23 #  51 33 3  67 43 C  83 53 S   99 63 c  115 73 s
//   4 04 EOT  20 14 DC4  36 24 $  52 34 4  68 44 D  84 54 T  100 64 d  116 74 t
//   5 05 ENQ  21 15 NAK  37 25 %  53 35 5  69 45 E  85 55 U  101 65 e  117 75 u
//   6 06 ACK  22 16 SYN  38 26 &  54 36 6  70 46 F  86 56 V  102 66 f  118 76 v
//   7 07 BEL  23 17 ETB  39 27 '  55 37 7  71 47 G  87 57 W  103 67 g  119 77 w
//   8 08 BS   24 18 CAN  40 28 (  56 38 8  72 48 H  88 58 X  104 68 h  120 78 x
//   9 09 HT   25 19 EM   41 29 )  57 39 9  73 49 I  89 59 Y  105 69 i  121 79 y
//  10 0A LF   26 1A SUB  42 2A *  58 3A :  74 4A J  90 5A Z  106 6A j  122 7A z
//  11 0B VT   27 1B ESC  43 2B +  59 3B ;  75 4B K  91 5B [  107 6B k  123 7B {
//  12 0C FF   28 1C FS   44 2C ,  60 3C <  76 4C L  92 5C \  108 6C l  124 7C |
//  13 0D CR   29 1D GS   45 2D -  61 3D =  77 4D M  93 5D ]  109 6D m  125 7D }
//  14 0E SO   30 1E RS   46 2E .  62 3E >  78 4E N  94 5E ^  110 6E n  126 7E ~
//  15 0F SI   31 1F US   47 2F /  63 3F ?  79 4F O  95 5F _  111 6F o  127 7F DEL


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    String count = String.valueOf(str.length() - 2);

    System.out.println(str.charAt(0) + count + str.charAt(str.length() - 1));
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,0,n) cin >> h[i];
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    vector<ll> bit(n+1);
    rep(i,0,n) {
        ll best = 0;
        int j = h[i];
        while(j>0) {
            best = max(best, bit[j]);
            j -= j&-j;
        }
        best += a[i];
        j = h[i];
        while(j<=n) {
            bit[j] = max(bit[j], best);
            j += j&-j;
        }
    }
    int j = n;
    ll ans = 0;
    while(j>0) {
        ans = max(ans, bit[j]);
        j -= j&-j;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 4224
#include <stdio.h>
int main(void)
{
    int count[26]={},num,i;
    char ch;
    
    while(scanf("%c",&ch)!=EOF)
    {
        if(ch>='A' && ch<='Z')
        {
            num=ch-'A';
            count[num]++;
        }
        else if(ch>='a' && ch<='z')
        {
            num=ch-'a';
            count[num]++;
        }
        
    }
    
        for(i=97;i<=122;i++)
        {
            printf("%c : %d\n",i,count[i-97]);
        }
    
    
    
    return 0;
}



Measured memory_bytes: 2036
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */

void sub_main(istream &cin) {
    ll N;
    cin >> N;
    if(!cin) return;
    ll ans = 0;
    ll leas = 0;
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        if(a > leas) {
            leas = a;
            ans = leas + b;
        }
    }// i
    cout << ans << endl;

}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test_1.txt";
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#\n";
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


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

#define ll long long
#define FASTIO std::ios::sync_with_stdio(false)

#define loop(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using namespace std;

int main() {
    FASTIO;
    ll n, k, q;
    cin >> n >> k >> q;
    vector<int> aa(n+1, 0);
    loop(i, 0, q) {
    	ll a;
        cin >> a;
        aa[a]++;
    }
    
    loop(i, 1, n+1) {
    	if (q - aa[i] >= k) 
    	    cout << "No" << endl;
        else 
            cout << "Yes" << endl;
    }
}

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

using namespace std;

long long solve(long long n) {
	if (n % 4 == 0) return n;
	if (n % 4 == 1) return 1;
	if (n % 4 == 2) return n + 1;
	return 0;
}

int main() {
	long long a, b; cin >> a >> b;
	cout << (solve(b) ^ solve(a - 1)) << "\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner input;
        int A,B,C,X;
        input = new Scanner(System.in);
        A = input.nextInt();
        B = input.nextInt();
        C = input.nextInt();
        X = input.nextInt();
        int ans = 0;
        for (int i = 0; i < A+1; i++){
          for (int j = 0; j < B+1; j++){
            for (int k = 0; k < C+1; k++){
              if (500*i + 100*j + 50*k == X){
                ans += 1;
              }
            }
          }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <iostream>

int main() {
    int d;
    std::cin >> d;

    if(d == 25) {
        std::cout << "Christmas" << std::endl;
    } else if(d == 24) {
        std::cout << "Christmas Eve" << std::endl;
    } else if(d == 23) {
        std::cout << "Christmas Eve Eve" << std::endl;
    } else {
        std::cout << "Christmas Eve Eve Eve" << std::endl;
    }
}


Measured memory_bytes: 256
S = input()
flg = 0
for i,s in enumerate(S):
    if i % 2 == 0:
        if s == 'L':
            flg = 1
    else:
        if s == 'R':
            flg = 1

if flg == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
// AOJ 2096: Private Teacher
// 2017.11.7 bal4u@uu

#include <stdio.h>
#include <string.h>

#define SIZE      110
long long cap[SIZE][SIZE];
char used[SIZE];
int  n;                 /* number of nodes */

long long augementPath(int s, int t, long long f)
{
	int i;
	long long u, v;

	if (s == t) return f;
	used[s] = 1;
	for (i = 0; i < n; i++) {
		if (!used[i] && cap[s][i] > 0) {
			u = cap[s][i];
			if (u > f) u = f;
			v = augementPath(i, t, u);
			if (v > 0) {
				cap[s][i] -= v, cap[i][s] += v;
				return v;
			}
		}
	}
	return 0;
}

long long maxflow(int s, int t)
{
	long long v, flow = 0;

	while (1) {
		memset(used, 0, sizeof(used));
		v = augementPath(s, t, 1LL<<60);
		if (v == 0) break;
		flow += v;
	}
	return flow;
}

char w[7][3] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" };
int tr[26][26];

int main()
{
	int N, i, c, src, sink;
	long long W, t, sum;
	char buf[10];

	for (i = 0; i < 7; i++) tr[w[i][0]-'A'][w[i][1]-'a'] = i;

	while (scanf("%d%lld", &N, &W) && N > 0) {
		memset(cap, 0, sizeof(cap));
		src = 0, sink = 1, n = 2+7+N;
		for (i = 2; i < 9; i++) cap[src][i] = W;

		sum = 0;
		for (i = 0; i < N; i++) {
			scanf("%lld", &t);
			sum += t;
			cap[i+9][sink] = t;
			scanf("%d", &c);
			while (c--) {
				scanf("%s", buf);
				cap[2 + tr[*buf-'A'][*(buf+1)-'a']][i+9] = W;
			}
		}
 		puts(maxflow(src, sink) == sum ? "Yes" : "No");
	}
    return 0;
}

Measured memory_bytes: 1760
#include <stdio.h>

int main()
{
	int i, j, N;
	char S[601][301];
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%s", S[i]);
		for (j = 0; j <= N; j++) S[i+N][j] = S[i][j];
	}
	
	int k, count = 0;
	for (k = 0; k < N; k++) {
		for (i = 0; i < N; i++) {
			for (j = 0; j < N; j++) {
				if (S[i+k][j] != S[j+k][i]) break;
			}
			if (j < N) break;
		}
		if (i == N) count++;
	}
	
	printf("%d\n", count * N);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1912
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=(n);i++)
#define Endl endl
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	if(n*a>b){
		cout<<b<<endl;
	}
	else{
		cout<<n*a<<endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	int n,m,c;
	cin>>n>>m>>c;

	int b[m];
	for(int i=0; i<m; i++) cin>>b[i];

	int a[n][m];
	for(int i=0; i<n; i++)
		for(int j=0; j<m; j++)
			cin>>a[i][j];

	int ans = 0;

	for(int i=0; i<n; i++) {
		int val = 0;
		for(int j=0; j<m; j++) {
			val += a[i][j] * b[j];
		}

		ans += (val+c) > 0;
	}

	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int sosuu(int n);
int b(int n);
int s(int n);
int main(){
    int n,big,small;
    while(scanf("%d",&n)!=EOF){
        big = b(n);
        small=s(n);
        printf("%d %d\n",small,big);
    }
    return 0;
}
int s(int n){
    int i,result;
    for(i=0;i<n;i++){
        if(sosuu(i)!=0){
            result=sosuu(i);
        }
    }
    return result;
}
int b(int n){
    int i;
    for(i=n+1;;i++){
        if(sosuu(i)!=0)break;
    }
    return i;
}
int sosuu(int n){
    if(n<=1) return 0;
    int i;
    for(i=2;i*i<=n;i++){
        if(n%i==0){
            return 0;
        }
    }
    return n;
}

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

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

    cout<<*max_element(a.begin(),a.end())-*min_element(a.begin(), a.end())<<endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

	public void Proc()
	{
        string inpt = Reader.ReadLine();
        string ans = "No";
        if(inpt.Contains('9')) {
            ans = "Yes";
        }
        Console.WriteLine(ans);



	}


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"




";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}


Measured memory_bytes: 13268
// E - Roaming
#include <bits/stdc++.h>

using namespace std;

const long long MOD = 1e9 + 7;

vector<long long> fact, finv;

void init_fact(int n)
{
	fact.resize(n); finv.resize(n);
	fact[0] = finv[n - 1] = 1;
	for (int i = 1; i < n; i++) fact[i] = fact[i - 1] * i % MOD;
	for (long long x = MOD - 2, a = fact[n - 1]; x > 0; a = a * a % MOD, x >>= 1)
		if (x & 1) finv[n - 1] = finv[n - 1] * a % MOD;
	for (int i = n - 2; i >= 0; i--) finv[i] = finv[i + 1] * (i + 1) % MOD;
}

long long cnr(int n, int r)
{
	if (r < 0 || r > n) return 0;
	if (r == 0 || r == n) return 1;
	return fact[n] * finv[r] % MOD * finv[n - r] % MOD;
}

int main(int argc, char *argv[])
{
	init_fact(400001);

	long long n, k, ans = 0;
	cin >> n >> k;

	for (long long i = 0; i <= min(k, n - 1); i++)
		ans = (ans + cnr(n, i) * cnr(n - 1, i) % MOD) %MOD;

	cout << ans << endl;

	return 0;
}


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

const int dx[] = {-1, -1, -1,  0, 0,  1, 1, 1};
const int dy[] = {-1,  0,  1, -1, 1, -1, 0, 1};

void dfs(int x, int y, vector<vector<bool> >& canGo){
  canGo[x][y] = false;
  for(int i = 0; i < 8; i++)
    if(canGo[x + dx[i]][y + dy[i]])
      dfs(x + dx[i], y + dy[i], canGo);
  return;
}


int main(void){
  while(true){
    int w, h;
    cin >> w >> h;
    if(w == 0 && h == 0){ break; }

    int input;
    vector<vector<bool> > canGo(h + 2, vector<bool>(w + 2, false));
    for(int i = 1; i <= h; i++){
      for(int j = 1; j <= w; j++){
        cin >> input;
        if(input == 1){ canGo[i][j] = true; }
      }
    }

    int count = 0;
    for(int i = 1; i <= h; i++){
      for(int j = 1; j <= w; j++){
        if(canGo[i][j]){
          ++count;
          dfs(i, j, canGo);
        }
      }
    }

    cout << count << endl;
  }

  return 0;
}

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

int N, P[100000];

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

    int ans = 0;
    for(int i=0;i<N-1;i++){
        if( P[i] == i+1 ){
            swap(P[i], P[i+1]);
            ans++;
        }
    }

    if( P[N-1] == N )   ans++;

    cout << ans << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef float f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int powm(int a, int b, int mod) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int arr[200005];


void solve()
{
   int a,b,c;
   cin>>a>>b>>c;
   a=a-b;
   if(a>c)
    cout<<"0"<<endl;
   else
    cout<<c-a<<endl;

}


signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
 	//cin>>t;
	fr(i,1,t) {
		solve();
	}
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}
/// template by rahuldugar



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n,b,f,r,v,house[4][3][10]={},i,j,k;
    string border(20,'#');
    cin>>n;
    for (i=0;i<n;i++) {
        cin >> b >> f >> r >> v;
        house[b-1][f-1][r-1] += v;
    }
    for (i=0;i<4;i++) {
        for (j=0;j<3;j++) {
            for (k=0;k<10;k++) {
                cout << " " << house[i][j][k];
            }
            cout << endl;
        }
        if (i < 3) cout << border << endl;
    }
    return 0;
}

Measured memory_bytes: 3144
#include <stdio.h>
#include"math.h"
int dig(long int x){
    if((long int)(x/10)==0)return 1;
    else return 1+dig((long int)(x/10));
}
int main(void){
    long int N;
    long int a,b;
    long int min=20000000000;
    scanf("%ld",&N);
    for(int i=1;i<(int)sqrt(N)+5;i++){
        if(N%i==0){
            a=dig(i);
            b=dig((int)(N/i));
            if(a>b)b=a;
            if(min>b)min=b;
        }
    }
    printf("%ld",min);
    return 0;
}


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

using namespace std;

int n;
int a[100005];

void ask(int id) {
    if (a[id]) return;
    cout << id << endl;
    string tmp; cin >> tmp;
    if (tmp[0] == 'V') exit(0);
    if (tmp[0] == 'M') a[id] = 1;
    else a[id] = 2;
}

int differ(int x, int y) {
    if ((x + a[x]) % 2 != (y + a[y]) % 2) return 1;
    return 0;
}

int main(void) {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    ask(0);
    int L = 0, R = n;
    while (1) {
        int M = L + R >> 1;
        ask(M);
        if (differ(L, M)) R = M;
        else L = M;
    }
}


Measured memory_bytes: 980
n = int(input())
a = [int(x) for x in input().split()]

l = []

c = 1
for i in range(1,n):
    if a[i] == a[i-1]:
        c += 1
    else:
        l.append(c)
        c = 1
    if i == n-1:
        l.append(c)

ans = 0

for x in l:
    if x != 1:
        ans += x // 2

print(ans)

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

int main()
{
    int N, X;
    cin >> N >> X;

    vector<int> x(N);
    for (auto& y : x) cin >> y;

    x.push_back(X);
    sort(x.begin(), x.end());

    int a = INT_MAX;
    vector<int> b(N);
    for (int i = 1; i < x.size(); i++) {
        b.push_back(x[i] - x[i - 1]);
        a = min(a, *b.rbegin());
    }

    int t = b[0];
    for (int i = 1; i < b.size(); i++) {
        t = __gcd(t, b[i]);
    }
    cout << t << endl;

    return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(Args&&... args) const { print(std::forward<Args>(args)...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(T&& head, Tail&&... tail) const { std::cout << head, print_rest(std::forward<Tail>(tail)...); }
        template <class T, class... Tail>
        void print_rest(T&& head, Tail&&... tail) const { std::cout << sep << head, print_rest(std::forward<Tail>(tail)...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
    template <class T>
    void print_vec(const std::vector<T>& vec, const char* sep = " ", const char* term = "\n") const {
        const size_t sz = vec.size();
        for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
    }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    ll left = -1, right = N;
    while (right - left > 1) {
        ll mid = (left + right) >> 1;
        ll cur = A[mid];
        bool ok = true;
        for (ll i = 0; i < N; i++) {
            if (i == mid) continue;
            if (A[i] <= cur * 2) {
                cur += A[i];
            }
            else {
                ok = false;
                break;
            }
        }
        if (ok) {
            right = mid;
        }
        else {
            left = mid;
        }
    }

    prints()(N - right);
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3968
# -*- coding: utf-8 -*-
"""
Created on Sat Apr  1 22:07:55 2017

@author: taichiNakamura
"""
import numpy as np
N = int(input())
# スペース区切りの整数の入力
num = list(map(int, input().split()))

num = np.array(num, dtype="int64")
num.sort()
sum = 0

for i in range(N):
    sum += num[3*N - 2 - i*2]
# 出力
print(sum)

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

int main() {
    int N;
    std::string S, T;
    std::cin >> N >> S >> T;

    std::string out;
    for (int i = 0; i < N; ++i) {
        out += S[i];
        out += T[i];
    }

    std::cout << out << std::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;

int main() {
    int N, A[200000];
    cin >> N;
    rep(i,N) cin >> A[i];
    ll ans = 0, l = 0, r = 0, s = 0;
    while (r < N) {
        //cout << l << " " << r << " " << ans << endl;
        if ((s & A[r]) != 0) {
            while ((s & A[r]) != 0) {
                ans += r - l;
                s -= A[l];
                l++;
            }
        }
        s += A[r];
        r++;
    }
    ans += (r - l) * (r - l + 1) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
 
using namespace std;
 
int main(){
    int N; cin>>N;
    vector<vector<double>> coordinate(N,vector<double>(2));
    for(int i=0;i<N;i++){
        for(int j=0;j<2;j++){
            cin>>coordinate.at(i).at(j);
        }
    }
    double sum = 0;
    sort(coordinate.begin(),coordinate.end());
    do{
        for(int i = 0;i<N-1;i++){
            sum = sum + pow((coordinate.at(i).at(1)-coordinate.at(i+1).at(1))*(coordinate.at(i).at(1)-coordinate.at(i+1).at(1))+(coordinate.at(i).at(0)-coordinate.at(i+1).at(0))*(coordinate.at(i).at(0)-coordinate.at(i+1).at(0)),0.5);
        }
    }while(next_permutation(coordinate.begin(),coordinate.end()));
  int fraction=1;
    for(int i = N;i>0;i--){
        fraction*=i;
    }
    cout<<fixed<<setprecision(10)<<sum/fraction<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>
#include <stack>
#include <cassert>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;
using Graph = Vvec<int>;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int k = 0;
    while(B <= A){
        B *= 2;
        k++;
    }
    while(C <= B){
        C *= 2;
        k++;
    }

    if(K < k){
        cout << "No\n";
    }else{
        cout << "Yes\n";
    }
}

Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

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

  std::sort(v.begin(), v.end());
  while(v.size()>1){
    double a = *(v.begin());
    double b = *(std::next(v.begin(), 1));
    v.erase(v.begin());
    v[0] = (a+b)/2.0;
  }
  std::printf("%.9lf\n", v[0]); 
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <cassert>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
int main(){
	int N, M;
	cin >> N >> M;
	int L[M], R[M];
	for(int i = 0; i < M; i++){
		cin >> L[i] >> R[i];
	}
	int mini = 0, maxi = N;
	for(int j = 0; j < M; j++){
		if(L[j] > mini){
			mini = L[j];
		}
		if(R[j] < maxi){
			maxi = R[j];
		}
	}
	if(maxi - mini + 1 >= 0){
		cout << maxi - mini + 1 << endl;
	}
	else{
		cout << 0 << endl;
	}

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 111111;
int a[N], b[N];
int n;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i, 1, n - 1) {
        cin >> b[i];
    }
    b[n] = 1e9;
    int ans = b[1];
    rep(i, 2, n) {
        ans += min(b[i - 1], b[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	basicIO "io"
	"os"
	"strconv"
)

func main() {
	protagonist(os.Stdin, os.Stdout)
}

func protagonist(r basicIO.Reader, w basicIO.Writer) {
	io := NewIO(r, w)
	N, _ := io.nextInt()
	K, _ := io.nextInt()

	io.PutInt(N - K + 1)
}

type IO struct {
	Scanner *bufio.Scanner
	Writer  basicIO.Writer
}

func NewIO(r basicIO.Reader, w basicIO.Writer) *IO {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &IO{
		Scanner: s,
		Writer:  w,
	}
}

func (io *IO) nextString() string {
	io.Scanner.Scan()
	return io.Scanner.Text()
}

func (io *IO) nextInt() (int, error) {
	io.Scanner.Scan()
	i, err := strconv.Atoi(io.Scanner.Text())
	return i, err
}

func (io *IO) PutInt(v int) {
	fmt.Fprintf(io.Writer, "%d\n", v)
}

func (io *IO) PutString(s string) {
	fmt.Fprintf(io.Writer, "%s\n", s)
}


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

int main()
{
    int n;
    int *a,*b;

    do{
        scanf("%d",&n);
    }while(n<2||n>200000);

    a=(int *)malloc(n*sizeof(int));
    b=(int *)malloc(n*sizeof(int));

    for (int i = 0; i < n;i++){
        b[i] = 0;
    }

        for (int i = 1; i < n; i++)
        {
            do
            {
                scanf("%d", &a[i]);
            } while (a[i] < 1 || a[i] > i);
            b[a[i] - 1]++;
        }

    for(int i=0;i<n;i++){
        printf("%d\n",b[i]);
    }

    free(a);
    free(b);

    return 0;
}

Measured memory_bytes: 2984
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  string s;
  cin>>s;
  ll dp[s.size()][13];
  rep(i,s.size()) rep(j,13) dp[i][j]=0;
  if(s[0]=='?') rep(i,10) dp[0][i]=1;
  else dp[0][s[0]-'0']=1;
  rep(k,s.size()-1){
    if(s[k+1]=='?'){
      rep(i,13){
        rep(j,10){
          dp[k+1][(i*10%13+j)%13]+=dp[k][i];
          dp[k+1][(i*10%13+j)%13]%=MOD;
        }
      }
    }else{
      rep(i,13){
        dp[k+1][(i*10+(s[k+1]-'0'))%13]+=dp[k][i];
        dp[k+1][(i*10+(s[k+1]-'0'))%13]%=MOD;
      }
      
      
      
    }
  }
  
  cout<<dp[s.size()-1][5]<<endl;
  
  
  
  
  
  
  
}

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

int n;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	long long a[n], b[n], c[n], dp[n][3];
	for (int i=0; i<n; i++) cin >> a[i] >> b[i] >> c[i];
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for (int i=1; i<n; i++) {
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
		dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
		dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
	}
	cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  
  cin >> A >> B >> C >> D;
  
  if(A + B > C + D)cout << "Left" << endl;
  else if(C + D > A + B)cout << "Right" << endl;
  else cout << "Balanced" << endl;
  
}

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

const int N = 510;

int n;
int x[N];
pair<int,int> a[N];
int res[N * N];
int rem[N];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) rem[i] = n;
	for (int i = 1; i <= n; ++i) cin >> x[i], a[i] = make_pair(x[i], i);
	sort(a + 1, a + n + 1);
	for (int i = 2; i <= n; ++i) if (a[i].first == a[i - 1].first) {
		printf("No\n"); return 0;
	}

	deque <int> dq;
	int ptr = 1;

	for (int pos = 1; pos <= n * n; ++pos) {
		if (a[ptr].first == pos) {
			res[pos] = a[ptr].second; --rem[a[ptr].second];
			if (dq.size() < a[ptr].second - 1) return printf("No\n"), 0;
			int cnt = 0;
			while(cnt < a[ptr].second - 1) {
				int p = dq.front(); dq.pop_front();
				res[p] = a[ptr].second;
				--rem[a[ptr].second];
				++cnt;
			}
			++ptr;
		} else {
			dq.push_back(pos);
		}
	}

	vector<int> REM;
	for (int i = 1; i <= n; ++i) {
		while(rem[a[i].second]--) {
			REM.push_back(a[i].second);
		}
	}
	reverse(REM.begin(), REM.end());

	for (int pos = 1; pos <= n * n; ++pos) {
		if (res[pos]) continue;
		res[pos] = REM.back(); REM.pop_back();
	}

	// check
	ptr = 1;
	for (int pos = 1; pos <= n * n; ++pos) {
		rem[res[pos]]++;
		if (a[ptr].first == pos) {
			if (rem[a[ptr].second] != a[ptr].second - 1) return printf("No\n"), 0;
			++ptr;
		}
	}

	// out
	printf("Yes\n");
	for (int i = 1; i <= n * n; ++i) printf("%d ", res[i]); printf("\n");
}

Measured memory_bytes: 3452