akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

string s, t;

signed main() {
	cin >> s >> t;
	cout << t << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
#define deb(x) cerr << "\n" << (#x) << " is " << (x) << endl
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}
auto random_add = [] { char *p = new char; delete p; return uint64_t(p); };
const uint64_t SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_add() | 1);
mt19937_64 rng(SEED);


const int N=2e5+5;



void solve()
{
  string s;
  cin>>s;
  if(s.back()=='s')
  s+="es";
  else
  s+="s";
  cout<<s;    
}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t=1;
// cin>>t;
 for(int i=1;i<=t;i++)
 {
   solve();
 }
}


Measured memory_bytes: 3640
#include<stdio.h>

int main(){
    int A[3];
    int i,sum;
    for(i=0;i<3;i++){
        scanf("%d",&A[i]);
        sum += A[i];
    }
    if(sum>=22){
        printf("bust\n");
    }else{
        printf("win\n");
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main()
{
    lint N, K;
    cin >> N >> K;
    lint a = 1;
    lint ans = 1;
    while(true) {
        a *= K;
        if(N < a) {
            cout << ans << endl;
            return 0;
        }
        ans++;
    }
}

Measured memory_bytes: 256
h,w = map(int, input().split())

if h == 1 or w == 1:
    print(1)
elif h % 2 == 0:
    print(int(h*w/2))
else:
    if w % 2 == 0:
        print(int(h*w/2))
    else:
        print(int(h*w//2 + 1))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>

#define INF 1000000000000000000
using namespace std;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	int x, y;
	x = 800 * n;
	y = 200 * (n/ 15);
	cout << x - y << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

n = int(input())
A = list(map(int, input().split()))

answer = 1

for a in A:
  if a == 0:
    answer = 0
    print(answer)
    sys.exit()
    
for a in A:
  answer = answer*a
  if answer > 10**18:
    answer = -1
    print(answer)
    sys.exit()


print(answer)

Measured memory_bytes: 21796
// ABC088D
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>
#include <functional>
#include <set>
#include <iterator>
#include <queue>

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

int main() {
   int X;
   int point = 0;
   int ans = 1;
   cin >> X;
   for (int i=2;i<=31;i++) {
      point = i;
      for (int j=2;;j++) {
         point *= i;
         if (point <= X && ans <= point) {
            ans = point;
         }
         if (point > X) {
            break;
         }
      }
   }
   printf("%d", ans);
}

Measured memory_bytes: 256
n,m=map(int, input().split())
e=[[] for _ in range(n+1)]
for _ in range(m):
    ai,bi=map(int, input().split())
    e[ai].append(bi);e[bi].append(ai)

from collections import deque

pth=deque([1,e[1][0]])
used=[0]*(n+1)
used[1]=1;used[e[1][0]]=1

for _ in range(n*2):
    r=pth[-1]
    for v in e[r]:
        if not used[v]:
            pth.append(v)
            used[v]=1
            break
    l=pth[0]
    for v in e[l]:
        if not used[v]:
            pth.appendleft(v)
            used[v]=1
            break
print(len(pth))
print(*pth)



Measured memory_bytes: 25556
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static int[][] mtx ;
        static List<int>[] tm;
        static int n;
        static int[] results;
        static List<string> cons = new List<string>();
        static void Main(string[] args)
        {
            string[] s1 = Console.ReadLine().Split(' ');
            int n = int.Parse(s1[0]);
            int k = int.Parse(s1[1]);

            string s2 = Console.ReadLine();

            char perm = ' ';
            var score = 0;
            char[] c = s2.ToCharArray();
            for (int i = 0; i < n; i++)
            {
                if (perm == c[i]) score++;
                perm = c[i];
            }

            score += k * 2;
            var max = n - 1;

            Console.WriteLine(Math.Min(score, max));
        }

 

    }

}

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

int main() {
  long long n;
  cin >> n ;
  vector<char> c(n);
  int r=0, ans=0;
  for(int i=0;i<n;i++){
    cin >> c[i];
    if(c[i] =='R') r++;
  }
  
  for(int i=r;i<n;i++){
    if(c[i] == 'R')ans++;
  }
  cout << ans << endl;
      
}


Measured memory_bytes: 3608
#include <stdio.h>

int main(){
    int A, B, C, X, Y;
    
    scanf("%d %d %d %d %d\n", &A, &B, &C, &X, &Y);
    
    int max = X;
    int min = Y;
    int max_cost = A;
    
    if (X < Y){
        min = X;
        max = Y;
        max_cost = B; 
    }
    
    int pattern[3];
    
    pattern[0] = A * X + B * Y;
    pattern[1] = (min * 2 * C) + ((max - min) * max_cost);
    pattern[2] = max * 2 * C;
    
    int result = pattern[0];
    int i;
    
    for (i = 0; i < 3; i++){
        if (result > pattern[i]){
            result = pattern[i];
        }
    }
    
    printf("%d", result);
    
    return 0;
}

Measured memory_bytes: 128
def triangle? a, b, c
  ((a ** 2) + (b ** 2)) == (c ** 2)
end

count = STDIN.gets.chomp.to_i
count.times do |i|
  (a,b,c) = STDIN.gets.chomp.split(" ").map(&:to_i).sort
  output = triangle?(a, b, c) ? 'YES' : 'NO'
  puts output
end

Measured memory_bytes: 8728
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int a,b,c;
	cin >> a>> b >>c;
	if (a == b && a !=c) {
		cout << "Yes" << endl;
		return 0;
	}
	if (b == c && b != a) {
		cout << "Yes" << endl;
		return 0;
	}
	if (a == c && a != b) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>
#include<chrono>
#include<random>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

long double constexpr pi = 3.141592653589793;

template<class T>
constexpr T sigma1(T i, T n){
    return (n - i + 1) * (i + n) / 2;
}

template<class T>
constexpr T sigma2(T i, T n){
    return (i == 1 ? n * (n + 1) * (2 * n + 1) / 6 :
            sigma2(1, n) - sigma2(1, i - 1));
}

template<class T>
constexpr T sigma3(T i, T n){
    if (i == 1) {
        auto temp = sigma1(i, n);
        return temp * temp;
    }
    return sigma2(1, n) - sigma2(1, i - 1);
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);
    ll a;string s;
    cin >> a >> s;

    ll b = 100 * (s[0] - '0') + 10 * (s[2] - '0') + (s[3] - '0');

    cout << a * b / 100<< "\n";


    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	string s;
	cin>>s;
	int A=0,B=0;
	rep(i,s.size()){
		if(s[i]=='c')cout<<"No"<<endl;
		else if(s[i]=='a'){
			if(A+B<a+b){
				cout<<"Yes"<<endl;
				A++;
			}else cout<<"No"<<endl;
		}else{
			if(A+B<a+b&&B<b){
				cout<<"Yes"<<endl;
				B++;
			}else cout<<"No"<<endl;
		}
	}
}








Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define mex 5000005
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//vector<int> adj[mex];
//a+b=a^b+2*(a&b)
int a[25][25];
ll dp[mex];
int n;

ll recur(int idx, int k){
	if(k==n)
	 return 1;
	else if(dp[idx]!=-1)
	 return dp[idx];
	else{
		dp[idx]=0;
		for(int i=0;i<n;i++){
			if((idx&(1<<i))==0 && a[k][i]==1)
			 dp[idx]=(dp[idx]+recur((idx|(1<<i)),k+1))%mod;
		}
		return dp[idx];
	}
}  
int main(){
	fast
	
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)
		 cin>>a[i][j];
	}
	for(int i=0;i<mex;i++)
	 dp[i]=-1;
	 
	cout<<recur(0,0);
	
}


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

using namespace std;
typedef long long ll;

ll dp[10000][10010];
int main(){
    ll n, W, i, j, k, a, b, c;
    cin >> n >> W;
    vector<ll> v, w;
    for(i = 0; i < n;i++){
        cin >> a >> b >> c;
        ll cmpc = c;
        j = 1;
        while(cmpc >>= 1) {
            v.push_back(a * j);
            w.push_back(b * j);
            j <<= 1;
        }
        if(c - j + 1 > 0) {
            v.push_back(a * (c - j + 1));
            w.push_back(b * (c - j + 1));
        }
    }
    ll vs = v.size();
    for(i = 0; i < vs;i++){
        for(j = 0; j <= W;j++){
            dp[i + 1][j] = dp[i][j];
            if(j>=w[i]){
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
            }
        }
    }
    ll ret = 0;
    for(i = 0; i <= W; i++){
        ret = max(dp[vs][i], ret);
    }

    cout << ret << endl;
    return 0;
}


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

int main() {
  string a;
  cin >> a;
  int counter = 0;
  if (a[0] == '1') ++counter;
  if (a[1] == '1') ++counter;
  if (a[2] == '1') ++counter;

  cout << counter << endl;
}


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

int main(){
    int n;
    cin>>n;
    int count[4][3][10]={0};
    int b, f, r, v;
    rep(i, n){
        cin>>b>>f>>r>>v;
        count[b-1][f-1][r-1]+=v;
    }
    rep(i, 4){
        if(i){
            rep(l, 20){
                cout<<"#";
            }
            cout<<endl;
        }
        rep(j, 3){
            rep(k, 10){
                cout<<" "<<count[i][j][k];
            }
            cout<<endl;
        }
    }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

int main() {
	// your code goes here
	long long int x;
	cin>>x;
	long long int a,b;
	int f=0;
	for( a=0;a<=sqrt(x);a++){
		for(b=-sqrt(x);b<=sqrt(x);b++){
			if(pow(a,5)-pow(b,5)==x){
				f=1;
				break;
			}
		}
		if(f==1)
		break;
	}
	cout<<a<<" "<<b;
	return 0;
}

Measured memory_bytes: 4092
import java.util.*;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		String aa=" ";
		aa=sc.next();
		int a=0;
		char[] b=new char[aa.length()];
		for(int i=0;i<aa.length();i++)
		{
			b[i]=aa.charAt(i);
			if(b[i]=='+')
			{a++;}
			else
			{a--;}
		}
		System.out.println(a);
	}
}

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

int main(){
int H,W;

cin>>H>>W;
char S[H][W];
for(int i=0;i<H;i++){
  for(int j=0;j<W;j++){
cin>>S[i][j];
  }
}
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
int ans=0;
if(S[i][j]=='#'){
continue;
}
for(int k=0;k<8;k++){
int ni=i+dx[k];
int nj=j+dy[k];
  if(H<=ni||W<=nj||ni<0||nj<0){
  continue;
  }
if(S[ni][nj]=='#'){
ans++;
}

}
S[i][j]=char('0'+ans);
}
}
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){  
cout<<S[i][j];    

}
cout<<endl;
}
}
  



Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long int

signed main(){
    int n,m;
    cin >> n >> m;
    int an[n];
    int ann[n];

    an[0] = 1;
    for(int i=1;i<n;i++){
        an[i] = 0;
    }

    for(int i=0;i<n;i++){
        ann[i] = 0;
    }

    if(m == 0){
        if(n == 1){
            cout << 0 << endl;
            return 0;
        }
        for(int i=0;i<n;i++){
            cout << an[i];
        }
        cout << endl;return 0;
    }

    int a[m][2];
    for(int i=0;i<m;i++){
        cin >> a[i][0] >> a[i][1];
        a[i][0]--;
    }

    for(int i=0;i<m;i++){
        if(ann[a[i][0]] && (an[a[i][0]] != a[i][1])){cout << -1 << endl;return 0;}
        an[a[i][0]] = a[i][1];
        ann[a[i][0]] = 1;
    }

    if(an[0] == 0 && n != 1){cout << -1 << endl;return 0;}
    for(int i=0;i<n;i++){
        cout << an[i];
    }

    cout << endl;
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n, k;
  std::cin >> n >> k;
  int ans = k;
  srep(i, 1, n) ans *= k - 1;
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef vector<bool> vi;
const int maxn=1e6+10;
char s[maxn];
int n,ans[maxn],len,p3[13];
void solve(int x,int v,vi &a){
    int res[3];
    vi tmp[3];
    for (int i=0;i<3;i++){
        tmp[i].clear();
        int now=i;
        for (int j=0;j<a.size();j++){
            if (a[j]){
                if (now>0) now=3-now;
                tmp[i].pb(1);
                int m=tmp[i].size();
                if (m>=2&&tmp[i][m-1]&&tmp[i][m-2]) tmp[i].resize(m-2);
            } else {
                now++;
                if (now==3){
                    now=0;
                    tmp[i].pb(0);
                }
            }
        }
        res[i]=now;
    }
    for (int i=0;i<p3[n]/p3[x];i++){
        ans[i*p3[x]+v]+=p3[x]*res[i%3];
    }
    if (x<n-1){
        for (int i=0;i<3;i++) solve(x+1,v+i*p3[x],tmp[i]);
    }
}
int main(){
    cin >> n >> s; len=strlen(s);
    vector <vi> dp;
    p3[0]=1; for (int i=1;i<=n;i++) p3[i]=p3[i-1]*3;
    vi res; res.clear();
    for (int i=0;i<len;i++){
        res.pb(s[i]=='S');
        int m=res.size();
        if (m>=2&&res[m-1]&&res[m-2]) res.resize(m-2);
    }
    solve(0,0,res);
    for (int i=0;i<p3[n];i++) cout << ans[i] << ' ' ; cout << endl;
}


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

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int sum = accumulate(all(a),0);
    int max = *max_element(all(a));
    cout << ((sum - max > max) ? "Yes" : "No") << endl;
    return 0;
}


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


int main() {
  string t, p;
  cin >> t >> p;
  int i, j;
  vector<int> a;
  for(i = j = 0; i < t.size() && j < p.size(); i++) {
    if (t[i] == p[j]) {
      j++;
      a.push_back(i);
    }
  }
  if (j != p.size()) {
    cout << "no" << endl;
    return 0;
  }
  string s = t, q = p;
  reverse(s.begin(), s.end());
  reverse(q.begin(), q.end());
  int k, l;
  vector<int> b;
  for(int k = l = 0; k < s.size() && l < q.size(); k++) {
    if (s[k] == q[l]) {
      l++;
      b.push_back(s.size() - k - 1);
    }
  }
  reverse(b.begin(), b.end());
  for (int m = 0; m < a.size(); m++) {
    if (a[m] != b[m]) {
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
}

Measured memory_bytes: 9784
#!/usr/bin/env python3
import sys

# from abc118_B.py

def solve(n, m, x, c, a):
    ret = float('inf')
    N = 1 << 12
    for b in range(N):
        tmp = [0] * m
        C = 0
        for i in range(n):
            if b & (1 << i) > 0:
                C += c[i]
                for j, aa in enumerate(a[i]):
                    tmp[j] += aa
        found = True
        for j in range(m):
            if tmp[j] < x:
                found = False
                break
        if found:
            ret = min(ret, C)
    if ret == float('inf'):
        ret = -1
    print(ret)
    return

def main():
    n, m, x = map(int, input().split())
    c = []
    a = []
    for i in range(n):
        tmp = list(map(int, input().split()))
        c.append(tmp[0])
        a.append(tmp[1:])
    solve(n, m, x, c, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 68708
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

using namespace std;
typedef long long ll;

int main() {

    string S;
    cin >> S;
    string out = "Yes";
    rep(i,S.length()){
        if(i%2 == 1){
            if(S[i] == 'R'){
                out = "No";
                break;
            }
        }else{
            if(S[i] == 'L'){
                out = "No";
                break;
            }
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cstring>
#include<queue>
#define maxn 100000 
using namespace std;
int dist[maxn+5];
bool inq[maxn+5];
vector<pair<int,int> >E[maxn+5];
inline void add_edge(int u,int v,int w){
	E[u].push_back(make_pair(v,w));
}
int spfa(int s,int t){
	memset(dist,0x3f,sizeof(dist));
	queue<int>q;
	q.push(s);
	dist[s]=1;
	inq[s]=1;
	while(!q.empty()){
		int x=q.front();
		q.pop();
		inq[x]=0;
		for(auto p : E[x]){
			int w=p.second,y=p.first;
			if(dist[y]>dist[x]+w){
				dist[y]=dist[x]+w;
				if(!inq[y]){
					inq[y]=1;
					q.push(y);
				}
			}
		}
	}
	return dist[t];
}
int K;
int main(){

	scanf("%d",&K);
	for(int i=0;i<K;i++){
		add_edge(i,(i+1)%K,1);//如果没有进位,数位和+1 
		add_edge(i,i*10%K,0);
	}
	printf("%d\n",spfa(1,0));//从1到%K=0(实际上就是K) 
	
}


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

using ll = long long int;

const ll MAX = (ll)(1e9 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

/////////////////////////////////////////////////////////////
// (0, n]
class BinaryIndexedTree {
 public:
  vector<ll> arr;
  int n;

  BinaryIndexedTree(int n) {
    this->arr = vector<ll>(n + 1, 0LL);
    this->n = n;
    init();
  }

  void init() {
    for (int i = 0; i < n; ++i) arr[i] = 0LL;
  }

  ll sum(int i) {
    ll s = 0LL;
    while (i > 0) {
      s += arr[i];
      i -= i & -i;
    }
    return s;
  }

  void add(int i, ll x) {
    while (i <= n) {
      arr[i] += x;
      i += i & -i;
    }
  }
};
/////////////////////////////////////////////////////////////

int n;
ll a[MAX_N];
ll b[MAX_N];

int s[MAX_N];

BinaryIndexedTree bit(MAX_N * 2);

bool check(ll x) {
  ll num = 0;

  for (int i = 1; i <= n; ++i) s[i] = (a[i] >= x) ? 1 : -1;
  for (int i = 1; i <= n; ++i) s[i] += s[i - 1];

  bit.init();

  for (int i = 0; i <= n; ++i) {
    num += bit.sum(s[i] + MAX_N);
    bit.add(s[i] + MAX_N, 1);
  }

  ll whole = (1LL * (n + 1) * n) / 2;
  ll target = (whole - 1) / 2 + 1;

  return (num >= target);
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &(a[i]));
    b[i] = a[i];
  }

  sort(b + 1, b + n + 1);

  b[n + 1] = b[n] + 1;  // guard

  int ok = 1;
  int ng = n + 1;

  while (abs(ok - ng) > 1) {
    int next = (ok + ng) / 2;

    if (check(b[next])) {
      ok = next;
    } else {
      ng = next;
    }
  }

  printf("%lld\n", b[ok]);

  return 0;
}


Measured memory_bytes: 3840
/*
ID: tanser.1
TASK: gift1
LANG: C++14
*/
#include <bits/stdc++.h>
//------
#define IC ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define db double
#define str string
//------
using namespace std;
//-------------------------
const int maxn=2e5+10;
ll n , a[maxn] , i , ans , cur ;
bool yes=1 ;
//-------------------------
int main()
{IC
/*
    ofstream cout ("gift1.out");
    ifstream cin ("gift1.in");
*/
    cin >> n ;
    for(i=0 ; i<n ; i++)
        cin >> a[i];
    for(i=n-2 ; i>=0 ; i--)
    {
        if(a[i]>i || a[i]<max(0LL,a[i+1]-1))
        {
            yes=0;
            break;
        }
    }
    if(!yes || a[0])
    {
        cout << "-1\n";
        return 0;
    }
    else
    {
        for(i=n-1 ; i>=0 ; i--)
        {
            if(cur<a[i])
            {
                cur=a[i];
                ans+=a[i];
            }
            cur=max(0LL,cur-1);
        }
    }
    cout << ans << endl ;
    return 0;
}


Measured memory_bytes: 1792
N=input()
n=list(N)
l=int(len(n))
L=[9,900,90000]
if l%2==0:
    if l==6:
        print(sum(L))
    elif l==4:
        print(9+900)
    else:
        print(9)
else:
    if l==5:
        print(int(N)-9999+909)
    elif l==3:
        print(int(N)-99+9)
    else:
        print(int(N))

Measured memory_bytes: 38256
#include "algorithm"
#include "functional"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

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

  ll H, W, K;
  cin >> H >> W >> K;

  V<string> mat(H);
  rep(i, H) cin >> mat[i];

  V<V<ll>> res(H, V<ll>(W));

  ll use = 0;
  rep(i, H) {
    use++;
    bool ok = false;

    rep(j, W) {
      auto c = mat[i][j];

      if (c == '#') {
        if (ok) {
          use++;
        }
        ok = true;
      }

      res[i][j] = use;
    }

    if (!ok) {
      rep(j, W) { res[i][j] = -1; }
      use--;
    }
  }

  rep(i, H) {
    if (i == 0) continue;

    if (res[i][0] == -1) {
      rep(j, W) res[i][j] = res[i - 1][j];
    }
  }

  for (ll i = H - 2; i >= 0; i--) {
    if (res[i][0] == -1) {
      rep(j, W) res[i][j] = res[i + 1][j];
    }
  }

  rep(i, H) {
    rep(j, res[i].size()) {
      if (j > 0) {
        cout << " ";
      }

      cout << res[i][j];
    }

    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#define REP(i,a) for(int i = 0; i < (a); i++)
using namespace std;

int binarySearch(int a[], int n, int key){
	int left = 0;
	int right = n;
	int mid;
	while(left < right){
		mid = (left + right) / 2;
		if(key == a[mid]) return 1;
		else if(key > a[mid]) left = mid + 1;
		else right = mid;
	}
	return 0;
}

int main(){
	int n;
	cin >> n;
	int s[n];
	REP(i,n) cin >> s[i];
	int q;
	cin >> q;
	int t[q];
	REP(i,q) cin >> t[i];
	int sum = 0;
	REP(i,q){
		if(binarySearch(s, n, t[i]))sum++;
	}
	cout << sum << endl;
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    for(char c : s) if(c == 'R')    cnt++;
    if(cnt > n-cnt) cout << "Yes" << endl;
    else            cout << "No" << endl;
    return 0;
}

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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int MAXN = 100;
//#define int long long
const int INF = 1e9;

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

    int n;
    cin >> n;
    int a, b;
    ll ans = 0LL;
    for (int i = 0; i < n-1; i++){
    	cin >> a >> b;
    	if (a > b) swap(a, b);
    	
    	ans -= (ll)a * (ll)(n - b + 1);
    }

    for (int i = 1; i <= n; i++){
    	ans += (ll)i * (ll)(n - i + 1);
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3628
n, k, q = map(int,input().split())
a = [int(input()) for _ in range(q)]
ans = [k-q]*n

for i in range(q):
  ans[a[i]-1] += 1
  
for i in range(n):
  if(ans[i] <= 0):
    print("No")
  else:
    print("Yes")
  


Measured memory_bytes: 10472
#include<cstdio>
using namespace std;
#define N 5005
long long dp[N][N];
int n,a,b,p[N];
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)dp[i][j]=1e17;
	dp[0][0]=0;
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	for(int i=1;i<=n;i++)
	{
		long long mn=1e18;
		for(int j=0;j<=n;j++)
		{
			long long tp=mn;
			if(p[i]>j)tp+=a;
			if(p[i]<j)tp+=b;
			if(dp[i][j]>tp)dp[i][j]=tp;
			if(mn>dp[i-1][j])mn=dp[i-1][j];
			tp=mn;
			if(p[i]>j)tp+=a;else tp+=b;
			if(dp[i][j]>tp)dp[i][j]=tp;
		}
	}
	long long as=1e18;
	for(int i=0;i<=n;i++)if(as>dp[n][i])as=dp[n][i];
	printf("%lld\n",as);
}

Measured memory_bytes: 195712
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    string s;
    cin>>s;
    if(s[5]!='0'||s[6]-'0'>4){ 
        out("TBD");
    }
    else{ 
        out("Heisei");
    }
}

Measured memory_bytes: 3604
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    # 入力
    N, M = LI()
    es = [[x for x in LI()] for _ in range(M)]
    all_v = list(range(1, N+1))

    # まず、outs, ins を定義する。
    # outs はグラフの関連リスト表記。
    # outs = {node1: [node2, node3, ...], node2: [...], ...}
    # ins は、そのノードに入る辺の本数。
    # ins  = {node1: 1, node2: 2, ...}

    from collections import defaultdict

    outs = defaultdict(list)  # ノードが int なら、[[] for _ in range(n+1)] でもよさそう。
    ins = defaultdict(int)    # ノードが int なら、 [0 for _ in range(n+1)] でもよさそう。
    for from_v, to_v in es:
        outs[from_v].append(to_v)
        ins[to_v] += 1


    # つぎに、探索キューを初期化する。
    # ノードを全探索し、ins が 0 のものを探索キューに入れておく。

    from collections import deque
    q = deque()
    for v in all_v:
        if ins[v] == 0:
            q.append((v, 0))  # node, depth


    # トポロジカルソート本体（要は幅優先探索）

    res = []
    depth_max = 0
    while q:
        v1, depth = q.popleft()
        res.append(v1)
        for v2 in outs[v1]:
            ins[v2] -= 1
            if ins[v2] == 0:
                q.append((v2, depth+1))
                depth_max = max(depth_max, depth+1)


    # # 結果
    # print(res)  # ソート済みリスト

    # # 閉路判定（閉路はあるか？）
    # print(False if len(res) == n else True)  # res の長さがノード数と一致していたら、閉路なし。そうでなければ閉路あり。

    # 最大の深さ：深さの情報も同時に埋め込んでおく（上のコードにはもう埋め込んである）。
    print(depth_max)


main()

Measured memory_bytes: 102620
h, w = map(int, input().split())
S = [["#"] * (w + 2)]
for i in range(h):
    S.append(["#"] + list(input()) + ["#"])
S.append(["#"] * (w + 2))
Lamp_row = [[0 for i in range(w+2)] for j in range(h+2)]
Lamp_col = [[0 for i in range(w+2)] for j in range(h+2)]
#print(S)

for row in range(h + 2):
    counter = 0
    for col1 in range(w + 1):
        col2 = col1 + 1
        if S[row][col1] == "#" and S[row][col2] == ".":
            start = col2
            counter += 1
        if S[row][col1] == "." and S[row][col2] == ".":
            counter += 1
        if S[row][col1] == "." and S[row][col2] == "#":
            end = col2
            for i in range(start, end):
                Lamp_row[row][i] = counter
            counter = 0
#print(*Lamp_row, sep="\n")
#print()

for col in range(w + 2):
    counter = 0
    for row1 in range(h + 1):
        row2 = row1 + 1
        if S[row1][col] == "#" and S[row2][col] == ".":
            start = row2
            counter += 1
        if S[row1][col] == "." and S[row2][col] == ".":
            counter += 1
        if S[row1][col] == "." and S[row2][col] == "#":
            end = row2
            for i in range(start, end):
                Lamp_col[i][col] = counter
            counter = 0
#print(*Lamp_col, sep="\n")

max_sum = 0
for row in range(h+2):
    for col in range(w+2):
        max_sum = max(max_sum, Lamp_row[row][col] + Lamp_col[row][col] - 1)
print(max_sum)

Measured memory_bytes: 302924
#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=(double)a/b;

   printf("%d %d %lf",d,r,f);

   return 0;

}
 

Measured memory_bytes: 636
from itertools import accumulate


def main():
    creatures = int(input())
    size = [int(x) for x in input().split()]
    size.sort()
    accumulate_size = list(accumulate(size))
    survivable = 0
    for i in range(creatures - 1):
        if 2 * accumulate_size[i] < size[i + 1]:
            survivable = i + 1
    print(creatures - survivable)


if __name__ == '__main__':
    main()



Measured memory_bytes: 14428
#include<bits/stdc++.h>
using namespace std;
template<typename T>
struct BIT{
	int n;
	vector<T>bit;
	BIT(int n_=0,T a=0):n(n_),bit(n_+1,a){}
	T sum(int i)
	{
		T ans=0;
		for(;i>0;i-=i&-i)ans+=bit[i];
		return ans;
	}
	void add(int i,T a)
	{
		if(i==0)return;
		for(;i<=n;i+=i&-i)bit[i]+=a;
	}
};
long n,r,l=-1,m,c,s,i;
vector<int>a;
main(){
	for(cin>>n;cin>>m;r=r<m?m:r)a.push_back(m);
	for(;r-l>1;)
	{
		m=l+r>>1;
		c=s=i=0;
		BIT<int>P(2*n);
		P.add(n,1);
		for(;i<n;i++){
			s+=a[i]>m?-1:1;
			c+=P.sum(s+n-1);
			P.add(s+n,1);
		}
		(c>n*(n+1)/4?r:l)=m;
	}
	cout<<r;
}


Measured memory_bytes: 1528
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

#include <x86intrin.h>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<ll> a(n+4);
  for (int i = 0; i < n; i++) cin >> a[i];

/*
  if (n % 2 == 0) {
    ll now = 0;
    for (int i = 0; i < n; i += 2) now += a[i];
    ll maximum = now;
    for (int i = n-2; i >= 0; i -= 2) {
      now += (a[i+1] - a[i]);
      if (now > maximum) maximum = now;
    }

    cout << maximum << endl;
  }
  else {
    vector<vector<ll> > dp(n+2, vector<ll>(3, (ll) -1e18));
    dp[0][0] = a[0];
    dp[1][1] = a[1];
    dp[2][2] = a[2];
    for (int i = 0; i < n; i++) {
      if (i+2 < n) dp[i+2][0] = max(dp[i+2][0], dp[i][0] + a[i+2]);
      if (i+2 < n) dp[i+2][1] = max(dp[i+2][1], dp[i][1] + a[i+2]);
      if (i+2 < n) dp[i+2][2] = max(dp[i+2][2], dp[i][2] + a[i+2]);
      if (i+3 < n) dp[i+3][1] = max(dp[i+3][1], dp[i][0] + a[i+3]);
      if (i+3 < n) dp[i+3][2] = max(dp[i+3][2], dp[i][1] + a[i+3]);
      if (i+4 < n) dp[i+4][2] = max(dp[i+4][2], dp[i][0] + a[i+4]);
    }

    cout << max(max(dp[n-3][0], dp[n-2][1]), dp[n-1][2]) << endl;
  }
*/

  vector<vector<ll> > next(n/2+16, vector<ll>(4));
  for (int i = 0; i < n; i += 2) {
    next[i/2][0] = a[i];
    next[i/2][1] = a[i+1];
    next[i/2][2] = a[i+2];
  }

  vector<vector<ll> > dp(n/2+16, vector<ll>(4, (ll) -1e18));
  dp[0][0] = next[0][0];
  dp[0][1] = next[0][1];
  dp[0][2] = next[0][2];
  for (int i = 0; i < n/2; i++) {
    dp[i+1][0] = dp[i][0] + next[i+1][0];
    dp[i+1][1] = max(dp[i][0], dp[i][1]) + next[i+1][1];
    dp[i+1][2] = max(max(dp[i][0], dp[i][1]), dp[i][2]) + next[i+1][2];
  }

  ll ans = max(dp[n/2-1][0], dp[n/2-1][1]);
  if (n % 2 == 1) ans = max(ans, dp[n/2-1][2]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 18776
#pragma comment(linker, "/STACK:10240000")
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

int main ()
{
    int n;
    scanf ("%d", &n);
    int ans = 0;
    for (int i = 1; i <= n; i ++)
    {
        int l, r;
        scanf ("%d%d", &l, &r);
        ans += r - l + 1;
    }
    printf ("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
n  = int(input())
#  = map(int, input().split())
p  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

ans = 0
min_ = 10**9
for i in range(n):
    if p[i] < min_:
        ans += 1
        min_ = p[i]

print(ans)



Measured memory_bytes: 25128
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	int n=s.size();
	string t1="",t2="";
	int x=0;
	for(int i=0;i<n;i++)
	{
		t1+=x+'0';
		t2+=(1^x)+'0';
		x^=1;
	}
	x=0;
	int y=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]!=t1[i])
			++x;
		if(s[i]!=t2[i])
			++y;
	}
	cout<<min(x,y)<<endl;
	return 0;
}

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

int main(){
    ll N,M;
    cin >> N >> M;
    priority_queue<ll> A;
    ll sum=0;
    rep(i,N){
        ll a;
        cin >> a;
        A.push(a);
    }
    rep(m,M){
        A.push(A.top()/2);
        A.pop();
    }

    rep(i,N){
        sum+=A.top();
        A.pop();
    };
    cout << sum << endl;
    return 0;
}

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

#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)

int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	string ans="No";
	if((abs(b-a)<=d&&abs(c-b)<=d)|abs(a-c)<=d)
	ans="Yes";
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream> 
#include <algorithm> 
#include <cstring> 
using namespace std;
struct node 
{ 
int c;//每本书的价格
int a[15];//这本书能够提升Ta的第j个算法多少等级
}book[15];//储存每一本书的信息
int b[15];//统计每个子集能够提升第j个算法的总的等级数 
int main() 
{ 
int n,m,x; 
cin>>n>>m>>x; 
for(int i=0;i<n;i++) 
{ 
cin>>book[i].c;  for(int j=0;j<m;j++) cin>>book[i].a[j]; 
} 
int ans=2e9; 
for(int i=0;i<(1<<n);i++) 
{ 
memset(b,0,sizeof b); 
int sum=0;//统计每一个子集所有书的总价格 
for(int j=0;j<n;j++) 
if(i>>j&1) 
{ 
sum+=book[j].c; 
for(int k=0;k<m;k++) b[k]+=book[j].a[k]; 
} 
bool flag=1;//判断m个算法是否都大于等于x，1为是，0为否 
for(int j=0;j<m;j++) if(b[j]<x) flag=0; 
if(flag) ans=min(ans,sum);//每次都选择更小价格 
} 
if(ans==2e9) cout<<"-1"; 
else cout<<ans;
return 0; 
}


Measured memory_bytes: 3600
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<map>
#include<array>
#include<cstring>
#include<numeric>
#include<string>
#include<set>
#include<cstdio>
#include<cmath>
#include<unordered_map>
#include<bitset>
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    int n;
    string s;
    cin>>n>>s;
    int sum=0;
    for(int i=0; i<s.size()-2; i++){
        if(s[i]=='A' && s[i+1]=='B' &&s[i+2]=='C')
            sum++;
    }
    cout<<sum<<"\n";
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lld long double
#define vc vector<ll>
typedef pair<ll,ll>pairs;
int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	ll t,n,i,j,k,l,c,f;
	char s;
	cin>>s;
    n=s;
    if(n>=97&&n<=122)
        cout<<'a';
    else
        cout<<'A';
	return 0;
}


Measured memory_bytes: 3648
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <thread>
#include <math.h>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <set>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for(int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

void Solve(){
	int a,b,c;	cin >> a >> b >> c;
	int ans = 0, num = a;
	while(num <= b){
		if(num % c == 0){
			ans++;
		}
		num++;
	}
	cout << ans << endl;
}

int main(){
	ios::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
	int t = 1;
	//int t;	cin >> t;
	while(t--) Solve();
	return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a
#define pr2(a,b)    cout<<a<<" "<<b
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll minize(ll& a,ll b){return a=(a>b?b:a);}
inline ll maxize(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll c[MAXN+5];
string s;
ll Solves(){
	
	ll n,k,cnt=0,ans=0,x,y,q,sum=0,v,t,m,odd=-1,four=0,two=0;
	// PROCESSING IN HERE
	sc2(n,m);
	fu(i,1,n){
		sc(s);
		fu(i,0,le(s)-1)c[s[i]]++;	
	}
	
	if(n&1 and m&1){
		two=(n-1+m-1)/2;
		fu(i,'a','z'){
			if(c[i]&1){
				if(odd!=-1){
					re cout<<"No",0;
				}
				else{
					odd=i;
					c[i]--;
					if(c[i]%4!=0){
						two--;
					}	
				}
									
			}
			else{
				if(c[i]%4!=0)	two--;					
			}	
			if(two<0)re cout<<"No",0;			
		}
		re cout<<"Yes",0;
	}
	if(n&1 or m&1){
		if(m&1)swap(n,m);				//n is odd
		two=m/2;
		
		fu(i,'a','z'){
			if(c[i]&1){
				re cout<<"No",0;				
			}
			else{
				if(c[i]%4!=0)	two--;					
			}	
			if(two<0)re cout<<"No",0;			
		}
		re cout<<"Yes",0;		
	}
	
	
	fu(i,'a','z'){
		if(c[i]&1 or c[i]%4!=0){
			re cout<<"No",0;				
		}			
	}
	
	re cout<<"Yes",0;

	re 0;
	// Hack it if you can :)
}

int main(){
//	INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	ll test;
//	sc(test);
//	fu(T,1,test)
	Solves();
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

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

ans = 'APPROVED'
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 == 0 or a[i] % 5 == 0:
            continue
        else:
            ans = 'DENIED'
            break

print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n;
int a[N];
long long dp[N];

long long f(int idx){
  if (idx>=n-1) return idx>=n?2e9+100:0;
  long long &ret = dp[idx];
  if (ret != -1) return ret;
  return ret = min(f(idx+1)+abs(a[idx]-a[idx+1]), f(idx+2)+abs(a[idx]-a[idx+2]));
}

int main(){
   scanf("%d",&n);
   for(int i=0; i<n; i++){
     scanf("%d",a+i);
   }
   memset(dp,-1,sizeof dp);
   cout << f(0) << endl;
}

Measured memory_bytes: 2944
#include <stdio.h>
#include <string.h>
int main(void)
{
	int n,m,i,j,x=0,y,max=0;
	char s[101][11],t[101][11],u[11];
	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%s",&s[i]);
	}
	scanf("%d\n",&m);
	for(i=0; i<m; i++){
		scanf("%s",&t[i]);
	}
	for(i=0; i<n; i++){
		strcpy(u,s[i]);
		for(j=0; j<n; j++){
			y=strcmp(u,s[j]);
			if(y==0){
				x=x+1;
			}
		}
		for(j=0; j<m; j++){
			y=strcmp(u,t[j]);
			if(y==0){
				x=x-1;
			}
		}
		if(max<x){
			max=x;
		}
		x=0;
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i=0;i<t;i++)
#define ll long long int
#define ld long double
#define umpl unordered_map<ll,ll> 
#define vl vector<ll>
#define vld vector<ld>
#define vvl vector<vl>
#define pb push_back
#define pll pair<ll,ll>
#define inf 1e18
#define pcout(x,p) cout<<fixed<<setprecision(p)<<x
#define all(a) a.begin(),a.end()
#define endl "\n"
const ll mod=998244353;
inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}
inline ll ceil(ll a,ll b){return (a%b==0)?(a/b):(a/b+1);}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    for(auto v : V) os << v <<"  ";
    return os;
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") ";
    return os<<"}";
}
struct comp { 
    template<class T1,class T2,class T3,class T4>
    bool operator()(const pair<T1,T2> &p1,const pair<T3,T4> &p2){
        return p1.first<p2.first;
    }
};


int main(){
	fio;	
	ll n,k;cin>>n>>k;
	set<ll> s;
	vector<pll> a(k);
	for(ll i=0;i<k;i++){
		ll l,r;cin>>l>>r;
		a[i]={l,r};
	}
	sort(all(a));
	vl dp(n+1,0);
	dp[0]=1;
	dp[1]=1;
	map<ll,ll> pre;
	pre[1]=1;
	for(ll i=2;i<=n;i++){
		for(int j=0;j<k;j++){
			if(a[j].first>=i){
				break;
			}else{
				ll temp=sub(pre[i-a[j].first],pre[i-a[j].second-1]);
				dp[i]=add(dp[i],temp);
			}
		}
		pre[i]=add(pre[i-1],dp[i]);
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 29040
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main() {
  int N,K;
  cin >> N >> K; 
  vector<char> v(N);
  REP(i,N)cin >> v.at(i);
  if(v.at(K-1)=='A'){
  	v.at(K-1) = 'a';
  }else if(v.at(K-1)=='B'){
    v.at(K-1) = 'b';
  }else{
  	v.at(K-1) = 'c';
  }
  
  REP(i,N){
    cout << v.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256