akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1 << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
int num(vector< int > &A, vector< int > &S, int m) {
	int i = 0, j = N - 1;
	int tmp = 0;
	while (i <= j) {
		while (j >= 0 && A[i] + A[j] < m)
			--j;
		if (j < i)
			break;
		tmp += 1 + (j - i) * 2;
		++i;
	}
	//cout << tmp << " " << M << " " << m << endl;
	return tmp;
}
signed main() {
	cin >> N >> M;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	sort(A.rbegin(), A.rend());
	int ans = 0;
	vector< int > S(N + 1, 0);
	rep(i, N) S[i + 1] = S[i] + A[i];
	int l = 0, r = INF;
	while (r - l > 1) {
		//cout << l << " " << r << endl;
		int m = (l + r) / 2;
		if (num(A, S, m) >= M) {
			l = m;
		} else {
			r = m;
		}
	}
	//cout << l << endl;
	int i = 0, j = N - 1;
	while (i <= j) {
		while (j >= 0 && A[i] + A[j] < r)
			--j;
		if (j < i)
			break;
		ans += (2 + (j - i) * 2) * A[i] + (S[j + 1] - S[i + 1]) * 2;
		++i;
	}
	//cout << r << " " << num(A, S, r) << endl;
	cout << ans + (M - num(A, S, r)) * l << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
string c;
vector<string>s;
int n;
int main()
{
	scanf("%d",&n);
	while(n--)
	{
		cin>>c;
		s.push_back(c);
	}
	sort(s.begin(),s.end());
	s.erase(unique(s.begin(), s.end()), s.end());
	printf("%d",s.size());
}

Measured memory_bytes: 9152
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	int i,j,n,m,s1=0,cut1=0,s2=0,cut2=0,len;
	char a[]={"JOI"};
	char b[]={"IOI"};
	char c[10000];
	while(scanf("%s",c)!=EOF){
	len=strlen(c);
		s1=0;
		s2=0;
		cut1=0;
		cut2=0;
	for(i=0;i<len;i++){
		if(a[s1]==c[i]){
			s1++;
			if(s1==3){
				cut1++;
				s1=0;
			}
		}
		else{
			s1=0;
			if(a[s1]==c[i]){
				s1++;
			}
		}
		if(b[s2]==c[i]){
			s2++;
			if(s2==3){
				cut2++;
				s2=1;
			}
		}
		else{
			s2=0;
			if(b[s2]==c[i]){
				s2++;
			}
		}
	}
	cout<<cut1<<endl<<cut2<<endl;
	}
	return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define MN 2000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,K,Q,a[MN+5],b[MN+5],ans=1e9,q[MN+5],top,c[MN+5];
int main()
{
    n=read();K=read();Q=read();
    for(int i=1;i<=n;++i) a[i]=b[i]=read();
    sort(b+1,b+n+1);
    for(int i=1;i<=n;++i)
    {
        top=0;
        for(int i=1;i<=n;++i) c[i]=a[i];
        for(int j=1,la=0;j<=n+1;++j)
            if(a[j]<b[i]||j>n)
            {
                if(j-1-la>=K) 
                {
                    int num=j-la-K;
                    sort(c+la+1,c+j);
                    for(int k=1,l=la+1;k<=num;++k,++l) q[++top]=c[l];
                }
                la=j;
            }
        if(top<Q) break;
        sort(q+1,q+top+1);
        ans=min(ans,q[Q]-b[i]);
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main()
{
    int N, W,a[100], min, i,temp;
    scanf("%d", &N);
    scanf("%d", &a[0]);

    for (i = 1; i < N; i++)
    {
        scanf("%d", &W);
        a[i] = a[i - 1] + W;
        //printf("%d\n", a[i]);
    }
    min = abs(a[N-1] - a[0] - a[0]);
    for (i = 1; i < 100;i++)
    {
        temp = abs(a[N-1] - a[i] - a[i]);
        if(temp<min) min = temp;
    }
    printf("%d\n", min);
    return 0;
}

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

        #define ll long long
        #define pb push_back
        #define printV(v) for(int i=0;i<(int)v.size();i++){cout << v[i]<< " ";} cout << endl
        #define printRev(v) for(int i=(int)v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
        #define sortV(v) sort(v.begin(),v.end())
        #define revV(v) reverse(v.begin(),v.end())
    

        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q,y;
        string str = "";
        ll mod = 1e9 + 7;
        const int N = 3009;
       
        int find_parent(int u,vector<int> &dsu){
            if(u == dsu[u]) return u;
            return dsu[u] = find_parent(dsu[u],dsu);
        }

        void make_set(int u,int v,vector<int> &dsu,vector<int> &sz){
            u = find_parent(u,dsu);
            v = find_parent(v,dsu);
            if(u != v){
                if(sz[u] < sz[v]) swap(u,v);
                sz[u] += sz[v];
                sz[v] = 0;
                dsu[v] = u;
            }
        }

        void solve(){
            cin >> n >> m;
            vector<int> sz(n+1,1);
            vector<int> dsu(n+1,0);
            vector< vector<int>> graph(n+1);
            for(int i=0;i<=n;i++) dsu[i] = i;
            for(int i=0;i<m;i++){
                int a,b;cin >> a >> b;
                graph[a].pb(b);
                graph[b].pb(a); 
            }
            for(int i=1;i<=n;i++){
                for(int k : graph[i]){
                    make_set(i,k,dsu,sz);
                }
            }
            int answer =  0;
            for(int i=1;i<=n;i++) answer = max(answer,sz[i]);
            //if(answer==1) answer--;
            cout << answer << endl;

            

        }  
        


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

            
          

            int cases = 1;
            //cin >> cases;

            while(cases--) solve();
            return 0;

        }


Measured memory_bytes: 16336
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main(){
    int h,w;cin>>h>>w;
    int gri[505][505]={};
    rep(i,0,h)rep(j,0,w){
        if(i%2==0&&j==0)gri[i][j]=1;
        else if(i%2==0)gri[i][j]=2;
        else if(i%2==1&&j==w-1)gri[i][j]=2;
        else gri[i][j]=1;
    }
    rep(i,0,h){
        rep(j,0,w){
            char h;cin>>h;
            if(h=='#')gri[i][j]=3;
        }
    }
    rep(i,0,h){
        rep(j,0,w){
            if(gri[i][j]==1||gri[i][j]==3)cout<<'#';
            else cout<<'.';
        }cout<<endl;
    }
    cout<<endl;
    rep(i,0,h){
        rep(j,0,w){
            if(gri[i][j]==2||gri[i][j]==3)cout<<'#';
            else cout<<'.';
        }cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 2816
n, x = map(int,input().split())
Ls = list(map(int,input().split()))

sum_l = 0
if sum(Ls) <= x:
    print(n+1)
else:
    for idx in range(n):
        sum_l += Ls[idx]
        if sum_l > x:
            print(idx+1)
            break


Measured memory_bytes: 2940
// Tarun IIITA
   //Тарун Асудани 
   //Не читайте этот код
   
   #include<bits/stdc++.h>
   using namespace std;
   #define ll   long long
   #define pb push_back
   #define pf push_front
   #define MP make_pair
   #define all(v) v.begin(),v.end()
   #define F first
   #define lb lower_bound
   #define ub upper_bound
   #define bs binary_search
   #define S second
   #define P pair<ll,ll>
   #define vect vector<ll>
   #define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
   #define mod  1000000007
   #define int  long long


   void solve(){
      int n;
      cin>>n;
      vector<int> v(n);
      for(int i=0;i<n;i++){
         cin>>v[i];
      }

      int cur = 1000;
      int ans = 0;
      for(int i=1;i<n;i++){
         if(v[i] > v[i-1]){
            int cnt = cur/v[i-1];
            ans = (v[i] - v[i-1])*cnt;
            cur += ans;
         }
      }
      cout<<cur<<"\n";
   }



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


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    int a,b; cin>>a>>b;
    if(a<b){
        for(int i=0;i<b;i++){
            cout<<a;
        }
    }else{
        for(int i=0;i<a;i++){
            cout<<b;
        }
    }
    cout<<endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
int N;
vector<vector<pint> > v;
bool judge(int bit){
  for(int i=0 ; i<N ; i++){
    if(!(bit & (1<<i)))  continue;

    for(pint xy : v[i]){
      int x = xy.first;
      int y = xy.second;

      if(y==1 && !(bit & (1<<x))){
        return false;
      }
      if(y==0 && (bit & (1<<x))){
        return false;
      }
    }
  }
  return true;
}
int main(){
  cin >> N;
  v.resize(N);
  for(int i=0 ; i<N ; i++){
    int A;  cin >> A;
    v[i].resize(A);
    for(int j=0 ; j<A ; j++){
      cin >> v[i][j].first >> v[i][j].second;
      v[i][j].first--;
    }
  }
  int res = 0;
  for(int bit=0 ; bit<(1<<N) ; bit++){
    if(judge(bit)){
      int count = 0;
      for(int i=0 ; i<N ; i++){
        if(bit & (1<<i)) count++;
      }
      res = max(res, count);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAX_N=2e5+10;
const int MAX=1e5+10;
int par[MAX_N],siz[MAX_N],cnt[MAX_N],n,h,w;
ll ans=0;
struct edge{
    int x,y,cost;
    edge(){}
    edge(int x,int y,int cost):x(x),y(y),cost(cost){}
    bool operator<(const edge&b)const{
        return cost>b.cost;
    }
};
void init(){
    for(int i=0;i<MAX_N;i++){
        par[i]=i,siz[i]=1,cnt[i]=0;
    }
}
int find(int x){
    return x==par[x]?par[x]:par[x]=find(par[x]);
}
void unit(int x,int y,int cost){
    x=find(x),y=find(y);
    if(x==y){
        if(cnt[x]+1==siz[x]){
            cnt[x]++;
            ans+=cost;
        }else{
            return;
        }
    }else if(cnt[x]+cnt[y]+1<=siz[x]+siz[y]){
        par[x]=y;
        siz[y]+=siz[x];
        cnt[y]+=cnt[x]+1;
        ans+=cost;
    }
}
int main(){
    init();
    vector<edge> vec;
    cin>>n>>h>>w;
    for(int i=0;i<n;i++){
        int cost,x,y;
        cin>>x>>y>>cost;
        vec.emplace_back(edge(x,y+MAX,cost));
    }
    sort(vec.begin(),vec.end());
    for(auto x:vec){
        unit(x.x,x.y,x.cost);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4340
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <utility>
using namespace std;

using ll = long long;

int main(){
  int n; cin >> n;
  char grid[2*(n+1)][2*(n+1)];
  for(int i=1; i<=n; i++){
    for(int j=1; j<=n; j++) {
      cin >> grid[i][j];
      grid[i+n][j] = grid[i][j+n] = grid[i+n][j+n] = grid[i][j];
    }
  }

  int cnt = 0;
  for(int k=0; k<n; k++){
    bool check = true;

    for(int i=1; i<=n; i++){
      for(int j=1; j<=n; j++){
        if(grid[i+k][j] != grid[j+k][i]){
          check = false;
        }
      }
    }
    if(check) cnt++;
  }

  cout << n*cnt << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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 T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    int grid[h+1][w+1];
    rep(i,h){
        rep(j,w){
            cin >> grid[i][j];
        }
    }
    int ans[250005][4];
    int y = 0,x = 0,a,b,n = 0;
    bool re = 0,flag = 0;
    while(y <= h-1 && x <= w-1){
        if (flag){
            grid[y][x]++;
            ans[n][0] = a;
            ans[n][1] = b;
            ans[n][2] = y+1;
            ans[n][3] = x+1;
            n++;
            flag = 0;
        }
        if (grid[y][x]%2){
            grid[y][x]--;
            a = y+1;
            b = x+1;
            flag = 1;
        }
        if (y%2 == 0 && x == w-1){
            y++;
            re = 1;
        }
        else if (y%2 == 1 && x == 0){
            y++;
            re = 0;
        }
        else if (re) x--;
        else x++;
    }
    PRINT(n);
    rep(i,n){
        cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << " " << ans[i][3] << '\n';
    }
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,s_1="";
    cin>>s;
    s_1+=s[0];
    for(int i=1;i<s.size();i++)
    {
        if(s[i]!=s[i-1])
        s_1+=s[i];
    }
    cout<<s_1.size()-1<<endl;
}

Measured memory_bytes: 512
#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>;

ll gcd(ll a, ll b){
    if(b == 0){ return a;}
    else{ gcd(b, a%b);}
}

int main(){
    ll a, b, ab, abm;
    cin >> a >> b;
    ab = gcd(max(a, b), min(a, b));
    abm = ab;
    ll ans = 1;

    ll N = sqrt(ab) + 100;
    vector<ll> arr(N);
    vector<ll> so(0);
    for(ll i = 0; i < N; i++){
        arr[i] = 1;
    }
    for(ll i = 2; i < sqrt(N); i++){
        if(arr[i]){
            for(ll j = 0; i * (j + 2) < N; j++){
                arr[i *(j + 2)] = 0;
            }
        }
    }
    for(ll i = 2; i < N; i++){
        if(arr[i]){
            so.push_back(i);
        }
    }

    rep(i, so.size()){
        if(ab%so.at(i) == 0) ans++;
        while(ab%so.at(i) == 0){
            ab /= so.at(i);
        }
        if(so.at(i)*so.at(i) > abm){
            if(ab == 1){
                break;
            }else{
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9208
using System;
using System.Diagnostics;
using System.Collections.Generic;

class Myon

{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }
    static Scanner cin;

    void calc()
    {
        long N = cin.nextLong();
        long[] A = new long[5];
        for (int i = 0; i < 5; i++)
        {
            A[i] = cin.nextLong();
        }
        long min = long.MaxValue;
        for (int i = 0; i < 5; i++)
        {
            min = Math.Min(A[i], min);
        }
        long ans = 5 + (N - 1) / min;
        Console.WriteLine(ans);
    }

}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}




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

int main(void) {
    int N,M,X,a,maxnm;
    cin >> N >> M >> X;
    
    maxnm = max(N,M) + 1;
    vector<int> A(maxnm,0);

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

    
    for(int i=1;i<=N;i++) {
        A[i] = A[i-1]+A[i];
    }

    cout << min(A[X-1],A[N]-A[X-1]) << endl;
    return 0;
}


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

int main() {
  // 頂点数と辺数
  int N;
  cin >> N;

  // グラフ入力受取 (ここでは無向グラフを想定)
  Graph G(N);
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    a--;
    G[i].push_back(a);
  }

  // BFS のためのデータ構造
  vector<int> dist(N, -1);  // 全頂点を「未訪問」に初期化
  queue<int> que;

  // 初期条件 (頂点 0 を初期ノードとする)
  dist[0] = 0;
  que.push(0);  // 0 を橙色頂点にする

  // BFS 開始 (キューが空になるまで探索を行う)
  while (!que.empty()) {
    int v =
        que.front();  // キューから先頭頂点を取り出す(front()では削除されない)
    que.pop();  // 先頭を削除

    // v から辿れる頂点をすべて調べる
    for (int nv : G[v]) {
      if (dist[nv] != -1) continue;  // すでに発見済みの頂点は探索しない

      // 新たな白色頂点 nv について距離情報を更新してキューに追加する
      dist[nv] = dist[v] + 1;
      que.push(nv);

    }
  }
  cout << dist[1];
}

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

int main(){
    int Sx,Sy,Tx,Ty;
    cin >> Sx >> Sy >> Tx >> Ty;
    int dx = Tx - Sx;
    int dy = Ty - Sy;
    cout << string(dy,'U') << string(dx,'R');
    cout << string(dy,'D') << string(dx,'L');
    cout << 'L' << string(dy+1,'U') << string(dx+1,'R') << 'D';
    cout << 'R' << string(dy+1,'D') << string(dx+1,'L') << 'U';
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<long long> d(n);
  for(int i = 0; i < n; i++) cin >> d[i];
  set<long long> s;
  for(int i = 0; i < n; i++) {
    long long m = 0;
    for(int j = i; j < n && j - i < 15; j++) {
      m *= 10;
      m += d[j];
      s.insert(m);
    }
  }
  if(s.find(0) == s.end()) {
    cout << 0 << endl;
    return 0;
  }
  s.insert(10000000000000000);
  long long old = -1;
  for(auto it = s.begin(); it != s.end(); it++) {
    if(*it - old > 1) {
      cout << old + 1 << endl;
      return 0;
    }
    old = *it;
  }
  return 0;
}

Measured memory_bytes: 3680
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>
#include<map>
#include<queue>

int main()
{
	int a, b, k;
	scanf("%d%d%d", &a, &b, &k);
	if (a + 2 * k <= b)
	{
		for (int i = a; i < a + k; i++)
			printf("%d\n", i);
		for (int i = b - k + 1; i <= b; i++)
			printf("%d\n", i);
	}
	else
	{
		for (int i = a; i <= b; i++)
			printf("%d\n", i);
	}

	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        k: usize,
        s: usize, 
    }
    let mut ans = 0;

    for x in 0..k+1 {
        for y in 0..k+1 {
            if x + y > s {
                break
            }
            let z = s - x - y;
            if z <= k {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
} 


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
void North(int *a,int *b,int *e,int *f){
  int x;
  x = *a;
  *a = *b;
  *b = *f;
  *f = *e;
  *e = x;
}
 
void East(int *a,int *c,int *d,int *f){
  int x;
  x = *a;
  *a = *d;
  *d = *f;
  *f = *c;
  *c = x;
}
 
void West(int *a,int *c,int *d,int *f){
  int x;
  x = *a;
  *a = *c;
  *c = *f;
  *f = *d;
  *d = x;
}
 
void South(int *a,int *b,int *e,int *f){
  int x;
  x = *a;
  *a = *e;
  *e = *f;
  *f = *b;
  *b = x;
}

int main(void){
  int d[6];
  int i;
  char c[100]={};
  for(i=0;i<6;i++){
    scanf("%d",&d[i]);
  }
  scanf("%s",c);
  i = 0;
  while(c[i]!=0){
    if(c[i]=='N') North(&d[0],&d[1],&d[4],&d[5]);
    else if(c[i]=='E') East(&d[0],&d[2],&d[3],&d[5]);
    else if(c[i]=='W') West(&d[0],&d[2],&d[3],&d[5]);
    else if(c[i]=='S') East(&d[0],&d[1],&d[4],&d[5]);
    i++;
  }
  printf("%d\n",d[0]);
  return 0;
}

Measured memory_bytes: 1812
#include<stdio.h>

#define INF (1<<30)

int adj[100][100],visited[100],c[100],parent[100];







int main(){
	int i,j,n,minCost,minID,ans;	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<n;j++)scanf("%d",&adj[i][j]);
	}

	for(i=1;i<n;i++)c[i]=INF;
	c[0]=0;
	parent[0]=-1;

	while(1){
		minCost=INF;
		for(i=0;i<n;i++){
			if(visited[i]==0 && minCost>c[i]){
				minCost=c[i];
				minID=i;
			}
		}if(minCost==INF)break;

		visited[minID]=1;
		for(i=0;i<n;i++){
			if(visited[i] || adj[minID][i]==-1)continue;

			if(c[i]>adj[minID][i]){
				c[i]=adj[minID][i];
				parent[i]=minID;
			}
		}
	}

	ans=0;
	for(i=1;i<n;i++){
		ans+=adj[parent[i]][i];
	}
	printf("%d\n",ans);

	return 0;
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
#define int long long
#define MAXN 1005
#define MOD 1000000007
#define sz(a) static_cast<long long>(a.size())
#define INF 2000000000000000000
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pp;
int n,t[MAXN],a[MAXN];
main(){
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen("inp.txt","r",stdin); //freopen("out.txt","w",stdout);
	//freopen(".INP","r",stdin); freopen(".OUT","w",stdout);
	cin>>n; int i,j,k,mul;
	cin>>t[1]>>a[1]; a[1]+=t[1];
	for (i=2;i<=n;i++){
		int maxi=1;
		cin>>t[i]>>a[i]; a[i]+=t[i];
		if (a[i]<a[i-1]){
			mul=a[i-1]/a[i]; if (a[i-1]%a[i]!=0) mul++;
			maxi=max(maxi,mul);
		}
		if (t[i]<t[i-1]){
			mul=t[i-1]/t[i]; if (t[i-1]%t[i]!=0) mul++;
			maxi=max(maxi,mul);
		}
		int hieu = (a[i-1]-t[i-1])-(a[i]-t[i]);
		if (hieu>0){
		hieu+=(a[i]-t[i]);
		mul = hieu/(a[i]-t[i]);
		if (hieu%(a[i]-t[i])!=0) mul++;
		maxi=max(maxi,mul);
		}
		a[i]*=maxi; t[i]*=maxi;
		//cout<<t[i]<<' '<<a[i]<<'\n';
	}
	cout<<a[n];
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int n;
  scanf("%d", &n);
  vector<ll> a(n), b(n);
  for (int i = 0; i < n; ++i) { scanf("%lld", &a[i]); }
  for (int i = 0; i < n; ++i) { scanf("%lld", &b[i]); }

  ll ans = 0;
  for (int bit = 0; bit < 30; ++bit) {
    ll T = (1 << bit);
    vector<ll> bb(n);
    for (int i = 0; i < n; ++i) {
      bb[i] = b[i] % (2 * T);
    }
    sort(bb.begin(), bb.end());
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      ll val = a[i] % (2 * T);
      cnt += (int)(upper_bound(bb.begin(), bb.end(), 2 * T - val - 1) -
        lower_bound(bb.begin(), bb.end(), T - val));
      cnt += (int)(upper_bound(bb.begin(), bb.end(), 4 * T - val - 1) -
        lower_bound(bb.begin(), bb.end(), 3 * T - val));
    }
    if (cnt % 2) { ans |= (1 << bit); }
  }

  printf("%lld\n", ans);
  return 0;
}


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

int main(){
    int N, M, C;
    cin >> N >> M >> C;
    
    int B[M];
    
    for(int i = 0; i < M; i++){
        cin >> B[i];
    }
    
    int ans = 0;
    int A[M];

    for(int i = 0; i < N; i++){
        int sum = C;
        for(int j = 0; j < M; j++){
            cin >> A[j];   
            sum += A[j] * B[j];
        }
        if(sum > 0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
#, setrecursionlimit, stdout
#setrecursionlimit(1000000)
#from collections import deque
#from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def si(): return stdin.readline().rstrip()
def lsi(): return list(si())
#mod=1000000007
res=['Yes', 'No']
############# CODE STARTS HERE #############

test_case=1
while test_case:
    test_case-=1

    x, y=mi()
    f=1
    while y>0:
        if x*2==y:
            f=0
            break
        x-=1
        y-=4
    if not x and not y:
        f=0
    print(res[f])

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

public class Main {
	
	static long[] values;
	static long[] weights;
	static long w;
	static long n;
	static long[][]dp;

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		
		n=sc.nextInt();
		w=sc.nextInt();
		weights=new long[(int)n];
		values=new long[(int)n];
		
		dp=new long[(int)n][(int)w+1];
		
		
		
		for(int i=0;i<n;i++) {
			weights[i]=sc.nextInt();
			values[i]=sc.nextInt();
		}
		
		for(long[] x:dp) {
			Arrays.fill(x, -1);
		}
		
		System.out.println(rec(0,w));
	
	
	}
	
	public static long rec(long i,long rem) {
		if(rem<0) {
			return (long) -1e9;
		}
		if(i>=n) {
			return 0;
		}
		if(dp[(int)i][(int)rem]!=-1) {
			return dp[(int)i][(int)rem];
		}
		
		long n=-(Integer.MAX_VALUE);
		long y=-(Integer.MAX_VALUE);
		if(rem-weights[(int)i]>=0) {
			y= values[(int)i]  +   rec(i+1,rem-weights[(int)i]);  //take
		}
		n= rec(i+1,rem);  //leave
		
		return(dp[(int)i][(int)rem]=Math.max(n, y));
		
		
	}
	
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

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

typedef unsigned long long ull;
typedef std::pair<int,int> P;

const int MAX_W = 100001;
int N, X[100000];

class SegmentTree{
public:
    SegmentTree(){}
    SegmentTree(int n){init(n);}
    void init(int n){
        size = 1;
        while(size < n){
            size *= 2;
        }
        REP(i, size*2-1){
            data[i] = 0;
        }
    }
    void update(int index, ull v){
        index += size - 1;
        data[index] = v;
        while(index > 0){
            index = (index-1) / 2;
            data[index] = std::max(data[index*2+1], data[index*2+2]);
        }
    }
    ull query(int a, int b){
        return _query(a, b, 0, 0, size);
    }
private:
    ull _query(int a, int b, int k, int l, int r){
        if(b <= l || r <= a){return 0;}
        if(a <= l && r <= b){return data[k];}
        return std::max(_query(a, b, k*2+1, l, (l+r)/2), _query(a, b, k*2+2, (l+r)/2, r));
    }
    ull data[MAX_W*4];
    int size;
};

SegmentTree st;

int main(){
    std::cin >> N;
    st.init(N+1);

    ull sum = 0;
    REP(i, N){
        std::cin >> X[i];
        sum += X[i];
    }

    REP(i, N){
        //std::cout << st.query(0, X[i]) + X[i] << std::endl;
        st.update(X[i], st.query(0, X[i]) + X[i]);
    }
    
    std::cout << sum-st.query(0, 100001) << std::endl;
}

Measured memory_bytes: 3604
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 




/*****************************************************************************/

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

	int n;
	cin >> n;
	vi h(n);
	f_vI(h, n);
	vi dp(n + 1, ll_INF);
	dp[0] = 0;
	f(i, 0, n-1) {
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
		if (i + 2 < n) {
			dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
		}
	}
	cout << dp[n - 1];
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

const int N = 1e2+7;
#define ll long long

int dp[N];

int main(){
	int n;
	scanf("%d",&n);
	for(int i = 0 ; i*4 <= n; i++){
		int b = n - i * 4;
		if(b % 7 == 0){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using mii = std::map<int, int>;
using mll = std::map<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = 2*(int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
//const int dc[4] = {1, -1, 0,  0};
//const int dr[4] = {0,  0, 1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

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

    string s;
    cin >> s;
    
    int cnt = 0;
    irep(i, n-1) {
        if(s[i] != s[i+1]) { cnt++; }
    }
    cout << n-1-max(cnt-2*k,0) << endl;
    return 0;
}
/*atcoder*/


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

int n,m;
int main(){
    string s[100],t[100];
    cin>>n;
    for (int i = 0; i < n; i++) {
        /* code */
        std::cin >> s[i];
    }
    std::cin >> m;;
    for (int i = 0; i < m; i++) {
        /* code */
        std::cin >> t[i];
    }
    int maxi=0;
    for (int i = 0; i < n; i++) {
        int counter=0;
        for (int j = 0; j < n; j++) {
            /* code */
                if(s[i]==s[j])counter++;
        }
        for (int j = 0; j < m; j++) {
            if(s[i]==t[j])counter--;
            
        }
        maxi=max(maxi,counter);
    }
    std::cout << maxi << std::endl;
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;
#define SORTVL(v) sort(v.begin(), v.end());
#define SORTVL_GR(v) sort(v.begin(), v.end(), greater<LL>());

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a % b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }
// 桁和
LL Ketawa_s(string s) { LL a = 0; FOR(i, 0, s.length())a += s[i] - '0'; return a; }
// 末尾数字で切り上げ
LL CeilLastNumber(LL n) { return ((n + (10 - 1)) / 10) * 10; }
//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p % i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % p) % p; }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL A, B;
	cin >> A >> B;

	O(lcm(A, B));

	return 0;
}

Measured memory_bytes: 256
inputs = readlines

ac = wa = tle = re = 0
inputs.each do |i|
  case i[0]
  when 'A'
    ac += 1
  when 'W'
    wa += 1
  when 'T'
    tle += 1
  when 'R'
    re += 1
  end
end

puts "AC x " + ac.to_s
puts "WA x " + wa.to_s
puts "TLE x " + tle.to_s
puts "RE x " + re.to_s

Measured memory_bytes: 22176
#include <iostream>

using namespace std;

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'S') {
			ans = max(ans, cnt);
			cnt = 0;
		}
		else
			cnt++;
	}
	if (cnt > 0) {
		ans = max(ans, cnt);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3592
h, n = map(int, input().split())
magic = [tuple(map(int, input().split())) for _ in range(n)]
#magic = [list(map(int, input().split())) for _ in range(n)]

dp = [float('inf')] * (h+1)
dp[0] = 0

for i in range(h):
    for d, c in magic:
        next_index = min(i+d, h)
        dp[next_index] = min(dp[next_index], dp[i]+c)
        #print(d, c, dp)

print(dp[-1])

Measured memory_bytes: 43100
#import heapq
#import itertools
#import math
#import numpy as np
#import sys

S = input()
# A,B = list(map(int, input().split()))
# S = [input() for _ in range(H)]
# T = [list(map(int,input().split())) for _ in range(N)]
# sys.exit()
if S == 'SAT' :
    print(1)
elif S == 'MON' :
    print(6)
elif S == 'TUE' :
    print(5)
elif S == 'WED' :
    print(4)
elif S == 'THU' :
    print(3)
elif S == 'FRI' :
    print(2)
elif S == 'SUN' :
    print(7)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'

int n;
VI v(101);

signed main()
{
    cin >> n;
    REP(i, n-1){
        cin >> v[i];
    }
    v.resize(n-1);
    v.push_back(v[n-2]);
    
    // REP(i, n){
    //     DEBUG(v[i]);
    // }
    int res = v[0];
    FOR(i,0, n-1){
        res += min(v[i], v[i+1]);
        // DEBUG(res);
        // cout << "hoge" << endl;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...)
#define dump(x)
#define debug(x)
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

class CCitySavers {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    in >> N;
	    vector<int> A(N+1);
	    REP(i,0,N+1) in >> A[i];
	    vector<int> B(N);
	    REP(i,0,N) in >> B[i];

	    ll answer = 0;
	    REP(i,0,N) {
	        int killed = min(B[i], A[i]);
	        answer += killed;
	        A[i] -= killed;
	        B[i] -= killed;
	        killed = min(B[i], A[i+1]);
	        answer += killed;
	        A[i+1] -= killed;
            B[i] -= killed;
	    }
	    out << answer << "\n";
	}
};


int main() {
	CCitySavers solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1024
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool check(ll mid,ll n,ll a,ll b,vector<ll>h){
  ll num=0;
  ll dis=a-b;
  rep(i,n){
    h[i]-=b*mid;
    if(h[i]>0){
      num+=(h[i]+dis-1)/dis;
    }
  }
  return mid>=num;
}

void solve(){
  ll n,a,b;cin>>n>>a>>b;
  vector<ll>h(n);
  rep(i,n)cin>>h[i];
  ll right=pow(10,10);
  ll left=0;
  while(right-left>1){
    ll mid=left+(right-left)/2;
    if(check(mid,n,a,b,h))right=mid;
    else left=mid;
  }
  cout<<right<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	solve();
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>

using namespace std;

int N, M;
int cost[100][100];
int cpycost[100][100];
int INF = 900000007;

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

	for (int i = 0; i < 100; i++)for (int j = 0; j < 100; j++) {
		if(i != j)
			cost[i][j] = INF, cpycost[i][j] = INF;
		else cost[i][j] = 0, cpycost[i][j] = INF;
	}

	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		cost[a][b] = c, cost[b][a] = c;
		cpycost[a][b] = c, cpycost[b][a] = c;
	}
	
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
			}
		}
	}
	int ans = M;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i > j && cpycost[i][j] != INF && cpycost[i][j] == cost[i][j])ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>

using namespace std;

typedef long long ll;

int a, b, c, d;

int main()
{
	cin >> a >> b >> c >> d;
	ll res = max(max(1ll * a * c, 1ll * a * d), max(1ll * b * c, 1ll * b * d));
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  int n,a;
  cin >> n >> a;
  cout << n*n - a << endl;
}


Measured memory_bytes: 256
n,x,y=map(int,input().split())
G=[[i,i+2] for i in range(n)]
G[0],G[-1]=[2],[n-1]
G[x-1].append(y)
G[y-1].append(x)
#print(G)
ans=[0]*(n-1)
for i in range(n-1):
    for j in range(i+1,n):
        temp1=j-i
        temp2=abs(x-(i+1))+1+abs(y-(j+1))
        dis=min(temp1,temp2)
        ans[dis-1]+=1
print(*ans,sep='\n')

Measured memory_bytes: 3700