akhauriyash/Code-Regression huggingface dataset:
#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 rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int n,m;cin>>n>>m;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    int al=0;
    rep(i,n)al+=a[i];
    al=(al+(4*m)-1)/(4*m);
    int t=0;
    rep(i,n){
        if(a[i]>=al)t++;
    }
    if(t>=m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1000000007;

int main(){
    long long L, R;
    while(cin >> L >> R){
        vector<vector<long long>> dp(2, vector<long long>(2, 0LL));
        for(int i=60;i>=0;i--){
            vector<vector<long long>> next(2, vector<long long>(2, 0LL));
            for(int l=0;l<=1;l++){
                for(int r=0;r<=1;r++){
                    if(!dp[l][r]) continue;
                    int low = (L>>i)%2;
                    int high = (R>>i)%2;
                    for(int d0=0;d0<=1;d0++){
                        for(int d1=d0;d1<=1;d1++){
                            if(l == 1 && d0 < low) continue;
                            if(r == 1 && d1 > high) continue;
                            int nl = (l && d0 == low ? 1 : 0);
                            int nr = (r && d1 == high ? 1 : 0);
                            next[nl][nr] = (next[nl][nr] + dp[l][r]) % MOD;
                        }
                    }
                }
            }
            if((L>>i) <= 1 && 1 <= (R>>i)){
                ++next[(L>>i) == 1 ? 1 : 0][(R>>i) == 1 ? 1 : 0];
            }
            dp = next;
        }
        long long res = 0;
        for(auto& v : dp){
            for(auto& t : v) res = (res + t) % MOD;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
  int a,b;
  cin>>a>>b;
  int ans=a*b-(a+b);
  ans++;
  cout<<ans<<endl;	
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}


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

#define int long long
#define CASET int _T; cin >> _T; REP(caset, 0, _T)
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define sq(x) (x)*(x)
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define t4i tuple<int,int,int,int>
#define mii map<int,int>

const int INF = 1LL<<60;
const int MOD = 1000000007;

template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
string to_string(string s) {return s;}
string to_string(bool b) {return b?"true":"false";}
template <typename A, typename B>
string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> t) {return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")";}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> t) { return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ", " + to_string(get<3>(t)) + ")";}
template <typename A>
string to_string(vector<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}
string bin_string(int x) {
    const int d = 32;
    string result(d, ' ');
    REP(i, 0, d) result[d-1-i] = '0'+(x>>i & 1LL);
    return result;
}

int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    int n = s.size();
    vi a(n);
    REP(i, 0, n) {
        if (s[i] == '?') a[i] = -1;
        else a[i] = s[i]-'0';
    }

    vi pows(n); pows[0] = 1;
    REP(i, 1, n) pows[i] = 10*pows[i-1] % 13;

    vector<vi> dp(n, vi(13));
    REP(i, 0, n) {
        vi posses;
        if (a[i] == -1) REP(j, 0, 10) posses.push_back(j);
        else posses.push_back(a[i]);
        REP(r, 0, 13) {
            for (int k : posses) {
                if (i==0) {
                    if (k==r) ++dp[i][r];
                } else dp[i][r] = (dp[i][r]+dp[i-1][(13+r-k*pows[i] % 13) % 13]) % MOD;
            }
        }
    }
    cout << dp[n-1][5];
}

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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  
  if (L>R){
    cout << "Left" << endl;
  }
  else if (L<R){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	int ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int temp;
		cin>>temp;
		ans=__gcd(ans,temp);
	 } 
	 cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int a[5]={0};
    for(int i=0;i<5;i++)
    {
        
        cin>>a[i];
    }
    for(int i=0;i<5;i++)
    {
        
        if(a[i]==0)
        {
            cout<<i+1<<endl;
            break;
        }
    }
   return 0; 
}

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

int main(void)
{
    int r, g, b;
    cin >> r >> g >> b;
    if( (r*100 + g*10 + b) % 4 == 0 ){
        cout << "YES";
    }else{
        cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double area = Math.PI * a *a;
        double length = Math.PI *2 *a;
        System.out.printf("%.6f\n%.6f",area,length);
        sc.close();
    }
}


Measured memory_bytes: 28368
#include<bits/stdc++.h>
using namespace std;
//size_t f = string::npos
//make pair, tuple

int main(){
      int n;cin >> n;
      int arr[n + 5];
      for(int i = 0;i < n;i++)cin >> arr[i];
      cout << *max_element(arr, arr + n) - *min_element(arr, arr + n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 2e5 + 5;

int n, k, x;
double a[N];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> k;
	double res = 0, cur = 0;
	for (int i = 1; i <= n; i++) {
		cin >> x;
		a[i] = (x + 1) / 2.0;
		cur += a[i];
		cur -= a[max(i - k, 0)];
		res = max(res, cur);
	}
	cout << fixed << setprecision(10) << res << endl;
	return 0;
}


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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 long long a,b,c,s,t,x,y,z;
 long long A,B,C,S,T,X,Y,Z;

 long long cnt;

 long double pi=3.14159265358979323846;

 string N,M;

unsigned long long D;

//long long mam(long long a, long long b){}

int main(){

	cin>>a;

	if(0<a%100 && a%100<13 && 0<a/100 && a/100<13) cout<<"AMBIGUOUS";
	else{
		if(0<a%100 && a%100<13) cout<<"YYMM";
		else{
			if(0<a/100 && a/100<13) cout<<"MMYY";
			else cout<<"NA";
		}}

	return 0;

}


Measured memory_bytes: 3560
package main

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

func main() {
	sc := NewScanner()
	A, B, C := sc.NextInt(), sc.NextInt(), sc.NextInt()

	mp := map[int]int{}
	mp[A]++
	mp[B]++
	mp[C]++

	if mp[A] == 1 {
		fmt.Println(A)
	} else if mp[B] == 1 {
		fmt.Println(B)
	} else if mp[C] == 1 {
		fmt.Println(C)
	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 233333,mo=1e9+7;
int n,m,f[N],qz[N];char s[N];
void init(int n, int lim){//<=lim
	umin(lim,n);//f[i]=sigma f[i-1..i-lim]
	f[0]=1;qz[0]=1;
	rep(i,1,n){
		f[i]=(qz[i-1]-(i-lim-1>=0?qz[i-lim-1]:0)+mo)%mo;
		qz[i]=(qz[i-1]+f[i])%mo;
	}
}
int main() {
	read(n);read(m);scanf("%s",s+1);
	int cnt=0;rep(i,1,m)cnt+=s[i]=='R';
	if(cnt==0||cnt==m){
		static int f[N];
		f[0]=1;f[1]=2;rep(i,2,n)f[i]=(f[i-1]+f[i-2])%mo;
		printf("%d\n",(f[n-1]+(n-3>=0?f[n-3]:1))%mo);
		return 0;
	}
	if(n&1){puts("0");return 0;}
	int lim=1e9;int j;for(j=1;j<=m;j++)if(s[j]!=s[1])break;j--;
	if(j%2==0)lim=j+1;
	rep(i,1,m)if(s[i]==s[1]){
		int j;for(j=i;j<=m;j++)if(s[j]!=s[i])break;
		//[i,j-1]
		if((j-i)%2&&j-1<m)umin(lim,j-i);
		i=j-1;
	}
//	cerr<<lim<<endl;
	lim++;init(n/2,lim/2);int res=0;//%2==0
	for(int i=2;i<=min(lim,n);i+=2)res=(res+1LL*i*f[(n-i)/2])%mo;
	cout<<res;
	return 0;
}


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

int r,c,n;

struct number
{
	int x,y,id;
	bool needtovalid()
	{
		return (x==0 || x==r) || (y==0 || y==c);
	}
	operator int()const
	{
		if(!x)return 2*(r+c)-y+1;
		if(y==c)return 2*r+c-x+1;
		return x+y;
	}
	bool operator<(const number &n)const
	{
		return (int)(*this)<(int)(n);
	}
};

set<number> checker;
stack<number> validator;

int main()
{
	scanf("%d%d%d",&r,&c,&n);
	for(int i=1;i<=n;++i)
	{
		number n1,n2;
		scanf("%d%d%d%d",&n1.x,&n1.y,&n2.x,&n2.y);
		n1.id=n2.id=i;
		if(n1.needtovalid() && n2.needtovalid())
		{
			checker.insert(n1);
			checker.insert(n2);
		}
	}
	for(auto num : checker)
		if(validator.empty() || validator.top().id^num.id)
			validator.push(num);
		else
			validator.pop();
	printf("%s\n",validator.empty()?"YES":"NO");
}

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

int main() {
	char S[4];
	string T;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> a >> b >> n;
	cout << (a + b) * n / 2 << endl;

}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int,input().split()))
    zip_a = list(zip(a,list(range(1,n+1))))
    zip_a = sorted(zip_a)
    ans = [str(i) for _,i in zip_a]
    print(" ".join(ans))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 25812
/*
        karmany evadhikaras te
        ma phalesu kadacana 
        ma karma-phala-hetur bhur
        ma re sango'stv akarmani (B.G.-2.47)
 
Translation:
        Lord Krsna to Arjuna.
You have a right to perform your prescribed duty, 
but you are not entitled to the fruits of action. 
Never consider yourself the cause of the results of your activities, 
and never be attached to not doing your duty.    
*/
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define int long long
const int N = 200005;
const ll mod = 2000000011;
#define ld long double
#define PI 3.14159265358979323846
const int X = 10000000;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(20);
}

//3. Structure or classes
//3. Ends here

//1. Data structures declaration here
vector<int>Next;
//1. Ends here

//2. Extra Functions here
//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    for(int i=1;i<=t;i++){
        solve();
    }
    return 0;
}

void solve()
{
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    bool vis[n+1]={0};
    int start=a[1];
    int cnt=0;
    while(true){
        //cout<<start<<" ";
        cnt++;
        if(vis[start]==0){
            vis[start]=1;
        }
        else break;
        if(start==2)break;
        start=a[start];
    }
    if(vis[2]==1)cout<<cnt<<"\n";
    else cout<<"-1\n";
    return;
}

Measured memory_bytes: 4524
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;

int gcd(int a, int b){
  if(b == 0) return a;
  else return gcd(b, a % b);
}

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

P add(P &a, P b){
  int c = lcm(a.second, b.second);
  return P(a.first * (c / a.second) + b.first * (c / b.second), c);
}

P sub(P &a, P b){
  int c = lcm(a.second, b.second);
  return P(a.first * (c / a.second) - b.first * (c / b.second), c);
}


P solve(P &a, bool type, int n){
  int b = 1;
  REP(i, n) b *= 2;
  return (type ? add(a, P(90, b)) : sub(a, P(90, b)));
}

int main() {
  string s;
  while(cin >>s && s != "#"){
    stringstream ss;
    for(int i = 0; i < (int)s.length(); ){
      if(s[i] == 'n'){
        ss << 0;
        i += 5;
      } else{
        ss << 1;
        i += 4;
      }
    }
    s = ss.str();
    REVERSE(s);
    P ans = (s[0] == '0' ? P(0, 1) : P(90, 1));
    FOR(i, 1, s.length()) ans = solve(ans, s[i] - '0', i);
    int c = gcd(ans.first, ans.second);
    if(c == ans.second) cout <<ans.first / ans.second <<endl;
    else if(c != 1) cout <<ans.first / c <<"/" <<ans.second / c <<endl;
    else cout <<ans.first <<"/" <<ans.second <<endl;
  }
  return 0;
}

Measured memory_bytes: 1212
N=int(input())
A=list(map(int,input().split()))
AA=[0]*(N)
AA[0]=A[0]
for i in range(1,N):
  AA[i]=AA[i-1]+A[i]
l=0
r=2
p=[]
for m in range(1,N-2):
  sl=AA[m]
  sr=AA[N-1]-sl
  while abs(sl-2*AA[l])>abs(sl-2*AA[l+1]):
    l+=1
  while abs(AA[N-1]+sl-2*AA[r])>abs(AA[N-1]+sl-2*AA[r+1]):
    r+=1
  P=AA[l]
  Q=sl-P
  R=AA[r]-sl
  S=sr-R
  ans=max(P,Q,R,S)-min(P,Q,R,S)
  p.append(ans)
print(min(p))

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

t = [list(map(int,input().split())) for i in range(3)]

ans = 0;

# for j + 1 in range(n) :
j = 1
while j <= n - 1 :
    if t[0][j - 1] + 1 == t[0][j] :
        ans += t[2][t[0][j - 1] - 1]
    j += 1

print(sum(t[1]) + ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a;
	copy_n(istream_iterator<int>(cin), n, back_inserter(a));

	reverse(a.begin(), a.end());

	bool first = true;
	for (const auto& x : a) {
		cout << (first ? "" : " ") << x;
		first = false;
	}
	cout << endl;
	return 0;
}



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

const int MAXP = 35, MAXN = 1e5 + 10;
int n, sz;
int bin[2];
int step[MAXP + 10];
int x[MAXN], y[MAXN];

inline void print(int x, int y) {
	for (int i = 1; i <= sz; ++i) {
		if (abs(x) > abs(y)) {
			if (x > 0) putchar('R'), x -= step[i];
			else putchar('L'), x += step[i];
		} else {
			if (y > 0) putchar('U'), y -= step[i];
			else putchar('D'), y += step[i];
		}
	}
	puts("");
	return;
}

signed main() {
	scanf("%lld", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%lld%lld", &x[i], &y[i]);
		bin[x[i] + y[i] & 1] = 1;
	}
	if (bin[0] && bin[1]) return puts("-1"), 0;
	for (int i = MAXP; ~i; --i) step[++sz] = 1LL << i;
	if (bin[0]) step[++sz] = 1;
	printf("%lld\n", sz);
	for (int i = 1; i <= sz; ++i) printf("%lld%c", step[i], " \n"[i == sz]);
	for (int i = 1; i <= n; ++i) print(x[i], y[i]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

int cnt(int x){
	if(x % 100) return 0;
	return 1 + cnt(x / 100);
}

int main(){
	int d, n;
	cin >> d >> n;
	for(int i = 1;;i++){
		if(cnt(i) == d){
			n--;
		}
		if(n == 0){
			cout << i << endl;
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
// A - ABC333
// https://abc109.contest.atcoder.jp/tasks/abc109_a

import scala.io.StdIn.readLine

object Main extends App {

  val Array(a, b) = readLine.split(" ").map(_.toInt)

  val isOdd = ((a * b) % 2 == 1)

  isOdd match {
    case true  => println("Yes")
    case false => println("No")
  }

}

Measured memory_bytes: 27316
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = map(int, input().split())
from collections import defaultdict
ns = defaultdict(set)
for i in range(m):
    u,v,c = map(int,input().split())
    u -= 1
    v -= 1
    ns[u].add((c,v))
    
score = [None]*n
score[0] = 0
prev = score
for i in range(n+3):
    update = False
    for u in range(n):
        if prev[u] is not None:
            for c,v in ns[u]:
                if score[v] is None or score[v]<prev[u]+c:
                    score[v] = prev[u]+c
                    update = True
    if not update:
        print(score[-1])
        break
    prev = score
else:
    reach = [False]*n
    for i in range(n+1):
        for u in range(n):
            if prev[u] is not None:
                for c,v in ns[u]:
                    if score[v] is None or score[v]<prev[u]+c:
                        score[v] = prev[u]+c
                        reach[v] = True
    if reach[-1]:
        print("inf")
    else:
        print(score[-1])

Measured memory_bytes: 48092
def main():
    s = input()
    t = input()
    s_len = len(s)
    t_len = len(t)

    dp_table = [[0] * (s_len+1) for _ in range(t_len+1)]

    for i in range(1, s_len+1):
        for j in range(1, t_len+1):
            if s[i-1] == t[j-1]:
                dp_table[j][i] = max(dp_table[j-1][i], dp_table[j][i-1], dp_table[j-1][i-1] + 1)
            else:
                dp_table[j][i] = max(dp_table[j-1][i], dp_table[j][i-1])
    
    ans = ''
    
    i = s_len
    j = t_len
    while(i != 0 and j != 0):
        if s[i-1] == t[j-1]:
            ans = s[i-1] + ans
            i -= 1
            j -= 1
        elif dp_table[j-1][i] > dp_table[j][i-1]:
            j -= 1
        else:
            i -= 1

    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 112348
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pcont(x) for(auto i: x){cout << i << " ";} cout << "\n";

int main(){
    IOS;
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i=  0; i<n; i++){
        cin >> l[i];
    }
    int count = 0;
    for(int i = 0; i<n; i++){
        for(int j = i+1; j<n; j++){
            for(int k = j+1; k<n; k++){
                if((l[i] + l[j] >l[k]) && (l[i] + l[k] > l[j]) && (l[j] + l[k] > l[i])){
                    if(l[i] != l[j] && l[i] != l[k] && l[j] != l[k]){
                        count++;
                    }
                }
            }
        }
    }
    cout << count << "\n";
    return 0;
}

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


int n,m;
vector <int> g[100005];
vector <int> h(100005);
int bfs (int nod){
    if (g[nod].size()==0) return 1;
    for (int i=0; i<g[nod].size(); i++){
        if (h[g[nod][i]]>=h[nod]) return 0;
    }
    
    return 1;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    for (int i=1; i<=n; i++)
        cin>>h[i];
    
    int a,b,res=0;
    
    
    for (int i=0; i<m; i++){
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    
    for (int i=1; i<=n; i++){
        res+=bfs(i);
    }
    
    cout<<res;
    
    return 0;
}

Measured memory_bytes: 8796
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

int main(){
    int n, m; cin >> n >> m;
    int s[n][m]; rep(i, n)rep(j, m) s[i][j] = 0;
    rep(i, m){
        int k; cin >> k;
        rep(j, k){
            int t; cin >> t;
            s[t-1][i] = 1;
        }
    }
    int p[m]; rep(i, m) cin >> p[i];
    int cnt[m]; rep(i, m) cnt[i] = 0;
    int ans = 0;
    rep(i, 1<<n){
        rep(j, n)if((i>>j) & 1){
            rep(k, m)if(s[j][k]) cnt[k]++;
        }
        bool flag = true;
        rep(j, m)if(cnt[j]%2 != p[j]) flag = false;
        if(flag) ans++;
        rep(j, m) cnt[j] = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define f first
#define s second
#define lint long long
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lint, lint>
#define ld long double
#define inlld(x) scanf("%lld", &x)
#define ind(x) scanf("%d", &x)
#define vi vector<int>

const int N=1e5+5;
const int MOD=1e9+7;
const lint INF=1e18;

lint _add(lint x, lint y)
{
    lint ret=x+y;
    while(ret<0LL)
        ret+=MOD;
    return ret;
}

lint _mult(lint x, lint y)
{
    x%=MOD;
    y%=MOD;
    lint ret=x*y;
    ret%=MOD;
    while(ret<0LL)
        ret+=MOD;
    return ret;
}

using namespace std;
using namespace __gnu_pbds;

template <typename T> 
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int k, m, arr[1000005];
signed main()
{
    cin >> m >> k;
    if(k>=(1<<m))
    {
        cout << -1;
        return 0;
    }
    if(m==0)
    {
        if(k==0)
        {
            cout << 0 << " " << 0;
        } 
        else
        {
            cout << -1;
        }
        return 0;
    }
    if(m==1)
    {
        if(k==0)
        {
            cout << 0 << " " << 0 << " " << 1 << " " << 1;
        }
        else
        {
            cout << -1;
        }
        return 0;
    }
    int n = (1<<(m+1));
    if(k==0)
    {
        for(int i = 0; i < n; i+=2)
        {
            arr[i]=arr[i+1]=i/2;
        }
        for(int i = 0; i < n; i++)
        {
            cout << arr[i] << " ";
        }
        return 0;
    }
    arr[0]=arr[2]=0;
    arr[1]=k;
    int cnt=0;
    for(int i = 1; i < n/2; i++)
    {
        if(i==k)
        {
            cnt=1;
            continue;
        }
        arr[2+i-cnt]=i;
    }
    arr[n/2+1]=k;
    cnt=0;
    int ptr=1;
    for(int i = n-1; i > n/2+1; i--)
    {
        if(ptr==k)
        {
            ptr++;
        }
        arr[i]=ptr;
        ptr++;
    }
    for(int i = 0; i < n; i++)
    {
        cout << arr[i] << " ";
    }
}

Measured memory_bytes: 2816
#include <stdio.h>
#include <stdlib.h>

int cmp_int(const void* p, const void* q) {
    return *(int*)p - *(int*)q;
}

int main(void)
{
    const int N;
    long long K;
    scanf("%d %lld", &N, &K);
    int A[N];
    for(int i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }
    int F[N];
    for(int i = 0; i < N; i++){
        scanf("%d", &F[i]);
    }
    qsort(A, N, sizeof(int), cmp_int);
    qsort(F, N, sizeof(int), cmp_int);

    long long l = 0;
    long long r = 1000000000000L;
    while(l < r){
        long long m = (l+r)/2;
        long c = 0;
        for(int i = 0; i < N; i++){
            long long t = A[N-1-i] - m/F[i];
            if(t > 0){
                c += t;
            }
        }
        if(K < c){
            l = m+1;
        } else {
            r = m;
        }
    }
    printf("%lld\n", r);
    return 0;
}


Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#  define DEBUG(x) cerr << "DBG: " <<  x << endl
#else
#  define DEBUG(x) do {} while (0)
#endif
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
#define each(x, v) for (auto &x : v)
#define all(v) (v).begin(), (v).end()
#define sz(v) ((int)(v).size())
#define mem(a, val) memset(a, val, sizeof(a))
#define rep(i, N) for (int i = 0; i < N; i++)
#define repr(i, N) for (int i = (N)-1; i >= 0; i--)
#define rep1(i, N) for (int i = 1; i <= (N); i++)
#define repr1(i, N) for (int i = (N); (i) > 0; i--)
using ii = pair<int, int>;
using ll = long long;
const int inf = 0x3f3f3f3f;
const long long linf = 0x3f3f3f3f3f3f3f3fll;
template<typename T> T abs (T x) { return x < 0 ? -x : x; }
template<typename T> T gcd (T a, T b) { return a ? gcd (b % a, a) : b; }
template<typename T> void max_self(T &a, T b) {  a = max(a, b); }
template<typename T> void min_self(T &a, T b) {  a = min(a, b); }
const int MOD = 1e9 + 7;
void solve(int tc) {
  int n, m;
  cin >> n >> m;
  vector< vector<int> >dp(n+1, vector<int>(m+1, 0));
  vector< string > v(n);
  dp[0][0] = 1;
  rep(i, n)cin >> v[i];
  rep(i, n)rep(j, m){
    if(i == 0 && j == 0)continue;
    if(v[i][j] == '.'){
      int acc = 0;
      if(i-1 >= 0 && v[i-1][j] == '.'){
        acc += dp[i-1][j];
        acc %= MOD;
      }
      if(j-1 >= 0 && v[i][j-1] == '.'){
        acc += dp[i][j-1];
        acc %= MOD;
      }
      dp[i][j] = acc;
    }
  }
  cout << dp[n-1][m-1] << endl;
}

int main() {
  int tc = 1;
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cin >> tc;
  for(int i = 1; i <= tc; ++i)solve(i);
  return 0;
}

Measured memory_bytes: 5248
import sys
import numpy as np

n=int(sys.stdin.readline())
#a=np.array(sys.stdin.readline().split(),dtype='int64')
#b=np.arange(n)
#ans=stack(a,b,axis=

#batch_size=10:
#for i in range(n):
#    ans[a[i]-1]=i+1

a=list(sys.stdin.readline().split())
b=[0]*n

for i in range(n):
    b[int(a[i])-1]=str(i+1)
b=' '.join(b)
print(b)


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

using namespace std;

int main() {
    int n;
    cin >> n;
    map<long long, int> m;
    for(int i = 0; i < n; i++) {
        long long a;
        cin >> a;
        try {
            m.at(a)++;
        } catch (out_of_range) {
            m.insert(make_pair(a, 1));
        }
    }
    if (m.size() == n) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

int main() {
	long long a;
	double b;
	cin >> a >> b;
	if (a < 0 || a > pow(10, 15) || b < 0 || b >= 10) {
		cout << "error\n";
		return 0;
	}
	int tmp = b * 100 + 0.5;

	cout << (long long)(a * tmp / 100) << endl;
	return 0;
}

Measured memory_bytes: 3716
n = int(input())
ans = [0 for _ in range(10**5)]
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            p = x**2 + y**2 + z**2 + x * y + y * z + z * x
            if p <= 10**4:
                ans[p] += 1
for i in range(1, n + 1):
    print(ans[i])

Measured memory_bytes: 73496
import java.io.*;
import java.util.*;

class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        char[] suits=new char[]{'S','H','C','D'};
        Card[] cards=new Card[52];
        boolean[] flag=new boolean[52];
        Arrays.fill(flag, false);
        int cards_count=0;
        for(char c:suits){
            for(int i=1;i<=13;i++){
                cards[cards_count]=new Card(c,i);
                cards_count++;
            }
        }
        int n=Integer.parseInt(br.readLine());
        for(int i=0;i<n;i++){
            StringTokenizer st=new StringTokenizer(br.readLine());
            char suit=st.nextToken().charAt(0);
            int number=Integer.parseInt(st.nextToken());
            for(int j=0;j<52;j++){
                if(cards[j].number==number&&cards[j].suit==suit){
                    flag[j]=true;
                }
            }
        }
        for(int i=0;i<52;i++){
            if(!flag[i]){
                System.out.println(cards[i].suit+" "+cards[i].number);
            }
        }
    }
    
}

class Card{
    char suit;
    int number;
    Card(char s,int n){
        this.suit=s;
        this.number=n;
    }
}

Measured memory_bytes: 24180
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a / gcd(a, b) * b ;
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
  int n,a,b;cin >> n >> a >> b;
  int count = 0;
  for(int i = 1;i<=n;i++) if(ketasum(i)>=a&&ketasum(i)<=b) count+=i;
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3688
#include<iostream>
using namespace std ;
typedef long long ll ;
ll dp[105][100005],weight[105],value[105];
int n,cap;
int main()
{
    cin >> n >> cap ;
    for(int i=1;i<=n;i++){ll x,y ; cin >> x >> y ; weight[i]=x;value[i]=y;}
    for(int i=1;i<=n;i++)
    {
        ll w = weight[i],v=value[i] ;
        for(int j=1;j<=cap;j++)
        {
            if(j>=w)
            {
                    ll hold = dp[i-1][j-w]+v ;
                    dp[i][j]=dp[i-1][j]>hold ? dp[i-1][j] : hold ;
            }
            else{dp[i][j]=dp[i-1][j];}
        }
    }
    cout << dp[n][cap] << endl;
    return 0 ;
}


Measured memory_bytes: 79360
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;

    String  in_num;
    boolean is_9;
    int     cnt;
    int     len;
    int     ans;

    try
    {
      in_stream = new BufferedReader(new InputStreamReader(System.in));

      in_num = new String(in_stream.readLine());


      ans = 0;
      len = in_num.length();

      if(1 == len)
      {
        ans = Integer.parseInt(in_num);
      }
      else
      {

        is_9 = true;
        for(cnt=1; cnt<len; cnt++)
        {
          if(!in_num.substring(cnt, cnt+1).equals("9"))
          {
            is_9 = false;
            break;
          }
        }

        if(is_9)
        {
          ans  = 9 * (len - 1);
          ans += Integer.parseInt(in_num.substring(0, 1));
        }
        else
        {
          ans  = 9 * (len - 1);
          ans += ( Integer.parseInt(in_num.substring(0, 1)) - 1);
        }
      }

      System.out.println("" + ans);
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}


Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
using namespace std;

typedef long long ll;

int main() {
	ll a, b, x; cin >> a >> b >> x;
	cout << b / x - (a == 0 ? -1 : (a - 1) / x) << endl;
	return 0;
}


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

int main(void){
    int n, m;
    cin >> n >> m;
    int x[m];
    for(int i = 0; i < m; i++)
        cin >> x[i];
    sort(x, x+m);
    int check[m-1];
    for(int i = 0;  i < m-1; i++)
        check[i]=x[i+1]-x[i];
    sort(check, check+m-1);
    int ans = 0;
    for(int i = 0; i < m-n; i++)
        ans += check[i];
    cout << ans << endl;
    return 0;
}

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

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

void solve() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (auto& x : a) cin >> x;
	int** dp = new int*[n + 1];
	int** sum = new int*[n + 1];
	for (int i = 0; i <= n; i++) 
		dp[i] = new int[k + 1],
		sum[i] = new int[k + 1];
	for (int j = 0; j <= k; j++) 
		dp[0][j] = (!j), sum[0][j] = 1;
	for (int i = 1; i <= n; i++) {
		for (int s = 0; s <= k; s++) {
			dp[i][s] = sum[i - 1][s];
			int bound = s - a[i - 1] - 1;
			if (bound >= 0) 
				dp[i][s] -= sum[i - 1][bound];
			if (dp[i][s] < 0) dp[i][s] += MOD;
//			cerr << "(" << i << "," << s << ") = " << dp[i][s] << " in range [" << bound << "," << s << "]\n";
			sum[i][s] = dp[i][s];
			if (s) 
				sum[i][s] += sum[i][s - 1], sum[i][s] %= MOD;
 		}
	}
	cout << dp[n][k];
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}

Measured memory_bytes: 82744
//Following the naive approach would lead to timeout as we have to perform dfs on all the nodes... 
// resulting in O(n^2)

//better to use the build dp solution based on calculating the respective lengths of the child nodes 

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
// #define mp make_pair
#define nt _int128 
#define fir first
#define sec second
#define fast_as_levi ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define inf 0x3f3f3f3f
 
const ll mod = 1e9 + 7;
const ll mx = 2e6 + 5;
const ll mxi = 2e3 + 5;

vector<ll> g[mx];
ll vis[mx];
ll dp[mx];
void dfs(ll s)
{
    vis[s] = 1;
    for(ll x : g[s])
    {
        if(!vis[x])
        {
            dfs(x);
        }
        dp[s] = max(dp[s], dp[x] + 1);
    }
    // return dp[s];
}

int main()
{
    fast_as_levi;
    ll i,j,n,e;
    cin>>n>>e;
    for(i=0;i<e;i++)
    {
        ll x,y;
        cin>>x>>y;
        g[x].pb(y);
    }
    memset(dp,0,sizeof(dp));
    memset(vis,0,sizeof(vis));
    ll ans = 0;
    for(i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(i);
        }
    }
    // for(i=0;i<=n;i++)
    // {
    //     cout<<dp[i]<<" ";
    // }
    // cout<<"\n";
    for(i=1;i<=n;i++)
    {
        ans = max(dp[i],ans);
    }
    cout<<ans;                    
}

Measured memory_bytes: 83584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a;
  in(n);
  vector<ll> c(n), s(n);
  rep(i, n)
    in(c[i]);
  s[0] = 0;
  s[1] = abs(c[1] - c[0]);
  rep2(i, 2, n){
    s[i] = min(s[i - 2] + abs(c[i] - c[i - 2]), s[i - 1] + abs(c[i] - c[i - 1]));
  }
  out(s[n - 1]);
  memi;
}

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

int main(){
  int N;
  cin >> N ;
  int A = 0;
  for(int i = 0; i < N ;i++){
    int l;
    int r;
    cin >> l >> r;
    int m;
    m = r - l + 1;
    A = A + m;
  }
  cout << A << endl;
}
    

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

typedef long long ll;
typedef vector < int > vi;
typedef pair <int , int > pi;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fr(i,a,b) for(int i=a;i<b;i++)



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    int arr[m];
    ll sum=0;
    for(int i=0;i<m;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }

    if(sum>n)
    {
        cout<<-1;
    }
    else
    {
        cout<<n-sum;
    }

    return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <set>
#include <cmath>
#include <tuple>
#include <vector>
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
	int h,w;
	std::cin >> h >> w;
	char board[51][51] = {'.'};
	for ( int i = 0 ; i < h ; i++ ) {
		for ( int ii = 0 ; ii < w ; ii++ ) {
			std::cin >> board[i][ii];
		}
	}
	for ( int i = 0 ; i < h ; i++ ) {
		for ( int ii = 0 ; ii < w ; ii++ ) {
			char moji = board[i][ii];
			if(moji=='#') continue;
			int cnt = 0;
			for ( int a = -1 ; a < 2 ; a++ ) {
				for ( int aa = -1 ; aa < 2 ; aa++ ) {
					if(board[i+a][ii+aa]=='#') cnt ++;
				}
			}
			board[i][ii] = '0' + cnt;
		}
	}
	for ( int i = 0 ; i < h ; i++ ) {
		for ( int ii = 0 ; ii < w ; ii++ ) {
			std::cout << board[i][ii];
		}
		std::cout << std::endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define bye return 0
#define Yes cout << "Yes" << "\n"
#define No  cout << "No" << "\n"
#define YES cout << "YES" << "\n"
#define NO cout << "NO" << "\n"
using namespace std;
int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    int a, b, c, cnt=0, in=0;

   cin >> a >> b;

   cout << (a*a) - b << "\n";

     

   bye;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k, q;
	cin>>n>>k>>q;
	vector<int> vec(n, 0);
	for(int i = 0; i < n; ++i)vec[i]+=k;
	for(int i = 0; i < q; ++i){
		int a;
		cin>>a;
		a--;
		vec[a]++;
	}
	for(int i = 0; i < n; ++i)vec[i]-=q;
	for(int i = 0; i < n; ++i){
		if(vec[i] > 0)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef pair<ll, ll> PLL;

#define REP(i, j) for(int i=0;i<j;i++)
#define FOR(i, b, e) for(int i=b; i<=e; i++)
#define FORD(i, b, e) for(int i=b; i>=e; i--)
#define SIZE(x) ((int)x.size())
#define LAST(x) (x[SIZE(x)-1])
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sp ' '
#define ent '\n'

ll dp[100005];
ll n, u, v, w;

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

    cin >> n >> u;

    REP(i, 100005){
        dp[i] = INT_MAX;
    }

    dp[0]=0;

    REP(i, n){
        cin >> w >> v;
        for(int j=100004-v;j>=0;j--){
            if(dp[j]!=INT_MAX && dp[j]+w<=u)dp[j+v] = min(dp[j]+w, dp[j+v]);
        }
    }
    for(int i=100004;i>=0;i--){
        if(dp[i]!=INT_MAX){
            cout << i;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    int h,w; cin>>h>>w;
    int k; cin>>k;
    string s[h];
    for (int i = 0; i < h; ++i)
    {
        cin>>s[i];
    }
    int ans=0;
    set<pair<int,int>> ss;
    for(int i1=0; i1<(1<<h); i1++){
        for(int i2=0; i2<(1<<w); i2++){
            string temp[h];
            for (int i = 0; i < h; ++i)
            {
                temp[i]=s[i];
            }

            for(int j1=0; j1<h; j1++){
                for(int j2=0; j2<w; j2++){
                    
                    if(i1&(1<<j1)){
                        for(int j=0; j<w; j++){
                            temp[j1][j]='$';
                        }
                    }
                    if(i2&(1<<j2)){
                        for(int j=0; j<h; j++){
                            temp[j][j2]='$';
                        }
                    }
                }
            }
            
            int s=0;
            for (int i = 0; i < h; ++i)
            {
                for(int j=0; j<w; j++){
                    if(temp[i][j]=='#')
                        s++;
                }
            }
            if(s==k){
                ans++;
                // ss.insert({j1,j2});
                // cout<<j1<<" "<<j2<<"\n";
                // ans++;
            }
        }
    }
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int n,m,ans=0;
int a[60],b[60];
bool graph[60][60];
bool visit[60];
void dfs(int v)
{
	visit[v]=true;
	for(int v2=0;v2<n;v2++)
	{
		if((!graph[v][v2])||visit[v2])
		continue;
		dfs(v2);
	}
}
int main()
{
	cin >>n>>m;
	for(int i=0;i<m;i++)
	{
    	cin >>a[i]>>b[i];
    	a[i]--;
    	b[i]--;
    	graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  	}
  	for(int i=0;i<m;i++)
  	{
  		graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
  		for(int j=0;j<n;j++)
  		visit[j]=false;
  		dfs(0);
  		for(int j=0;j<n;j++)
  		if(visit[j]==false)
  		{
  			ans++;
  			break;
	    }
		graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
    }
    cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 256