akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
using namespace std;
int read(){
	int f=1,x=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return f*x;
}
void out(){
	cout<<"No";
	exit(0);
}
char s[510],t[510],s1[510];
int ls,lt,i;
int main(){
	cin>>s>>t;
	ls=strlen(s);
	lt=strlen(t);
//	cout<<ls<<" "<<lt;
	if(ls!=lt)out();
	lt+=2;i=0;
	while(i<lt){
		s1[0]=s[ls-1];
		for(int j=1;j<ls;j++){
			s1[j]=s[j-1];
		}
		for(int j=0;j<ls;j++)s[j]=s1[j];
		if(strcmp(s1,t)==0){
			cout<<"Yes";
			return 0;
		}
		i++;
	}
	out();
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	int A = sc.nextInt();
	int B = sc.nextInt();
	int C = sc.nextInt();
	
	if(A == B && A == C && B == C){
	    System.out.println("Yes");
    }else{
		System.out.println("No");
	}
}
}

Measured memory_bytes: 21972
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}
ll N,A,B;
vector<ll>h(100005);
bool isOK(ll mid){
	ll ret=0;
	for(int i=0;i<N;i++){
		if(h[i]-mid*B>0){
			ret+=(h[i]-mid*B+(A-B)-1)/(A-B);
		}
	}
	return ret<=mid;
}


int main(){
	init();
	ll a,b,c;
	cin>>a>>b>>c;
	ll num=100*a+10*b+c;
	if(num%4==0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

string s;
int q;
deque<char> dq;

int main() {
	ios_base::sync_with_stdio(0);
	cin >> s;
	REP(i, sz(s)) {
		dq.push_back(s[i]);
	}
	cin >> q;
	bool rev = false;
	REP(_, q) {
		int t;
		cin >> t;
		if (t == 1) {
			rev = (1 - rev);
		} else {
			int f;
			char p;
			cin >> f >> p;
			f--;
			if ((f + rev) % 2 == 0) {
				dq.push_front(p);
			} else {
				dq.push_back(p);
			}
		}
	}
	string ans = "";
	for (auto x: dq) ans += x;
	if (rev) reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1368
//To debug :  g++ -g file.cpp -o code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 INT_MAX
#define big3 1000000000
#define sma -(big+1)
#define sma1 LONG_MIN
#define sma2 INT_MIN
#define sma3 -1000000000
#define mp make_pair
#define mt make_tuple
#define dub double
#define ivec vector<int>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define inv2 500000004
#define MOD 998244353 
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{

	ll k,n,i,ans = big;

	cin>>k>>n;

	ll a[n];

	rep(i,0,n)	
		cin>>a[i];

	sort(a,a+n);

	if(n==1)
	{
		cout<<0<<"\n";
		return 0;
	}

	rep(i,1,n)
	{
		ans = min(ans,k - (a[i]-a[i-1]));
	}

	ans = min(ans,k - (k - (a[n-1]-a[0])));


	cout<<ans<<"\n";




	return 0;
}

Measured memory_bytes: 1792
//#include <iostream>
//#include <math.h>
//using namespace std;
// 
//int main(){
//	int N;
//	int arr[8][2]={0,};
//	int sum=0;
//	double average=0;
//
//	cin >> N;
//
//	for(int i=0;i<N;i++){
//		for(int j=0; j<2; j++){
//			cin >> arr[i][j];
//		}
//	}
//
//	for(int i=0;i<N-1;i++){
//		for(int j=i+1; j<N; j++){
//			cin >> arr[i][j];
//		}
//	}
//
//
//	return 0;
//}

#include <iostream>
#include <string>
using namespace std;

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

	if("SUN" == S){
		cout << 7;
	}else if("MON" == S){
		cout << 6;
	}else if("TUE" == S){
		cout << 5;
	}else if("WED" == S){
		cout << 4;
	}else if("THU" == S){
		cout << 3;
	}else if("FRI" == S){
		cout << 2;
	}else if("SAT" == S){
		cout << 1;
	}else{
		cout << "error";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repi(i,x,n) for(int i = x; i < n; i++)
#define rep(i,n) repi(i,0,n)
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;

#define int long long

#define MAX 5100

#define x first
#define a second

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, L;
    vector<pair<int,int>> t, z;
    static int dp[MAX][MAX];
    // vector<vector<int>> dp;
    int ans = 0;

    cin>>N>>L;
    
    t.resize(N+10);
    //dp.resize(N+5,vector<int>(L+5,0));
    
    for(int i = 0; i < N; i++){
        cin>>t[i].x;
    }
     for(int i = 0; i < N; i++){
        cin>>t[i].a;
    }

     for(int i = N-1; i >= 0; i--){
         z.push_back(t[i]);
     }

     for(int i = z[0].x; i < L; i += z[0].a){
         dp[0][i] = 1;
         // cout<<0<<" "<<i<<" "<<dp[0][i]<<endl;
         if(z[0].a == 0) break;
     }
     
     for(int i = 1; i < N; i++){
         for(int j = L-i, sum = 0; j >= z[i].x; j--){
             if(z[i].a == 0){
                 if(z[i].x == j){
                     dp[i][j] = sum%MOD;
                 }
             } else if((j-z[i].x)%z[i].a == 0){
                 dp[i][j] = sum%MOD;
                 //cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
             }
             sum += dp[i-1][j];
             sum %= MOD;
         }
     }

     for(int i = 0; i < L; i++){
         ans += dp[N-1][i];
         ans %= MOD;
     }

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




Measured memory_bytes: 62016
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        while (true){
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            if (op.equals("?"))
                break;
            if (op.equals("+"))
                System.out.println(a + b);
            else if (op.equals("-"))
                System.out.println(a - b);
            else if (op.equals("*"))
                System.out.println(a * b);
            else if (op.equals("/"))
                System.out.println(a / b);
        }
    }
}



Measured memory_bytes: 26336
#include<bits/stdc++.h>
// using namespace std;
typedef long long ll;
const int N=2e5+5;
int main(){
    // ios::sync_with_stdio(false),std::cin.tie(0),std::cout.tie(0);
    // freopen("a.in","r",stdin);
    // int T;scanf("%d",&T);for(int tttt=1;tttt<=T;tttt++){
    if(true){
    // while(~scanf("%d",&n)){
    char s[4];
    scanf("%s",s);
    int cnt=1,ans=0;
    for(int i=1;i<=3;i++){
        if(s[i]!=s[i-1]){
            if(s[i-1]=='R')ans=std::max(cnt,ans);
            cnt=1;
        }
        else cnt++;
    }
    printf("%d\n",ans);
    }return 0;
}


Measured memory_bytes: 3760
N = int(input())
c = 0
for i in range(N):
  d1, d2 = map(int, input().split())
  if d1 == d2:
    c += 1
    if c >= 3:
      break
  else:
    c = 0
if c >= 3:
  print('Yes')
else:
  print('No')
  

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

int main(){
  cout << fixed << setprecision(12);
 
  double r; 
  cin>>r;

  double PI = acos(-1); 
  double area = r * r * PI;
  double cir = (r + r) * PI;
  cout<<area<<" "<<cir<<endl;

  return 0 ;
}



Measured memory_bytes: 3292
n=int(input())
import math
fac=math.factorial(n)
mod=10**9+7
#エラトステネスの篩で素数リストを作り
ans=[0]*(n+1)
ans[0]=ans[1]=1
i=2
while i*i<=n:
    j=2
    while i*j<=n and ans[i]==0:
        ans[i*j]=1
        j+=1
    i+=1
v=[]
for i in range(n+1):
    if ans[i]==0:
        v.append(i)
total=1
count=0
#素数リストの中からできるだけ割る
for i in v:
    while fac%i==0:
        count+=1
        fac//=i
    total*=count+1
    count=0
print(total%mod)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){

    int sum = 0;
    int n = 0;
    cin >> n;

    int *b = new int[n - 1];
    int *bCopy = new int[n - 1];
    for (int i = 0; i < n -1; i++){
        cin >> b[i];
        bCopy[i] = b[i];
    }

    int tmp = 0;
    tmp = b[0];

    for (int i = n - 2; i >= 1; i--){
        //printf("%d : %d\n", b[i-1], b[i]);
        if (b[i-1] > b[i]){
            bCopy[i-1] = b[i];
        }
    }
    
    for (int i = 0; i < n -1; i++){
        sum += bCopy[i];
    }

    sum += tmp;

    cout << sum << endl;

}


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

int main() {
	int n;cin>>n;
	string t,h;
	int ct=0,ch=0;
	for(int i=0;i<n;i++)
	{
		cin>>t>>h;
		if(t==h)ct++,ch++;
		else if(t<h)ch+=3;
		else ct+=3;
	}
	cout<<ct<<" "<<ch<<endl;
	return 0;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int x, a, b;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> x >> a >> b;
  if(a+x < b){
    cout << "dangerous" << endl;
    return 0;
  }
  if(a >= b){
    cout << "delicious" << endl;
    return 0;
  }
  cout << "safe" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx")
// #pragma comment(linker, "/stack:200000000"]
 
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>
#include <fstream>
#include <sstream>
#include <chrono>

#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map 
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

#define int ll

using namespace std;

#ifdef __LOCAL
	#define dbg(x) cerr << #x << " : " << x << '\n'
	const int maxn = 20;
#else 
	#define dbg(x)
	const int maxn = 2e5 + 20;
#endif

//tg: @galebickosikasa
 
const ll inf = (ll) 2e9;
const ld pi = asin (1) * 2;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());



signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g (n);
	vector<int> h (n);
	cinv (h);
	fr (i, m) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		g[a].pb (b), g[b].pb (a);
	}
	vector<int> kek (n);
	fr (i, n) {
		for (auto& x: g[i]) {
			kek[i] = max (kek[i], h[x]);
		}
	}
	int ans = 0;
	fr (i, n) {
		ans += (h[i] > kek[i]);
	}
	cout << ans;






}	

Measured memory_bytes: 10612
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n,m,j;
  cin >> n >> m >> j;
  ll co = 0;
  rrep1(i,100){
    if(n%i==0 && m%i == 0){
      co++;
      if(co==j) {
        pri(i);
        break;
      }
    }
  }
  return 0;
}


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

cnt = [[0 for _ in range(10)] for _ in range(10)]

for i in range(1, N + 1):
  s = str(i)
  if int(s[-1]) != 0:
    cnt[int(s[0])][int(s[-1])] += 1
    
answer = 0
for i in range(1, 10):
  for j in range(1, 10):
    answer += cnt[i][j] * cnt[j][i]

print(answer)

Measured memory_bytes: 3064
/*
 *  Author : Jun_SH
 *  Solution for ABC 145 D
 */
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
const int mod=1e9+7;
int quick_mod(int a, int b)
{
    int ans=1;
    a%=mod;
    while(b){
        if(b & 1){
            ans=ans*a%mod;
        }
        b>>=1;
        a=a*a%mod;
    }
    return ans;
}
int inv(int x){
    return quick_mod(x,mod-2);
}
int c(int m,int n){
    int a=1,b=1;
    for(int i=1;i<=n;++i){
        b=(b*i)%mod;
        a=(a*(m-n+i))%mod;
    }
    return a*inv(b)%mod;
}
main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int x,y;
    cin>>x>>y;
    if(y>2*x||x>2*y){
        cout<<(0)<<endl;
        return 0;
    }
    if(y>x){
        int del=y-x;
        x-=del;
        if(x%3){
            cout<<(0)<<endl;
            return 0;
        }
        cout<<c(2*x/3+del,x/3)<<endl;
    }
    else if(y<x){
        int del=x-y;
        y-=del;
        if(y%3){
            cout<<(0)<<endl;
            return 0;
        }
        cout<<c(2*y/3+del,y/3)<<endl;
    }
    else{
        if(x%3){
            cout<<(0)<<endl;
            return 0;
        }
        cout<<c(2*x/3,x/3)<<endl;
    }
}


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


int main() {
  int N;
  cin >> N;
  long a[310000];
  for(int i = 0; i < 3 * N; ++i) {
    cin >> a[i];
  }
  sort(a, a + 3 * N, greater<int>());
  long sum = 0;
  for(int i = 0; i < 2 * N; ++i) {
    if(i % 2 == 1) {
      
      sum += a[i];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 2560
n,m = map(int,input().split())
path = [[] for _ in range(n)]
ab = [list(map(int,input().split())) for _ in range(m)]
for a,b in ab:
  path[a-1].append(b-1)
  path[b-1].append(a-1)

def DFS(now,v_set):
  if v_set.count(True) == n:
    return 1
  if all(v_set[i] for i in path[now]):
    return 0
  c = 0
  for v in path[now]:
    if v_set[v]==False:
      v_set[v] = True
      c += DFS(v,v_set)
      v_set[v] = False
  return c
  
v_set = [False]*n
v_set[0] = True
print(DFS(0,v_set))

Measured memory_bytes: 3064
import bisect

n, m , k = [int(x) for x in input().strip().split()]

a = [int(x) for x in input().strip().split()]
b = [int(x) for x in input().strip().split()]

pa = []
pb = []
s=0
for e in a:
    s+=e
    pa.append(s)

s=0
for e in b:
    s+=e
    pb.append(s)

res=0
for i in range(n):
    elem = k-pa[i]
    if elem<0:
        break
    ind = bisect.bisect_right(pb,elem)
    # print(ind, i)
    res = max(res, ind+i+1)

for i in range(m):
    elem = k-pb[i]
    if elem<0:
        break
    ind = bisect.bisect_right(pa,elem)
    # print(ind, i)
    res = max(res, ind+i+1)

ind = bisect.bisect_right(pa,k)
res = max(res, ind)

ind = bisect.bisect_right(pb,k)
res = max(res, ind)

print(res)



Measured memory_bytes: 133624
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n;
vll a;

void output(){
    cout << a[0];
    for(lli i = 1;i < n;i++){
        cout << " " << a[i];
    }
    cout << endl;

}

int main(){
    cin >> n;
    a = vll(n);
    for(lli i = 0;i < n;i++) cin >> a[i];
    for(lli i = 0;i < n;i++){
        for(lli j = i-1;j >= 0 && a[j] > a[j+1];j--){
            swap(a[j],a[j+1]);
        }
        output();
    }
    return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const long long  int INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"

void Main()
{
	ll N,M;
	ll result=0;
	string S;
	cin>>N>>M;
	if(N==1&&M==1){
		result=1;
	}
	else if(N==1||M==1){
		result=max(N,M)-2;
	}
	else {
		result=(N-2)*(M-2);
	}
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static long[] fac = new long[100_0000], finv = new long[100_0000], inv = new long[100_0000];

    static void COMinit() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < 100_0000; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    static long COM(int n, int k) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

    // int N = Integer.parseInt(scanner.nextLine());
    // int N = scanner.nextInt(), M = scanner.nextInt();
    // scanner.nextLine();
    // int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    // long[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToLong(Long::parseLong).toArray();
    static void solve(Scanner scanner) {
        COMinit();
        int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int X = Math.max(n[0], n[1]), Y = Math.min(n[0], n[1]);
        if ((X + Y) % 3 != 0) {
            System.out.println(0);
            return;
        }
        int diff = X - Y;
        int r = (Y - diff) / 3 + (X - Y);
        int d = (Y - diff) / 3;

        System.out.println(COM(r + d, r));
    }
}


Measured memory_bytes: 53456
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  int n; cin >> n;
  unordered_map<int, int> mp1;
  unordered_map<int, int> mp2;
  rep(i, n) {
    int a; cin >> a;
    if (i & 1) {
      mp1[a]++;
    } else {
      mp2[a]++;
    }
  }
  
  int ma1 = 0;
  int ma2 = 0;
  int pos1;
  int pos2;
  for(auto e : mp1) {
    //debug(e.first);debugln(e.second);
    if (e.second > ma1) {
      ma1 = e.second;
      pos1 = e.first;
    }
  }
  for(auto e : mp2) {
    //debug(e.first);debugln(e.second);
    if (e.second > ma2) {
      ma2 = e.second;
      pos2 = e.first;
    }
  }

  //debug(ma1);debug(ma2);debug(pos1);debugln(pos2);

  if (pos1 != pos2) {
    cout << n - ma1 - ma2 << endl;
    return 0;
  }

  int pos = pos1;
  int ma3 = 0;
  int ma4 = 0;
  for(auto e : mp1) {
    if (e.first != pos && e.second > ma3) {
      ma3 = e.second;
    }
  }
  for(auto e : mp2) {
    if (e.first != pos && e.second > ma4) {
      ma4 = e.second;
    }
  }
  cout << n - ma1 - ma2 + min(ma1 - ma3, ma2 - ma4) << endl;
}

Measured memory_bytes: 4376
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-9;
const int inf=1e8;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	int n,m;
	cin>>n>>m;
	vs a(n),b(m);
	rep(i,n)cin>>a[i];
	rep(i,m)cin>>b[i];
	rep(i,n-m+1)rep(j,n-m+1){
		bool h=true;
		rep(x,m)rep(y,m)if(a[i+x][j+y]!=b[x][y])h=false;
		if(h){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}











Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX=31;

int h,w,n,ok,ans,res;
string S[MAX],T[MAX];
int check[MAX][MAX];

int combo(){
    for (int i=0;i<h;++i)
        for (int j=0;j<w;++j)
            check[i][j]=0;
    for (int i=0;i<h;++i){
        for (int j=0;j<w;++j){
            if (T[i][j]=='.') continue;
            for (int k=0;k<n&&i+k<h;++k){
                if (T[i+k][j]!=T[i][j]) break;
                if (k==n-1) for (int l=0;l<n;++l){
                    check[i+l][j]=1;
                }
            }
            for (int k=0;k<n&&j+k<w;++k){
                if (T[i][j+k]!=T[i][j]) break;
                if (k==n-1) for (int l=0;l<n;++l){
                    check[i][j+l]=1;
                }
            }
        }
    }
    res=0;
    for (int i=0;i<h;++i)
        for (int j=0;j<w;++j)
            res|=check[i][j];
    for (int j=0;j<w;++j){
        for (int i=h-1;i>=0;--i){
            for (int k=i;k>=-1;--k){
                if (0<=k&&!check[k][j]){
                    T[i][j]=T[k][j];
                    check[k][j]=1;
                    break;
                }
                if (k==-1) T[i][j]='.';
            }
        }
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w >> n;
    for (int i=0;i<h;++i) cin >> S[i];
    ans=0;
    for (int i=0;i<h;++i){
        for (int j=0;j<w-1;++j){
            if (S[i][j]=='.'&&S[i][j+1]=='.') continue;
            for (int k=0;k<h;++k) T[k]=S[k];
            swap(T[i][j],T[i][j+1]);
            if (T[i][j]=='.'){
                for (int k=i-1;k>=0;--k)
                    swap(T[k][j],T[k+1][j]);
                for (int k=i+1;k<h;++k){
                    if (T[k][j+1]=='.') swap(T[k-1][j+1],T[k][j+1]);
                    else break;
                }
            }
            if (T[i][j+1]=='.'){
                for (int k=i-1;k>=0;--k)
                    swap(T[k][j+1],T[k+1][j+1]);
                for (int k=i+1;k<h;++k){
                    if (T[k][j]=='.') swap(T[k-1][j],T[k][j]);
                    else break;
                }
            }
            while(combo()){}
            ok=1;
            for (int k=0;k<h;++k)
                for (int l=0;l<w;++l)
                    if (T[k][l]!='.') ok=0;
            ans|=ok;
        }
    }
    cout << (ans?"YES":"NO") << '\n';
}


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

int main(){
  int N, T, A;
  cin >> N >> T >> A;
  
  int H;
  int min_ind=1;
  double min_diff=10000.0;
  for (int i=1;i<=N;i++) {
    cin >> H;
    if (abs(T-H*0.006-A)<min_diff) {
      min_diff = abs(T-H*0.006-A);
      min_ind = i;
    }
  }

  cout << min_ind << endl;

}

  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
int main()
{
    long K, N;
    cin >>N >> K;
    vector<long> p(N);
    rep(i, N) cin >> p.at(i);
    rep(i, N) p.at(i)++;
    int mx = 0;
    int s = 0;
    queue<int> q;
    rep(i,N){
        s += p[i];
        q.push(p[i]);
        if(q.size()>K){
            s -= q.front();
            q.pop();
        }
        if(q.size()==K){
            mx = max(mx, s);
        }
    }
    double ans = mx;
    ans /= 2;
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, c, k; cin >> n >> c >> k;
    vint a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    queue<int> t;
    rep(i,n) t.push(a[i]);
    int ans = 0;
    while (!t.empty()) {
        int x = t.front();
        int start = x + k;
        int ct = 0;
        while (ct < c && !t.empty()) {
            if (t.front() <= start) {
                t.pop();
                ct++;
            } else {
                break;
            }
        }
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4100
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(n):
    a=p[i]
    for j in range(n):
        b=p[j]
        for k in range(n):
            c=p[k]
            if a!=b and b!=c and c!=a and a+b>c and b+c>a and c+a>b and i<j<k:
                ans+=1
                #print(a,b,c,i,j,k)
print(ans)

Measured memory_bytes: 9196
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
using namespace std;
const int maxn=1000010;
int n,a[maxn],s[maxn],fa[maxn],st[maxn],dfn[maxn],tim;
bool f[maxn];
struct edge
{
	int t;
	edge *next;
}*con[maxn];
int read()
{
	int x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
	return x;
}
void ins(int x,int y)
{
	edge *p=new edge;
	p->t=y;
	p->next=con[x];
	con[x]=p;
}
void dfs()
{
	int top=1;st[1]=1;fa[1]=0;
	while(top>0)
	{
		int v=st[top--];
		dfn[++tim]=v;
		for(edge *p=con[v];p;p=p->next)
			if(p->t!=fa[v]) 
			{
				fa[p->t]=v;
				st[++top]=p->t;
			}
	}
	for(int i=n;i>1;i--){int v=dfn[i];if(a[v]<a[fa[v]]&&s[v]==0) s[fa[v]]++;}
	for(int i=2;i<=n;i++)
	{
		int v=dfn[i];
		f[v]=(s[fa[v]]-(a[fa[v]]>a[v]&&s[v]>0));
		if(a[fa[v]]<a[v]) s[v]+=(f[v]==0);
	}
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();	
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		ins(x,y);
		ins(y,x);
	}
	dfs();	
	for(int i=1;i<=n;i++)
		if(s[i]>0) printf("%d ",i);
	return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int A[3];
	cin >> A[0] >> A[1] >> A[2];
	sort(A,A+3);
	int ans=0;
	int d1=A[2]-A[1], d2=A[2]-A[0];
	ans+=d1/2+d2/2;
	if(d1%2==1 && d2%2==1) ans++;
	else if(d1%2==0 && d2%2==0);
	else ans+=2;
	cout << ans << endl;

	return 0;
}

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

long long int n, i, j, a = 1, d[6] = {1, 2, 3, 4, 5, 6};
char s[5];

main(){
    for(;scanf("%lld", &n),n;a=1){
        for(j = 0; j < 6; ++j){
            d[j] = j + 1;
        }
        j = 4;
        for(i = 0; i < n; ++i, j=4){
            scanf(" %s", s);
            switch(s[0]){
                case 'R':
                    swap(d[1], d[2]);
                    swap(d[4], d[2]);
                    swap(d[4], d[3]);
                    break;
                case 'L':
                    swap(d[1], d[3]);
                    swap(d[4], d[3]);
                    swap(d[4], d[2]);
                    break;
                case 'N':
                    --j;
                case 'W':
                    --j;
                case 'E':
                    --j;
                case 'S':
                    swap(d[0], d[j]);
                    swap(d[5], d[j]);
                    swap(d[5], d[5 - j]);
                    break;
            }
            a += d[0];
        }
        cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 3164
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(N, M, inputs):
    roads = list(map(string_to_int, inputs))
    towns = {i+1: [] for i in range(N)}

    for r in roads:
        towns[r[0]].append(r[1])
        towns[r[1]].append(r[0])
    ret = []

    for t in sorted(towns.keys()):
        ret.append(len(towns[t]))
    return ret


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    [N, M] = string_to_int(input())
    ret = solve(N, M, inputs(M))
    for r in ret:
        print(r)


Measured memory_bytes: 38512
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sc scanf
using namespace std;
const int N=1e5+5;
const int mod=1e9+7;
typedef unsigned long long ull;
typedef long long ll;
template <typename it>int o(it a){cout<<a<<endl;return 0;}
char s[10];
int main(){
	 cin>>s;
	 if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])o("Bad");
	 else o("Good");
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll mult_mod(ll x, ll y, ll mod){
    return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
}

ll pow_mod(ll a, ll b, ll p){
    ll res = 1;
    while (b){
        if (b & 1)
            res = mult_mod(res, a, p);
        a = mult_mod(a, a, p);
        b >>= 1;
    }
    return res % p;
}

ll gcd(ll a, ll b){
    return b ? gcd(b, a % b) : a;
}

const int N = 2e5 + 10;

ll n, k, x, l, r, mid, tmp;
vector<ll> a, f;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i ++ ){
        cin >> x;
        a.push_back(x);
    }
    for (int i = 1; i <= n; i ++ ){
        cin >> x;
        f.push_back(x);
    }
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());
    for (int i = 0; i < n; i ++ )
        r = max(r, a[i] * f[i]);
    while (l < r){
        mid = (l + r) >> 1;
        tmp = 0;
        for (int i = 0; i < n; i ++ )
            tmp += max(0ll, a[i] - mid / f[i]);
        if (tmp <= k)
            r = mid;
        else
            l = mid + 1;
    }
    cout << l << "\n";
    return 0;
}

Measured memory_bytes: 5872
def main():
    n=int(input())
    ga,sa,ba=map(int,input().split())
    gb,sb,bb=map(int,input().split())
    
    def calc_1(dg,a0,a1):
        return (dg//a0)*a1+dg%a0

    def calc_2(dg,a0,a1,b0,b1):
        x=dg//a0
        visit=set()
        temp=0
        for i in range(x,-1,-1):
            amari=(dg-i*a0)%b0
            if amari in visit:
                break
            temp=max(i*a1+((dg-i*a0)//b0)*b1+amari,temp)
            visit.add(amari)
        return temp

    def calc_3(dg,a0,a1,b0,b1,c0,c1):
        return max([a1*i+calc_2(dg-a0*i,b0,b1,c0,c1) for i in range(dg//a0,-1,-1)])

    gsb=[[ga,gb],[sa,sb],[ba,bb]]
    gsb.sort(key=lambda x:x[1]/x[0],reverse=True)
    temp=[[i,j] for i,j in gsb if i<j]
    if len(temp)==1:
        n=calc_1(n,temp[0][0],temp[0][1])
    elif len(temp)==2:
        n=calc_2(n,temp[0][0],temp[0][1],temp[1][0],temp[1][1])
    elif len(temp)==3:
        n=calc_3(n,temp[0][0],temp[0][1],temp[1][0],temp[1][1],temp[2][0],temp[2][1])

    gsb=reversed(gsb)
    temp=[[j,i] for i,j in gsb if i>j]
    if len(temp)==1:
        n=calc_1(n,temp[0][0],temp[0][1])
    elif len(temp)==2:
        n=calc_2(n,temp[0][0],temp[0][1],temp[1][0],temp[1][1])
    elif len(temp)==3:
        n=calc_3(n,temp[0][0],temp[0][1],temp[1][0],temp[1][1],temp[2][0],temp[2][1])
    print(n)
main()

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;

    string S;
    cin >> S;

    S.at(K-1) = tolower(S.at(K-1));

    cout << S << endl;
}


Measured memory_bytes: 256
n = int(input())
ass = input().split()
for i in range(n):
	ass[i] = int(ass[i])

ass.sort(reverse=True)

if 0 in ass:
	print(0)
	exit()

ans = 1
for i in range(n):
	ans *= ass[i]
	if ans > 10**18:
		print(-1)
		exit()

print(ans)


Measured memory_bytes: 19344
// Contest: AtCoder Beginner Contest 158 (https://atcoder.jp/contests/abc158)
// Problem: C: Tax Increase (https://atcoder.jp/contests/abc158/tasks/abc158_c)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    int a, b; cin >> a >> b;
    reps(i, 1, 10000)
        if (8 * i / 100 == a && i / 10 == b)
            cout << i << '\n', exit(0);
    cout << "-1\n";

    return 0;
}

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

int main() {
    int N;
    cin >> N;
    long long h[N];
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }

    long long dp[N];

    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for (int i = 2; i < N; i++) {
        dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]), dp[i-1] + abs(h[i] - h[i-1]));
    }

    cout << dp[N-1] << endl;
}

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

int main(){
	long N,K;
	cin >> N >> K;
	vector<double> A(N);
	for(long i=0; i<N; i++) cin >> A.at(i);

	for(long i=K; i<N; i++){
		if(A.at(i)/A.at(i-K)>1){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	/*
	double buff = 1;
	for(long j=0; j<K; j++) buff*=A.at(j);
	for(long i=K; i<N; i++){
		double buff2 = buff*A.at(i)/A.at(i-K);
		if(buff < buff2){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
		buff=buff2;
	}
	*/
	return 0;
}


Measured memory_bytes: 4788
#include<stdio.h>
#include<set>
using std::set;

int n;
set<int> S;

int main(void){
	int n;
	scanf("%d",&n);
	for(int i=0,temp;i<n;i++){
		scanf("%d",&temp);
		if(S.find(temp)!=S.end())
			S.erase(temp);
		else
			S.insert(temp);
	}
	return printf("%d\n",S.size()),0;
}

Measured memory_bytes: 4864
n = int(input())
d  =list(map(int,input().split()))
d.sort()
m = int(input())
t = list(map(int,input().split()))
t.sort()
i = 0
for x in t:
    while d[i] < x:
        i += 1
    if d[i] == x:
        i += 1
    else:
        print("NO")
        exit()
print("YES")

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

int main(int argc,char* argv[]){
  int num,score;
  char c;

  std::multimap<int,int> map;

  while(std::cin >> num >> c >> score){
    if(num == 0 && score == 0){break;} 
    map.insert(std::multimap<int,int>::value_type(score,num));
  }

  while(std::cin >> num){
    std::multimap<int,int>::reverse_iterator it = map.rbegin();
    int pre_s = -1,count = 0;
    bool end = false;
    while(it != map.rend()){
      if((*it).first != pre_s){
	pre_s = (*it).first;
	count++;
      }
      
      if((*it).second == num){
	end = true;
	break;
      }
      
      if(end){
	break;
      }

      ++it;
    }
    
    std::cout << count << std::endl;
  }
  
  
  return 0;
  
}

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

using namespace std;

#define all(x) (x).begin(),(x).end()
#define sz(x) (int)x.size()
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define debug(x) cerr << "  - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << "  - " << #x << ": " << x << "\t\t" << #y << ": " << y << endl;
#define debugv(v, n) cerr << #v << " : " << " "; for(int i = 0; i < n; i++) cerr << "\t" << #v << "[" <<  i <<  "]" <<  " : " << v[i] << "\n"; cerr << endl;
#define sep() cerr << "--------------------" << endl;

typedef long long ll;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const int N = 3005;

string s, t;
string res;

int dp[N][N];
int go(int i, int j) {
	if(i == sz(s) || j == sz(t)) return 0;
	int &ret = dp[i][j];
	if(ret != -1) return ret;
	ret = 0;
	if(s[i] == t[j])
		ret = max(ret, 1 + go(i + 1, j + 1));
	
	ret = max(ret, go(i + 1, j));
	ret = max(ret, go(i, j + 1));
	
	return ret;
}

void build(int i, int j) {
	if(i == sz(s) || j == sz(t)) return;
	// if(go(i, j) == 1 + go(i + 1, j + 1)) {
	// 	res += s[i];
	// 	build(i + 1, j + 1);
	// 	return;
	// }
	if(s[i] == t[j]) {
		res += s[i];
		build(i + 1, j + 1);
		return;
	}
	else {
		if(go(i, j) == go(i + 1, j)) {
			build(i + 1, j);
			return;
		}
		if(go(i, j) == go(i, j + 1)) {
			build(i, j + 1);
			return;
		}
		assert(false);
	}
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s >> t;
	
	memset(dp, -1, sizeof dp);
	int ans = go(0, 0);
	build(0, 0);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 35968
import java.util.ArrayList;
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		int human = sc.nextInt();
		int okashi = sc.nextInt();
		int cnt = 0;

		ArrayList<Integer> list = new ArrayList<>();

		for(int i = 1; i <= human; i++){
			list.add(i);
		}

		for(int i = 0; i < okashi; i++){
			cnt = sc.nextInt();
			for(int j = 0; j < cnt; j++){
				list.remove((Object)sc.nextInt());
			}
		}

		System.out.println(list.size());

		sc.close();
	}
}

Measured memory_bytes: 46536
#include<bits/stdc++.h> 
using namespace std; 
typedef  pair<int, int> iPair; 
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
   
}
    
ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}
 
ll minl(ll a,ll b){
    if(a>b)return b;
    return a;
}
 
ll mod = 998244353;
 
ll mulmod(ll a, ll b,ll c){ 
    ll res = 0; 
    a = a % c; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % c;
        }
        a = (a * 2) % c; 
        b /= 2; 
    } 
    return res % c; 
}
 
int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid; 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return -1; 
} 
 
int a[100005];
int tree[200005];
 
void build(int st,int low,int high){
    if(low==high){
        tree[st] = a[high]%2;
        return;
    }
    int mid = low+(high-low)/2;
    build(2*st,low,mid);
    build(2*st+1,mid+1,high);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
void update(int st,int start,int end,int ind,int val){
    if(start==end){
        tree[st] = val%2;
        return;
    }
    int mid = start+(end-start)/2;
    if(ind<=mid){
        update(2*st,start,mid,ind,val);
    }
    else update(2*st+1,mid+1,end,ind,val);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
int query(int st,int start,int end,int low,int high){
    if(start>high || end<low)return 0;
    int mid = start + (end-start)/2;
    if(start==low && end==high){
        return tree[st];
    }
    if(low>mid)return query(2*st+1,mid+1,end,low,high);
    if(high<=mid)return query(2*st,start,mid,low,high);
    return query(2*st,start,mid,low,mid)+query(2*st+1,mid+1,end,mid+1,high);
}

int main()
{
        ios_base::sync_with_stdio(false);
        ll n;
        cin >> n;
        int a[n+1];
        int b[n+1];
        int c[n];
        for(int i=0;i<n;i++){
            cin >> a[i];
        }
         for(int i=1;i<=n;i++){
            cin >> b[i];
        }
         for(int i=1;i<=n-1;i++){
            cin >> c[i];
        }
        ll ans = b[a[0]];
        for(int i=1;i<n;i++){
            ans+=b[a[i]];
            if(a[i]==a[i-1]+1)ans+=c[a[i-1]];
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 256
S = str(input())
K = int(input())

ans = 1
index = 0
for j in range(len(S)):
    if S[j] != '1':
        ans = int(S[j])
        index = j
        break

if ans == 1:
    print(ans)
elif index > K-1:
    print(1)
else:
    print(ans)
        

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

int main() {
    int Alice, Bob;
    cin >> Alice >> Bob;

    if (Alice == Bob ) cout << "Draw" << endl;
    else if (Alice == 1) cout << "Alice" << endl;
    else if (Bob == 1) cout << "Bob" << endl;
    else if (Alice != 1 && Bob != 1) {
        cout << (Alice > Bob ? "Alice" : "Bob") << endl;
    } 

    return 0;
}

Measured memory_bytes: 256