akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9 +7  ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
void solve(){
   int n , k ;
   cin >> n >> k ;
   vector < int > dp(n,0);
   for( int i = 0 ; i < k ; i++){
        int d ;
        cin >> d ;
        for( int j = 0 ; j < d ; j++){
            int x ;
            cin >> x ;
            x--;
            dp[x]++;
        }
   }
   int cnt = 0 ;
    for( int i = 0 ; i < n ; i++){
        if(dp[i]==0) cnt++;
    }
    cout << cnt ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1 ;
    //cin >> t ;
    while(t--){
        solve( );
    }
}


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

int main() {
    ll h, ans = 1;
    cin >> h;
    for (ll i = 1; i < h;)
    {
        i = i * 2 + 1;
        ans = i;
        //cout << i << endl;
        //cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// default code for competitive programming
// ver 3.1415 {{{

// Includes
#include <bits/stdc++.h>

// Defines
#define NAME(x) #x
#define SZ(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, e) for( int i = 0 ; i < (e) ; i++ )
#define ITER(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define REP(i, s, e) for(int i = (s); i <= (e); i++)
#define REPD(i, s, e) for(int i = (s); i >= (e); i--)
#define IOS ios_base::sync_with_stdio( 0 )
#define DEBUG 1
#define fst first
#define snd second
#define PB push_back
#ifdef ONLINE_JUDGE
#define FILE( fn ) \
    freopen(fn".in","r",stdin); \
freopen(fn".out","w",stdout);
#else
#define FILE( fn )
#endif

#ifdef AKAI
#define debug( ... ) fprintf( stderr , __VA_ARGS__ )
#else
#define debug( ... )
#endif

using namespace std;

// Typedefs
typedef double real;
typedef long long ll;
typedef pair<ll, int> pli;
typedef tuple<ll, int> tli;
typedef pair<int, int> pii;
typedef tuple<int, int> tii;
typedef unsigned long long ull;

// Some common const.
const double EPS = 1e-8;
const double Pi = acos(-1);

// Equal for double
bool inline equ(double a, double b)
{return fabs(a - b) < EPS;}

int _R( int& x ) { return scanf( "%d" , &x ); }
int _R( ll& x ) { return scanf( "%" PRId64 , &x ); }
int _R( double& x ) { return scanf( "%lf" , &x ); }
int _R( char* s ) { return scanf( "%s" , s ); }

int R() { return 0; }

  template< typename T1 , typename... T2 >
int R( T1& x , T2&... tail )
{
  int tmp = _R( x );
  return tmp + R( tail... );
}

  template< typename Iter , typename F >
inline void out( Iter s , Iter e , F of )
{
  bool flag = 0;
  for( Iter it = s ; it != e ; it++ )
  {
    if( flag ) printf( " " );
    else flag = 1;
    of( *it );
  }
  puts( "" );
}

// }}}
// start ~~QAQ~~

const int MAXN = 20010;

int n , p[ MAXN ];
int a[ MAXN ] , b[ MAXN ];

int main() {
  R( n );
  REP( i , 1 , n ) R( p[ i ] );
  REP( i , 1 , n ) a[ i ] = i*n;
  int cur = n*n+1;
  REP( i , 1 , n ) {
    int id = p[ i ];
    b[ id ] = cur-a[ id ];
    cur++;
  }
  REP( i , 1 , n ) printf( "%d%c" , a[ i ] , " \n"[ i==n ] );
  REP( i , 1 , n ) printf( "%d%c" , b[ i ] , " \n"[ i==n ] );
}


Measured memory_bytes: 896
S = input()
MOD = 10 ** 9 + 7

dp = [0] * 13
dp[0] = 1

for s in S:
    prev = dp
    dp = [0] * 13
    if s == '?':
        add = range(10)
    else:
        add = [int(s)]
    for i in range(13):
        for a in add:
            dp[(10*i+a)%13] += prev[i]
    dp = [x%MOD for x in dp]
print(dp[5])

Measured memory_bytes: 43884
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef long long ll;

const int    INF = 1000000000;
const int    MOD = 1000000007;
const double EPS = 1e-8;

int main(){
    ll M, r1, r2, c1, c2;
    while(cin >> M >> r1 >> r2 >> c1 >> c2){
        M -= ceil(100.0 * c1 / r1) + ceil(100.0 * c2 / r2);
        if(M < 0) M = -1;
        cout << M << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
N, K = map(int, input().split())
DL = list(map(int, input().split()))
Dlist = [1,1,1,1,1,1,1,1,1,1]
for i in range(len(DL)):
  Dlist[DL[i]]=0

while True:
  f = True
  Nx = str(N)
  for i in range(len(Nx)):
    if Dlist[int(Nx[i])] == 0:
      f = False
  if f:
    print(N)
    break
  else:
    N += 1

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int power = sc.nextInt();
		int number = sc.nextInt();
		if (number == 100) {
			System.out.println((int) Math.pow(100, power) * (number + 1));
			return;
		}
		System.out.println((int) Math.pow(100, power) * number);

	}

}

Measured memory_bytes: 22740
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int cnt = 0, space, work;
		boolean flag;
		char[] target = sc.next().toCharArray();
		
		for(int i=0; i<n; i++){
			char[] old = sc.next().toCharArray();
			flag = true;
			for(int j=0; j<old.length; j++){
				if(target[0]==old[j]){//??????????????????????????£??????
					
					for(int k=j+1; k<old.length; k++){
						if(target[1]==old[k]){//??????????????????????????£??????
							
							space = k-j;
							if(old.length<=space*(target.length-1)+j) break;//??????????????\???????????¨????????£??????
							work = k;
							
							for(int l=2; l<target.length; l++){
								work+=space;
								if(old[work]!=target[l]) break;//??????????????\???????????£??????
								if(l==target.length-1){
									cnt++;
									flag = false;//???????????£???????????§?¬?????????????
								}
							}
							if(flag==false) break;
						}
					}
				}
				if(flag==false) break;
			}
		}
		
		System.out.println(cnt);
		
	}

}

Measured memory_bytes: 27468
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
const ll infl = 1LL << 60;
const int inf = 1 << 30;

ll f(ll b, ll n) {
    if (b > n) return n;
    else return f(b, n / b) + (n % b);
}

ll ceilDiv(ll a, ll b) {
    return (a + b - 1LL) / b;
}

int main() {
    ll n, s; cin >> n >> s;
    ll all = sqrt(n);

    if (n == 1) {
        if (s == 1) {
            cout << 2 << endl;
        }
        else {
            cout << -1 << endl;
        }
        return 0;
    }

    if (s > n) {
        cout << -1 << endl;
        return 0;
    }

    if (s == n) {
        cout << (n + 1LL) << endl;
        return 0;
    }

    for (ll b = 2LL; b <= all; ++b) {
        ll dsum = f(b, n);
        if (dsum == s) {
            cout << b << endl;
            return 0;
        }
    }

    ll k = 1;
    ll ans = infl;
    
    while (true) {
        ll low = ceilDiv(n + 1LL, k + 1LL);
        ll upp = ceilDiv(n + 1LL, k);
        ll cur = (upp + low) / 2LL;

        if (low <= all) {
            break;
        }

        while (upp - low > 1LL) {
            ll dsum = f(cur, n);

            if (dsum < s) upp = cur;
            else low = cur;

            cur = (upp + low) / 2LL;
        }

        if (f(low, n) == s) {
            ans = min(ans, low);
        }

        ++k;
    }

    if (ans != infl) {
        cout << ans << endl;
    }
    else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(void)
{
   int f[31] = {1};
   for(int i = 0;i < 28;i++)
   {
      int a;
      scanf("%d",&a);
      f[a] = 1;
   }
   for(int i = 0;i < 31;i++)
   {
      if(f[i] == 0) printf("%d\n",i);
   }
   return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

long long f(long long N){
    if(N%2){
        return (N+1)/2%2;
    }else{
        return (N/2%2) ^ N;
    }
}

int main(){
    long long A, B;
    cin >> A >> B;
    cout << (f(B) ^ f(A-1)) << endl;
    return 0;
}

Measured memory_bytes: 256
from numpy import sign

n = int(input())
a = list(map(int,input().split()))
b = [sign(a[i+1]-a[i]) for i in range(n-1)]

c = 1
f = 0
for t in b:
  if f == 0:
    f = t
  elif f == 1 and t == -1:
    c += 1
    f = 0
  elif f == -1 and t == 1:
    c += 1
    f = 0
print(c)
    
  

Measured memory_bytes: 23128
import java.awt.Point;
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			Stack<Point> table = new Stack<Point>();
			for (int i = 1; i <= n; i++) {
				int s = sc.nextInt();
				if (i % 2 == 0) {
					if (table.peek().x == s) {
						Point p = table.pop();
						p.y++;
						table.push(p);
					} else {
						Point p = table.pop();
						if (table.empty()) {
							p.x ^= 1;
							p.y++;
							table.push(p);
						} else {
							Point pp = table.pop();
							pp.y += p.y + 1;
							table.push(pp);
						}
					}
				} else {
					if (table.empty()) {
						table.push(new Point(s, 1));
					} else if (table.peek().x == s) {
						Point p = table.pop();
						p.y++;
						table.push(p);
					} else {
						table.push(new Point(s, 1));
					}
				}
				// System.out.println(i);
				// System.out.println(table);
			}
			int ans = 0;

			while (!table.empty()) {
				Point p = table.pop();
				if (p.x == 0) {
					ans += p.y;
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
long long a[55];
long long f[8]={0,0,1,2,3,3};
long long ans;
long long b[55];
long long updata(long long n,long long x)
{
    if(n==1)
    {
        ans+=f[x];
        return f[x];
    }
    else
    {
        if(x>((a[n]+1)/2))
        {
            if(b[n-1]==-1)
            b[n-1]=updata(n-1,a[n-1]);
            if(x!=a[n])
            return b[n-1]+updata(n-1,x-((a[n]+1)/2))+1;
            else
            return b[n-1]+updata(n-1,a[n-1])+1;
        }
        else if(x==(a[n]+1)/2)
        {
            return updata(n-1,a[n-1])+1;
        }
        else
        {
            return updata(n-1,x-1);
        }
    }
}
int main(int argc, char *argv[])
{
    long long n,x;
    cin>>n>>x;
    a[1]=5;
    memset(b,-1,sizeof(b));
    for(int i=2;i<=n;i++)
    {
        a[i]=a[i-1]*2+3;
    }
    ans=0;
    cout<<updata(n,x)<<endl;
    //cout<<ans+(n-1)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>


using namespace std;

int main(){
  int C1,C2,C3,sum,cnt;
  bool card[11];
  while(cin >> C1 >> C2 >> C3){
    for(int i=0;i<=10;i++)card[i] = true;
    card[C1] = card[C2] = card[C3] = false;
    sum = C1+C2; cnt = 0;
    for(int i=1;i<=10;i++)if(card[i] && sum+i <= 20)cnt++;
    cnt*10 >= 35 ? cout << "YES":cout << "NO";
    cout << endl;    

  }
  return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = 10;
        int[] ary = new int[n];
        for (int i = 0; i < n; i++) {
            ary[i] = sc.nextInt();
        }
        
        for (int i = 1; i < n; i++) {
            int value = ary[i];
            for (int j = i-1;; j--) {
                if (j < 0) {
                    break;
                }
                if (ary[j] >= value) {
                    ary[j+1] = value;
                    break;
                }
                ary[j+1] = ary[j];
                ary[j] = value;
            }
        }
        for (int i = 0; i < 3; i++) {
            System.out.println(ary[i]);
        }
    }
}

Measured memory_bytes: 26304
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            temp = i * 500 + j * 100 + k * 50
            if temp == X:
                ans += 1

print(ans)


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

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

    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d.at(i);
    }

    int div = n / 2;
    int cnt = 0, abc;
    sort(d.begin(), d.end());
    for (int i = d.at(div-1); i < d.at(div); i++) cnt++;

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N,M;
  int t[110], p[110], x[110];
  int res=0;
  cin >> N;
  rep(i,N) cin >> t[i];
  cin >> M;
  rep(i,M){
    cin >> p[i] >> x[i];
    p[i]--;
  }
  rep(i,M){
    res=0;
    rep(j,N){
      if(p[i]==j) res+= x[i];
      else res+= t[j];
    }
    cout << res << endl;
  }

}


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

int main() {
	int n;
	int a[110];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n, greater<int>());

	int alice = 0;
	int bob = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			alice += a[i];
		}
		else {
			bob += a[i];
		}
	}
	cout << alice - bob << endl;
}

Measured memory_bytes: 256
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n, k;
	while(cin >> n >> k) {
		vector<int> h(n);
		REP(i, n) cin >> h[i];
		int ans = 0;
		REP(i, n) {
			if(h[i] >= k) {
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long a[] = new long[N+1];
		long b[] = new long[N];

		for (int i = 0; i < N+1; i++) {
			a[i] =sc.nextLong();
		}
		for (int i = 0; i < N; i++) {
			b[i] = sc.nextLong();
		}

		long cnt = 0;
		for (int i = 0; i < N; i++) {
			if (a[i] <= b[i]) {
				cnt += a[i];

				if (a[i+1] >= ( b[i] - a[i])) {
					cnt += (b[i] - a[i]);
					a[i+1] = a[i+1] - ( b[i] - a[i]);
				} else {
					cnt += a[i+1];
					a[i+1] = 0;
				}
			} else {
				cnt += b[i];
			}
		}
		System.out.println(cnt);
	}
}


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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")


signed main() {
    string s;
    cin >> s;
    int h = stoi(s.substr(0,2));
    int t = stoi(s.substr(2,2));
    string ans;
    if (0 < h && h <= 12) {
        if (0 < t && t <= 12) {
            ans = "AMBIGUOUS";
        } else {
            ans = "MMYY";
        }
    } else {
        if (0 < t && t <= 12) {
            ans = "YYMM";
        } else {
            ans = "NA";
        }
    }
    cout << ans << nl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

#define cin_desync()                      \
	do {                                  \
		ios_base::sync_with_stdio(false); \
		cin.tie(0);                       \
	} while (0)                           \

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

typedef long double ld;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int max_N = 1e5 + 10;
int S[max_N], p[max_N];
int a[max_N], deg[max_N];
vector<int> ava[max_N];

int root(int x);
void join(int x, int y);

int main()
{
	cin_desync();

	int N, M;
	cin >> N >> M;

	for (int i = 1; i <= N; ++i) {
		cin >> a[i];
		p[i] = i, S[i] = 1;
	}

	for (int i = 1; i <= M; ++i) {
		int x, y;
		cin >> x >> y;
		++x; ++y;
		join(x, y);
	}

	vector<int> roots;
	for (int i = 1; i <= N; ++i) {
		int r = root(i);
		ava[r].push_back(a[i]);
		if (r == i) {
			roots.push_back(i);
		}
	}

	if (roots.size() == 1) {
		cout << 0 << endl;
		return 0;
	}

	ll ans = 0;
	for (auto &r : roots) {
		sort(ava[r].begin(), ava[r].end(), greater<int>());
		ans += ava[r].back();
		ava[r].pop_back();
		deg[r] = 1;
	}

	set<pii> choose;
	for (auto &r : roots) {
		if (!ava[r].empty()) {
			choose.insert({ava[r].back(), r});
		}
	}

	int f = roots.size();
	for (int i = 0; i < f - 2; ++i) {
		if (choose.empty()) {
			cout << "Impossible" << endl;
			return 0;
		}

		int r = choose.begin() -> second;
		choose.erase(choose.begin());

		++deg[r];
		ans += ava[r].back();
		ava[r].pop_back();

		if (!ava[r].empty() && deg[r] < f - 1) {
			choose.insert({ava[r].back(), r});
		}
	}

	cout << ans << endl;
}

int root(int x)
{
	while (x != p[x]) {
		x = p[x];
	}
	return x;
}

void join(int x, int y)
{
	x = root(x); y = root(y);
	assert(x != y);

	if (S[x] < S[y]) {
		swap(x, y);
	}

	S[x] += S[y];
	p[y] = x;
}


Measured memory_bytes: 7672
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    _ = int(input())
    S = input()

    if len(set(S)) == 1:
        return print(0)

    w = S.count('.')
    b = 0
    ans = w
    for s in S:
        if s == '#':
            b += 1
        else:
            w -= 1
        ans = min(ans, b + w)
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    ll res = 0;
    for (ll i = 1; i < n + 1; ++i) {
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        if (i % 15 == 0) continue;
        res += i;
    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 3640
#include <stdio.h>
 
 
int main(){
 
    int n, m, l;
    int x, y, k;
    long sum;
    int a[100][100], b[100][100];
 
 
    scanf( "%d %d %d", &n, &m, &l );
 
    for( y=0; y<n; y++ ){
    for( x=0; x<m; x++ ){
        scanf( "%d", &a[x][y] );
    }}
 
    for( y=0; y<m; y++ ){
    for( x=0; x<l; x++ ){
        scanf( "%d", &b[x][y] );
    }}
 
 
 
 
    for( y=0; y<n; y++ ){
    for( x=0; x<l; x++ ){
        sum=0;
        for( k=0; k<m; k++ ){
            sum += a[k][y]*b[x][k];
        }
        printf( "%ld", sum );
        if( x != (l-1) ) printf( " " ); 
     
    }printf( "\n" );}
 
 
 
 
 
 
 
    return 0;
 
}

Measured memory_bytes: 680
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    cout << s.substr(0, s.size()-8) << endl;
}

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

int main(void){
  int n;
  cin >> n;
  
  vector<int> length(n);
  
  for (int i = 0; i < n; i++) {
    cin >> length.at(i);
  }
  
  int sum = 0;
  bool check = true;
  
  for (int i = 0; i < n; i++) {
    sum += length.at(i);
  }
  
  for (int i = 0; i < n; i++) {
    if (length.at(i) >= sum - length.at(i)) {
      check = false;
    }
  }
  
  if (check) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010

int main()
{
    ld a,v,b,w,t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;
    ld dist_a=labs(a-b);
    ld v_w=(v-w);
    ld ans=dist_a/v_w;
    if(ans<0||ans>t){
        NO;
    }else{
        YES;
    }
}

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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if(a < b) 
    {
        cout << "a < b" << endl;
    }
    else if(a > b)
    {
        cout << "a > b" << endl;
    }
    else
    {
        cout << "a == b" << endl;
    }

    return 0;    
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
int a,b,c;
cin >> a >> b >> c;
if((b+c)%2==0)cout<<"Alice"<<endl;
else cout<<"Borys"<<endl;
}
 


Measured memory_bytes: 256
import sys
N = int(input())
cor_lis = [0] * N
diff_lis = [0] * N
for n in range(N):
    cor_lis[n] = tuple(map(int, input().split()))
cor_lis = [[0, 0, 0]] + cor_lis
for n in range(N):
    diff_lis[n] = [cor_lis[n + 1][0] - cor_lis[n][0], abs(cor_lis[n + 1][1] - cor_lis[n][1]), abs(cor_lis[n + 1][2] - cor_lis[n][2])]
    if diff_lis[n][0] % (diff_lis[n][1] + diff_lis[n][2]) != 0:
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 27492
#include <bits/stdc++.h>  // ver1.8
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int n,m;
  cin >> n >> m;
  
 /* if(n==1) {
    cout << 1 << endl;
    return 0;
  }*/
  
  string s;
  cin >> s;
  Vi a(0);
  int ct=0;
  
  if(s[0]=='0') a.pb(0);
  
  rep(i,0,n){
    if(ct>=0 && s[i]=='1') ct++;
    else if(ct<=0 && s[i]=='0') ct--;
    else if(ct<0 && s[i]=='1') {
      a.pb(ct);
      ct = 1;
    }
    else if(ct>0 && s[i]=='0'){
      a.pb(ct);
      ct = -1;
    }
  }
  a.pb(ct);
  if(s[n-1]=='0') a.pb(0);
  
  int ans = 0,now = 0;
  int len = 2*m + 1;
  int lena = a.size();
  
  if(lena-2*m <= 0) {
    cout << n << endl;
    return 0;
  }
  
  rep(i,0,(lena-len)/2 + 1){
    now = 0;
    rep(j,2*i,2*i+len){
      now += abs(a[j]);
      			//cout << now <<' ';
    }
    ans = max(ans,now);
    			//cout << now << endl;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1528
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias pred)(int n) {
    foreach(i; 0..n) pred();
}
auto rep(alias pred, T = typeof(pred()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = pred();
    return res;
}

int[] dy = 3.iota.map!"a-1".repeat.take(3).array.join;
int[] dx = 3.iota.map!"a-1".map!(a => a.repeat.take(3).array).array.join;
void main() {
    long H, W;
    int N;
    readf("%d %d %d\n", &H, &W, &N);

    long[] ans = new long[10];

    int[int[2]] aa;
    N.times!({
        int a, b;
        readf("%d %d\n", &a, &b);
        a--; b--;
        foreach(i; 0..dy.length) {
            [a+dy[i], b+dx[i]].pipe!((int[2] p) {
                if (1<=p[0] && p[0]<H-1 && 1<=p[1] && p[1]<W-1) {
                    aa[p]++;
                }
            });
        }
    });

    foreach(v; aa.byValue) {
        ans[v]++;
    }
    ans[0] = (W-2)*(H-2) - aa.length;
    ans.each!writeln;
}


Measured memory_bytes: 56020
S = input()

F = int(S[:2])
B = int(S[2:])

if F == 0 and B == 0:
    print('NA')
elif (F == 0 and B > 12) or (B == 0 and F > 12):
    print('NA')
elif F == 0:
    print('YYMM')
elif B == 0:
    print('MMYY')
elif (F <= 12 and B <= 12):
    print('AMBIGUOUS')
elif F > 12 and B <= 12:
    print('YYMM')
elif F <= 12 and B > 12:
    print('MMYY')
else:
    print('NA')


Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, a[200100], ans=0, i, rmax;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    rmax=a[0];
    for(i=1;i<n;i++){
        if(rmax<a[i]) rmax=a[i];
        else ans+=rmax-a[i];
    }
    cout << ans <<endl;
}

Measured memory_bytes: 5164
/** author: __nishad__ **/
//#pragma GCC optimize(2)
//#pragma GCC optimize(3, "Ofast", "inline")
#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a,b) for(ll i=(a);i<(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;


    int n, num;

    cin>>n;
    vector<int> arr, brr;

    loop(i, 0, n){
        cin>>num;
        arr.pb(num);
    }

    brr = arr;
    sort(all(arr), greater<int>());


    loop(i, 0, n){
        if(brr[i] == arr[0])
            cout<<arr[1]<<endl;
        else
            cout<<arr[0]<<endl;
    }


}





























Measured memory_bytes: 5004
#include<bits/stdc++.h>
using namespace std;
//AtCoder Problem C- Vacation
int solve(vector<vector<int>> mat , int n){
  vector<vector<int>> v(n, vector<int>(3,0));
  v[0][0]  = mat[0][0];
  v[0][1]  = mat[0][1];
  v[0][2]  = mat[0][2];

  for(int i=1;i<n;i++){
    v[i][0] = max(v[i-1][1] , v[i-1][2]) + mat[i][0];
    v[i][1] = max(v[i-1][0] , v[i-1][2]) + mat[i][1];
    v[i][2] = max(v[i-1][1] , v[i-1][0]) + mat[i][2];
  }
  return max(v[n-1][0] , max(v[n-1][1] , v[n-1][2]));
}
int main(){
  int n;
  cin>>n;
  vector<vector<int>> v(n,vector<int> (3));
  for(int i =0; i<n;i++){
    cin>>v[i][0]>>v[i][1]>>v[i][2];
  }
  cout<<solve(v,n);
  return 0;
}

Measured memory_bytes: 19576
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ld long double
#define pa pair<int,int>
#define pii pair<ll,ll>
#define st first
#define nd second
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

int main()
{
  BOOST;
  int n,h;
  cin>>h>>n;
  int tab[n];
  ll sum=0;
  for (int i=0;i<n;i++)
  {
    cin>>tab[i];
    sum+=tab[i];
  }

  if (sum>=h)cout<<"Yes";
  else cout<<"No";
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> P2;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define INF 1145141919
#define MOD 1000000007
int X, N, Q;
vector<P> qs;

struct Node {
  long long a, b, c;
  Node(long long a, int b, int c) : a(a), b(b), c(c) {}
  Node() : a(0), b(0), c(0) {}
  int f(int x) {
    if (x+a <= b) return b;
    else if (x+a>=c) return c;
    return x+a;
  }
};

Node node[200001];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> X >> N;
  vector<int> xs, rs;
  rep(i, N) {
    int r;
    cin >> r;
    xs.pb(r); rs.pb(r);
  }
  cin >> Q;
  rep(i, Q) {
    int t, a;
    cin >> t >> a;
    xs.pb(t);
    qs.pb(P(t, a));
  }
  sort(all(xs)); uniq(xs);
  node[0] = Node(0, 0, X);
  rep(i, xs.size()) {
    int x = xs[i];
    int n = x - (i>0?xs[i-1]:0);
    if (index(rs, x) % 2) {
      // up
      node[i+1] = Node(n, min(n, X), X);
    }
    else {
      node[i+1] = Node(-n, 0, max(X-n, 0));
    }
  }
  rep(i, xs.size()) {
    Node a = node[i], b = node[i+1];
    node[i+1] = Node(a.a + b.a, b.f(a.b), b.f(a.c));
  }
  for (P q : qs) {
    int t = q._1, a = q._2;
    cout << node[index(xs, t)+1].f(a) << "\n";
  }
  return 0;
}


Measured memory_bytes: 8048
#include<stdio.h>

int main(void){
    int a, b, c;
    int cntf = 0;
    int cnts = 0;

    scanf("%d %d %d", &a, &b, &c);

    if(a==5){
        cntf++;
    }
    if(b==5){
        cntf++;
    }
    if(c==5){
        cntf++;
    }

    if(a==7){
        cnts++;
    }
    if(b==7){
        cnts++;
    }
    if(c==7){
        cnts++;
    }

    if(cntf==2&&cnts==1){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    
    return 0;
}

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

int main() {
    int N,M;
    cin >> N >> M;
    long long x[1000], y[1000], z[1000];
    for(int i=0; i<N; ++i) cin >> x[i] >> y[i] >> z[i];

    long long ans = 0;
    for(int k=0; k<8; ++k) {
        vector<long long> A(N,0);
        for(int i=0; i<N; ++i) {
            if(k % 2) A[i] += x[i];
            else A[i] -= x[i];
            if((k >> 1) % 2) A[i] += y[i];
            else A[i] -= y[i];
            if((k >> 2) % 2) A[i] += z[i];
            else A[i] -= z[i];
        }
        sort(A.begin(), A.end(), greater<long long>());
        long long tmp = 0;
        for(int i=0; i<M; ++i) tmp += A[i];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque

R = lambda: map(int, input().split())
n, m = R()
g = [None] + [[] for _ in range(n)]
V = [None] + [False] * n
for _ in range(m):
  u, v = R()
  g[u].append(v)
  g[v].append(u)

q = deque()
r = -1
for u in range(1, n + 1):
  if not V[u]:
    r += 1
    V[u] = True
    q.append(u)
    while q:
      u = q.popleft()
      for v in g[u]:
        if not V[v]:
          V[v] = True
          q.append(v)

print(r)


Measured memory_bytes: 27188
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n,sum=0;
	cin >> n;
	vector<ll>s(n),tenb;
	rep(i, n) {
		cin >> s[i];
		if (s[i] % 10 != 0)tenb.push_back(s[i]);
	}
	sort(all(tenb));
	sum = accumulate(all(s), 0LL);
	if (sum % 10 != 0)return cout << sum << endl, 0;
	else cout << (tenb.size() == 0 ? 0 : sum - tenb[0]) << endl;
}




Measured memory_bytes: 256
dice = map(int, raw_input().split())
inst = raw_input()

for i in range(len(inst)):
    if inst[i] == 'E':
        temp = dice[5]
        dice[5] = dice[2]
        dice[2] = dice[0]
        dice[0] = dice[3]
        dice[3] = temp
    elif inst[i] == 'W':
        temp = dice[5]
        dice[5] = dice[3]
        dice[3] = dice[0]
        dice[0] = dice[2]
        dice[2] = temp
    elif inst[i] == 'N':
        temp = dice[5]
        dice[5] = dice[4]
        dice[4] = dice[0]
        dice[0] = dice[1]
        dice[1] = temp
    elif inst[i] == 'S':
        temp = dice[5]
        dice[5] = dice[1]
        dice[1] = dice[0]
        dice[0] = dice[4]
        dice[4] = temp

print dice[0]

Measured memory_bytes: 6496
n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
#print(n,l)
l.sort(key=lambda x:x[2],reverse=True)

for cx in range(0,101):
    for cy in range(0,101):
        formerH = 0
        H = 0
        flag = 0
        for i in range(n):
            x = l[i][0]
            y = l[i][1]
            h = l[i][2]
            if i == 0:
                formerH = 0
            else:
                formerH = H
            if h == 0:
                if max(H-abs(x-cx)-abs(y-cy),0) != 0:
                    break
            else:         
                H = abs(x-cx)+abs(y-cy)+h
                if i > 0 and H != formerH:
                    break
            if i == n-1:
                a_cx = cx
                a_cy = cy
                a_H = H
                flag = 1
                break
        if flag == 1:
            break
    if flag == 1:
        break

if flag == 1:
    print(a_cx,a_cy,a_H)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <algorithm>
#define ULL unsigned long long
#define INF 0x3f3f3f3f
using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(c+b>a){
        printf("%d",c+b-a);
    }else
    printf("0");
    return 0;
}


Measured memory_bytes: 256
import numpy as np
from sys import stdin

def main():
  s = input()
  n = len(s)
  
  ok = True
  for i in range(n):
    if (i%2 == 1 and s[i] == "R"):
      ok = False
    if (i%2 == 0 and s[i] == "L"):
      ok = False
  
  if (ok):
    str_ = "Yes"
  else:
    str_ ="No"
    
  print(str_)
  
if __name__ == "__main__":
    main()



Measured memory_bytes: 13652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;

int main() {
  ll p, q;
  cin >> p >> q;
  ll g = __gcd(p, q);
  p /= g;
  q /= g;
  ll ans = 1;
  for(ll i = 2; i * i <= q; i++) {
    if(q % i != 0) continue;
    ans *= i;
    while(q % i == 0) q /= i;
  }
  ans *= q;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3100
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
#define STR 10
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        for(int i=0;i<b;i++){
            printf("%d",a);
        }
    }else{
        for(int i=0;i<a;i++){
            printf("%d",b);
        }
    }
    return 0;
}

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

#define ll long long int
#define pi 3.141592653589793238
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007


void solve()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d});
    return;
}

int main()
{
    FAST;
    #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
      #endif
    ll q;
    q=1;
    // sieve();
    // cin>>q;
    while(q--)
        solve();
    return 0;
}


Measured memory_bytes: 3624
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<bitset>
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long ll;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

int A,B,N,S,F,ans;
vector<bool> sub(1001);

int main(){
    cin>>A>>B>>N;
    FOR(i,A,B+1) sub[i] = true;
    FOR(i,0,N){
        cin>>S>>F;
        FOR(i,S,F+1){
            if(S==B || F == A) break;
            if(sub[i]) ans = 1;
        }
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }
 
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
 
inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}
 
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  bool existOdd=false;
  rep(i,n){
    int a; cin>>a;
    if(a&1) existOdd=true;
  }
  if(existOdd) cout<<"first"<<endl;
  else cout<<"second"<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict

N, A = list(map(int, input().split()))
x = list(map(int, input().split()))

x = [x - A for x in x]

counter = defaultdict(int)
counter[0] = 1

for x_i in x:
    copy = dict(counter)
    for d, c in copy.items():
        counter[d+x_i] += c

print(counter[0]-1)


Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)

bool debug=true;

/*    *************************************
	  * Written in New Computer           *
	  * The following code belongs to     *
	  * XiaoGeNintendo of HellHoleStudios *
	  *************************************
*/
template<typename T1,typename T2>ostream& operator<<(ostream& os,pair<T1,T2> ptt){
	os<<ptt.first<<","<<ptt.second;
	return os;
}
template<typename T>ostream& operator<<(ostream& os,vector<T> vt){
	os<<"{";
	for(int i=0;i<vt.size();i++){
		os<<vt[i]<<" ";
	}
	os<<"}";
	return os;
}

string s;
int ssum;

const ll mod=998244353;

int dp[200005][4][4][4];

ll dfs(int pos,int par,int last,bool has){
	if(pos==s.size()){
		return has && par==ssum;
	}
	if(dp[pos][par][last][has]!=-1){
		return dp[pos][par][last][has];
	}
	
	ll ans=0;
	ans+=dfs(pos+1,(par+0)%3,0,(last==0)|has);
	ans+=dfs(pos+1,(par+1)%3,1,(last==1)|has);
	ans+=dfs(pos+1,(par+2)%3,2,(last==2)|has);
	ans%=mod;
	return dp[pos][par][last][has]=ans;
}

inline char get(char a,char b){
	if(a>b){
		swap(a,b);
	}
	if(a=='a' && b=='b'){
		return 'c';
	}
	if(a=='a' && b=='c'){
		return 'b';
	}
	if(a=='b' && b=='c'){
		return 'a';
	}
}

set<string> mp;
void force(string s){
	if(mp.count(s)){
		return;
	}
	mp.insert(s);
	
	string ss=s;
	if(s.size()>=2 && s[0]!=s[1]){
		s[0]=s[1]=get(s[0],s[1]);
		force(s);
	}
	if(ss.size()>=3 && ss[1]!=ss[2]){
		ss[1]=ss[2]=get(ss[1],ss[2]);
		force(ss);
	}
}

void brute(){
	force(s);
//	assert(false);
	cout<<mp.size()<<endl;
}
int main(int argc,char* argv[]){
	cin>>s;
	
	if(s.size()<=3){
		brute();
		return 0;
	}
	
	memset(dp,-1,sizeof(dp));
	
	bool allOne=true,allClear=true;
	
	for(int i=0;i<s.size();i++){
		ssum+=s[i]-'a';
		ssum%=3;
		
		if(s[i]!=s[0]){
			allOne=false;
		}
		if(i!=s.size()-1 && s[i]==s[i+1]){
			allClear=false;
		}
	}
	
	if(allOne){
		cout<<1;
		return 0;
	}
	
	int base=dfs(0,0,3,0);
	
	cout<<(base+allClear)%mod<<endl;
	
	return 0;
}



Measured memory_bytes: 66180
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, x;
    cin >> n >> x;
    vi a(n);
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    x -= sum;
    sort(all(a));
    cout << n + x / a[0];
}

Measured memory_bytes: 256
n = int(input())
blue_card = {}
for _ in range(n):
    s = input()
    if s not in blue_card:
        blue_card[s] = 1
    else:
        blue_card[s] += 1

m = int(input())
red_card = {}
for _ in range(m):
    s = input()
    if s not in red_card:
        red_card[s] = 1
    else:
        red_card[s] += 1
max_diff = 0
for s in blue_card:
    if s not in red_card:
        red_card[s] = 0
    diff = blue_card[s] - red_card[s]
    max_diff = max(max_diff, diff)
print(max_diff)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  int n, m;
  cin >> n >> m;
  int ans = n * (n - 1) / 2 + m * (m - 1) / 2;
  cout << ans;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(void)
{
	int x, y;
	int table[100][100];
	int all = 0;
	scanf("%d%d", &x, &y);
	
	for(int i = 0; i < x; i++){
		for(int j = 0; j < y; j++){
			scanf("%d", &table[i][j]);
		}
	}
	
	for(int i = 0; i < x; i++){
		int end = 0;
		for(int j = 0; j < y; j++){
			printf("%d ", table[i][j]);
			end += table[i][j];
			all += table[i][j];
		}
		printf("%d\n", end);
	}
	for(int i = 0; i < y; i++){
		int end = 0;
		for(int j = 0; j < x; j++){
			end += table[j][i];
		}
		printf("%d ", end);
	}
	printf("%d\n", all);
	
	return 0;
}


Measured memory_bytes: 2112
n = int(input())
l = list(map(int, input().split()))

l.sort(reverse=True)
m = sorted(l)
#print(l)
# print(m)

import bisect

ans = 0
for i in range(n-2):
  a = l[i]
  for j in range(i+1,n-1):
    b = l[j]
    x = a-b
    ind = bisect.bisect_right(m,x)
    #print(a, b, j, ind)
    if n-1-j-ind >= 0:
      ans += n-1-j-ind

print(ans)


Measured memory_bytes: 45320
use std::io;
use std::collections::HashSet;

fn main() {
    let mut values = HashSet::new();
    let n: i32 = get_line().parse().unwrap();
    for _ in 0..n {
        let a: i32 = get_line().parse().unwrap();
        if !values.contains(&a) {
            values.insert(a);
        } else {
            values.remove(&a);
        }
    }
    println!("{}", values.len());
    fn get_line() -> String {
        let mut line = String::new();
        io::stdin().read_line(&mut line).unwrap();
        return String::from(line.trim())
    }
}


Measured memory_bytes: 6396