akhauriyash/Code-Regression huggingface dataset:
public class
Main
{
  private final static int[ ][ ] d = new int[ ][ ] {
    { },
    { 0,    0,  300,  500,  600,  700, 1350, 1650 },
    { 0,  300,    0,  350,  450,  600, 1150, 1500 },
    { 0,  500,  350,    0,  250,  400, 1000, 1350 },
    { 0,  600,  450,  250,    0,  250,  850, 1300 },
    { 0,  700,  600,  400,  250,    0,  600, 1150 },
    { 0, 1350, 1150, 1000,  850,  600,    0,  500 },
    { 0, 1650, 1500, 1350, 1300, 1150,  500,    0 } };
  private final static boolean[ ][ ] f = new boolean[ ][ ] {
    { },
    { false, false,  true,  true,  true,  true, false, false },
    { false,  true, false,  true,  true,  true,  true, false },
    { false,  true,  true, false,  true,  true,  true, false },
    { false,  true,  true,  true, false,  true,  true,  true },
    { false,  true,  true,  true,  true, false,  true,  true },
    { false, false,  true,  true,  true,  true, false,  true },
    { false, false, false, false,  true,  true,  true, false } };

  public void
  run (
    final java.util.Scanner sc,
    final java.io.PrintStream out
    )
  {
    for ( ; ; )
    {
      int s, t;
      int h, m, t1, t2;

      s = sc.nextInt ( );
      if ( s == 0 ) break ;
      h = sc.nextInt ( ); m = sc.nextInt ( );
      t1 = h * 60 + m;
      t = sc.nextInt ( );
      h = sc.nextInt ( ); m = sc.nextInt ( );
      t2 = h * 60 + m;

      if ( f[ s ][ t ]
        && ( ( t1 >= 17 * 60 + 30 && t1 <= 19 * 60 + 30 )
          || ( t2 >= 17 * 60 + 30 && t2 <= 19 * 60 + 30 ) ) )
      {
        out.println ( d[ s ][ t ] / 2 / 50 * 50 + ( ( d[ s ][ t ] / 2 ) % 50 == 0 ? 0 : 50 ) );
      }
      else
      {
        out.println ( d[ s ][ t ] );
      }
    }
  }

  public static void
  main (
    final String[ ] args
    )
  {
    ( new Main ( ) ).run ( new java.util.Scanner ( System.in ), System.out );
  }
}

Measured memory_bytes: 20524
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,oo=1e18; cin>>N;
  ll ans=1;
  vector<ll> A(N,0);
  for(ll i=0; i<N; i++){
    cin>>A[i];
    if(A[i]==0){
      cout<<0<<endl;
      return 0;
    }
  }
  for(ll i=0; i<N; i++){
    if(log10(ans)+log10(A[i])>18){
      cout<<-1<<endl;
      return 0;
    }
    ans*=A[i];
  }
  if(ans>oo) ans=-1;
  cout<<ans<<endl;
}

Measured memory_bytes: 4116
#include<cstdio>
#include<vector>


using namespace std;

using vi=vector<int>;


int main(void)
{
	int n, m;

	while(scanf("%d%d", &n, &m)==2)
	{
		vi as;
		int ans=0;

		as.assign(m+1, n);
		for(int i=0;i<n;i++)
		{
			int k;
			scanf("%d", &k);
			for(int j=0;j<k;j++)
			{
				int a;
				scanf("%d", &a);
				as[a]--;
				if(!as[a]) ans++;
			}
		}
		printf("%d\n", ans);

	}

	return 0;
}


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


int main(){
    string s;
    cin >> s;
    ll b,e;
    for (int i = 0; i < s.size(); i++){
        if(s[i] == 'A'){
            b = i;
            break;
        }
    }

    for (int i = s.size() - 1; i >= 0; i--){
        if(s[i] == 'Z'){
            e = i;
            break;
        }
    }
    cout << e - b + 1 << endl;
}


Measured memory_bytes: 640
s = input()

sum = 0
process_stack = []
puddle_stack = []

length = len(s)

for i in range(length):
    if s[i] == "\\":
        process_stack.append(i)
    elif s[i] == "/":
        if process_stack:
            edge = process_stack.pop()
            sum += i - edge
            puddle_sum = 0
            while puddle_stack:
                if puddle_stack[len(puddle_stack) - 1][0] < edge:
                    break;
                puddle_sum += puddle_stack.pop()[1]
            puddle_stack.append((edge, puddle_sum + i - edge))

print(sum)

result_string = ""
puddle_num = len(puddle_stack)
result_string += str(puddle_num)
for i in range(len(puddle_stack)):
    result_string += " "
    result_string += str(puddle_stack.pop(0)[1])

print(result_string)


Measured memory_bytes: 6240
#include <iostream>

using namespace std;

bool fl[10];
int a[10];
int n,m,s,c;

int main()
{
    cin >> n >> m;
    for (int i(1);i<=n; i++) {
            fl[i]=false;
            a[i]=0;
    }
    for (int i(1); i<=m; i++)
        {
            cin >> s >> c;
            if (fl[s])
                {
                    if (c!=a[s]) {
                    cout << -1;
                    return 0;
                    }
                }
            else
            {
                fl[s]=true;
                a[s]=c;
            }
        }
    if (n==1) {
        cout << a[1];
        return 0;
    }
    if (a[1]==0 && fl[1]) {
        cout << -1;
        return 0;
    }
    if (a[1]==0) a[1]=1;
    for (int i(1); i<=n; i++) cout << a[i];
}


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

using namespace std;
int main(){
	long long N,A[16] = {},ans = 0;
	bool B = false;
	cin >> N;
	long long MOD = 1;
	if(N < 10){
		cout << N << endl;
		return 0;
	}
	for (int i = 0; i < 15; ++i)
	{
		MOD *= 10;
	}
	vector<long long> v;
	for (int i = 15; i >= 0; --i)
	{
		if(N / MOD != 0){
			long long j = N / MOD;
			if(!B){
				B = true;
				long long k = 1;
				for (int l = 0; l < i; ++l)
				{
					k *= 10;
				}
				if((N+1)%k == 0){
					ans = j + i * 9;
					cout << ans << endl;
					return 0;
				}
			}
			if(j != 9){
				ans += j-1;
				ans += i*9;
				break;
			}else if(j == 9){
				ans += 9;
				N -= j*MOD;
				if(i == 1 && N % 10 != 9){
					ans += 8;
					break;
				}
			}
		}
		MOD /= 10;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#define re register
#define int long long
using namespace std;
typedef long long ll;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

inline ll f(ll x) {
    if (x==0) return 0;
    if (x==1) return 1;
    else return 2*f(x/2)+1;
}

signed main() {
    printf("%lld\n",f(read()));
    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

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

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

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

	ll N;
	string S;

	cin >> N;
	cin >> S;

	vector<ll> As(N);
	for (ll i = 0; i < N; ++i) {
		As[i] = ll(S[i] - '1');
	}

	vector<ll> power_of_2(N);
	for (ll i = 0; i < N; ++i) {
		ll n = 2;
		while (i / n > 0) {
			power_of_2[i] += i / n;
			n *= 2;
		}
	}

	ll accum = 0;
	for (ll i = 0; i < N; ++i) {
		if (power_of_2[N - 1] - power_of_2[N - 1 - i] - power_of_2[i] == 0) {
			accum += As[i];
		}
	}

	if (accum % 2 == 1) {
		cout << 1 << endl;
		return 0;
	}
	for (ll i = 0; i < N; ++i) {
		if (As[i] % 2 == 1) {
			cout << 0 << endl;
			return 0;
		}
		As[i] /= 2;
	}
	
	accum = 0;
	for (ll i = 0; i < N; ++i) {
		if (power_of_2[N - 1] - power_of_2[N - 1 - i] - power_of_2[i] == 0) {
			accum += As[i];
		}
	}
	if (accum % 2 == 0) {
		cout << 0 << endl;
	}
	else {
		cout << 2 << endl;
	}

	return 0;
}


Measured memory_bytes: 17052
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    ll N;cin>>N;
    ll ans=N-1;
    for(ll i=2;i<=1000000;i++){
        if(N%i==0){
            ans=min(ans,i+(N/i)-2);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3604
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
typedef long long ll;
using namespace std;
int main(){
    int a,b,q;
    ll x,l[2],r[2],ans;
    vector<ll> s,t;
    scanf("%d %d %d",&a,&b,&q);
    s.resize(a);
    t.resize(b);
    for(int i=0;i<a;i++){
        scanf("%lld",&s[i]);
    }
    for(int i=0;i<b;i++){
        scanf("%lld",&t[i]);
    }
    for(int i=0;i<q;i++){
        scanf("%lld",&x);
        decltype(s) :: iterator it =lower_bound(s.begin(),s.end(),x);
        decltype(t) :: iterator it2 =lower_bound(t.begin(),t.end(),x);
        if(it==s.end()){
            it--;
            l[0]=r[0]=*it;
            it++;
        }
        else if(it==s.begin()){
            l[0]=r[0]=*it;
        }
        else{
            r[0]=*it;
            it--;
            l[0]=*it;
        }
        if(it2==t.end()){
            it2--;
            l[1]=r[1]=*it2;
            it2++;
        }
        else if(it2==t.begin()){
            l[1]=r[1]=*it2;
        }
        else{
            r[1]=*it2;
            it2--;
            l[1]=*it2;
        }
        ans=llabs(l[0]-l[1])+min(llabs(l[0]-x),llabs(l[1]-x));
        ans=min(ans,llabs(l[0]-r[1])+min(llabs(l[0]-x),llabs(r[1]-x)));
        ans=min(ans,llabs(r[0]-l[1])+min(llabs(r[0]-x),llabs(l[1]-x)));
        ans=min(ans,llabs(r[0]-r[1])+min(llabs(r[0]-x),llabs(r[1]-x)));
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 2816
fun main(args: Array<String>) = ARC061C.main()

object ARC061C {
    val S = readLine()!!

    fun main() {
        val nums = S.toList()

        // +の挿入箇所
        val inserts = if (1 < S.length) (1..nums.lastIndex).toList() else emptyList()

        val expressions = BitChoose<Int>().generate(inserts)
            .map { insertPositions ->
                insertPositions.asReversed().let {
                    val buffer = nums.toMutableList()
                    it.forEach { buffer.add(it, '+') }
                    buffer.joinToString("")
                }
            }

        val sums = expressions.map { it.calc() }
        println(sums.sum())
    }

    private fun String.calc(): Long {
        val nums = this.split('+').map { it.toLong() }
        return nums.sum()
    }


    class BitChoose<T> {
        fun generate(items: List<T>): Sequence<List<T>> {
            when {
                items.isEmpty() -> return sequenceOf(listOf())
                else -> {
                    val first = items.last()
                    val remain = items.dropLast(1)
                    val base = generate(remain)
                    return base + base.map { it + first }
                }
            }
        }
    }
}

Measured memory_bytes: 38640
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main() {
  long long n;
  cin >> n;
  vector<long long> lst;
  map<long long, int> cnt;
  
  for (long long i = 0; i < n; i++) {
    long long tmp;
    cin >> tmp;
    if (cnt.count(tmp) == 0) {
      cnt[tmp] = 1;
    } else {
      cnt[tmp] += 1;
    }
    lst.push_back(tmp);
    //cout << tmp << ' ' << cnt[tmp] << endl;
  }
  
  long long sum = 0;
  for (auto x : cnt) {
    long long c = x.second;
    sum += c * (c-1) / 2;
  }
  
  for (long long i = 0; i < n; i++) {
    long long o = lst[i];
    long long p = cnt[o];
    long long res = sum - (p-1);
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 12144
import Control.Applicative
import Control.Monad
import Data.List

-- |
-- >>> solve 4 4 6
-- 5
-- >>> solve 5 4 3
-- 0
-- >>> solve 1 7 10
-- 0
-- >>> solve 1 3 3
-- 1
solve n a b
    | a >  b    = 0
    | a == b    = 1
    | n == 1    = 0
    | n == 2    = 1
    | otherwise = b2 - a2 + 1
  where
    a2 = sum $ replicate (n - 2) a
    b2 = sum $ replicate (n - 2) b

main :: IO ()
main = do
    [n, a, b] <- fmap read . words <$> getLine :: IO [Int]
    print $ solve n a b

Measured memory_bytes: 508
N=int(input())
B=list(map(int,input().split()))
A=[]
for c in B:
    A.append(c)
A.append(B[-1])

for a in range(len(B)):
   
    if A[a]>B[a]:
        A[a]=B[a]
    elif A[a+1]>B[a]:
        A[a+1]=B[a]

print(sum(A))

Measured memory_bytes: 61732
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main () {
  char n[3];
  cin >> n;
  if (n[0] == '7' || n[1]=='7' || n[2]=='7'){
    cout << "Yes";
  }else{
    cout << "No";
  }
 
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;
/*
ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		else a=a*a%MOD;
		b>>=1;
	}
	return res;
}
*/
set<int> st;
vector<int> a;
int main()
{
	//IOS;
	int n,m;
	cin>>n>>m;
	while(m--){
		int u,v;
		cin>>u>>v;
		if(u==1) st.insert(v);
		if(v==n) a.pb(u);
	}
	for(int t:a){
		if(st.count(t)){
			cout<<"POSSIBLE";
			return 0;
		}
	}
	cout<<"IMPOSSIBLE";
	return 0;
}


Measured memory_bytes: 5368
while True:
    count = 0

    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    for i in range(1, n + 1):
        for j in range(i+1, n + 1):
            k = x - i - j
            if i + j + k == x and j < k <= n:
                count += 1
    print(count)



Measured memory_bytes: 5596
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

const int MAX = 2e3;
const int INF = 2e9;
typedef long long ll;

int n, x, y;
vector<int> adj[MAX + 1];
ll ans[MAX + 1];

vector<int> dijkstra(int u) {

    vector<int> dist(n + 1, INF);
    vector<bool> visited(n + 1, false);

    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> pq;

    dist[u] = 0;
    pq.push({dist[u], u});

    while (!pq.empty()) {
        auto& x = pq.top();
        int here = x.second;
        int cost = x.first;
        pq.pop();

        // if (visited[here]) continue;
        // visited[here] = true;

        if (dist[here] < cost) {
            continue;
        }

        for (auto && there : adj[here]) {
            if (dist[there] > dist[here] + 1) {
                dist[there] = dist[here] + 1;
                pq.push({dist[there], there});
            }
        }
    }

    return dist;
}


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

    cin >> n >> x >> y;

    for (int i = 1; i < n; ++i)
    {
        adj[i].push_back(i + 1);
        adj[i + 1].push_back(i);
    }
    adj[x].push_back(y);
    adj[y].push_back(x);

    vector<ll> ans(n - 1);
    for (int i = 1; i < n; ++i)
    {
        auto&& dist = dijkstra(i);
        for (int j = i + 1; j <= n; ++j)
        {
            ans[dist[j] - 1]++;
        }
    }

    for (auto && x : ans)
        cout << x << "\n";

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include<math.h>
using namespace std;

int main(){
  int N, X;
  cin >> N >> X;
  int a[N];
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  int sum = 0;
  int cnt = 1;
  for(int i = 0; i < N; i++){
    sum += a[i];
    if(sum > X){
      break;
    }
    else{
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
def selectionSort(nums, length):
  count = 0
  for i in xrange(length):
    minj = i
    for j in xrange(i, length):
      # print "i = %d, j = %d, minj = %d, count = %d" % (i, j, minj, count)
      # print nums
      if nums[j] < nums[minj]:
        minj = j
    nums[i], nums[minj] = nums[minj], nums[i]
    count += 1 if i != minj else 0
  return [nums, count]

length = int(raw_input())
nums = map(int, raw_input().split())
ans = selectionSort(nums, length)

print " ".join(map(str, ans[0]))
print ans[1]

Measured memory_bytes: 6440
def collatz(x):
    if x%2==0:
        return x//2
    else:
        return 3*x+1

s=int(input())
a=[s]
n=2

while(1):
    a.append(collatz(a[-1]))
    if a[-1] in a[:-1]:
        break
    n+=1

print(n)

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<sstream>
using namespace std;
int n;
int main()
{
	int m;
	cin>>n>>m;	
	if(n*500>=m)cout<<"Yes";
	else cout<<"No";
}


Measured memory_bytes: 3604
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin>>n;
    
    ll ans = 1ll;
    bool check = false;
    for(;n;n--){
        ll e;
        cin>>e;
        
        string a,b;
        a = to_string(ans);
        b = to_string(e);
        if(a.size()+b.size()>20){
            check = true;
            break;
        }else if(a.size()+b.size() ==20){
            bool bre= false;
            if(a[0]=='1' && b[0]=='1'){
                for(int i =1; i<a.size(); i++){
                    if(a[i]!='0'){
                        bre = true;
                        break;
                    }
                }
                for(int i=1; !bre && i<b.size(); i++){
                    if(b[i]!='0'){
                        bre = true;
                        break;
                    }
                }
                       }else{
                        bre= true;
                    }
           if(bre){
                        check = true;
                        break;
            }
        }
        
        ans *= e;
        if(ans>1000000000000000000ll){
            check = true;
            break;
        }
    }
    if(check){
        n--;
        while(n>0){
            ll e;
            cin >>e;
            if(e==0ll){
                cout<<0<<endl;
                return 0;
            }
            n--;
        }
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3744
#include<stdio.h>
#define N 1000000
#define TRUE 1
#define FALSE 0

int a[N],n,key;

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

int main(){
  int q,i,sum=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(search()==TRUE) sum++;
  }

  printf("%d\n",sum);

  return 0;
}



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

using namespace std;

typedef long long int llint;

int N, X, Y;

int main() {
	cin >> N >> X >> Y;
	vector<int> k(N - 1, 0);
	for (int i = 1; i < N; i++) {
		for (int j = i + 1; j <= N; j++) {
			int d;
			int d1 = j - i;
			int d2 = abs(X - i) + 1 + abs(j - Y);
			//int d3 = abs(Y - i) + 1 + abs(j - X);
			d = min(d1, d2);
			k[d-1]++;
		}
	}
	for (int i = 0; i < N - 1; i++) {
		cout << k[i] << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		int indexOfA = s.indexOf('A');
		int indexOfZ = s.lastIndexOf('Z');
		String subst = s.substring(indexOfA, indexOfZ+1);
		int ans = subst.length();
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 29964
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;



int main()
{
    int a[4];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    int t=a[2]-a[1];
    a[0]+=t;
	a[1]+=t;
    if(a[2]-a[0]==2)
        cout<<t+1<<endl;
    else{
        int t1=a[2]-a[0];
        if(t1==1)
            cout<<t+2<<endl;
        else if(t1%2==1){
            int t2=t1/2;
            cout<<t2+t+2<<endl;

        }else{
                int t3=t1/2;
                cout<<t+t3<<endl;
            }
    }

    return 0;
}


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

int main() {
  int A,B,count=0;
  cin >>A>>B;
  for (int i=A; i<B+1 ; i++){
    if(i/10000 == i % 10 && (i/10)%10 == (i/1000)%10){
      count +=1;
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;

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

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

int main()
{
    string s, t;
    cin >> s >> t;
    long long a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (u.at(0) == s.at(0))
    {
        cout << a - 1 << " " << b << endl;
    }
    else
    {
        cout << a << " " << b - 1 << endl;
    }
}


Measured memory_bytes: 256
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod=1e9+7;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];

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

void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

int main()
{
 
stArt();
fast
//cout << setprecision(15) << fixed;


cin >> n;
fr(i,1,n+1)
{
	cin >> k;
	if(k&1 && i&1)
		m++;
}
cout << m;

eNd();
  return 0;
 
}


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

if 0 in a:
    print(0)
    exit()

ans = a[0]
for a_ in a[1:]:
    if ans * a_ <= 10 ** 18:
        ans *= a_
    else:
        print(-1)
        break
else:
    print(ans)


Measured memory_bytes: 22688
fn main() {
 loop {
  let v: Vec<i32>=r();
  if v[0] == -1 && v[1] == -1 && v[2] == -1 {
   break;
  }
  let r = v[0] + v[1];
  println!("{}", if v[0] == -1 || v[1] == -1 {"F"} else if 80 <= r {"A"} else if 65 <= r { "B" } else if 50 <= r { "C" } else if 30 <= r { if 50 <= v[2] { "C" } else { "D" } } else {"F"});
 }
}
fn r<T:std::str::FromStr>()->Vec<T>{
 let mut b=String::new();
 let s=std::io::stdin();
 s.read_line(&mut b).unwrap();
 b.split_whitespace().flat_map(str::parse).collect()
}



Measured memory_bytes: 5024
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    A, B, C, D, E, F = map(int, input().split())
    water = [0]*F**2
    sugar = [0]*F**2

    sugar_idx = 0
    for i in range(F+1):
        for j in range(F+1):
            y = i*C+j*D
            if y <= F:
                sugar[sugar_idx] = y
                sugar_idx += 1

    water_idx = 0
    for i in range(F+1):
        for j in range(F+1):
            x = i*100*A+j*200*D
            if x <= F:
                water[water_idx] = x
                water_idx += 1

    dens = 0
    ans = (0, 0)

    for i in range(water_idx):
        for j in range(sugar_idx):
            w=water[i]
            s=sugar[j]
            if 0 < w+s <= F:
                if s/(w+s) >= dens and s/(w+s) <= E/(100+E):
                    dens = s/(w+s)
                    ans = (w+s, s)
    print(*ans)


resolve()

Measured memory_bytes: 162972
s = gets.chomp
put = []
for i in 0..s.length-1
  if s[i] == "0"
    put.push(0)
    elsif s[i] == "1"
    put.push(1)
    elsif s[i] == "B" && put != []
      put.pop
  end
end
puts put.join("")

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define tri pair<pll, ll>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000005
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

void __print(ll x) {cerr << x;}
void __print(ld x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll cpow(ll a, ll b, ll M){ll ans = 1;while(b){if(b&1) ans = ans*a%M; b/=2;a=a*a%M;}return ans;}
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}
ll fexp(ll a, ll b) {return cpow(a, b, MOD);}
ll cinv(ll a, ll p){return cpow(a, p-2, p);} 
ll inverse(ll a)    {return cinv(a, MOD);}

int main(){
	// #ifndef ONLINE_JUDGE
 //        freopen("../input.txt", "r", stdin);
 //        freopen("../output.txt", "w", stdout);
 //    #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    ll tc = 0;
    while(tc++ < t){
        ll n, d;
        cin>>n>>d;
        ll x, y;ll cnt = 0;
        rep(i, n){
            cin>>x>>y;
            cnt += (x*x + y*y <= d*d);
        }
        cout<<cnt;
    }
}

Measured memory_bytes: 3652
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define pii pair<int,int>
#define ti3 tuple<ll,ll,ll>

ll a[100001];
ll b[100001];

int main()
{
    ll n;
    cin >> n;
    
    for(int i = 0;i < n;i++)
    {
        cin >> a[i] >> b[i];
    }
    ll count = 0;
    for(ll i = n-1;i >= 0;i--)
    {
        ll mod = (a[i]+count) % b[i];
        if(mod != 0)
        {
            count += b[i] - mod;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
	int t;
	for (int i = 0; i < 4; i++) {
		int x;
		cin >> t >> x;
		switch (t) {
			case 1:
				cout << 6000 * x << endl;
				break;
			case 2:
				cout << 4000 * x << endl;
				break;
			case 3:
				cout << 3000 * x << endl;
				break;
			case 4:
				cout << 2000 * x << endl;
				break;
			default:
				cout << "fuck u (改行してあげません＾＾)";
				return 114514;
		}
	}

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

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

    ll n, k; cin >> n >> k;
    vector<ll> p(n), c(n);
    for (int i = 0; i < n; i++) cin >> p[i], --p[i];
    for (int i = 0; i < n; i++) cin >> c[i];

    ll ans = -LINF;

    for (int i = 0; i < n; i++) {
        int x = i;
        ll sum = 0, len = 0;

        while (true) {
            ++len;
            sum += c[x];
            x = p[x];
            if (x == i) break;
        }

        ll sum2 = 0, cnt = 0;

        while (true) {
            cnt++;
            sum2 += c[x];

            if (cnt > k) break;

            ll num = (k-cnt)/len;
            ll score = sum2 + max(0LL, sum)*num;
            ans = max(ans, score);

            x = p[x];
            if (x == i) break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=1;i<n;i++)
    {
        int e,f,g;
        cin>>e>>f>>g;
        int x,y,z;
        x=a;
        y=b;
        z=c;
        a= e+max(y,z);
        b= f+max(x,z);
        c= g+max(x,y);
    }
    cout<< max(a,max(b,c));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define cnt count
#define in insert
#define er erase
#define ll long long
#define pb push_back
#define fi first
#define se second
#define vi vector<ll>
#define vc vector<char>
#define vpi vector < pair <ll , ll> >
#define si set<ll>
#define sc set<char>
#define msi multiset<ll>
#define msc multiset<char>
#define lb lower_bound
#define ub upper_bound
#define mll map<ll,ll>
#define gcd __gcd
#define mp(i,j) pb(make_pair(i,j))
#define all(v) v.begin(),v.end()
#define forl(i,n) for(ll i = 0;i<n;i++)
#define fore(i,n) for(ll i = 1;i<=n;i++)
#define forn(i,n) for(ll i = n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL);
#define wq ll q ; cin >> q ; while(q--)
#define pattern ll n ; cin >> n ;
#define pattern1 ll n ; cin >> n ; ll ar[n] ; forl(i,n){cin >> ar[i];}
#define pattern2 ll n,k ; cin >> n ; cin >> k ; ll ar[n] ; forl(i,n){cin >> ar[i];}
#define pattern3 ll n ; cin >> n ; char ar[n] ; forl(i,n){cin >> ar[i];}
#define pattern4 ll n,k ; cin >> n ; cin >> k ; char ar[n] ; forl(i,n){cin >> ar[i];}
using namespace std;
ll bpow(ll a,ll b,ll mod){
    a%=mod;
    ll res = 1;
    while(b>0){
        if(b & 1){
            res = res*a%mod;
        }
        a = a*a%mod;
        b >>= 1;
    }
    return res;
}
bool dio(ll a,ll b,ll c){
    ll g = gcd(a,b);
    if(g%c==0 || c%g==0){
        return true;
    }
    else{
        return false;
    }
}
bool pdrome(string s){
    ll n = s.length();
    forl(i,n/2){
        if(s[i]!=s[n-i-1]){
            return false;
        }
    }
    return true;
}
ll onf(ll n){
    for(ll i = 2;i<n;i++){
        if(n%i==0){
            return i;
        }
    }
    return 1;
}
ll bis(ll arr[], ll l, ll r, ll x){
    while (l <= r){
        ll m = l + (r - l) / 2;
        if(arr[m] == x){
            return m;
        }
        if(arr[m] < x){
            l = m + 1;
        }
        else{
            r = m - 1;
        }
    }
    return -1;
}
ll isprime(ll x){
    ll k;
    for(ll i = 2;i<=x;i++){
        if(x%i==0){
            k = i;
            break;
        }
    }
    if(k==x){
        return 1;
    }
    else{
        return 0;
    }
}
ll mindig(ll x){
    ll ans = 9;
    ll t = x;
    while(x){
        ans = min(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
ll maxdig(ll x){
    ll ans = 0;
    ll t = x;
    while(x){
        ans = max(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    fastio;
    string s,t;
    cin >> s >> t;
    ll n = s.length();
    ll n1 = t.length();
    ll tt = 1;
    if(n1!=n+1){
        cout << "No";
    }
    else{
        forl(i,n){
            if(s[i]!=t[i]){
                tt*=0;
            }
        }
        if(tt==1){
            cout << "Yes";
        }
        else{
            cout << "No";
        }
    }

}

Measured memory_bytes: 3656
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  if (x > y) swap(x, y), swap(a, b);
  int ans = x * a + y * b;
  ans = min(ans, x * c * 2 + b * (y - x));
  ans = min(ans, 2 * c * y);
  cout << ans << endl;
  return 0;	
}

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

int main(){
  int N,K;
  cin >>N>>K;
  vector<int> h(N);
  rep(i,N) cin>>h[i];
  sort(h);
  vector<int> dif(N-K+1);
  rep(i,N-K+1) dif[i] = h[i+K-1] - h[i];
  sort(dif);
  cout << dif[0] << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if (s[0] == s[1] && s[2] == s[3]&&s[0]!=s[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
if __name__ == "__main__":
    n, k = [int(i) for i in input().split()]
    a_list = [False] * n
    for i in range(k):
        v = int(input())
        for j in input().split():
            a_list[int(j)-1] = True

    ans = len([i for i in a_list if i == False])
    print(ans)

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

int main()
{
	int n;
	cin >> n;
	vector<string> ss(n);
	for (auto &&s : ss)
	{
		cin >> s;
	}
	int m;
	cin >> m;
	vector<string> ts(m);
	for (auto &&t : ts)
	{
		cin >> t;
	}

	set<string> st;
	for (auto &&s : ss)
	{
		st.insert(s);
	}
	for (auto &&t : ts)
	{
		st.insert(t);
	}

	map<string, int> g, l;
	for (auto &&s : ss)
	{
		g[s]++;
	}
	for (auto &&t : ts)
	{
		l[t]++;
	}

	int ans = 0;

	for (auto &&u : st)
	{
		ans = max(ans, g[u] - l[u]);
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

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

    int n = s.size();
    for (int i = 0; i < n; ++i) {
        if (s.substr(i, 2) == "AC") {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int cmp(const void* a,const void* b){
  return *(int*)a - *(int*)b;
}
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  int c[a];
  for(int i=0; i<a; i++){
    scanf("%d",&c[i]);
  }
  qsort(c,a,sizeof(int),cmp);
  int d=c[a-1]-c[0],e;
  for(int i=0; i<a-b+1; i++){
    e=c[i+b-1]-c[i];
    if(e<d){d=e;}
  }
  printf("%d",d);
  return 0;}

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

using namespace std;

const int MAXN = 1e6+5;
int tab[MAXN];
int main()
{
  int n;
  cin >> n;
  int res = 0;
  for (int i = 0; i*i <= n; i++)
  {
    res = i;
  }
  cout << res*res << "\n";
}


Measured memory_bytes: 256
N,K=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]

freq=[0 for i in range(N+1)]
for i in range(N):
    freq[A[i]]+=1
# print(freq)

sorted_freq=sorted(freq)
# print(sorted_freq)

count=0
for i in range(1,N-K+1):
    count+=sorted_freq[i]
print(count)


Measured memory_bytes: 26004
def dsum(n):
    ret = 0
    while n > 0:
        ret += n % 10
        n //= 10
    return ret

n = int(input())
s = "9" * len(str(n))
ans = 0
for i in range(len(str(n))):
    for x in range(10):
        a = s[:i] + str(x) + s[i+1:]
        if int(a) <= n:
            ans = max(ans, dsum(int(a)))
print(ans)

Measured memory_bytes: 3064
import numpy as np
N, W = map(int, input().split())
WV = np.array([list(map(int, input().split())) for _ in range(N)])
max_V = WV[:, 1].max()

dp = np.full(N * max_V + 1, 10**10, dtype=np.int64)
dp[0] = 0
for w, v in WV:
    np.minimum(dp[v:], dp[:-v] + w, out=dp[v:])

dp[dp > W] = 0
ans = np.nonzero(dp)[0][-1]

print(ans)


Measured memory_bytes: 13948
from itertools import accumulate
from collections import deque

def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))


    ac = list(accumulate([0] + A))
    bc = list(accumulate([0] + B))
    # print(ac, bc)
    a_max = -1
    for i in range(N+1):
        if ac[i] <= K:
            a_max = i
        else:
            break
    
    ans = a_max
    # print(a_max)
    js = 0
    for i in range(a_max+1)[::-1]:
        a = ac[i]
        for j in range(js, M+1):
            # print(a + bc[j], i, j)
            if a + bc[j] <= K:
                js = j
                if i + j > ans:
                    ans = i + j
            else:
                break

    print(ans)

if __name__ == '__main__':
    main()

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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define INF 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;

int main(){
    string s;
    cin >> s;
    string ans;

    rep(i,s.size()){
        if(s[i] == '0' || s[i] == '1')
            ans += s[i];
        else if(!ans.empty()){
            ans.erase(ans.size()-1);
        }
    }
    
    cout << ans;
    //printf("%.15lf",ans);
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
r.sort()
r.reverse()
p.sort()
p.reverse()
q.sort()
q.reverse()
lisp = []
for i in range(x):
    lisp.append(p[i])
lisq = []
for i in range(y):
    lisq.append(q[i])
lis = lisp + lisq
lis.sort()
i = 0
j = 0
# print(lisp)
# print(lisq)
# print(lis)
while j < c and  i < len(lis):
    if lis[i] < r[j]:
        lis[i] = r[j]
        i += 1
        j += 1
    else:
        break
print(sum(lis))

Measured memory_bytes: 23328
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,k = readInts()
A = readInts()
mi = float('inf')
A = sorted(A)

print(sum(A[:k]))


Measured memory_bytes: 10388
#include<bits/stdc++.h>
#define pb push_back

#define f(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define int long long
using namespace std;
#define mod 1000000007
vector<int>adj[200001];
int visited[200001];
int dfs(int s)
{
    visited[s] = 1;
    int count = 1;
    for(int i = 0; i < adj[s].size(); i++)
    {
        if(visited[adj[s][i]] == 0)
        {
            count += dfs(adj[s][i]);
        }
    }
    return count;
}
signed main()
{

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

    int n, m, a, b;
    cin >> n >> m;
    while(m--)
    {
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    vector<int>arr;
    int r, sum1 = 0, ans = 0;
    memset(visited, 0, sizeof(visited));
    for(int i = 1; i <= n; i++)
    {
        if(visited[i] == 0)
        {
            r = dfs(i);
            if(r != 1)
            {
                arr.pb(r);
            }
        }
    }
    if(arr.size() != 0)
    {
        sort(arr.rbegin(), arr.rend());
        cout << arr[0] << endl;
    }
    else
    {
        cout << 1 << endl;
    }
    return 0;
}




Measured memory_bytes: 25456
#include <stdio.h>

int main() {
	int H,W,N,i,j,cnt=0,a[10000],jabara[10000];
	scanf("%d %d %d", &H, &W, &N);
	for (i = 1; i <= N; i++) {
		scanf("%d", &a[i]);
	}
	
	for (j = 1; j <= N; j++) {
		for (i = 0; i < a[j]; i++) {
			jabara[cnt] = j;
			cnt++;
		}
	}

	cnt = 0;

	for (i = 0; i < H; i++) {
		if (i % 2 == 0) {
			for (j = 0; j < W; j++) {
				printf("%d ", jabara[cnt]);
				cnt++;
			}

		}
		else {
			for (j = 0; j < W; j++) {
				printf("%d ", jabara[cnt + W - j - 1]);
			}
			cnt += W;
		}
		printf("\n");

		}
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s,t; cin>>s>>t;
	string ans,judge;
	for(int i=0;i<s.size();++i){
		ans+='z'+1;
	}
	judge=ans;
	for(int i=0;i+t.size()<=s.size();++i){
		bool yes=true;
		for(int j=0,k=i;j<t.size();++j,++k){
			if(t.at(j)!=s.at(k)&&s.at(k)!='?'){
				yes=false;
			}
		}
		if(yes){
			string key=s.substr(0,i)+t;
			if(key.size()<s.size())key+=s.substr(key.size());
			replace(key.begin(),key.end(),'?','a');
			ans=min(ans,key);
		}
	}
	cout<<(ans!=judge?ans:"UNRESTORABLE"s)<<"\n"s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define INFLL 1ull<<60u
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    ll X,K,D;
    cin >> X >> K >> D;
    if (X < 0) X = -X;
    ll left = ll(INFLL)/D;
    ll right = 0;
    while(left - right > 1) {
        ll mid = left + (right - left)/2;
        if((X - (mid * D)) > 0 ) right = mid;
        else left = mid;
    }
    ll ans = INFLL;
    if(right <= K && (((K-right) % 2) == 0)) chmin(ans,X-(right*D));
    else if(left <= K && (((K-left) % 2) == 0)) chmin(ans,abs(X-(left*D)));
    // できるだけ近づく or そもそも結構良い
    else {
        ans = abs(X-(K*D));
    }


    cout << ans<< endl;

}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define md 1000000007
#define inf 1e18
#define rep(i,a,b) for(int i=a;i<b;++i)
using namespace std;
#define M 300010

int r[M],c[M];
vector<int>X[M],Y[M];
int32_t main(){
	
	
	int h,w,m;cin>>h>>w>>m;
	int mxr=0,mxc=0;
	rep(i,0,m){
		int x,y;cin>>x>>y;
		X[x].pb(y),Y[y].pb(x);
		r[x]++,c[y]++;
		mxr=max(mxr,r[x]);
		mxc=max(mxc,c[y]);	
	}
	vector<int>R,C;
	rep(i,0,M){
		if(r[i]==mxr)R.pb(i);
		if(c[i]==mxc)C.pb(i);
	}
	bool ok=0;
	for(auto x:R){
		int cnt=0;
		for(auto y:X[x])if(c[y]==mxc)cnt++;
		if(cnt<C.size())ok=1;
	}
	cout<<mxc+mxr-1+ok;
	
		
    return 0;
}

Measured memory_bytes: 46968
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
int main() {
  int n,W;
  cin>>n>>W;
  vector<long> w(n),v(n);
  rep(i,n){
    cin >> w.at(i)>>v.at(i);
  }
  int inf=1001001001;
  vector<vector<long>>dp(n+1,vector<long>(100100));
  rep(i,n+1){
    rep(j,100100){
      dp[i][j]=inf;
    }
  }
  dp[0][0]=0;
  rep(i,n){
    rep(j,100100){
      if(j<v[i]){
        dp[i+1][j]=dp[i][j];
      }
      else{
        dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
      }
    }
  }
  int ans=0;
  rep(i,n+1){
    rep(j,100100){
      if(W>=dp[i][j]){
        ans=max(ans,j);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 80256