akhauriyash/Code-Regression huggingface dataset:
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);
const long double PI=3.14159265358979;

// Required random number generators

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    ll ans=N;
    string S;
    cin>>S;
    ll R=0;
    FORI(i,0,N)
    {
        R+=(S[i]=='R');
    }
    ans=min(R,N-R);
    ll pre=0;
    FORI(i,0,R)
    {
        pre+=(S[i]=='W');
        ans=min(ans,pre+R-(i+1));
    }
    cout<<ans<<endl;

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


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

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

int main(void){
  int x,y,z;
  cin >> x >> y >> z;
  int min = abs(x-y)+abs(y-z);
  min = min < abs(x-z)+abs(z-y) ? min : abs(x-z)+abs(z-y);
  min = min < abs(y-x)+abs(x-z) ? min : abs(y-x)+abs(x-z);
  min = min < abs(y-z)+abs(z-x) ? min : abs(y-z)+abs(z-x);
  min = min < abs(z-x)+abs(x-y) ? min : abs(z-x)+abs(x-y);
  min = min < abs(z-y)+abs(y-x) ? min : abs(z-y)+abs(y-x);
  cout << min << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll makes(ll t) {
	ll res = 0;
	ll sum = 0;
	for (int i = 31; i >= 0; i--) {
		ll j = (ll)1 << i;
		ll dif1 = abs(sum+j - t);
		ll dif2 = abs(sum - j - t);
		if (dif1 < dif2) {
			res += j;
			sum += j;
		}
		else {
			sum -= j;
		}
	}
	return res;
}

string move(ll a, ll b) {
	string res;
	ll t1 = makes(a), t2 = makes(b);
	rep(i, 32) {
		ll key = (ll)1 << i;
		if ((t1&key) && (t2&key)) {
			res.push_back('R');
		}
		else if (t1&key) {
			res.push_back('U');
		}
		else if (t2&key) {
			res.push_back('D');
		}
		else res.push_back('L');
	}
	return res;
}
LP v[1000];
int main() {
	int m = 32;
	int n; cin >> n;
	bool exi[2] = { false,false };
	rep(i, n) {
		ll x, y; cin >> x >> y;
		if ((x + y) % 2) {
			exi[1] = true;
		}
		else {
			y--;
			exi[0] = true;
		}
		v[i] = { x,y };
	}
	if (exi[0] && exi[1]) {
		cout << -1 << endl;
	}
	else {
		if (exi[0]) {
			m++;
		}
		cout << m << endl;
		if (exi[0])cout << "1 ";
		rep(i, 32) {
			ll ele = (ll)1 << i;
			if (i > 0)cout << " "; cout << ele;
		}
		cout << endl;
		rep(i, n) {
			string g;
			if (exi[0]) {
				g.push_back('U');
			}
			cout << g+move(v[i].first + v[i].second, v[i].first - v[i].second) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep1(i,a,b) for(int i=a;i<b;i++)
#define rep2(i,a,b) for(int i=a;i>=b;i--)
#define mod 1000000007
#define garou ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
signed main() {
garou;
	vector<int> v1(1000001,0);
int n;
cin>>n;
vector<int> v(n,0);
rep1(i,0,n)
cin>>v[i];
int x=0;
rep1(i,0,n){
	for(int j=2;j*j<=v[i];j++){
		if(v[i]%j==0){
			v1[j]++;
			if((j*j)!=v[i])
			v1[v[i]/j]++;
			if((v1[j]>=2||v1[v[i]/j]>=2)&&v[i]/j>1){
				x=-1;
				break;
			}
		}
	}
		v1[v[i]]++;
		if(v1[v[i]]>=2&&v[i]>1){
			x=-1;
			break;
		}
	if(x==-1)
	break;
}
if(x==0){
	cout<<"pairwise coprime";
	return 0;
}
int g=v[0];
rep1(i,1,n)
g=__gcd(g,v[i]);
if(g==1){
	cout<<"setwise coprime";
	return 0;
}
cout<<"not coprime";
	}

Measured memory_bytes: 18760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)
#define INF 99999999

int main() {
    int H, W; cin >> H >> W;
    pair<int, int> C, D;
    cin >> C.first >> C.second >> D.first >> D.second;
    C.first++; C.second++; D.first++; D.second++;
    vector<vector<char>> S(H+4, (vector<char>(W+4, '#')));
    char tmp;
    /*rep(i, 2) {
        rep(j, W+4) {
            S[i][j] = '#';
            S[H+3-i][j] = '#';
        }
    }
    rep(j, 2) {
        rep(i, H+4) {
            S[i][j] = '#';
            S[i][W+3-j] = '#';
        }
    }*/
    //rep(i, H)rep(j, W) cin >> S[i+2][j+2];
    scanf("%c", &tmp);
    rep(i, H) {
        rep(j, W) {
            scanf("%c", &S[i+2][j+2]);
        }
        scanf("%c", &tmp);
    }
    vector<vector<int>> check(H+4, vector<int>(W+4, INF));
    check[C.first][C.second] = 0;
    deque<pair<int, int>> q;
    q.push_back(C);
    while(!q.empty()) {
        int x = q.front().first, y = q.front().second;
        q.pop_front();
        //cout << x << " " << y << endl;
        if (x == D.first && y == D.second) continue;
        if (check[x][y] >= check[D.first][D.second]) continue;
        for (int i = x-2; i <= x+2; i++) {
            for (int j = y-2; j <= y+2; j++) {
                if (S[i][j] == '#') continue;
                if (abs(i-x) + abs(j-y) == 0) continue;
                if (abs(i-x) + abs(j-y) == 1) {
                    if (check[i][j] > check[x][y]) {
                        check[i][j] = check[x][y];
                        q.push_front(make_pair(i, j));
                    }
                    continue;
                }
                if (check[i][j] > check[x][y]+1) {
                    check[i][j] = check[x][y]+1;
                    q.push_back(make_pair(i, j));
                }
            }
        }
    }
    if (check[D.first][D.second] < INF) cout << check[D.first][D.second] << endl;
    else cout << -1 << endl;

}


Measured memory_bytes: 8724
import sys
def input(): return sys.stdin.readline().rstrip()
from operator import itemgetter
def main():
    n=int(input())
    ST=[]
    for i in range(n):
        x,l=map(int,input().split())
        ST.append((x-l,x+l))
    ST.sort(key=itemgetter(1))
    ans=0
    for i,st in enumerate(ST):
        if i==0:
            ans+=1
            max_t=st[1]
        if max_t<=st[0]:
            ans+=1
            max_t=st[1]
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 18276
# -*- coding: utf-8 -*-
import  numpy as np

def solve():
    X, Y = map(int, input().split())
    res = max(4-X,0)*100000 + max(4-Y,0)*100000 + (X==Y==1)*400000
    return str(res)

if __name__ == '__main__':
    print(solve())


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

int main() {
    int n;
    cin >> n;
    string ans = "T";
    for(int i=0;i<n;i++){
        string p;
        cin >> p;
        if(ans=="T"){
            ans = p;
        }
        else{
            ans = "T";
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define inf 10000000000000009
using namespace std;
long long n,a[2005];
long long ans[2000][2000];
long long dem=0;
int main(){
    cin>>n;
    for(long long i=0;i<n;i++){
        cin>>a[i];
     }
    for(long long i=0;i<n;i++){
        ans[i][n-1]=a[(i-1+n)%n];
    }
    for(long long j=n-2;j>=1;j--){
        for(long long i=0;i<n;i++){
            if((n-j)%2==0){
                if(a[(i+n-1)%n]>a[(i+j-1)%n]){
                    ans[i%n][j]=ans[(i+n-1)%n][j+1];
                }
                if(a[(i)%n]<a[(i+j)%n]){
                    ans[i%n][j]=max(ans[i%n][j],ans[(i)%n][j+1]);
                }
                if(ans[i][j]==0) ans[i][j]=-inf;
            }
            else{
                ans[i%n][j]=max(ans[(i+n-1)%n][j+1]+a[(i+n-1)%n],ans[i][j+1]+a[(i+j)%n]);
            }
        }
    }
    if(n%2==0){
        for(long long i=0;i<n;i++){
            dem=max(dem,ans[i][1]);
        }
    }
    else{
        for(long long i=0;i<n;i++){
            dem=max(dem,ans[i][1]+a[i]);
        }
    }
    cout<<dem<<endl;
}

Measured memory_bytes: 34356
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll a,b,c;cin>>a>>b>>c;
  cout<<b+min(a+b+1,c)<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();
	
	public static void main(String[] args) {
		int N = sc.nextInt();
		char[] c = sc.next().toCharArray();
		ArrayList<Character> str = new ArrayList<>();
		
		for(int i=0; i<N; i++) {
			str.add(c[i]);
		}
		
		int kakko = 0;
		int kakko_l = 0;
		int kakko_r = 0;
		int kakko_max = 0;
		int kakko_min = 0;
		for(int i=0; i<N; i++) {
			if(str.get(i) == '(') {
				kakko++;
				kakko_l++;
				if(kakko > kakko_max) {
					kakko_max = kakko;
				}
			} else if(str.get(i) == ')'){
				kakko--;
				kakko_r++;
				if(kakko < kakko_min) {
					kakko_min = kakko;
				}
			}
		}
		

		for(int i=1; i<=kakko_min * (0-1); i++) {
			str.add(0, '(');
			kakko_l++;
			kakko++;
		}
		
		for(int i=1; i<=kakko; i++) {
			str.add(')');
			kakko_r++;
		}
		
		
		if(kakko_l < kakko_r) {
			for(int i=1; i<=kakko_r-kakko_l; i++) {
				str.add(0, '(');
			}
		} else if(kakko_l > kakko_r) {
			for(int i=1; i<=kakko_l-kakko_r; i++) {
				str.add(')');
			}
		}
		
		
		
		for(int i=0; i<str.size(); i++) {
			System.out.print(str.get(i));
		}
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}



Measured memory_bytes: 22612
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  std::string s; std::cin >> s;
  int ans = s.size();
  int aa[] = {0, 1, 0, 1};
  int bb[] = {0, -1, -1, 0};
  for(int i = 0; i < 4; ++i) {
    int a = aa[i], b = bb[i];
    int cur = a-b;
    for(auto c: s) {
      if(c=='0')      { --a; --b; }
      else if(c=='1') { ++a; ++b; }
      else            { --a; ++b; }
      if(a < 0) a += 2;
      if(b > 0) b -= 2;
      cur = std::max(cur, a-b);
    }
    ans = std::min(ans, cur);
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 4716
n = int(input())

w = [int(i) for i in input().split()]
s1 = 0
ans = float("inf")
sumw = sum(w)
for i in w:
    s1 += i
    s2 = sum(w) - s1
    ans = min(ans, abs(s1 - s2))

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////

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

	ll ans = INF;
	while( s >= 100 ){
		ll num = s % 1000;
		ans = min( ans , abs(num - 753) );
		s /= 10;
	}

	cout << ans << endl;

	ret 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,L;
ll A[101010];
ll S[101010];
set<int> SS;
set<pair<ll,int>> P;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>L;
	FOR(i,N) cin>>A[i];
	
	FOR(i,N-1) {
		if(A[i]+A[i+1]>=L) {
			_P("Possible\n");
			FOR(j,i) _P("%d\n",j+1);
			for(j=N-2;j>i;j--) _P("%d\n",j+1);
			_P("%d\n",i+1);
			return;
			
		}
	}
	
	_P("Impossible\n");
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	string s, t;
	cin >> s >> t;

	int t_len = t.size();
	int ans = 0;
	rep(i, s.size() - t.size() + 1)
	{
		int cnt = 0;
		rep(j, t.size())
		{
			if (t[j] == s[i + j])
				cnt++;
			if (cnt == t.size())
			{
				cout << 0 << endl;
				return ;
			}
		}
		chmax(ans, cnt);
	}
	cout << t_len - ans << endl;
}

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

	solve();
}



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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n,pp;
    cin >> n;
    for(int i=0;;i++){
        if(pow(2,i) > n){
            pp = i-1;
            break;
        }
    }
    cout << pow(2,pp) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        
        long k = in.nextInt();
        long x = in.nextInt();
        k = k * 500;
        if (k >= x) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        

    }

}


Measured memory_bytes: 21972
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,K,ans=INF;
  cin>>N>>K;
  ll H[N+1];
  H[0]=0;
  RREP(i,N) cin>>H[i];
  
  ll DP[N+1][N+1]; // DP[i][j]=i列目まで見てちょうどj列使った時のコストの最小値
  REP(i,N+1){
    REP(j,N+1){
      DP[i][j]=INF;
    }
  }
  DP[0][0]=0;
  
  for(int i=1; i<=N; ++i){
    for(int j=1; j<=i; ++j){
      for(int k=j-1; k<i; ++k){
        chmin(DP[i][j],DP[k][j-1]+max(0ll,H[i]-H[k]));
      }
    }
  }
  
  for(int i=N-K; i<=N; ++i) chmin(ans,DP[i][N-K]);
  co(ans);
  return 0;
}

Measured memory_bytes: 4348
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

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


Measured memory_bytes: 256
class UnionFind:
    __slots__ = ["N", "root", "rank"]

    def __init__(self, N):
        """
        N:要素数
        root:各要素の親要素の番号を格納するリスト.
             ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
        rank:ランク
        """
        self.N = N
        self.root = [-1] * N
        self.rank = [0] * N

    def __repr__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    def find(self, x):
        """頂点xの根を見つける"""
        if self.root[x] < 0:
            return x
        else:
            while self.root[x] >= 0:
                x = self.root[x]
            return x

    def union(self, x, y):
        """x,yが属する木をunion"""
        # 根を比較する
        # すでに同じ木に属していた場合は何もしない.
        # 違う木に属していた場合はrankを見てくっつける方を決める.
        # rankが同じ時はrankを1増やす
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def same(self, x, y):
        """xとyが同じグループに属するかどうか"""
        return self.find(x) == self.find(y)

    def count(self, x):
        """頂点xが属する木のサイズを返す"""
        return - self.root[self.find(x)]

    def members(self, x):
        """xが属する木の要素を列挙"""
        _root = self.find(x)
        return [i for i in range(self.N) if self.find == _root]

    def roots(self):
        """森の根を列挙"""
        return [i for i, x in enumerate(self.root) if x < 0]

    def group_count(self):
        """連結成分の数"""
        return len(self.roots())

    def all_group_members(self):
        """{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す"""
        return {r: self.members(r) for r in self.roots()}


import sys
input = sys.stdin.readline
n, q = map(int, input().split())
uf = UnionFind(n)
for i in range(q):
    t, u, v = map(int, input().split())
    if t:
        print(int(uf.same(u, v)))
    else:
        uf.union(u, v)


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

using namespace std;

int n, dp[200005][2];
char x[200005];

int main() {
	scanf("%s", x);
	n = strlen(x);
	dp[1][0] = dp[2][1] = 1;
	for (int i = 2; i <= n; i++)
		for (int j = i - 2; j < i; j++)
			for (int k = 0; k < 2; k++)
				if (dp[j][k] && string(x + j, i - j) != string(x + j - (k + 1), k + 1))
					dp[i][i - j - 1] = max(dp[i][i - j - 1], dp[j][k] + 1);
	printf("%d\n", max(dp[n][0], dp[n][1]));
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,m,n) for (int i = m; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
inline int popcount(const int x) { return __builtin_popcount(x);}
template<class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b;}
template<class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b;}
template<class T> void drop(const T &x) { std::cout<<x<<endl; exit(0);}
void debug_out() { std::cout << "\n";}
template<class T, class... Args> void debug_out(const T &x, const Args &... args) { std::cout<<x<< " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

struct InitIO{
  InitIO() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
  }
}init_io;


int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b;
  rep(i,n) {
    cin >> a[i];
    if (i == 0) b.emplace_back(a[i]);
    else if (a[i-1] != a[i]) b.emplace_back(a[i]);
  }
  ll money = 1000, kabu = 0;
  int m = b.size();
  rep(i, m) {
    if (i == 0) {
      if (b[i] > b[i+1]) continue;
      else { //buy
        kabu += money / b[i];
        money %= b[i];
      }
    }
    else if (i == m-1) {
      money += kabu * b[i];
      kabu = 0;
    }
    else {
      if (b[i-1] < b[i] and b[i] > b[i+1]) { //sell
        money += kabu * b[i];
        kabu = 0;
      }
      else if (b[i-1] > b[i] and b[i] < b[i+1]) { //buy
        kabu += money / b[i];
        money %= b[i];
      }
    }
  }
  cout << money << endl;
  return 0;
}

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

typedef pair <int, int> ii;

const int Maxn = 52;

int n;
int X[Maxn], Y[Maxn];
map <ii, int> M;

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d %d", &X[i], &Y[i]);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) {
            int dx = X[i] - X[j], dy = Y[i] - Y[j];
            if (dx || dy) M[ii(dx, dy)]++;
        }
    int mx = 0;
    for (map <ii, int>::iterator it = M.begin(); it != M.end(); it++)
        mx = max(mx, it->second);
    printf("%d\n", n - mx);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define Graph vector<vector<int>>

int binary_search_under(vector<int> A, int key){//めぐる式（要復習)//ngとokは下側を残したいか上側を残したいかで調整すること(okは残したい側からスタート)
  int ng = (int)A.size(); //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = -1; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (A[mid]<=key) ok = mid;//ここの分岐を変えるだけで求める境界をkeyより大きい最小か、keyより小さい最大かなど多彩に変化させられる(今回はkeyより小さいから<=key)
        else ng = mid;
    }
    return ok;
}//今回はkey以下になる最大のindexを返す

int binary_search_over(vector<int> A, int key){//めぐる式（要復習)//ngとokは下側を残したいか上側を残したいかで調整すること(okは残したい側からスタート)
  int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)A.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (A[mid]>=key) ok = mid;//ここの分岐を変えるだけで求める境界をkeyより大きい最小か、keyより小さい最大かなど多彩に変化させられる(今回はkeyより大きいから>=key)
        else ng = mid;
    }
    return ok;
}//今回はkey以上になる最大のindexを返す

 
int main() {

  int A,B;

  cin >> A >> B ;

  if(A+B==3) cout << 3 << endl;

  if(A+B==4) cout << 2 << endl;

  if(A+B==5) cout << 1 << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    s = [list(input()) for _ in range(n)]
    for i in range(n):
        for j in range(n):
            if (i==j):
                s[i][j] = 0
                continue
            if (s[i][j]=="1"):
                s[i][j] = 1
            else:
                s[i][j] = float("inf")
    #print(s)
    for k in range(n):
        for i in range(n):
            for j in range(n):
                s[i][j] = min(s[i][j], s[i][k]+s[k][j])
    #print(s)
    w = [[] for _ in range(n)]
    m = [s[0][0],0,0]
    for i in range(n):
        for j in range(n):
            if (s[i][j] > m[0]):
                m = [s[i][j],i,j]
    #print(m)
    for i in range(n):
        w[s[m[1]][i]].append(i)
    #print(w)
    for i in range(n):
        if (len(w[i])>=2):
            for j in range(len(w[i])-1):
                for k in range(j+1,len(w[i])):
                    if (s[w[i][j]][w[i][k]]==1):
                        print(-1)
                        exit()
    print(m[0]+1)
    

if __name__=="__main__":
    main()

Measured memory_bytes: 57436
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<int> h(n);
    vector<ll> a(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &h[i]);
    }
    for(i=0; i<n; i++) {
        scanf("%lld", &a[i]);
    }

    set<pair<int, ll> > z;
    z.insert(make_pair(0, 0));
    for(i=0; i<n; i++) {
        auto it = z.lower_bound( make_pair(h[i], 0) );
        assert(it!=z.begin());
        it--;
        ll val = it->second+a[i];
        it = z.insert(make_pair(h[i], val)).first;
        it++;
        while(it!=z.end() && it->second<=val) {
            it=z.erase(it);
        }
    }
    printf("%lld\n", z.rbegin()->second);

    return 0;
}


Measured memory_bytes: 15104
//To all well wishers,I own this code
#include <bits/stdc++.h>
using namespace std;
#define int                     long long   
#define double                  long double
#define endl                    "\n"
#define pb                      push_back
#define PI                      3.1415926535897932384626433832795l
#define F                       first
#define S                       second
#define mp                      make_pair
#define f(i,n)                  for(int i=0;i<n;i++)
#define fastio                  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)                  (v).begin(),(v).end()
#define rall(v)                 (v).rbegin(),(v).rend()
#define gcd(a,b)                __gcd((a),(b))
#define fill(a,value)           memset(a,value,sizeof(a));
#define minn(v)                 *min_element(v.begin(), v.end());
#define maxx(v)                 *max_element(v.begin(), v.end());
#define print(x)                cout<<(x)<<endl;
#define sum(v)+x                accumulate(v.begin(), v.end(),x);
#define debug(x)                cout<<#x<<'='<<(x)<<endl;
typedef pair<int,int>           pii;
typedef vector<int>             vi;

signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int a;
    cin>>a;
    string s;
    cin>>s;
    if(a<3200)print("red")
    else print(s)
    return 0;
}




Measured memory_bytes: 3504
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a, b; cin >> a >> b;
    if(a > 0) cout << "Positive" << endl;
    else if(b >= 0) cout << "Zero" << endl;
    else if((b - a) % 2 == 0) cout << "Negative" << endl;
    else cout << "Positive" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll K,X;
    cin >> K >> X;
    Yes(500*K>=X);
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n, r, c;
    scanf("%d%d", &n, &c);
    if(n>=500)
    {
        r = n%500;
        if(r<=c)
            printf("Yes\n");
            else
                printf("No\n");
    }
    else if(n<500)
    {
        if(n<c)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int>arr(n);
	for(int i=0;i<n;++i) cin>>arr[i];
	int max_so_far=0,cur_max=0;
	for(int i=1;i<n;++i){
		if(arr[i]<=arr[i-1]){
			cur_max++;
		}else{
			cur_max=0;
		}
		max_so_far = max(max_so_far,cur_max);
	}
	cout<<max_so_far<<endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main 
{           
    public static void main(String[] args) 
    {
        Scanner scan = new Scanner (System.in);

        int W = scan.nextInt();
        
        int H = scan.nextInt();
        
        int x = scan.nextInt();
        
        int y = scan.nextInt();
        
        int r = scan.nextInt();
       
        if( x + r <= W && y + r <= H &&  x - r >= 0 && y - r  >= 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }        
}      


Measured memory_bytes: 26228
// Author: πα

#include <bits/stdc++.h>
using namespace std;
#define long int64_t

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(n % 2)
        return cout << "No", 0;
    string t = s.substr(0, n/2);
    cout << (s == t+t ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long LL;
int main(){
    int N,X,T;
    scanf("%d%d%d",&N,&X,&T);
    int num = N /X + (N % X != 0);
    printf("%d\n",num * T);
    return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<algorithm>
using namespace std;
int partition(int A[],int p, int r){
    int x=A[r];
    int i=p-1;
    for(int j=p;j<=r-1;j++){
        if(A[j]<=x){
            i+=1;
            swap(A[i],A[j]);
        }
    }
    swap(A[i+1],A[r]);
    return i+1;
}
int main(){
    int n;
    cin>>n;
    int A[100000];
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    int q=partition(A,0,n-1);
    for(int i=0;i<n;i++){
        if(i==q){
            cout<<'['<<A[i]<<']';
        }else{ 
            cout<<A[i];
        }
        if(i<n-1){
            cout<<' ';
        }else{
            cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3472
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        string S = Console.ReadLine();
        ulong K = ulong.Parse(Console.ReadLine());
        if (K == 1) { Console.WriteLine(S[0]); }
        else
        {
            int count = C_ABC(S);
            if (ulong.Parse(count.ToString()) >= K)
            {
                Console.WriteLine(1);
            }
            else {
                Console.WriteLine(S[count]);
            }
        }
    }

    public static int C_ABC(string S)
    {
        char[] c = S.ToCharArray();
        int count = 0;
        foreach (char ch in c)
        {
            if (ch == '1') count++;
            else break;
        }
        return count;
    }

}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = strReverce(ret);
        return ret;
    }

}


Measured memory_bytes: 11092
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef int_fast64_t ll;

template<int N, typename T, T M>
struct ModFact {
    T fact[N+1];
    constexpr ModFact() : fact() {
        fact[0] = 1;
        for (int i=0; i<N; ++i)
            fact[i+1] = (fact[i]*(i+1))%M;
    }
};
 
ModFact<100000, ll, MOD> fact;

ll N, M, ans = 1;
int tmp, cnt = 0;
constexpr ll th = 1LL<<45;
char S[200000];

int main() {
    scanf("%lld\n", &N);
    M = N << 1;
    fread_unlocked(S, 1, M, stdin);
	for(size_t i = 0; i < M; i++) {
		tmp = (S[i]=='B') + cnt;
		if(tmp&1) cnt++;
		else {
            ans *= cnt;
            if(ans > th) ans %= MOD;
			cnt--;
		} 
		if(cnt < 0) break;
	}
    ans = cnt == 0 ? ((ans % MOD) * fact.fact[N]) % MOD : 0;
    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int x,n,i,j;
    map<long long int,long long int>mt;
    cin>>x>>n;
    long long int A[n];
    for(i=0;i<n;i++){
        cin>>A[i];
        mt[A[i]]+=1;
    }
    i=0;
    bool ok=false;
    while(ok==false){
        if(mt[x+i]==0||mt[x-i]==0)
            ok=true;
        else
            i+=1;
    }
    if(mt[x-i]==0)
        cout<<x-i;
    else
        cout<<x+i;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main()
{
	int a[32]={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};
	int k;
	cin>>k;
	cout<<a[k-1];
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int i;
int N;
int M;
cin >> N >> M;
int L[M];
int R[M];
for(i=0;i<M;i++)cin >> L[i] >> R[i];
int Max=L[0];
int Min=R[0];
for(i=1;i<M;i++){
  Min=min(Min,R[i]);
  Max=max(Max,L[i]);}
  if(Min>=Max)cout << Min-Max+1 << endl;
  else{cout << 0 <<endl;}
}

Measured memory_bytes: 1024
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    public static long mod = (long) (1e9+7);
	public static void main(String[] args) {
		
		FastReader sc = new FastReader();
		 
         int n = sc.nextInt();
         int[] a = new int[n];
         long x = 0;
         for(int i=0;i<n;++i) {
        	 a[i] = sc.nextInt();
        	 x^=a[i];
         }
       
        if(x == 0) out.println("Yes");
        else out.println("No");
        	
         out.close();
	}
	
		
	}
	

Measured memory_bytes: 35856
import java.util.Scanner;

public class Main {
    public static void main(String[] args){


        Scanner scan = new Scanner(System.in);
        while(true) {
            int a = scan.nextInt();
            char op = scan.next().charAt(0);
            int b = scan.nextInt();

            if (op == '?') {
                break;
            }

            switch (op) {
                case '+':
                    System.out.println(a + b);
                    break;

                case '-':
                    System.out.println(a - b);
                    break;

                case '*':
                    System.out.println(a * b);
                    break;

                case '/':
                    System.out.println(a / b);
                    break;
            }
        }
    }
}


Measured memory_bytes: 26260
import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
F = np.array(list(map(int, input().split())))

if sum(A) < K:
    K = sum(A)

A.sort()
F.sort()
F = F[::-1]

left = 0
right = 10 ** 12
while left < right:
    mid = (left + right) // 2
    sum = 0
    G = A - (mid // F)
#    for i in range(N):
#        sum += max(0, G[i])
    if G[G>0].sum() <= K:
        right = mid
    else:
        left = mid + 1

print(right)

Measured memory_bytes: 37208
/*
 * FileName:     binary_tree_2
 * CreatedDate:  2020-04-22 21:32:11 +0900
 * LastModified: 2020-04-23 01:02:05 +0900
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define node_max 500000
typedef struct _node{
    long int number;
    struct _node *pare;
    struct _node *left;
    struct _node *right;
}_node;
void insert_node(_node *pare, _node *new){
    if(pare==NULL){
        return;
    }
    if(pare->left==NULL&&pare->number>new->number){
        pare->left=new;
        new->pare=pare;
    }
    else if(pare->left!=NULL&&pare->number>new->number){
        insert_node(pare->left,new);
    }
    else if(pare->right==NULL&&pare->number<new->number){
        pare->right=new;
        new->pare=pare;
    }
    else{
        insert_node(pare->right,new);
    }
}
void print_node(_node *pare,int order){
    if(pare==NULL){
        return ;
    }
    if(order==0){
        printf(" %ld",pare->number);
        print_node(pare->left,order);
        print_node(pare->right,order);
    }
    else{
        print_node(pare->left,order);
        printf(" %ld",pare->number);
        print_node(pare->right,order);
    }
}
int find_node(_node *pare,int key){
    if(pare==NULL){
        return 0;
    }
    if(pare->number==key){
        return 1;
    }
    else{
        if(pare->number>key){
            return find_node(pare->left,key);
        }
        else{
            return find_node(pare->right,key);
        }
    }
}
int main(void){
    int n,count=0;
    scanf("%d",&n);
    _node *nn = (_node*)malloc(sizeof(_node));
    nn->left=NULL;
    nn->right=NULL;
    nn->pare=NULL;
    char tmp[7];
    scanf("%s %ld",tmp,&nn->number);
    _node *pare = nn;
    _node *node = (_node*)malloc(n*sizeof(_node));
    for(int i=1;i<n;i++){
        char *command = (char*)malloc(7*sizeof(char));
        scanf("%s",command);
        if(strcmp(command,"insert")==0){
            scanf("%ld",&(node+count)->number);
            insert_node(pare,node+count);
            count++;
            pare=nn;
        }
        else if(strcmp(command,"print")==0){
            print_node(pare,1);
            printf("\n");
            print_node(pare,0);
            printf("\n");
        }
        else{
            int key;
            scanf("%d",&key);
            if(find_node(pare,key)==0){
                printf("no\n");
            }
            else{
                printf("yes\n");
            }
            pare=nn;
        }
        free(command);
    }
    free(nn);
    free(node);
    return 0;
}



Measured memory_bytes: 13840
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = "";

		ArrayList<StringBuilder[]> ds = new ArrayList<StringBuilder[]>();
		int n = 0;

		try {
			s = br.readLine();
			n = Integer.parseInt(s);

			for (int i = 0; i < n; i++) {
				StringBuilder[] sb = new StringBuilder[2];

				s = br.readLine();
				sb[0] = new StringBuilder(s);

				s = br.readLine();
				sb[1] = new StringBuilder(s);

				ds.add(sb);
			}

		} catch (IOException e) {
			e.printStackTrace();
		}

		for (StringBuilder[] sb : ds) {
			StringBuilder sum = new StringBuilder();
			sb[0].reverse();
			sb[1].reverse();
			int len1 = sb[0].length();
			int len2 = sb[1].length();
			int len = (len1 > len2 ? len1 : len2);

			// q: 商, r: 余
			int q, r;
			q = r = 0;
			for (int i = 0; i < len + 1; i++) {

				int n1, n2;
				if (i < len1)
					n1 = Integer.parseInt(String.valueOf(sb[0].charAt(i)));
				else
					n1 = 0;
				if (i < len2)
					n2 = Integer.parseInt(String.valueOf(sb[1].charAt(i)));
				else
					n2 = 0;
				if (i >= len1 && i >= len2 && q == 0) {
					sum.append("");
				} else {
					r = (n1 + n2 + q) % 10;
					sum.append(r);
					q = (n1 + n2 + q) / 10;
				}
			}
			if (sum.length() > 80)
				System.out.println("overflow");
			else
				System.out.println(sum.reverse());
		}
	}
}

Measured memory_bytes: 16968