akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int H,W;
	cin>>H>>W;
	REP(i,H){
		string s;
		cin>>s;
		cout<<s<<endl;
		cout<<s<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A1 = [0] + list(map(int, input().split()))
A2 = [0] + list(map(int, input().split()))

R1 = [0] + [0 for _ in range(N)]
R2 = [0] + [0 for _ in range(N)]
for i in range(1, N+1):
    R1[i] = R1[i - 1] + A1[i]
    R2[i] = R2[i - 1] + A2[i]

ans = 0
for i in range(1, N+1):
    ans = max(R1[i] + (R2[N] - R2[i - 1]), ans)

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	int e,y;
	scanf("%d %d",&e,&y);
	switch(e){
	case 0:
		if(y<1912){
			printf("M%d\n",y-1867);
		}else if(y<1926){
			printf("T%d\n",y-1911);
		}else if(y<1989){
			printf("S%d\n",y-1925);
		}else{
			printf("H%d\n",y-1988);
		}
		break;
	case 1:
		printf("%d\n",1867+y);
		break;
	case 2:
		printf("%d\n",1911+y);
		break;
	case 3:
		printf("%d\n",1925+y);
		break;
	default:
		printf("%d\n",1988+y);
	}
	return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <algorithm>
#include <cmath>
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout);
using namespace std;
typedef long long ll;
const int MAXN = 3005;
const int MOD = 1e9 + 7;
int n, m;
ll f[MAXN][MAXN][2], ans;

int main() {
    scanf("%d %d", &m, &n);
    for (int i = 1; i <= m; i++)
        f[0][i][0] = 1;
    f[0][0][1] = 1;
    for (int i = 0, t; i < n; i++) {
        t = i + 1;
        for (int j = 0; j <= m; j++)
            for (int k = 0; k < 2; k++) {
                if (j) {
                    (f[t][j - 1][k | !(j - 1)] += f[i][j][k]) %= MOD;
                    (f[t][j][k | !(j - 1)] += f[i][j][k]) %= MOD;
                }
                if (j != m) {
                    (f[t][j + 1][k] += f[i][j][k]) %= MOD;
                    (f[t][j][k] += f[i][j][k]) %= MOD;
                }
            }
    }
    for (int i = 0; i <= m; i++)
        ans = (ans + f[n][i][1]) % MOD;
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 141056
#include <bits/stdc++.h>
using namespace std;
  
int main() {

  int a, b;
  cin >> a >> b;
  
  int ans = 0;
  
  for(int i=0; i<2; i++)
  {
    if(a>b){
      ans += a;
      a--;
    }else{
      ans += b;
      b--;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  int flag = 0;
  cin>>a>>b>>c;
  
  vector<int> n;
  n.push_back(a);
  n.push_back(b);
  n.push_back(c);
  
  sort(n.begin(), n.end());
  
  for(int i=1;i<3;i++)
  {
    if(n[i] == n[i-1])
      flag++;
  }
  
  if(flag == 1)
    cout<<"Yes"<<endl;
  
  else 
    cout<<"No"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
ll vis[3000] ;
vector < ll > adj[20000] ;
ll ans ;
ll bfs (ll n){
      ll r= 0;
      queue<ll> q ;
      vis[n]=1 ;
      q.push(n) ;

      while(!q.empty()){
            ll s= q.front() ;
            q.pop() ;

            for(auto it :adj[s]){
                if (!vis[it]){
                    vis[it]=vis[s]+1 ;
                    q.push(it) ;
                    r=max(r,vis[it]) ;
                }
            }



      }
    return r-1 ;


}

void solve(){
    ll h , w ,i;
    cin >> h >> w ;

    string s[h+1] ;

    for(i=0;i<h;i++)
        cin >> s[i] ;
    ll j ;
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if (j!=0) { if (s[i][j-1]=='.') adj[i*100+j].push_back(i*100+j-1) ;  }
            if (j!=w) { if (s[i][j+1]=='.') adj[i*100+j].push_back(i*100+j+1) ;  }
            if (i!=0) { if (s[i-1][j]=='.') adj[i*100+j].push_back((i-1)*100+j) ; }
            if (i!=h) { if (s[i+1][j]=='.') adj[i*100+j].push_back((i+1)*100+j) ; }
        }
    }
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            memset(vis, 0, sizeof(vis));
            if (s[i][j]=='.') ans=max(ans,bfs(i*100+j)) ;
        }
    }
    cout << ans << endl ;

}


int main(){

    solve();
    return 0 ;


}



Measured memory_bytes: 768
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using INT = mp::cpp_int;
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll;
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define count2way(v, x) high2way(v, x) - low2way(v, x)
#define lower(v, x) low2way(v, x) - v.begin()       //1番左が0、もし見つから無いならｎを出力
#define higher(v, x) high2way(v, x) - v.begin() - 1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout << a << endl
#define putout2(a, b) \
  putout(a);          \
  putout(b)
#define putout3(a, b, c) \
  putout(a);             \
  putout(b);             \
  putout(c)
#define putout4(a, b, c, d) \
  putout(a);                \
  putout(b);                \
  putout(c);                \
  putout(d)
#define putout5(a, b, c, d, e) \
  putout(a);                   \
  putout(b);                   \
  putout(c);                   \
  putout(d);                   \
  putout(e)
#define Gput(a, b) G[a].push_back(b)
#define cin1(a) cin >> a
#define cin2(a, b) cin >> a >> b
#define cin3(a, b, c) cin >> a >> b >> c
#define cin4(a, b, c, d) cin >> a >> b >> c >> d
#define cin5(a, b, c, d, e) cin >> a >> b >> c >> d >> e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}
ll lcm(ll x, ll y)
{
  ll z = gcd(x, y);
  return x * y / z;
}
INT LCM(INT x, INT y)
{
  INT z = gcd(x, y);
  return x * y / z;
}
ll primejudge(ll n)
{
  if (n < 2)
    return 0;
  else if (n == 2)
    return 1;
  else if (n % 2 == 0)
    return 0;
  double sqrtn = sqrt(n);
  Loop(i, 3, sqrtn + 1)
  {
    if (n % i == 0)
    {
      return 0;
    }
    i++;
  }
  return 1;
}
INT modinv(INT a, INT m)
{
  INT b = m, u = 1, v = 0;
  while (b)
  {
    INT t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}
int main()
{
  cout << fixed << setprecision(30);
  string s;
  cin>>s;
  bool check=true;
  if(s.size()%2==1)check=false;
  loop(i,s.size()){
    if(i%2==0&&s[i]!='h')check=false;
    if(i%2==1&&s[i]!='i')check=false;
  }
  if(check)putout("Yes");
  else putout("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define trav(x, it) for(auto it = x.begin(); it != x.end(); it++)
#define pr(x) cout << #x << " = " << x << endl
#define fill(x,y) memset(x,y,sizeof(x))
#define endl "\n"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

const int mxn = 2e6 + 10;
ll fac[mxn];
ll invfac[mxn];

ll ncr(ll n, ll r)
{
	if(r > n)
		return 0;
	return (((fac[n] * invfac[n - r]) % mod) * invfac[r]) % mod;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	ll k, n, ans = 1, i, rem = 0, val, len;
	fac[0] = invfac[0] = fac[1] = invfac[1] = 1;
	rep(i, 2, mxn)
	{
		fac[i] = (fac[i - 1] * i) % mod;
		invfac[i] = modinv(fac[i]);
	}

	string s;
	cin >> k >> s;	
	n = s.length() + k;
	len = s.length();
	rep(i, 0, len)
	{
		val = (ncr(n, i) * binpow(25LL, n - i)) % mod;
		rem = (rem + val) % mod;
	}
	ans = (binpow(26LL, n) - rem + mod) % mod;
	cout << ans << endl;
}

Measured memory_bytes: 35500
import collections
[n,k] = [int(i) for i in input().split()]
dic = collections.defaultdict(int)
for i in range(n):
  [a,b] = [int(j) for j in input().split()]
  dic[a] += b
keys = sorted(list(dic.keys()))
tmp = 0
for key in keys:
  tmp += dic[key]
  if k <= tmp:
    print(key)
    break
  


Measured memory_bytes: 85780
#include <bits/stdc++.h>
#include <stdio.h>
# define M_PI  3.14159265358979323846
using namespace std;

typedef long long ll;
const int N = 1e5 + 9, M = 9e2 + 9, OO = 0x3f3f3f3f;
const double EPS = 0.00000000001;
const int mod = 1000000000+7;


int n, a[N];


int main(){

  scanf("%d", &n);
  for(int i = 0 ; i < n ; ++i) scanf("%d", a+i);
  sort(a, a+n);
  printf("%d\n", a[n/2]-a[(n/2)-1]);


  return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def cmb(n, k):
    # print(n,k)
    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    a = factorial(n)
    b = factorial(k)
    c = factorial(n - k)
    return a // b // c

def dfs(i, k, lenn, sn):
    if k == 0:
        return 1
    if i == lenn:
        return 0
    if sn[i] == "0":
        return dfs(i + 1, k, lenn, sn)
    return cmb(lenn - i - 1, k) * 9 ** k + cmb(lenn - i - 1, k - 1) * 9 ** (k - 1) * (int(sn[i]) - 1) + dfs(i + 1, k - 1, lenn, sn)

#solve
def solve():
    n, k = IR(2)
    lenn = len(str(n))
    sn = str(n)
    ans = dfs(0,k,lenn,sn)
    print(int(ans))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

struct M {
  using T = struct mms { lint min, max, sum; mms(lint a = numeric_limits<lint>::max(), lint b = numeric_limits<lint>::min(), lint c = 0) : min(a), max(b), sum(c) {} };
  using U = struct lf { lint a, b; lf(lint a = 1, lint b = 0) : a(a), b(b) {} };
  static T op(const T& a, const T& b) { return T{min(a.min, b.min), max(a.max, b.max), a.sum + b.sum}; }
  static void ap(T& a, const U& g, lint k) {
    a.min = g.a * a.min + g.b;
    a.max = g.a * a.max + g.b;
    if (g.a < 0) swap(a.min, a.max);
    a.sum = g.a * a.sum + k * g.b;
  }
  static void ap(U& f, const U& g) { f.a *= g.a; f.b = g.a * f.b + g.b; }
};

template<class M> struct ST {
  using T = typename M::T;
  using U = typename M::U;
  lint n;
  unordered_map<lint, T> t;
  unordered_map<lint, U> u;

  ST(lint n) : n(1LL << 8 * sizeof(lint) - __builtin_clzll(max(n - 1, 1LL))) {}

  void _ap(lint i, const U& f) {
    M::ap(t[i], f, 1 << __builtin_clzll(i) - __builtin_clzll(n));
    if (i < n) M::ap(u[i], f);
  }

  T get(lint l, lint r) {
    _push(l, r);
    T resl, resr;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) resl = M::op(resl, t[l++]);
      if (r & 1) resr = M::op(t[--r], resr);
    }
    return M::op(resl, resr);
  }

  void _push(lint l, lint r) {
    for (lint hl = 8 * sizeof(lint) - __builtin_clzll(l + n) - 1, hr = 8 * sizeof(lint) - __builtin_clzll(r - 1 + n) - 1; hr > 0; hl--, hr--) {
      lint i = r - 1 + n >> hr;
      _ap(2 * i, u[i]);
      _ap(2 * i + 1, u[i]);
      u.erase(i);
      i = l + n >> hl;
      if (i == r - 1 + n >> hr or i >= n) continue;
      _ap(2 * i, u[i]);
      _ap(2 * i + 1, u[i]);
      u.erase(i);
    }
  }

  void set(lint l, lint r, const U& f) {
    _push(l, r);
    for (lint i = l + n, j = r + n; i < j; i >>= 1, j >>= 1) {
      if (i & 1) _ap(i++, f);
      if (j & 1) _ap(--j, f);
    }
    for (l += n; !(l & 1);) l >>= 1;
    while (l >>= 1) t[l] = M::op(t[2 * l], t[2 * l + 1]);
    for (r += n; !(r & 1);) r >>= 1;
    while (r >>= 1) t[r] = M::op(t[2 * r], t[2 * r + 1]);
  }
};

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  ST<M> st(n);
  st.set(0, n, M::U(0, 0));
  for (int i = 0; i < q; i++) {
    int t; cin >> t;
    if (t) {
      int l, r; cin >> l >> r;
      cout << st.get(l, r + 1).min << '\n';
    } else {
      int l, r, x; cin >> l >> r >> x;
      st.set(l, r + 1, M::U(1, x));
    }
  }
}


Measured memory_bytes: 17152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;


int main(){ 

    Int N;
    cin >> N;
    vector<Int> A(N), B(N);

    rep(i,N) cin >> A[i] >> B[i];

    sort(A.begin(),A.end());
    sort(B.begin(),B.end());

    Int Amed, Bmed;

    if (N % 2 == 1) {
        Int indi = N / 2;
        Amed = A[indi];
        Bmed = B[indi];

        cout << Bmed - Amed + 1 << endl;
    }

    else {
        Int indi = N / 2;
        Amed = A[indi - 1] + A[indi];
        Bmed = B[indi - 1] + B[indi];

        cout << Bmed - Amed + 1 << endl;
    }
}

Measured memory_bytes: 6428
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    h,w = LI()
    a = LIR(h)
    b = LIR(h)
    for i in range(h):
        for j in range(w):
            a[i][j] -= b[i][j]
            if a[i][j] < 0:
                a[i][j] *= -1
    d = [(0,1),(1,0)]
    f = [0 for x in range(w)]
    M = (1<<25600)-1
    b = 12800
    f[0] = (1<<(b+a[0][0]))|(1<<(b-a[0][0]))
    for y in range(h):
        ny = y+1
        nf = [0 for x in range(w)]
        for x in range(w):
            nx = x+1
            if nx < w:
                f[nx] |= ((f[x]<<a[y][nx])|(f[x]>>a[y][nx]))
            if ny < h:
                nf[x] |= ((f[x]<<a[ny][x])|(f[x]>>a[ny][x]))
        if ny < h:
            f = [i for i in nf]
    ans = bin(f[w-1])[2:]
    ans = [abs(i-b) for i in range(len(ans)) if ans[len(ans)-i-1] == "1"]
    print(min(ans))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 49372
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<double, null_type, less_equal<double>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define int long long
typedef long long ll;
typedef double dd;
typedef long double ldd;
typedef pair <int, int> pii;
typedef pair <pii , int> ppii;
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define f first
#define s second
#define sz(x) (int)x.size()
#define smin(x , y) x = min(x , y)
#define smax(x , y) x = max(x , y)
#define mp make_pair
#define all(x) x.begin() , x.end()
#define debug(x) cerr<< #x << " = " << x << endl
#define ddebug(x, y) cerr<< #x << " = " << x  << ", " << #y << " = " << y << endl
#define uop(x, y) pii(min(x, y), max(x, y))
#define out return cout << "No" << endl, 0
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
const int mx = 6e3 + 10;
int n, m, fact[mx], inv[mx], C[mx][mx], M2[mx], M3[mx], p[mx];
int _pow(int a, int b){
	if(!b)
		return 1;
	return ((_pow((a * a) % m, b >> 1) * ((b & 1) ? a : 1)) % m);
}
void pre(){
	fact[0] = 1;
	for(int i = 1; i <= 3 * n; i++)
		fact[i] = (fact[i - 1] * i) % m;
	inv[3 * n] = _pow(fact[3 * n] , m - 2);
	for(int i = 3 * n - 1; ~i; i--)
		inv[i] = (inv[i + 1] * (i + 1)) % m;
	for(int i = 0; i <= 3 * n; i++)
		for(int j = 0; j <= i; j++)
			C[i][j] = fact[i] * inv[j] % m * inv[i - j] % m;
	M2[0] = 1;
	for(int i = 2; i <= 3 * n; i += 2)
		M2[i] = M2[i - 2] * C[i][2] % m;
	M3[0] = 1;
	for(int i = 3; i <= 3 * n; i += 3)
		M3[i] = M3[i - 3] * C[i][3] % m;
	p[0] = 1;
	for(int i = 1; i <= 3 * n; i++)
		p[i] = p[i - 1] * 2 % m;
	return;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	pre();
	int ans = 0;
	for(int a = 0; a <= n; a++)
		for(int b = 0; b <= n; b++){
			int c = 3 * n - 3 * a - 2 * b;
			if(c < b)
				continue;
			int cnt = (C[3 * n][3 * a] * p[a] % m * M3[3 * a] % m * inv[a] % m) % m;
			cnt = cnt * (C[3 * n - 3 * a][2 * b] * M2[2 * b] % m * inv[b] % m) % m;
			ans = (ans + cnt) % m;
		}
	cout << ans << endl;
	return 0;
} 


Measured memory_bytes: 280576
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PII pair<int,int>
#define MP make_pair
#define PB push_back
typedef long long LL;
const LL P = 998244353;
const int N = 200010;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n;

int main(){
	//freopen("test.in","r",stdin);
	cin>>n;
	int ans = 0;
	rep(i,1,n){
		if(i<=9 || 100<=i&&i<=999 || 10000<=i&&i<=99999)++ans;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n,l,r,sum=0;cin>>n;
    REP(i,n){
        cin>>l>>r;
        sum+=r-l+1;
    }
    cout<<sum<<endl;
    return 0;
}


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

int main(void){
    // Your code here!
    int H, W;
    cin >> H >> W;
    vector<vector<char>> data(H, vector<char>(W, '\0'));
    rep(i, H) {
        rep(n, W) {
            cin >> data.at(i).at(n);
        }
    }
    bool remove = true;
    rep(i, H) {
        remove = true;
        rep(n, W) {
            if (data.at(i).at(n) != '.')
                remove = false;
        }
        if (remove) {
            rep (n , W) {
                data.at(i).at(n) = '\0';
            }
        }
    }
    rep(i, W) {
        remove = true;
        rep(n, H) {
            if (data.at(n).at(i) == '#')
                remove = false;
        }
        if (remove) {
            rep (n, H) {
                data.at(n).at(i) = '\0';
            }
        }
    }
    rep(i, H) {
        remove = true;
        rep(n, W) {
            if (data.at(i).at(n) != '\0') {
                cout << data.at(i).at(n);
                remove = false;
            }
        }
        if (!remove)
            cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lp(i, n) for (int i = 0; i < n; i++)
#define pb push_back
#define ll long long

string IntToStr(int tmp){
    ostringstream out;
    out << tmp;
    return out.str();
}


int main()
{
    int a[3];
    for(int i=0; i<3; i++)
        cin>>a[i];
    sort(a,a+3);
    cout<<a[0]+a[1]<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			ArrayList<HashSet<Integer>> list = new ArrayList<HashSet<Integer>>();
			ArrayList<HashSet<Integer>> sche = new ArrayList<HashSet<Integer>>();
			for(int i = 0; i < n; i++){
				list.add(new HashSet<Integer>());
				list.get(i).add(i);
				
				sche.add(new HashSet<Integer>());
				int t = sc.nextInt();
				while(t-- > 0){
					int day = sc.nextInt();
					sche.get(i).add(day);
				}
			}
			boolean flg = true;
			for(int day = 0; day < 31; day++){
				HashSet<Integer> today = new HashSet<Integer>();
				for(int i = 0; i < n; i++){
					if(sche.get(i).contains(day)){
						today.add(i);
					}
				}
				
				for(int hum: today){
					for(int hum2: today){
						list.get(hum).addAll(list.get(hum2));
					}
					if(list.get(hum).size() == n){
						System.out.println(day);
						flg = false;
						break;
					}
				}
				
				if(! flg) break;
				
			}
			
			if(flg) System.out.println(-1);
		}
	}

	

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 75528
exps = input().split()

stack = []

for n in exps:
    if n == '+':
        b = stack.pop()
        a = stack.pop()
        stack.append(a + b)
    elif n == '-':
        b = stack.pop()
        a = stack.pop()
        stack.append(a - b)
    elif n == '*':
        b = stack.pop()
        a = stack.pop()
        stack.append(a * b)
    else:
        stack.append(int(n))

print(stack.pop())


Measured memory_bytes: 5596
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let i, j = ref 0, ref 0
let f b = 
        if b then
                (* side effect *)
                (
                        incr i;
                        Printf.printf "Yes\n"
                )
        else
                Printf.printf "No\n"

let () =
        Scanf.sscanf (read_line ()) "%d %d %d" (
                fun _ a b -> 
                        Str.split (Str.regexp "") (read_line ())
                        |> List.iter
                                (function 
                                          "a" ->
                                                f (!i < a + b)
                                        | "b" -> 
                                                (* side effect *)
                                                (
                                                        incr j;
                                                        f (!i < a + b && !j <= b)
                                                ) 
                                        | _ -> 
                                                f false 
                                )
        )


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

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

using namespace std;

const int IINF = INT_MAX;
int W,arr[100100],maxi[100100];

int main(){
  scanf("%d",&W);
  rep(i,W) { scanf("%d",arr+i); maxi[i] = 0; }
  int mini = 0;
  rep(i,W) {
    if( arr[i] == 0 ) mini = IINF;
    else if( arr[i] < 0 ) mini = min(mini-1,-arr[i]);
    else if( mini-1 > 0 ) maxi[i] = max(maxi[i],min(mini-1,arr[i])), --mini;
  }
  mini = 0;
  for(int i=W-1;i>=0;i--){
    if( arr[i] == 0 ) mini = IINF;
    else if( arr[i] < 0 ) mini = min(mini-1,-arr[i]);
    else if( mini-1 > 0 ) maxi[i] = max(maxi[i],min(mini-1,arr[i])), --mini;
  }
  int answer = 0;
  rep(i,W) if( arr[i] > 0 ) answer += maxi[i];
  printf("%d\n",answer);
  return 0;
}

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

int main(){
  bool is_prime[1000000];

  is_prime[0] = is_prime[1] = false;
  for(int i=2; i<1000000; i++){
    is_prime[i] = true;
  }

  for(int i=2; i*i<1000000; i++){
    if(is_prime[i]){
      for(int j=i*i; j<1000000; j+=i){
	is_prime[j] = false;
      }
    }
  }

  int n_prime[1000000];

  int cnt = 0;
  for(int i=0; i<1000000; i++){
    if(is_prime[i]){
      cnt++;
    }

    n_prime[i] = cnt;
  }

  while(true){
    int n;
    cin >> n;

    if(cin.eof())
      break;

    cout << n_prime[n] << endl;
  }

  return 0;
}



Measured memory_bytes: 7960
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <set>

using namespace std;

typedef long long ll;
#define mems(p) memset(p,0,sizeof(p));
#define mp make_pair;

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);}

int main() {
	int n,k;
	cin>>n>>k;
	cout<<n-k+1<<endl;
}

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

using Vertex = int;
using Weight = long long;
struct Edge {Vertex from, to; Weight weight;};
using Graph = vector<vector<Edge>>;

// 逆辺からなるグラフ O(|V| + |E|)
Graph reverse(const Graph& G) {
  Graph H(G.size());
  for(auto& list: G) for(auto& e: list) H[e.to].push_back({e.to, e.from, e.weight});
  return H;
}

// 強連結成分分解 O(|V| + |E|)
vector<vector<Vertex>> strongly_connected_component(const Graph& G) {
  vector<vector<Vertex>> scc;
  stack<Vertex> S;
  vector<bool> inS(G.size());
  vector<int> num(G.size()), low(G.size());
  int timer = 0;
  function<int(Vertex v)> dfs = [&](Vertex v) {
    num[v] = low[v] = ++timer;
    S.push(v); inS[v] = true;
    for(const auto& e: G[v]) {
      if(!num[e.to])     low[v] = min(low[v], dfs(e.to));
      else if(inS[e.to]) low[v] = min(low[v], num[e.to]);
    }
    if(num[v] == low[v]) {
      scc.push_back(vector<Vertex>());
      while(true) {
        auto w = S.top(); S.pop(); inS[w] = false;
        scc.back().push_back(w);
        if(v == w) break;
      }
    }
    return low[v];
  };
  for(Vertex v = 0; v < G.size(); ++v) if(!num[v]) dfs(v);
  return scc;
}

// 帰りがけ順 O(|V| + |E|)
vector<Vertex> postorder(const Graph& G) {
  vector<bool> used(G.size());
  vector<Vertex> order;
  function<void(Vertex)> dfs = [&](Vertex v) {
    used[v] = true;
    for(const auto& e: G[v]) if(!used[e.to]) dfs(e.to);
    order.emplace_back(v);
  };
  for(Vertex v = 0; v < G.size(); ++v) if(!used[v]) dfs(v);
  return order;
}

// トポロジカルソート O(|V| + |E|)
vector<Vertex> topological_order(const Graph& G) {
  return postorder(reverse(G));
}

bool path(const auto& G) {
  vector<Weight> x(G.size());
  for(auto v: topological_order(G)) {
    for(auto e: G[v]) {
      if(x[e.to] && x[e.to] != x[e.from] + e.weight) return true;
      x[e.to] = x[e.from] + e.weight;
    }
  }
  return false;
}

string solve(const auto& G) {
  auto scc = strongly_connected_component(G);
  if(scc.size() != G.size()) return "No";
  if(path(G)) return "No";
  return "Yes";
}

int main() {
  int N, M;
  cin >> N >> M;
  Graph G(N);
  for(auto i = 0; i < M; ++i) {
    int L, R, D;
    cin >> L >> R >> D;
    --L; --R;
    G[L].push_back({L, R, D});
  }

  cout << solve(G) << endl;
}


Measured memory_bytes: 31904
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n ;
    cin >> n ;
    vector<int> v(n) ;
    for(int i = 0; i < n; i++){
        cin >> v[i] ;
    }
    int cash = 1000 , stocks = 0 ;
    int ans = 1000 ;
    for(int i = 0; i < n; i++){
        int cnt = 0 ;
        for(int j = i + 1; j < n; j++){
            if ( v[j] < v[j - 1] ) {
                break ;
            }
            cnt++ ;
        }
        debug() << imie(i) imie(cnt) ;
        if ( cnt > 0 ) {
            int nix = v[i] ;
            int nax = v[i + cnt] ;
            debug() << imie(nix) imie(nax) ;
            stocks = cash / nix ;
            cash = cash - cash / nix * nix ;
            cash += stocks * nax ;
            ans = max(ans, cash) ;
        }
        i = i + cnt ;
    }
    cout << ans << endl;
    return 0; 
}

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

int main() {
    int x;
    cin >> x;
    if (x < 600) cout << 8;
    else if (x < 800) cout << 7;
    else if (x < 1000) cout << 6;
    else if (x < 1200) cout << 5;
    else if (x < 1400) cout << 4;
    else if (x < 1600) cout << 3;
    else if (x < 1800) cout << 2;
    else if (x < 2000) cout << 1;
    return 0;
}


Measured memory_bytes: 3628
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a) { return (a % mod + mod) % mod; }

inline ll add(ll a, ll b) { return take_mod(a + b); }

inline ll sub(ll a, ll b) { return take_mod(a - b); }

inline ll mul(ll a, ll b) { return take_mod(a * b); }

inline ll pow(ll x, ll n) {
  ll res = 1LL;
  while (n > 0) {
    if (n & 1) res = mul(res, x);
    x = mul(x, x);
    n >>= 1;
  }
  return res;
}

ll mod_inv(ll x) { return pow(x, mod - 2); }

void make_fact(ll n) {
  fact[0] = 1;
  ll res = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = res;
    res = mul(res, i + 1);
  }
}

void make_invfact(ll n) {
  invfact[0] = 1;
  invfact[n] = mod_inv(fact[n]);
  for (int i = n - 1; i >= 1; i--) {
    invfact[i] = mul(invfact[i + 1], i + 1);
  }
}

ll perm(ll n, ll k) { return mul(fact[n], invfact[n - k]); }

ll comb(ll n, ll k) { return mul(mul(fact[n], invfact[n - k]), invfact[k]); }

ll ncr(ll n, ll r) {
  ll npr = 1;
  ll rfc = 1;
  rep(i, r) {
    npr = mul(npr, n - i);
    rfc = mul(rfc, r - i);
  }
  ll invrfc = mod_inv(rfc);
  return mul(npr, invrfc);
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll ttn = pow(2LL, n);
  ll nca = ncr(n, a);
  ll ncb = ncr(n, b);

  ll ans = sub(ttn, 1LL);
  ans = sub(ans, nca);
  ans = sub(ans, ncb);

  cout << ans << endl;

  return 0;
}


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

const int N = 100005;
int n, m, ans, cnt[N]; bool vis[N];
int main () {
	cin >> n >> m, ans = 0, vis[1] = 1;
	for (int i = 1; i <= n; ++i) cnt[i] = 1;
	for (int i = 1, x, y; i <= m; ++i) {
		scanf("%d%d", &x, &y);
		--cnt[x], ++cnt[y];
		if (vis[x]) vis[y] = 1;
		if (cnt[x] == 0) vis[x] = 0;
	}
	
	for (int i = 1; i <= n; ++i) ans += vis[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <ctime>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

typedef long long LL;
const int N = 2000010;
const int mod = 1e9 + 7;

LL qpow(LL a, LL b) 
{
	LL ret = 1, base = a;
	while (b) {
		if (b & 1) ret = ret * base % mod;
		base = base * base % mod, b >>= 1;
	}
	return ret;
}

LL p[N], invp[N];

LL C(int a, int b) { return p[a] * invp[b] % mod * invp[a - b] % mod;}

int main()
{
	int h, w, a, b;
	scanf("%d%d%d%d", &h, &w, &a, &b);
	p[0] = 1;
	Rep(i, h + w) p[i] = p[i - 1] * i % mod;
	invp[h + w] = qpow(p[h + w], mod - 2);
	for (int i = h + w - 1; i >= 0; i --){
		invp[i] = invp[i + 1] * (i + 1) % mod;
	}
	LL ans = C(h + w - 2, h - 1);
	
	//printf("%lld\n", ans);
	
	Rep(i, b){
		ans = (ans - C(h - a - 1 + i - 1, i - 1) * C(a - 1 + w - i, w - i) % mod + mod) % mod;
		//printf("%lld %lld\n", C(h - a - 1 + i - 1, i - 1), C(a - 1 + w - i, w - i));
	}
	printf("%lld\n", ans);
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int> > vp;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define out(n) cout << (n) << endl;
#define vut(v) rep(i, v.size()) out(v[i]);

int main() {
  cin.tie(0);
	ios::sync_with_stdio(false);
  int n, m, d[100001] = {0};
  cin >> n >> m;

  int a, b;
  rep(i, 0, m) {
    cin >> a >> b;
    d[a]++, d[b]++;
  }

  rep(i, 0, n + 1) {
    if(d[i] & 1) {
      out("NO")
      return 0;
    }
  }

  out("YES")
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
//#include <fstream>

using namespace std;

int gcd (int a, int b)
{
	if (a > b ){
		swap (a, b );
	} // end if
	while (b % a != 0 ){
		b = b % a;
		if (a > b ){
			swap (a, b );
		} // end if
	} // end while

	return a;
}

int lcm (int a, int b )
{
	int res = a / gcd (a, b );
 	res *= b;

	return res;
}

int main()
{
//	cut here before submit 
//	freopen("testcase.gl", "r", stdin);
	string str = "";

	while (getline (cin, str ) ) {
		int a, b;
		stringstream ss (str );
		ss >> a >> b;
		cout << gcd (a, b ) << ' ' << lcm (a, b ) << endl;
	} // end for

	return 0;
}

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

int h,w;
char mat[1005][1005];
ll dp[1005][1005];

int main() {
    cin >> h >> w;
    for (int i=1;i<=h;i++) {
        for (int j=1;j<=w;j++) {
            cin >> mat[i][j];
        }
    }

    dp[1][0]=1;
    for (int i=1;i<=h;i++) {
        for (int j=1;j<=w;j++) {
            if (mat[i][j]=='#') {continue;}
            dp[i][j]=(dp[i][j-1]+dp[i-1][j])%MOD;
        }
    }
    cout << dp[h][w] << endl;
}


Measured memory_bytes: 12416
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC076A
{
    class Program
    {
        static void Main(string[] args)
        {
            int R,G,c;

            R = int.Parse(Console.ReadLine());
            G = int.Parse(Console.ReadLine());

            c = 2 * G - R;

            Console.WriteLine(c);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]

st_dict = {}

for i in range(N):
    if s[i] not in st_dict.keys():
        st_dict[s[i]] = 1
    else:
        st_dict[s[i]] += 1
for i in range(M):
    if t[i] not in st_dict.keys():
        st_dict[t[i]] = -1
    else:
        st_dict[t[i]] -= 1

if max(st_dict.values()) < 0:
    print(0)
else:
    print(max(st_dict.values()))

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

int main(int argc, char** argv){
  char c;
  bool direction[4];
  for(auto &i:direction){
    i = false;
  }
  while(!cin.eof()){
    cin >> c;
    if(c=='N') direction[0]=true;
    if(c=='W') direction[1] = true;
    if(c=='S') direction[2] = true;
    if(c=='E') direction[3] = true;
  }
  if((direction[0]&&!direction[2])||(!direction[0]&&direction[2])||(direction[1]&&!direction[3])||(!direction[1]&&direction[3])){
    cout << "No";
    return 0;
  }
  cout << "Yes";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
   ll S;
   cin >> S;
   ll mx=1000000000;
   ll k=S/mx;
   ll r=S%mx;
   if(k>=mx){
      cout << 0 << " " << 0 << " " << mx << " " << 0 << " " << 0 << " " << mx << endl;
      return 0;
   }
   cout << 0 << " " << 0 << " " << mx << " " <<  1 << " " << mx-r << " " << k+1 << endl;
   
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef struct {
	int value;
	char suit;
}card;

void BubbleSort(card C[], int N) {
	for (int i = 0; i < N; ++i) {
		for (int j = N - 1; j > i; --j) {
			if (C[j].value < C[j - 1].value) swap(C[j], C[j - 1]);
		}
	}
}

void selectionSort(card C[], int N) {
	for (int i = 0; i < N; ++i) {
		int minj = i;
		for (int j = i; j < N; ++j)
			if (C[j].value < C[minj].value) minj = j;
		if (i != minj) swap(C[i], C[minj]);
	}
}

void printC(card C[], int N) {
	for (int i = 0; i < N; ++i) {
		if (i) cout << " ";
		cout << C[i].suit << C[i].value;
	}
	cout << endl;
}

int main() {
	card C1[36], C2[36];
	int N; cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> C1[i].suit >> C1[i].value;
		C2[i] = C1[i];
	}
	BubbleSort(C1, N);
	printC(C1, N);
	cout << "Stable" << endl;
	selectionSort(C2, N);
	printC(C2, N);
	bool flag = true;
	for (int i = 0; i < N; ++i)
		if (C1[i].suit != C2[i].suit) flag = false;
	cout << (flag ? "Stable" : "Not stable") << endl;

	return 0;
}


Measured memory_bytes: 3088
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    sc.close();
    long now =100;
    int c = 0;
    // Stirng i = 9223372036854775807
    // System.out.println(1); 
    while(N>now){
      now = now + now/100;
      // now = now + (int)(now*0.01);
      c++;
      // System.out.println(c);  
    }
    System.out.println(c);  
  }
  
}




Measured memory_bytes: 35804
N, K = map(int, input().split(" "))

retSum = 0
for b in range(K+1, N+1):
    q = N // b
    r = N - q * b
    if r >= K and r != 0:
        if r == K: retSum += 1
        else:
            if K == 0: retSum += r - K
            else: retSum += r - K + 1
    retSum += q * (b - K)
print(retSum)

Measured memory_bytes: 3060
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
const int INF = 1001001001;
const ll LINF = 1e18;
const ll mod = 1e9 + 7;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}


int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int p; vi as, bs, cs;
    while(cin >> p){
        if(p <= A) as.push_back(p);
        else if (p > A && p <= B) bs.push_back(p);
        else if (p > B) cs.push_back(p);
    }
    int min_s = (int)as.size();
    min_s = min(min_s, (int)bs.size());
    min_s = min(min_s, (int)cs.size());
    cout << min_s << endl;
    return 0;
}



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

const int L = 26;

int main() {
  string word;
  cin >> word;

  int n = word.size();
  bool book[L];
  fill(book, book + L, false);
  for (int i = 0; i < n; ++i) {
    book[word[i] - 'a'] = true;
  }

  if (n < 26) {
    for (int i = 0; i < L; ++i) {
      if (!book[i]) {
        word += i + 'a';
        cout << word << endl;
        return 0;
      }
    }
  }

  for (int i = n - 1; i >= 0; --i) {
    int now = word[i] - 'a';
    for (int j = now + 1; j < L; ++j) {
      if (!book[j]) {
        word.resize(i + 1);
        word[i] = j + 'a';
        cout << word << endl;
        return 0;
      }
    }
    book[now] = false;
  }
  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n[3];
string s;

int main(){
	while(cin>>s){
		bool f=0;
		for(int i=0;i<10;i++){
			int cur=0,a=0;
			fill(n,n+3,0);
			bool f2=1,f3=0,f4=0;
			while(cur<s.size()){
				if(isdigit(s[cur])){
					n[a]=n[a]*10+s[cur]-'0';
					f2=0;
					if(f3&&!i){f4=1;break;}
				}
				else if(s[cur]=='X'){
					n[a]=n[a]*10+i;
					if(f3&&!i){f4=1;break;}
					if(f2)f3=1;
				}
				else {a++;f2=1;f3=0;}
				//if(!i)cout<<cur<<":"<<f2<<f3<<f4<<endl;
				cur++;
			}
			if(n[0]+n[1]==n[2]&&!f4){
				cout<<i<<endl;f=1;break;
			}
		}
		if(!f)cout<<"NA"<<endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;

ll int power(ll int x, ll int y, ll int p)  
{  
   ll int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
 
int main()
{
  fastio();
ll int T;
T=1;

while(T--)
{
ll int n,m,i,j,ans=0,x,y;
cin>>n>>m;
vector<ll int> graph[n+1];
ll int h[n+1];
for(i=1;i<=n;i++)
  cin>>h[i];
for(i=0;i<m;i++)
{
  cin>>x>>y;
  graph[x].push_back(y);
  graph[y].push_back(x);
}
for(i=1;i<n+1;i++)
 { for(j=0;j<graph[i].size();j++)
   {
     if(h[graph[i][j]]>=h[i])
     {
       break;
     }
   }
   if(j==graph[i].size())ans++;}

cout<<ans<<endl;


}


    return 0;
}

Measured memory_bytes: 10272
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, K;
  cin >> N >> K;

  vector<int> A(N);
  REP(i, N) cin >> A[i];
  
  int MAX = 0;
  REP(i, N) chmax(MAX, A[i]);

  int g = A[0];
  REP(i, N) g = __gcd(g, A[i]);

  if(K%g == 0 && K <= MAX) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
bool ispal(string& str, int idx, int len){
  for(int s = 0; s < len; ++s){
    if(str[s + idx] != str[idx + len - s - 1]) return false;
  }
  return true;
}
int main(){
  string str;
  cin >> str;
  string res[] = {"No", "Yes"};
  std::cout << res[ispal(str, 0, str.size()) && ispal(str, 0, str.size() / 2) && ispal(str, str.size() / 2 + 1, str.size() / 2)] << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int INF = 0x3f3f3f3f;

int n;

int id(int a, int b, int c) {
  return a * 301 * 301 + b * 301 + c;
}

void solve(int a, int b, int c) {
  // x = 1 + (tx + e) / n
  // nx = n + (tx + e)
  // x = (n+e)/(n-t)
  vector<double> dp(301 * 301 * 301 + 1, 0.0);
  for (int k=0; k<=300; ++k) {
    for (int j=0; j<=300; ++j) {
      for (int i=0; i<=300; ++i) {
        if (i + j + k == 0 || i + j + k > 300) continue;
        double ex = 0.0;
        if (k > 0) ex += k * dp[id(i, j+1, k-1)];
        if (j > 0) ex += j * dp[id(i+1, j-1, k)];
        if (i > 0) ex += i * dp[id(i-1, j, k)];
        dp[id(i, j, k)] = (double(n) + ex) / double(i + j + k);
      }
    }
  }

  cout << setprecision(19) << dp[id(a, b, c)] << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  int num;
  vector<int> count(4, 0);
  for (int i=0; i<n; ++i) {
    cin >> num;
    ++count[num];
  }
  solve(count[1], count[2], count[3]);
  return 0;
}

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

int main(){
  int n,a1=0,a2=0,a3=0,a4=0;
  cin >> n;
  string s;
  for(int i = 0 ; i < n;i++){
    cin >> s;
    if(s=="AC"){
      a1++;
    } else if(s=="WA"){
      a2++;
    } else if(s=="TLE"){
      a3++;
    } else {
      a4++;
    }
  }
  cout << "AC x " << a1 << endl;
  cout << "WA x " << a2 << endl;
  cout << "TLE x " << a3 << endl;
  cout << "RE x " << a4 << endl;
}

Measured memory_bytes: 3632
N, M = map(int, input().split())

uv = {}
for i in range(M):
    u, v = map(int, input().split())
    if not u in uv:
        uv[u] = [v]
    else:
        uv[u].append(v)


S, T = map(int, input().split())

b = [[False] * (10**5+1) for i in range(3)]
us = [S]
b[-1][S] = True
cnt = 0
while us:
    cnt += 1
    for i in range(3):
        tmpus = []
        for u in us:
            if u in uv:
                for v in uv[u]:
                    if b[i][v] is False:
                        b[i][v] = True
                        tmpus.append(v)
        us = tmpus

    if T in us:
        print(cnt)
        break

if not T in us:
    print(-1)


Measured memory_bytes: 66008