akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int hmr, oktime;
  cin >> hmr >> oktime;
  vector<int> costs(hmr);
  vector<int> times(hmr);
  for (int i = 0; i < hmr * 2; i++) {
    if (i % 2 == 0) {
      cin >> costs.at(i / 2);
    } else {
      cin >> times.at(i / 2);
    }
  }
  int isittle = 0;
  for (int i = 0; i < hmr; i++) {
    if (times.at(i) > oktime) {
      isittle++;
    }
  }
  int leastcost = 0;
  if (isittle == hmr) {
    cout << "TLE" << endl;
  }
  else {
    for (int i = 0; i < hmr; i++) {
      if (times.at(i) <= oktime) {
        if (costs.at(leastcost) > costs.at(i)) {
          leastcost = i;
        }
      }
    }
    cout << costs.at(leastcost) << endl;
  }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

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

	ll k = 1,cur = 1LL;
	while(1){
		cur = k * (k - 1) / 2LL;
		if(cur >= n) break;
		k++;
	}


	if(cur != n){
		puts("No");
	} else {
		puts("Yes");
		cout << k << endl;
		vector<vector<int>> ans(k);
		int val = 1;
		rep(i,k)rep(j,i){
			ans[i].push_back(val);
			ans[j].push_back(val);
			val++;
		}

		rep(i,k){
			cout << ans[i].size();
			for(auto &elem:ans[i]) cout << " " << elem;
				cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 2304
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int h,w; cin >> h >> w;
	int m; cin >> m;
	vector<int> a(m),b(m);
	set<pair<int,int>> st;
	vector<pair<int,int>> H(h),W(w);
	for(int i=0;i<m;i++){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		H[a[i]].first++;
		W[b[i]].first++;
		st.insert({a[i],b[i]});
	}
	for(int i=0;i<h;i++){
		H[i].second=i;
	}
	for(int i=0;i<w;i++){
		W[i].second=i;
	}
	sort(H.rbegin(), H.rend());
	sort(W.rbegin(), W.rend());
	int sum=H[0].first+W[0].first;
	if(st.find(make_pair(H[0].second,W[0].second))==st.end()){
		printf("%d\n",sum );
		return 0;
	}
	for(int i=0;i<h;i++){
		if(H[0].first!=H[i].first)break;
		for(int j=0;j<w;j++){
			if(W[0].first!=W[j].first)break;
			if(st.find(make_pair(H[i].second,W[j].second))==st.end()){
				printf("%d\n",sum );
				return 0;
			}
		}
	}
	printf("%d\n",sum-1 );
}

Measured memory_bytes: 24356
#include <stdio.h>

int main(void) {
	int a,b;
	while(scanf("%d%d", &a, &b)){
		if(a == 0 && b == 0) break;
		if(a < b) printf("%d %d\n", a,b);
		else printf("%d %d\n", b,a);
	}
	return 0;
}

Measured memory_bytes: 600
N = int(input())
A = list(map(int, input().split()))
s = 0
count = 0
for i in range(N):
    if A[i] >=0:
        s += A[i]
    else:
        A[i] = - A[i]
        s += A[i]
        count += 1

if count%2 == 0:
    ans = s
else:
    ans = s - 2*min(A)

print(ans)

Measured memory_bytes: 14224
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll X, Y, A, B, C, p[112345], q[112345], r[112345];

int main() {

	cin >> X >> Y >> A >> B >> C;
	rep(i, A) cin >> p[i];
	rep(i, B) cin >> q[i];
	rep(i, C) cin >> r[i];

	sort(p, p + A, greater<>());
	sort(q, q + B, greater<>());
	sort(r, r + C, greater<>());

	vector<ll> eat;

	rep(i, X) eat.push_back(p[i]);
	rep(i, Y) eat.push_back(q[i]);

	sort(all(eat));

	rep(i, min(X + Y, C)) {
		if (eat[i] < r[i]) {
			eat[i] = r[i];
		}
		else {
			break;
		}
	}

	cout << accumulate(all(eat), 0ll) << endl;

	return 0;
}


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

using namespace std;

int main(){

  int e;

  while(cin>>e,e){

	int m=100000;

	  for(int z=0;z*z*z<=e;++z){
		for(int y=0;y*y<=e-z*z*z;++y){
		  int x=e-y*y-z*z*z;
		  m = min(m,x+y+z);
		}
	  }
	  
	  cout<<m<<endl;
	
  }
  
}

		   



Measured memory_bytes: 3080
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main (){
	
	string s1 , s2;
	cin >> s1 >> s2;
	reverse(s2.begin() , s2.end());
	if(s1==s2)cout << "YES";
	else cout <<"NO";
	return 0;
}

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

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    string ans;
    rep(i,n) {
        ans += s[i];
        ans += t[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
typedef struct{double x,y,key;}w;w p[101],bs;i,m,v[100],n,j;z(w*c,w*d){return c->key>d->key?-1:c->key<d->key;}double outer(q,r,s){return p[q].x*(p[r].y-p[s].y)+p[r].x*(p[s].y-p[q].y)+p[s].x*(p[q].y-p[r].y);}main(){double k,t;for(;~scanf("%d",&n),n;){for(m=i=0;i<n;i++)scanf("%lf,%lf",&p[i].x,&p[i].y),p[m].y>p[i].y?m=i:0;bs=p[m];p[m]=*p;*p=bs;p[100].x=bs.x;p[100].y=bs.y+1;for(i=1;i<n;i++){k=outer(0,i,100);t=(p[i].x-bs.x)*(p[i].x-bs.x)+(p[i].y-bs.y)*(p[i].y-bs.y);k*=k/t;if(bs.x>p[i].x)k=-k;p[i].key=k;}qsort(p+1,n-1,sizeof(w),z);v[0]=0;v[1]=1;v[2]=j=2;for(i=3;i<n;i++){for(;outer(v[j-1],v[j],i)<=0;j--);v[++j]=i;}printf("%d\n",n+~j);}exit(0);}

Measured memory_bytes: 0
W,H,N=map(int,input().split())
points=[[int(i) for i in input().split()] for _ in range(N)]

space=[[0 for _ in range(H)] for __ in range(W)]
for point in points:
    if point[2]==1:
        for i in range(W):
            for j in range(H):
                if i<point[0]:
                    space[i][j]=1
    elif point[2]==2:
        for i in range(W):
            for j in range(H):
                if i>=point[0]:
                    space[i][j]=1
    elif point[2]==3:
        for i in range(W):
            for j in range(H):
                if j<point[1]:
                    space[i][j]=1
    elif point[2]==4:
        for i in range(W):
            for j in range(H):
                if j>=point[1]:
                    space[i][j]=1

count=0

for i in range(W):
    for j in range(H):
        if space[i][j]==0:
            count+=1
print(count)

Measured memory_bytes: 43244
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {

	int T[5];
	int i=0, min=0, d=10;

	while(i < 5){
	scanf("%d", &T[i]);

	if(T[i] % 10 != 0){

		if(T[i] % 10 <= d){
				d = T[i] % 10;
			}

		while(T[i] % 10 != 0){
			T[i]++;
		}
	}
	min += T[i];
	i++;
	}

	min = min - (10-d);

	printf("%d", min);

	return 0;
}


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

int main(){
    int h, w; cin >> h >> w;
    char A[h][w];
    int sharp=0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> A[i][j];
            if(A[i][j]=='#')
                sharp++;
        }
    }
    if(sharp == h + w -1){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;

}

Measured memory_bytes: 3612
# n, k = map(int, input())
n = int(input())
heights = list(map(int, input().split()))
heights = [0] + heights
dp = [10**10]*(n+1)
dp[1] = 0
for i in range(1, n+1 - 2):
    dp[i+1] = min(dp[i+1], abs(heights[i+1] - heights[i]) + dp[i])
    dp[i+2] = min(dp[i+2], abs(heights[i+2] - heights[i]) + dp[i])

dp[n] = min(dp[n], dp[n-1] + abs(heights[n] - heights[n-1]))
print(dp[n])



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


int main(){
  
  int X, Y;
  cin >> X >> Y;
  
  for(int i = 0; i <= X; i++){
    
    if (2 * i + 4 * (X - i) == Y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <stack>
#include <limits>
#include <climits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>
#include <set>
#include <array>

using namespace std;

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

#define inf 0x3f3f3f3f
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second
#define SETUP cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15)

namespace {
	struct input_returnner {
		int N; input_returnner(int N_ = 0) :N(N_) {}
		template<typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); }
		template<typename T> operator T() const { T res; cin >> res; return res; }
		template<typename T> T operator - (T right) { return T(input_returnner()) - right; }
		template<typename T> T operator + (T right) { return T(input_returnner()) + right; }
		template<typename T> T operator * (T right) { return T(input_returnner()) * right; }
		template<typename T> T operator / (T right) { return T(input_returnner()) / right; }
		template<typename T> T operator << (T right) { return T(input_returnner()) << right; }
		template<typename T> T operator >> (T right) { return T(input_returnner()) >> right; }
	};
	template<typename T> input_returnner in() { return in<T>(); }
	input_returnner in() { return input_returnner(); }
	input_returnner in(int N) { return std::move(input_returnner(N)); }
}

void solve();
/// ---template---

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

signed main(void) {
	SETUP;
	solve();
	return 0;
}

void solve() {
	string str[] = { "dreamer", "dream", "eraser", "erase" };
	REP(i, 4) reverse(str[i].begin(), str[i].end());

	string S = in();
	reverse(S.begin(), S.end());

	while (S.size() > 0) {
		bool f = false;
		REP(i, 4) {
			if (S.find(str[i]) == 0) {
				S = S.substr(str[i].size());
				f = true;
			}
		}
		if (not f) {
			cout << "NO" << endl;
			return;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
string s;

int main(void){
  
  IN(N);
  ll happy[3][ARRAY];
  REP(i, N) {
    IN(happy[0][i]);
    IN(happy[1][i]);
    IN(happy[2][i]);
  }

  ll dp[3][ARRAY];
  dp[0][0] = happy[0][0];
  dp[1][0] = happy[1][0];
  dp[2][0] = happy[2][0];
  FOR(i, 1, N) {
    dp[0][i] = happy[0][i] + max(dp[1][i-1], dp[2][i-1]);
    dp[1][i] = happy[1][i] + max(dp[2][i-1], dp[0][i-1]);
    dp[2][i] = happy[2][i] + max(dp[0][i-1], dp[1][i-1]);
  }
  ret = CHMAX(ret, dp[0][N-1]);
  ret = CHMAX(ret, dp[1][N-1]);
  ret = CHMAX(ret, dp[2][N-1]);
  PRINT(ret);
}


Measured memory_bytes: 4992
#include<iostream>
#include<string>

int main(){
    
    std::string s;
    std::cin >> s;

    if(s == "Sunny"){
        std::cout << "Cloudy" << std::endl;
    }else if(s == "Cloudy"){
        std::cout << "Rainy" << std::endl;
    }else{
        std::cout << "Sunny" << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] place = new int[N];
        double sum = 0;
        
        
        for(int i = 0; i < N; i++) {
            place[i] = sc.nextInt();
            sum += place[i];
        }
        
        double av = sum / N;
        int intav = (int)av;
        if(av - intav >= 0.5) {
            intav += 1;
        }
        

        int ans = 0;
        for(int i = 0; i < N; i++) {
            ans += Math.pow(place[i] - intav, 2);
        }
        
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 21588
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<vector>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC diagnostic error "-std=c++14"

#define isNum(a) (a>='0'&&a<='9')
#define SP putchar(' ')
#define EL putchar('\n')
#define ri register int

template<class T>
inline void in(T&);
template<class T>
inline void out(const T&);

typedef long long ll;
using std::min;
using std::max;
using std::abs;
using std::sort;
using namespace std;

ll a,b;

int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    in(a);in(b);a%=b;
    out(min(a,b-a));EL;
    return 0;
}

template<class T>
void in(T &Re)
{
    T k=0;
    char ch=getchar();
    int flag=1;
    while (!isNum(ch))
	{
        if (ch=='-')
		{
            flag=-1;
        }
        ch=getchar();
    }
    while (isNum(ch))
	{
        k=(k<<1)+(k<<3)+ch-'0';
        ch=getchar();
    }
    Re=flag*k;
}

template<class T>
void out(const T &Wr)
{
    if (Wr<0)
	{
        putchar('-');
        out(-Wr);
    }
	else
	{
        if (Wr<10)
		{
            putchar(Wr+'0');
        }
		else
		{
            out(Wr/10);
            putchar((Wr%10)+'0');
        }
    }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int N;
  cin>>N;
  vs s(N);
  rep(i,N) cin>>s[i];
  int M;
  cin>>M;
  vs t(M); 
  rep(i,M) cin>>t[i];
  auto point=[&](string x) {
    int counter=0;
    for(auto a : s) {
      if(a==x) counter++;
    }
    for(auto a : t) {
      if(a==x) counter--;
    }
    return counter;
  };
  int answer=0;
  for(auto a : s) {
    answer=max(answer,point(a));
  }
  cout<<answer<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int  r, c, b;
    cin >> r >> c;
    int A[100]={};
    int B[100]={};
    int sum=0;
    for(int i=0;i<r;i++){
        cin >> b; cout << b;
        A[i]+=b;
        B[0]+=b; 
        for(int j=1;j<c;j++){
            cin >> b;
            cout <<" " << b;
            A[i]+=b;
            B[j]+=b; 
    }
    cout << " " << A[i] << endl;
    sum+=A[i];
    }
    cout << B[0];
    for(int j=1;j<c;j++){
        cout << " " << B[j];    
    }
    cout << " " << sum <<  endl;
    return 0;
}


Measured memory_bytes: 3084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
  
namespace ConsoleApplication32
{
    class Program
    {  
      static void Main()
      {
           double a = 0;
           double b =0;
           double e=0;
           string c;
           while((c=Console.ReadLine())!=null)
           {
              double[] s = c.Split(',').Select(double.Parse).ToArray();
              a += s[0]*s[1];
              b +=s[1];
              e++;         
                      }
                 b=b/e;
                 b=Math.Round(b,MidpointRounding.AwayFromZero);
                 Console.WriteLine(a);
                 Console.WriteLine(b);
           }
	   }
   }

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	double pi=3.141592653589793238;
	double A,B,H,M;
	cin>>A>>B>>H>>M;
	double x1=A*sin(((H*60+M)/2)*(pi/180));
	double y1=A*cos(((H*60+M)/2)*(pi/180));
	double x2=B*sin((M*6)*(pi/180));
	double y2=B*cos((M*6)*(pi/180));
	double dis=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
	cout << fixed << setprecision(10) << dis <<endl; 
	return 0;
}

Measured memory_bytes: 4132
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  int A, B, C; cin >> A >> B >> C;

  int ans = 0;
  if(B >= A*C) cout << C << endl;
  else cout << B/A << endl;

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int N=190;
int f[N][N][N],dime[N][N],hix[N][N][N],sum[N][N],opt[N][N][N];
char a[N][N];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m,i,j,k,l,lef,mid,rig,ans=0;
	cin>>n>>m;
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			cin>>a[i][j];
			if(a[i][j]=='.'){
				dime[i][j]=0;
			}
			else{
				dime[i][j]=1;
			}
			sum[i][j]=sum[i-1][j]+dime[i][j];
		}
	}
	for(i=1;i<=n;i++){
		for(j=i;j<=n;j++){
			f[i][j][m+1]=m+1;
		}
	}
	for(i=1;i<=n;i++){
		for(j=i;j<=n;j++){
			for(k=m;k>=1;k--){
				if(sum[j][k]-sum[i-1][k]==0){
					if(sum[j][k+1]-sum[i-1][k+1]==0){
						f[i][j][k]=f[i][j][k+1];
					}
					else{
						f[i][j][k]=k+1;
						//cout<<"cac1"<<endl;
					}
				}
				else{
					if(sum[j][k]-sum[i-1][k]==j-i+1){
						if(sum[j][k+1]-sum[i-1][k+1]==j-i+1){
							f[i][j][k]=f[i][j][k+1];
						}
						else{
							f[i][j][k]=k+1;
							//cout<<"cac2"<<endl;
						}
					}
					else{
						f[i][j][k]=k;
						//cout<<"cac3"<<endl;
					}
//					if(i==1&&j==2&&k==3){
//						cout<<j-i+1<<' '<<sum[j][k]-sum[i-1][k]<<endl;
//					}
				}
				//cout<<i<<' '<<j<<' '<<k<<' '<<f[i][j][k]<<endl;
			}
		}
	}
	//cout<<"cac"<<endl;
	while(f[1][n][1]<=m){
		for(i=1;i<=n;i++){
			for(j=i;j<=n;j++){
				for(k=1;k<=m;k++){
					if(f[i][j][k]>m){
						hix[i][j][k]=m+1;
						continue;
					}
					else{
						hix[i][j][k]=f[i][j][f[i][j][k]];
					}
					if(i<j){
						lef=i;
						rig=j-1;
						while(rig>=lef){
							mid=(lef+rig)/2;
							hix[i][j][k]=max(hix[i][j][k],min(f[i][mid][k],f[mid+1][j][k]));
							if(f[i][mid][k]>f[mid+1][j][k]){
								lef=mid+1;
							}
							else{
								rig=mid-1;
							}
						}
					}
				}
			}
		}
		ans++;
		for(i=1;i<=n;i++){
			for(j=i;j<=n;j++){
				for(k=1;k<=m;k++){
					f[i][j][k]=hix[i][j][k];
				}
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 53632
#include <iostream>
#include <iomanip>
#include <queue>
#include <deque>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

using namespace std;
using ll = long long;

const int kInf = 2e9;
const ll kLInf = 2e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

string S;

int main()
{
   cout << fixed << setprecision(10);
   cin >> S;
   REP(i, SZ(S)) {
      cout << "x";
   }
   cout << endl;
   return 0;
}



Measured memory_bytes: 256
import math;

def swap(a,b):
    return (b,a)

def gcd(a,b):
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def main():
    n = int(input())
    v = [x for x in map(int,input().split())]
    v.sort()
    ans = v[0]
    for i in range(1,n):
        ans = (ans+v[i])/2
    print(ans)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
x, y, a, b, c = map(int, input().split())
red = list(reversed(sorted(list(map(int, input().split())))))
green = list(reversed(sorted(list(map(int, input().split())))))
white = list(reversed(sorted(list(map(int, input().split())))))

result = 0
count = 0
ri = 0
gi = 0
wi = 0

while count < x + y:
	best = -1
	if wi < c:
		best = white[wi]

	if gi < y:
		best = max(best, green[gi])

	if ri < x:
		best = max(best, red[ri])

	if gi < y and best == green[gi]:
		gi += 1
	else:
		if ri < x and best == red[ri]:
			ri += 1
		else:
			wi += 1

	result += best
	count += 1


#print(ri, gi, wi)
print(result)



Measured memory_bytes: 103652
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n, m, x = map(int, readline().split())
    bookcosts = [] 
    data = [] 
    for _ in range(n):
        c, *d = map(int, readline().split())
        bookcosts.append(c)
        data.append([i for i in d])
    INF = int(1e9)
    #bit全探索
    ans = INF
    for i in range(1<<n):
        cost = 0
        score = [0 for _ in range(m)]
        for j in range(n):
            if (i>>j) & 1:
                #j番目のbookをかう
                #j番目のbookを買うとcostは増える
                cost += bookcosts[j]
                #j番目のbookを買うと理解度が上がる
                for k in range(m):
                    score[k] += data[j][k]
        #全ての理解度がx以上か判定する
        f = True
        for j in range(m):
            if score[j] >= x:
                pass
            else:
                f = False
        
        if f:
            ans = min(cost, ans)

    if ans == INF:
        print(-1)
    else:
        print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P, P> PP;
constexpr ll MOD = ll(1e9 + 7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

ll N, D;
vector<ll> X, Y;
vector<P> ls[2];

template <typename Monoid>
struct SegmentTree{
private:
    using F = function<Monoid(Monoid, Monoid)>;
    int N;
    vector<Monoid> node;
    F f;
    Monoid e;  // identity element

public:
    SegmentTree(){}
    SegmentTree(F f, Monoid e):f(f), e(e){}
    void init(int sz){
        N = 1;
        while(N < sz) N <<= 1;
        node.assign(2*N-1, e);
    }
    void build(vector<Monoid>& v){
        int sz = int(v.size());
        init(sz);
        for(int i=0; i<sz; i++){
            node[i+N-1] = v[i];
        }
        for(int i=N-2; i>=0; i--){
            node[i] = f(node[i*2+1], node[i*2+2]);
        }
    }
    void update(int k, Monoid x){
        k += N-1;
        node[k] = x;
        while(k > 0){
            k = (k-1)/2;
            node[k] = f(node[2*k+1], node[2*k+2]);
        }
    }
    // [a,b)
    Monoid query(int a, int b){return query(a, b, 0, 0, N);}
    Monoid query(int a, int b, int k, int l, int r){
        if(b <= l || r <= a) return e;
        if(a <= l && r <= b) return node[k];
        Monoid vl, vr;
        vl = query(a, b, 2*k+1, l, (l+r)/2);
        vr = query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};

void build(int bg, int en, vector<P> &v){
    int m = en-bg, S_MAX = int(pow(3,m));
    vector<P> tmp;
    for(int S=0;S<S_MAX;S++){
        int T = S;
        ll xs = 0, ys = 0;
        for(int i=bg;i<en;i++){
            ll t = (T%3)-1;
            xs += X[i]*t;
            ys += Y[i]*t;
            T /= 3;
        }
        tmp.push_back({xs, ys});
    }
    sort(tmp.begin(), tmp.end());
    tmp.push_back({LLINF,LLINF});
    for(int i=0;i<S_MAX;i++){
        if(tmp[i].first == tmp[i+1].first) continue;
        v.push_back(tmp[i]);
    }
}

auto f = [=](ll a, ll b){return max(a, b);};
SegmentTree<ll> seg(f, -LLINF);

int main() {
    cin >> N >> D;
    X.resize(N);
    Y.resize(N);
    for(int i=0;i<N;i++){
        cin >> X[i] >> Y[i];
    }
    build(0,N/2, ls[0]);
    build(N/2,N, ls[1]);
    vector<ll> tmp;
    for(auto p : ls[1]){
        tmp.push_back(p.second);
    }
    seg.build(tmp);
    ll ans = 0;
    for(auto p : ls[0]){
        int R = upper_bound(ALL(ls[1]), make_pair(D-p.first, LLINF)) - ls[1].begin();
        int L = lower_bound(ALL(ls[1]), make_pair(-D-p.first, -LLINF)) - ls[1].begin();
        if(L==R)continue;
        ans = max(ans, p.second + seg.query(L,R));
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 726052
def X(A,B,C):
  if A == 5 or A == 7:
    if B == 5 or B == 7:
      if C == 5 or C == 7:
          if A + B + C == 17:
              return "YES"
  return "NO"
A,B,C = map(int, input().split())
print(X(A,B,C))


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

class Dice {
public:
  int face[7];

  void roll(int p) {
    int w;
    if (p == 1) {
      w = face[1]; face[1] = face[2]; face[2] = face[6]; face[6] = face[5]; face[5] = w;
    } else if (p == 2) {
      w = face[1]; face[1] = face[4]; face[4] = face[6]; face[6] = face[3]; face[3] = w;
    } else {
      w = face[2]; face[2] = face[3]; face[3] = face[5]; face[5] = face[4]; face[4] = w;
    }
  }

  void find_top(int t) {
    if (face[1] == t) return;
    for (int i = 0; i < 3; i++) {
      roll(1);
      if (face[1] == t) return;
    }
    for (int i = 0; i < 3; i++) {
      roll(2);
      if (face[1] == t) return;
    }
  }

  void find_front(int f) {
    if (face[2] == f) return;
    for (int i = 0; i < 3; i++) {
      roll(3);
      if (face[2] == f) return;  
    }    
  }
};

bool same(Dice d1, Dice d2) {
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < 4; j++) {
      bool check = true;
      for (int k = 1; k <= 6; k++) {
        if (d1.face[k] != d2.face[k]) {
          check = false;
          break;
        }
      }
      if (check) return true;
      d1.roll(3);
    }
    if (i < 3) {
      d1.roll(1);
    }
    else if (i == 3) {
      d1.roll(2);
    }
    else {
      d1.roll(2);
      d1.roll(2);
    }
  }
  return false;
}

int main() {
  Dice d1, d2;
  for (int i = 1; i <= 6; i++) cin >> d1.face[i];
  for (int i = 1; i <= 6; i++) cin >> d2.face[i];

  if (same(d1, d2)) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	string n;
	cin >> n;
	string ans = "No";
	if ((n[0] == n[1] && n[1] == n[2] && n[2] == n[0])||(n[3] == n[1] && n[1] == n[2] && n[2] == n[3])) {
		ans = "Yes";
	}
	cout << ans;
	return 0;
}

//Ctrl+Aを使わない

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

const int INF = 1001001001;

int main() {
  int n, d, ans;
  cin>>n>>d;

  ans = (n + (d * 2))/ (d * 2 + 1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>
#include <climits>

using namespace std;

struct SugarWater
{
    int sugar;
    int water;

    bool operator>(const SugarWater &sw)
    {
        if (sw.water == -1 && sw.sugar == -1)
        {
            return true;
        }
        // sugar/(water+sugar) > sw.sugar/(sw.water+sw.sugar)
        return this->sugar * (sw.water + sw.sugar) > sw.sugar * (this->water + this->sugar);
    }
    bool operator>=(const SugarWater &sw)
    {
        if (sw.water == -1 && sw.sugar == -1)
        {
            return true;
        }
        // sugar/(water+sugar) > sw.sugar/(sw.water+sw.sugar)
        return this->sugar * (sw.water + sw.sugar) >= sw.sugar * (this->water + this->sugar);
    }

    SugarWater(int s, int w) : sugar(s), water(w) {}
    SugarWater() : sugar(-1), water(-1) {}
};

int main()
{
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    A *= 100;
    B *= 100;

    // 取りうる水の量を列挙
    vector<int> waters;
    for (int a = 0; a <= F / A; ++a)
    {
        for (int b = 0; b <= F / B; ++b)
        {
            auto w = a * A + b * B;
            if (0 < w && w <= F)
            {
                waters.push_back(w);
            }
        }
    }

    SugarWater best;
    for (auto w : waters)
    {
        // 100:E = w:max_sugar <-> max_sugar = E*w/100
        int max_sugar = (E * w + 99) / 100;
        for (int c = 0; c * C <= max_sugar; ++c)
        {
            for (int d = 0; d * D <= (max_sugar - c * C); ++d)
            {
                auto s = c * C + d * D;
                if (s + w > F)
                {
                    continue;
                }
                if (s * 100 > E * w)
                {
                    continue;
                }
                SugarWater sw(s, w);
                if (sw > best)
                {
                    best = sw;
                }
            }
        }
    }

    cout << (best.sugar + best.water) << " " << best.sugar << endl;

    return 0;
}

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

char a[22][22];
int n,m;
 
struct pos{
	int x;
	int y;
	int step;
};

pos make_pos(int a,int b,int c){
	pos ret;
	
	ret.x=a;
	ret.y=b;
	ret.step=c;
	
	return ret;
}

int bfs(int sx,int sy,int ex,int ey){
	bool vis[n+2][m+2];
	
	for(int i=0;i<=n+1;++i)
		for(int j=0;j<=m+1;++j)
			if(a[i][j]=='#')
				vis[i][j]=true;
			else
				vis[i][j]=false;
		
	queue<pos> q;
	q.push(make_pos(sx,sy,0));
	vis[sx][sy]=true;
	int move[2][4]={{0,0,-1,1},{-1,1,0,0}};
	
	while(!q.empty()){
		pos fr=q.front();
		q.pop();
		if(fr.x==ex&&fr.y==ey)
			return fr.step;
			
		pos newpo;
		for(int i=0;i<4;++i){
			int nx=fr.x+move[0][i];
			int ny=fr.y+move[1][i];
			if(vis[nx][ny])
				continue;
			vis[nx][ny]=true;
			newpo=make_pos(nx,ny,fr.step+1);
			q.push(newpo);
		}
	}
	return 0;
}

int main(){
	int i,j,i1,i2,j1,j2;
	
	for(i=0;i<22;++i)
		for(j=0;j<22;++j)
			a[i][j]='#';
			
	cin>>n>>m;
	
	for(i=1;i<=n;++i)
		for(j=1;j<=m;++j)
			cin>>a[i][j];
			
	int maxv=0;
	
	for(i1=1;i1<=n;++i1)
		for(j1=1;j1<=m;++j1){
			if(a[i1][j1]=='#')
				continue;
			for(i2=1;i2<=n;++i2)
				for(j2=1;j2<=m;++j2){
					if(a[i2][j2]=='#')
						continue;
					if(i1==i2&&j1==j2)
						continue;
						
					maxv=max(maxv,bfs(i1,j1,i2,j2));	
				}
		}
		
	cout<<maxv<<endl;
	return 0;
}

Measured memory_bytes: 384
def factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
def rle(a): #圧縮された要素を保持
    ll,l=[],1
    for i in range(len(a)-1):
        if a[i]==a[i+1]:
            l+=1
        else:
            ll.append([l,a[i]])
            l=1
    ll.append([l,a[-1]])
    return ll
n,p=map(int,input().split())
if p==1:
    print(1)
    exit()
ans=1
for i,j in rle(factorize(p)):
    if i>=n:
        ans*=j**(i//n)
print(ans)

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;	
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
inline int mul(int x, int y, int mod) {
  if (x >= mod) x %= mod;
  if (y >= mod) y %= mod;
  return (x*y) % mod;
}
signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n , k;
		cin >> n >> k;
		fn{
			cin >> ar[i];
		}
		sort(ar,ar+n);
		if(ar[n-1]==0 && (k&1))return cout << 0 , 0;
		if(ar[n-1]<0 && (k&1)){
			int ans =1;
			for(int i=n-1;k;k--,i--)ans =mul(ans,ar[i],MOD);
				if(ans<0)ans+=MOD;
			return cout<<ans,0;
		}
		int ans =1;
		int i =0 , j = n-1;
		if(k&1)ans=mul(ans,ar[j],MOD),--j,--k;
		k/=2;
		while(k--){
			int lp , rp;
			lp = ar[i] * ar[i+1];
			rp = ar[j] * ar[j-1];
			if(lp>rp){
				ans=mul(ans,lp,MOD);
				i+=2;
			}else{
				ans=mul(ans,rp,MOD);
				j-=2;
			}
		}
		if(ans<0)ans+=MOD;
		cout<<ans;
	
	}
	return 0;
}


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

public class Main {
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner (System.in);
		//ArrayList
		ArrayList<String> array = new ArrayList<String>();
		//????????????????????°?????????
		int card = sc.nextInt();
		//???????????????????????°???????´?
		for(int i = 0; i <= card; i++){
			array.add(sc.nextLine());
		}

		//???S??? ???????????? ???????????????????????¨???
		for(int i = 1; i < 14; i++){
			//???????????????????????¨("????????? " ????????????????????????)????????´????????????????????° -1??????????????? false??¨?????????-1?????????
			//-1(???????????????)????£?????????°??¨???
			if(array.contains("S " + i) ==false){
				System.out.println("S " + i);
			}
		}
		//???H??? ????????? ???????????????????????¨???
		for(int i = 1; i < 14; i++){
			//???????????????????????¨("????????? " ????????????????????????)????????´????????????????????° -1??????????????? false??¨?????????-1?????????
			//-1(???????????????)????£?????????°??¨???
			if(array.contains("H " + i) ==false){
				System.out.println("H " + i);
			}
		}
		//???C??? ??????????????? ???????????????????????¨???
		for(int i = 1; i < 14; i++){
			//???????????????????????¨("????????? " ????????????????????????)????????´????????????????????° -1??????????????? false??¨?????????-1?????????
			//-1(???????????????)????£?????????°??¨???
			if(array.contains("C " + i) ==false){
				System.out.println("C " + i);
			}
		}
		//???D??? ????????? ???????????????????????¨???
		for(int i = 1; i < 14; i++){
			//???????????????????????¨("????????? " ????????????????????????)????????´????????????????????° -1??????????????? false??¨?????????-1?????????
			//-1(???????????????)????£?????????°??¨???
			if(array.contains("D " + i) ==false){
				System.out.println("D " + i);
			}
		}
	}
}

Measured memory_bytes: 26296
# -*- coding: utf-8 -*-

#入力
n, a, b = map(int, input().split())

sum = 0

if n <= a:
    sum = n

elif n <= (a + b):
    sum = a

else:
    p = n // (a + b)
    sum += a * p
    n -= p * (a + b)

    if n <= a:
        sum += n

    elif n <= (a + b):
        sum += a


#出力
print(sum)


Measured memory_bytes: 38384
def main():
    N, M = map(int, input().split())

    st = {1, M}
    d = 2
    while d * d <= M:
        if M % d == 0:
            st.add(d)
            st.add(M // d)
        d += 1

    ans = 1
    for d in st:
        if d >= N:
            e = M // d
            ans = max(ans, e)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))
b=0
for j in range(0,n-1):
  for i in range(0,n-1):
    if a[i]<a[i+1]:
      b=a[i]
      a[i]=a[i+1]
      a[i+1]=b
num=0
for x in range(0,n//2):
  num=num+a[2*x]-a[2*x+1]
if n%2==1:
  num+=a[n-1]
print(num)

Measured memory_bytes: 3064
//
//  BC102A.cpp
//  
//
//  Created by Taime Shoji on 2018/07/21.
//

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

int main(void) {
    int N;
    cin >> N;
    vector <long long int> A(N);
    int sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i]-1;
    }
    
    cout << sum << endl;
    return 0;


}
    
    



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,x,ans=1,sum=0;
	cin>>n>>x;
	rep(i,n){
		int in;
		cin>>in;
		sum+=in;
		if(sum<=x)ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main() {
    int a, b, c, ans;
    scanf("%d%d%d", &a, &b, &c);
    ans = b;
    if (c > a + b + 1)
        ans += a + b + 1;
    else
        ans += c;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARegistration solver = new ARegistration();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARegistration {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            String s1 = s.next(), s2 = s.next();
            w.println(s1.equals(s2.substring(0, s1.length())) ? "Yes" : "No");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public String next() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            StringBuilder res = new StringBuilder();

            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 25548
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m;
string s;

int main() {
    cin >> s;

    int res1 = 0;
    int res2 = 0;
    REP(i, s.size()) {
        if (s[i] - '0' == i % 2) res1++;
        if (s[i] - '0' != i % 2) res2++;
    }

    std::cout << min(res1, res2) << '\n';

    return 0;
}


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

public class Main{

	static int MOD=(int)1e9+7;
	static PrintWriter out=new PrintWriter(System.out);;
	static long [][]memo;
	static int n;
	static int [][]a;
	
	static long dp(int idx,int t) {
		if(idx==n)
			return 0;
		if(memo[t][idx]!=-1)
			return memo[t][idx];
		long ans=0;
		for(int t2=0;t2<3;t2++)
			if(t2!=t)
				ans=Math.max(ans, dp(idx+1,t2)+a[t2][idx]);
		return memo[t][idx]=ans;
		
	}
	
		
		
	
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner();
		
		n=sc.nextInt();
		a=new int [3][n];
		memo=new long [5][n];
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<3;j++)
				a[j][i]=sc.nextInt();
			
		}
		for(long []a:memo)
			Arrays.fill(a, -1);
		out.println(dp(0,3));
		
		out.close();

	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		Scanner(String fileName) throws FileNotFoundException{
			br=new BufferedReader(new FileReader(fileName));
		}
		String next() throws IOException {
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		String nextLine() throws IOException {
			return br.readLine();
		}
		int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		long nextLong()  throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}


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


int main(){
    int N, X, Y; cin >> N >> X >> Y;
    X--, Y--;
    vector<vector<int>> G(N);
    for(int i=0; i<N-1; i++){
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    G[X].push_back(Y);
    G[Y].push_back(X);
    vector<vector<int>> cnt(N, vector<int>(N, 0));
    vector<vector<int>> dist(N, vector<int>(N, -1));
    queue<int> que;
    
    for(int i=0; i<N; i++){
        dist[i][i] = 0;
        que.push(i);
        while (!que.empty()) {
            int v = que.front();
            que.pop();
            for (int nv : G[v]) {
                if (dist[i][nv] != -1) continue;
                dist[i][nv] = dist[i][v] + 1;
                cnt[i][dist[i][nv]]++;
                que.push(nv);
            }
        }
    }
    for(int k=1; k<N; k++){
        ll res=0;
        for(int i=0; i<N; i++){
            res+=cnt[i][k];
        }
        res/=2;
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 31744
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<math.h>
#include<algorithm>
#include <iomanip>
using namespace std;
int main()
{
	int N, K, Ni, num = 0;
	cin >> N >> K;
	int x = N;
	vector<int> vech;
	while (N--)
	{
		cin >> Ni;
		vech.push_back(Ni);
	}
	for (int i=0;i<x;++i)
	{
		if (vech[i] >= K) num++;
	}
	cout << num;
	return 0;
	
}

Measured memory_bytes: 1020