akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public 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 <= c && c <= b) || (a >= c && c >= b)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;cin>>n;
	int ac=0;
	int w=0;int t=0;int r=0;
	while(n--)
	{
		string s;cin>>s;
		if(s=="AC")
		{
			ac++;
		}
		if(s=="WA")
		{
			w++;
		}
		if(s=="TLE")
		{
			t++;
		}
		if(s=="RE")
		{
			r++;
		}
	}
	cout<<"AC x "<<ac<<"\n";
	cout<<"WA x "<<w<<"\n";
	cout<<"TLE x "<<t<<"\n";
	cout<<"RE x "<<r<<"\n";
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	vll sum(n+1,0) ;
	for(int i=0;i<n;i++) sum.at(i+1) = sum.at(i)+a.at(i) ;
	ll ans = INF ;
	for(int i=2;i<=n-2;i++){
		ll s1,s2,s3,s4 ;
		ll l1=0,r1=i,m1 ;
		while(l1+1<r1){
			m1 = (l1+r1)/2 ;
			if(2*sum.at(m1)<sum.at(i)) l1 = m1 ;
			else r1 = m1 ;
		}
		if(l1==0){
			s1 = sum.at(1) ;
			s2 = sum.at(i)-sum.at(1) ;
		}else if(r1==i){
			s1 = sum.at(l1) ;
			s2 = sum.at(i)-sum.at(l1) ;
		}else if(sum.at(i)-2*sum.at(l1)>2*sum.at(r1)-sum.at(i)){
			s1 = sum.at(r1) ;
			s2 = sum.at(i)-sum.at(r1) ;
		}else{
			s1 = sum.at(l1) ;
			s2 = sum.at(i)-sum.at(l1) ;
		}
		ll l2=i,r2=n,m2 ;
		while(l2+1<r2){
			m2 = (l2+r2)/2 ;
			if(2*(sum.at(m2)-sum.at(i))<sum.at(n)-sum.at(i)) l2 = m2 ;
			else r2 = m2 ;
		}
		if(l2==i){
			s3 = sum.at(i+1)-sum.at(i) ;
			s4 = sum.at(n)-sum.at(i+1) ;
		}else if(r1==n){
			s3 = sum.at(l2)-sum.at(i) ;
			s4 = sum.at(n)-sum.at(l2) ;
		}else if(sum.at(n)-sum.at(i)-2*(sum.at(l2)-sum.at(i))>2*(sum.at(r2)-sum.at(i))-sum.at(n)+sum.at(i)){
			s3 = sum.at(r2)-sum.at(i) ;
			s4 = sum.at(n)-sum.at(r2) ;
		}else{
			s3 = sum.at(l2)-sum.at(i) ;
			s4 = sum.at(n)-sum.at(l2) ;
		}
		ans = min(ans,max(max(s1,s2),max(s3,s4))-min(min(s1,s2),min(s3,s4))) ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 6432
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

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

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}
ll ans=-1000000000;



int main()
{
 ll n;
 cin>>n;
 vector<ll>v(n);
 rep(i,n)cin>>v[i];
 rep(i,n)v[i]--;
  vector<ll>cnt(n);
  ll ans=0;
 rep(j,n){
     ans+=cnt[v[j]];
     cnt[v[j]]++;
     }
 rep(i,n){
     ll k=cnt[v[i]]-1;
     cout<<ans-k<<endl;
 }
}



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

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;
    
    A = (A == 1 ? 14 : A);
    B = (B == 1 ? 14 : B);
    
    if (A > B) {
        cout << "Alice" << endl;
    } else if (A < B) {
        cout << "Bob" << endl;
    } else {
        cout << "Draw" << endl;
    }        
    return 0;
}


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

using namespace std;
using ll = long long;

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


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

    ll p = 1;
    for(ll i=2; i*i<=N; ++i){
        if(N % i == 0){
            p = i;  
        }
    }
    
    _PR(p+(N/p)-2);

    return 0;
}

/*



*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

string s;
int x,y;
bitset<202020> X[2];

int main(){
  cin >> s >> x >> y;
  X[0][101010] = true;
  X[1][101010] = true;

  int cou = 0;
  int index = 0;
  while(index < s.size() && s[index++] == 'F') cou++;
  X[0] = (X[0] << cou);

  int now = 1;

  while(index < s.size()){
    cou = 0;
    while(index < s.size() && s[index++] == 'F') cou++;
    X[now] = (X[now] << cou) | (X[now] >> cou);
    now ^= 1;
  }

  if(X[0][x + 101010] && X[1][y + 101010]){
    cout << "Yes" << endl;
  }
  else{
    cout <<"No" << endl;
  }
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
 
string divide[4] = { "dream","dreamer","erase","eraser" };
int main()
{
	int N,C,K;
	cin >> N;
	vector<int> T(N);
	for (int i = 0; i < N; i++)
	{
		cin >> T.at(i);
	}
	long sum = 0;
	long cnt1 = 0;
	for (int i = 0; i < N; i++)
	{
		sum += T.at(i);
		if (i % 2 == 0)
		{
			if (sum <= 0)
			{
				cnt1 += -sum + 1;
				sum = 1;
			}
		}
	else {
			if (sum >= 0)
			{
				cnt1 += sum + 1;
				sum = -1;
			}
		}
	}
 
	long cnt2 = 0;
	sum = 0;
	for (int i = 0; i < N; i++)
	{
		sum += T.at(i);
		if (i % 2 == 1)
		{
			if (sum <= 0)
			{
				cnt2 += -sum + 1;
				sum = 1;
			}
		}
		else {
			if (sum >= 0)
			{
				cnt2 += sum + 1;
				sum = -1;
			}
		}
	}
 
	cout << min(cnt1,cnt2) << endl;
	return 0;
 
 
	
}

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


int main(void){
    long long int a,b,x;
    long long int tmp,r;
    cin >> a >> b;
    x = a * b;
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
     
  }
 
  /* 最小公倍数を出力 */
  printf("%ld\n", x/b);

    
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<bool,char> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

string S;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(1){
    cin>>S;
    if(S=="#")break;
    ll N=S.size();
    bool ok=false;
    for(ll i=0;i<N;){
      bool okk=true;
      vector<P> vs;
      string crt;
      while(i<N&&S[i]!='|'){
        if(S[i]=='&'||S[i]=='('||S[i]==')'){
          if(crt.size()){
            if(crt[0]=='~'){
              vs.push_back(P(true,crt[1]));
            }else{
              vs.push_back(P(false,crt[0]));
            }
            crt.clear();
          }
        }else{
          crt+=S[i];
        }
        i++;
      }
      i++;
      rep(j,vs.size())rep(k,j){
        if(vs[j].fi!=vs[k].fi&&vs[j].se==vs[k].se){
          okk=false;
        }
      }
      if(okk)ok=true;
    }
    if(ok)cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }

  return 0;
}



Measured memory_bytes: 3204
#include <fstream>
#include <iostream>

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 1000000007
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define lli long long int
#define pii pair<int,int>
#define add(a,b) ((int) (((lli) (a) + (b))%MOD))
#define mul(a,b) ((int) (((lli) (a) * (b))%MOD))
#define PB emplace_back

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

int K;
string S;
int fact [2000001];

int modexp(int a, int e) {
    int ans = 1;
    int cur = a;
    while (e) {
        if (e&1) {ans = mul(ans, cur); e--;}
        e /= 2;
        cur = mul(cur,cur);
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> K >> S;
    fact[0] = 1;
    FOR(i,1,K+S.size()+1) fact[i] = mul(fact[i-1],i);
    int ans = 0;
    FOR(av, S.size(), K+S.size()+1) {
        int nck = mul(fact[av-1],modexp(mul(fact[S.size()-1], fact[av-S.size()]), MOD-2));
        int p1 = modexp(25, av-S.size());
        int p2 = modexp(26, K+S.size()-av);
        ans = add(ans, mul(mul(p1,p2),nck));
    }
    cout << ans << '\n';
}

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

long long n, k, q, a;
long long A[110000];
int main()
{
    cin >> n >> k >> q;

    for( int i = 1 ; i <= q ; i ++ )
    {
        cin >> a ;
        A[a] ++ ;
    }

    for( int i = 1 ; i <= n ; i ++ )
    {
        if(((k - q) + A[i]) > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 1408
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 1987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

int main() {
	int n;
	scanf("%d",&n);
	if(n==3)return !printf("2 5 63");
	if(n&1)
	{
		int a[8]={6,2,10,3,9,4,8,12};
		int s=0,cnt=0;
		while(cnt<n)
		{
			printf("%d ",s+a[cnt%8]);
			cnt++;
			if(cnt%8==0)s+=12;
		}
	}
	else
	{
		int a[8]={2,10,3,9,4,8,6,12};
		int s=0,cnt=0;
		while(cnt<n)
		{
			printf("%d ",s+a[cnt%8]);
			cnt++;
			if(cnt%8==0)s+=12;
		}
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	if (n & 1) {
		cout << "No" << endl;
		return 0;
	}

	string s; cin >> s;

	int m = n / 2;
	FOR_LT(i, 0, m) {
		if (s[i] != s[i + m]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

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

n = int(input())
a = list(map(int, input().split()))
a.sort()
b = list(map(int, input().split()))
b.sort()
c = list(map(int, input().split()))
c.sort()
ans = 0
for j in b:
    ans += bisect.bisect_left(a,j)*(n-bisect.bisect_right(c,j))
print(ans)

Measured memory_bytes: 92644
#平方数でなければ約数は奇数とはならない
N= int(input())
e = [0] * (N+1)
for i in range(2, N+1):
  cur = i
  for j in range(2, i+1):
    while cur % j == 0:
      e[j] += 1
      cur //= j

def num(m): # e の要素のうち m-1 以上のものの個数
  return len(list(filter(lambda x: x >= m-1, e)))

ans = num(75) + num(25)*(num(3)-1) + num(15)*(num(5)-1) + num(5)*(num(5)-1)*(num(3)-2)//2

print(ans)

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

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

    int N;
    std::cin >> N;

    int sum = 0;
    for(int i=0;i<N;++i){
        int a;
        std::cin >> a;

        sum += a;
    }

    sum -= N;

    std::cout << sum << std::endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        int N = int.Parse(ReadLine());
        var ab = new int[N][];
        for (int i = 0; i < N; i++)
        {
            ab[i] = ReadLine().Split().Select(int.Parse).ToArray();
        }
        var cd = new int[N][];
        for (int i = 0; i < N; i++)
        {
            cd[i] = ReadLine().Split().Select(int.Parse).ToArray();
        }

        Array.Sort(ab, (x, y) => x[1] == y[1] ? x[0].CompareTo(y[0]) : x[1].CompareTo(y[1]));
        Array.Sort(cd, (x, y) => x[1] == y[1] ? x[0].CompareTo(y[0]) : x[1].CompareTo(y[1]));

        var used = new bool[N];
        int ans = 0;
        for (int i = 0; i < N; i++)
        {
            int index = -1;
            int maxx = -1;
            for (int j = 0; j < N; j++)
            {
                if (!used[j])
                {
                    if (cd[i][0] > ab[j][0] && cd[i][1] > ab[j][1])
                    {
                        if (maxx < ab[j][0])
                        {
                            index = j;
                            maxx = ab[j][0];
                        }
                    }
                }
            }
            if (index != -1)
            {
                ans++;
                used[index] = true;
            }
        }

        WriteLine(ans);
    }
}


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

using namespace std;

int bubbleSort(vector<string>& vector_array,int n){
    int counter = 0;
    bool flag = true;
    while(flag){
        flag = false;
        for(int j=n-1; j>0; j--){
            if (vector_array[j][1] < vector_array[j-1][1]){
                swap(vector_array[j],vector_array[j-1]);
                flag = true;
                counter ++ ;
            }
        }
    }
    return counter;
}

int selectionSort(vector<string>& vector_array,int n){
    int counter = 0;
    rep(i,n-1){
        int minj = i;
        for(int j = i;j < n;j++){
            if(vector_array[j][1] < vector_array[minj][1]) minj = j;
        }
        if(minj > i) {
            swap(vector_array[i],vector_array[minj]);
            counter++;
        }
    }
    return counter;
}

bool isStable(vector<string> input_vector,vector<string> output_vector,int n){
    for(int i = 0;i < n;i++){
        for(int j = i+1;j < n;j++){
            for(int a = 0;a < n;a++){
                for(int b = a+1;b < n;b++){
                    if(input_vector[i][1] == input_vector[j][1] 
                    && input_vector[i] == output_vector[b] 
                    && input_vector[j] == output_vector[a]) {
                        return false;
                    }
                    
                }
            }
        }
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    vector<string> string_array_input(n);
    rep(i,n){
        cin >> string_array_input[i];
    }
    vector<string> string_array_output(n);
    string_array_output = string_array_input;

    bubbleSort(string_array_output,n);
    rep(i,n){
        cout << string_array_output[i];
        if(i < n-1) cout << " ";
    }
    cout << "\n" ;
    if(isStable(string_array_input,string_array_output,n)) cout << "Stable\n";
    else cout << "Not stable\n";

    string_array_output = string_array_input;
    selectionSort(string_array_output,n);
    rep(i,n){
        cout << string_array_output[i];
        if(i < n-1) cout << " ";
    }
    cout << "\n" ;
    if(isStable(string_array_input,string_array_output,n)) cout << "Stable\n";
    else cout << "Not stable\n";


    return 0;   
}


Measured memory_bytes: 3204
s = gets.chomp.split("")
k = gets.chomp.to_i

a1 = s.clone
s.each_cons(2) {|ary| a1 << ary.join}
s.each_cons(3) {|ary| a1 << ary.join}
s.each_cons(4) {|ary| a1 << ary.join}
s.each_cons(5) {|ary| a1 << ary.join}
puts a1.sort.uniq[k-1]




Measured memory_bytes: 8116
#include <iostream>

using namespace std;

int main() {
	int w,h,x,y,r;
	cin >> w >> h >> x >> y >> r;
	if( x + r <= w && x - r >= 0 && y + r <= h && y - r >= 0 ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long int;
using namespace std;
ll mod=1e9+7;


int main(){
  int n,k;
  cin >> n >>k;
  int ans=0;
  int a[n]={};
  rep(i,k){
    int d;
    cin >> d;
    rep(i,d){
      int A;
      cin >> A;
      a[A-1]++;
    }
  }
  rep(i,n){
    if(a[i]==0)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int &i : v) cin >> i;
    int T;
    cin >> T;
    while (T--) {
        int a, b;
        cin >> a >> b;
        reverse(v.begin()+a, v.begin()+b);
    }
    for (int i = 0; i < n; i++) {
        cout << v[i];
        if(i!=n-1)cout << " ";
    }
    cout << endl;
    return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  int max = a;
  if (b > max) {
    max = b;
  }
  if (c > max) {
    max = c;
  }

  cout << (a + b + c - max) << endl;
}


Measured memory_bytes: 3644
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();

   List<Integer> con = new ArrayList<>();
   while(!con.contains(N))
   {
     con.add(N);
     if(N%2==0) N = N/2;
     else N = 3*N +1;
   }
   
   System.out.println(con.size()+1);
 }
}

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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int N,H; cin>>N>>H;
    int a[N],b[N]; REP(i,N) cin>>a[i]>>b[i];
    sort(a,a+N);
    vector<int> th;
    REP(i,N) if(b[i]>a[N-1]) th.push_back(b[i]);
    sort(th.begin(),th.end());
    int HP = H;
    int ans = 0;
    REP(i,th.size()) {
        HP -= th[th.size()-1-i];
        ans++;
        if(HP<=0) {
            cout<<ans<<endl;
            return 0;
        }
    }
    cout<<ans+(HP+a[N-1]-1)/a[N-1]<<endl;
}



Measured memory_bytes: 1660
#include"bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<vector<ll>> connect(N);
    vector<ll> ans;

    for (ll i = 0; i < M; i++) {
        ll A, B;
        cin >> A >> B;
        A--; B--;
        connect[A].push_back(B);
        connect[B].push_back(A);

        if (i == 0) {
            ans.push_back(A);
            ans.push_back(B);
        }
    }

    vector<bool> visit(N, false);
    visit[ans[0]] = true;
    visit[ans[1]] = true;

    auto isOK = [&]() {
        for (auto n : connect[ans.front()]) {
            if (!visit[n]) {
                return false;
            }
        }
        for (auto n : connect[ans.back()]) {
            if (!visit[n]) {
                return false;
            }
        }
        return true;
    };

    while (!isOK()) {
        bool add = false;
        for (auto n : connect[ans.back()]) {
            if (!visit[n]) {
                ans.push_back(n);
                visit[n] = true;
                add = true;
                break;
            }
        }
        if (add) {
            continue;
        }
        for (auto n : connect[ans.front()]) {
            if (!visit[n]) {
                ans.insert(ans.begin(), n);
                visit[n] = true;
                break;
            }
        }
    }

    cout << ans.size() << endl;
    for (ll i = 0; i < ans.size(); i++) {
        cout << ans[i] + 1 << " \n"[i == ans.size() - 1];
    }
}

Measured memory_bytes: 7156
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  size_t P, Q, R;
  cin >> P >> Q >> R;
  vector<size_t> v{P, Q, R};

  sort(v.begin(), v.end());

  cout << v[0] + v[1] << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long

int main(){
    int n; cin >> n;
    rep(i, n + 1){
        if(n - i * 7 < 0) break;
        if((n - i * 7) % 4 == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
import bisect
N, M = map(int, input().split())
A = sorted(map(int, input().split()))
for _ in range(M):
    x = A.pop()
    y = x // 2
    i = bisect.bisect_left(A, y)
    A.insert(i, y)
ans = sum(A)
print(ans)

Measured memory_bytes: 85584
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{


    class Program
    {

        const int INF = 1000000000;

        static int Solve(string X, string Y)
        {
            int xn = X.Length;
            int yn = Y.Length;

            int[,] dp = new int[xn + 1, yn + 1];

            dp[0, 0] = 0; 
            
            for(int i = 1; i <= xn; i++)
            {
                dp[i, 0] = i;
            }
            for(int j = 1;j <= yn; j++)
            {
                dp[0, j] = j;
            }
            
            for(int i = 1; i <= xn; i++)
            {
                for(int j = 1; j <= yn; j++)
                {
                    dp[i, j] = INF;
                    if(X[i - 1] == Y[j - 1])
                    {
                        dp[i, j] = dp[i - 1, j - 1];
                    }
                    else
                    {
                        if(i - 1 >= 0 && j - 1 >= 0)
                        {
                            dp[i, j] = Math.Min(dp[i, j], dp[i - 1, j - 1] + 1);
                        }
                        if(i - 1 >= 0)
                        {
                            dp[i, j] = Math.Min(dp[i, j], dp[i - 1, j] + 1);
                        }
                        if(j - 1 >= 0)
                        {
                            dp[i, j] = Math.Min(dp[i, j], dp[i, j - 1] + 1);
                        }
                    }


                }
            }
            
            return dp[xn, yn];
        }



        static void Main(string[] args)
        {
            string X = Console.ReadLine();
            string Y = Console.ReadLine();

            Console.WriteLine(Solve(X, Y));
        }
    }
}


Measured memory_bytes: 19208
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,res;
  cin>>n;
  vector<vector<int>> f(n,vector<int>(10)),p(n,vector<int>(11));
  for(auto& v:f)for(int& i:v)cin>>i;
  for(auto& v:p)for(int& i:v)cin>>i;
  for(int i=1;i<(1<<10);++i){
    vector<int> c(n,0);
    for(int j=0;(i>>j)>0;++j){
      if((i>>j)&1)for(int s=0;s<n;++s){
        if(f[s][j])++c[s];
      }
    }
    int sum=0;
    for(int j=0;j<n;++j)sum+=p[j][c[j]];
    if(i>1)res=max(res,sum);
    else res=sum;
  }
  cout<<res;
}

Measured memory_bytes: 256
use strict;
use warnings;
use utf8;
use Data::Dumper;

use feature qw(say);

my $nd = <STDIN>;
chomp $nd;
my ($n, $d) = (split/ /, $nd);
my $count = 0;

for (my $i = 0; $i < $n; $i++) {
    my $input = <STDIN>;
    chomp $input;
    my ($x, $y) = (split/ /, $input);
    my $distance = sqrt($x * $x + $y * $y);
    if ($distance <= $d) {
        $count++
    }
}
say $count;


Measured memory_bytes: 6240
#include <stdio.h>
int main (void){
    char t[200000];
    int i = 0;
    scanf("%s",t);
    for(i=0;t[i] != '\0';i++){
        if(t[i] == '?'){
            if(t[i-1] == 'P') t[i] = 'D';
            else if(t[i-1] == 'D' && t[i+1] == 'D') t[i] = 'P';
            else if(t[i-1] == 'D' && t[i+1] == '?') t[i] = 'P';
            else t[i] = 'D';
        }
    }
    printf("%s",t);
    return 0;
}


Measured memory_bytes: 1900
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    int a,b;
    cin >> a >> b;

    ll ans=0;
    if(a > b){
        for(int i = 0; i < a;i++){
            ans+=b*pow(10,i);
        }
    }else{
        for(int i = 0; i < b;i++){
            ans+=a*pow(10,i);
        }
    }

    cout << ans << endl;

    

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  int l = a[n-1];
  int mid = l / 2;
  int r = 0;
  rep(i,n-1) {
    if(a[i] < mid) r = i;
  }
  if(abs(l - a[r]*2) <= abs(l - a[r + 1]*2)) printf("%d %d\n",l,a[r]);
  else printf("%d %d\n",l,a[r + 1]);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int W, H, N;
    cin >> W >> H >> N;
    vector<int> X(W);
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        X[x] = max(X[x], y);
    }
    int ans = INF;
    int temp = 0;
    repr(i, W) {
        ans = min(ans, i + temp);
        temp = max(temp, X[i]);
    }

    cout << ans << endl;
}


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

int n;
vector<int> x, y;

double dist(int a, int b){
    return sqrt((x[a]-x[b])*(x[a]-x[b]) + (y[a]-y[b])*(y[a]-y[b]));
}

bool solve(){
    for(int i=0;i<n;i++){
        if(dist(n, i) >= dist(n+1, i)) return false;
    }

    for(int i=0;i<n;i++){
        if(dist(n, 0) + dist(0, i) >= dist(n+1, i)) return false;
    }
    return true;
}

int main(){
    while(1){
        cin >> n;
        if(n == 0) break;
        x.assign(n+2, 0);
        y.assign(n+2, 0);
        cin >> x[n] >> y[n] >> x[n+1] >> y[n+1];
        for(int i=0;i<n;i++){
            cin >> x[i] >> y[i];
        }

        if(solve()){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int t; cin >> t;
  int h, m, s;
  h = t / 3600;
  m = t % 3600 / 60;
  s = t % 3600 % 60;
  cout << h << ":" << m << ":" << s << endl;
  return 0;
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    string s;
    cin>> s;

    for(int i=0; i< s.size(); i++)
    {
        if( ( i%2== 0 && s[i] == 'L') or ( i%2== 1 && s[i] == 'R'))
        {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";

    return 0;
}




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

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insertx (int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;

    if(y == NIL){
        root = z;
    } else {
        if (z->key < y->key){
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void preOrder(Node *z){
    if (z == NIL){
        return;
    }
    cout << " " << z->key;
    preOrder(z->left);
    preOrder(z->right);
}

void inOrder(Node *z){
    if (z == NIL){
        return;
    }
    inOrder(z->left);
    cout << " " << z->key;
    inOrder(z->right);
}

int main() {
    int m; cin >> m;

    rep(i, m){
        string S; cin >> S;
        if(S == "insert"){
            int k; cin >> k;
            insertx(k);
        } else {
            inOrder(root);
            cout << endl;
            preOrder(root);
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 26600
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define GG return puts("No"),0;
const int maxn=100005;
typedef long long ll;
int ufs1[maxn];ll w1[maxn];
int ufs2[maxn];ll w2[maxn];
struct node{
  int x,y,val;
  void read(){
    scanf("%d%d%d",&x,&y,&val);
  }
}P[maxn];
bool cmpx(const node &A,const node &B){
  return A.x<B.x;
}
bool cmpy(const node &A,const node &B){
  return A.y<B.y;
}
int find1(int x){
  if(x==ufs1[x])return x;
  int rt=find1(ufs1[x]);
  w1[x]+=w1[ufs1[x]];
  return ufs1[x]=rt;
}
int find2(int x){
  if(x==ufs2[x])return x;
  int rt=find2(ufs2[x]);
  w2[x]+=w2[ufs2[x]];
  return ufs2[x]=rt;
}
bool link1(int a,int b,ll w){
  if(find1(a)!=find1(b)){
    int ra=find1(a),rb=find1(b);
    ufs1[ra]=ufs1[rb];
    w1[ra]=w+w1[b]-w1[a];
    return true;
  }else{
    return w1[a]==w+w1[b];
  }
}
bool link2(int a,int b,ll w){
  if(find2(a)!=find2(b)){
    int ra=find2(a),rb=find2(b);
    ufs2[ra]=ufs2[rb];
    w2[ra]=w+w2[b]-w2[a];
    return true;
  }else{
    return w2[a]==w+w2[b];
  }
}
ll Min1[maxn],Min2[maxn];
int main(){
  int R,C;scanf("%d%d",&R,&C);
  for(int i=1;i<=R;++i){
    ufs1[i]=i;w1[i]=0;
  }
  for(int i=1;i<=C;++i){
    ufs2[i]=i;w2[i]=0;
  }
  int n;scanf("%d",&n);
  for(int i=1;i<=n;++i)P[i].read();
  sort(P+1,P+n+1,cmpx);
  for(int i=1;i<n;++i){
    if(P[i].x==P[i+1].x){
      if(!link2(P[i].y,P[i+1].y,P[i+1].val-P[i].val))GG;
    }
  }
  sort(P+1,P+n+1,cmpy);
  for(int i=1;i<n;++i){
    if(P[i].y==P[i+1].y){
      if(!link1(P[i].x,P[i+1].x,P[i+1].val-P[i].val))GG;
    }
  }
  memset(Min1,0x3f,sizeof(Min1));
  memset(Min2,0x3f,sizeof(Min2));
  for(int i=1;i<=n;++i){
    int rt=find1(P[i].x);
    Min1[rt]=min(Min1[rt],P[i].val+w1[P[i].x]);
  }
  for(int i=1;i<=R;++i){
    int rt=find1(i);
    Min2[rt]=min(Min2[rt],-w1[i]);
  }
  for(int i=1;i<=R;++i){
    if(ufs1[i]==i&&Min1[i]+Min2[i]<0){
      GG;
    }
  }
  memset(Min1,0x3f,sizeof(Min1));
  memset(Min2,0x3f,sizeof(Min2));
  for(int i=1;i<=n;++i){
    int rt=find2(P[i].y);
    Min1[rt]=min(Min1[rt],P[i].val+w2[P[i].y]);
  }
  for(int i=1;i<=C;++i){
    int rt=find2(i);
    Min2[rt]=min(Min2[rt],-w2[i]);
  }
  for(int i=1;i<=C;++i){
    if(ufs2[i]==i&&Min1[i]+Min2[i]<0)GG;
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main() {
    long long n, k;
    cin >> n >> k;
    double p = 0;

    for (int i = 1; i <= n; ++i) {
        long long score = i, count = 0;
        while (score < (long long)k) {
            score *= 2;
            ++count;
        }
        p += (1 / (double)n) * pow(0.5, count);
    }
    printf("%.10f\n", p);
    return 0;
}


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

bool check_even(vector<int> v){
    for (const auto& x : v){
        if (x % 2 != 0) return false;
    }
    return true;
}

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

    vector<int> v(N);
    for (auto& x : v) cin >> x;

    int counter = 0;
    while (1){
        if (check_even(v) == true){
            for (auto &x : v) x /= 2;
            ++counter;
        } else break;
    }

    cout << counter << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<list>
using namespace std;

int main()
{
	int n,q;
	int s[10010]={0},t[510]={0};
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
	}
	cin>>q;
	for(int i=0;i<q;i++)
	{
		cin>>t[i];
	}
	int cnt=0;
	for(int i=0;i<q;i++)
	{
		int j=0;
		for(;j<n&&t[i]!=s[j];j++);
		if(j<n)cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3112
#include<stdio.h>
int main(void)
{
	int i,j,n,k,l[50],box,u;
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&l[i]);
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(l[i]<l[j]){
			box=l[i];
			l[i]=l[j];
			l[j]=box;
			}
		}
	}
	for(i=0;i<k;i++){
		u+=l[i];
	}
	printf("%d\n",u);
	return 0;
}

Measured memory_bytes: 128
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]

n = I()
print(ceil(n/2))

Measured memory_bytes: 3316
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Lunlun Number
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int N = 10;

/* typedef */

/* global variables */

int dp[N][10];

/* subroutines */

/* main */

int main() {
  int k;
  scanf("%d", &k);
  k--;
  
  for (int j = 0; j < 10; j++) dp[0][j] = 1;

  for (int i = 1; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      dp[i][j] = dp[i - 1][j];
      if (j > 0) dp[i][j] += dp[i - 1][j - 1];
      if (j < 9) dp[i][j] += dp[i - 1][j + 1];
    }
  }
  //printf("%d\n", dp[9][3]);

  int maxi = 0;
  for (;;) {
    int sum = 0;
    for (int j = 1; j < 10; j++) sum += dp[maxi][j];
    if (sum > k) break;
    k -= sum;
    maxi++;
  }

  for (int i = maxi, j0 = 1, j1 = 9; i >= 0; i--) {
    int j = j0;
    while (j <= j1 && dp[i][j] <= k) k -= dp[i][j++];
    putchar('0' + j);
    j0 = max(j - 1, 0), j1 = min(j + 1, 9);
  }
  putchar('\n');
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>
#include <map>
#include <set>
#include <functional>

using namespace std;

const int N_MAX = 10005;

int f[N_MAX] = {0};
int N;

int main()
{
  cin >> N;

  int x = 1;
  int y = 1;
  int z = 1;
  while (true) {
    int n = pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x;

    if (n <= N) {
      f[n]++;
      z++;
    }
    else {
      if (y == 1 && z == 1) {
        break;
      }
      else if (z == 1) {
        x++;
        y = 1;
        z = 1;
      }
      else {
        y++;
        z = 1;
      }
    }
  }

  for (int i = 1; i <= N; i++) {
    cout << f[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3596
from math import inf
n, m, x = map(int, input().split())
ca = list()
for _ in range(n):
    ca.append(list(map(int, input().split())))

money = inf
tmp = 1
for i in range(n):
    tmp += 2**i
for i in range(tmp):
    B = str(format(i, str(n).zfill(n)+'b'))
    j = 0
    cnt = 0
    a = [0]*m
    for ch in B:
        if ch == '1':
            cnt += ca[j][0]
            for k in range(1, m+1):
                a[k-1] += ca[j][k]
        j += 1
    for ch in a:
        if ch < x:
            break
    else:
        money = min(cnt, money)
print(-1 if money == inf else money)


Measured memory_bytes: 9128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <stdio.h>

int main(){
    int n;
    std::cin>>n;

    int i = 1;
    while(true){
        if(i * i > n){
            std::cout<<(i - 1) * (i - 1)<<std::endl;
            break;
        }
        ++i;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi = vector<int>;
using vl= vector<ll>;
using vs=vector<string>;

ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a);}
ll max(ll a, ll b) {if (a > b) return a; else return b;}
ll min(ll a, ll b) {if (a < b) return a; else return b;}
ll power(ll a,ll b) {ll i,p=1; for(i=0;i<b;i++){p*=a;} return p;}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcase=1;
    //cin>>testcase;
    for(int p=0;p<testcase;p++){
       ll n=0,a=0,b=0;
       cin>>n>>a>>b;
       ll y=0;
       y=n%(a+b);
       ll e=n/(a+b);
       ll bb=e*a;
       bb+=min(y,a);
       cout<<bb;
       
        
        
        
        }

    return 0;
}


Measured memory_bytes: 3576
/*
	Author: Dinesh Verra
	College: ABV-IIITM
	Date: 20/06/2020
*/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define cu continue
#define br break
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define F first
#define S second
#define vll vector <ll>
#define vpll vector <pll>
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define all(v) v.begin(),v.end()
#define nl cout<<'\n'

template <typename A1>
void prn(A1&& arg)
{
	cout<<arg<<'\n';
}
template <typename A1, typename... A>
void prn(A1&& arg, A&&... args)
{
	cout<<arg<<' ';
	prn(args...);
}

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


	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	ll ans=0;
	for(ll i=0;i<k;i++) ans+=a[i];
	prn(ans);
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define all(x) x.begin(),x.end() 
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define per(i,a,b) for(ri i=(a);i>=(b);--i)
#define ls (x<<1)
#define rs (x<<1|1)
#define mid (l+r>>1)
#define db(x) cout << "#x:" << x << endl
#define dd() cout << "Out put!\n"
const int mod=1e9+7,eps=1e-6,pi=acos(-1.0),maxn=1000010;
const int inf=0x7f7f7f7f7f7f7f7f;
using namespace std;
int a[maxn],b[maxn],c[maxn];
string s; 
signed main()
{
	int a,b;
	cin >> a >> b ;
	cout << a*b;
	return 0;
}

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

int n;
int top[100], bottom[100];
int dp[100][100];

int rec(int l, int r)
{
	//printf("l = %d, r = %d\n", l, r);
	if (dp[l][r] != -1) return dp[l][r];

	int res = INT_MAX;
	if (l == r)
	{
		res = 0;
	} else if (l + 1 == r) {
		res = top[l] * bottom[l] * top[r] * bottom[r];
	} else {
		//cout << "YES" << endl;
		for (int i=l; i<=r-1; i++)
		{
			res = min(res, rec(l, i) + rec(i + 1, r) + top[l] * bottom[i] * top[i+1] * bottom[r]);
		}
	}

	return dp[l][r] = res;
}

signed main()
{
	cin >> n;
	rep(i,n) cin >> top[i] >> bottom[i];

	memset(dp, -1, sizeof(dp));
	cout << rec(0, n - 1) << endl;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

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

int main()
{
    cout << fixed << setprecision(15);
    ll A, B, X;
    cin >> A >> B >> X;

    if(X>=A && X<=A+B){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,d,r;
	double f;
	
	scanf("%d %d",&a,&b);
	
	d=a/b;
	r=a%b;
	f=1.0*a/b;
	
	printf("%d %d %.5f\n",d,r,f);
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(){
	int n,i,time_total=0;
	scanf("%d",&n);
	int t[n];
	for(i=0;i<n;i++){
		scanf("%d",&(t[i]));
		time_total+=t[i];
	}
	int m;
	scanf("%d",&m);
	int p[m],x[m];
	for(i=0;i<m;i++){
		scanf("%d %d",p+i,x+i);
	}
	
	for(i=0;i<m;i++){
		printf("%d\n",time_total-t[p[i]-1]+x[i]);
	}
	
	return 0;
}

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

typedef long long ll;
typedef pair< ll, ll > P;

const ll LINF = 1.1e18;

int N;
ll D, X[30], Y[30];
vector< P > v[2];

struct SegmentTree {
	
	int sz;
	vector< ll > node;
	
	SegmentTree(int n) {
		sz = 1;
		while (sz < n) sz <<= 1;
		node.assign(2 * sz - 1, -LINF);
	}

    void update(int k, ll x) {
		k += sz - 1;
		node[k] = x;
		while(k > 0) {
			k = (k - 1) / 2;
			node[k] = max(node[k * 2 + 1], node[k * 2 + 2]);
		}
	}

	ll query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return -LINF;
		if (a <= l && r <= b) return node[k];
		return max(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
	}

	ll query(int a, int b) {
		return query(a, b, 0, 0, sz);
	}
};

void dfs(int type, int idx, int last, ll xsum, ll ysum) {
	if (idx == last) v[type].push_back(P(xsum, ysum));
	else {
		dfs(type, idx + 1, last, xsum, ysum);
		dfs(type, idx + 1, last, xsum + X[idx], ysum + Y[idx]);
		dfs(type, idx + 1, last, xsum - X[idx], ysum - Y[idx]);
	}
}

int main() {
	cin >> N >> D;
	for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];
    
	dfs(0, 0, N / 2, 0, 0);
	dfs(1, N / 2, N, 0, 0);

	sort(v[0].rbegin(), v[0].rend());
	sort(v[1].begin(), v[1].end());
	
	int sz0 = v[0].size(), sz1 = v[1].size();

	SegmentTree tree(sz1);
	for (int i = 0; i < sz1; i++) {
		tree.update(i, v[1][i].second);
	}

	ll ans = 0;
    int l = 0, r = 0;
	for (int i = 0; i < sz0; i++) {
        while (l < sz1 && v[1][l].first < -D - v[0][i].first) l++;
		while (r < sz1 && v[1][r].first <= D - v[0][i].first) r++;
		ll ma = tree.query(l, r);
		ans = max(ans, ma + v[0][i].second);
	}

	cout << ans << endl;
}



Measured memory_bytes: 713372