akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    string a,b;
    cin>>a>>b;
    reverse(b.begin(),b.end());
    if(a==b){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

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

//--> definitions
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define RFOR(i,a,b) for(int i=b-1;i>=a;i--)

//--> typedef
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<pii,int> piii;
typedef tuple<int,int,int> tiii;

#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define INF 1e9

const int maxN = 1e4+11;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    
    float d,t,s;
    
    cin>>d>>t>>s;
    
    if((d/s) <=t)
        cout<<"Yes\n";
    else
        cout<<"No\n";


	return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;


int main(){
	int W,Q;
	int a[100];
	while(cin>>W>>Q,W|Q){
		memset(a,-1,sizeof(a));
		for(int i=0;i<Q;i++){
			char c;
			cin>>c;
			if(c=='s'){
				int id,w;
				cin>>id>>w;
				int pos=-1;
				for(int j=0;j<=W-w;j++){
					bool ok=true;
					for(int k=0;k<w;k++)
						if(a[j+k]!=-1)ok=false;
					if(ok){
						pos=j;
						break;
					}
				}
				if(pos==-1)cout<<"impossible"<<endl;
				else{
					cout<<pos<<endl;
					for(int j=0;j<w;j++)a[pos+j]=id;
				}
			}else{
				int id;
				cin>>id;
				for(int j=0;j<W;j++)
					if(a[j]==id)a[j]=-1;
			}
		}
		cout<<"END"<<endl;
	}
    return 0;
}

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

int rec(int num,int min,int t){
  if(!t){
    if(!num)return 1;
    else return 0;
  }

  int res = 0;
  for(int i=min;i*i<=num;i++)res += rec(num-i*i,i,t-1);
  return res;
}
    
int main(){
  int n;
  for(;;){
    cin >> n;
    if(!n)break;
    cout << rec(n,0,4) << endl;
  }
}

Measured memory_bytes: 868
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        400005
#define mod         1000000007
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,sum=0,sum1=0,mi=MAX;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sum1=0;
    for(i=0;i<n-1;i++){
        sum1+=a[i];
        sum-=a[i];
        mi=min(mi,abs(sum1-sum));
    }
    cout<<mi;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long X, K, D;
  cin >> X >> K >> D;
  X = abs(X);
  long long dis = X / D;
  long long ans;
  if (dis >= K) {
    ans = X - K*D;
  }
  else {
    if ((dis % 2) == (K % 2)) {
      ans = X % D;
    }
    else {
      ans = D- (X % D);
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static boolean[][] need;

	public static void main(String[] args) {
		int T = sc.nextInt();
		for (int i = 0; i < T; ++i) {
			int N = sc.nextInt();
			String state = sc.next();
			need = new boolean[2][N + 1];
			for (int j = 0; j < 2 * N; ++j) {
				if (state.charAt(j) == 'Y') {
					need[0][(j + 1) / 2] = true;
				}
				if (state.charAt(j + 2 * N) == 'Y') {
					need[1][(j + 1) / 2] = true;
				}
			}
			int[] dp = new int[3];
			dp[1] = dp[2] = 1 << 28;
			for (int j = 0; j <= N; ++j) {
				int[] next = { Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE };
				if (need[1][j]) {
					next[0] = Math.min(next[0], dp[0] + 3);
					next[1] = Math.min(next[1], dp[0] + 2);
				} else if (need[0][j]) {
					next[0] = Math.min(next[0], dp[0] + 1);
					next[1] = Math.min(next[1], dp[0] + 1);
				} else {
					next[0] = dp[0];
					next[1] = Math.min(next[1], dp[0] + 1);
				}
				next[2] = Math.min(next[2], dp[0] + 2);

				if (need[0][j] && need[1][j]) {
					next[1] = Math.min(next[1], dp[1] + 2);
					next[0] = Math.min(next[0], dp[1] + 2);
					next[2] = Math.min(next[2], dp[1] + 2);
				} else if (need[0][j] || need[1][j]) {
					next[1] = Math.min(next[1], dp[1] + 1);
					next[0] = Math.min(next[0], dp[1] + 1 + (need[1][j] ? 1 : 0));
					next[2] = Math.min(next[2], dp[1] + 1 + (need[0][j] ? 1 : 0));
				} else {
					next[1] = Math.min(next[1], dp[1]);
					next[0] = Math.min(next[0], dp[1] + 1);
					next[2] = Math.min(next[2], dp[1] + 1);
				}

				if (need[0][j]) {
					next[2] = Math.min(next[2], dp[2] + 3);
					next[1] = Math.min(next[1], dp[2] + 2);
				} else if (need[1][j]) {
					next[2] = Math.min(next[2], dp[2] + 1);
					next[1] = Math.min(next[1], dp[2] + 1);
				} else {
					next[2] = Math.min(next[2], dp[2]);
					next[1] = Math.min(next[1], dp[2] + 1);
				}
				next[0] = Math.min(next[0], dp[2] + 2);

				++next[0];
				++next[1];
				++next[2];
				dp = next;
			}
			System.out.println(dp[0] - 1);
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int n; cin >> n;
  vector<int> a(n);
  vector<int> ans(n);
  int index = 1;
  rep(i, n) {
    cin >> a[i];
    a[i] --;
    ans[a[i]] = index;
    index ++;
  }

  rep(i, n) {
    if (i) cout << " ";
    cout << ans[i];
  }
  cout << endl;
}

Measured memory_bytes: 1664
#include<iostream>
#include<sstream>
#include<fstream>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<cctype>
#include<vector>
#include<string>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define mem(a,b) memset(a,b,sizeof(a))
#define random(a,b) (rand()%(b-a+1)+a)
#define ll long long
#define ull unsigned long long
#define e 2.71828182
#define Pi acos(-1.0)
#define ls(rt) (rt<<1)
#define rs(rt) (rt<<1|1)
#define lowbit(x) (x&(-x))
using namespace std;
int read()
{
	int s=1,x=0;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') s=-1;ch=getchar();}
	while(isdigit(ch)) {x=10*x+ch-'0';ch=getchar();}
	return x*s;
}
int main()
{
	int r=read();
	cout<<r*r; 
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

template<unsigned long long mod>
class basic_mod_int{
private:
    unsigned long long num;
public:
    static basic_mod_int pow(basic_mod_int x,unsigned long long y)
    {
        return y==0?1:y%2==0?pow(x*x,y/2):x*pow(x,y-1);
    }
    basic_mod_int()=default;
    basic_mod_int(unsigned long long n):num(n%mod)
    {
    }
    explicit operator unsigned long long()const
    {
        return num;
    }
    bool operator==(const basic_mod_int&mi)const
    {
        return num==mi.num;
    }
    bool operator!=(const basic_mod_int&mi)const
    {
        return !operator==(mi);
    }
    basic_mod_int operator~()const
    {
        return pow(*this,mod-2);
    }
    basic_mod_int operator+(const basic_mod_int&mi)const
    {
        return num+mi.num;
    }
    basic_mod_int operator-(const basic_mod_int&mi)const
    {
        return num+mod-mi.num;
    }
    basic_mod_int operator*(const basic_mod_int&mi)const
    {
        return num*mi.num;
    }
    basic_mod_int operator/(const basic_mod_int&mi)const
    {
        return num*(~mi).num;
    }
    basic_mod_int&operator+=(const basic_mod_int&mi)
    {
        return*this=operator+(mi);
    }
    basic_mod_int&operator-=(const basic_mod_int&mi)
    {
        return*this=operator-(mi);
    }
    basic_mod_int&operator*=(const basic_mod_int&mi)
    {
        return*this=operator*(mi);
    }
    basic_mod_int&operator/=(const basic_mod_int&mi)
    {
        return*this=operator/(mi);
    }
};
int main()
{
    using mod_int=basic_mod_int<static_cast<unsigned long long>(1e9+7)>;
    ll n=in(),k=in();
    mod_int ans=0;
    vector<mod_int>p(k+1);
    for(int g=k;g>=1;--g){
        p[g]=mod_int::pow(k/g,n);
        for(ll i=g*2;i<=k;i+=g)p[g]-=p[i];
        ans+=p[g]*g;
    }
    cout<<(unsigned long long)ans<<endl;
}


Measured memory_bytes: 3980
#include <stdio.h>
int main(){
	int a,b[100],x=0,y=0;
	scanf("%d",&a);
	for (int i = 0; i < a; ++i)
	{
		scanf("%d",&b[i]);
	}
	for (int j = 0; j < a; ++j)
	{
		if (x<=b[j])
		{
			x=b[j];
		}
		y=y+b[j];
	}
	printf("%d\n",y-(x/2));
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}


int main(){

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

    string s, t;
    cin >> s >> t;

    int q; cin >> q;
    vector<int> s_a(s.size()+1), t_a(t.size()+1);
    s_a[0] = t_a[0] = 0;
    for(int i = 0; i < s.size(); ++i){
        s_a[i+1] = s_a[i] + (s[i] == 'A');
    }

    for(int i = 0; i < t.size(); ++i){
        t_a[i+1] = t_a[i] + (t[i] == 'A');
    }
    for(int i = 0; i < q; ++i){
        int a, b, c, d;
        cin >> a >> b >> c >> d;

        int s_a_num = s_a[b] - s_a[a-1];
        int t_a_num = t_a[d] - t_a[c-1];

        JUDGE(((s_a_num-a+b+1) % 3) == ((t_a_num-c+d+1) % 3));
    }

    return 0;
}


Measured memory_bytes: 1744
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ll n,i,t=1,f=0; cin>>n;
    ll a[n];
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<n;i++){
        if(a[i]==t){
            f++;
            t++;
        }
    }
    if(f==0) cout<<-1<<endl;
    else cout<<n-f<<endl;
}

Measured memory_bytes: 1792
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: usize = read();
    let avec: Vec<u64> = read_vec();
    let mut cnt: Vec<u64> = vec![0, 0, 0];
    let mut ans: u64 = 1;
    for i in 0..n {
        let a = avec[i];
        let mut tmpc = 0;
        let mut tmpi = 0;
        for j in 0..3 {
            if cnt[j] == a {
                tmpc += 1;
                tmpi = j
            }
        }
        cnt[tmpi] += 1;
        ans = (ans * tmpc) % 1000000007;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int arr[509][509];
int main()
{
        int n, m, q, i, j, x, y, ans;
        for(i=0; i <= 509; i++)
                for(j=0; j<=509; j++)
                        arr[i][j] = 0;

        cin >> n >> m >> q;
        for(i=1; i<=m; i++){
                cin >> x >> y;
                arr[x][y] += 1;
        }
        for(i=1; i<=n; i++){
                for(j=i; j<=n; j++)
                        arr[i][j] += arr[i][j-1];
        }
        for(j=n; j>=1; j--){
                for(i=j; i>=1; i--){
                        arr[i][j] += arr[i+1][j];
                }
        }
        for(i=1; i<=q; i++){
                cin >> x >> y;
                cout << arr[x][y] << endl;
        }
        return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0); }

int main() {
  ull n;
  cin >> n;

  vector<ull> h;
  each(i, n) {
    ull tmp;
    cin >> tmp;
    h.push(tmp);
  }

  ull result = 1;
  auto first = h[0];
  vector<ull> bef;
  bef.push(h[0]);
  for (auto i=1; i < n; i++) {
    bool all = true;
    each(j, bef.size()) {
      if (h[i] >= bef[j]) {
      } else {
        all = false;
        break;
      }
    }

    if (all) {
      result++;
    }

    bef.push(h[i]);
  }

  cout << result << endl;


  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
void Merge(int s[],int l,int r);
int temp[1000000];
int c=0;
int main(){
  int n,i,j,l,m,r,q;
  int a[1000000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  Merge(a,0,n-1);
  for(i=0;i<n-1;i++){
    printf("%d ",a[i]);
  }
  printf("%d\n",a[n-1]);
  printf("%d\n",c);
  return 0;
}
void Merge(int x[],int left,int right){
  int mid,i,j,k;
  if(left>=right){
    return;
  }
  mid=(left+right)/2;
  Merge(x, left, mid);
  Merge(x, mid + 1, right);
  for (i = left; i <= mid; i++){
    temp[i] = x[i];
  }

  for (i = mid + 1, j = right; i <= right; i++, j--){
    temp[i] = x[j];
  }

  i = left;
  j = right;

  for (k = left; k <= right; k++){
    if (temp[i] <= temp[j]){
        x[k] = temp[i++];
        c++;
      }
    else{
        x[k] = temp[j--];
        c++;
      }
    }
}



Measured memory_bytes: 5632
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	
	int n;

	scanf("%d",&n);
	int ans = 0;
	for(int i=0,x;i<n;i++){
		scanf("%d",&x);
		while(x && x%2==0)ans++,x/=2;
	}
	printf("%d\n",ans );
}	



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    string S;
    cin >> S;
    ll ans = 0;
    if(S == "SUN") ans = 7;
    if(S == "MON") ans = 6;
    if(S == "TUE") ans = 5;
    if(S == "WED") ans = 4;
    if(S == "THU") ans = 3;
    if(S == "FRI") ans = 2;
    if(S == "SAT") ans = 1;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
int cc(int n,int bit){
    int c=0;
    rep(i,n){
        if(bit&(1<<i))c++;
    }
    return c;
}

int main(){
    int n,k;
    std::cin >> n>>k;
    VEC(ll,aa,n);
    ll ans=INF64;
    brep(n){
 //       std::cout << cc(n,bit) << std::endl;
        std::vector<ll> a(aa);
        if(cc(n,bit)<k)continue;
        ll m=a[0],d=0ll;
        rrep(i,1,n){
            if(bit&(1<<i)){
                d+=max(0ll,m-a[i]+1);
                a[i]=max(a[i],m+1);
            }
            m=max(m,a[i]);
        }
  //      erep(i,a)std::cout << i << " ";
   //     std::cout << std::endl;
        ans=min(ans,d);
    }
    std::cout << ans << std::endl;
}

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

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	set<int> s;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (s.find(a) == s.end()) s.insert(a);
		else s.erase(a);
	}
	cout << s.size() << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
const int infty = 1 << 30;
using namespace std;
int main(){
  while(true){
    vector<int> taro;
    vector<int> hanako;
    
    int n,m;
    int pass_min = infty;
    int pass_taro = -1;
    int pass_hanako = -1;
    int sum_taro = 0;
    int sum_hanako = 0;
    cin >> n >> m;
    if( n == 0 && m == 0 ) break;
    for(int i = 0; i < n; ++i){
      int t; cin >> t;
      taro.push_back(t);
      sum_taro += t;
    }
    for(int i = 0; i < m; ++i){
      int t; cin >> t;
      hanako.push_back(t);
      sum_hanako += t;
    }
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < m; ++j){
	if( sum_taro - taro[i] + hanako[j] ==
	    sum_hanako - hanako[j] + taro[i] ){
	  if( pass_min > taro[i] + hanako[j] ){
	    pass_taro = taro[i];
	    pass_hanako = hanako[j];
	    pass_min = taro[i] + hanako[j];
	  }
	}
      }
    }
    if( pass_taro < 0 || pass_hanako < 0 ){
      cout << "-1" << endl;
    }else{
      cout << pass_taro << " " << pass_hanako << endl;
    }
  }
  return 0;
}

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

int main() {
int n,d,x;
cin>>n>>d>>x;
int a[n];
REP(i,n){
  cin>>a[i];
}
int day=0;
REP(i,n){
  REP(j,d){
    if (j*a[i]+1<=d)
  {
    /* code */
    day++;
  }
  
  }
  
}
cout<<day+x<<endl;
}

Measured memory_bytes: 256
#include<cstdio>


using ll=long long;


int main(void)
{
	int n, a, b;
	ll ans;

	while(scanf("%d%d%d", &n, &a, &b)==3)
	{
		ans=0;
		if(a<=b && n>1)
		{
			ans=((ll)b*(n-1)+a)-((ll)a*(n-1)+b)+1;
		}
		if(a==b) ans=1;
		printf("%lld\n", ans);
	}

	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt()

    val a = LongArray(n) { sc.nextLong() }
    val sums = LongArray(n+1)
    for (i in 0 until n) sums[i+1] = sums[i] + a[i] - 1

    var ans = 0L
    val mp = mutableMapOf(0L to 0L)

    for (i in 0..n) {
	if (i >= k) {
	    val tmp1 = mp[sums[i-k]%k]!!
	    mp[sums[i-k]%k] = tmp1 - 1
	}

	val tmp = mp[sums[i]%k] ?: 0
	ans += tmp
	mp[sums[i]%k] = tmp + 1
    }
    println(ans);
}


Measured memory_bytes: 77368
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int N;
    cin>>N;
    while(1){
        N-=1000;
        if(N<=0){
            N*=-1;
            break;
        }
    }
    cout<<N<<endl;
    return 0;
}


Measured memory_bytes: 3636
package main

import (
	"fmt"
	"strings"
)

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	var n, a, b, c, d int
	var s string
	fmt.Scan(&n, &a, &b, &c, &d)
	fmt.Scan(&s)
	if c < d {
		if !(strings.Contains(s[a-1:c], "##")) && !(strings.Contains(s[b-1:d], "##")) {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	} else {
		if strings.Contains(s[b-2:min(c, d)+1], "...") && !(strings.Contains(s[a-1:c], "##")) && !(strings.Contains(s[b-1:d], "##")) {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


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

#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--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000
#define _GLIBCXX_DEBUG

int threemax(int a, int b, int c) {
	if (a >= b && a >= c) {
		return a;
	}
	else if (b >= a && b >= c) {
		return b;
	}
	else {
		return c;
	}
}

int threemin(int a, int b, int c) {
	if (a <= b && a <= c) {
		return a;
	}
	else if (b <= a && b <= c) {
		return b;
	}
	else {
		return c;
	}
}

void chmaxl(ll &a,ll b){
	if(a<b){
		a=b;
	}
	return;
}

void chminl(ll &a,ll b){
	if(a>b){
		a=b;
	}
	return;
}

void chmaxi(int &a,int b){
	if(a<b){
		a=b;
	}
	return;
}

void chmini(int &a,int b){
	if(a>b){
		a = b;
	}
	return;
}



int main() {
  double D,T,S;
  cin >> D >> T >> S;
  if (D/S<=T){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
vector<vector<ll> >G(100010);
vector<ll>d(100010,0);
vector<ll>k(0);
ll u,v;
bool dfs(ll i,ll p){
    bool f=0;
    ll ma=0;
    for(auto e:G[i]){
        if(e==p)continue;
        f|=dfs(e,i);
        ma=max(d[e]+1,ma);
    }
    if(i==u)f=1;
    if(f)k.pb(i);
    d[i]=ma;
    return f;
}
int main(){
    ll n;cin>>n;
    cin>>u>>v;
    rep(i,n-1){
        ll a,b;cin>>a>>b;
        G[a].pb(b);
        G[b].pb(a);
    }
    dfs(v,-1);
    ll ans;
    if(k.size()==2)ans=d[u];
    else{
        if(k.size()%2){
            ans=k.size()/2-1+d[k[k.size()/2-1]]+1;
        }else{
            ans=ans=k.size()/2-1+d[k[k.size()/2-1]];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 13312
import sys

parts = sys.stdin.readline().split(' ')
m = int(parts[0])
n = int(parts[1])
ans = 0

for i in range(m):
    for j in range(n):
        d1 = (j + 1) % 10
        d2 = (j + 1) // 10
        if d1 > 1 and d2 > 1 and d1 * d2 == i + 1:
            ans += 1

print(ans)


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

int main()
{
    int a,b,c;
    while(cin>>a>>b>>c)
    {
        int  s1=0,s2=0;
        if(a==5)
        s1++;
        if(a==7)
        s2++;
        if(b==5)
        s1++;
        if(b==7)
        s2++;
        if(c==5)
        s1++;
        if(c==7)
        s2++;
        if(s1==2&&s2==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,d=0,r=0;
	double f=0.0;
        scanf("%d%d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/b;
	printf("%d %d %f\n",d,r,f);
	return 0;
}

Measured memory_bytes: 2684
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int a,b,c;cin>>a>>b>>c;
  if(a==b+c || b==a+c || c==a+b){
    P("Yes");
  }else{
    P("No");
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,i,j,a[100005],tree[4005],f[2005][2005],w[100005],b[100005];
char c[100005];
int lowbit(int x)
{
	return -x&x;
}
void modify(int x)
{
	while(x<=n*2)
	{
		++tree[x];
		x+=lowbit(x);
	}
}
int Query(int x)
{
	int y=0;
	while(x)
	{
		y+=tree[x];
		x-=lowbit(x);
	}
	return y;
}
int main()
{
	scanf("%d\n",&n);
	for(i=1;i<=n*2;++i)
	{
		scanf("%c %d\n",&c[i],&a[i]);
		if(c[i]=='W')
			w[a[i]]=i;
		else
			b[a[i]]=i;
	}
	for(i=0;i<=n;++i)
	{
		memset(tree,0,sizeof(tree));
		for(j=1;j<i;++j)
			modify(w[j]);
		if(i!=0)
			f[i][0]=i-1-Query(w[i])+f[i-1][0];
		for(j=1;j<=n;++j)
		{
			int s=i+j-1-Query(b[j]);
			if(i!=0&&w[i]<b[j])
				--s;
			f[i][j]=f[i][j-1]+s;
			modify(b[j]);
			if(i!=0)
				f[i][j]=min(f[i][j],f[i-1][j]+i+j-1-Query(w[i]));
		}
	}
	cout<<f[n][n];
}

Measured memory_bytes: 16000
def solve():
    a,b,c,d = map(int,input().split())
    lower = [a,b]
    upper = [c,d]

    mx = -float('inf')
    for l in lower:
        for u in upper:
            mx = max(mx, l*u)
    
    print(mx)
    
if __name__ == '__main__':
    solve()


Measured memory_bytes: 61688
'''
問題：
    アライグマはモンスターと戦っています。

    モンスターの体力は H です。
    アライグマは N 種類の必殺技を使うことができ、
    i 番目の必殺技を使うとモンスターの体力を Ai 減らすことができます。
    必殺技を使う以外の方法でモンスターの体力を減らすことはできません。

    モンスターの体力を 0 以下にすればアライグマの勝ちです。

    アライグマが同じ必殺技を
    2 度以上使うことなくモンスターに勝つことができるなら Yes を、
    できないなら No を出力してください。
'''

'''
制約：
    1 ≦ H ≦ 1000000000
    1 ≦ N ≦ 100000
    1 ≦ Ai ≦ 10000
    入力中のすべての値は整数である。
'''

# 標準入力から H, N, Ai を取得する
h, m = map(int, input().split())
a = list(map(int, input().split()))

# 必殺技を1回ずつ使った場合、モンスターの体力をどれだけ削れるか計算する
hissatsu_hp = 0
for i in range(0, m):
    hissatsu_hp += a[i]

# 同じ必殺技を使わずアライグマを倒せるか判定して結果を出力する
result = ""
if hissatsu_hp >= h:
    result = "Yes"
else:
    result = "No"

print(result)


Measured memory_bytes: 20540
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    string s; cin >> s;
    if(s == "ABC"){
        cout << "ARC" << endl;
    }
    else cout << "ABC" << endl;

    system("pause");
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int dp[2][105],cost[2][105];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<2;i++)
        for(int j=0;j<n;j++)
            cin>>cost[i][j];
    dp[1][n-1]=cost[1][n-1];
    dp[0][n-1]=dp[1][n-1]+cost[0][n-1];
    for(int i=1;i>=0;i--)
        for(int j=n-2;j>=0;j--)
            if(i==1)
                dp[i][j]=dp[i][j+1]+cost[i][j];
            else
                dp[i][j]=max(dp[i+1][j]+cost[i][j],dp[i][j+1]+cost[i][j]);
    cout<<dp[0][0]<<endl;
    return 0;
}


Measured memory_bytes: 256
def main():
	N, M, X = map(int,input().split())
	A = list(map(int, input().split()))
	l, r = 0, 0
	for a in A:
		if a < X:
			l += 1
		elif a > X:
			r += 1
	print(min(l, r))


if __name__ == '__main__':
	main()

Measured memory_bytes: 2940
n = int(input())
t_list = [0]*(n+1)
x_list = [0]*(n+1)
y_list = [0]*(n+1)
for i in range(n):
    t_list[i+1], x_list[i+1], y_list[i+1] = map(int,input().split())
for i in range(n):
    d = abs(x_list[i+1] - x_list[i]) + abs(y_list[i+1] - y_list[i])
    t = t_list[i+1] - t_list[i]
    if  t<d or t%2 != d%2:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 11636
n,a,b,c,d=map(int,input().split())
def kyo(p,q):
    if p[1]<q[0] or q[1]<p[0]:
        return False
    else:
        return True
for i in range(n):
    am=[a-i*d,a-i*c]
    ap=[a+i*c,a+i*c]
    bm=[b-(n-1-i)*d,b-(n-1-i)*c]
    bp=[b+(n-1-i)*c,b+(n-1-i)*d]
    for j in [am,ap]:
        for k in [bm,bp]:
            if kyo(j,k):
                print('YES')
                exit()
print('NO')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;



signed main(){
  int N, K; cin >> N >> K;
  vector<int> f(105);
  REP(x, K) {
    int d; cin >> d;
    REP(y, d) {
      int inp ; cin >> inp;
      f.at(inp) = true;
    }
  }

  da(f);
  int cnt = 0;
  FOR1(x, N){
    if(f.at(x) == false) cnt++;
  }
  cout << cnt << endl;
}


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

using ll = long long;
using namespace std;

int search(int A[], int n, int key){
    int i = 0;
    A[n] = key;
    while ( A[i] != key) i++;
    return i != n;
}

int main() {
    int n, q, sum = 0;
    cin >> n;
    int V[n];
    for (int i = 0; i < n; ++i) {
        scanf("%d", &V[i]);
    }
    int key = V[n];
    cin >> q;
    for (int i = 0; i < q; ++i) {
        scanf("%d", &key);
        if (search(V, n, key)) sum++;
    }
    cout << sum << "\n";

    return 0;
}


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

ll A[101010], B[101010];
vector<int> day[101010];
int daycur[101010];

int main() {
    ll N, M;
    cin >> N >> M;

    vector<pair<ll, ll>> tmp(N);
    rep(i, N) {
        cin >> A[i] >> B[i];
        tmp[i] = {A[i]-1, -B[i]};
    }
    sort(tmp.begin(), tmp.end());

    ll ans = 0;
    int cur = 0;
    priority_queue<ll> que;

    tmp.emplace_back(1e8, -1e8);

    // rep(i, tmp.size()) {
    //     cout << tmp[i].first << ", " << tmp[i].second << endl;
    // }

    rep(i, tmp.size()) {
        ll aa = tmp[i].first, bb = tmp[i].second;

        if (cur >= M) break;

        if (cur < aa) {

            for (; cur<min(M, aa); ++cur) {
                if (que.size()) {
                    //cout << que.top() << ", " << cur << endl;
                    ans += que.top();
                    que.pop();
                }
            }
            if (aa >= M) break;
        }

        if (cur == aa) que.push(-bb);
    }


    cout << ans << endl;


}


Measured memory_bytes: 8576
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using lb = long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/*-------------ここまで---------------------------------------------*/
int main(){
    int x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;
    return 0;
}

Measured memory_bytes: 3632
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

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

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n,k = lr()
a = lr()
l = 0
r = max(a)+1
def totalK(mid):
    ret = 0
    for num in a:
        ret += ((num+mid-1)//mid-1)
    return ret
mid = 0
while r > l:
    mid = l + (r-l)//2
    if mid == 0:
        print(1)
        sys.exit()
    nowk = totalK(mid)
    if nowk > k:
        l = mid+1
    else:
        r = mid
print(r)

Measured memory_bytes: 109440
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;
#define rep(i, n) for (int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for (int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main()
{
    int N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;
    vector<char> hand(N);
    int score = 0;
    rep(i, N)
    {
        if (i - K < 0)
        {
            if (T[i] == 's')
            {
                score += R;
                hand[i] = 'R';
            }
            else if (T[i] == 'p')
            {
                score += S;
                hand[i] = 'S';
            }
            else
            {
                score += P;
                hand[i] = 'P';
            }
        }
        else
        {
            if (T[i] == 's' && hand[i - K] != 'R')
            {
                score += R;
                hand[i] = 'R';
            }
            else if (T[i] == 'p' && hand[i - K] != 'S')
            {
                score += S;
                hand[i] = 'S';
            }
            else if (T[i] == 'r' && hand[i - K] != 'P')
            {
                score += P;
                hand[i] = 'P';
            }
            else
            {
                hand[i] = '0';
            }
        }
    }
    cout << score << endl;
    return 0;
}

Measured memory_bytes: 3804
/*
 * FileName:     lower_bound_fix_2
 * CreatedDate:  2020-08-19 14:42:40 +0900
 * LastModified: 2020-08-19 15:14:07 +0900
 */

#include <stdio.h>
#include <stdlib.h>
void binary_search(int k, int *a, int n){
    int left = -1, right = n;
    while(left+1<right){
        int middle = (left+right) / 2;
        if(a[middle] < k){
            left = middle;
        }
        else{
            right = middle;
        }
    }
    printf("%d\n", right);
}


int main(void){
    int n;scanf("%d", &n);
    int *a = malloc(n*sizeof(int));
    for(int i=0; i<n; i++) scanf("%d", a+i);
    int q;scanf("%d", &q);
    for(int i=0; i<q; i++){
        int k;scanf("%d", &k);
//        if( k<=a[0] ){
//            printf("0\n");
//            continue;
//        }
        binary_search(k, a, n);
    }
    free(a);
    return 0;
}



Measured memory_bytes: 2112
def d_abs(N, Z, W, A):
    # 山札の枚数が1枚なら、Xがそれを引いて終わる。山札が2枚以上なら、
    # Xは初手でN-1枚目かN枚目かのどちらかスコアが大きくなる方を取るのが最善。
    # そうしなかった場合、Xが最善手を取らなかったことになって前提に反するか、
    # Yが最善手を取ってスコアabs(A[N - 1] - A[N - 2])になるかのどちらかである
    ans = abs(A[0] - W) if N == 1 else max(abs(A[N - 1] - W), abs(A[N - 1] - A[N - 2]))
    return ans

N,Z,W = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(d_abs(N, Z, W, A))

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


int main(){
    int N;
    cin>>N;
    vector<int64_t> L(N+1);
    L.at(0)=2;
    L.at(1)=1;
    for(int i=2;i<N+1;i++){
        L.at(i)=L.at(i-2)+L.at(i-1);
    }
    printf("%lld\n",L.at(N));
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

int main(){
    int N;
    cin >> N;
    int maxi = 0;
    int sum = 0;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        sum += a;
        maxi = max(maxi,a);
    }
    cout << sum - maxi / 2 << endl;
    return 0;
}

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

int main(){
    int N;
    unordered_map<string, int> S;
    
    cin >> N;
    for (int i = 0; i < N; i++){
        string s;
        cin >> s;
        S[s]++;
    }
    cout << S.size() << endl;
}

Measured memory_bytes: 17688
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL


using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n;
ll K;
ll ans;
ll X = 1000000007;

void cal(ll x){
	ans = (ans*x) % X;
}

int main()
{
	char S[2][100];
	char a;
	scanf("%d\n",&n);
	for(int j=0;j<=1;j++){
		for(int i=0;i<n;i++){
			scanf("%c",&S[j][i]);
		}
		if(j==0)scanf("%c",&a);
	}
	int mode=0;
	for(int i=0;i<n;i++){
		if(i==0){
			if(S[0][i]==S[1][i]){
				ans=3;mode=0;
			}else{
				ans=6;mode=2;
			}
		}else{
			if(mode==0){
				ans = (ans*2)%X;
				if(S[0][i]==S[1][i]){
					mode=0;
				}else{
					mode=2;
				}
			}else if(mode==1){
				if(S[0][i]==S[1][i]){
					mode=0;
				}else{
					ans = (ans*3)%X;
					mode=2;
				}
			}else if(mode==2){
				mode=1;
			}
		}
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;




int main() {

    vi dp(100000,false);
    int n,k;
    cin>>n>>k;
    set<int> v;
    vi use;
    rep(i,k){
        int t;
        cin>>t;
        v.insert(t);
    }
    rep(i,10){
        if(v.count(i)==0)use.pb(i);
    }
    
    rep(i,use.size())dp[use[i]]=1;
    for(int i=0;i<=10000;i++){
        if(!dp[i])continue;
        rep(j,use.size()){
            dp[i*10+use[j]]=1;
        }
    }
    // rep(i,30){
    //     cout<<i<<" "<<dp[i]<<endl;
    // }
    for(int i=n;i<100000;i++){
        if(dp[i]){
            fin(i);
            return 0;
        }
    }
    
}



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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n;
    cin >> n;
    vector<ll> a;
    ll ans=0;
    int sum=0;
    rep(i,0,n){
        ll in;
        cin >> in;
        if(in>4){
            ans+=in-4;
            in=4;
        }
        sum+=in;
        a.push_back(in);
    }

    sort(a.rbegin(),a.rend());
    int tmp=min(sum-(n-1),10);
    int mini=tmp;
    vector<vector<int>> vs(tmp+1);
    rep(i,0,1<<tmp) vs[__builtin_popcount(i)].push_back(i);;
    function<void(int,vector<int>,int)> dfs=[&](int idx,vector<int> v,int x){
        if(idx==n){
            mini=__builtin_popcount(x);
            return;
        }
        for(int i:vs[a[idx]]){
            int x_=x|i;
            if(__builtin_popcount(x_)>=mini) continue;
            bool ok=true;
            rep(j,0,idx){
                if(__builtin_popcount(i&v[j])<2) continue;
                ok=false;
                break;
            }
            if(!ok) continue;
            vector<int> w=v;
            w.push_back(i);
            dfs(idx+1,w,x_);
        }
    };
    dfs(0,vector<int>(),0);
    ans+=mini;
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

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

int main(void)
{
	int n;
	int m;
	string str;
	string cmp;
	while(1)
	{
		str.clear();
		cmp.clear();
		cin >> n;
		if(n == 0)
			return 0;
		cin >> m;
		cin >> str;
		cmp += "IOI";
		for(int i=1;i<n;++i){
			cmp += "OI";
		}
		int count = 0;
		int next=0;
		while(1)
		{
			auto a = str.find(cmp,next+1);
			if(a == string::npos)
				break;
			else{
				next = a;
				++count;
			}
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 2112