akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

long long mod = 1000000007;
long long N, K;
long long nr[209][109];
long long dp[209][109], nex[209][209];

string S;
int LIM[209];
bool used[209];

void init() {
	for (int i = 0; i <= 200; i++) {
		for (int j = 0; j <= 200; j++) {
			if (i == 0 || j == 0) nr[i][j] = 1;
			else nr[i][j] = (nr[i - 1][j] + nr[i][j - 1]) % mod;
		}
	}
}

long long ncr(int n, int r) {
	if (r < 0 || n < r) return 0;
	return nr[n - r][r];
}

long long solve(int cnt1, int cnt2) {
	// ステップ 1: 前処理
	for (int i = 0; i < 200; i++) { used[i] = false; LIM[i] = 0; }

	// ステップ 2: 上限文字数の計算
	int f1 = 0, f2 = 0; vector<int> E;
	for (int i = 0; i < K; i++) {
		if (S[i] == 'r' && f1 < cnt1 + cnt2) { f1++; used[i] = true; }
		if (S[i] == 'b' && f2 < min(f1, cnt1)) { f2++; used[i] = true; E.push_back(i); }
	}
	if (f1 < cnt1 + cnt2 || f2 < cnt1) return 0;
	for (int i = 0; i < cnt1; i++) {
		for (int j = E[i] + 1; j < K; j++) {
			if (used[j] == false) LIM[i]++;
		}
	}

	// ステップ 3: 初期化
	for (int i = 0; i <= 70; i++) {
		for (int j = 0; j <= 70; j++) { dp[i][j] = 0; nex[i][j] = 0; }
	}
	
	// ステップ 4: DP の計算
	int V = N - 2 * (cnt1 + cnt2) + 1;
	int MaxLetter = (V / 2);

	dp[0][0] = 1;
	for (int i = 0; i <= MaxLetter; i++) {
		for (int j = 0; j <= cnt1; j++) {
			for (int k = 0; k <= MaxLetter; k++) {
				if (dp[j][k] == 0) continue;
				
				int cx = j, cy = k, cnt = 0;
				while (cx <= cnt1 && cy <= min(LIM[cnt1 - cx], MaxLetter)) {
					nex[cx][cy] += ncr(cx, j) * dp[j][k];
					nex[cx][cy] %= mod;
					cx += 1; cy += i;
				}
			}
		}
		for (int j = 0; j <= cnt1; j++) {
			for (int k = 0; k <= MaxLetter; k++) {
				dp[j][k] = nex[j][k];
				nex[j][k] = 0;
			}
		}
	}

	// ステップ 5: 最終的な計算
	long long ret = 0;
	for (int i = 0; i <= MaxLetter; i++) {
		int minimal_letter = 2 * (cnt1 + cnt2) - 1 + i * 2;
		int ranged = (cnt1 + cnt2 + 1) + (cnt1 * 3 + i * 2) + cnt2;
		long long V1 = dp[cnt1][i];
		long long V2 = ncr(ranged + (N - minimal_letter) - 1, N - minimal_letter);
		ret += (V1 * V2);
		ret %= mod;
	}

	long long ret2 = ncr(cnt1 + cnt2, cnt2);
	return (ret * ret2) % mod;
}

int main() {
	cin >> N >> K >> S;
	init();

	long long Answer = 0;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N; j++) {
			long long rem = solve(i, j);
			//cout << i << " " << j << " " << rem << endl;
			Answer += rem;
			Answer %= mod;
		}
	}

	cout << Answer << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef vector<int> vi;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define ll long long int
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i, a, b) for(int i = a; i < b; i++)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define trarr(a,n) rep(i,0,n) cerr<<a[i]<<" \n"[i==n-1];
#define trmat(g,n,m) rep(i,0,n)rep(j,0,m) cerr<<g[i][j]<<" \n"[i==m-1];
#define tr(...) cerr<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

const ld PI = acos(-1);
const ld EPS = 1e-9;
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int P = 1e9+7;
const int N = 2e5+10;
void solve(int _t){
	int n;
	cin >> n;
	vi a(n);
	rep(i, 0, n){
		cin >> a[i];
	}
	ll ans = 0;
	rep(i, 1, n){
		if(a[i] < a[i-1]){
			ans+=a[i-1]-a[i];
			a[i] = a[i-1];
		}
	}
	cout<<ans<<endl;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	// cin >> t;
	rep(test, 1, t+1){
		solve(test);
	}
	return 0;
}  

Measured memory_bytes: 3988
x,y = gets.chomp.split.map(&:to_i)

p = 0
f = 300000
s = 200000
t = 100000

if x == 1
    p += f
elsif x == 2
    p += s
elsif x == 3
    p += t
end 

if y == 1
    p += f
elsif y == 2
    p += s
elsif y == 3
    p += t
end 

if p == 600000
    puts p + 400000
else
    puts p
end


Measured memory_bytes: 3836
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;

string table = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
	while (cin >> n&&n) {
		string s;
		int num[110];
		REP(i, n) {
			cin >> num[i];
		}
		cin >> s;
		int cnt = 0;
		REP(i, s.size()) {
			FOR(j, table.size() / 2, table.size()) {
				//cout << table[j];
				if (table[j] == s[i]) {
					s[i] = table[j - num[cnt]];
					break;
				}
			}
			cnt++;
			if (cnt == n)cnt = 0;
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 3068
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

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

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

#define bit(x) (1LL<<(x))

int n,k;
vi a;
vector<vi> dp(51, vi(2,-1));

signed main(){

    in(n,k);
    resz(n,a);
    in(a);

    dp[0][0]=0;
    REP(i,1,50){
        int num=0;
        // show(i,bit(i),bit(49-i));
        rep(j,n) if(a[j]&(bit(49-i))) num++;

        int res0=bit(49-i)*num,res1=bit(49-i)*(n-num);

        if(dp[i-1][0]!=-1){
            if(k&bit(49-i)){
                dp[i][0]=dp[i-1][0]+res1;
            }else{
                dp[i][0]=dp[i-1][0]+res0;
            }
        }

        if(dp[i-1][0]!=-1){
            if(k&bit(49-i)){
                dp[i][1]=dp[i-1][0]+res0;
            }
        }

        if(dp[i-1][1]!=-1){
            dp[i][1]=max(dp[i][1],dp[i-1][1]+max(res0,res1));
        }

        // show(i,49-i,dp[i][0],dp[i][1]);
    }
    out(max(dp[49][0],dp[49][1]));

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int L = sc.nextInt();

		int total = 0;

		for (int i=0; i<N; i++){
			total += (L + i);
		}
		if (L <= 0 && (L + N -1) >= 0 ) {
			System.out.println(total);
		} else {
			if (total >= 0) {
				total = total - L;
			} else {
				total = total - (L + N -1);
			}
			System.out.println(total);
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const auto mod=1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int a,b,x,y;
  cin >> a >> b >> x >> y;
  cout << double(a)*double(b)/2 << " " <<  (x+x==a && y+y==b) << endl;
 }

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 1000100
typedef long long ll;
inline ll read(){
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,cnt[3],id[3]={0,1,2},pos[3];
char s[N];
void Del_C(){
	int tmp=0;
	char t[N];
	for(int i=1,j=1;i<=n;i=j+1){         //尽量删去每段的 C 
		int d[2]={0,0};
		j=i;
		while(j<n&&s[j+1]!='A')++j;
		if(s[i]=='A')t[++tmp]=s[i++];
		for(int k=i;k<=j;++k)++d[s[k]-'B'];         //统计 B 和 C 的个数 
		if(i<j&&d[1]==d[0]+1&&cnt[2]>cnt[1]+1){   //C的个数 大于 B的个数，能删掉 2 个 C。 
			for(int k=i+1;k<j;++k)t[++tmp]=s[k];
			cnt[2]-=2;
		}
		else if(i<j&&d[1]>=d[0]&&cnt[2]>cnt[1]){  //C的个数 等于 B的个数，能删掉 1 个 C。 
			if(s[i]=='C'){
				for(int k=i+1;k<=j;++k)t[++tmp]=s[k];
			}
			else{
				for(int k=i;k<j;++k)t[++tmp]=s[k];
			}
			--cnt[2];
		}
		else{
			for(int k=i;k<=j;++k)t[++tmp]=s[k];
		}
	}
	if(cnt[2]>cnt[1]&&t[tmp]=='C'){  //删去结尾的 C 
		--tmp,--cnt[2];
	}
	if(cnt[2]>cnt[1]&&t[1]=='C'){     //删去开头的 C 
		--cnt[2];
		for(int i=1;i<tmp;++i)t[i]=t[i+1];
		--tmp;
	}
	n=tmp;
	swap(s,t);
	if(cnt[2]==cnt[1])return;
	memset(t,0,sizeof(t));
	tmp=0;
	for(int i=1;i<=n;++i){           //删去 AC 
		if(i<n&&cnt[2]>cnt[1]&&s[i]=='A'&&s[i+1]=='C'){
			++i,--cnt[2],--cnt[0];
		}
		else t[++tmp]=s[i];
	} 
	n=tmp;
	swap(s,t);
}
void Del_BC(){
	int tmp=0;
	char t[N];
	for(int i=1;i<=n;++i){
		if(cnt[1]>cnt[0]&&i<n&&s[i-1]!='A'&&s[i]!='A'&&s[i+1]!='A'){ //删去 BC 或 CB 
			++i,--cnt[1],--cnt[2];
		}
		else t[++tmp]=s[i];
	}
	n=tmp;
	swap(s,t);
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	int tmp=0;
	for(int i=1;i<=n;++i){   
		if(s[i]^s[i-1])s[++tmp]=s[i];  //把连续段缩起来 
	}
	n=tmp;
	for(int i=1;i<=n;++i){
		++cnt[s[i]-'A'];
	}
	sort(id,id+3,[&](int i,int j){return cnt[i]<cnt[j];});
	for(int i=0;i<3;++i)pos[id[i]]=i;
	sort(cnt,cnt+3);
	for(int i=1;i<=n;++i){
		s[i]=pos[s[i]-'A']+'A';
	}
	Del_C();
	Del_BC();
	for(int i=1;i<=n;++i){
		putchar(id[s[i]-'A']+'A');
	}
	putchar('\n');
	return 0;
}




Measured memory_bytes: 5672
// inputに入力データ全体が入る
function Main(input) {
    var N = input[0].split(" ")[0]-0;
    var M = input[0].split(" ")[1]-0;
    var list = {};
    for(var i=1;i<=M;i++){
        var a = input[i].split(" ")[0]-0;
        var b = input[i].split(" ")[1]-0;
        list[a] = list[a]||{};
        list[b] = list[b]||{};
        list[a][b] = i;
        list[b][a] = i;
    }
    
    var ans = 0;
    for(var i=1;i<=M;i++){
        if(check(list, i)!=N)ans++;
    }
    
    console.log(ans);
}


function check(list, i){
    var stack = [1];
    var checked = {};
    while(stack.length>0){
        var now = stack.splice(0,1)[0];
        if(checked[now]) continue;
        checked[now] = true;
        var next = Object.keys(list[now]);
        next.forEach(nxt=>{
            if(list[now][nxt]!=i){
                stack.push(nxt);
            }
        });
    }
    return Object.keys(checked).length;
}


Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));



Measured memory_bytes: 7752
#include <algorithm>
#include <stdio.h>
using ll = long long;

int main() {
	int N, a[100], used = 0, free = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", a + i);
		if (3200 <= a[i])
			free++;
		else
			used |= 0x1 << (a[i] / 400);
	}
	used = (used & 0x55) + ((used >> 1) & 0x55);
	used = (used & 0x33) + ((used >> 2) & 0x33);
	used = (used & 0x0f) + ((used >> 4) & 0x0f);
	printf("%d %d\n", std::max(1, used), used + free);
}

Measured memory_bytes: 128
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n, p = map(int, input().split())
a = [int(m) for m in input().split()]
k = 0
for i in range(n):
    if a[i] % 2 == 0:
        k += 1

if p == 1:
    tmp = 0
    for i in range(1, n - k + 1, 2):
        tmp += comb(n - k, i)
    print((2 ** k) * tmp)
else:
    tmp = 0
    for i in range(0, n - k + 1, 2):
        tmp += comb(n - k, i)
    print((2 ** k) * tmp)

Measured memory_bytes: 3064
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1e9 + 7;

// Union-Find木
// 初期化 UF(N); Nは要素数
// 結合 unite(x,y); 同じ集合か判定 same(x,y);
// 集合の数 count
struct UnionFind {
  vector<ll> par, sizes;
  ll cnt;
  UnionFind(ll N) : par(N), sizes(N, 1), cnt(N) {
    for (ll i = 0; i < N; i++) par[i] = i;
  }

  ll find(ll x) { return par[x] == x ? x : par[x] = find(par[x]); }

  bool same(ll x, ll y) { return find(x) == find(y); }

  ll size(ll x) { return sizes[find(x)]; }

  void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
    cnt--;
  }

  ll count() const { return cnt; }
};

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

  vvll eds(n);

  rep(i, n) {
    ll u, k;
    cin >> u >> k;
    u--;
    rep(j, k) {
      ll v;
      cin >> v;
      v--;
      eds[u].push_back(v);
    }
  }

  vll dist(n, -1);
  queue<ll> q;
  q.push(0);
  dist[0] = 0;
  while (!q.empty()) {
    ll u = q.front();
    q.pop();
    for (auto& v : eds[u]) {
      if (dist[v] == -1) {
        dist[v] = dist[u] + 1;
        q.push(v);
      }
    }  // v
  }

  rep(i, n) printf("%lld %lld\n", i + 1, dist[i]);

  return 0;
}



Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
const int MAXN=110;
int N,K,A[MAXN];char s[MAXN];
int main()
{
	scanf("%s",s+1);
	N=strlen(s+1);
	cin>>K;
	for (int i=1;i<=N;++i) A[i]=s[i]-'0';
	long long Ans=0;
	if (K==1)
	{
		Ans+=A[1];
		for (int i=2;i<=N;++i) Ans+=9;
	}
	else if (K==2)
	{
		Ans+=(A[1]-1)*(N-1)*9;
		int p=-1;
		for (int i=2;i<=N;++i) if (A[i]) {p=i;break;}
		if (p!=-1)
		{
			Ans+=A[p];
			for (int i=p+1;i<=N;++i) Ans+=9;
		}
		for (int i=2;i<=N;++i)
			for (int j=i+1;j<=N;++j)
				Ans+=9*9;
	}
	else
	{
		Ans+=(A[1]-1)*((N-1)*(N-2)/2)*9*9;
		int p=-1;
		for (int i=2;i<=N;++i) if (A[i]) {p=i;break;}
		if (p!=-1)
		{
			Ans+=(A[p]-1)*(N-p)*9;
			int pp=-1;
			for (int i=p+1;i<=N;++i) if (A[i]) {pp=i;break;}
			if (pp!=-1)
			{
				Ans+=A[pp];
				for (int i=pp+1;i<=N;++i) Ans+=9;
			}
			for (int i=p+1;i<=N;++i)
				for (int j=i+1;j<=N;++j)
					Ans+=9*9;
		}
		for (int i=2;i<=N;++i)
			for (int j=i+1;j<=N;++j)
				for (int k=j+1;k<=N;++k)
					Ans+=9*9*9;
	}
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    string s,t;
    cin >> s >> t;
    int n = s.size();
    vector<char> v(26,'?');
    rep(i,n) {
        char ns = s[i];
        char nt = t[i];
        if(v[ns-'a'] == '?') {
            rep(j,26) if(v[j] == nt) {
                cout << "No" <<  endl;
                return 0;
            }
            v[ns-'a'] = nt;
        } else {
            if(v[ns-'a'] != nt) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    int cnt = 0;
    rep(i,26) if(v[i] != '?') cnt++;
    cout << "Yes" << endl;
}

Measured memory_bytes: 776
#include <stdio.h>
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main()
{
	long long a,b;
	scanf("%lld%lld",&a,&b);
	long long jia,jian,cheng;
	cheng=a*b;
	jia=a+b;
	jian=a-b;
	
	if ( jia>=jian && jia >=cheng  )
	printf("%lld\n",jia);
	else if(jian>=jia&&jian>=cheng)
	printf("%lld\n",jian);
	else if( cheng>=jia&&cheng>=jian )
	printf("%lld\n",cheng);
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AOJ0012
{
    class Program
    {
        static void Main()
        {
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                var values = line.Split(' ').Select(double.Parse).ToArray();
                var p1 = new Point(values[0], values[1]);
                var p2 = new Point(values[2], values[3]);
                var p3 = new Point(values[4], values[5]);
                var p = new Point(values[6], values[7]);

                Console.WriteLine(InTriangle(p1, p2, p3, p) ? "YES" : "NO");
            }
        }

        public static bool InTriangle(Point p1, Point p2, Point p3, Point p)
        {
            var v12 = new Vector(p1, p2);
            var v1P = new Vector(p1, p);
            var v23 = new Vector(p2, p3);
            var v2P = new Vector(p2, p);
            var v31 = new Vector(p3, p1);
            var v3P = new Vector(p3, p);
            var vc1 = v12.Cross(v1P);
            var vc2 = v23.Cross(v2P);
            var vc3 = v31.Cross(v3P);

            if ((vc1.Z > 0 && vc2.Z > 0 && vc3.Z > 0)
                || (vc1.Z < 0 && vc2.Z < 0 && vc3.Z < 0))
            {
                return true;
            }

            return false;
        }
    }

    public class Point
    {
        public double X { get; set; }
        public double Y { get; set; }
        public double Z { get; set; }

        public Point(double x = 0, double y = 0, double z = 0)
        {
            X = x;
            Y = y;
            Z = z;
        }
    }

    public class Vector
    {
        public double X { get; set; }
        public double Y { get; set; }
        public double Z { get; set; }

        public Vector(double x = 0, double y = 0, double z = 0)
        {
            X = x;
            Y = y;
            Z = z;
        }

        public Vector(Point p1, Point p2) : this(p2.X - p1.X, p2.Y - p1.Y, p2.Z - p1.Z)
        {
        }

        public Vector Cross(Vector other)
        {
            var x = Y*other.Z - Z*other.Y;
            var y = Z * other.X - X * other.Z;
            var z = X * other.Y - Y * other.X;

            return new Vector(x, y, z);
        }
    }
}

Measured memory_bytes: 6120
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  cin >> N;
  ;
}
int dp[MX + 1333];
void solve() {
  dp[0] = 1;
  rep(i, 0, N) {
    if (dp[i]) {
      dp[i + 100] = 1;
      dp[i + 101] = 1;
      dp[i + 102] = 1;
      dp[i + 103] = 1;
      dp[i + 104] = 1;
      dp[i + 105] = 1;
    }
  }

  cout << dp[N] << endl;

  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 1024
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e4+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    ll n;
    cin>>n;
    string res;
    while(n--){
        res+=('a'+n%26);
        n/=26;
    }
    reverse(allv(res));
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}


Measured memory_bytes: 3652
#include <cstdio>

int main(){
	char Ans[256]={};
	for(int i=0;i<3;i++){
		char Temp[256]={};
		scanf(" %s",&Temp);
		Ans[i]=Temp[0]+('A'-'a');
	}
	Ans[3]=NULL;
	printf("%s\n",Ans);
	return 0;
}

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

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        scanf("%d", &b[i]);
    }
    sort(b.begin(), b.end());
    for (int i = 0; i < n; i++) {
        scanf("%d", &c[i]);
    }
    sort(c.begin(), c.end());

    vector<long long> db(n);
    for (int i = 0; i < n; i++) {
        int cnt = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        if (i > 0) {
            db[i] = db[i - 1];
        }
        db[i] += cnt;
    }

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        int last = lower_bound(b.begin(), b.end(), c[i]) - b.begin();
        last--;
        if (last != -1) {
            ans += db[last];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
using namespace std;;
int main(){
  char a1,a2,a3,b1,b2,b3;
  cin >>a1>>a2>>a3;
  cin >> b1>>b2>>b3;
int flag=0;
  if(a1==b3){
if(a2==b2){
if(a3==b1){
flag=1;
  cout <<"YES";}
}
}
    if(flag==0){
    cout <<"NO";
    }
return 0;
}

Measured memory_bytes: 764
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, int> LP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

bool dp[3005][3005];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	dp[0][0] = true;
	double ans = -1.0;
	int wat = 0, sug = 0;
	rep(i,f+1){
		rep(j,f+1){
			if(!dp[i][j]) continue;
			if(i+j <= f && i+j != 0){
				double milk = (double)(100 * j) / (double)(i + j);
				if(milk > ans){
					wat = i + j;
					sug = j;
					ans = milk;
				}
			}
			if(i+100*a <= f) dp[i+100*a][j] = true;
			if(i+100*b <= f) dp[i+100*b][j] = true;
			if(i+j+c <= f && j+c <= e*i/100) dp[i][j+c] = true;
			if(i+j+d <= f && j+d <= e*i/100) dp[i][j+d] = true;
		}
	}
	cout << wat << " " << sug << endl;
	return 0;
}

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

using namespace std;

struct edge {
	int from;
	int to;
	int w;
};


int const N = 1234567;

vector<edge> edges[N];
int d[N];
int was[N];

void dfs(int v, int val) {
	d[v] = val;
	was[v] = true;
	for (auto &e : edges[v]) {
		if (!was[e.to]) {
			dfs(e.to, val + e.w);
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int v, u, d;
		cin >> v >> u >> d;
		--v;
		--u;
		edges[v].push_back({v, u, d});
		edges[u].push_back({u, v, -d});
	}
	for (int i = 0; i < n; i++) was[i] = false;
	for (int i = 0; i < n; i++) {
		if (!was[i]) {
			dfs(i, 0);
		}
	}
	for (int i = 0; i < n; i++) {
		for (auto &e : edges[i]) {
			if (d[e.from] + e.w != d[e.to]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes\n";
}


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

 string S, T;
 void input() {
 cin >> S >> T;
 }

 void solve() {
 T.pop_back();
 if(S == T) cout << "Yes" << endl;
 else cout << "No" << endl;
 }

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


Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb(x) (x&-(x))
const int N = 101010;

//int num[205];
int cnt(int x)
{
	int ans=0;
	while(x){
		if(x/2&&x%2==0) 
		{
		ans++;
		x/=2;
		}
		else break;
	}
	return ans; 
}
int main(){
	int n;
	int num;
	int minn=999999;
	int tmp;
	cin>>n;
	for(int i=0;i<n;i++) 
	{
		scanf("%d",&num);
		tmp=cnt(num);
		minn=min(tmp,minn);
	}

	cout<<minn<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <tuple>
#include <map>
#include <algorithm>
using namespace std;
using ll = int64_t;
using lll = tuple<ll,ll,ll>;

ll LSB(ll n) { return n&(-n); }
struct Fenwick {
  Fenwick(ll n) : A(n+1) {}
  void add(ll i, ll x) {
    while(i<A.size()) {
      A[i] += x;
      i += LSB(i);
    }
  }
  ll query(ll i) {
    ll ans = 0;
    while(i>0) {
      ans += A[i];
      i -= LSB(i);
    }
    return ans;
  }
  vector<ll> A;
};

int main() {
  // A[i] = previous occurence of C[i], else -1
  // Sort the queries!
  // Query(L,R) = number of A[i]<L
  // Initially only the first occurence of each color counts
  // As we increase L, the element occurence of C[L] counts

  ll n,q;
  cin >> n >> q;
  //cerr << "n=" << n << " q=" << q << endl;
  vector<ll> C(n, 0);
  vector<lll> Q;
  vector<ll> NEXT(n, -1);
  map<ll,ll> PREV;
  Fenwick F(n);

  for(ll i=0; i<n; i++) {
    cin >> C[i];
  }
  //cerr << "READ C" << endl;
  for(ll i=0; i<n; i++) {
    if(PREV.count(C[i])==0) {
      F.add(i+1, 1);
    } else {
      ll previ = PREV[C[i]];
      NEXT[previ] = i;
    }
    PREV[C[i]] = i;
  }
  //cerr << "COMPUTED NEXT" << endl;

  for(ll i=0; i<q; i++) {
    ll a,b;
    cin >> a >> b;
    a--; b--;
    Q.push_back({a,b,i});
  }
  //cerr << "READ Q" << endl;

  sort(Q.begin(), Q.end());
  vector<ll> QA(q, 0);
  ll st = 0;
  for(ll i=0; i<q; i++) {
    auto [a,b,qi] = Q[i];
    //cerr << " i=" << i << " a=" << a << " b=" << b << " qi=" << qi << endl;
    while(st < a) {
      if(NEXT[st]>=0) {
        F.add(NEXT[st]+1, 1);
      }
      st++;
    }
    QA[qi] = F.query(b+1)-F.query(a);
  }
  for(ll i=0; i<q; i++) {
    cout << QA[i] << endl;
  }
}


Measured memory_bytes: 62456
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

bool kaibun(int n){
  VEC<int> a;
  while(n>0){
    a.push_back(n%10);
    n/=10;
  }
  bool ok = 1;
  int m = a.size();
  REP(i,0,a.size()/2+1){
    if(a[i]!=a[m-i-1])ok=0;
  }
  return ok;
}
int main() {
  int a,b;
  cin>>a>>b;
  int cnt = 0;
  REPC(i,a,b){
    if(kaibun(i))++cnt;
  }
  cout<<cnt<<endl;


  return 0;
}


Measured memory_bytes: 384
#if 0
17:43
#endif
#include <iostream>
#include <vector>
#include <unordered_map> 
#define int long long
using namespace std;
int N, M, H[1500], W[1500], sumH[1501], sumW[1501];
int solve(){
    vector<int> dH;
    for(int i=0; i<N; i++){
        for(int j=i; j<N; j++){
            dH.push_back(sumH[j+1]-sumH[i]);
        }
    }
    vector<int> dW;
    for(int i=0; i<M; i++){
        for(int j=i; j<M; j++){
            dW.push_back(sumW[j+1]-sumW[i]);
        }
    }
    unordered_map<int,int> mul;
    unordered_map<int,int> dub;
    for(auto itr=dH.begin(); itr!=dH.end(); ++itr){
        mul[*itr]+=1;
        dub[*itr]=0;
    }
    for(auto itr=dW.begin(); itr!=dW.end(); ++itr){
        auto t = mul.find(*itr);
        if(t != mul.end()){
            dub[*itr]+=1;
        }
    }
    int count = 0;
    auto itr_m = mul.begin();
    for(auto itr_d=dub.begin(); itr_d!=dub.end(); ++itr_d){
        count += itr_m->second * itr_d->second;
        ++itr_m;
    }
    #if 0
    for(auto itr=dH.begin(); itr!=dH.end(); ++itr){
        cout << *itr << ", ";
    }cout << endl;
    for(auto itr=dW.begin(); itr!=dW.end(); ++itr){
        cout << *itr << ", ";
    }cout << endl;
    for(auto itr=mul.begin(); itr!=mul.end(); ++itr){
        cout << itr->first << ": " << itr->second << ", ";
    }cout << endl;
    for(auto itr=dub.begin(); itr!=dub.end(); ++itr){
        cout << itr->first << ": " << itr->second << ", ";
    }cout << endl;
    #endif

    return count;
}
signed main(){
    while(cin >> N >> M && N > 0){
        sumH[0] = 0;
        for(int i=0; i<N; i++){
            cin >> H[i];
            sumH[i+1] = sumH[i] + H[i];
        }
        sumW[0] = 0;
        for(int i=0; i<M; i++){
            cin >> W[i];
            sumW[i+1] = sumW[i] + W[i];
        }
        cout << solve() << endl;
    }
}


Measured memory_bytes: 38868
//ITNOA
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <iomanip>

using namespace std;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

#define rep(i, s, e) for(int i = s; i < e; i ++)
#define X first
#define Y second

typedef long long ll;
typedef long double ld;

const int maxN = 100*1000 + 5;
const int mod = 1000*1000*1000 + 7;
const int base = 701;
const int SQ = 500;
const int maxL = 20;


int a[maxN];

int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];

	int ans = 0;
	for(int i = 1; i <= n; i ++)
		if(a[a[i]] == i)
			ans ++;

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


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

int main(){
	string S; cin >> S;
	int	max_cnt = 0;
	int	cnt = 0;
	for (char c:S)
	{
		if(c=='A'||c=='C'||c=='G'||c=='T')
		{
			cnt += 1;

			if (cnt > max_cnt)
			{
				max_cnt = cnt;
			}
		}else{
			cnt = 0;
		}
	}

	cout << max_cnt << endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int i = 0;
  while(1){
      i += N;
      if ((i % N ==0) && (i % 2 == 0)) {
          cout << i << endl;
          return 0;
      }
  }
}


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

#define ll long long int
#define debug(c) cout << #c << " = " << c << endl;

int main()
{
  ll flag=0,i;
  string s;
  cin>>s;
  for(i=0;i<s.length();i++)
  {
    if(s[i]=='7')
    {
        flag=1;
        cout<<"Yes";
        break;
    }
  }
  if(flag==0)
  {
      cout<<"No";
  }
  return 0;
}


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

int main() {
    int N, K;
    string S;

    cin >> N;
    cin >> S;
    cin >> K;

    for(int i = 0; i < S.length(); i++) {
        if(S[i] != S[K - 1])
            S[i] = '*';
    }

    cout << S;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

using ll = long long;
template <ll MOD = 1000000007>
struct Mint{
    ll x;

    Mint() : x(0) {}
    Mint(ll t){
        x = t % MOD;
        if(x < 0) x += MOD;
    }
    
    Mint pow(ll n){
        Mint res(1), t(x);
        while(n > 0){
            if(n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        ll a = x, b = MOD, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint & operator += (Mint a){
        x += a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    Mint & operator -= (Mint a){
        x += MOD - a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    Mint & operator *= (Mint a){
        x = 1LL * x * a.x % MOD;
        return *this;
    }
    Mint & operator /= (Mint a){
        return (*this) *= a.inv();
    }

    Mint operator + (Mint a) const { return Mint(x) += a; }
    Mint operator - (Mint a) const { return Mint(x) -= a; }
    Mint operator * (Mint a) const { return Mint(x) *= a; }
    Mint operator / (Mint a) const { return Mint(x) /= a; }

    Mint operator - () const{ return Mint(-x); }

    bool operator == (const Mint a){ return x == a.x; }
    bool operator != (const Mint a){ return x != a.x; }
    bool operator < (const Mint a){ return x < a.x; }

    friend ostream & operator << (ostream & os, const Mint &a){
        return os << a.x;
    }

    friend istream & operator >> (istream & is, Mint &a){
        ll t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

signed main(){
    int n;
    cin >> n;
    vector<int> man[n];
    REP(i,n){
        REP(j,n){
            int a;
            cin >> a;
            if(a == 1) man[i].emplace_back(1 << j);
        }
    }
    Mint<> dp[1 << n];
    dp[0] = 1;
    for(int S = 0; S < (1 << n) - 1; S++){
        int i = __builtin_popcount(S);
        for(int woman : man[i]){
            if(S & woman) continue;
            dp[S | woman] += dp[S];
        }
    }
    cout << dp[(1 << n) - 1] << endl;
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define loop1(x,s,e) for(int x=s;x!=e;x+=1-2*(s>e))
#define input_matrix(a,m,n) for(int i=0;i<m;i++)for(int j=0;j<n;j++)cin>>a[i][j];
#define input_array(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define all(x) x.begin(),x.end()
#define newl "\n"
#define tests(t) int t; cin>>t; while(t--)
#define speed ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
 {
     speed;
     int n,m,a;
     cin>>n>>m;
     priority_queue<int> q;
     for(int i=0;i<n;i++)
     {
         cin>>a;
         q.push(a);
     }
     for(int i=0;i<m;i++)
     {
         a=q.top(); q.pop();
         a/=2;
         q.push(a);
     }
	long long int ans=0;
	while(!q.empty())
	{
	    ans+=q.top(),q.pop();
	}
	cout<<ans<<newl;
	return 0;
}

Measured memory_bytes: 892
def f(x):
    if x%2:
        if x%4==1:
            return 1
        else:
            return 0
    if x%4==2:
        return x+1
    else:
        return x

def solve():
    a,b = map(int,input().split())
    print(f(a-1)^f(b))
if __name__=='__main__':
    solve()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

void slove(int n, int m){
	vint tmph(1501);
	vint h(1500001);//?????±?????????????????????
	vint tmpw(1501);
	vint w(1500001);

	//??\???
	rep(i, n) scanf("%d", &tmph[i]);
	rep(i, m) scanf("%d", &tmpw[i]);

	for (int i = 0; i < n; ++i){
		int len = 0;
		for (int j = i; j < n; ++j){
			len += tmph[j];
			h[len]++;
		}
	}

	for (int i = 0; i < m; ++i){
		int len = 0;
		for (int j = i; j < m; ++j){
			len += tmpw[j];
			w[len]++;
		}
	}

	ll sum = 0;
	rep(i, 1500001){
		sum += h[i] * w[i];
	}

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

int main(void){
	int n, m;
	while(1){
		scanf("%d %d", &n, &m);
		if(n == 0) break;
		slove(n, m);
	}
	return 0;
}

Measured memory_bytes: 14588
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	long long int j,n,i,a[101],dp[102][21]={0};
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		if(i==1)
		{
			dp[1][a[i]]=1;
		}
	}
	for(i=1;i<=n-1;i++)
	{
		for(j=0;j<21;j++)
		{
			if(dp[i][j]>=1)
			{
				if(j+a[i+1]<=20)
				{
					dp[i+1][j+a[i+1]]=dp[i+1][j+a[i+1]]+dp[i][j];
				}
				if(j-a[i+1]>=0)
				{
					dp[i+1][j-a[i+1]]=dp[i+1][j-a[i+1]]+dp[i][j];
				}
			}
		}
	}
	cout<<dp[n-1][a[n]]<<endl;
	return 0;
}

Measured memory_bytes: 3096
n, k = map(int, input().split())
p = list(map(int, input().split()))

p_sum = [0] * (n + 1)

for i in range(n):
    p_sum[i + 1] = p_sum[i] + p[i]

ans = 0
for i in range(n - k + 1):
    ans = max(ans, p_sum[i + k] - p_sum[i])

ans = (ans + k) / 2
print(ans)

Measured memory_bytes: 25060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    string s, t;
    ll a, b;
    string u;

    cin >> s >> t >> a >> b >> u;

    if(s == u){
        a--;
    }else{
        b--;
    }

    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Console;

class Program {
    static void Main() {
        var n = NextInt();
        var way = 0;
        var pre = 0;
        var ans = 1;

        for (var i = 0; i < n; i++) {
            var now = NextInt();
            if (i == 0 || now - pre == 0) {
                //pass
            } else if (way == 0) {
                way = Math.Sign(now - pre);
            } else if (Math.Sign(now - pre) != way) {
                ans++;
                way = 0;
            }
            pre = now;
        }
        WriteLine(ans);
    }

    static int NextInt() {
        return int.Parse(NextString());
    }

    static string NextString() {
        var result = new List<char>();
        while (true) {
            int next = Read();
            if (next < 0)
                break;
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
                result.Add(nextChar);
            else if (nextChar != '\r')
                break;
        }
        return string.Join("", result);
    }
}

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

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

using namespace std;

/////////////////////////////////////////////////////
#define r3 0.57735026918962576450914878050196
//#define s3 1.7320508075688772935274463415059
#define INF 1e12
#define pdl pair<double,ll>
ll n, K,x[10101],y[10101];
vector<pdl> av, bv;
//vector<ll> cv;
ll i, j,mk[101010];
double ans;

int main(){
    while(true){
        ans = INF;
        scanf("%lld",&n);
        if(n==0)
            break;
        scanf("%lld", &K);
        K = n - K;
        av.resize(n);
        bv.resize(n);
        fornum(i,0,n){
            scanf("%lld%lld", &x[i], &y[i]);
            av[i] = mp(x[i] - y[i] * r3, i);
            bv[i] = mp(x[i] + y[i] * r3, i);
        }
        sort(av.begin(), av.end());
        sort(bv.begin(), bv.end());
        fornum(i,0,n){
            ll l = 0, r = 0,kk=0;
            ll yy = y[i];
            fornum(j,0,n){
                mk[j] = 0;
            }
            fornum(l, 0, n){
                if (y[av[l].second] < yy)
                    continue;
                while(r<n&&kk<K){
                    ll ii = bv[r].second;
                    if(yy<=y[ii]&&mk[ii]!=2){
                        mk[ii] = 1;
                        kk++;
                    }
                    r++;
                }
                if(kk<K)
                    break;
                ll li = av[l].second;
                if(mk[li]==1){
                    ll ri = bv[r-1].second;
                    double aaa = (x[ri] + (y[ri] - yy) * r3) - (x[li] - (y[li] - yy) * r3);
                    if(aaa<ans)
                        ans = aaa;
                    kk--;
                }else{
                    double aaa = (x[li] + (y[li] - yy) * r3) - (x[li] - (y[li] - yy) * r3);
                    if(aaa<ans)
                        ans = aaa;
                }
                mk[li] = 2;
            }
        }

        printf("%.10lf\n", ans*3);
    }
    return 0;
}


Measured memory_bytes: 3536
import java.util.Scanner;

public class Main {
    public static int valid(long x, long y,long z,long n){
        return (z*z+x*x+y*y+y*z+x*y+x*z==n?1:0);
    }
    public static int solve(int n){
        int ans=0;
        for (long x = 1; x*x+x*2 <= n ; x++) {
            for (long y = 1; y*y+x*y+x*x+x+y <= n ; y++) {
                for (long z = 1; z*z+x*x+y*y+y*z+x*y+x*z<= n ; z++) {
                    ans+= valid(x,y,z,n);
                }
            }
        }
        return ans;
    }
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int n;
        n = scan.nextInt();
        for (int i = 1; i <= n ; i++) {
            System.out.println(solve(i));
        }
    }
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a>12)
    cout << b << endl;
  else if(a<=12 and a>5)
    	cout << b/2 << endl;
  else
    cout << 0 << endl;
 return 0; 
}

Measured memory_bytes: 256
# coding: utf-8

if __name__ == "__main__":

    k = int(input())
    n = 50

    x, y = k//n, k%n

    ans = [i + x for i in range(n)]

    for i in range(n):
        if i <= y-1:
            ans[i] += n-y+1
        else:
            ans[i] -= y

    print(n)
    print(' '.join(map(str, ans)))


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

int main(){	
	double PI = 3.14159265358979;
	double r;
	cin >> r;
	cout << fixed << setprecision(20) << r * r * PI << " "  << setprecision(20) << 2 * r * PI << endl;
	return 0;
}


Measured memory_bytes: 3252
using System;


public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var w = int.Parse(line[0]);
        
        var h = int.Parse(line[1]);
        var x = int.Parse(line[2]);
        var y = int.Parse(line[3]);
        var r = int.Parse(line[4]);
        if ((r <= x && x <= w - r) && (r <= y & y <= h - r)) Console.WriteLine("Yes");
        else Console.WriteLine("No");


    }
}

Measured memory_bytes: 8876