akhauriyash/Code-Regression huggingface dataset:
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
    s <- B.getLine
    print $ solve s

solve :: B.ByteString -> Int
solve = (\(_, _, _, w) -> w) . B.foldl op (1, 0, 0, 0)

op :: (Int, Int, Int, Int) -> Char -> (Int, Int, Int, Int)
op (x, y, z, w) 'A' = (x, y %+% x, z, w)
op (x, y, z, w) 'B' = (x, y, z %+% y, w)
op (x, y, z, w) 'C' = (x, y, z, w %+% z)
op (x, y, z, w) '?' = (3 %*% x, 3 %*% y %+% x, 3 %*% z %+% y, 3 %*% w %+% z)

infixl 6 %+%
(%+%) :: Int -> Int -> Int
x %+% y = (x + y) `mod` 1000000007

infixl 7 %*%
(%*%) :: Int -> Int -> Int
x %*% y = (x * y) `mod` 1000000007


Measured memory_bytes: 28028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			var S = retreiveStringArray()[0];

			var count = 0;

			var currentString = '1';

			for (int i = 0; i < N; i++) {

				if(currentString != S[i]) {
					count++;
					currentString = S[i];
				}

			}
			//答えの出力
			var ans = count;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


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

int main( void )
{
  string S;
  cin >> S;
  vector<bool> alf( 1024 );
  int count = 0;

  for( int i = 0; i < 1024; i++ )
    alf.at( i ) = false;

  for( int i = 0; i < S.size(); i++ )
    alf.at( S.at( i ) - 'a' ) = true;

  for( int i = 0; i < 26; i++ ) {
    if( !alf.at( i ) ) {
      cout << (char)( i + 'a' ) << endl;
      break;
    }
    count++;
  }

  if( count == 26 )
    cout << "None" << endl;
}

Measured memory_bytes: 3736
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P = pair<int, int>;

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

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;

int main(){
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        if (op == '?') break;
        if (op == '+'){
            printf("%d\n", a+b);
        } else if (op == '-') {
            printf("%d\n", a-b);
        } else if (op == '*') {
            printf("%d\n", a*b);
        } else if (op == '/') {
            printf("%d\n", a/b);
        }
    }
    return 0;
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

    int N, W, H;
    cin >> N >> W >> H;
    V cx(W + 1, 0);
    V cy(H + 1, 0);
    rep(i, N) {
        int x, y, w;
        cin >> x >> y >> w;
        cx[max(0LL, x - w)]++;
        cx[min(W, x + w)]--;
        cy[max(0LL, y - w)]++;
        cy[min(H, y + w)]--;
    }

    rep(i, W) {
        cx[i + 1] += cx[i];
    }

    rep(i, H) {
        cy[i + 1] += cy[i];
    }
    
    auto check1 = [&]{
        rep(i, W) {
            if (cx[i] <= 0) return false;
        }
        return true;
    };

    auto check2 = [&]{
        rep(i, H) {
            if (cy[i] <= 0) return false;
        }
        return true;
    };

    cout << (check1() || check2() ? "Yes" : "No") << endl;

}

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

typedef long long ll;
typedef unsigned long long ull;

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

  vector<ll> d(n);
  for (ll i = 0; i < n; ++i) {
    cin >> d[i];
  }

  ll ans = 0;
  for (ll i = 0; i < n; ++i) {
    for (ll j = i+1; j < n; ++j) {
      ans += d[i] * d[j];
    }
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define vi vector<int>
#define pi pair<int,int>
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define ll long long 

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x){
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x){
	for(auto& i:x)
		input>>i;
	return input;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod=1e9+7;

int mul(int a,int b)
{
	return (a*1ll*b)%mod;
	}
	
	int add(int a,int b)
	{
		a+=b;
		if(a>=mod)return a-mod;
		return a;
		}
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
		}
		return res;
	}



void solve()
{
int n,W;
cin>>n>>W;
ll dp[W+1]={0};
for(int i=0;i<n;i++)
{
	int w,v;
	cin>>w>>v;
	for(int j=W;j>=w;j--)
	{
		dp[j]=max(dp[j],dp[j-w]+v);
		}
	
	}
cout<<dp[W];
}
	
	
int main()
{   ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
		}
	
	
	}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
	int w, h, x, y, r;
	std::cin >> w >> h >> x >> y >> r;
	if ((w < r + x || 0 > x - r)||(h < r + y || 0 > y - r)) {
		std::cout << "No" << std::endl;
	} else {
		std::cout << "Yes" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll d;cin>>d;
    vector<ll>c(26);
    rep(i,26)cin>>c[i];
    vector<vector<ll> >s(d,vector<ll>(26));
    rep(i,d){
        rep(j,26)cin>>s[i][j];
    }
    vector<ll>last(26);
    vector<ll>v(d);
    ll ans=0;
    rep(i,d){
        ll ma=-inf*inf;
        ll idx=0;
        rep(t,26){
            ll cn=0;
            cn+=s[i][t];
            last[t]=i+1;
            cn+=5*(d-last[t]+1);
            if(cn>ma){
                ma=cn;
                idx=t;
            }
        }
        last[idx]=i+1;
        v[i]=idx+1;
    }
    rep(i,d){
        cout<<v[i]<<endl;
    }
}

Measured memory_bytes: 3724
s="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"
n=int(input())
print((s.split(", "))[n-1])

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

ll mo;
vector<int> E[101010];
vector<ll> dp[101010];

ll dfs(int cur, int pre) {
	ll ret = 1;
	REP(i, E[cur].size()) {
		int e = E[cur][i];
		if(e == pre) continue;
		dp[cur][i] = dfs(e, cur);
		(ret *= (1 + dp[cur][i])) %= mo;
	}
	return ret;
}

void dfs2(int cur, int pre, ll p) {
    int n = E[cur].size();

	REP(i, n) if(E[cur][i] == pre) dp[cur][i] = p;

	vector<ll> L(n), R(n);

	REP(i, n) {
		L[i] = (i ? L[i - 1] : 1) * (1 + dp[cur][i]) % mo;
	}

	for(int i = n - 1; i >= 0; i--) {
		R[i] = ((i < n - 1) ? (R[i + 1]) : 1) * (1 + dp[cur][i]) % mo;
		if(E[cur][i] == pre) continue;
        
		ll tot = (i ? L[i - 1] : 1) * ((i < n - 1) ? R[i + 1] : 1) % mo;
		dfs2(E[cur][i], cur, tot);
	}
}

int main() {
    int N;
	cin >> N >> mo;
    
	REP(i, N - 1) {
        int x, y;
		cin >> x >> y;
        x--, y--;        
		E[x].push_back(y);
		E[y].push_back(x);
	}

	REP(i, N) dp[i].resize(E[i].size());

	dfs(0,-1);
	dfs2(0,-1,0);
	
	REP(i, N) {
		ll res = 1;
		for(auto&& d : dp[i]) (res *= (1 + d)) %= mo;
		cout << res <<endl;
	}

    return 0;
}

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

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    ll v[4];
    cin >> v[0] >> v[1] >> v[2] >> v[3];
    reverse(v,v+4);
    ll N;
    cin >> N;
    N *= 4;
    ll ans = 0L;
    if(v[0] < 2*v[1] && v[0] < 4*v[2] && v[0] < 8*v[3]){
        ans += (N/8) * v[0];
        N = N - (N/8) * 8;
    }
    if(v[1] < 2*v[2] && v[1] < 4*v[3]){
        ans += (N/4) * v[1];
        N = N - (N/4) * 4;
    }
    if(v[2] < 2 * v[3]){
        ans += (N/2) * v[2];
        N = N - (N/2) * 2;
    }
    ans += N * v[3];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
main(){
  std::string s;
  std::cin>>s;
  std::string t="CODEFESTIVAL2016";
  int n=s.size();
  int ans=0;
  for(int i=0;i<n;++i)if(s[i]!=t[i])ans++;
  std::cout<<ans<<std::endl;
}

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


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

	// ビット演算を用いて書けるらしい。
	int l = S.size();
	unsigned long long sum = 0;
	for (unsigned int i = 0; i < (1 << (l-1)); i++) {
		bitset<10> b(i);
		unsigned long long s = 0;
		unsigned long long r = S.at(0) - '0';
		for (int j = 1; j < l; j++) {
			unsigned int c = S.at(j) - '0';
			if (b.test(j-1)) {
				s += r;
				r = c;
			}
			else {
				r = r * 10 + c;
			}
		}
		s += r;
		sum += s;
	}
	cout << sum << endl;

	return 0;
}



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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> r(n);
  for(int i=0; i<m; i++){
    int a, b;
    cin >> a >> b;
    r[a-1].push_back(b-1);
    r[b-1].push_back(a-1);
  }
  vector<int> d(n, -1);
  queue<int> que;
  d[0]=0;
  que.push(0);
  while(!que.empty()){
    int v=que.front();
    que.pop();
    for(int nv : r[v]){
      if(d[nv] != -1) continue;
      d[nv]=v;
      que.push(nv);
    }
  }
  cout << "Yes" << endl;
  for(int i=1; i<n; i++){
    cout << d[i]+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 10244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(),v.end()

int main() {
  string s,t;
  cin >> s;
  cin >> t;
  int count=0;
  for(int i=0;i<s.length();i++){
  	if(s[i]!=t[i])count++;
  }
  cout << count << endl;
}



Measured memory_bytes: 3832
#include <bits/stdc++.h>
//#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;
ll N;
ll acnt[201000];
ll bcnt[201000];
ll sumcnt[201000];
vector<ll> A, B;

int main() {
    cin >> N;
    A.resize(N);
    B.resize(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        acnt[A[i]]++;
        sumcnt[A[i]]++;
    }
    for(int i = 0; i < N; i++) {
        cin >> B[i];
        bcnt[B[i]]++;
        sumcnt[B[i]]++;
    }
    set<l_l> ast, bst;
    for(int i = 1; i <= N; i++) {
        if(acnt[i]) {
            ast.insert({-sumcnt[i], i});
        }
        if(bcnt[i]) {
            bst.insert({-sumcnt[i], i});
        }
    }
    vector<l_l> ans;
    for(int t = 0; t < N; t++) {
        auto tmp = *ast.begin();
        auto itr = bst.begin();
        if((*itr).second == tmp.second) {
            if(bst.size() == 1) {
                cout << "No" << endl;
                return 0;
            }
            itr++;
        }
        auto tmp2 = *itr;
        ll vala = tmp.second;
        ll valb = tmp2.second;
        ans.push_back({tmp.second, tmp2.second});
        ast.erase({-sumcnt[vala], vala});
        ast.erase({-sumcnt[valb], valb});
        bst.erase({-sumcnt[vala], vala});
        bst.erase({-sumcnt[valb], valb});
        acnt[vala]--;
        sumcnt[vala]--;
        bcnt[valb]--;
        sumcnt[valb]--;
        if(acnt[vala]) ast.insert({-sumcnt[vala], vala});
        if(acnt[valb]) ast.insert({-sumcnt[valb], valb});
        if(bcnt[vala]) bst.insert({-sumcnt[vala], vala});
        if(bcnt[valb]) bst.insert({-sumcnt[valb], valb});
    }
    cout << "Yes" << endl;
    sort(ans.begin(), ans.end());
    for(int i = 0; i < N; i++) {
        if(i != 0) cout << " ";
        cout << ans[i].second;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 40284
#include<bits/stdc++.h>
#define ll long long

using namespace std;
const int MAXN = 200005;
const int MOD = 1000000007;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n;
	cin >> n;
	ll l = 1 , h = n;
	while(l < h){
		ll m = (l + h) >> 1;
		ll k = m * (m+1) / 2;
		if(k < n) l = m+1;
		else h = m; 
	}
	cout << h << '\n';
	return 0;
}


Measured memory_bytes: 256
n,k,*a=map(int,open(0).read().split())
for _ in range(k):
  b=[0]*(n+1)
  for i,c in enumerate(a):
    b[max(0,i-c)]+=1
    b[min(n,c+i+1)]-=1
  for i in range(n):
    b[i+1]+=b[i]
  a=b[:-1]
  if a==[n]*n:
    print(*a)
    exit()
print(*a)

Measured memory_bytes: 171592
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

template <class T>
struct DelaySegmentTree{
  using F = function<T(T,T)>;
  F f;
  T inf;
  int n;
  vector<int> node, delay_val, delay_add;
  vector<bool> delayflag;

  DelaySegmentTree(vector<T> v ,T inf, F f) : inf(inf), f(f){
    n = 1; while(n < v.size()) n *= 2;
    node.resize(2*n-1, inf);
    delay_val.resize(2*n-1, inf);
    delay_add.resize(2*n-1, 0);
    delayflag.resize(2*n-1, false);
    for(int i = 0; i < v.size(); i++) node[i+n-1] = v[i];
    for(int i = n-2; i >= 0; i--) node[i] = f(node[2*i+1], node[2*i+2]);
  }

  void eval(int k, int l, int r){
    if(delayflag[k]){
      node[k] = delay_val[k];
      if(r - l > 1){
        delay_val[2*k+1] = delay_val[2*k+2] = delay_val[k];
        delayflag[2*k+1] = delayflag[2*k+2] = true;
      }
      delayflag[k] = false;
    }
    if(delay_add[k] != 0){
      node[k] += delay_add[k]; //区間sum
      //node[k] += delay_add[k] / (r - l); //区間min(max)
      if(r - l > 1){
        delay_add[2*k+1] += delay_add[k] / 2;
        delay_add[2*k+2] += delay_add[k] / 2;
      }
      delay_add[k] = 0;
    }
  }

  void update(int a, int b, T x){ update(a, b, x, 0, 0, n); }
  void update(int a, int b, T x, int k, int l, int r){
    eval(k, l, r);
    if(b <= l || r <= a) return;
    if(a <= l && r <= b){
      delay_val[k] = x;
      delayflag[k] = true;
      eval(k, l, r);
    }else{
      update(a, b, x, 2*k+1, l, (l+r)/2);
      update(a, b, x, 2*k+2, (l+r)/2, r);
      node[k] = f(node[2*k+1], node[2*k+2]);
    }
  }

  void add(int a, int b, T x){ add(a, b, x, 0, 0, n); }
  void add(int a, int b, T x, int k, int l, int r){
    eval(k, l, r);
    if(b <= l || r <= a) return;
    if(a <= l && r <= b){
      delay_add[k] += x * (r - l);
      eval(k, l, r);
    }else{
      add(a, b, x, 2*k+1, l, (l+r)/2);
      add(a, b, x, 2*k+2, (l+r)/2, r);
      node[k] = f(node[2*k+1], node[2*k+2]);
    }
  }

  //区間[a, b)の値を返す
  T getval(int a, int b){ return getval(a, b, 0, 0, n); }
  T getval(int a, int b, int k, int l, int r){
    eval(k, l, r);
    if(b <= l || r <= a) return inf;
    if(a <= l && r <= b) return node[k];
    T vl = getval(a, b, 2*k+1, l, (l+r)/2);
    T vr = getval(a, b, 2*k+2, (l+r)/2, r);
    return f(vl, vr);
  }
};

signed main(){

  int n, q; cin >> n >> q;
  DelaySegmentTree<int> seg(vector<int>(n, 0), 0, [&](int x, int y){ return (x + y); });
  for(int i = 0; i < q; i++){
    int c, s, t, x; cin >> c >> s >> t;
    s--, t--;
    if(c == 0){
      cin >> x;
      seg.add(s, t+1, x);
    }else{
      cout << seg.getval(s, t+1) << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 9716
n,m=map(int,input().split())
S=[]
for _ in range(m):
    s=list(map(int,input().split()))
    S.append(s[1:])
P=tuple(map(int,input().split()))
ans=0
for i in range(1<<n):
    for j in range(m):
        cnt=0
        for k in S[j]:
            if i&(1<<(k-1)):
                cnt+=1
        if cnt%2!=P[j]:
            break
    else:
        ans+=1
print(ans)

Measured memory_bytes: 41200
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void get(Args...)(ref Args args)
{
    import std.traits, std.meta, std.typecons;

    static if (Args.length == 1) {
        alias Arg = Args[0];
        
        static if (isArray!Arg) {
            args[0] = readln.split.to!Arg;
        } else static if (isTuple!Arg) {
            auto input = readln.split;
            static foreach (i; 0..Fields!Arg.length) {
                args[0][i] = input[i].to!(Fields!Arg[i]);
            }
        } else {
            args[0] = readln.chomp.to!Arg;
        }
    } else {
        auto input = readln.split;
        assert(input.length == Args.length);

        static foreach (i; 0..Args.length) {
            args[i] = input[i].to!(Args[i]);
        }
    }
}

void get_lines(Args...)(size_t N, ref Args args)
{
    import std.traits, std.range;

    static foreach (i; 0..Args.length) {
        static assert(isArray!(Args[i]));
        args[i].length = N;
    }

    foreach (i; 0..N) {
        static if (Args.length == 1) {
            get(args[0][i]);
        } else {
            auto input = readln.split;
            static foreach (j; 0..Args.length) {
                args[j][i] = input[j].to!(ElementType!(Args[j]));
            }
        }
    }
}

void main()
{
    long X, Y; get(X, Y);
    writeln(abs(X - Y) <= 1 ? "Brown" : "Alice");
}

Measured memory_bytes: 2756
/**
 *  author: MOOONI
 *  hackers are welcome!
**/
#include <bits/stdc++.h>

#define int long long

using namespace std;

template<typename T>
void debug_out(T x) {
  cerr << x;
}

template<typename A>
void debug_out(vector<A> v) {
  cerr << '{';
  for (int i = 0; i < (int) v.size(); i++) {
    if (i) {
      cerr << ", ";
    }
    debug_out(v[i]);
  }
  cerr << '}';
}

template <typename A, typename B>
void debug_out(pair<A, B> p) {
  cerr << '(';
  debug_out(p.first);
  cerr << ", ";
  debug_out(p.second);
  cerr << ')';
}

template <typename A, typename B, typename C>
void debug_out(tuple<A, B, C> p) {
  cerr << '(';
  debug_out(get<0>(p));
  cerr << ", ";
  debug_out(get<1>(p));
  cerr << ", ";
  debug_out(get<2>(p));
  cerr << ')';
}

template <typename A, typename B, typename C, typename D>
void debug_out(tuple<A, B, C, D> p) {
  cerr << '(';
  debug_out(get<0>(p));
  cerr << ", ";
  debug_out(get<1>(p));
  cerr << ", ";
  debug_out(get<2>(p));
  cerr << ", ";
  debug_out(get<3>(p));
  cerr << ')';
}

template <size_t N>
void debug_out(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  cerr << res;
}

template <typename T>
void debug_with_endl(T v) {
  debug_out(v);
  cerr << endl;
}

template <typename Head, typename... Tail> 
void debug_with_endl(Head H, Tail... T) {
  debug_with_endl(H);
  debug_with_endl(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_with_endl(__VA_ARGS__)
#else
#define debug(...) 2003
#endif

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> ans(n);
  for (int i = 0; i < n - 1; i++) {
    int id;
    cin >> id;
    --id;
    ++ans[id];
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 4748
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("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let n: usize = read();

    let mut ret: u128 = 1;
    let a: Vec<u128> = (0..n).map(|_| read()).collect();
    let is_zero = (&a).into_iter().fold(false, |a, &b| a || b == 0);
    if is_zero  {
        println!("0");
        return;
    }

    for b in &a {
        ret *= b;
        if ret > 1_000_000_000_000_000_000 {
            println!("-1");
            return;
        }
    }
    println!("{}", ret);
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, m; cin >> n >> m;
    vector<P> edge;
    vector<vector<int>> G(n);
    rep(i,m){
        int a, b; cin >> a >> b;
        --a, --b;
        edge.push_back(make_pair(a,b));
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int ans = 0;
    rep(i,m){
        P deleted = edge[i];
        vector<int> dist(n, -1);
        queue<int> q;
        q.push(0);
        dist[0] = 0;
        while(!q.empty()){
            int v = q.front(); q.pop();
            for(auto nv : G[v]){
                if(v == deleted.first && nv == deleted.second) continue;
                if(nv == deleted.first && v == deleted.second) continue;
                if(dist[nv] != -1) continue;
                q.push(nv);
                dist[nv] = dist[v] + 1;
            }
        }
        bool isBridge = false;
        rep(i,n){
            if(dist[i] == -1) isBridge = true;
        }
        if(isBridge) {
            //cout << deleted.first << " " << deleted.second << endl;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
using namespace std;

int n;

VI v;

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

	cin >> n;

	if(n==3)
	{
		cout << 2 << " " << 5 << " " << 63 << endl;
		return 0;
	}

	for(int i = 1; i <= 30000; ++i)
	{
		if(i%2==0 || i%3==0)
			v.pb(i);
	}

	srand(21);

	while(1)
	{
		random_shuffle(ALL(v));

		int curr = 0, g = v[0];

		for(int i = 0; i < n; ++i)
		{
			curr += v[i];
			curr %= 6;
			g = __gcd(v[i], g);
		}

		if(!curr && g==1)
		{
			for(int i = 0; i < n; ++i)
			{
				cout << v[i] << " ";
			}

			exit(0);
		}
	}
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, greater<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define MOD 1000000007LL
//#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[&](auto f,auto... args){return f(f,args...);};


int main(){
    string s;
    cin>>s;
    lint n;
    cin>>n;
    for(lint i=0;i<s.size();i+=n){
        cout<<s[i];
    }
    cout<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	ABK := scanIntNums()

	AA, AB := checkRemain(int64(ABK[0]), int64(ABK[1]), int64(ABK[2]))
	fmt.Printf("%d %d\n", AA, AB)

}

// example
func checkRemain(A, B, K int64) (AA, AB int64) {
	//var i int64
	if A >= K {
		AA = A - K
		AB = B
		return
	}
	if K > A && A+B > K {
		AA = 0
		AB = B - (K - A)
		return
	}
	AA = 0
	AB = 0
	return
}

func scanIntNums() (nums []int) {
	sc.Scan()
	numString := strings.Split(sc.Text(), " ")

	nums = make([]int, len(numString))
	var err error

	for i := 0; i < len(nums); i++ {
		nums[i], err = strconv.Atoi(numString[i])
		if err != nil {
			panic(err)
		}
	}
	return nums
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>

typedef long long int llint;

int main(void){

  int n;
  std::cin >> n;
  std::vector<int> A(n+1, 0);

  for(int i=0; i<n-1; i++){
    int temp;
    std::cin >> temp;
    A[temp]++;
  }

  for(int i=1; i<=n; i++){
    std::cout << A[i] << " ";
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 4052
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;

void solve() {
    int n, l;
    cin >> n >> l;
    int sum = 0, mn = INF;
    for (int i = 1; i <= n; i++) {
        sum += l + i - 1;
        if (abs(mn) > abs(l + i - 1)) mn = l + i - 1;
    }
    cout << sum - mn;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //int t;
    //cin >> t;
    int t = 1;
    //srand(time(0));
    while (t--) solve();
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vi dp(1000001,INF), dp2(1000001,INF);
	dp[0] = 0; dp2[0] = 0;
	for (int i = 1; i*(i + 1)*(i + 2) / 6 <= 1000000; ++i) {
		int k = i*(i + 1)*(i + 2) / 6;
		
		REP(j, 1000001-k) {
			dp[j + k] = min(dp[j + k], dp[j] + 1);
		}
	}
	for (int i = 1; i*(i + 1)*(i + 2) / 6 <= 1000000; ++i) {
		int k = i*(i + 1)*(i + 2) / 6;
		if (k % 2 == 0)continue;
	
		REP(j, 1000001 - k) {
			dp2[j + k] = min(dp2[j + k], dp2[j] + 1);
		}
	}
	while (1) {
		int n;
		cin >> n;
		if (!n)break;
		cout << dp[n] <<" "<<dp2[n]<< endl;
	}
	return 0;
}

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

int main()
{
  int y,n;
  cin >> y >> n;
  
  int p[n];
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }

  int x[101] = {0};
  for(int i = 0; i < n; i++){
    x[p[i]]++;
  }
  
  int maxze = 101;
  int ans = 101;
  for(int i = 0; i <= 101; i++){
    if( (x[i] == 0) && (abs(i - y) < maxze) ){
      maxze = abs(i - y);
      ans = i;
    }
  }
  
  if(n == 0){
    ans = y;
  }
  if(maxze >= abs(y + 1)){
    ans = -1;
  }
  

  
  cout << ans << endl;
  
}

Measured memory_bytes: 3612
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n,a,b,sum=0;
    cin>>n;
    while(n--)
    {
        cin>>a>>b;
        sum=sum+abs(b-a)+1;
    }
    cout<<sum<<endl;
    return 0;
}

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


int main() {
  
  string S;
  cin >> S;
  
  int count = 0;
  
  for (int i = S.size(); i > 0; i -= 2) {
    string A;
    string B;
    for (int j = 0; j < i / 2; j++) {
      A.push_back(S.at(j));
      B.push_back(S.at(i / 2 + j));
    }
    
    if (i != S.size() && A == B) {
      count = A.size();
      break;
    }
  }
  
  cout << count * 2 << endl;
      
  
  
  

}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair




int main(){
    int N,M; cin>>N>>M;
    map<int,int> mp;
    for(int i=1;i<=N;++i){
        int p;
        cin >> p;
        mp[p] = i;
    }
    
    vector<int> edge[N+1];
    REP(i,M){
        int x,y;
        cin >> x >> y;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    
    int ans = 0;
    int visit[N+1] = {0};
    for(int start=1;start<=N;++start){
        if(visit[start]){ continue;}
        vector<int> number;
        vector<int> place;
        queue<int> que;
        
        visit[start] = 1;
        number.push_back(start);
        place.push_back(mp[start]);
        que.push(start);
        while(!que.empty()){
            int cur = que.front();
            que.pop();
            for(int next:edge[cur]){
                if(visit[next]){ continue; }
                visit[next] = 1;
                number.push_back(next);
                place.push_back(mp[next]);
                que.push(next);
            }
        }
        
        sort(ALL(place));
        for(int x:number){
            if(x==*lower_bound(ALL(place),x)){
                ++ans;
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 11772
#include <bits/stdc++.h>
using namespace std;
int memo[200][200] , n , m , nxtr , nxtc;
char grid[200][200];
int dx[] = {1 , 0};
int dy[] = {0 , 1};
bool inside(int a , int b){
	return (a >= 1 && a <= n && b >= 1 && b <= m);
}
int dp(int r , int c){
	if(!inside)return 1e8;
	if(r == n && c == m){
		if(grid[r][c] == '#')return 1;
		else return 0;
	}
	if(memo[r][c] != 1e8)return memo[r][c];
	for(int i = 0 ; i <= 1 ; i++){
		if(!inside(r + dx[i] , c + dy[i]))continue;
		nxtr = r + dx[i];
		nxtc = c + dy[i];
		if(grid[r][c] == '.'){
			memo[r][c] = min(dp(nxtr , nxtc) , memo[r][c]);
		}
		else if(grid[r][c] == '#'){
			if(grid[nxtr][nxtc] == '#')memo[r][c] = min(dp(nxtr , nxtc) , memo[r][c]);
			else memo[r][c] = min(dp(nxtr , nxtc) + 1 , memo[r][c]);
		}
	}
	return memo[r][c];
}
int main(){
	cin >> n >> m;
	for(int i = 1 ; i <= n ; i++){
		for(int j = 1 ; j <= m ; j++){
			cin >> grid[i][j];
			memo[i][j] = 1e8; 
		}
	}
	cout << dp(1 , 1) << endl;
}

Measured memory_bytes: 3688
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include <map>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()


int main() {
	ll k;
	cin >> k;
	
	
	ll mod = 7 % k;
	rep(i, k) {
		//cout << mod << endl;
		if (mod == 0) {
			cout << i+1 << endl;
			return 0;
		}
		mod = (mod * 10 + 7) % k;

	}
	cout << -1 << endl;

}


Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String[] S = new String[n];
		char c;
		int[][] count = new int[n][26];

		S[0]=scan.nextLine();
		for(int i =0;i<n;i++){
			S[i]=scan.nextLine();
		}

		for(int i =0;i<n;i++){
			for(int j =0;j<S[i].length();j++){
			c = S[i].charAt(j);
			count[i][c-'a']++;
			}
		}

		int[] min = new int[26];

		for(int i =0;i<26;i++){
			min[i]=50;
			for(int j =0;j<n;j++){
				if(count[j][i] < min[i]){
					min[i]=count[j][i];
				}
			}
		}

		c = 'a';
		for(int i=0;i<26;i++){
			for(int j=0;j<min[i];j++){
				System.out.print(c);
			}
			c++;
		}
		System.out.println("");

	}

}


Measured memory_bytes: 23124
#!/usr/bin/env python
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor

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

    if A <= 5:
        print(0)
    elif A <= 12:
        print(B // 2)
    else:
        print(B)

if __name__ == '__main__':
    main()


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

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

    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    int passNum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
        if (h[i] >= K)
            passNum++;
    }
    cout << passNum << endl;
    return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
 
public class Main{

  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      boolean[][] checkCards = new boolean[4][13];
      for( int i = 0; i < 4; i++ ) {
        Arrays.fill(checkCards[i], false);
      }
      String[] lines = br.readLine().split(" ");
      int n = Integer.parseInt(lines[0]);
      int a,b;

      for(int i = 0; i < n; i++) {
        lines = br.readLine().split(" ");
        a = suitToInt(lines[0]);
        b = Integer.parseInt(lines[1]);
        checkCards[a][b-1] = true;
      }

      for(int i = 0; i < 4; i++ ) {
        for( int j = 0; j < 13; j++ ) {
          if(!checkCards[i][j]) System.out.println(intToSuit(i) + " " + (j+1));
        }
      }
    }
  }

  public static int suitToInt( String suit ) {
    switch( suit ) {
      case "S": return 0;
      case "H": return 1;
      case "C": return 2;
      default : return 3;
    }
  }
  public static String intToSuit( int r ) {
    switch( r ) {
      case 0  : return "S";
      case 1  : return "H";
      case 2  : return "C";
      default : return "D";
    }
  }
}


Measured memory_bytes: 24328
package main

import (
	"fmt"
)

//input
//N(int 0<N<26)
//S(String 1<S<10^4)
func main() {
	var s string
	var n int
	fmt.Scan(&n, &s)
	var ret string
	var err error
	ret, err = Caesar(s, n)
	if err == nil {
		fmt.Println(ret)
	}
}
func Caesar(s string, n int) (string, error) {
	v := []uint8(s)
	nb := uint8(n)
	for i, c := range v {
		//todo 'A' < c < 'Z'じゃないと例外投げたほうがよくね？
		c += nb
		for c > 'A'+25 {
			c -= 26
		}
		v[i] = c
	}
	return string(v), nil
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
    cin>>s;
    if(s=="SUN")cout<<7<<endl;
    else if(s=="MON")cout<<6<<endl;
    else if(s=="TUE")cout<<5<<endl;
    else if(s=="WED")cout<<4<<endl;
    else if(s=="THU")cout<<3<<endl;
    else if(s=="FRI")cout<<2<<endl;
    else if(s=="SAT")cout<<1<<endl;
}


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

vector<int> adj[200005];
bool vis[200005];

vector<int> bfs(int u) {
    queue<int> q;
    q.push(u);
    memset(vis, false, sizeof(vis));
    vector<int> level(200005);
    while (!q.empty()) {
        int x = q.front();
        vis[x] = true;
        q.pop();
        for (auto nei : adj[x]) {
            if (!vis[nei]) {
                q.push(nei);
                level[nei] = level[x] + 1;
            }
        }
    }
    return level;
}

int main() {
    int n, u, v;
    cin >> n >> u >> v;
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    int ans = -1;
    vector<int> aoki = bfs(v);
    vector<int> taka = bfs(u);
    for (int i = 1; i <= n; i++) {
        if (aoki[i] > taka[i]) {
            ans = max(aoki[i] - 1, ans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N;
int p[20100];
ll a[20100], b[20100];
int main(void){
	cin >> N;
	rep(i, N) cin >> p[i];
	rep(i, N) p[i]--;
	rep(i, N){
		a[p[i]] = i + 1;
	}
	rep(i, N){
		a[i] += 30000 * (i + 1);
	}

	REP(i, N){
		b[i] = INF - 30000 * (i + 1);
	}
	rep(i, N) printf("%lld ", a[i]);
	printf("\n");
	rep(i, N) printf("%lld ", b[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int,input().split()))

B = [0 for _ in range(N)]
for i in range(N-1,-1,-1):
  isum = 0
  itr = 2
  while (i+1)*itr -1 < N:
    isum += B[(i+1)*itr - 1]
    itr += 1
  isum %= 2
  if isum != A[i]:
    B[i] = 1

if sum(B) == 0:
  print(0)
else:
  print(sum(B))
  for i in range(N):
    if B[i] != 0:
      print(i+1)


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

int main() {
  vector<string> tenki = {"Sunny", "Cloudy", "Rainy"};
  string S;
  cin >> S;
  for (int i = 0; i < tenki.size(); i++) {
  	if (S == tenki[i]) {
      if (i < tenki.size() - 1) {
      	cout << tenki[i + 1] << endl;
      } else {
      	cout << tenki[0] << endl;
      }
    }
  }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i]>>c[i];

    int dp[n][3];
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];

    for(int i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }

    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;

    return 0;
}


Measured memory_bytes: 5464
fun main(arr:Array<String>) {
    val ans = if (canComplete()) "Yes" else "No"
    println(ans)
}

data class Work(val require:Int, val limit:Int)

fun canComplete():Boolean {
    val workCount = readLine()!!.toInt()
    var works = (0..workCount-1).map { 
        val (a,b) = readLine()!!.split(" ").map { it.toInt() }
        Work(a, b)
    }.sortedBy { it.limit }
    var now = 0
    works.forEach {
        now = now + it.require
        if(now > it.limit) {
            return false
        }
    }
    return true
}

Measured memory_bytes: 116188
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#define ll long long
#define vi vector<ll>
#define vs vector<string>
#define fr(i, k, n) for (ll i = k; i < n; i++)
#define rep(i, n) fr(i, 0, n)
#define alll(v) v.begin(), v.end()
#define mp(a, b) make_pair(a, b)
#define rdd(a) ll a; cin >> a
#define rrd rdd(a); rep(i, a)
//min({a,b,c,d})などの記法
using namespace std;
template <class X> void pr(X x) { cout << x << endl; }
template <class X> void prr(X x) { for (auto it : x) { cout << it<<" ";}cout<<endl; }

int main(int argc, const char * argv[]) {
    
    ll t;
    cin >> t;
    
    unordered_map<ll,vector<pair<ll, ll> > > mat;
    rep(z, t-1){
        ll h,k,n;
        cin>>h>>k>>n;
        mat[h].push_back(mp(k, n));
        mat[k].push_back(mp(h, n));
    }
    ll q,k,x,y;
    cin >>q>>k;
    vector<ll> d(t+1,-1);
    vector<ll> Q;
    d[k]=0;
    Q.push_back(k);
    while (Q.size()!=0) {
        ll indx=Q.front();
        ll omomi =d[indx];
        Q.erase(Q.begin());
        for(auto itt:mat[indx]){
            //            for(auto itt:it){
            if (d[itt.first]==-1) {
                d[itt.first]=omomi+itt.second;
                Q.push_back(itt.first);
            }
            //            }
        }
    }
    rep(i, q){
        cin>>x>>y;
        cout <<d[x]+d[y]<<endl;
    }
    return 0;
}

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

int main() {
	int N, sum, W[100 + 10];
    cin >> N;
    for (int i = 0; i < N; ++i){
        cin >> W[i];
        sum += W[i];
    }

    int left = 0;
    int right = sum;
    int ans = abs(left - right);
    for (int i = 0; i < N; ++i){
        left += W[i];
        right -= W[i];
        ans = min(ans, abs(left - right));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256