akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc147/tasks/abc147_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

template <int MOD> struct ModInt {
    static const int Mod = MOD;
    unsigned x;
    ModInt() : x(0) {}
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) {
        if ((x += that.x) >= MOD)
            x -= MOD;
        return *this;
    }
    ModInt &operator-=(ModInt that) {
        if ((x += MOD - that.x) >= MOD)
            x -= MOD;
        return *this;
    }
    ModInt &operator*=(ModInt that) {
        x = (unsigned long long)x * that.x % MOD;
        return *this;
    }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const {
        long long a = x, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            std::swap(a, b);
            u -= t * v;
            std::swap(u, v);
        }
        return ModInt(u);
    }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const {
        ModInt t;
        t.x = x == 0 ? 0 : Mod - x;
        return t;
    }
};
template <int MOD> ostream &operator<<(ostream &st, const ModInt<MOD> a) {
    st << a.get();
    return st;
};
template <int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1;
    while (k) {
        if (k & 1)
            r *= a;
        a *= a;
        k >>= 1;
    }
    return r;
}
typedef ModInt<1000000007> mint;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> v(N);
    for (auto &x : v) {
        cin >> x;
    }

    mint res = 0;
    REP(d, 60) {
        int n0 = 0, n1 = 0;
        for (auto &x : v) {
            if (x >> d & 1) {
                n1++;
            } else {
                n0++;
            }
        }
        mint msk = (1LL << d);
        res += msk * n0 * n1;
    }
    cout << res << endl;
    return 0;
}


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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename Val,typename Number>
//use ll or int for gcd
Val gcd(Val a, Val b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
//count vector and return pair (count,vector item)
template <typename Val,typename Number>
void count_vector(vector<Val>* A,vector<pair<Number,Val>>*R){
  sort(A->begin(),A->end());
  int count = 1;
  rep(i,A->size()){
    if(i<A->size()-1){
      if(A->at(i)==A->at(i+1))count++;
      else{
        R->push_back(make_pair(count,A->at(i)));
        count = 1;
      }
    }else{
      R->push_back(make_pair(count,A->at(i)));
      count = 1;
    }
  }
}

//---------------------------------------------------------------

int main(){
  int N,K,ans;
  ans = 0;
  cin>>N>>K;
  vector<int> A(N);

  rep(i,N){
    cin>>A.at(i);
  }
  vector<pair<int,int>>R;
  count_vector(&A,&R);
  if(R.size()>K){
    sort(R.begin(),R.end());
    rep(i,R.size()-K){
      ans+=R.at(i).first;
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < n; ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define ll long long
using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef  long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
// ui64 mx=1000*1000*1000+3;
// ui64 dp[mx];
int dp[3009][3009];
int main()
{
string m,n;
cin>>m>>n;
int M=m.size(),N=n.size();

for(int i=0;i<=M;i++)
{
	for(int j=0;j<=N;j++)
	{
		if(i==0||j==0)
	{	dp[i][j]=0;
continue;
	}	if(m[i-1]==n[j-1])
		{
			dp[i][j]=1+dp[i-1][j-1];
		}
		else
		dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
	}
}
string ans="";
int len=dp[M][N];
int i=M,j=N;
while(i>0&&j>0)
{

	 if(dp[i][j]==dp[i][j-1])
	{
		j--;
	}
	else if(dp[i][j]==dp[i-1][j])
	{
		i--;
	}
	else
	{
		ans+=m[i-1];
		i--;
		j--;
	}
}
reverse(ans.begin(),ans.end());
cout<<ans;
	return 0;
}


Measured memory_bytes: 35584
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int n, t;
    cin >> n >> t;
    int ans = 1001;
    for(int i = 0; i < n; i++){
        int c, ct;
        cin >> c >> ct;
        if(ct <= t){
            ans = min(ans, c);
        }
    }
    if(ans == 1001){
        cout << "TLE" << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

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


int main(){
 long long n,b,x,m,c=0;
 cin >>n;
 int a[n];
 for(int i=0;i<n;i++)cin >>a[i];

 for(int i=0;i<n;i++){
    if( (i+1)%2!=0 && a[i]%2!=0)c++;

 }
 cout << c << endl;
}


Measured memory_bytes: 3524
import java.util.Scanner;
public class Main {
	public static void main(String args[]){//double 处理果盘
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		System.out.println(a-2*b >= 0 ? a-2*b : 0);
	}
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        long a = sc.nextLong();
        long b = sc.nextLong();
        
        System.out.println(lcm(a, b));
    }
    
    private static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }
    
    private static long lcm(long a, long b) {
        long mult = a * b;
        return mult / gcd(a, b);
    }
}

Measured memory_bytes: 23252
#include <iostream>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

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

    ll x[N];
    for(int i=0; i<N; i++){
        cin >> x[i];
    }

    ll ans = 1000000000;
    for(int i=0; i<N; i++){
        if(i + K - 1 >= N) continue;
        int l = i;
        int r = i + K - 1;
        ll d1 = abs(x[r]) + abs(x[r] - x[l]);
        ll d2 = abs(x[l]) + abs(x[l] - x[r]);
        ll ta = min(d1, d2);
        ans = min(ans, ta);
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1024
#include <math.h>

#include <algorithm>
#include <bitset>
#include <iostream>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;

const int INF = 10000000;
typedef pair<int, int> P;

int main() {
  long long A, B, C, K;
  cin >> A >> B >> C >> K;
  long long ans = 0;
  int total = 0;
  long res = K;
  if (A >= K) {
    cout << K << endl;
    return 0;
  }
  res -= A;
  if (B >= res) {
    cout << A << endl;
    return 0;
  }
  res -= B;
  cout << A - res << endl;

  return 0;
}


Measured memory_bytes: 3636
def modpow(a,n,m):
  res=1
  while n>0:
    if n&1:res=res*a%m
    a=a*a%m
    n//=2
  return res
class mod_comb_k():
  def __init__(self, MAX_N = 10**6, mod = 10**9+7):
    self.fact = [1]
    self.fact_inv = [0] * (MAX_N + 4)
    self.mod = mod
    #if MAX_N > mod:print('MAX_N > mod !')
    for i in range(MAX_N + 3):
      self.fact.append(self.fact[-1] * (i + 1) % self.mod)
    self.fact_inv[-1] = pow(self.fact[-1], self.mod - 2, self.mod)
    for i in range(MAX_N + 2, -1, -1):
      self.fact_inv[i] = self.fact_inv[i + 1] * (i + 1) % self.mod
  def comb(self, n, k):
    if n < k:
      #print('n < k !')
      return 0
    else:return self.fact[n] * self.fact_inv[k] % self.mod * self.fact_inv[n - k] % self.mod
mod=998244353
c=mod_comb_k(mod=mod)
n,m,k=map(int,input().split())
ans=0
for i in range(k+1):
  ans+=modpow(m-1,n-i-1,mod)*c.comb(n-1,i)*m%mod
  ans%=mod
print(ans)

Measured memory_bytes: 162248
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	_, _ = strconv.Atoi(stringLineScan())
	m, _ := strconv.Atoi(stringLineScan())
	py := make([][]int, m)
	x := map[int][]int{}
	for i := 0; i < m; i++ {
		t := make([]int, 2)
		t[0], _ = strconv.Atoi(stringLineScan())
		t[1], _ = strconv.Atoi(stringLineScan())
		py[i] = t
		if val, ok := x[t[0]]; ok {
			x[t[0]] = append(val, t[1])
		} else {
			u := make([]int, 1)
			u[0] = t[1]
			x[t[0]] = u
		}
	}
	for k, _ := range x {
		sort.Ints(x[k])
	}
	y := map[string]string{}
	for k, v := range x {
		for i, w := range v {
			q := make([]int, 2)
			q[0], q[1] = k, w
			y[fmt.Sprint(q)] = fmt.Sprintf("%06d", k) + fmt.Sprintf("%06d", i+1)
		}
	}
	for _, b := range py {
		fmt.Println(y[fmt.Sprint(b)])
	}
}

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

#define vi vector<int>
 
#define ff first
#define ss second
 
#define pb push_back
#define MOD 1000000007
//const int nax = 1e6+5;
#define inf 4e18
 
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "
#define all(v) v.begin(),v.end()
int sqr(int x){return x*x;}
inline int add(int a, int b){ int c = a + b; if(c >= MOD) c -= MOD; return c; }
inline int mul(int a, int b){ return (a * 1ll * b) % MOD; }
inline int sub(int a, int b){ int c = a - b; if(c < 0) c += MOD; return c; }
const int nax = 300*1000 + 10;

int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,c,d;
    int ans = -inf;
    cin>>a>>b>>c>>d;
    if(a<=0 && b>=0)ans  = 0;
    if(c<=0 && d>=0)ans  = 0;
    
    ans = max({ans , a*c , a*d , b*c , b*d});
    cout << ans;
    
   

    return 0;
}
    

// Химаншу
// check overflow
// special case n == 1



Measured memory_bytes: 3648
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
while(1){
int i,j,r,c,cnt,ans=0,sum,l;
static int t[10][10000];
scanf("%d%d",&r,&c);
if(r==0&&c==0)return 0;
for(i=0;i<r;i++){
for(j=0;j<c;j++){
scanf("%d",&t[i][j]);
}
}
for(l=0;l<(1<<r);l++){
sum=0;
for(j=0;j<c;j++){
cnt=0;
for(i=0;i<r;i++){
cnt+=(t[i][j]==((l>>i)&1));
}
sum+=max(r-cnt,cnt);
}
ans=max(ans,sum);
}
printf("%d\n",ans);
}
return 0;
}



Measured memory_bytes: 3580
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#define ull int
using namespace std;
 
const int nmax = 200100;
ull N,n;
ull a[nmax], b[nmax], c[nmax];
ull curmod = 0;
 
void read(){
    cin >> N;
    n = N;
    for(int i=0;i < N; ++i)cin >> a[i];
    for(int i=0;i < N; ++i)cin >> b[i];
}
ull bs(ull a, ull C, ull B, ull A, ull x)
{
    int AA = 1 << x + 1;
	int BB = 3 * (1 << x);
	int CC = 1 << x;
    if(AA!=A || BB != B || CC!=C)
    {
        cout << "YOEOEOEOEOELOEL\n";
        exit(0);
    }
    ull res = 0;
    int ind = lower_bound(c, c+N, C - a) - c;
    res = (res + ind) % 2;
    ind = lower_bound(c, c+N , A - a) - c;
    res = (res - ind % 2 + 2) % 2;
    ind = lower_bound(c, c+N, B - a) - c;
    res = (res + N - ind) % 2; 
    return res;
}
 
 
int Solve(int x)
{
	int A = 1 << x + 1;
	int B = 3 * (1 << x);
	int C = 1 << x;
	for (int i = 0; i < n; i++)
		c[i] = b[i] % A;
	sort(c, c + n);
	int res = 0;
	for (int i = 0; i < n; i++) {
		int ind = lower_bound(c, c + n, C - a[i] % A) - c;
		res = (res + ind) % 2;
		ind = lower_bound(c, c + n, A - a[i] % A) - c;
		res = (res - ind % 2 + 2) % 2;
		ind = lower_bound(c, c + n, B - a[i] % A) - c;
		res = (res + n - ind) % 2; 
	}
	return res;
}
 
void solve(){
    ull ans = 0;
    curmod = 1;
    for(int i = 0; i <= 28; ++i)
    {
        //ans += Solve(i) ? (1 << i) : 0;
        //continue;
        
        vector <ull> bmod;
        for(int j=0; j < N; ++j){
            c[j] = (b[j] % (curmod<<1));
        }
  
//sort(bmod.begin(), bmod.end());
        sort(c, c+N);
        ull cnt = 0;
        for(int j=0;j<N; ++j)
        {
            cnt += bs(a[j] % (curmod << 1), curmod, 3 * curmod , curmod << 1,i );
            //cout << cnt << ' ' << a[j] << endl;
        }
        ans += (cnt & 1) * (curmod);
        //if(curmod==4)break;
        curmod <<=1;
        //cout << "---\n";
    }
    cout << ans << endl;
}
 
int main(){
    read();
    solve();
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ld long double
#define mod 998244353
int main()
{
    ll n,m,h;
    cin>>n>>m>>h;
    ll c[n];
    ll a[n][m];
    for(int x=0;x<n;x++)
    {
        cin>>c[x];
        for(int y=0;y<m;y++)
            cin>>a[x][y];
    }
    ll f=1<<n;
    ll ans=10000000000000000;
    for(int y=0;y<f;y++)
    {
        ll d[m]={0};
        ll co=0;
        for(int x=0;x<n;x++)
        {
            if(y&(1<<x))
            {   co+=c[x];
                for(int z=0;z<m;z++)
                {
                    d[z]+=a[x][z];
                }
            }
        }
        bool j=true;
        for(int x=0;x<m;x++)
        {
            if(d[x]<h)
                j=false;
        }
        if(j)
            ans=min(ans,co);
    }
    if(ans<1e13)
        cout<<ans;
    else
        cout<<-1;
}


Measured memory_bytes: 3596
x1,y1,x2,y2=map(float,input().split())

def dist(a1,b1,a2,b2):
    d = ( (a2 - a1)**2 + (b2 - b1)**2 )**0.5
    return d
    
a = dist(x1,y1,x2,y2)
print("{:.10f}".format(a))



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

int main() {
    int N;
    cin >>N;
    int T=0;
    int H=0;
    for (int i=0; i<N; i++) {
        string TT, HH;
        cin >>TT >>HH;
        if (TT==HH) {
            T++;
            H++;
        } else if (TT > HH)
            T +=3;
        else
            H +=3;
    }
    cout <<T <<' ' <<H <<endl;
    return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using i64 = int64_t;
using u64 = uint64_t;
using u32 = uint32_t;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

constexpr int64_t MOD = 1000000007LL;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)    

template<class T>
std::tuple<T> input() {
    T x; std::cin >> x;
    return std::make_tuple(x);
}

template<class T, class U, class... Args>
std::tuple<T, U, Args...> input() {
    auto first = input<T>();
    auto rest = input<U, Args...>();
    return std::tuple_cat(first, rest);
}

template<class T>
std::vector<T> input_vec(std::size_t size) {
    std::vector<T> vec(size);
    for (std::size_t i=0; i<size; i++)
        cin >> vec[i];
    return vec;
}

template<class T>
std::vector<T> input_vec(std::size_t size, T fill_value) {
    std::vector<T> vec(size, fill_value);
    for (std::size_t i=0; i<size; i++)
        cin >> vec[i];
    return vec;
}

/******************************************************/

void solve() {
    int N; cin>>N;

    ull ans = 0;
    for (int A=1; A*A<=N; A++) {
        for (int B=A; A*B<N; B++) {
            int x = A * B;
            if (x < N) {
                ans += 2;
                ans -= (A == B);
            }
        }
    }
    cout << ans<<endl;
}

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

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define mn(a, b) (a < b ? a : b)
#define mx(a, b) (a > b ? a : b)
#define f first
#define s second
#define all(v) (v).begin(), (v).end()
#define base 331

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > par;

int const MAXn = 3e3 + 3;

int dp[MAXn][MAXn];
par from[MAXn][MAXn];

int main(){

    //freopen(".in","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s, k;
    cin>>s>>k;
    int ts = s.size(), tk = k.size();
    s = " " + s + "$";
    k = " " + k + "$";
    for(int i = 1; i <= ts + 1; i++){
        for(int j = 1; j <= tk + 1; j++){
            if(i <= ts && j <= tk && s[i] == k[j]){
                if(dp[i][j] < dp[i - 1][j - 1] + 1){
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                    if(s[i - 1] == k[j - 1])
                        from[i][j] = {i - 1, j - 1};
                    else
                        from[i][j] = from[i - 1][j - 1];
                }
            }
            if(dp[i][j] < dp[i - 1][j]){
                dp[i][j] = dp[i - 1][j];
                if(s[i - 1] == k[j])
                    from[i][j] = {i - 1, j};
                else
                    from[i][j] = from[i - 1][j];
            }
            if(dp[i][j] < dp[i][j - 1]){
                dp[i][j] = dp[i][j - 1];
                if(s[i] == k[j - 1])
                    from[i][j] = {i, j - 1};
                else
                    from[i][j] = from[i][j - 1];
            }
            if(dp[i][j] < dp[i - 1][j - 1]){
                dp[i][j] = dp[i - 1][j - 1];
                if(s[i - 1] == k[j - 1])
                    from[i][j] = {i - 1, j - 1};
                else
                    from[i][j] = from[i - 1][j - 1];
            }
        }
    }
    par mov = from[ts + 1][tk + 1];
    stack < char > pila;
    while(mov.f != 0 && mov.s != 0){
        pila.push(s[mov.f]);
        par aux = mov;
        mov = from[aux.f][aux.s];
    }
    while(!pila.empty()){
        cout<<pila.top();
        pila.pop();
    }
    return 0;
}
/**
abab
ab
*/


Measured memory_bytes: 105984
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
ll l,r;
int left,right;
const int mod = 2019;
int ans = 2019;

void solve()
{
    if (r-l>=2019) {printf("0\n");return ;}
    left = (int) l%mod;
    right = (int) r%mod;
    for(int i=left;i<right;i++)
    {
        for(int j=i+1;j<=right;j++)
        {
            ans = min(ans,(i*j)%mod);
        }
    }
    printf("%d\n",ans);
    return ;
}

int main()
{
    scanf("%lld%lld",&l,&r);
    solve();
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
#define FIRSTWIN do{cout << "Monocarp\n"; return 0;}while(0)
#define SECONDWIN do{cout << "Bicarp\n"; return 0;}while(0)
 
const int MAXN = 1e5+5;
const int MOD = 1e9+7;
const int INF = 1e9+1;

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    int ans;
    if(s == "MON") ans = 6;
    else if(s == "TUE") ans = 5;
    else if(s == "WED") ans = 4;
    else if(s == "THU") ans = 3;
    else if(s == "FRI") ans = 2;
    else if(s == "SAT") ans = 1;
    else ans = 7;

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
long long int N,ans;
vector<long long> A;
 
int main(){
    scanf("%lld",&N);
    for(int i=0;i<N;++i){
        scanf("%lld",&ans);
        A.push_back(ans);
    }
    partial_sum(A.begin(),A.end(),A.begin());
    ans=1LL<<50;
    auto it=A.begin()+1,ed=A.end()-1,a=A.begin(),b=it+1;
    for(;it+1!=ed;++it){
        while(a+1!=it)
            if(*a<*it-*(a+1)) ++a;
            else break;
        if(b==it)++b;
        while(b+1!=ed)
            if(*b-*it<*ed-*(b+1)) ++b;
            else break;
        ans=min(ans,max({*a,*it-*a,*b-*it,A[N-1]-*b})-min({*a,*it-*a,*b-*it,A[N-1]-*b}));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;
typedef pair<ll, ll> P;

//static const ll MOD = 1000000007;
//static const ll INF = 100000000;

int main() {
    // input
    string S, T;
    cin >> S >> T;

    // process
    cout << T << S << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
int n, A[200002], cnt[1000002], ans = 0;
bool vis[1000002];
int main()
{
	cin >> n;
	loop(i, 0, n)cin >> A[i], cnt[A[i]]++;
	sort(A, A + n);
	if (A[0] == 1)
	{
		if (cnt[1] == 1)cout << 1;
		else cout << 0;
		return 0;
	}
	loop(i, 0, n)
	{
		if (!vis[A[i]])
		{
			if (cnt[A[i]] == 1)ans++;
			for (int j = A[i]; j <= 1000000; j += A[i])
			{
				vis[j] = 1;
			}
		}
	}
	cout << ans;
}


Measured memory_bytes: 9096
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]


def solve():
    a, b = [int(x) for x in input().split()]
    s = input()
    if s[a] == '-' and s.count('-') == 1:
        print("Yes")
    else:
        print("No")
        
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()



"""

1 4
7
RRRR
1 1 0 1
----
4

1 4
47
RCRR
1 1 0 1
----
-1

2 2
10
RR
RR
1 7
4 1
----
4

2 2
10
RR
RR
7 4
7 4
----
-1

3 3
8
RCR
RRC
RRR
1 1 1
1 1 1
1 3 1


3 3
1
RCR
RRC
RRR
1 1 1
1 1 1
1 3 1


"""





Measured memory_bytes: 3316
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def fact(N):
        res = {}
        tmp = N
        for i in range(2, int(N ** 0.5 + 1) + 1):
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if cnt > 0:
                res[i] = cnt
        if tmp != 1:
            res[tmp] = 1
        if res == {}:
            res[N] = 1
        return res


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    H, N = Scanner.map_int()
    A = [0 for _ in range(N)]
    B = [0 for _ in range(N)]
    for i in range(N):
        A[i], B[i] = Scanner.map_int()
    dp = [INF for _ in range(10 ** 4 + 10)]
    dp[0] = 0
    for i in range(H + 1):
        for n in range(N):
            dp[i] = min(dp[i], dp[max(0, i - A[n])] + B[n])
    print(dp[H])


def main():
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 62828
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
main(){
    int X,sum = 0;
    cin >> X;
    for(int i = 1;i < 100000;i++){
        sum += i;
        if(X <= sum){
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bitset<4000005> B;
int n,v,sum;
int main(){
	scanf("%d",&n);
	B[0]=1;
	for(int i=1;i<=n;i++){
		scanf("%d",&v);
		B|=B<<v;
		sum+=v;
	}
	for(int i=(sum+1)/2;i<=sum;i++)
		if(B[i]){
			printf("%d\n",i);
			return 0;
		}
	cout<<"peace & love.";
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

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

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

ll solve(ll n)
{
    if (n==1)
    {
        return 1;
    }
    return 1+2*solve(n/2);
}
int main()
{
    start();
    ll n;
    cin>>n;
    cout<<solve(n);
    return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
#define MAX 100000
#define NIL -1

typedef struct{
    int parent;
    int left;
    int right;
}Node;

Node T[MAX];
int n;
int Depth[MAX];

int getDepth(int i)
{
    int count=0;
    while(T[i].parent!=NIL){
        i=T[i].parent;
        count++;
    }
    return count;
}

void print(int i)
{
    int count,k;
printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,Depth[i]);
    if(T[i].parent==NIL) printf("root, [");
    else if(T[i].left!=NIL) printf("internal node, [");
    else printf("leaf, [");
    
    for(count=0,k=T[i].left;k!=NIL;count++,k=T[k].right){
        if(count==0) printf("%d",k);
        else printf(", %d",k);
    }
    printf("]\n");
}

int main(){
    int i,j,k,child;
    int vertex,degree;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        T[i].parent=NIL;
        T[i].left=NIL;
        T[i].right=NIL;
    }
    for(i=0;i<n;i++){
        scanf("%d%d",&vertex,&degree);
        for(j=0;j<degree;j++){
            scanf("%d",&child);
            if(j==0) T[vertex].left=child;
            else T[k].right=child;
            k=child;
            T[child].parent=vertex;
        }
    }
    for(i=0;i<n;i++) Depth[i]=getDepth(i);
    for(i=0;i<n;i++) print(i);
    return 0;
}

Measured memory_bytes: 2172
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // long longの1次元の型に vll という別名をつける
using vvll = vector<vll>; // long longの2次元の型に vvll という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pll という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
    bool ans=false;
    int n;
    cin>>n;
    vll a(n),b(n);
    rep(i,n)cin>>a.at(i)>>b.at(i);
    rep(i,n-2){
        if(a.at(i)==b.at(i)){
            if(a.at(i+1)==b.at(i+1)){
                if(a.at(i+2)==b.at(i+2))ans=true;
            }
        }
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}



Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;
using ld = double;
template <typename T>
vector<T> Vec(int n, T v)
{
    return vector<T>(n, v);
}
template <class... Args>
auto Vec(int n, Args... args)
{
    auto val = Vec(args...);
    return vector<decltype(val)>(n, move(val));
}

int main()
{
    int M, N;
    cin >> M >> N;
    auto p = Vec(M, N, static_cast<ld>(0.0));
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < N; j++) {
            cin >> p[i][j];
        }
    }
    const int maximum = 1 << M;
    auto dp = Vec(maximum, M, static_cast<ld>(0.0));  // 残りネコ集合=i,戦闘ネコ=k,敵k-1まで倒した の状態から攻略する確率
    for (int i = 0; i < maximum; i++) {
        for (int j = 0; j < M; j++) {
            dp[i][j] = (i & (1 << j)) ? 1 : 0;
        }
    }
    auto sub = vector<ld>(maximum, static_cast<ld>(0.0));
    for (int k = N - 1; k >= 0; k--) {
        fill(sub.begin(), sub.end(), static_cast<ld>(0.0));
        auto tmp = Vec(maximum, M, static_cast<ld>(0.0));
        for (int i = 0; i < maximum; i++) {
            for (int j = 0; j < M; j++) {
                if (i & (1 << j)) {
                    tmp[i][j] = p[j][k] * dp[i][j] + (1 - p[j][k]) * sub[i - (1 << j)];
                    sub[i] = max(sub[i], tmp[i][j]);
                }
            }
        }
        dp = tmp;
    }
    cout << fixed << setprecision(15) << sub[maximum - 1] << endl;

    return 0;
}



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


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define pb push_back
#define mp make_pair
#define snd second
#define fst first
#define debug printf("--%d--\n",__LINE__)
#define ll long long int

ll N;
ll a[131072];

int main(void){
	cin >> N;
	ll sum = 0;
	for(int i=0;i<N;i++){
		cin >> a[i];
		sum += a[i];
	}
	ll sum2 = N * (N+1) / 2;
	if (sum % sum2) {cout << "NO" << endl; return 0;}
	ll m = sum / sum2;
	
	ll cnt = 0;
	for(int i=0;i<N;i++){
		if ((m - a[(i+1)%N] + a[i]) % N){
			cout << "NO" << endl; return 0;
		}
		ll x = (m - a[(i+1)%N] + a[i]) / N;
		if (x < 0){
			cout << "NO" << endl; return 0;
		}
		cnt += x;
	}
	cout << ((cnt==m) ? "YES" : "NO") << endl;
	
	
	
	return 0;
}


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

int main(void){
    int n,d;
    cin >> n >> d;
    
    int x[n][d];
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin >> x[i][j];
        }
    }
    
    int ans(0);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            
            int rout(0);
            for(int k=0;k<d;k++){
                rout += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            
            bool judge(false);
            for(int k=0;k<=rout;k++){
                if(k*k == rout){
                    judge = true;
                }
            }
            
            if(judge){
                ans++;
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3604
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
struct p
{
    int num;
    int p;
    int state[20];
} a[20];
int w[20],n,m,ans=0;
void check()
{
    int flag=1;
    for(int i=1;i<=m;i++)
    {
        int sum=0;
        for(int j=1;j<=a[i].num;j++)
            if(w[a[i].state[j]])
                sum++;
        if(sum%2!=a[i].p)
        {
            flag=0;
            break;
        }
    }
    if(flag)
        ans++;
}
void dfs(int x)
{
    if(x==n+1)
    {
        check();
        return ;
    }
    for(int i=0;i<=1;i++)
    {
        w[x]=i;
        dfs(x+1);
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1; i<=m; i++)
    {
        scanf("%d",&a[i].num);
        for(int j=1; j<=a[i].num; j++)
            scanf("%d",&a[i].state[j]);
    }
    for(int i=1;i<=m;i++)
        scanf("%d",&a[i].p);
    dfs(1);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int r, g, b;
    cin >> r >> g >> b;
    if((r*100+g*10+b)%4 == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>

int n,m;

int main(){
	scanf("%d %d", &n,&m);
	int f[n][m];
	int b[m];
	
	for(int i=0; i<n; ++i){
		for(int j=0; j<m; ++j){
			scanf("%d", &f[i][j]);
		}	
	}
	
	for(int i=0; i<m; ++i){
		scanf("%d",&b[i]);
	}
	

	for(int i=0; i<n; ++i){
		int temp=0;
		for(int j=0; j<m; ++j){
			temp+=f[i][j]*b[j];
		}
		printf("%d\n", temp);
	}
	return 0;
}



Measured memory_bytes: 2740
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////


int main(){

	double R;
	cin >> R;

	cout << fixed << setprecision(10);

	double ans = R * 2.0*acos(-1);

	cout << ans;


	system("PAUSE");
}


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

using namespace std;

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

//#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define cl(x, v) memset((x), (v), sizeof(x))
#define all(x) x.begin(),x.end()
#define sz(x) int(x.size())
#define MOD 1000000007LL
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (( (a)/__gcd((a), (b)) )*(b))

ll memo[110][100010];
ll sum[110][100010];

int v[110];
int n;

ll solve(int k){
	for(int j=0; j<=v[0]; j++){
		memo[0][j] = 1LL;
		sum[0][j] = j+1; 	
	}
	
	for(int j=v[0]+1; j<=k; j++){
		memo[0][j] = 0LL;
		sum[0][j] = sum[0][j-1]; 			
	}
		
	for(int i=1; i<n; i++){		
		memo[i][0] = sum[i-1][0];
		sum[i][0] = memo[i][0]; 	
		for(int j=1; j<=v[i]; j++){
			memo[i][j] = sum[i-1][j];
			sum[i][j] = (sum[i][j-1] + memo[i][j])%MOD; 	
		}
		
		for(int j=v[i]+1; j<=k; j++){
			memo[i][j] = (MOD+(sum[i-1][j] - sum[i-1][j-v[i]-1])%MOD)%MOD;
			sum[i][j] = (sum[i][j-1] + memo[i][j])%MOD; 	
		}
		
	}
	
	return memo[n-1][k];
}

int main() {	
	memset(memo, -1, sizeof(memo));
	cin.sync_with_stdio(0);
	cin.tie(0);
	int k;
	
	cin >> n >> k;
	for(int i=0; i<n; i++){
		cin >> v[i];
	}
	
	cout << solve(k) << endl;

	return 0;	
}


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

using namespace std;

typedef double D;
typedef long long int LL;

#define st first
#define nd second
#define pb push_back
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 1e5 + 7;
const int MX = 1e9 + 7;
const LL INF = 1e18 + 9LL;

int n;
PII st[N];
PII st2[N];

bool vis[N];
bool vis2[N];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i){
		scanf("%d %d", &st[i].st, &st2[i].st);
		st[i].nd = st2[i].nd = i;
	}
	
	sort(st + 1, st + n + 1);
	sort(st2 + 1, st2 + n + 1);
	reverse(st2 + 1, st2 + n + 1);
	
	LL res = INF, sa = 0, sb = 0;
	for(int i = 1; i <= n; ++i)
		sb += st2[i].st;
	res = sb;
	
	int cnt = 0;
	for(int i = 1; i <= n; ++i){
		sb -= st2[i].st;
		sa += st[i].st;
		
		cnt -= vis[st[i].nd] ^ vis2[st[i].nd];
		cnt -= vis[st2[i].nd] ^ vis2[st2[i].nd];

		vis[st[i].nd] = true;
		vis2[st2[i].nd] = true;

		cnt += vis[st[i].nd] ^ vis2[st[i].nd];
		cnt += vis[st2[i].nd] ^ vis2[st2[i].nd];
		
		if(cnt > 0)
			res = min(res, sa + sb);
		else if(i < n){
			res = min(res, sa + sb + st2[i].st - st2[i + 1].st);
			res = min(res, sa - st[i].st + st[i + 1].st + sb);
		}
	}
	
	res = min(res, sa);
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    rep(i,n) {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
  cout << ans << endl;
}

Measured memory_bytes: 256
// In The Name Of God
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define sqr(A) ((A) * (A))
#define X first
#define Y second
#define MP make_pair
#define bsz  __builtin_popcount
#define all(A) A.begin(), A.end()
using namespace std;
using namespace __gnu_pbds;
template < typename T >
using ordered_set = tree < T , null_type , less < T > , rb_tree_tag , tree_order_statistics_node_update >;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

const int N = 1e5 + 20;
vector<int> out[N], in[N], topol;
bool visited[N];
int n, m, par[N], id[N];

void dfs(int v) {
	visited[v] = 1;
	for (int u : out[v])
		if (!visited[u])
			dfs(u);
	topol.push_back(v);
	id[v] = topol.size();
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 0, v, u; i < n - 1 + m; i++) {
		cin >> v >> u;
		out[v].push_back(u);
		in[u].push_back(v);
	}
	for (int i = 1; i <= n; i++)
		if (!visited[i])
			dfs(i);
	par[topol.back()] = 0;
	for (int i = topol.size() - 2; i >= 0; i--) {
		int v = topol[i];
		int p = in[v][0];
		for (int u : in[v])
			if (id[u] < id[p])
				p = u;
		par[v] = p;
	}
	for (int i = 1; i <= n; i++)
		cout << par[i] << endl;
}
























Measured memory_bytes: 16380
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<list>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, a, b;

int main()
{
	cin >> n >> a >> b;
	cout << min(a, b) << " ";
	if (a + b <= n) cout << 0 << endl;
	else cout << a + b - n << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-13;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}

int main(){
	int a;scanf("%d",&a);
	if(a==3){
		printf("2 5 63\n");
		return 0;
	}
	int t2=1;
	int t3=2;
	int t4=1;
	int t6=0;
	a-=4;
	int ad=min(4999,a/2);
	t2+=ad;
	t4+=ad;
	a-=ad*2;
	ad=min(4998,a-a%2);
	t3+=ad;
	a-=ad;
	t6+=a;
	for(int i=0;i<t2;i++)printf("%d ",i*6+2);
	for(int i=0;i<t3;i++)printf("%d ",i*6+3);
	for(int i=0;i<t4;i++)printf("%d ",i*6+4);
	for(int i=0;i<t6;i++)printf("%d ",i*6+6);

	printf("\n");
}

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

const int N = 100000;
int step[N + 1];
bool a[N + 1];

int main(){
	int n, k, buf, mlen = 0;
	bool iszero;
	while(cin >> n >> k, n && k){
		fill(step, step + (N + 1), 0);
		fill(a, a + (N + 1), false);
		iszero = false;
		for(int i = 0;i < k;++i){
			cin >> buf;
			if(buf == 0) iszero = true;
			else a[buf] = true;
		}
		for(int i = 1;i <= n;++i){
			if(a[i]) step[i] = step[i - 1] + 1;
		}
		for(int i = 1;i <= n;++i){
			mlen = max(mlen, step[i]);
		}
		if(iszero){
			queue<int> q;
			for(int i = n - 1;0 < i;--i){
				if(a[i + 1] && a[i]) step[i] = step[i + 1];
			}
			for(int i = 2;i < n;++i){
				if(a[i - 1] && a[i + 1] && !a[i]) q.push(i);
			}
			while(!q.empty()){
				int idx = q.front();
				q.pop();
				mlen = max(mlen, step[idx - 1] + step[idx + 1] + 1);
			}
		}
		cout << mlen << endl;
	}
	return 0;
}

Measured memory_bytes: 1760
#include <iostream>

using namespace std;

int main()
{
    int n,ans=false;
    cin>>n;
    if(n%10==7)ans=true;
    n/=10;
    if(n%10==7)ans=true;
    n/=10;
    if(n%10==7)ans=true;
    if(ans==true)
    {
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> k >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int mx = k + a[0] - a[n - 1];
    for (int i = 0; i < n - 1; i++) {
        mx = max(mx, a[i + 1] - a[i]);
    }
    cout << k - mx << endl;
    return 0;
}

Measured memory_bytes: 1024
using System;

namespace abc107_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            Console.WriteLine(a-b+1);
            Console.Read();
        }
    }
}


Measured memory_bytes: 27556
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#define int long long
using namespace std;
const int INF = 10000000000000;//5000000000000000

signed main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i < N; i++) ans += i;
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;

namespace abc107A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = (A - B) + 1;
            Console.WriteLine(C);
        }
    }
}


Measured memory_bytes: 13140
import numpy as np

n = int(input())
a = list(map(int, input().split()))
na = np.array(a)
total = 0

wh = len([i for i in a if i <= 0])

if wh % 2 == 0 :
    print(sum(np.abs(na)))
else :
    m = min(np.abs(na))
    print(sum(np.abs(na)) - 2*m)

Measured memory_bytes: 23320
#include<iostream>
using namespace std;
int a[10];
int d[10];
int main(){
	int n,k,i,j;
	int m=0,s=0;
	cin>>n>>k;
	for(i=0;i<k;i++){
		cin>>d[i];
	}
	for(i=0;n!=0;i++){
		a[i]=n%10;
		n/=10;
		m++;
	}
	while(1){
		for(i=0;i<m;i++){
			for(j=0;j<k;j++){
				if(a[i]==d[j])s=1;
			}
		}
		if(s==0)break;
		s=0;
		a[0]++;
		for(i=0;i<m;i++){
			if(a[i]>9){
				a[i]-=10;
				a[i+1]++;
				if(i+1==m)m++;
			}else{
				break;
			}
		}
	}
	for(i=m-1;i>=0;i--){
		cout<<a[i];
	}
	return 0;
}

Measured memory_bytes: 256