akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef vector<int> vi;  
typedef pair<int,int> ii;  
typedef vector<ii> vii;  
typedef list<int> li;  
typedef unordered_map<int,int> mii;

#define int long long
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)  
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rap(i,a,n) for (int i = a; i < (n); i++) 
#define rrap(i,n,a) for (int i = (n)-1; i >= a; i--) 


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,a;
    cin >> n;
    vi v;
    rep(i,n) {
        cin >> a;
        v.push_back(a);
    }
    vi cost;
    cost.resize(n);
    cost[0] = 0;
    cost[1] = abs(v[1] - v[0]);
    rap(i,2,n) {
        cost[i] = min(cost[i-2] + abs(v[i-2]-v[i]), cost[i-1] + abs(v[i-1]-v[i]));
    }
    cout << cost[n-1] << '\n';



    return 0;

    //compile: g++ -std=c++14 -O2 -Wall NAME.cpp -o NAME
}


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

const ll maxs = 1e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){
    
}

void solve(){
    
    ll a,b;
    cin >> a >> b;
    if(b >= a){
        cout << "unsafe";
    }
    else{
        cout << "safe";
    }

}

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

Measured memory_bytes: 3652
N = int(input())
A = [int(i) for i in input().split()]
MOD = 10**9 + 7

def gcd(n, m):
    if m == 0:
        return n
    while m != 0:
        n, m = m, n % m
    return n

def lcm(n, m):
    return n * m // gcd(n, m)

L = 1
for a in A:
    L = lcm(L, a)

ans = 0
for i, a in enumerate(A):
    ans += L // a
    if i == N // 2:
        ans %= MOD

print(ans % MOD)


Measured memory_bytes: 4084
blue = Hash.new(0)
n = gets.to_i
n.times do
  blue[gets.chomp] += 1
end


red = Hash.new(0)
m = gets.to_i
m.times{red[gets.chomp] += 1}

counter = 0
blue.keys.each do |k|
  sum = blue[k] - red[k]
  counter = sum if counter < sum
end

puts counter

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+13; 
const int mod= 998244353;
int dp[maxn];
int cal[maxn];
int l[maxn];
int r[maxn];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++)
	{
		scanf("%d%d",&l[i],&r[i]);
	}
	cal[1]=dp[1]=1;//到初始都是一种方法 
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			dp[i]=(dp[i]+(cal[max(0,i-l[j])]-cal[max(0,i-r[j]-1)]))%mod;
			dp[i]=(dp[i]+mod)%mod;
			cal[i]=(cal[i-1]+dp[i])%mod;
		}
	}
	printf("%d",dp[n]);
	
 } 

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

int main(){
  string s,t;
  cin >> s >> t;
  int lens=(int)s.size(),lent=(int)t.size();

  vector<vector<int>> dp(lens+1,vector<int>(lent+1));
  for (int i = 0; i < lens; i++)
  {
    for (int j = 0; j < lent; j++)
    {
      if(s[i]==t[j]) dp[i+1][j+1] = dp[i][j]+1;
      else dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
    }
  }

  string ans = "";
  while(lens>0 && lent>0){
    if(dp[lens][lent]==dp[lens][lent-1]) lent--;
    else if(dp[lens][lent]==dp[lens-1][lent]) lens--;
    else{
      ans = s[lens-1] + ans;
      lens--;
      lent--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 35584
/*╔═══╗──╔╗╔╗───────────────────╔╗────────╔═══╦═══╗
  ║║─║╠╗╠╗╔╣╚═╦══╦═╗╔╦╗╔═╗╔══╦══╣╚═╦╦══╦══╣║─║║║─╚╝
  ║╔═╗║╚╝║╚╣║║║╚╝║║─╔╦╗║║║║╚╝║╚╝║╚╝║║║═╬══║╔═╗║╚╩═║
  ╚╝─╚╩══╩═╩╝╚╩══╩╝─╚╩╝╚╝╚╩══╩══╩══╩╩══╩══╩╝─╚╩═══╝*/
#include<bits/stdc++.h>
#define mod 1000000007
#define modc 998244353
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define deb(x) cout << #x << " " << x << endl;
#define deb2(x,y) cout << #x << " " << x << " " <<  #y << " " << y << endl
#define deb3(x,y,z) cout << #x << " " << x << " " << #y << " " << y << " " << #z << " "  << z << endl;
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define nl cout << endl
#define hello cout << "hello" << endl;
using namespace std;
template <class T>
string to_binary(T n)
{
	string binaryNum;
	int i = 0;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
		i++;
	}
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
template<class T>
bool perfectSq(T n)
{
	if(sqrt(n) == floor(sqrt(n)))
		return true;
	else
		false;
}
template<class T>
void print(T &v)
{
	for(auto x : v)
		cout << x << " " ;
	nl;
}
void solve()
{
	int i,j;
	ll sum = 0,prod = 1;
	string s,t;
	cin >> s >> t;
	s += t.back();
	if(s == t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3620
#include<iostream>
#define N 32770

using namespace std;

int n;

int solve(int k, int x, int cnt){
  if(k==x*x) return 1;
  if(k<x*x || cnt==4) return 0;
  int ans=0;
  for(int i=1; i<=x; ++i){
    ans += solve(k-x*x, i, cnt+1);
  }
  return ans;
}

int main(){
  while(1){
    cin >> n;
    if(!n) break;
    int ans=0;
    for(int i=1; i*i<=n; ++i){
      ans += solve(n, i, 1);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n,k;
  cin>>n>>k;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  vector<double> kitai(n,0);
  for(int i=0;i<n;i++){
    for(int v=1;v<=p[i];v++){
      kitai[i]+=v/(double)p[i];
    }
  }
  double sum=0;
  for(int i=0;i<k;i++){
    sum+=kitai[i];
  }
  double result=sum;
  for(int i=k;i<n;i++){
    sum-=kitai[i-k];
    sum+=kitai[i];
    UpdateMax(result,sum);
  }

  cout<<result<<endl;



  return 0;
}




Measured memory_bytes: 2560
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* ---------- Functions */
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double m = H * 60 + M;
    double h = m / 60.0;

    double dega = 90.0 - 30.0 * h;
    double degb = 90.0 - 6.0 * m;

    double xa = A * cos(dega * PI / 180.0);
    double ya = A * sin(dega * PI / 180.0);

    double xb = B * cos(degb * PI / 180.0);
    double yb = B * sin(degb * PI / 180.0);

    cout << setprecision(10) << fixed << sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)) << endl;
    return 0;
}

Measured memory_bytes: 4112
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
#define int 		long long
#define vi 			vector<int>
#define vec(x) 		vector<x>
#define matrix 		vector<vector<int>>
#define pii 		pair<int,int>
#define rep(i,s,e)  for(int i=s;i<e;i++)
#define rrep(i,e,s) for(int i=e;i>=s;i--)
#define MOD			1000000007
#define pb 			push_back
#define ff 			first
#define ss 			second		
#define w(x)		int x; cin>>x; while(x--)
const int INF=1e18;

#define TRACE
#ifdef TRACE
#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
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// find_by_order(k-1)  returns iterator to kth element starting from 0; Returns the kth smallest element
// order_of_key(k) returns count of elements strictly smaller than k;Returns the number of elements less than k
// erase,insert same as normal set

const int mxn=100+13;
const int MXN=100*1000+13;

int n,W;
int w[mxn],v[mxn];

int dp[mxn][MXN];

int func(int idx,int value){
	if(value<=0) return 0;
	if(idx==n) return INF;

	if(dp[idx][value]!=-1) return dp[idx][value];

	int ans=func(idx+1,value);
	ans=min({ans,w[idx]+func(idx+1,value-v[idx])});

	return dp[idx][value]=ans;
}

void solve(){
	cin>>n>>W;

	int sum=0;
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
		sum+=v[i];
	}

	memset(dp,-1,sizeof(dp));

	for(int i=sum;i>=0;i--){
		if(func(0,i)<=W){
			cout<<i<<endl;return;
		}
	}
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt","r",stdin);
// 	freopen("output.txt","w",stdout);
// #endif
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

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

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

  int N;

  string rs;
  rs = s;

  N = s.size();
  reverse(rs.begin(), rs.end());
  if (s != rs)
  {
    cout << "No" << endl;
    return 0;
  }

  for (int i = 0; i < (N - 1) / 2; ++i)
  {
    if (s.at(i) != s.at((N - 1) / 2 - 1 - i))
    {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  int n, total;
  cin >> n >> total;
  for (int i = 0; i <= n; i++) {
    int j = n - i;
    if (2 * i + 4 * j == total) {
      cout << "Yes" << endl;
      return;
    }
  }
  cout << "No" << endl;
}

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

Measured memory_bytes: 3644
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func main() {
	sc.Split(bufio.ScanWords)
	buf := make([]byte, 10000)
	sc.Buffer(buf, 1000000)

	n := nextInt()
	s := nextLine()

	data := strings.Split(s, "")

	min := 1000000
	right := make([]int, n+1)
	left := make([]int, n+1)

	for i := 1; i < n; i++ {
		if data[i-1] == "W" {
			left[i] = left[i-1] + 1
		} else {
			left[i] = left[i-1]
		}
	}

	for i := n-1; i > 0; i-- {
		if data[i] == "E" {
			right[i-1] = right[i] + 1
		} else {
			right[i-1] = right[i]
		}
	}

	for i := 0; i < n; i++ {
		sum := right[i] + left[i]
		if min > sum {
			min = sum
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    vector<ll> v(n+1);
    rep(i, n+1){
        cin>>v[i];
    }
    vector<pair<ll, ll> > minmax(n+1);
    minmax[n] = make_pair(v[n], v[n]);
    for(int i = n-1;i>=0;i--){
        minmax[i] = make_pair((minmax[i+1].first+2-1)/2+v[i], minmax[i+1].second+v[i]);
    }
    if(!(minmax[0].first<=1 && minmax[0].second>=1)){
        cout<<-1<<endl;
        return 0;
    }
    ll now = 1;
    ll ans = 1;
    for(int i = 1;i<=n;i++){
        now = min((now-v[i-1])*2, minmax[i].second);
        ans += now;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int H,W,N;
	cin>>H>>W>>N;
	int ans[100][100]={};
	int h = 0, w = 0;
	rep(i,N){
		int n;
		cin>>n;
		rep(t,n){
			ans[h][w] = i+1;
			if(h%2==0) w++;
			else w--;
			if(w==W){
				w = W-1;
				h++;
			}
			if(w==-1){
				w = 0;
				h++;
			}
		}
	}
	rep(i,H){
		rep(j,W){
			cout<<ans[i][j]<<" ";
		}
		puts("");
	}
}


Measured memory_bytes: 384
function ary2(y,x){x=x||y;return Array(y).fill(0).map(a=>Array(x).fill(0));}
function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  one: function(f){return this.a(f);},
  single: function(f){return this.a(f);},
  l: function(f){
    var s = this._s, y = this._y;
    s[y] = typeof s[y] === "string" ? s[y].split(" ") : s[y].reverse();
    this._y++;
    return f?s[y]:s[y].map(a=>+a);
  },
  line: function(f){return this.l(f);},
  row: function(f){return this.l(f);},
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
  matrix: function(n,f){return this.m(n,f);},
};

var o = new gets(require("fs").readFileSync("/dev/stdin","utf8"));
main();
function main(){
  var n = o.a(), m = o.a(), q = o.a();
  var l = o.m(m);
  var p = o.m(q);
  var dp = ary2(n+1);
  for(var i = 0; i < m; i++){
    dp[l[i][0]][l[i][1]]++;
  }
  for(i = 1; i <= n; i++){
    dp[i][i] += dp[i-1][i];
    for(var j = i+1; j <= n; j++){
      dp[i][j] += dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1];
    }
  }
  var ans = [];
  for(i = 0; i < q; i++){
    ans[i] = dp[p[i][1]][p[i][1]] - dp[p[i][0]-1][p[i][1]];
  }
  console.log(ans.join("\n"));
}


Measured memory_bytes: 81648
import math
a,b,c = map(int,input().split())
c = math.radians(c)
s = a*b*math.sin(c)/2
cr = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(c))
l = a + b + cr
h = b*math.sin(c)
print(s,l,h)


Measured memory_bytes: 5712
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, d;
  	cin >> a >> b >> c >> d;
  	while (a >= 0) {
     	 c -= b;
      	 if (c <= 0) break;
      	 a -= d;
    }
  	cout << (a <= 0 ? "No" : "Yes") << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int h[101010];
int main() {
	int n, mi = 2e9 + 1, k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) cin >> h[i];
	sort(h + 1, h + n + 1);
	for (int i = k; i <= n; ++i) mi = std::min(mi, h[i] - h[i - k + 1]);
	cout << mi;
	return 0;

}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

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

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

const ll INF = 1e15;
int n;
vector<ll> sum;
vector<ll> memo;
ll solve(int s) {
    if (s == 0) return 0;
    if (memo[s] != -INF) return memo[s];
    
    ll res = -INF;
    int sub = s;
    do {
        sub = (sub - 1) & s;
        if (sub == 0) {
            chmax(res, sum[s]);
            break;
        }
        else chmax(res, solve(sub) + solve(s ^ sub));
    } while (sub != s);
    return memo[s] = res;
}

int main() {
    cin >> n;
    vector<vector<ll>> a(n, vector<ll>(n));
    cin >> a;
    sum.resize(1 << n);
    rep(bit, 1 << n) {
        ll s = 0;
        rep(i, n) repr(j, i + 1, n) if (bit >> i & 1 && bit >> j & 1) s += a[i][j];
        sum[bit] = s;
    }
    memo.assign(1 << n, -INF);
    cout << solve((1 << n) - 1) << endl;
}

Measured memory_bytes: 1408
N, M = map(int,input().split())
LR = [list(map(int,input().split())) for _ in range(M)]

LMax = LR[0][0]
RMin = LR[0][1]
for l,r in LR[1:]:
  if LMax < l:
    LMax = l
  if RMin > r:
    RMin = r

print(max(0,RMin - LMax + 1))

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


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

    vector<int> P, Q, R;
    int p, q, r;
    for  (int  i = 0; i < A; ++i) {
        cin >> p;
        P.push_back (p);
    }
    std::sort(P.begin(), P.end());

    for  (int  i = A-1; i > A-X-1; --i) {
        R.push_back (P[i]);
    }

    for  (int  i = 0; i < B; ++i) {
        cin >> q;
        Q.push_back (q);
    }
    std::sort(Q.begin(), Q.end());

    for  (int  i = B-1; i > B-Y-1; --i) {
        R.push_back (Q[i]);
    }

    for  (int  i = 0; i < C; ++i) {
        cin >> r;
        R.push_back (r);
    }

    std::sort(R.begin(), R.end());


    long long ans=0;
    
    for  (int  i = X+Y+C-1; i > C-1; --i) {
        ans+=R[i];
    }


    cout << ans << endl;
    return 0;

}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int> >;
using vii = vector<pair<int, int> >;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	int n; cin >> n;
	vi x(n);
	rep(i, n) cin >> x[i];

	vi tmp(n);
	tmp = x;

	sort(ASC(tmp));

	int hoge = tmp[n / 2 - 1];

	rep(i, n) {
		if (hoge >= x[i]) cout << tmp[n / 2] << endl;
		else cout << hoge << endl;
	}
}

Measured memory_bytes: 3712
#include<iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#define fi(p) for(int i=0;i<(p);i++)
using namespace std;
int N;
int L;
int P;
const int MAX_N = 100000;
const int MAX_W = 100000;


int A[MAX_N+1];
int B[MAX_N+1];

void solve() {
	int N,M,X,Y;
	cin >> N >> M >> X >> Y;
	vector<int> x;
	vector<int> y;
	bool res = false;

	fi(N) {
		int temp;
		cin >> temp;
		x.push_back(temp);
	}
	fi(M) {
		int temp;
		cin >> temp;
		y.push_back(temp);
	}
	int max_x = -1000000;
	for (int i = 0; i < (int)x.size(); ++i) {
		if (x[i] > max_x) {
			max_x = x[i];
		}
	}
	int min_y = 1000000;
	for (int i = 0; i < (int)y.size(); ++i) {
		if (y[i] < min_y) {
			min_y = y[i];
		}
	}
	for (int z = X + 1; z <= Y; z++) {
		if (z > max_x&&z <= min_y) {
			res = true;
		}
	}
	if (res == true) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}
}

int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 256
package main

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

type Scanner struct {
	innerScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := new(Scanner)
	innerScanner := bufio.NewScanner(os.Stdin)
	innerScanner.Split(bufio.ScanWords)
	sc.innerScanner = innerScanner
	return sc
}

func (sc Scanner) scan() {
	sc.innerScanner.Scan()
}

func (sc Scanner) next() string {
	sc.scan()
	return sc.innerScanner.Text()
}

func (sc Scanner) nextInt() int {
	i, _ := strconv.Atoi(sc.next())
	return i
}

func (sc Scanner) nextFloat() float64 {
	f, _ := strconv.ParseFloat(sc.next(), 64)
	return f
}

func main() {
	sc := NewScanner()
	n := sc.nextInt()
	m := sc.nextInt()
	q := sc.nextInt()
	var t [501][501]int
	var sum [501][501]int

	for i := 0; i < m; i++ {
		l := sc.nextInt()
		r := sc.nextInt()
		t[l][r]++
	}

	for i := 1; i <= n; i++ {
		for j := 1; j <= n; j++ {
			sum[i][j] = sum[i][j - 1] + t[i][j]
		}
	}

	for i := 0; i < q; i++ {
		l := sc.nextInt()
		r := sc.nextInt()
		ans := 0
		for j := l; j <= r; j++ {
			ans += sum[j][r] - sum[j][l - 1]
		}
		fmt.Println(ans)
	}
}

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

#define int long long int
#define double long double
#define pb push_back
#define fi first
#define se second
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define inf LLONG_MAX


main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n,i,j,ans,R=0,W=0;
	string s;
	cin>>n>>s;
	vii r,w;
	for(i=0;i<n;i++)
	{
		if(s[i]=='R')
			r.pb(i),R++;
		else
			w.pb(i),W++;
	}
	ans=min(R,W);
	int cnt=0;
	if((!r.empty())&&(!w.empty()))
	{
		i=0,j=r.size()-1;
		while(i<w.size()&&j>=0)
		{
			if(w[i]<r[j])
				cnt++,++i,--j;
			else
				break;
		}
		ans=min(ans,cnt);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 5816
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int a[n], x = 0, y = 0, z = 0;
	for (int i = 0 ; i < n ; i++) {
		cin >> a[i];
		if (a[i] % 4 == 0) x++;
		else if (a[i] % 2 == 0) y++;
		else z++; 
	}
	if(z <= x) cout << "Yes\n";
    else if(y == 0 && z <= x + 1) cout << "Yes\n";
    else cout << "No\n";
}   

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

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int q[3];
    for (int i = 0; i < 3; i++) {
        q[i] = 0;
    }
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        if (p <= a)
            q[0]++;
        else if (p <= b)
            q[1]++;
        else
            q[2]++;
    }
    cout << q[min_element(q, q + 3) - q] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int[] x={scan.nextInt(),scan.nextInt(),scan.nextInt()};
        int j=0;
        
        for(int i=x[0];i<=x[1];i++){
            if(x[2]%i==0)j++;
        }
        System.out.println(j);
    }
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	int N,K;
	cin >> N >> K;
	vec(V);
	fx(N) {
		vecp(V);
	}

	int ans = 0;
	fx(K+1) {
		fy(K+1) {
			if (x+y>N||x+y>K||(x==0&&y==0)) {
				break;
			}
			int rest = K - x - y;
			int sum = 0;
			vec(S);
			fz(x) {
				pb(S, V[z]);
				sum += V[z];
			}
			fz(y) {
				pb(S, V[N - 1 - z]);
				sum += V[N - 1 - z];
			}
			sorts(S);
			while(rest-->0&&S.size()>0&& S.front()<0) {
				sum -= S.front();
				S.erase(S.begin());
			}
			ans = max(ans, sum);
		}
	}

	ce(ans)
    return 0;
}



Measured memory_bytes: 256
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,u){function i(e){try{l(r.next(e))}catch(e){u(e)}}function a(e){try{l(r.throw(e))}catch(e){u(e)}}function l(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(i,a)}l((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,o,u,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return u={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function a(u){return function(a){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,a])}}},u=this;t.__esModule=!0;var i=n(1);r(u,void 0,void 0,function(){var e,t,n;return o(this,function(r){switch(r.label){case 0:return[4,i.readInput()];case 1:for(e=r.sent(),t={0:0,1:0},n=0;n<e.length;n++)t[e[n]]++;return console.log(2*Math.min(t[0],t[1])),[2]}})})},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};t.__esModule=!0;var o=r(n(2));t.readInput=function(){return new Promise(function(e,t){o.default.readFile("/dev/stdin","utf8",function(n,r){n?t(n):e(r)})})}},function(e,t){e.exports=require("fs")}]);

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

using namespace std;

int main()
{
    int N,a;
    int num_two, num_four, odd_num;
    num_two = num_four = odd_num = 0;

    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> a;
        if (a % 2) {
            odd_num++;
        } else {
            if (a % 4) {
                num_two++;
            } else {
                num_four++;
            }
        }
    }

    if (odd_num <= num_four) {
        cout << "Yes\n";
    } else if (odd_num <= num_four + 1 && num_two == 0) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  int X=0;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N ;i++)
  {
    cin >> A.at(i);
    if((A.at(i)%2) == 1)X++;
  }
  if((X%2) == 0 )cout << "YES" << endl;
  if((X%2) == 1 )cout << "NO" << endl;
}
    

Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
    ll N;
    cin >> N;
    ll a;
    vector<pair<ll, ll>> A(N);
    for(int i=0; i<N; i++){
        cin >> a;
        A.at(i) = make_pair(a, i);
    }

    sort(A.begin(), A.end());
    for(auto c : A){
        cout << c.second  + 1<< " ";
    }


}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[1001][1001];




	
int main (){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	//input
	string s,t;
	cin >> s >> t;

	//set
	for(int i=0;i<=s.size();++i)dp[i][0]=i;
	for(int i=0;i<=t.size();++i)dp[0][i]=i;

	//algorithm
	for(int i=1;i<=s.size();++i)for(int j=1;j<=t.size();++j){
		if(s[i-1]==t[j-1])dp[i][j]=dp[i-1][j-1];
		else dp[i][j]=min(dp[i-1][j],min(dp[i][j-1],dp[i-1][j-1]))+1;
	}

	//output
	//for(int i=0;i<=s.size();++i){for(int j=0;j<=t.size();++j)cout << dp[i][j];cout << endl;}
	cout << dp[s.size()][t.size()] << endl;
}





Measured memory_bytes: 7176
import java.util.Scanner;

class Main {

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int i = 0;
		while(x != 0){
			i++;
			System.out.println("Case " + i + ": " + x);
			x = scan.nextInt();
		}
	}
}

Measured memory_bytes: 45492
#include <iostream>
#define ll long long
using namespace std;
ll a[90];
int main() {
    int n;
    a[0] = 2, a[1] = 1;
    for(int i = 2; i <= 86; i++)
        a[i] = a[i-1] + a[i-2];
    cin >> n;
    cout << a[n] << "\n";
    return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#define ll long long 
using namespace std;
string s;
ll k;

int main()
{
    cin >> s >> k;
    for (int i = 0, sz = min(k, (ll)s.size()); i < sz; i++)
        if (s[i] != '1'){
            cout << s[i];
            return 0;
        }
    cout << 1;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

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

using namespace std;

typedef long long ll;

const ll M=1000000007;

const int N_MAX=100000;

template<class T>
class Fenwick_tree_dual{
	int n;
	T a[N_MAX];

public:
	void build(int n){
		this->n=n;
		rep(i,n) a[i]=0;
	}

	void add(int i,int j,T v){
		if(i==0){
			for(;j>=0;j=(j&(j+1))-1) a[j]+=v;
			return;
		}
		add(0,j,v);
		add(0,i-1,-v);
	}

	T sum(int i){
		T s=0;
		for(;i<n;i|=i+1) s+=a[i];
		return s;
	}
};

int main(){
	static ll fact[100000];
	fact[0]=1;
	rep(i,99999) fact[i+1]=(i+1)*fact[i]%M;

	for(int n;scanf("%d",&n),n;){
		static int a[100000];
		rep(i,n) a[i]=i;

		int r; scanf("%d",&r);
		rep(i,r){
			int s,t; scanf("%d%d",&s,&t); s--; t--;
			swap(a[s],a[t]);
		}

		static Fenwick_tree_dual<int> F;
		F.build(n);

		ll ans=0;
		rep(i,n){
			ans=(ans+(a[i]-F.sum(a[i]))*fact[n-i-1])%M;
			F.add(a[i]+1,n-1,1);
		}
		printf("%lld\n",ans);
	}

	return 0;
}

Measured memory_bytes: 2588
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define cn cin>>
#define co cout<<
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{
// #ifndef RAHUL
//     freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
// #endif

 
char c;
cin>>c;


char b=toupper(c);


if(b==c)
	cout<<"A"<<endl;
else
	cout<<"a"<<endl;

return 0;
}

Measured memory_bytes: 3584
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

int main() {
	int n, m; scanf("%d %d", &n, &m);
	vector<vector<int>> graph(n, vector<int>());
	for (int i = 0; i < m; ++i) {
		int ai, bi; scanf("%d %d", &ai, &bi);
		graph[--ai].push_back(--bi);
		graph[bi].push_back(ai);
	}
	vector<int> dist(n, -1);
	dist[0] = 0;
	queue<int> q;
	q.push(0);
	while (!q.empty()) {
		int cur = q.front(); q.pop();
		for (int neighbor : graph[cur]) {
			if (dist[neighbor] == -1) {
				dist[neighbor] = dist[cur] + 1;
				q.push(neighbor);
			}
		}
	}
	printf("%s\n", (dist[n-1] != 2 ? "IMPOSSIBLE" : "POSSIBLE"));
	return 0;
}

Measured memory_bytes: 13168
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll power(ll a, ll b){
    ll ans = 1;
    while(b){
        if(b & 1) ans = ans * a;
        b >>= 1;
        a = a * a;
    }
    return ans;
}
int main(){
    int x; cin >> x;
    for(int i = 2000; i >= -2000; i--){
        for(int j = -2000; j <= 2000; j++){
            if(power(i, 5) - power(j, 5) == x){
                cout << i << " " << j << "\n";
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3648
S = input()
output = 'No'

if S[0] == S[1]:
  if S[2] == S[3] and S[2] != S[0]:
    output = 'Yes'

if S[0] == S[2]:
  if S[1] == S[3] and S[1] != S[0]:
    output = 'Yes'

if S[0] == S[3]:
  if S[1] == S[2] and S[1] != S[0]:
    output = 'Yes'

print(output)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#define FRER() freopen("i.txt", "r", stdin);

using namespace std;

const int maxn = 200000 + 5;

int l[maxn], r[maxn], ml[maxn] = {0}, mr[maxn] = {0}, sum[maxn] = {0};

int main()
{
	int n, ans1 = 0, ans2 = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) {
		scanf("%d %d", &l[i], &r[i]);
		++sum[l[i]];
		--sum[r[i]];
		++ml[l[i]];
		++mr[r[i]];
	}
	for(int i = 1; i < maxn; ++i) {
		sum[i] += sum[i - 1];
		ml[i] += ml[i - 1];
		mr[i] += mr[i - 1];
		ans2 = max(ans2, sum[i]);
	}
	for(int i = 0; i < n; ++i) {
		ans1 = max(ans1, ml[r[i] - 1] - mr[l[i]]);
	}
	printf("%d %d\n", ans1, ans2);
	return 0;
}


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

const int MOD = 1000000007;

long long C(int n, int k, vector<long long> &fac, vector<long long> &finv){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int x,y;
  cin >> x >> y;
  
  if((x+y)%3!=0){
    cout << 0 << endl;
    return 0;
  }
  
  int X=x , Y=y;
  X -= (x+y)/3;
  Y -= (x+y)/3;
  if(X<0||Y<0){
    cout << 0 << endl;
    return 0;
  }
  
  vector<long long> fac(X+Y+2), finv(X+Y+2), inv(X+Y+2);
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < X+Y+2; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
  
  cout << C(X+Y,X,fac,finv) << endl;
  return 0;
}


Measured memory_bytes: 15872
#include <iostream>
using namespace std;
unsigned long long int LCM(unsigned long long int, unsigned long long int);

int main(void){
    // Your code here!
    unsigned long long int min, max;
    unsigned long long int antiDiv1, antiDiv2;
    
    cin >> min >> max >> antiDiv1 >> antiDiv2;
    
    unsigned long long int divisorNum1, divisorNum2, divisorNumAll;
    unsigned long long int lcm = LCM(antiDiv1, antiDiv2);
    divisorNum1 = (max / antiDiv1) - ((min - 1) / antiDiv1);
    divisorNum2 = (max / antiDiv2) - ((min - 1) / antiDiv2);
    divisorNumAll = (max / lcm) - ((min - 1) / lcm);
    
    cout << (max - min + 1) - (divisorNum1 + divisorNum2 - divisorNumAll) << endl;
}

unsigned long long int LCM(unsigned long long int a, unsigned long long int b){
    unsigned long long int temp;
    unsigned long long int x = a * b;
    
    if(a < b){
        temp = a;   a = b;  b = temp;
    }
    
    unsigned long long int r = a % b;
    
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    
    return x/b;
}

Measured memory_bytes: 256
s = list(input())
s2 = s.copy()
s_cnt, s2_cnt = 0, 0
if s[0] == '1':
    s2[0] = '0'
    s2_cnt += 1
else:
    s2[0] = '1'
    s2_cnt += 1

for i in range(1, len(s)):
    if s[i] == s[i-1]:
        s_cnt += 1
        if s[i-1] == '1':
            s[i] = '0'
        else:
            s[i] = '1'
    if s2[i] == s2[i-1]:
        s2_cnt += 1
        if s2[i-1] == '1':
            s2[i] = '0'
        else:
            s2[i] = '1'
print(min(s_cnt, s2_cnt))

Measured memory_bytes: 4772
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include <algorithm>
using namespace std;

int main()
{
	int A, B, X;
	cin >> X;
	cin >> A;
	cin >> B;
	if (A - B >= 0)
	{
		cout << "delicious";
	}
	else if (A - B >= -X)
	{
		cout << "safe";
	}
	else
	{
		cout << "dangerous";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <list>
#include <math.h>
#include <map>
using namespace std;
#define REP(i, k, n) for(int i = k;i < n; i++)
#define rep(i, n) REP(i,0,n)
#define ll long long int
int dx[4] = {0,-1,1,0};
int dy[4] = {-1,0,0,1};
#define eps 10e-6
#define mod 1000000007
ll a[100001];
int main(void){
	int n, k;
	cin >> n >> k;
	vector<int> vec;
	rep(i,n){
		int a;
		cin >> a;
		vec.push_back(a);
	}
	sort(vec.rbegin(), vec.rend());
	int sum = 0;
	rep(i, k){
		sum += vec[i];
	}
	cout << sum << endl; 
}


Measured memory_bytes: 256
///In the name of GOD
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 4e5 + 10;
ll n, ans, res = 1, num[MXN], part[MXN];
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i <= n; ++ i) cin >> num[i];
    if (n == 0){
        if (num[0] == 1) return cout << 1, 0;
        else return cout << -1, 0;
    }
    for (int i = n; i >= 0; -- i) part[i] = part[i + 1] + num[i];
    for (int i = 0; i <= n; ++ i){
        if (i) res = (res - num[i - 1]) * 2;
        if (res <= 0) return cout << -1, 0;
      /////////////////////////////
        ans += res;
        if (res <= part[i] && (res - num[i]) * 2 >= part[i + 1] && i < n){
            for (int j = i + 1; j <= n; ++ j) ans += part[j];
            cout << ans << '\n';
            return 0;
        }
    }
    return cout << -1, 0;

    return 0;
}
/*!
    I CHOOSE TO HAVE FAITH,
    BECAUSE WITHOUT THAT,
    I HAVE NOTHING....
    ITS THE ONLY THING THAT'S KEEPING ME GOING.
*/
//! N.N


Measured memory_bytes: 5208
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int mod_pow(Int x, Int y){
  Int res = 1;
  while(y){
    if(y&1) res = res * x % mod;
    x = x * x % mod;
    y /= 2;
  }
  return res;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  assert(mod_pow(2, 10) == 1024);

  Int N, K;
  cin>>N>>K;

  Int ans = 0;
  vector<Int> cnt(K + 1, 0);

  for(Int i=1;i<=K;i++){
    Int num = K / i;
    ans += mod_pow(num, N) * i % mod;
    ans %= mod;
    ans += mod - mod_pow(num, N) * cnt[i] % mod;
    ans %= mod;
    for(Int j=2;i*j<=K;j++) cnt[i * j] = (cnt[i * j] - cnt[i] + mod) % mod;
    for(Int j=2;i*j<=K;j++) cnt[i * j] = (cnt[i * j] + i) % mod;

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


Measured memory_bytes: 3988
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const double EPS=1e-10;
const ll INF=1000000000;
const ll MAX=100010;
int main(){
    int M,T,P,R;
    while(cin>>M>>T>>P>>R,M+T+P+R){
        pair<pair<int,int>,int> v[60]={};
        int wa[60][11]={};
        int pn[60]={};
        for(int i=0;i<R;i++){
            int m,t,p,j;
            cin>>m>>t>>p>>j;
            t--;
            if(j!=0){
                wa[t][p]++;
                continue;
            }
            pn[t]+=wa[t][p]*20;
            v[t].first.first--;
            v[t].first.second+=m;
        }
        for(int i=0;i<T;i++){
            v[i].first.second+=pn[i];
            v[i].second=-(i+1);
        }
        sort(v,v+T);
        for(int i=0;i<T;i++){
            cout<<-v[i].second;
            if(i==T-1){
                cout<<endl;
                continue;
            }
            if(v[i].first==v[i+1].first){
                cout<<"=";
            }else{
                cout<<",";
            }
        }
    }
}


Measured memory_bytes: 3040
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char[] c = s.toCharArray();
    int count = 0;

    if (c[0] == c[1]) {
      count++;
    }
    if (c[1] == c[2]) {
      count += 2;
    }
    if (c[2] == c[3]) {
      count++;
    }

    if (count >= 3) {
      System.out.println("Yes");
      return;
    }

    System.out.println("No");
  }

}


Measured memory_bytes: 23380
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	String s = scn.next();
		String[] list = s.split("");
      	int count = 0;
		for(int i=1; i<n; i++){
			if(list[i].equals(list[i-1])) count++;
		}
      	System.out.println(n-count);
	}
}


Measured memory_bytes: 46644