akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  int n,a,b;
  while(input(n,a,b)) {
    cout << min(n*a,b) << endl;
  }
}


Measured memory_bytes: 256
import sys
l,r = map(int,(input().split()))
if r-l>=2018:
    print(0)
    sys.exit()

else:
    if l%2019>r%2019:
        l=l%2019
        r=r%2019+2019
    else:
        l=l%2019
        r=r%2019

    m=2018
    for i in range(l,r):
        for j in range(i+1,r+1):
            a =i*j%2019
            m =min(m,a)

    print(m)


Measured memory_bytes: 3064
//
// Created by Mahmoud Rashad on 11/27/19.
//

#include <bits/stdc++.h>


using namespace std;

typedef pair<int, int> ii;

long long count_P_in_nfact(long long n , long long p) {
    long long res = 0;
    while (n) {
        n /= p;
        res += n;
    }
    return res;
}
long long count_5_in_nfact(long long n , long long p) {
    long long res = 0;
    while (n) {
        n /= p;
        res += n / 2;
    }
    return res;
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.out", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int n;
    cin >> n;
    vector<int> arr(n);
    for (int &x : arr)
        cin >> x;

    int ans = 0;
    int cur = 1;
    for (int &x : arr) {
        if (x == cur) {
            ++ans;
            ++cur;
        }
    }

    if (ans)
        cout << n - ans << '\n';
    else
        cout << -1 << '\n';


    return 0;
}

Measured memory_bytes: 1024
n, *a = $<.read.split.map(&:to_i)

a = a.map.with_index{|t,i| [t,i] }.sort_by{|(t,_)| -t }

dp = Array.new(n+1){ [0] * (n+1) }

a.each_with_index do |(a, k),i|
  (i+1).times do |j|
    dp[i+1][j+1] =                  dp[i][j] + (k      -j) * a
    dp[i+1][j]   = [ dp[i+1][j],    dp[i][j] + (n-i+j-1-k) * a ].max
  end
end

puts dp[-1].max

Measured memory_bytes: 45676
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

ll n, m;
struct cake {
    ll x, y, z;
};
vector<cake> c;
ll dp[1000];

ll calc(vector<cake> v) {
    ll retx = 0, rety = 0, retz = 0;
    rep(i, m) retx += c[i].x, rety += c[i].y, retz += c[i].z;
    return abs(retx) + abs(rety) + abs(retz);
}

void solve() {
    ll ans = 0;
    sort(c.begin(), c.end(), [](cake a, cake b) { return a.x + a.y + a.z > b.x + b.y + b.z; });
    ans = max(calc(c), ans);
    sort(c.begin(), c.end(), [](cake a, cake b) { return a.x + a.y - a.z > b.x + b.y - b.z; });
    ans = max(calc(c), ans);
    sort(c.begin(), c.end(), [](cake a, cake b) { return a.x - a.y + a.z > b.x - b.y + b.z; });
    ans = max(calc(c), ans);
    sort(c.begin(), c.end(), [](cake a, cake b) { return -a.x + a.y + a.z > -b.x + b.y + b.z; });
    ans = max(calc(c), ans);
    sort(c.begin(), c.end(), [](cake a, cake b) { return -a.x - a.y + a.z > -b.x - b.y + b.z; });
    ans = max(calc(c), ans);
    sort(c.begin(), c.end(), [](cake a, cake b) { return -a.x + a.y - a.z > -b.x + b.y - b.z; });
    ans = max(calc(c), ans);
    sort(c.begin(), c.end(), [](cake a, cake b) { return a.x - a.y - a.z > b.x - b.y - b.z; });
    ans = max(calc(c), ans);
    sort(c.begin(), c.end(), [](cake a, cake b) { return -a.x - a.y - a.z > -b.x - b.y - b.z; });
    ans = max(calc(c), ans);
    cout << ans << endl;
}

int main() {
    cin >> n >> m;
    c.resize(n);
    rep(i, n) {
        ll t1, t2, t3;
        cin >> t1 >> t2 >> t3;
        c[i] = {t1, t2, t3};
    }
    solve();
    return 0;
}

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

N, X = map(int, input().split())

a, p = [1], [1]

for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)


def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])


print(f(N, X))


Measured memory_bytes: 3064
def pri(x):
    if x>0:
        print('*'*x)
    else:
        print('-')
while True:
    n = int(input())
    if n ==0:
        break
    a=[]
    b=c=d=e=f=g=h=k=l=m=0
    for i in range(n):
        a.append(int(input()))
    a.sort()
    for j in range(n):
        if a[j]==0:
            b += 1
        if a[j]==1:
            c += 1
        if a[j]==2:
            d += 1
        if a[j]==3:
            e += 1
        if a[j]==4:
            f += 1
        if a[j]==5:
            g += 1
        if a[j]==6:
            h += 1
        if a[j]==7:
            k += 1
        if a[j]==8:
            l += 1
        if a[j]==9:
            m += 1
    pri(b)
    pri(c)
    pri(d)
    pri(e)
    pri(f)
    pri(g)
    pri(h)
    pri(k)
    pri(l)
    pri(m)


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

using namespace std;

int main() 
{
    int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int &x : a)
	    cin >> x;
	vector<bool> dp(k + 1, false);
	for (int i=1; i<=k; i++)
	{
	    for (int x : a)
	    {
	        if (x <= i && dp[i - x] == false)
	            dp[i] = true;
	    }
	}
	cout << (dp.back() ? "First" : "Second");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
signed main()
{
	int n,m,k;
	cin>>n>>m>>k;
	int y=m-1;
	if (k<m)  y=k;
	cout<<((y%m)*n)/m; 
	re 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,A[111],B[111];

ll i, j, k,ans;
int main(){
    scanf("%lld",&N);
    B[0] = 1e9;
    fornum(i,1,N){
        scanf("%lld", &B[i]);
        ans += min(B[i], B[i - 1]);
    }
    ans += B[N - 1];
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;
int min(int a,int b){
    return a<b?a:b;
}
int main(void){
    string S;
    int Q;
    bool right_reading = true;
    deque<char> dq;

    cin >> S >> Q;
    
    for(int i=0;i<S.length();i++){
        dq.push_back(S[i]);
    }
    for(int i=0;i<Q;i++){
        int T,F;
        char C;
        cin >> T;
        if(T == 1){
            right_reading = !right_reading;
        }
        else{
            cin >> F >> C;
            if((right_reading && F == 1)|| (!right_reading && F == 2)){
                dq.push_front(C);
            }
            else {
                dq.push_back(C);
            }
        }
    }
    
    if(right_reading){
        while(!dq.empty()){
            cout << dq.front();
            dq.pop_front();
        }
    }
    else{
        while(!dq.empty()){
            cout << dq.back();
            dq.pop_back();
        }
    }
}


Measured memory_bytes: 3420
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define mp make_pair
#define pb push_back
#define pf push_fron
#define INF 1000000000
typedef long long ll;


pair<int,int> red[110], blue[110];

int main() {
	int n, cnt = 0;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> red[i].first >> red[i].second;
	for (int i = 0; i < n; i++)cin >> blue[i].first >> blue[i].second;
	sort(red, red + n); sort(blue, blue + n);

	for (int i = 0; i < n; i++) {
		int maxk = i, maxy = -INF;
		bool flag = false;
		for (int j = n-1; j >= 0; j--) {
			if (blue[i].first>red[j].first&&blue[i].second > red[j].second) {
				flag = true;
				if (maxy < red[j].second) {
					maxy = red[j].second;
					maxk = j;
				}
			}
		}
		if (flag) {
			cnt++;
			red[maxk].first = INF;
			red[maxk].second = INF;
		}
	}

	cout << cnt << endl;

	
	return 0;
}

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

int solve(int n, int a, int b, int c, int x, vector<int> &y, vector<int> &z) {
  int head = 0;
  rep (t, 10000+1) {
    if (y[head] == z[t]) head++;
    if (head == n) return t;
  }
  return -1;
}

int main() {
  int n, a, b, c, x;
  vector<int> y;
  vector<int> z(10000);

  while(cin >> n >> a >> b >> c >> x, n) {
    y.resize(n); z[0] = x;
    rep (i, n) cin >> y[i];

    for (int i=1; i<=10000; i++) z[i] = (a*z[i-1] + b) % c;
    cout << solve(n, a, b, c, x, y, z) << endl;
  }
  return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define sort(vec) sort(vec.begin(),vec.end())
#define reverse(vec) reverse(vec.begin(),vec.end())
int gcd(int x,int y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int n,m;
int ans=1;
signed main(){
    cin>>n>>m;
    int t=m/n;
    for(int i=t;i>1;i--){
        if(m%i==0){
          ans=i;
          break;
        }
    }
    cout<<ans<<endl;
    return 0;
}   

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

int main()
{
	long long n,a,b;
	cin >> n >> a >> b;
	long long m=a+b;

	long long bluenred = n / m;
	long long blue = bluenred * a;
	long long res = n - bluenred * m;
	if ( a < res ) blue += a;
	else blue += res;

	cout << blue << endl;
}


Measured memory_bytes: 256
pln[14][14];
main(i,j,c,f){
	while(1){
		for(i=3;i<11;i++){
			for(j=3;j<11;j++)	pln[i][j]=getchar()-'0';
			if(getchar()==-1)	exit(0);
		}
		getchar();

		f=1;
		for(i=3;f&&i<11;i++)for(j=3;f&&j<11;j++)
			if(pln[i][j]){
				if     (pln[i+3][j])	c='B';
				else if(pln[i][j+3])	c='C';
				else if(pln[i+2][j-1])	c='D';
				else if(pln[i+1][j+2])	c='E';
				else if(pln[i+2][j+1])	c='F';
				else if(!pln[i+1][j+1])	c='G';
				else	c='A';
				f=0;
			}
		printf("%c\n",c);
	}
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.lang.Exception;
import java.lang.Integer;
import java.lang.String;
import java.lang.System;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] a) throws IOException {
        java.io.BufferedReader r = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));

        try {
            int count = Integer.parseInt(r.readLine());
            String[] ans = new String[count];

            for(int i = 0; i < count; i++) {
                String s = r.readLine();
                StringTokenizer st = new StringTokenizer(s);
                int num[] = new int[4];
                for(int j = 0; j < 3;j++) {
                    num[j] = Integer.parseInt(st.nextToken());
                    if(num[0] < num[j]) {
                        int tmp = num[0];
                        num[0] = num[j];
                        num[j] = tmp;
                    }
                }
                if ( num[0] * num[0] == num[1] * num[1] + num[2] * num[2]) {
                    ans[i] = "YES";
                } else {
                    ans[i] = "NO";
                }
            }

            for(int i = 0; i < count; i++) {
                System.out.println(ans[i]);
            }
        } catch (Exception ex) {
            System.exit(0);
        }
    }
}

Measured memory_bytes: 18468
D,G = [int(i) for i in input().split()]
pc = [[int(i) for i in input().split()]for j in range(D)]
Ans = sum(list(map(list, zip(*pc)))[0])
G1 = G 
for i in range(2**D-1):
    ans = 0
    G1 = G
    i2 = '0'*(D-len(str(bin(i)[2:100])))+str(bin(i)[2:100])
    i_2 = i2.rfind('0')
    for j in range(D):
        if i2[j] == '1':
            G1 -= pc[j][0]*(j+1)*100 + pc[j][1]
            ans += pc[j][0]
    if G1 <= 0:
        Ans = min(Ans,ans)
    elif G1 <= pc[i_2][0]*(i_2+1)*100:
        Ans = min(Ans,ans-(-G1//((i_2+1)*100)))
print(Ans)

Measured memory_bytes: 3064
N,M = map(int,input().split())
H_list = list(map(int,input().split()))

H2_list=[0]*N

for i in range(M):
  A,B = map(int,input().split())
  if H_list[A-1]<H_list[B-1]:
    #print(H_list[A-1],"<",H_list[B-1])
    H2_list[A-1]=-1
  elif H_list[A-1]==H_list[B-1]:
    H2_list[A-1]=-1
    H2_list[B-1]=-1
  else:
    #print(H_list[A-1],">",H_list[B-1])
    H2_list[B-1]=-1


print(N-H2_list.count(-1))
#print(H2_list)

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

using namespace std;

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

  int n, m;
  cin >> n >> m;
  string ans;
  if (n == 1) {
    ans = "0";
  } else if (n == 2) {
    ans = "10";
  } else {
    ans = "100";
  }
  vector<int> need(n, -1);
  for (int i = 0; i < m; ++i) {
    int s, c;
    cin >> s >> c;
    --s;
    if (s == 0 and n > 1 and c == 0) {
      cout << -1;
      return 0;
    }
    if (need[s] == c or need[s] == -1) {
      need[s] = c;
      ans[s] = c + '0';
    } else {
      cout << -1;
      return 0;
    }
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int h,i,j,p,k,l,c;
  while(scanf("%d",&h),h){
    int d[15][7]={0};
    for(i=p=0;i<h;i++){
      for(j=0;j<5;j++)scanf("%d",&d[h-i-1][j]);
    }
    for(l=0;l<20;l++){
      for(i=0;i<h;i++){
	c=1;
	for(j=0;j<5;j++){
	  if(d[i][j]==d[i][j+1])c++;
	  else{
	    if(c>2){
	      p+=c*d[i][j];//printf("%d %d;",c,d[i][j]);
	      for(k=j-c+1;k<=j;k++)d[i][k]=0;
	    }
	    c=1;
	  }
	}
      }//printf("b\n");
      for(j=0;j<5;j++){
	for(i=c=0;i<h;i++){
	  d[i-c][j]=d[i][j];
	  if(d[i][j]==0)c++;//if(d[i][j]==0)printf("%d %d\n",i,j);
	}
	for(i=h-c;i<h;i++)d[i][j]=0;
      }
      /*for(i=0;i<h;i++){
	for(j=0;j<5;j++)printf("%d ",d[i][j]);printf("\n");
      }printf("%d\n",p);//*/
    }
    printf("%d\n",p);
  }
  return 0;
}

Measured memory_bytes: 600
cooking = [int(input()) for _ in [0]*5]

#全ての注文が届く時間を求める
sum_num = sum([(x+9)//10*10 for x in cooking])

#注文が届いてから次の注文が届くまでの誤差の中で最少を求める
min_num = min([x%10 if (x%10) else 10 for x in cooking])

print(sum_num + min_num - 10)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long long LL;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N;
	vector<string> S;
	VLL T;
	cin >> N;
	S.resize(N);
	T.resize(N);
	for (LL n = 0; n < N; n++) {
		cin >> S[n] >> T[n];
	}
	string end;
	cin >> end;
	LL n = 0;
	while (n < N) {
		if (S[n] == end)break;
		n++;
	}
	n++;
	LL ans = 0;
	for (; n < N; n++) {
		ans += T[n];
	}
	cout << ans  << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    string s;
    cin >> s;
    int n = s.size();
    ll ans = 0;
    for(int i = 0; i < 1<<(n-1); i++) {
        ll sum = 0;
        ll x = s[0] - '0';
        rep(j, n-1){
            if (i >> j & 1){
                sum += x;
                x = 0;
            }
            x *= 10;
            x += s[j+1] - '0';
        }
        sum += x;
        ans += sum;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void){
  int N, save, num[9], digit = 0, sum = 0;
  scanf("%d",&N);
  save = N;
  while(0 < N){
    num[digit] = N % 10;
    sum = sum + num[digit];
    N = N / 10;
    digit++;
  }
  if(save % sum == 0) printf("Yes");
  else printf("No");
  return 0;
}

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

int main()
{
    string s,t;
    cin>>s>>t;
    int maxx=0;
    for(int i=0;i<s.length()-t.length()+1;i++)
    {
        int c=0,k=0;
       for(int j=i;k<t.length();j++,k++)
       {
           if(s[j]==t[k])
            c++;
       }
       maxx=max(maxx,c);
    }
    
    cout<<t.length()-maxx;
    
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,m,n) for(int i=m;i<n;i++)

int main(){
	int N,K;
	cin >> N >> K;
	string S;
	cin >> S;
	
	int stand = -1;
	
	int ans=-1;
	if(S[0] == '1'){
		stand = 0;
	}else{
		stand = 1	;
	}
	int R=0,L=0;
	
	while(R < N){
		//右端を進める場合
		//cout << R << ' '<<L << ' '<<stand << ' ' <<ans << endl;; 
		if(stand <=  K){
			if(S[R] =='1' and S[R+1] =='0') ++stand;
			
			ans = max(ans ,R-L+1);
			++R;
			
		}else if(L==R){
			++L;
			++R;
		}
		//左端を薦める場合
		else{
			if(S[L] =='0' and S[L+1] =='1') --stand;
			++L;
		}
		
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 512
def main():
    N = int(input())
    T = tuple(int(input()) for _ in range(N))

    lcm_ = T[0]
    for i in T:
        lcm_ = lcm(i, lcm_)

    print(lcm_)

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

def lcm(a, b):
    c = gcd(a, b)
    return a * b // c

main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int a, b; cin >> a >> b;
  if(a <= b){
    string aa;
    for (int i = 0; i < b; i++){
      char hoge = '0' + a;
      aa += string{hoge};
    }
    say(aa);
  }else{
    string bb;
    for (int i = 0; i < a; i++){
      char hoge = '0' + b;
      bb += string{hoge};
    }
    say(bb);
    // int tmp = 10;
    // int hoge = b;
    // for (int i = 1; i <= a - 1; i++){
    //   b += b*tmp;
    //   tmp *= 10;
    // }
    // say(b)
  }
}

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

vector<long long> All;
vector<long long> P;

long long dfs(int level, long long remain) {

  if (level == 0){
    return 1;
  }

  long long answer = 0;
 
  // 最初のパン
  if (1 <= remain) {
    remain--;
  }

  // X-1 
  if (1 <= remain) {
    if (All[level - 1] <= remain) {
      remain -= All[level - 1];
      answer += P[level - 1];
    } else {
      answer += dfs(level - 1, remain);
      remain = 0;
    }
  }

  // 真ん中のパティ
  if (1 <= remain) {
    remain--;
    answer++;
  }

  // X-1 
  if (1 <= remain) {
    if (All[level - 1] <= remain) {
      remain -= All[level - 1];
      answer += P[level - 1];
    } else {
      answer += dfs(level - 1, remain);
      remain = 0;
    }
  }

  // 最後のパン
  if (1 <= remain) {
    remain--;
  }

  return answer;
}

int main() {

  int N;
  long long X;
  cin >> N >> X;

  All.resize(N);
  P.resize(N);

  All[0] = 1;
  P[0] = 1;

  for (int i = 1; i < N; i++) {
    All[i] = All[i - 1] * 2 + 3;
    P[i] = P[i - 1] * 2 + 1;
  }

  long long answer = dfs(N, X);

  cout << answer << endl;

  return 0;

}

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

using namespace std;

int main(void) {
  int N;
  cin >> N;
  vector<int> a(N);
  for (auto& v : a) {
    cin >> v;
  }
  int ans = 0;
  for (auto v : a) {
    if (ans + 1 == v) ans++;
  }
  if (ans > 0) {
    cout << N - ans << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 4044
a=int(input())
if 400<=a<600:
    print('8')
if 600<=a<800:
    print('7')
if 800<=a<1000:
    print('6')
if 1000<=a<1200:
    print('5')
if 1200<=a<1400:
    print('4')
if 1400<=a<1600:
    print('3')
if 1600<=a<1800:
    print('2')
if 1800<=a<2000:
    print('1')

Measured memory_bytes: 9192
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;

int i,n,a[N];

void solve()
{
    cin>>n;
    int total=0;
    for(i=1;i<=n;++i)
    {
        cin>>a[i];
        total^=a[i];
    }
    for(i=1;i<=n;++i)
    {
        cout<<(total^a[i])<<" ";
    }
}

signed main()
{
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5168
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	int N;
	string S;

	cin >> N >> S;
	set<string> s_set;
	int ans = 0;

	for (int i = 0; i < 1000; ++i)
	{
		string ls = to_string(i);
		if (ls.size() == 1) ls = "00" + ls;
		if (ls.size() == 2) ls = "0" + ls;

		int cnt = 0;
		bool find = false;
		for (int j = 0; j < N; ++j)
		{
			if (S[j] == ls[cnt]) cnt++;
			if (cnt == 3)
			{
				find = true;
				break;
			}
		}

		if (find) ans += 1;
	}

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

Measured memory_bytes: 3756
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [S] = [(input_raw[0])]
    count_x= 0
    for s in S:
        if s == "x":
            count_x += 1
    if count_x >= 8:
        print "NO"
    else:
        print "YES"


if __name__ == '__main__':
    main()


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

ll myPow(ll x, ll n)
{
    ll ans = 1;
    while (n > 0)
    {
        if ((n % 2) == 1)
        {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

template <typename Container>
void UNIQUE(Container &&c)
{
    c.erase(std::unique(c.begin(), c.end()), c.end());
}

void Main()
{
    int x;
    cin >> x;

    vll list;
    REP(i, 1, 1000)
    {
        REP(j, 2, 20)
        {
            int n = myPow(i, j);
            if (n > 1000)
                break;
            list.pb(n);
        }
    }
    sort(ALL(list));
    UNIQUE(list);
    reverse(ALL(list));

    for (auto n : list)
    {
        if (n <= x)
        {
            cout << n << endl;
            return;
        }
    }
}

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


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
      String s1=sc.next(); String s2=sc.next();
      int count=0;
      for(int i=0;i<s1.length();++i)
      {
          if(s1.charAt(i)!=s2.charAt(i))
          {
              ++count;
          }
      }
      System.out.println(count);
    }
    
}

Measured memory_bytes: 41032
N = input()
A = map(int, raw_input().split())
B = map(int, raw_input().split())
x = 0

for a, b in zip(A, B):
    if a >= b:
        x -= a - b
    else:
        x += (b - a) / 2

print 'Yes' if x >= 0 else "No"


Measured memory_bytes: 3964
#include "bits/stdc++.h"
using namespace std;

int main(){
	vector<int> a(4);
	vector<int> b(4);
	while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
		int hit=0;
		int bro=0;
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				if(a[i]==b[j]){
					if(i==j){
						hit++;
					}else{
						bro++;
					}
				}
			}
		}
		cout<<hit<<" "<<bro<<endl;
	}
	return 0;
}

Measured memory_bytes: 3048
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (n, m) = listOfInt()
    val bulbFlags = Array(m){ listOfInt().drop(1).fold(0, {acc, num -> acc or 1.shl(num-1) }) }
    val pp = listOfInt()

    var ans = 0

    for (i in 0 until 1.shl(n)) {
        var failed = false

        for (j in 0 until m) {
            val on = Integer.bitCount(i and bulbFlags[j])
            if (pp[j] == 0 && on % 2 != 0) failed = true
            if (pp[j] == 1 && on % 2 != 1) failed = true
        }

        if (!failed) ans++
    }

    println(ans)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37904
n,m = gets.split.map(&:to_i)
arr = gets.split.map(&:to_i)
cnt = 0
sum = arr.inject(&:+)

arr.each do |v|
  if v >= (sum / (4.0*m))
    cnt += 1
  end
end


if cnt >= m
  puts "Yes"
else
  puts "No"
end


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

int h, w;
char c[305][305];
int ct[305][305];
int dp[305][305];
ll ans = 0;

int main() {
	cin >> h >> w;
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
			cin >> c[j][i];
	for (int i = 0; i < w-1; ++i) {
		memset(ct, 0, sizeof(ct));
		memset(dp, 0, sizeof(dp));
		for (int a = 0; a < h; ++a)
			for (int b = 0; b < h; ++b)
				if (c[i][a] == c[i+1][b])
					ct[h-1-a][h-1-b]++;
		for (int a = h-1; a >= 0; --a)
			for (int b = h-1; b >= 0; --b)
				ct[a][b] += ct[a+1][b+1];
		/* for (int a = 0; a < h; ++a)
			for (int b = 0; b < h; ++b)
				cout << a << ' ' << b << ' ' <<ct[a][b] << endl; */
		for (int a = h-1; a >= 0; --a)
			for (int b = h-1; b >= 0; --b)
				dp[a][b] = ct[a][b] + min(dp[a][b+1], dp[a+1][b]);

		ans += dp[0][0];
		// cout << ans << endl;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1152
local mmi, mma, mab = math.min, math.max, math.abs
local n = io.read("*n", "*l")
local s = io.read()
local sa = {}
for i = 1, n do
  table.insert(sa, {i, s:sub(i, n)})
end
table.sort(sa, function(x, y) return x[2] < y[2] end)
local lcpa = {}
for i = 1, n - 1 do
  local len = mmi(#sa[i][2], #sa[i + 1][2])
  local c = 0
  for j = 1, len do
    if sa[i][2]:sub(j, j) == sa[i + 1][2]:sub(j, j) then
      c = c + 1
    else break end
  end
  lcpa[i] = c
end
local ret = 0
for i = 1, n - 1 do
  local prv = lcpa[i]
  for j = i, n - 1 do
    local nxt = lcpa[j]
    if nxt == 0 then
      break
    else
      prv = mmi(prv, nxt)
      ret = mma(ret, mmi(prv, mab(sa[j + 1][1] - sa[i][1])))
    end
  end
end
print(ret)


Measured memory_bytes: 13056
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

double pi = 3.14159265358979;

int main(){
  double a, b, x;
  cin >> a >> b >> x;
  cout << setprecision(14);
  if(x>=a*a*b/2)cout << atan(2*b/a-2*x/(a*a*a))*180/pi;
  else cout << atan(a*b*b/(2*x))*180/pi;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long

int32_t main(){
	int x;
	cin >> x;
	for (int i = -1e3; i <= 1e3; i++){
		for (int j = -1e3; j <= 1e3; j++){
			if(pow(i, 5) - pow(j, 5) == x){
				cout << i << ' ' << j;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 4028
n,p=map(int,input().split())

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

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

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

    return arr

l=factorization(p)
ans=1
for i in range(len(l)):
    if l[i][1]>=n:
        ans*=l[i][0]**(l[i][1]//n)
print(ans)


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout << x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

double startTime;
double getCurrentTime() {
	return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->


int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll x,y;
	cin>>x>>y;


	// 3 6 12 24
	// 25 50 100

	ll ans = 0;

	while(x<=y)
	{
		x *= 2;
		ans++;
	}

	cout<<ans<<endl;
}


Measured memory_bytes: 3540
n,w = map(int, input().split())
item = [list(map(int,input().split())) for i in range(n)]
dp = [0 for i in range(w+1)]
for i in range(w+1):
	for v in item:
		if i+v[1] <= w:
			dp[i+v[1]] = max(dp[i+v[1]], dp[i]+v[0])
print(dp[w])


Measured memory_bytes: 5928
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll l0 = 2;
    ll l1 = 1;
    ll ans = 1;
    REP(i, n - 1){
        ans = l0 + l1;
        l0 = l1;
        l1 = ans;
    }
    cout << ans << "\n";
    return 0;
}


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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	vector<bool> res(n, true);
	rep (i, n) cin >> h[i];
	rep (i, m) {
	  int a, b;
	  cin >> a >> b;
	  if (h[a - 1] == h[b - 1]) {
		res[a - 1] = res[b - 1] = false;
	  } else if (h[a - 1] > h[b - 1]) {
		res[b - 1] = false;
	  } else {
		res[a - 1] = false;
	  }
	}
	int cnt = 0;
	rep (i, n) cnt += res[i];
	cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
ll N;
ll ans = 0;

void calc(){
    ans += N/10;
    N = N/10;
    while(1){
        ans += N/5;
        N = N/5;
        if(N<5)break;
    }
}


void solve(){
    if(N<2){
        cout << 0 << endl;
        return ;
    }
    else if(N%2==1){
        cout << 0 << endl;
        return ;
    }else{
    while(N%5!=0){
        N-=2;
    }
    calc();
    }
    cout << ans << endl;
}

int main(){
    cin >> N;
    
    //cout << N << endl;
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int sort1(const void *a, const void *b){
  if(*(char *)a > *(char *)b){
    return -1;
  }else if(*(char *)a == *(char *)b){
    return 0;
  }
  return 1;
}

int sort2(const void *a, const void *b){
  if(*(char *)a < *(char *)b){
    return -1;
  }else if(*(char *)a == *(char *)b){
    return 0;
  }
  return 1;
}

int main(void){
  char s[101], t[101];
  int l, f=0, i;
  scanf("%s",s);
  scanf("%s",t);
  qsort((void *)s, strlen(s), sizeof(s[0]), sort2);
  qsort((void *)t, strlen(t), sizeof(t[0]), sort1);
  l = strlen(s);
  if(l>strlen(t)) l=strlen(t);
  for(i=0;i<l;i++){
    if(s[i]>t[i]){f=1; break;}
    else if(s[i]<t[i]){f=2; break;}
  } 
  if((f==0 && strlen(s)<strlen(t)) || f==2) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 128
from collections import deque
 
def solve():
    N, M, K = map(int, input().split())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
 
    a, b = [0], [0]
    for i in range(N):
        a.append(a[i] + A[i])
    for i in range(M):
        b.append(b[i] + B[i])
 
    ans = 0
    j = M
 
    for i in range(len(a)):
        if a[i] > K:
            break
        while b[j] > K - a[i]:
            j -= 1
        ans = max(ans, i+j)
    
    print(ans)
            
solve()

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

using namespace std;

int solve(int N, int K, const string& S)
{
    int ans = 0, L = 0;
    vector<int> xs, bs;

    while (L < N)
    {
        int R = L + 1;

        while (R < N and S[L] == S[R])
            ++R;

        xs.push_back(R - L);
        bs.push_back(S[L] == '0' ? 1 : 0);

        L = R;
    }

    L = 0;
    N = xs.size();

    int sum = xs[0], flips = bs[0], R = L + 1;

    while (L < N)
    {
//cout << "\nL = " << L << ", sum = " << sum << ", flips = " << flips << '\n';

        while (R < N and (flips < K or (flips == K and bs[R] == 0)))
        {
            sum += xs[R];
            flips += bs[R];
//cout << "R = " << R << ", sum = " << sum << ", flips = " << flips << '\n';
            R++;
        }

        ans = max(ans, sum);

        sum -= xs[L];
        flips -= bs[L];
        ++L;
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, K;
    string S;
    cin >> N >> K >> S;

    auto ans = solve(N, K, S);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1372
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();

        if (n < 2 || n % 2 == 1) {
            System.out.println("No");
            return;
        }
        int size = n / 2;
        String sub = s.substring(0, size);
        StringBuilder sb = new StringBuilder();
        sb.append(sub).append(sb);
        if (sb.toString().equals(s)) {
            System.out.println("Yes");            
        } else {
            System.out.println("No");
        }
        
    }

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;

string app() {
  int s,w;
  cin>>s>>w;
  return (w>=s)?"unsafe":"safe";
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r; cin >> r;
    if(r < 1200) cout << "ABC";
    if(1200 <= r && r < 2800) cout << "ARC";
    if(r >= 2800) cout << "AGC";
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
//Robs Code

/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>

/***********MACROS***************/
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>

using namespace std;

const int N = 1e5 + 1;
int n,m,i,j,k,l,x,y,z,cnt[3],sum[3];

/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin >> n >> m;
	int ans = 0;
	for(int i = 0;i < n;i++){
		int x,y;
		cin >> x >> y;
		if((x*x + y*y) <= (m*m)){
			ans++;
		}
	}
	cout << ans;
}
//.........

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

using namespace std;

using ll = long long int;

int main() {
    // Input
    int N;
    vector<ll> A;

    cin >> N;
    A = vector<ll>(N);
    rep(i, N) cin >> A[i];

    // Process
    sort(A.begin(), A.end());

    ll ans = 1;
    const ll limit = (ll)1e18;
    rep(i, N) {
        if (limit / ans >= A[i]) {
            ans *= A[i];
        } else {
            ans = -1;
            break;
        }

        if (ans == 0) break;
    }

    // Output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3968
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        //static int N;
        //static long X;
        //static int[]A;
        static string S, T; 

        public static void Input()
        {
            var cin = new Scanner();
            S = Console.ReadLine();
            T = Console.ReadLine();
        }

        static void Main(string[] args)
        {
            Input();
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            int ans = 0;
            for(var i = 0; i < S.Length; i++)
            {
                if (S[i] == T[i]) { ans++; }
            }
            Console.WriteLine(ans);

            //Console.Out.Flush();
        }

    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

        public int[] MultiLineReader(int N)
        {
            int[] ret = new int[N];
            for(var i = 0; i < N; i++)
            {
                ret[i] = int.Parse(Console.ReadLine());
            }

            return ret;
        }
        public long[] MultiLineReaderL(int N)
        {
            long[] ret = new long[N];
            for (var i = 0; i < N; i++)
            {
                ret[i] = long.Parse(Console.ReadLine());
            }

            return ret;
        }

    }

    public class Graph
    {
        
    }
}

    



Measured memory_bytes: 11092