akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

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

    v_int a(n+3);
    irep(i, m) {
        int tmp;
        cin >> tmp;
        a[tmp] = 1;
    }

    v_int dp(100005);
    dp[0] = 1;

    irep(i, n+1) {
        if(!a[i+1]) { dp[i+1] += dp[i]; dp[i+1] %= MOD; }
        if(!a[i+2]) { dp[i+2] += dp[i]; dp[i+2] %= MOD; }
    }

    cout << dp[n] << endl;

    return 0;
} /*atcoder*/


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

template <typename T>
void print(const T &v);

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n)
    {
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if (n % 2 == 1)
    {
        // A, Bそれぞれの中央値を求める
        int left = a[n / 2];
        int right = b[n / 2];
        cout << right - left + 1 << endl;
        return 0;
    }
    else
    {
        int left = a[n / 2 - 1] + a[n / 2];
        int right = b[n / 2 - 1] + b[n / 2];
        cout << right - left + 1 << endl;
        return 0;
    }
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


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

int x;
bool eval(int left, int right) {
    return (left <= x && x < right);
}

int main() {
  cin >> x;
  for (int left = 400; left <= 1800; left += 200) {
    int right = left + 200;
    if (eval(left, right)) {
      cout << (2000 - left) / 200 << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[4],k;
    cin>>a[1]>>a[2]>>a[3]>>k;
    sort(a+1,a+3+1);
    a[3]*=pow(2,k);
    cout<<a[1]+a[2]+a[3];
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;  //このネームスペースを使う

int main(){
  int D;

  cin >> D ;
  switch (D){
  	case 25:
      cout <<"Christmas"<< endl;
      break;
  	case 24:
      cout <<"Christmas Eve" << endl;
      break;
  	case 23:
      cout <<"Christmas Eve Eve" << endl;
      break;
  	case 22:
      cout <<"Christmas Eve Eve Eve" << endl;
      break;
    default:
      break;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M; cin >> N >> M;
    vector<int> num(M);
    for (int i = 0; i < N; i++) {
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            int a; cin >> a; a--;
            num[a]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < M; i++) {
        if (num[i] == N) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# AOJ 1109: Fermat's Last Theorem
# Python3 2018.7.14 bal4u

from bisect import bisect_left

tbl = [i**3 for i in range(1111)]
while True:
	z = int(input())
	if z == 0: break
	ma = 0
	for x in range(z-1, 0, -1):
		y = bisect_left(tbl, tbl[z]-tbl[x])-1
		if tbl[y] > tbl[x]: break
		ma = max(ma, tbl[x]+tbl[y])
	print(tbl[z]-ma)


Measured memory_bytes: 5640
#include <stdio.h>
#define HEAP 500000

void maxHeapify(int *, int);
void buildMaxHeap(int *);
int n;

int main(){
  int i, key[HEAP];

  scanf("%d", &n);

  for(i = 1; i <= n; i++){
    scanf("%d", &key[i]);
  }

  buildMaxHeap(key);

  for(i = 1; i <= n; i++)
    printf(" %d",key[i]);
  printf("\n");

  return 0;
}

void maxHeapify(int *A, int i){
  int left, right, largest, tmp;
  left = i * 2;
  right = i * 2 + 1;
  
  if(left <= n && A[left] > A[i])
    largest = left;
  else largest = i;
  
  if(right <= n && A[right] > A[largest])
    largest = right;
  
  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A, largest);
  }
}

void buildMaxHeap(int *A){
  int i;

  for(i = n / 2; i >= 1; i--)
    maxHeapify(A, i);
}

Measured memory_bytes: 2552
import java.util.Random;
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Random rand = new Random();
    Scanner stdIn = new Scanner(System.in); int j = 0;

    double[] ans = new double[1000];
    while (true) {
       int n = stdIn.nextInt();
       if (n == 0) break;
    int[] s = new int[n];
    double m=0;
    for (int i = 0; i < n; i++) {
      s[i] = stdIn.nextInt();
      m += s[i];
    }
    if (m != 0)
    m /= n;
    else 
    m = 0;
    double sd=0;
    for (int i = 0; i < n; i++) {
      sd += (s[i] - m) * (s[i] - m);
    } sd = Math.sqrt(sd/n);
      ans[j++] = sd;
    }

    for(int i = 0; i < j; i++)
      System.out.printf("%.8f\n", ans[i]);
   
  }
}


Measured memory_bytes: 33804
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  int a;
  string b;
  cin>>a>>b;
  if(3200<=a)
    cout<<b;
  else
    cout<<"red";
}


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

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,n) loop(i,0,n)

typedef vector<string> vs;
typedef vector<int> vi;

pair<int,int> solve(vs G){
    int w = G[0].size(), h = G.size(), res_area = 0;
    pair<int,int> res;
    vi dp(w+1);
    rep(y, h){
        stack<pair<int,int> > s;
        rep(x, w+1){
            dp[x]= (G[y][x] == '.' /* free? */) ? dp[x] + 1 : 0;
            int l = x;
            while(!s.empty() && dp[x] < s.top().first){
                int th = s.top().first, tw = x - s.top().second;
                int area = tw*th;
                if(res_area < area){
                    res_area = area;
                    res = make_pair(tw,th);
                }
                l = s.top().second;
                s.pop();
            }
            s.push(make_pair(dp[x],l));
        }
    }
    return res;
}

int main(){
    for(int h,w;cin>>h>>w,h|w;){
        vs G(h);
        rep(y,h) cin >> G[y];
        auto ans = solve(G);
        cout << ans.first * ans.second << endl;
    }
}

Measured memory_bytes: 1728
#include<iostream>
#include<cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
int mod=1e9+7;
int q_pos(ll x,int n){
	ll res=1;
	while(n){
		if(n&1) res=(res*x)%mod; 
		n>>=1;
   		x=(x*x)%mod; 
  }
  return res;
}
int main()
{ll n; 
 cin>>n;
 cout<<((q_pos(10,n)-(2*q_pos(9,n))+q_pos(8,n))%mod+mod)%mod;
 return 0;
}


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

#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define rrep(i, a, b) for (int i = int(a) - 1; i >= b; i--)
#define sz(x) (int)(x).size()

using namespace std;
using ll = long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main() {
  int a, b;
  cin >> a >> b;
  rep(i, 1, 100000) {
    int ei = (double)i * 0.08;
    int te = (double)i * 0.1;
    if (ei == a && te == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll R,G,B,N;
    cin >> R >> G >> B >> N;
    ll r = N/R;
    ll g = N/G;
    ll out = 0;
    rep(i,r+1){
        rep(j,g+1){
            if((N-i*R-j*G)%B==0&&(N-i*R-j*G)/B>=0){
                out++;
            }
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define endl "\n"
    #define space " "
    #define ll long long int
    #define vl vector<ll>
    #define vvl vector < vll >
    #define pii pair<int,int>
    #define pll pair<ll,ll>
    #define vpl vector < pll >
    #define mod 1000000007
    #define pi 3.1415926535897932384626433
    #define inf 1000000000000000001;
    #define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y) 
    #define mem(a,val) memset(a,val,sizeof(a))
    #define pb push_back
    #define f first
    #define s second
    
    void solve()
    {
        int n; cin>>n;
        cout<<n+pow(n,2)+pow(n,3);
    }

    signed main()
    {

    fast;
    #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
     #endif

    ll T=1;
    // cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
    }


Measured memory_bytes: 4176
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-22 15:47:32
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

inline unsigned long long fast_gcd(unsigned long long x, unsigned long long y) {
  int shift;
  if (x == 0) return y;
  if (y == 0) return x;
  shift = __builtin_ctzll(x | y);
  x >>= __builtin_ctzll(x);
  do {
    y >>= __builtin_ctzll(y);
    if (x > y) std::swap(x, y);
    y -= x;
  } while (y);
  return x << shift;
}

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

  int n, x; cin >> n >> x;
  vector<int> a(n); cin >> a;
  for (int& e : a) e = abs(e - x);
  cout << accumulate(all(a), 0, [](int p, int q){ return fast_gcd(p, q); }) << endl;

  return 0;
}

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

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);

    cout << a[2] * 10 + a[0] + a[1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <string>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int first_digit(int n) {
	while (n) {
		if (n / 10 == 0) {
			return n % 10;
		}

		n /= 10;
	}

	return 0;
}

int last_digit(int n) {
	return n % 10;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<vector<int> > c(10, vector<int> (10));
	for (int i = 1; i <= n; ++i) {
		int f = first_digit(i);
		int l = last_digit(i);
		++c[f][l];
	}

	long long ans = 0;
	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			ans += c[i][j] * c[j][i];
		}
	}

	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 3664
#include "bits/stdc++.h"
using namespace std;

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

const int INF = 1000000007;

int main(void){
	set<char> st;
	string S; cin>>S;

	for(int i=0;i<S.size();i++)	st.insert(S[i]);

	bool can = false;
	if(S.size() == st.size()) can = true;

	if(can) printf("yes\n");
	else printf("no\n");

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner  scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] input = new int[n];
		for(int i = 0; i < n; i++) {
			input[i] = scan.nextInt();
		}
		
		Arrays.sort(input);
		System.out.println(input[n - 1] - input[0]);
		scan.close();
	}
}


Measured memory_bytes: 21844
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin>>n;
	vi v(n);
	rep(i,n){
		cin>>v[i];
	}
	int c = 0;
	rep(i,n){
		if(v[i]!=i+1)c++;
	}
	if(c == 2 || c == 0){
		cout<<"YES";
	}
	else{
		cout<<"NO";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(n,v) for(int64_t i=0;i<(n);i++){cin >> (v).at(i);}

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  I n,q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<P> lr(q);
  REP(i,q){
    cin >> lr.at(i).first >> lr.at(i).second;
  }
  V loc;
  char prev;
  REP(i,s.size()){
    if (prev == 'A' && s.at(i) == 'C'){
      loc.push_back(i+1);
    }
    prev = s.at(i);
  }
  REP(i,q){
    I t=0;
    auto start = lower_bound(ALL(loc), lr.at(i).first+1);
    auto end = upper_bound(ALL(loc), lr.at(i).second);
    t = end - start;
    cout << t << endl;
  }
  return 0;
}



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

int N, M;
int p;
int ac[100001];
int wa[100001];
string S;

int main()
{
  int i;
  int acn, wan;

  for (i=1; i<=N; i++) {ac[i]=0;wa[i]=0;}
  cin >> N >> M;
  for (i=0; i<M; i++) {
    cin >> p >> S;
    if (S == "AC") ac[p] = 1;
    if (S == "WA" && ac[p] == 0) wa[p]++;
  }

  acn=0; wan=0;
  for (i=1; i<=N; i++) {
    acn += ac[i];
    if (ac[i]) wan += wa[i];
  }

  printf("%d %d\n", acn, wan);

  return 0;
}


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

int main() {
  long long N;
  cin >> N;
  long long ans = 100000000;
  for (long long i = 1; i <= sqrt(N); i++) {
    if (N % i == 0) {
      long long j = N / i;
      long long digit_i = to_string(i).size();
      long long digit_j = to_string(j).size();
      long long tmp = max(digit_i, digit_j);
      ans = min(ans, tmp);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	static int goal;
	static int items;
	static int[] list;
	static int[][] cache;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		goal = sc.nextInt();
		items = sc.nextInt();
		list = new int[items];
		cache = new int[goal + 1][items];
		for (int i = 0; i < items; i++) {
			int a = sc.nextInt();
			list[i] = a;

		}

		System.out.println(compute(goal, items - 1));
		sc.close();
	}

	public static int compute(int value, int last) {
		

		if (value == 0) {
			return 0;
		}
		if (last < 0 || value < 0) {
			return Integer.MAX_VALUE / 2;
		}
		if (cache[value][last] != 0) {
			return cache[value][last];
		}

		int include = 1 + compute(value - list[last], last);
		int exclude = compute(value, last - 1);

		cache[value][last] = Math.min(include, exclude);
		return Math.min(include, exclude);

	}

}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(m);
    rep(i,m) {
        int l, r;
        cin >> l >> r;
        a[i].push_back(l);
        a[i].push_back(r);
    }
    int ans_l = 0;
    int ans_r = 1e9;
    rep(i,m) {
        ans_l = max(a[i][0],ans_l);
    }
    rep(i,m) {
        ans_r = min(a[i][1],ans_r);
    }
    if (ans_l <= ans_r) {
        cout << ans_r - ans_l + 1 << endl;
    } else cout << 0 << endl;
}

Measured memory_bytes: 5760
#!/usr/bin/env python3
import sys


def solve(N: int, M: int):
    print((M * 1900 + (N - M) * 100) * 2 ** M)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef double d;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}

vector<vector<ll> > MatMul(vector<vector<ll> > &A,vector<vector<ll> > &B,ll n)
{
    vector<vector<ll> > C(n,vector<ll>(n,0));
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<n;j++)
        {
            C[i][j] = 0;
            for(ll k=0;k<n;k++)
            {
                ll p = (A[i][k]*B[k][j])%M;
                C[i][j] = (C[i][j] + p)%M;
            }
        }
    }
    return C;
}
vector<vector<ll> > MatPower(vector<vector<ll> > &G,ll n,ll p)
{
    if(p==0)
    {
        vector<vector<ll> > v(n,vector<ll>(n,0));
        for(ll i=0;i<n;i++){v[i][i]=1;}
        return v;
    }
    if(p==1)
    {
        return G;
    }
    vector<vector<ll> > G2 = MatPower(G,n,p/2);
    G2 = MatMul(G2,G2,n);
    if(p&1)
    {
        G2 = MatMul(G,G2,n);
    }
    return G2;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll k;
    cin>>k;
    vector<vector<ll> > G(n,vector<ll>(n,0));
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<n;j++)
        {
            cin>>G[i][j];
        }
    }
    vector<vector<ll> > ans = MatPower(G,n,k);
    ll fans=0;
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<n;j++)
        {
            fans=(fans+ans[i][j])%M;
        }
    }
    cout<<fans;
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
#define int             long long
#define ld              long double
#define fi              first
#define se              second
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define fo(i,n)         for(i=0; i<n; i++)
#define fo1(i,n)        for(i=1; i<=n; i++)
#define Fo(i,k,n)       for(i=k; k<=n?i<=n:i>=n; k<=n?i++:i--)
#define all(x)          x.begin(), x.end()
#define rall(x)         x.rbegin(), x.rend()
#define sortall(x)      sort(all(x))
#define sortrall(x)     sort(rall(x))
#define clr(x)          memset(x, 0, sizeof(x))
#define tr(it, a)       for(auto it = a.begin(); it != a.end(); it++)
#define pii             pair<int, int>
#define mk(arr,n,type)  type *arr = new type[n];
#define vi              vector<int>
#define si              set<int>
#define usi             unordered_set<int>
#define mii             map<int, int>
#define umii            unordered_map<int, int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int, vi, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define trailzrobits(x) __builtin_ctzll(x)
#define leadzrobits(x)  __builtin_clzll(x)
#define paritybits(x)   __builtin_parityll(x)
#define gcd             __gcd
#define lcm(x, y)       (x * y) / gcd(x, y)
#define mod             1000000007
#define endl            '\n'
#define PI              3.1415926535897932384626
#define inf             1e18
#define sp(x,y)         fixed<<setprecision(y)<<x
void __print(int32_t x) {cout<<x;}
void __print(int x) {cout<<x;}
void __print(ld x) {cout<<x;}
void __print(double x){cout<<x;}
void __print(float x){cout<<x;}
void __print(bool x) {cout<<(x?"true":"false");}
void __print(char x){cout <<'\''<<x<<'\'';}
void __print(const char *x){cout <<'\"' <<x<<'\"';}
void __print(const string &x) {cout<<'\"'<<x<<'\"';}
template<typename T,typename V>     void __print(const pair<T,V> &x) {cout<<'{';__print(x.first);cout<<',';__print(x.second);cout<<'}';}
template<typename T>                void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}void _print() {cout << "]\n";}
template <typename T,typename... V> void _print(T t, V... v) {__print(t);if(sizeof...(v))cout<<", ";_print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_print(x)
#else 
#define dbg(x...)
#endif
int power(int base, int exp){ int res = 1; base %= mod; while(exp > 0){ if(exp & 1) res = (res * base) % mod; base = (base * base) % mod; exp = exp >> 1; } return res; }
int inv(int x){ return power(x, mod - 2) % mod; }
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++




const int N = 1e6 + 6, M = N;
int i, j;

void solve(){
    
    int n; cin>>n;
    vi a(n);
    int xr=0;
    fo(i,n){ cin>>a[i]; xr^=a[i];}
    
    fo(i,n) cout<<(xr^a[i])<<" ";
    cout<<endl;
    
    
}




int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1;
    // cin >> t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 4692
class Main{
    public static void main(String[] a){

int i,j, k;
		for(i=1; i<=9; ){
			for(j=1; j<=9; j++){
				k = i*j;
				System.out.println(i + "x" + j + "=" + k);	
			
			}
	
	i++; }    

}
}

Measured memory_bytes: 16852
import java.io.*;
import java.math.*;
import java.util.*;

class Main
{
	private static void logging(int x) {System.out.println(x);}

	public static void main(String[] args)throws IOException
	{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		String line;
		int keep,mx=0;
		int count[]=new int[1000];
		int ans[]=new int[1000];

		while((line=input.readLine())!=null)
		{
			keep=Integer.parseInt(line);
			count[keep]++;
			mx=Math.max(mx,keep);
		}

		int count_mx=0; 
		for(int i=0;i<=mx;i++)count_mx=Math.max(count[i],count_mx);

		int count_ans=0;
		for(int i=1;i<=mx;i++)
		{
			if(count_mx==count[i])
				ans[count_ans++]=i;
		}
		for(int i=0;i<count_ans;i++)logging(ans[i]);
	}
}

Measured memory_bytes: 24104
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n;
  while(cin>>n,n){
    int k,sum=0,flag=0;
    for(int i=0;i<n;i++){
      cin>>k;
      if(k==0){
      }
      else if(k==1){
	sum++;
      }
      else{
	sum++;
	flag++;
      }
    }
    if(flag==0){
      cout<<"NA"<<'\n';
    }
    else{
      cout<<sum+1<<'\n';
    }
  }
  return(0);
}



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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long n, k;
    cin >> n >> k;
    n = n % k;
    long long m = n;
    unordered_map<long long, bool> cache;
    while (cache.find(n) == cache.end()) {
        cache[n] = true;
        n = abs(n - k);
        m = min(m, n);
    }
    cout << m << endl;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


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

int main() {
  int x,y,z;
  cin >> x >> y >> z;
  int ans=0;
  for ( int i=0; i<=x; i++ ) {
    if ( y*i+(i+1)*z <= x ) {
      ans=i;
    } else {
	  break;
    }
  }
  cout << ans << '\n';
  return 0; 
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;

int main(){
    int N;
    ll Tb,Ab;
    ll T,A;
    cin >> N;
    cin >> Tb >> Ab;
    FOR(i,1,N){
        cin >> T >> A;
        ll m = 1+max((Tb-1)/T,(Ab-1)/A);
        Tb = T*m;
        Ab = A*m;
    }
    cout << Tb+Ab << endl;
    return 0;
}


Measured memory_bytes: 256
def check(i):
    if(p_list[i-1]< p_list[i] and p_list[i] < p_list[i+1]):
        return 1
    if(p_list[i-1] > p_list[i] and p_list[i] > p_list[i+1]):
        return 1
    return 0

n = int(input().strip())
p_list = list(map(int, input().split()))

ans = 0
for i in range(1, n - 1):
    ans += check(i)
print(ans)

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

int main(){
 int n,k,q;
 cin >> n >> k >> q;
    vector<int> h(n);
    rep(i,n){
        h[i]=k-q;
    }
    rep(i,q){
        int x;
        cin >> x;
        h[x-1]++;
        }
        rep(i,n){
            if(h[i]>0){
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
        }
        return 0;
}

Measured memory_bytes: 3772
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <unordered_set>
#include <cctype>
#include <cassert>


using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("angle2.in", "r", stdin);
	//freopen("angle2.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;

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

	vector<int>dp(n, 2e9);
	dp[0] = 0;
	dp[1] = abs(a[0] - a[1]);
	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i], dp[i - 1] + abs(a[i] - a[i - 1]));
		dp[i] = min(dp[i], dp[i - 2] + abs(a[i] - a[i - 2]));
	}

	cout << dp[n - 1];
 	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,M;
    int A;
    int sum = 0;
    scanf("%d %d",&N,&M);
    for(int i = 0; i < M; i++)
    {
        scanf("%d",&A);
        sum += A;
    }
    
    printf("%d\n",(sum <= N)? N-sum:-1);
}


Measured memory_bytes: 3824
N,K=gets.split.map(&:to_i)
an,hs,ar=0,{},[]
a=gets.split.map(&:to_i)
a.each{|i|
  hs[i]=0 if hs[i]==nil
  hs[i]+=1
}
hs.each_with_index{|o,i|ar[i]=o[1]}
ar.sort!
(hs.size-K).times{|i|an+=ar[i]}
puts an

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

using namespace std;

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

#define int ll

main(){
	int a,b,c;

	cin >> a >> b >> c;
	
	if(a<c){
		if(c<b) cout << "Yes" << endl;
		else cout << "No" << endl;
	}else{
		if(c>b) cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    int H,W,N;
    cin >> H >> W >> N;
    int answer = (N + (max(H,W)-1))/max(H,W);
    cout <<answer<< "\n";
}

Measured memory_bytes: 256
n = int(input())
A = [int(i) for i in input().split()]
G = A.copy()
L = A.copy()

def gcd(x, y):
    while y != 0:
        x, y = y, x%y
    return x

def lcm(x, y):
    return (x * y) // gcd(x, y)

for i in range(n - 1):
    g = gcd(G[i], A[i + 1])
    l = lcm(L[i], A[i + 1])
    G[i + 1] = g
    L[i + 1] = l

ans = 0

for i in range(n):
    ans += (L[-1] - 1) % A[i]
    
print(ans)

Measured memory_bytes: 13172
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  int res=0;
  rep1(i,n){
    int buf;cin>>buf;
    if(i%2==1&&buf%2==1){
      ++res;
    }
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 3628
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))

from collections import Counter 
from collections import defaultdict
from collections import deque
import itertools
import heapq
import sys
sys.setrecursionlimit(10**6)

n,m=input_list()
a=deque(input_list())
ans=0
for get_num in range(m+1):
    ret_num=min(m-get_num,get_num)
    if get_num>n:
        get_num=n
        ret_num=min(m-get_num,get_num)
    
    for get_left in range(get_num+1):
        cal=[]
        get_right=get_num-get_left
        val=0
        for i in range(get_left):
            val+=a[i]
            heapq.heappush(cal,a[i])
        for i in range(get_right):
            ii=n-1-i
            val+=a[ii]
            heapq.heappush(cal,a[ii])
        for _ in range(ret_num):
            p_val=heapq.heappop(cal)
            if p_val>0:
                break
            val-=p_val
        ans=max(ans,val)
print(ans)


        

Measured memory_bytes: 3444
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<time.h>
#include<string>
#include<cmath>
#include<stack>
#include<map>
#include<set>
#define int long long
//#define double long double
using namespace std;
#define PI  3.1415926535898
#define eqs 1e-6
const long long max_ = 3e5 + 7;
int mod = 998244353;
const int inf = 1e9;
const long long INF = 1e18;
int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') {
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * f;
}
inline int min(int a, int b) {
	return a < b ? a : b;
}
inline int max(int a, int b) {
	return a > b ? a : b;
}
int node[100] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
signed main() {
	int t = read();
	cout << node[t - 1]; return 0;
}

Measured memory_bytes: 256
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha;
  cout.imbue(loc);

  int N, x;
  cin >> N >> x;
  vector<int> res(N * 2 - 1);
  if (N == 2) {
    if (x == 2) {
      cout << true << endl;
      REP(i,3) cout << i + 1 << endl;
    }
    else cout << false << endl;
  }
  else {
    if (x == 1 || x == N * 2 - 1) {
      cout << false << endl;
      return 0;
    }
    cout << true << endl;
    if (x == N * 2 - 2) {
      res[N-2] = 1;
      res[N-1] = N * 2 - 1;
      res[N+0] = x;
      res[N+1] = 2;
      int idx = 0;
      for (int i = 3; i < N * 2 - 2; ++i) {
        if (i == x) continue;
        while (res[idx] != 0) ++idx;
        res[idx] = i;
      }
    }
    else {
      res[N-2] = N * 2 - 1;
      res[N-1] = 1;
      res[N+0] = x;
      res[N+1] = N * 2 - 2;
      int idx = 0;
      for (int i = 2; i < N * 2 - 2; ++i) {
        if (i == x) continue;
        while (res[idx] != 0) ++idx;
        res[idx] = i;
      }
    }
    for (int i: res) cout << i << endl;
  }
  return 0;
}


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

int main(void){
    int n,total_xor=0;cin>>n;
    int a[n];
    for(int i=0;i<n;i++) 
    {
        cin>>a[i];
        total_xor^=a[i];
    }
    for(int i=0;i<n;i++)
    {
        cout<<(total_xor^a[i])<<" ";
    }
}


Measured memory_bytes: 4344
#include <stdio.h>
long long n, s, ans, x;
long long a[200000];
int main() {
	scanf("%lld", &n);
	for (long long i = 0; i < n; i++) {
		scanf("%lld", a + i);
		s += a[i];
	}
	ans = s;
	for (int i = 0; i < n; i++) {
		x += a[i];
		if (2 * x >= s) {
			if (2 * x - s < ans)ans = 2 * x - s;
		}
		else {
			if (s - 2 * x < ans)ans = s - 2 * x;
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1664
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long int ll;
const int MOD = 1e9 + 7;

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

    int cnt = 0;
    for(size_t i = 0; i < s.length() - 1; i++){
        if(s[i] != s[i+1]){
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


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

signed main(){
    int N,A,B;
    cin >> N >> A >> B;
    
    int tmp = N/(A+B);
    int tmp2 = N-(tmp*(A+B));
    
    int ans = 0;
    if(tmp2>=A) ans = (N/(A+B))*A+A;
    else ans = (N/(A+B))*A+tmp2;
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
struct edge{
    int to,cost;
    edge(int to,int cost):to(to),cost(cost){}
};
const int INF=1001001001;
int N,M;
int S,T,Q;
vector<edge>G[100000];
vector<int>L[100000];
int dist[100000];
bool used[100000];
unsigned long long dp[100000];
vector<int>ord;
void dijkstra(){
    fill_n(dist,N,INF);
    dist[S]=0;
    priority_queue<P,vector<P>,greater<P> >que;
    que.push(P(0,S));

    while(que.size()){
        P p=que.top();que.pop();
        if(dist[p.second]<p.first)continue;
        for(int i=0;i<G[p.second].size();i++){
            edge &e=G[p.second][i];
            if(dist[e.to]<=p.first+e.cost)continue;
            dist[e.to]=p.first+e.cost;
            que.push(P(dist[e.to],e.to));
        }
    }
}

void dfs(int v){
    used[v]=true;
    for(int i=0;i<L[v].size();i++){
        int to=L[v][i];
        if(used[to])continue;
        dfs(to);
    }
    ord.push_back(v);
}

void build(){
    queue<int>que;
    que.push(T);
    used[T]=true;
    while(que.size()){
        int pos=que.front();que.pop();
        for(int i=0;i<G[pos].size();i++){
            edge &e=G[pos][i];
            if(dist[e.to]+e.cost==dist[pos]){
                L[e.to].push_back(pos);
                if(!used[e.to]){
                    used[e.to]=true;
                    que.push(e.to);
                }
            }
        }
    }
}

int main(){
    scanf("%d%d",&N,&M);
    for(int i=0;i<M;i++){
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        a--;b--;
        G[a].push_back(edge(b,c));
        G[b].push_back(edge(a,c));
    }
    scanf("%d%d%d",&S,&T,&Q);
    S--;T--;

    dijkstra();

    build();
    fill_n(used,N,false);
    for(int i=0;i<N;i++)if(!used[i])dfs(i);
    reverse(ord.begin(),ord.end());


    for(int i=0;i<(Q+63)/64;i++){
        int a[64],b[64];
        int lim=min(64,Q-i*64);
        fill_n(dp,N,0);
        for(int j=0;j<lim;j++){
            scanf("%d%d",&a[j],&b[j]);
            a[j]--;b[j]--;
            dp[a[j]]|=(1ll<<j);
        }
        for(int j=0;j<N;j++){
            int v=ord[j];
            for(int k=0;k<L[v].size();k++){
                int to=L[v][k];
                dp[to]|=dp[v];
            }
        }

        for(int j=0;j<lim;j++){
            if(dp[b[j]]>>j&1)puts("Yes");
            else puts("No");
        }
    }
    return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

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

	cout << (n-1)*(m-1) << endl;
}

Measured memory_bytes: 256
N = int(input())
S = input()

al = [chr(i) for i in range(97, 97+26)]
ans = 0
for i in range(N):
    a = S[i:]
    b = S[:i]
    cnt = 0
    for j in al:
        if j in a and j in b:
            cnt+=1

    ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,flg[1001],cnt=0;
	char a[1001];
	scanf("%s",a);
	for(i=0;i<strlen(a);i++){
		flg[i]=0;
		if(a[i]=='B'){
			flg[i]=1;
			while(1){
				cnt++;
				if(flg[i-cnt]!=1){
					flg[i-cnt]=1;
					cnt=0;
					break;
				}
			}
		}
	}
	for(i=0;i<strlen(a);i++){
		if(flg[i]==0){
			printf("%c",a[i]);
		}
	}
	printf("\n");
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int v[26] = {};
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        int a[26] = {};
        for(auto c: s){
            a[c-'a']++;
        }
        if(i!=0){
            for(int i=0; i<26; i++){
                v[i] = min(v[i], a[i]);
            }
        }else{
            for(int i=0; i<26; i++){
                v[i] = a[i];
            }
        }
    }
    for(int i=0; i<26; i++){
        for(int j=0; j<v[i]; j++){
            cout << char('a' + i);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;

int v[112345];
int a[112345];
int b[112345];
vector<pair<int,int>> veca;
vector<pair<int,int>> vecb;
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  for(int i=0;i<n;i+=2){
    a[v[i]]++;
  }
  for(int i=1;i<n;i+=2){
    b[v[i]]++;
  }
  for(int i=0;i<112345;i++){
    veca.push_back(make_pair(a[i],i));
    vecb.push_back(make_pair(b[i],i));
  }
  sort(all(veca));
  reverse(all(veca));

  sort(all(vecb));
  reverse(all(vecb));

  if(veca[0].second!=vecb[0].second){
  //  dump("t");
  dump(veca[0].first);
  dump(vecb[0].first);
  dump(veca[1].first);
  dump(vecb[1].first);

    cout<<n-veca[0].first-vecb[0].first<<endl;
  }else{
    int a=n-veca[1].first-vecb[0].first;
    int b=n-veca[0].first-vecb[1].first;
    dump(veca[0].first);
    dump(vecb[0].first);
    dump(veca[1].first);
    dump(vecb[1].first);
    dump(a);dump(b);
    int ans=min(n-veca[1].first-vecb[0].first,n-veca[0].first-vecb[1].first);
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3436
#include <iostream>
#include <map>

using namespace std;

int main()	{
  	int a;
  	map<int, int> freq;
  	for (int i = 0; i < 3; i++)	{
    	cin >> a;
      	freq[a]++;
    }
  	if (freq[5] != 2 || freq[7] != 1)
      	cout << "NO" << endl;
  	else
      	cout << "YES" << endl;
  	return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <string.h>
#include <sstream>
#include <cctype>
#include <climits>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <vector>
#include <iterator>
#include <algorithm>
#include <stack>
#define _clr(x,y) memset(x,y,sizeof(x))
#define _inf(x) memset(x,0x3f,sizeof(x))
#define pb push_back
#define mp make_pair
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
typedef long long LL;
const LL mo=1000000000+7;
int isprime(int x)
{
	for(int i=2;i*i<=x;i++) if(x%i==0)return 0;return 1;
}
int main()
{
	//ios_base::sync_with_stdio(false);cin.tie(0);
	#ifndef ONLINE_JUDGE
		//freopen("in.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif
	
	LL ans=1;
	int n;
	cin>>n;
	for(int i=2;i<=n;i++)
	{
		if(!isprime(i)) continue;
		LL tmp=n,cnt=1;
		while(tmp)
		{
			cnt+=tmp/i;
			tmp/=i;
		}
		ans=(ans*cnt)%mo;
	}
	cout<<ans<<endl;
	
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  vector<char> v(n + 1, 0);
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  int ans = 0;
  int i = 1;
  while (v[i] == 0) {
    v[i] = 1;
    ans += 1;
    if (a[i] == 2)
      break;
    i = a[i];
    if (v[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}


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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    cout << a[n-1] - a[0] << endl;
}

Measured memory_bytes: 256