akhauriyash/Code-Regression huggingface dataset:
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
 
use io::read;
fn main(){
    let n: usize = read();
    let a :Vec<i64> = (0..n).map(|_| read()).collect();
    
    let mut ans = 0;
    let mut minus = 0;
    
    for &a in a.iter() {
    	ans += a.abs();
        if a < 0 {
        	minus += 1;
        }
    }
    
    if minus % 2 == 1 {
    	ans -= a.iter().map(|a| a.abs()).min().unwrap() * 2;
    }
    
    println!("{}",ans)
}

Measured memory_bytes: 4352
// Template Headers {{{
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<long long>; using vvll = vector<vll>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}
// Preprocessing & "Global" variables {{{
struct Solver {
	Solver() {}
	int solve();
};
// }}}


int Solver::solve() {
	int n, m; cin >> n >> m;
	cout << 1LL * abs(n - 2) * abs(m - 2) << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	Solver solver;
	#ifdef JUDGE_MULTI_CASE
		int t; cin >> t; for (int i = 1; i <= t; i++)
	#endif
	solver.solve();
	// cout << "Case #" << i << ": ", solver.solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

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

// vim: fdm=marker


Measured memory_bytes: 3652
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

MOD = 10 ** 9 + 7
n,m = map(int,input().split())
A = set(int(input()) for _ in range(m)) #壊れた階段

dp = [0] * (n+1)
dp[0] = 1

for i in range(1,n+1):
    if i in A:
        continue
    x = dp[i-1]
    if i > 1:
        x += dp[i-2]
    dp[i] = x%MOD

print(dp[n])



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

const long long M = 998244353;

int main(){
    string s;
    int k;

    cin >> s >> k;

    vector<int> a, p;
    p.push_back(0);
    s.push_back('0');

    int cur = 0;
    for(int i = 0; i<s.size(); i++){
        if(s[i] == '0'){
            a.push_back(cur);
            p.push_back(p.back() + cur);
            cur = 0;
        }

        else cur++;
    }

    //cout << p.back();

    k = min(k, p[a.size()]);
    long long dp[p.size()][k + 1][p.back() + 1];

    for(int i = 0; i<=a.size(); i++){
        for(int j = 0; j<=p.back(); j++){
            for(int l = 0; l<=k; l++){
                dp[i][l][j] = 0;
                dp[0][0][0] = 1;
            }
        }
    }

    for(int i = 1; i<=a.size(); i++){
        for(int j = 0; j<=p.back(); j++){
            for(int m = 0; m<=k; m++){
                for(int l = max(0, p[i] - j); j + l <= p.back(); l++){
                    //if(j + l > p[a.size()]) continue;
                    //else if(j + l < p[i]) continue;

                    if(l > a[i - 1]){
                        if(k >= m + l - a[i - 1]){
                            dp[i][m + l - a[i - 1]][j + l] += dp[i - 1][m][j];
                            dp[i][m + l - a[i - 1]][j + l] %= M;
                        }
                    }

                    else{
                        dp[i][m][j + l] += dp[i - 1][m][j];
                        dp[i][m][j + l] %= M;
                    }

                }
            }
        }
    }
/*
    for(int i = 0; i<=k; i++){
        for(int j = 0; j<=p.back(); j++){
            cout << dp[3][i][j] << " ";
        }
        cout << endl;
    }

    cout << endl;
    */

    int ans = 0;
    for(int i = 0; i<=k; i++){
        ans += dp[a.size()][i][p[a.size()]];
        ans %= M;
    }
    cout << ans;

}


Measured memory_bytes: 30296
#include <stdio.h>

int
main(int argc, char *argv[])
{
        int a, b;
        
        while(scanf("%d %d", &a, &b), (a != 0) || (b != 0)) {
                if (a < b)
                        printf("%d %d\n", a, b);
                else
                        printf("%d %d\n", b, a);
        }

        return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int f[200010], g[200010];
int n, k, c;
string s;

inline void work() {
    cin >> n >> k >> c;
    cin >> s;
    bool flag = true;
    for (int i = 1; i <= n; ++i) {
        f[i] = f[i - 1];
        g[i] = -1;
        if (s[i - 1] == 'o') {
            f[i] = max(f[i], (i - c - 1 >= 0 ? f[i - c - 1] : 0) + 1);
        }
        if (f[i] == k + 1) {
            flag = false;
            break;
        }
    }
    if (flag) {
        unordered_map<int, vector<int>> v;
        for (int i = 1; i <= n; ++i) {
            if (s[i - 1] == 'o') {
                v[f[i]].push_back(i);
            }
        }
        vector<int> ans;
        int pos = v[k].back();
        if (v[k].size() == 1) {
            ans.push_back(pos);
        }
        for (int i = n - 1; i >= 1; --i) {
            for (int j = v[i].size() - 1; j >= 0; --j) {
                if (v[i][j] + c < pos) {
                    if (j == 0) {
                        ans.push_back(v[i][0]);
                    }
                    pos = v[i][j];
                    break;
                }
            }
        }
        reverse(ans.begin(), ans.end());
        for (int elem: ans) {
            cout << elem << "\n";
        }
    }
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    work();
    return 0;
}

Measured memory_bytes: 22748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" );
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const ll INF = 1e9+9, LINF = 1e18;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout << ( ((b-c)%2) ?"Borys\n":"Alice\n" );
    
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
ans = [1, n]

for _ in range(m):
    l,r = map(int,input().split())
    ans[0] = max(l, ans[0])
    ans[1] = min(r, ans[1])

if ans[1] - ans[0] >= 0:
    print(ans[1] - ans[0] + 1)
else:
    print(0)


Measured memory_bytes: 45160
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	char b;
	cin >> b;

	static const map<char, char> cmap{ {'A','T'},{'T','A'},{'C','G'},{'G','C'} };

	cout << cmap.at(b) << endl;

	return 0;
}



Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
		a: i64, s: String,
    }
  	let ans = if a >= 3200 { s } else { "red".to_string() };
  	println!("{}", ans);
}


Measured memory_bytes: 2144
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

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

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}


int main(){
    int W, a, b;
    cin >> W >> a >> b;

    if (a + W < b) {
        cout << b - (a + W) << endl;
    } else if (b + W < a) {
        cout << a - (b + W) << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


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

using namespace std;

int main(int argc, char const *argv[]) {
  long long int n, ans = 0;
  cin >> n;

  if (n < 10) ans = n;
  else{
    bool tf = true;
    long long int cnt = 0, h;
    while (n>0) {
      cnt++;
      if (n/10 == 0) {
        h = n%10;
      }
      else {
        if (n%10 != 9) tf = false;
      }
      n /= 10;
    }
    if (tf) ans = 9*(cnt-1)+h;
    else ans = (h-1) + (cnt-1)*9;
  }

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


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var s = Console.ReadLine();
            var dict = new Dictionary<char, int>();
            for (var i = 0; i < s.Length; i++)
            {
                if (dict.ContainsKey(s[i]))
                {
                    dict[s[i]]++;
                }
                else
                {
                    dict.Add(s[i], 1);
                }
            }
            Console.WriteLine(dict.Count() == 2 && dict.ElementAt(0).Value == 2 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13268
/**
 *    Author:  "Robin Singh" !!!!    
**/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define str string 
#define szz(v) ((int)(v).size())  
#define vi vector<int>
#define vll vector<ll>
#define fr(i, j, k) for(i = j; i < k; i++)
#define bk(i, j, k) for(i = j; i >= k; i--)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0 //
#define rtn return 
#define RT fprintf(stderr, "\nTIME = %lf\n", 1.0 * clock()/CLOCKS_PER_SEC)
#define nl "\n"
#define INF 1LL<<61
#define inf 1<<30
#define dbg(x) (cerr << #x << ": " << x << "\n")
const long long mod = 1e9+7;

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int ans = 0;
    for(int i=0; i<4; i++){
        char c;
        cin >> c;
        if(c == '+') ans++;
        else ans--;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#define INF 0x3f3f3f3f;

using namespace std;

string s[200005];

bool cmp(string a,string b) {
        return a.compare(b)<0;
}

int main() {
    int n,i;
    scanf("%d",&n);
    for(i=0; i<n; i++)
        cin>>s[i];
    sort(s,s+n,cmp);
    int m=1,cnt=1;
    for(i=1; i<n; i++) {
        if(s[i].compare(s[i-1])==0)
            cnt++;
        else
            cnt=1;
        m=max(cnt,m);
    }
    cnt=1;
    if(m==1)
        cout<<s[0]<<endl;
    for(i=1; i<n; i++) {
        if(s[i].compare(s[i-1])==0)
            cnt++;
        else
            cnt=1;
        if(cnt==m)
            cout<<s[i]<<endl;
    }
}


Measured memory_bytes: 14208
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int a, b; 
    scanf("%d%d", &a, &b);
    if (a < 6) printf("0\n");
    else if (a < 13) printf("%d\n", b/2);
    else printf("%d\n", b);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1000000007;



int main()
{
    int N;
    cin >> N;
    ve<int> A(N);
    rep(i,N) cin >> A[i];
    
    vi B;
    for (int i = 0; i < N; i+=2) {
        B.push_back(A[i]);
    }
    reverse(all(B));
    for (int i = 1; i < N; i+=2) {
        B.push_back(A[i]);
    }
    
    if(N % 2 == 1) {
        outve(B);
    }else{
        reverse(all(B));
        outve(B);
    }



    return 0;
}


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

int main() {
  int n;
  int all[200005];
  cin >> n;
  for(int i = 0;i<n;i++)
    cin>>all[i];
  sort(all,all+n);
  for(int i = 0;i<n-1;i++)
    if(all[i]==all[i+1])
    {
      cout<<"NO"<<endl;
      return 0;
    }
  
  
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
int n, k, a[N];

bool check(int x) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (x < a[i]) cnt += a[i] / x;
        if (cnt > k) return 0;
    }
    return 1;
}

int main()
{
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) scanf("%d", a+i);
    sort(a,a+n);
    int l = 0, r = 1e9+1;
    while (l+1 < r) {
        int mid = (l+r)/2;
        if (check(mid)) r = mid;
        else l = mid;
    }
    printf("%d\n", l+1);
    return 0;
}

Measured memory_bytes: 4496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 998244353;

ll modpow(ll a, ll n)
{
    ll res = 1;
    while (n > 0) {
        if (n % 2) {
            res = res * a % MOD;
        }
        a = a * a % MOD;
        n /= 2;
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> D(N); // iとの距離
    vector<ll> cnt(N); // 距離iにいくつのノードがあるか
    rep(i, N)
    {
        cin >> D[i];
        cnt[D[i]]++;
    }
    ll res = 1;
    // 距離maxdのノードがあれば,そのノードにたどり着くためにそれ以下の距離のノードもある
    bool flag = false;
    for (int maxd = N - 1; maxd >= 1; --maxd) {
        if (cnt[maxd] != 0) {
            flag = true;
        }
        if (flag && cnt[maxd] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    if (cnt[0] != 1 || D[0] != 0) { // 最初のノードだけが距離0
        cout << 0 << endl;
        return 0;
    }
    for (int i = 1; i < N; i++) {
        res *= modpow(cnt[i - 1], cnt[i]);
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
 
ans=0
for i in range(n):
    ans+=b[a[i]-1]
for j in range(n-1):
    if(a[j+1]-a[j]==1):
        ans+=c[a[j]-1]
print(ans)

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

int main(){
  int A,B;
  cin >> A >> B;
  int add = A+B;
  int sub = A-B;
  int mul = A*B;
  
  if(add>=sub && add>=mul){
    cout << add << endl;
  }else if(sub>=add && sub>=mul){
    cout << sub << endl;
    }else{
    cout << mul << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int INF = 1001001001;

int main() {
  string s,t,u;
  int sn,tn;
  cin >> s >> t;
  cin >> sn >> tn;
  cin >> u;
  if (u == s) {
    sn--;
  }else if (u == t) {
    tn--;
  }

  cout << sn << ' ' << tn << endl;

}


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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            //cout<<x<<"/"<<y;
            cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////



int main(){fastio
    ll n,m,k;cin>>n>>m>>k;
    ll a[n+1],b[m+1];
    rep(i,1,n)cin>>a[i];
    rep(i,1,m)cin>>b[i];
    a[0]=0;
    rep(i,1,n)a[i]+=a[i-1];
    b[0]=0;
    rep(i,1,m)b[i]+=b[i-1];
    ll ans=0;
    ll r=m;
    rep(i,0,n){
        if(a[i]>k)continue;
        while(r>=0&&a[i]+b[r]>k){
            r--;
        }
        chmax(ans,i+r);
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 6772
#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 <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 <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  if(n < 1000) cout << "ABC" << endl;
  else cout << "ABD" << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,c=0,s=0,ans;
    cin>> n;
    while(n>0){
        n=n/2;
        c++;
        ans=pow(2,c-1);
        s=s+ans;
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  if(n <= 3) {
    cout << "No" << endl;
    return 0;
  }
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {  
      if(n == i*4+j*7) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3636
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
A.insert(0, 0) #モンスター
B.insert(0, 0) #勇者の能力
C=[0]*(N+1)     #次の街に回せる能力
D=[0]*(N+1) #必要な担当勇者(iが等しい)が倒す数
E=[0]*(N+2) #その街で実際に倒す数
F=[0]*(N+2) #合計能力
 
for i in range(1,N+1):
  if i==1:
    F[i]=B[i]
  else:
    F[i]=B[i]+C[i-1] #余った能力をもらったうえで使える能力を計算
    
  if F[i]>=A[i]: #所有能力が勝ってたら
    E[i]=A[i]
    C[i]=min(F[i]-A[i],B[i])
  else:
    E[i]=F[i]
    C[i]=0
 
  #print(i,A[i],B[i],C[i],D[i],E[i],F[i])
 
if C[N]>=A[N+1]: #剰余能力がモンスターより多かったら
  E[N+1]=A[N+1]
else:
  E[N+1]=C[N]
 
ans=sum(E)
#print(E)
print(ans)

Measured memory_bytes: 20616
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int mod = 1e9 + 7 ;
#define int long long int

int32_t main() {
    IOS ;
    // int t ; cin >> t ; while(t--) {}
    int n ; cin >> n ; int arr[n+1], dp[n+1] ;
    dp[0] = 0 ;
    for(int i=1; i<=n ; i++) {
        cin >> arr[i] ; 
        dp[i] = (dp[i-1] + arr[i]) % mod ;
    }
    
    int res = 0 ;
    for(int i=2; i<=n; i++) {
        int  x = (arr[i] * dp[i-1]) % mod ; 
        res = (res + x) % mod ;
    }
    
    cout << res ;
    
    return 0 ;
}


Measured memory_bytes: 6756
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
using namespace std; const int N=1000010;
inline int read()
{
	int s=0, w=1; ri char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar(); return s*w;
}
void print(int x) {if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
int n,x,y,book[N];
signed main()
{
	n=read(), x=read(), y=read();
	for(ri int i=1;i<=n;i++)
	for(ri int j=i+1;j<=n;j++)
	book[min(abs(i-j),min(abs(x-i)+abs(y-j)+1,abs(y-i)+abs(x-j)+1))]++;
	for(ri int i=1;i<n;i++) printf("%lld\n",book[i]);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

Alice = []
Bob = []
a.sort()
a.reverse()

for x in range(N):
    if x % 2 == 0:
        Alice.append(a[x])
    else:
        Bob.append(a[x])

print(sum(Alice) - sum(Bob))

Measured memory_bytes: 3060
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

int calc(int a) {
    return (a + a + 1 + a + 2 + a + 7 + a + 8 + a + 9 + a + 14 + a + 15 + a + 16) % 11;
}

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1];
    long ans = 0;

    if (N < 3) {
        writeln(-1);
        return;
    }

    if (N < 50) {
        for (int i = 0, a = 1; i < N - 2; ++i, a = (a + 7) % 11) 
            for (int j = a; j < a + 5; ++j) 
                ans += calc(j) == K;
        ans.writeln;
        return;
    }

    for (int i = 0, a = 1; i < 11; ++i, a = (a + 7) % 11) 
        for (int j = a; j < a + 5; ++j) 
            ans += calc(j) == K;
    
    ans *= (N - 2) / 11L;

    for (int i = 0, a = 1; i < (N - 2) % 11; ++i, a = (a + 7) % 11) 
        for (int j = a; j < a + 5; ++j) 
            ans += calc(j) == K;

    ans.writeln;
}


Measured memory_bytes: 256
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instr = lambda: sys.stdin.readline()
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
X = inintl()

p = 0
min_d = 10**10
ans = 0

for i in range(1,max(X)+1):
    t_d = 0
    for x in X:
        t_d += (x-i)**2
    if t_d < min_d:
        min_d = t_d
        p = i

for x in X:
    ans += (x-p)**2

print(ans)


Measured memory_bytes: 64068
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int maxNum = scan.nextInt();
		int sum = scan.nextInt();
		int ans = 0;
		
		for(int x = 0; x <= maxNum; ++x){
			for(int y = 0; y <= maxNum; ++y){
				int z = sum - x - y;
				if(0 <= z && z <= maxNum){
					ans = ans + 1;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 10005
 
#define PI 3.14159265358979323846264338327950
 
#define F first
#define S second
 
#define ll 	 long long int
 
#define mod  1000000007



int main()
{
	FAST;
	ll n;
	cin >> n;
 
    ll b = -2;
    ll f = 2;
 
    string ans = "";
    if (n == 0) {
        ans = "0";
    }
    while (n) {
        int d = (n % b + f)     % f;
        ans += (d + 48);
        n -= d;
        n /= b;
 
    }
 
    reverse(ans.begin(), ans.end());
 
    cout << ans ;
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#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()





int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> ctr_r(n), ctr_w(n);
    if (s[0] == 'W') {
        ctr_w[0] = 1;
    } else {
        ctr_w[0] = 0;
    }
    rep (i, 1, n) {
        if (s[i] == 'W') {
            ctr_w[i] = ctr_w[i-1] + 1;
        } else {
            ctr_w[i] = ctr_w[i-1];
        }
    }
    if (s[n-1] == 'R') {
        ctr_r[n-1] = 1;
    } else {
        ctr_r[n-1] = 0;
    }
    rep (i, 1, n) {
        if (s[n-1-i] == 'R') {
            ctr_r[n-1-i] = ctr_r[n-i] + 1;
        } else {
            ctr_r[n-1-i] = ctr_r[n-i];
        }
    }
    int ans = 0;
    rep (i, n) {
        if(ctr_w[i] > 0 && ctr_r[i] > 0) {
            chmax(ans, min(ctr_w[i], ctr_r[i]));
        }
    }
    if (ans == 1e9+7) {
        cout << 0 << endl;
    } else {
        cout << ans << endl;
    }
}



Measured memory_bytes: 5240
sx, sy, tx, ty = map(int, input().split())

W = abs(sx-tx)
H = abs(sy-ty)
ans = ""

for i in range(W):
    ans += "R"
for i in range(H+1):
    ans += "U"
for i in range(W+1):
    ans += "L"
for i in range(H+1):
    ans += "D"
ans += "R"

for i in range(H):
    ans += "U"
for i in range(W+1):
    ans += "R"
for i in range(H+1):
    ans += "D"
for i in range(W+1):
    ans += "L"
ans += "U"

print(ans)


Measured memory_bytes: 9168
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && b == c) {
        cout << "No" << endl;
    }
    else if(a == b || a == c || c == b) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);

	while(a > 0 || c > 0) {
		c -= b;
		if(c <= 0) break;
		a -= d;
	}

	if(a > 0) {
		printf("Yes");
	} else {
		printf("No");
	}


	return 0;
}

Measured memory_bytes: 1708
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let m: f32 = read();
    let a: Vec<usize> = (0..n).map(|_| read()).collect();
    let sum: usize = a.iter().sum();
    let mut ans: f32 = 0.0;
    for ai in a {
        if ai as f32 >= (sum as f32)/(4.0*m) {
            ans += 1.0;
        }
    }
    println!("{}", if ans >= m {"Yes"} else {"No"} );
}


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


long long a,b,c,d;
long long f(long long x){
  return x-x/c-x/d+x/((c*d)/__gcd(c,d));
}
int main(){
  
  cin>>a>>b>>c>>d;
  long long ans=f(b)-f(a-1);
  cout<<ans<<endl;
} 

Measured memory_bytes: 256
// atcoder/abc146/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  vector<string> v({"MON","TUE","WED","THU","FRI","SAT", "SUN"});

  string s;
  while (cin >> s) {
    for (int i = 0; i < v.size(); ++i) {
      if (v[i] == s) {
        int x = v.size() - i - 1;
        if (x == 0) x = 7;
        cout << x << endl;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    int N;
    cin >> N;
    ll mod = 1000000007;
    ll mod10 = 1;
    ll mod8 = 1;
    ll mod9 = 1;
    rep(i, N) {
        mod10 *= 10;
        mod8 *= 8;
        mod9 *= 9;
        mod10 %= mod;
        mod8 %= mod;
        mod9 %= mod;
    }
    ll preans = mod10 + mod8 - 2*mod9;
    preans %= mod;
    if (preans < 0) {
        cout << preans + mod << endl;
    }
    else {
        cout << preans << endl;
    }
}

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

typedef long long int lli;
set<lli> se;

void list_maker(string s, int n)
{
    if(n == 9)
    {
        return;
    }

    s += "7";
    se.insert(stol(s));
    list_maker(s, n+1);
}

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

    int n;
    cin >> n;

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

    int l = 0, r = n - 1;
    int sum = 0;

    while(l < r)
    {
        while(v[l] == 'R')
        {
            l++;
            if(l >= n)
            {
                cout << sum << endl;
                return 0;
            }
        }

        while(v[r] == 'W')
        {
            r--;
            if(r < 0)
            {
                cout << sum << endl;
                return 0;
            }
        }

        if(l < r)
        {
            v[r] = 'W';
            v[l] = 'R';
            sum++;
        }
    }

    cout << sum << endl;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
//cin.ignore();	// better to use 2 times getline(cin,s);
// g++ iterator.cpp -std=c++17
//cout << (A + B == C ? "YES" : "NO") << endl;
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);}

int main(void)
{
  fast();
 // 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
  int a[32];
  a[0]=1;

  a[1]=1;

  a[2]=1;

  a[3]=2;

  a[4]=1;

  a[5]=2;

  a[6]=1;

  a[7]=5;

  a[8]=2;

  a[9]=2;

  a[10]=1;

  a[11]=5;

  a[12]=1;

  a[13]=2;

  a[14]=1;

  a[15]=14;

  a[16]=1;

  a[17]=5;

  a[18]=1;

  a[19]=5;

   a[20]=2;
   a[21]=2;
   a[22]=1;
   a[23]=15;
   a[24]=2;
   a[25]=2;
   a[26]=5;
   a[27]=4;
   a[28]=1;
   a[29]=4;
   a[30]=1;
   a[31]=51;

    
    int x;
    cin>>x;
    cout<<a[x-1]<<endl;

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	void run() {

		int M = 1120;
		boolean[] isPrime = new boolean[M + 1];
		Arrays.fill(isPrime, true);
		isPrime[0] = isPrime[1] = false;
		for (int i = 2; i * i <= M; i++) {
			if (!isPrime[i]) continue;
			for (int j = i * 2; j <= M; j += i) isPrime[j] = false;
		}

		List<Integer> l = new ArrayList<>();
		for (int i = 0; i <= M; i++) if (isPrime[i]) l.add(i);
		int[] p = new int[l.size()];
		for (int i = 0; i < l.size(); i++) p[i] = l.get(i);

		int[][] dp = new int[15][M + 1];
		dp[0][0] = 1;

		for (int i = 0; i < p.length; i++) {
			for (int j = 13; j >= 0; j--) {
				for (int k = 0; k < M; k++) {
					if (k + p[i] <= M) dp[j + 1][k + p[i]] += dp[j][k];
				}
			}
		}

		for (;;) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			if ((n | k) == 0)
				return;
			System.out.println(dp[k][n]);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (abs(a-c) <=d || (d >= abs(a - b) && abs(b - c) <= d)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main(int argc, char const *argv[])
{
	int a;
	cin>>a;
	string s[a];
	for (int i = 0; i < a; ++i)
	{
		cin>>s[i];
	}
	int b;
	cin>>b;
	string t[b];
	for (int i = 0; i < b; ++i)
	{
		cin>>t[i];
	}
	int ans=0;
	for (int i = 0; i < a; ++i)
	{
		int cnt=0;
		for (int j = 0; j < a; ++j)
		{
			if (s[i]==s[j])
			{
				++cnt;
			}
		}
		for (int j = 0; j < b; ++j)
		{
			if (s[i]==t[j])
			{
				--cnt;
			}
		}
		ans=max(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,k,p[309],pi,sf[309],mod=998244353LL,dp[304][304][304],pas;
string s;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>s>>k;
    a=s.size();
    if(k>a) k=a;
    s.insert(0,"0");
    zx=0;
    for(i=a; i>=1; i--){
        if(s[i]=='0'){
            pi++;
            p[pi]=zx;
            zx=0;
        }else{
            zx++;
        }
    }
    pi++;
    p[pi]=zx;
    dp[pi+1][0][0]=1;
    for(i=1; i<=pi/2; i++) swap(p[i],p[pi-i+1]);
    for(i=pi; i>=1; i--){
        sf[i]=sf[i+1]+p[i];
    }
    for(i=pi; i>=1; i--){
        //cout<<p[i]<<" "<<sf[i]<<endl;
        for(j=0; j<=sf[i]; j++){
            for(jj=0; jj<=k; jj++){
                zx=j+1;xc=jj-p[i]-1;
                for(ii=0; ii<=j; ii++){
                    zx--;xc++;
                    //dp[i][j][jj]+=dp[i+1][j-ii][jj+ii-f[i]];
                    if(ii<=p[i]) dp[i][j][jj]+=dp[i+1][zx][xc]; else dp[i][j][jj]+=dp[i+1][zx][jj];
                }
                dp[i][j][jj]%=mod;
            }
        }
        /*for(j=1; j<=300; j++){
            for(jj=0; jj<=k; jj++){
                dpp[i][j][jj]+=dpp[i][j-1][jj];
                if(dpp[i][j][jj]>=mod) dpp[i][j][jj]-=mod;
            }
        }
        for(j=1; j<=300; j++){
            for(jj=0; jj<=k; jj++){
                kl[i][j][jj]+=kl[i][j-1][jj+1];
                if(kl[i][j][jj]>=mod) kl[i][j][jj]-=mod;
            }
        }*/
    }
    //cout<<endl;
    for(jj=0; jj<=k; jj++){
        pas+=dp[1][sf[1]][jj];
        if(pas>mod) pas-=mod;
    }
    cout<<pas;
    return 0;
}

Measured memory_bytes: 56900
import sys
from itertools import permutations
def main():
    input = sys.stdin.readline
    N = int(input())
    xy = [tuple(map(int, input().split())) for _ in range(N)]
    def dist(x1,y1,x2,y2): return ((x1-x2)**2 + (y1-y2)**2)**0.5
    ans = 0
    for route in permutations(range(N)):
        for i in range(N-1):
            ans += dist(xy[route[i]][0],xy[route[i]][1],xy[route[i+1]][0],xy[route[i+1]][1])
    for i in range(1,N+1):
        ans /= i
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 39792
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const ll MOD = 1000000007;
// const int INF = 2000000000;

int M, K;

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

  if (M == 0) {
    if (K == 0) {
      cout << "0 0" << endl;
      return 0;
    }
  } else if (M == 1) {
    if (K == 0) {
      cout << "0 0 1 1" << endl;
      return 0;
    }
  } else {
    int lim = pow(2, M);
    if (K < lim) {
      vector<int> b(lim);
      for (int i = 0; i < lim; i++) {
        b[i] = i;
      }

      for (int i = 0; i < lim; i++) {
        if (i != K) {
          cout << b[i] << " ";
        }
      }
      cout << K << " ";
      for (int i = lim - 1; i >= 0; i--) {
        if (i != K) {
          cout << b[i] << " ";
        }
      }
      cout << K << endl;

      return 0;
    }
  }

  cout << "-1" << endl;
  return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector <vector<int>>;
using vvl = vector <vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if (s.back() == 's') s.push_back('e');
  s.push_back('s');
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3660
using namespace std;
typedef signed long long ll;

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>


#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.length();
	map<char, char> mp;
	REP(i, n) {
		mp[s[i]] = t[i];
	}

	for (char c = 'a'; c <= 'z'; c++) {
		for (char d = 'a'; d <= 'z'; d++) {
			if (mp.count(c) == 0 || mp.count(d) == 0 || c == d) continue; 
			if (mp[c] == mp[d]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	REP(i, n) {
		s[i] = mp[s[i]];
	}
	cout << (s == t ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<P> vp;
typedef vector<T> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n = in();
  vi a(n);
  rep(i,n) cin >> a[i];
  
  sort(a.begin(), a.end());
  uni(a);
  if (a.size() == n) puts("YES");
  else puts("NO");
  return 0;
}

Measured memory_bytes: 1024