akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<vector>
#include<map>
#include<queue>

#define N 300005
#define M 8000005

#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)

#define mk make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

int i,j,m,n,p,k,f[2005][2005],ans,C[2005][2005];

char c[2005];

#define Mo 998244353

int main()
{
		scanf("%s",c+1);
		n=strlen(c+1);
		f[0][0]=1;
		for (i=0;i<2005;++i)
		{
				C[i][0]=1;
				for(j=1;j<=i;++j) C[i][j]=(C[i-1][j]+C[i-1][j-1])%Mo;
		}
		for (i=0;i<n;++i)
			for (j=0;j<=i;++j)
					if (f[i][j])
				{
						int a=j,b=i-j;
						if (c[i+1]=='0') a+=2;
						if (c[i+1]=='1') a++,b++;
						if (c[i+1]=='2') b+=2;
						if (a>0) (f[i+1][a-1]+=f[i][j])%=Mo;
						if (b>0) (f[i+1][a]+=f[i][j])%=Mo;
				}
		for (i=0;i<=n;++i) if (f[n][i]) (ans+=1ll*f[n][i]*C[n][i]%Mo)%=Mo;
		printf("%d\n",ans);
}


Measured memory_bytes: 30720
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

    ll A, B;
    cin >> A >> B;
    cout << 6 - A - B << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 100000 + 1000;
const int INF = 0x1f1f1f1f;

int n;
typedef pair<int, int> pii;
vector<pii> edg[MAXN];

int root = 0;
int mx[MAXN], sz[MAXN];

void find_root(int x, int fa)
{
	sz[x] = 1, mx[x] = 0;
	for(int i = 0; i < edg[x].size(); i++)
		if(edg[x][i].first != fa)
		{
			int y = edg[x][i].first;
			find_root(y, x);
			sz[x] += sz[y];
			mx[x] = max(mx[x], sz[y]);
		}
	mx[x] = max(mx[x], n - sz[x]);
	if(mx[x] < mx[root])
		root = x;
}

long long ans = 0;

void dfs(int x, int fa)
{
	sz[x] = 1;
	for(int i = 0; i < edg[x].size(); i++)
		if(edg[x][i].first != fa)
		{
			int y = edg[x][i].first;
			dfs(y, x);
			ans += (long long)edg[x][i].second * sz[y] * 2;
			sz[x] += sz[y];
		}
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n;
	for(int i = 1; i <= n - 1; i++)
	{
		int x, y, z;
		cin >> x >> y >> z;
		edg[x].push_back(make_pair(y, z));
		edg[y].push_back(make_pair(x, z));
	}

	root = 0, mx[root] = n;
	find_root(1, 0);
	dfs(root, 0);
	// cerr << root << ' ' << ans << endl;
	bool flag = false;
	int mn = INF;
	for(int i = 0; i < edg[root].size(); i++)
		if(sz[edg[root][i].first] == (n + 1) / 2)
		{
			ans -= edg[root][i].second;
			flag = true;
			break;
		}
		else
			mn = min(mn, edg[root][i].second);
	if(!flag)
		ans -= mn;
	// cerr << flag << endl;

	cout << ans << endl;


	return 0;
}


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

constexpr auto m_gcd(size_t m, size_t n){
    if(m == 0){
        return n;
    }else if(n == 0){
        return m;
    }else{
        return m_gcd(n, m % n);
    }
}

int main(){

    size_t n, x;
    std::cin >> n >> x;

    std::vector<size_t> xi(n);
    for(auto&& e : xi){
        std::cin >> e;
    }

    std::vector<size_t> diff;
    for(const auto& e : xi){
        diff.emplace_back(std::max(e, x) - std::min(e, x));
    }

    size_t ans = diff[0];
    for(const auto& e : diff){
        ans = m_gcd(ans, e);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 2168
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#define MAXN 100006
#define INF 2100000000
using namespace std;
int a[MAXN],ok,n,l[MAXN],r[MAXN],u,k,v,p;
vector<int> road[MAXN];
void DFS1(int x,int father,int deep)
{
	if(a[x]!=-INF)
	{
		if(ok==-1) ok=((a[x]+deep)%2+2)%2;
		if(ok!=((a[x]+deep)%2+2)%2)
		{
			printf("No");
			exit(0);
		}
	}
	for(int i=0;i<(int)road[x].size();i++)
	{
		int nex=road[x][i];
		if(nex==father) continue;
		DFS1(nex,x,1+deep);
	}
}
void check(int v,int u)
{
	l[u]=max(l[u],l[v]-1);
	r[u]=min(r[u],r[v]+1);
	if(l[u]>r[u])
	{
		printf("No");
		exit(0);
	}
}
int DFS2(int x,int father)
{
	if(a[x]!=-INF) l[x]=r[x]=a[x];
	else l[x]=-INF,r[x]=INF;
	for(int i=0;i<(int)road[x].size();i++)
	{
		int nex=road[x][i];
		if(nex==father) continue;
		if(DFS2(nex,x)) check(nex,x);
	}
	if(l[x]==-INF&&r[x]==INF) return 0;
	return 1;
}
void DFS3(int x,int father)
{
	if(father) check(father,x);
	if(a[x]==-INF) a[x]=r[x];
	for(int i=0;i<(int)road[x].size();i++)
	{
		int nex=road[x][i];
		if(nex==father) continue;
		DFS3(nex,x);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		road[u].push_back(v);
		road[v].push_back(u);
	}
	for(int i=1;i<=n;i++)
		a[i]=-INF;
	scanf("%d",&k);
	for(int i=1;i<=k;i++)
	{
		scanf("%d%d",&v,&p);
		a[v]=p;
	}
	ok=-1;
	DFS1(1,0,0);
	DFS2(1,0);
	printf("Yes");
	DFS3(1,0);
	for(int i=1;i<=n;i++)
		printf("\n%d",a[i]);
}

Measured memory_bytes: 15360
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;
 
int main(){
	ll n;
  	cin >> n;
  	
  	ll ans = 1e18;
	for(ll i = 1; i*i <= n; i++){
    	if(n%i != 0) continue;
      	ll j = n/i;
       	ans = min(ans, i+j-2);
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using s64 = signed long long;
using u64 = unsigned long long;
using f128 = long double;

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

    s64 minCount = t.size();
    for(s64 i = 0; i <= s.size() - t.size(); i++)
    {
        string subS = s.substr(i, t.size());
        s64 count = 0;
        for(s64 j = 0; j < t.size(); j++)
        {
            if(t[j] != subS[j])
            {
                count++;
            }
        }

        minCount = min(minCount, count);
    }

    cout << minCount << endl;

    return 0;
}


Measured memory_bytes: 3604
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    str s;
    cin >> s;
    rep(i, 19) {
        if(s[i] == ',') {
            cout << " ";
        }
        else {
            cout << s[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll L, R;

int main() {
	scanf("%lld %lld", &L, &R);
	ll iniRef = 2019 - (L % 2019);
	ll diff = R - L;
	if(diff >= iniRef) {
		printf("0\n");
	}	
	else {
		// ll ans = (((L %  2019) * ((L + 1) % 2019)) % 2019);
		// ll ans = (L * (L + 1)) % 2019;
		ll ans = 1e13;
		for(long long i = L; i < R; i++) {
			for(long long j = i + 1; j <= R; j++) {
				if(((i * j) % 2019) < ans) {
					ans = (i * j) % 2019;
				}
			}
			// cout << "ues";
			// cout << (i * (i + 1)) % 2019 << " "; 
		}
		printf("%lld\n", ans);
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    ll K;
    cin>>K;
    const int N = 50;
    vector<ll> A(N);
    REP(i, N) A[i] = i + (K/N);
    K = K % N;
    for(int i=0; i<K; i++){
        ll mxi = 0;
        ll mxv = A[0];
        ll mni = 0;
        ll mnv = A[0];
        REP(j, N){
            if(mxv<A[j]) mxv = A[j], mxi = j;
            if(mnv>A[j]) mnv = A[j], mni = j;
            A[j]--;
        }
        A[mni] += N+1;
    } 
    cout << N << endl;
    cout << A << endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut c = [0; 26];
    let w = atcoder::read_single_string();

    for wc in w.chars() {
        let i = (wc as u8) - ('a' as u8);
        c[i as usize] += 1;
    }

    if c.iter().all(|i| i % 2 == 0) {
        println!("Yes");
    } else {
        println!("No");
    }
}

#[allow(dead_code)]
mod atcoder {
    pub fn read_single_num<T: ::std::str::FromStr>() -> T
        where <T as ::std::str::FromStr>::Err: ::std::fmt::Debug {
            let mut buffer = String::new();
            ::std::io::stdin().read_line(&mut buffer).unwrap();
            buffer.trim().parse().unwrap()
    }

    pub fn read_multiple_num<T: ::std::str::FromStr>() -> Vec<T>
        where <T as ::std::str::FromStr>::Err: ::std::fmt::Debug {
            let mut buffer = String::new();
            ::std::io::stdin().read_line(&mut buffer).unwrap();
            buffer.split_whitespace().map(|i| i.parse().unwrap() ).collect()
    }

    pub fn read_single_string() -> String {
            let mut buffer = String::new();
            ::std::io::stdin().read_line(&mut buffer).unwrap();
            buffer.trim().to_string()
    }

    pub fn read_multiple_string() -> Vec<String> {
            let mut buffer = String::new();
            ::std::io::stdin().read_line(&mut buffer).unwrap();
            buffer.split_whitespace().map(|s| s.to_string() ).collect()
    }
}


Measured memory_bytes: 380
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk)
{
  var text = chunk.trim();
  var x = [];
  for (var i = 97; i <= 122; i++) {
    x[String.fromCharCode(i)] = 0; 
  }

  for (i = 0; i < text.length; i++) {
    var c = text.charAt(i).toLowerCase();
    var cCode = c.charCodeAt(0);
    if (cCode >= 97 && cCode < 123) {
      x[c] += 1;
    }
  }

  for (var i =97; i <=122; i++) {
    console.log(String.fromCharCode(i), ":", x[String.fromCharCode(i)]);
  }
});

Measured memory_bytes: 15928
n = int(input())
ab = set(tuple(map(int, input().split())) for _ in range(n))
cd = sorted(tuple(map(int, input().split())) for _ in range(n))
ab |= {(-1, -1)}

ans = 0
for c, d in cd:
    tmp = max((b, a) for a, b in ab if (a < c and b < d))
    if tmp != (-1, -1):
        ab.remove(tmp[::-1])
        ans += 1
print(n - (len(ab) - 1))


Measured memory_bytes: 67656
a,b,c,x,y = [int(x) for x in input().split()]

#そのまま
aprice = a*x + b*y
#組み合わせ
if x > y:
    amari = a*(x-y)
elif x < y:
    amari = b*(y-x)
else:
    amari = 0
bprice = min(x,y)*c*2 + amari
#セットのみ
cprice = c*max(x, y)*2

#print(aprice,bprice,cprice)
print(min(aprice,bprice,cprice))

Measured memory_bytes: 3064
A,B,C = map(int, input().split())
ans = 0 
while 1:
  if (A%2,B%2,C%2) == (0,0,0):
    if A == B == C:
      print(-1)
      break
    else:
      ans += 1
      A,B,C = (B+C)//2,(C+A)//2,(A+B)//2
  else:
    print(ans)
    break

Measured memory_bytes: 3060
import java.util.*;

public class Main {
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		if (0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#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))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;
int p[maxn];
void run_case()
{
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> p[i];
    }
    sort(p + 1, p + 1 + n);
    int ans = 0;
    for (int i = 1; i <= k; i++)
    {
        ans += p[i];
    }
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3616
// Kagami Mochi

#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int N;
	cin >> N;
	int d[N];
	for (int i = 0; i < N; ++i)
		cin >> d[i];

	sort(d, d+N);
	reverse(d, d+N);

	int maxv = 101, res = 0;

	for (int i = 0; i < N; ++i){
		if (d[i] < maxv){
			maxv = d[i];
			res++;
		}
	}

	cout << res << endl;

	return 0;
}


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

static inline int min(const int a, const int b) {
  return a < b ? a : b;
}
static inline int max(const int a, const int b) {
  return a > b ? a : b;
}

#define Z 2001

int IMOS[Z][Z];
int N, K;

static inline void g(const int x_from, const int x_to, const int y_from, const int y_to) {
  IMOS[x_from][y_from] += 1;
  IMOS[x_to][y_from] -= 1;
  IMOS[x_from][y_to] -= 1;
  IMOS[x_to][y_to] += 1;
}

void f(const int x_from, const int x_to, const int y_from, const int y_to) {
  g(x_from, min(x_to, 2*K), y_from, min(y_to, 2*K));
  if (x_to > 2*K && y_to > 2*K) {
    g(0, x_to-2*K, 0, y_to-2*K);
    g(0, x_to-2*K, y_from, 2*K);
    g(x_from, 2*K, 0, y_to-2*K);
  } else if (x_to > 2*K) {
    g(0, x_to-2*K, y_from, y_to);
  } else if (y_to > 2*K) {
    g(x_from, x_to, 0, y_to-2*K);
  }
}

int main(void) {
  scanf("%d %d\n", &N, &K);

  for (int i = 0; i < N; ++i) {
    int x_from, y_from;
    char c;
    scanf("%d %d %c", &x_from, &y_from, &c);

    int x_add = c == 'W' ? 0 : K;
    x_from = (x_from + x_add) % (2*K);
    y_from %= 2*K;

    int x_to = x_from + K;
    int y_to = y_from + K;
    f(x_from, x_to, y_from, y_to);

    int x_from1 = x_from + K;
    int x_to1 = x_to + K;
    int y_from1 = y_from + K;
    int y_to1 = y_to + K;
    if (x_from1 >= 2*K) {
      x_from1 %= 2*K;
      x_to1 %= 2*K;
    }
    if (y_from1 >= 2*K) {
      y_from1 %= 2*K;
      y_to1 %= 2*K;
    }
    f(x_from1, x_to1, y_from1, y_to1);
  }

  for (int x = 0; x < Z; ++x)
    for (int y = 1; y < Z; ++y)
      IMOS[x][y] += IMOS[x][y-1];

  for (int x = 1; x < Z; ++x)
    for (int y = 0; y < Z; ++y)
      IMOS[x][y] += IMOS[x-1][y];

  int ans = 0;
  for (int x = 0; x < Z; ++x)
    for (int y = 0; y < Z; ++y)
      if (IMOS[x][y] > ans)
        ans = IMOS[x][y];
  printf("%d\n", ans);

  return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

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

	vi v(n);
	rep(i, 0, n) cin >> v[i];

	int ans = 0;
	rep(i, 0, min(n, k)+1){
		rep(j, 0, min(n, k)+1-i){
			vi a;
			int t = 0;

			rep(l, 0, i){
				t += v[l];
				if(v[l] < 0) a.pb(v[l]);
			}

			rep(l, 0, j){
				t += v[n-1-l];
				if(v[n-1-l] < 0) a.pb(v[n-1-l]);
			}

			sort(all(a));

			rep(l, 0, min(k-(i+j), (int)a.size())){
				t -= a[l];
			}

			chmax(ans, t);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    char[] s = scanner.next().toCharArray();
    int n = s.length;
    int[] a = new int[n + 1];
    for (int i = 0; i < n; i++) a[n - i] = s[i] - '0';


    long sum = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= i; j++) {
        long b = 1;
        for (int k = 0; k < j - 1; k++) b *= 10;
        b *= a[i];
        b *= 1 << (n - i);
        if (i - j - 1 > 0) b *= 1 << (i - j - 1);
        sum += b;
      }
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  char c;
  cin>>c;
  if(c=='A') cout<<'T'<<endl;
  else if(c=='T') cout<<'A'<<endl;
  else if(c=='C') cout<<'G'<<endl;
  else cout<<'C'<<endl;
  return 0;
}


Measured memory_bytes: 256
a1,b1= list(map(int,input().split()))
a2,b2= list(map(int,input().split()))
a3,b3= list(map(int,input().split()))

counts = [0,0,0,0]
counts[a1-1]+=1
counts[b1-1]+=1
counts[a2-1]+=1
counts[b2-1]+=1
counts[a3-1]+=1
counts[b3-1]+=1

counts.sort()
if counts[0] ==1 and counts[1] ==1 and counts[2] ==2 and counts[3]==2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3064
// https://atcoder.jp/contests/arc061/tasks/arc061_a

#include <iostream>
#include <string>

using namespace std;

long fs(string num, long sum, int position) {

    long target = atol(num.substr(num.length() - position, position).c_str());

    if (num.length() == position) {
        return sum + target;
    } else {
        return fs(num.substr(0, num.length() - position), sum + target, 1) + fs(num, sum, position + 1);
    }
}

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

    long result = fs(s, 0, 1);
    cout << result << endl;

    return 0;
}

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

using namespace std;

#define MOD 1000000007

int main() {
    int n;

    cin >> n;

    vector<pair<int_fast64_t, int_fast64_t>> a(n);

    for(int i = 0; i < n; ++i) {
        cin >> a.at(i).first >> a.at(i).second;
    }

    map<pair<int_fast64_t, int_fast64_t>, pair<int, int>> mp;
    int_fast64_t g, a1, a2, c0;

    for(int i = 0; i < n; ++i) {
        g = __gcd(a.at(i).first, a.at(i).second);
        if(g == 0) {
            ++c0;
        } else {
            a1 = a.at(i).first / g;
            a2 = a.at(i).second / g;
            if(a2 < 0 || a2 == 0 && a1 < 0) {
                a1 = - a1;
                a2 = - a2;
            }
            if(a1 > 0) {
                mp[make_pair(a1, a2)].first++;
            } else {
                mp[make_pair(a2, -a1)].second++;
            }
        }
    }

    int_fast64_t c = 1, c1, c2;

    for(pair<pair<int_fast64_t, int_fast64_t>, pair<int, int>> p: mp) {
        c1 = 1;
        c2 = 1;
        for(int i = 0; i < p.second.first; ++i) c1 = (c1 << 1) % MOD;
        for(int i = 0; i < p.second.second; ++i) c2 = (c2 << 1) % MOD;
        c = (c * ((c1 + c2 - 1) % MOD)) % MOD;
    }
    c = ((c + c0) % MOD + MOD - 1) % MOD; 

    printf("%ld\n", c);

    return 0;
}

Measured memory_bytes: 18600
#include <iostream>
#include <string>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int mod = 1000000007;
string s;
int n;
int dp[100001][2];

signed main() {
	int i, j;
	
	cin >> s;
	n = s.length();
	
	dp[0][1] = 1;
	rep(i, n) {
		rep(j, 2) {
			//0, 0
			(dp[i + 1][j && (s[i] == '0')] += dp[i][j]) %= mod;
			//0, 1 か 1, 0
			if (j == 1 && s[i] == '0') continue;
			(dp[i + 1][j] += 2 * dp[i][j]) %= mod;
		}
	}
	
	int ans = dp[n][0] + dp[n][1];
	ans %= mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2048
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: usize,
        a: [usize; n],
    };
    println!("{}", a.iter().map(|n| n.trailing_zeros()).min().unwrap());
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main(){
	

	int t = 1;
	//cin >> t;
	while(t--){
		int n, m;
		cin >> n >> m;
		string s;
		s.append(n, ' ');
		//cout << s;
		int a;
		char b;
		int ans = 0;
		for(int i = 0; i < m; ++i){
			cin >> a >> b;
			if(s[a - 1] == ' '){
				s[a - 1] = b;
			}
			else if(s[a - 1] == b){

			}
			else{
				ans = -1;
			}
		}
		if(ans == 0){
			if(n == 1){
				if(s == " "){
					cout << "0";
				}
				else cout << s;
			}
			else{
				if(s[0] == '0'){
					cout << "-1";
					return 0;
				}
				if(s[0] == ' ') s[0] = '1';
				for(int i = 1; i < n; ++i){
					if(s[i] == ' ') s[i] = '0';
				}
				cout << s;	
			}
		}
		else cout << ans;
	}
	return 0;
}

Measured memory_bytes: 256
a,b,c,x,y = list(map(int,input().split()))
m = a*x + b*y
n = max(x, y) * 2*c
d = {x: b, y: a}
v = 2*c*min(x, y) + d[min(x, y)]*abs(x-y)
print(min(m, n, v))



Measured memory_bytes: 9088
#include <stdio.h>
#include <string.h>
int main()
{
	int a = 0,b = 0,n, i, j, flag = 1, temp, minj,samecut = 0;
	char N1[36], B1[36], S1[36], strtemp;
	int N2[36], B2[36], S2[36];
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf(" %c", &N1[i]);
		S1[i] = N1[i];
		B1[i] = N1[i];
		scanf(" %d", &N2[i]);
		S2[i] = N2[i];
		B2[i] = N2[i];
	}
	while (flag) {
		flag = 0;
		for (j = n - 1; j > 0; j--) {
			if (B2[j] < B2[j - 1]) {
				strtemp = B1[j - 1];
				temp = B2[j - 1];
				B1[j - 1] = B1[j];
				B2[j - 1] = B2[j];
				B1[j] = strtemp;
				B2[j] = temp;
				flag = 1;
			}
		}
	}
	flag = 0;
	j = 0;
	for (i = 0; i < n; i++) {
		if (i)printf(" ");
		printf("%c%d", B1[i], B2[i]);
	}
	printf("\n");
	
	if (flag) {
		printf("Not stable\n");
	}
	else {
		printf("Stable\n");
	}
	for (i = 0; i <= n - 1; i++) {
		minj = i;
		for (j = i; j <= n - 1; j++) {
			if (S2[j] < S2[minj]) {
				minj = j;
			}
		}
		strtemp = S1[minj];
		temp = S2[minj];
		S1[minj] = S1[i];
		S2[minj] = S2[i];
		S1[i] = strtemp;
		S2[i] = temp;
	}
	for (i = 0; i < n; i++) {
		if (i)printf(" ");
		printf("%c%d", S1[i], S2[i]);
	}
	printf("\n");
	flag = 0;
	for (i = 0; i < n;i++) {
		if (B1[i] != S1[i]) {
			flag = 1;
		}
	}
	if (flag) {
		printf("Not stable\n");
	}
	else {
		printf("Stable\n");
	}
	return 0;
}


Measured memory_bytes: 2108
// D - Xor Sum 2

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

ll cum_sum[200001];
ll cum_xor[200001];
ll A[200000];

bool is_ok(ll i, ll j) {
	return (cum_sum[j+1] - cum_sum[i]) == (cum_xor[j+1] ^ cum_xor[i]);
}

// [lower, upper) の範囲でis_ok()を満たすような上限のi（存在しない場合は-1）を返す
//   lower: 最小のインデックス
//   upper: 最大のインデックス + 1
ll find_max_ok(ll lower, ll upper) {
	ll ok = lower;
	ll ng = upper;

	while(ng - ok > 1) {
		ll trying = (ng + ok) / 2;

		if (is_ok(lower, trying)) {
			ok = trying;
		} else {
			ng = trying;
		}
	}

	return ok;
}

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

	for (int i=0; i<N; i++) {
		cin >> A[i];
	}

	for (int i=0; i<N; i++) {
		cum_sum[i+1] = cum_sum[i] + A[i];
		cum_xor[i+1] = cum_xor[i] ^ A[i];
	}

	ll ans = 0;

	for (int i=0; i<N; i++) {
		ans += find_max_ok(i, N) - i + 1;
	}

	cout << ans << endl;

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

const ld PI = acos(-1);

void fft(vector<cd>& a, bool invert) {
	int n = a.size();
	if(n == 1) return;
	
	vector<cd> even(n/2), odd(n/2);
	for(int i = 0; 2*i < n; i++) {
		even[i] = a[2*i];
		odd[i] = a[2*i+1];
	}
	
	fft(even, invert);
	fft(odd, invert);
	double ang = 2 * PI / n * (invert ? -1 : 1);
	cd w(1), wn(cos(ang), sin(ang));
	for(int i = 0; 2*i < n; i++) {
		a[i] = even[i] + w * odd[i];
		a[i+n/2] = even[i] - w * odd[i];
		if(invert) {
			a[i] /= 2; // divide by n
			a[i+n/2] /= 2;
		}
		
		w *= wn;
	} 
}

vector<ll> conv(vector<ll>& a, vector<ll>& b) {
	vector<cd> fa(a.begin(), a.end()), fb(b.begin(), b.end());
	assert((fa.size() & (fa.size()-1)) == 0);
	assert((fb.size() & (fb.size()-1)) == 0);

	fft(fa, false);
	fft(fb, false);
	
	for(int i = 0; i < (int) fa.size(); i++) {
		fa[i] *= fb[i];
	}
	
	fft(fa, true);
	vector<ll> res(fa.size());
	
	for(int i = 0; i < (int) fa.size(); i++) {
		res[i] = round(fa[i].real());
	}
	
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	ll n, m;
	cin >> n >> m;
	vector<ll> a(200*1000+5), b;
	for(int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		a[x]++;
	}
	
	while((a.size() & (a.size()-1))) {
		a.push_back(0);
	}
	
	b = a;
	vector<ll> cnt = conv(a, b);
	ll ans = 0;
	
	for(int i = cnt.size() - 1; i > 0; i--) {
		ll take = min(m, cnt[i]);
		ans += take*i;
		m -= take;
	}
	
	cout << ans << endl;
}


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

binlen = 0
while 2 ** binlen <= K:
    binlen += 1
binlen -= 1

if binlen < 0:
    print(sum(A))
    exit()

bitcount = [0] * (len(bin(max(A))) - 2)
for a in A:
    for i, s in enumerate(bin(a)[::-1][:-2]):
        if s == "1":
            bitcount[i] += 1

maxn = 2 ** binlen
mid = N / 2

for i in range(binlen + 1):
    if i < len(bitcount):
        if bitcount[i] < mid and i != binlen:
            maxn += 2 ** i
        elif bitcount[i] > mid and i == binlen:
            maxn -= 2 ** i
    elif i != binlen:
        maxn += 2 ** i

pos = 0
while maxn > K:
    if bin(maxn)[2:][pos] == "1" and bin(K)[2:][pos] == "0":
        maxn -= 2 ** (len(bin(maxn)) - 3 - pos)
    pos += 1

print(sum([maxn ^ a for a in A]))


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

int main(){

  int t;
  cin>>t;

  int h,m,s;

  h = t/3600;
  m = (t-h*3600)/60;
  s = t-h*3600-m*60;

  cout<<h<<":"<<m<<":"<<s<<endl;

  return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>
#include <string.h>

int main(){
	while(1){
		LOOP:
		int n;
		scanf("%d",&n);
		if(!n) break;
		char w[40][11];
		int c[40];
		for(int i=0;i<n;i++){
			scanf("%s",w[i]);
			c[i]=strlen(w[i]);
		}
		int f[]={5,7,5,7,7};
		int k;
		int tmp;
		for(int i=0;i<n;i++){
			k=0;
			tmp=0;
			for(int j=i;j<n;j++){
				if(f[k]<tmp+c[j])
					break;
				tmp+=c[j];
				if(tmp==f[k]){
					k++;
					tmp=0;
				}
				if(k==5){
					printf("%d\n",i+1);
					goto LOOP;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2652
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll L, R;
    cin >> L >> R;
    bool flag = true;
    ll ans = 100000000;
    if (R - L + 1 >= 2019)
        ans = 0;
    else
    {
        rep(i, L, R + 1)
        {
            rep(j, i + 1, R + 1) ans = min(ans, i * j % 2019);
        }
    }
    cout << ans << endl;
}


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

#include <bits/stdc++.h>
using namespace std;
#define _ cin.tie(0);ios::sync_with_stdio(false);
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()

const ll oo = (ll) 1e18;
const int mod = (int) 1e9 + 7;
const double PI = acos((ll)-1.0);

class TaskC {
public:

    void solve(std::istream& in, std::ostream& out){_
        int n,ct=0,cf=0,cn=0;
        in >> n;
        for(int i=0;i<n;++i){
            int x;
            in >> x;
            if(x%4 == 0) ++cf;
            else if(x%2 == 0) ++ct;
            else ++cn;
        }
        bool ans = true;
        if (ct == 1) ++cn,--ct;
        if(ct == 0){
            ans = cf >= cn - 1;
        }
        else {
            ans = cf >= cn;
        }
        out << (ans ? "Yes\n": "No\n");
    };
};


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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

const int INF = INT_MAX;

struct Solver
{
	int n, l;
	VI as, dp, done;

	Solver()
	{
		cin >> n >> l;
		as.resize( n );
		FOR( a, as )
		{
			cin >> a;
		}
		dp.resize( n );
		done.resize( n );

		return;
	}

	operator int()
	{
		int res = 0;
		REP( i, 0, n )
		{
			res = max( res, rec( i ) );
		}
		return res;
	}

	int rec( int x )
	{
		if ( done[x] )
		{
			return dp[x];
		}

		done[x] = true;
		
		int res = 0;
		if ( x && as[x] < as[ x - 1 ] )
		{
			res = max( res, rec( x - 1 ) );
		}
		if ( x + 1 < n && as[x] < as[ x + 1 ] )
		{
			res = max( res, rec( x + 1 ) );
		}
		return dp[x] = res + ( l - as[x] );
	}
};

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

	cout << Solver() << endl;

	return 0;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
    chutiyaap;
    ll x;cin>>x;
    ll a=100,cnt=0;
    for(ll i=0;i<=1000000;i++)
    {
    	ll rem=(a/100);
    	a+=rem;
    	cnt++;
    	if(a>=x)break;
    }
    cout<<cnt;
}


Measured memory_bytes: 3640
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int H = 0;
        int W = 0;

        while (true) {
            H = sc.nextInt();
            W = sc.nextInt();

            if (H == 0 && W == 0) break;

            for (int i=0; i<H; ++i) {
                for (int j=0; j<W; ++j) {
                    if (i%2 == 0) {
                        if (j%2 == 0) System.out.print('#');
                        else System.out.print('.');
                    } else {
                        if (j%2 == 0) System.out.print('.');
                        else System.out.print('#');
                    }
                }
                System.out.print('\n');
            }

            System.out.print('\n');
        }
    }
}


Measured memory_bytes: 40088
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
	char c,s[9];
	int n=0,f=0;
	for(;(c=getchar())!=EOF;)
	{
		if(47<c&&c<58)
		{
			memset(s,0,9);
			s[0]=c;
			for(f=1;(c=getchar())!=EOF&&47<c&&c<58;f++)
				s[f]=c;
			n+=atoi(s);
		}
	}
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 524
#include <stdio.h>

int main(int argc, const char * argv[]) {
    long long int a[101][101]={},b[101][101]={},c[101][101]={};
    long long int n,m,l,i,j,k = 0;
    scanf("%lld %lld %lld",&n,&m,&l);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%lld",&a[i][j]);
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            scanf("%lld",&b[i][j]);
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            for(k=0;k<m;k++){
                c[i][j] += a[i][k]*b[k][j];
            }
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            printf("%lld",c[i][j]);
            if(j!=l-1){
                printf(" ");
            }
        }
        
        if(j!=l-1){
            printf("\n");
        }
    }
    //printf("\n");
    return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - (int)1e8;
const ll INFLL = numeric_limits<ll>::max() - (ll)1e17;

int main() {
    int S, W;
    cin >> S >> W;
    if (W >= S) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

Measured memory_bytes: 3636
//package atcoder.beginner_171;

import java.io.*;
import java.util.StringTokenizer;

public class Main {

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

        String s = "AZaz";

//        br = new BufferedReader(new StringReader(s));
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));

        rl(); char[] A=nca();
        for(int i=0; i<A.length; ++i) {
            if(A[i]>=65 && A[i]<=90) {
                A[i]='A';
            } else {
                A[i]='a';
            }
        }


        bw.write(A);
        bw.newLine();
        bw.flush();

    }

    static BufferedReader br;
    static BufferedWriter bw;
    static StringTokenizer st;
    static void rl() throws Exception{
        st = new StringTokenizer(br.readLine());
    }
    static long nlo(){
        return Long.parseLong(st.nextToken());
    }
    static int nin(){
        return Integer.parseInt(st.nextToken());
    }
    /*private static void te(){
      }*/
    static double ndo(){
        return Double.parseDouble(st.nextToken());
    }
    static char[] nca(){
        return st.nextToken().toCharArray();
    }
    static String nstr(){
        return st.nextToken();
    }
}

Measured memory_bytes: 32528
#include <bits/stdc++.h>
using namespace std;
int n,m,k,a[15][10005];
int res(int x1,int y1,int x2,int y2)
{
	return a[x2+1][y2+1]-a[x2+1][y1]-a[x1][y2+1]+a[x1][y1];
}
bool check(int x,int y,int z)
{
	int t=0;
	for(int i=0;i<n;i++)
	{
		if(x&(1<<i)||i==n-1)
		{
			int cnt=res(t,y,i,z);
			if(cnt>k)
				return false;
			t=i+1;
		}
	}
	return true;
}
int run(int x,int y)
{
	if(check(y,x,m-1))
		return 0;
	if(!check(y,x,x))
		return (int)1e9;
	int t=x;
	for(int i=(1<<15);i>0;i>>=1)
	{
		if(t+i>=m)
			continue;
		if(!check(y,x,t+i))
			continue;
		t+=i;
	}
	return 1+run(t+1,y);
}
int main()
{
	cin>>n>>m>>k;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		for(int j=0;j<m;j++)
			a[i+1][j+1]=s[j]=='1';
	}
	for(int i=0;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			a[i][j]+=a[i][j-1];
	}
	for(int j=0;j<=m;j++)
	{
		for(int i=1;i<=n;i++)
			a[i][j]+=a[i-1][j];
	}
	int sum=(int)1e9;
	for(int i=0;i<(1<<(n-1));i++)
	{
		int t=run(0,i)+__builtin_popcount(i);
		sum=min(sum,t);
	}
	cout<<sum;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,x; cin >> n>>x;
  vector<int> l(n); for(int i=0;i<n;i++) cin>>l.at(i);
  int count = 1;
  int y = 0;
  for(int i = 0;i<n;i++){
    y+=l.at(i);
    if (y<=x) count++;
    else break;
  }
  cout << count << endl;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int n;
	string s;
	cin >> n >> s;
	
	for(auto& c : s)
	{
		char ch = (((c + n) - 'A') % 26 + 'A');
		cout << ch;
	}
}

int main()
{
	fastio;
	solve();

	return 0;
}

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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = pow(2, 62);
const int mod = 1000000007;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




/* main */


signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int x, y; cin >> x >> y;
    if(abs(x - y) > 1){
        print("Alice");
    }else{
        print("Brown");

    }








   








    
    












    

    








    






    


    
    

    
    






    




    

    





    

   




    

    

    



    
    



    







    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,m,c,a[105],b[105],ans=0,sum=0;
  cin>>n>>m>>c;
  for(int i=1;i<=m;i++)
      cin>>b[i];
  while(n--){
    for(int i=1;i<=m;i++)
      cin>>a[i];
    for(int i=1;i<=m;i++){
      sum+=a[i]*b[i];}
    sum+=c;
    if(sum>0) ans++;
  sum=0;}
  cout<<ans<<endl;
  return 0;
}
   

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

#define MAX_N 100000

using namespace std;

int main(void)
{
    int N;
    int A[MAX_N];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A, A + N);
    long long x = 0;
    long long y = 0;
    for (int i = N - 1; i >= 1; i--) {
        if (A[i] == A[i - 1]) {
            if (x == 0) {
                x = A[i];
            } else {
                y = A[i];
                break;
            }
            i--;
        }
    }
    cout << x * y << endl;
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

void solve()
{
    int d,t,s;
    scanf("%d%d%d", &d,&t,&s);
    
    if (d <= s * t) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 1664
//https://abc100.contest.atcoder.jp/tasks/abc100_d

#include <vector>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <stack>
#include <iomanip>
#include <queue>
#include <string>
using namespace std;

#define left asdfghjkl
#define right sdfghjk
#define ll long long
#define db double

struct triple{
    ll a, b, c;
};

int n,m;
vector<triple> cake;

ll findCake(int k){
    priority_queue<ll, vector<ll>, less<ll> > pq;
    int c1, c2, c3;
    c3 = k % 2;
    k = k/2;
    c2 = k % 2;
    k = k/2;
    c1 = k;
    if (!c1){
        c1 = -1;
    }
    if (!c2){
        c2 = -1;
    }
    if (!c3){
        c3 = -1;
    }
    for (int i = 0; i < n; i++){
        ll a, b, c ;
        a = cake[i].a;
        b = cake[i].b;
        c = cake[i].c;
        pq.push(a*c1 + b*c2 + c*c3);
    }
    ll sum = 0;
    for(int i = 0; i < m; i++){
        sum += pq.top();
        pq.pop();
    }
    //cout << sum << endl;
    return sum;
}

int main(){
    //freopen("input.txt","r",stdin);
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        ll a, b, c;
        cin >> a >> b >> c;
        triple temp;
        temp.a = a;
        temp.b = b;
        temp.c = c;
        cake.push_back(temp);
    }
    ll res = 0;
    for(int i = 0; i < 8; i++){
        res = max(res,findCake(i));
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	a := 0
	b := 0
	c := 0
	d := 0
	sc := bufio.NewScanner(os.Stdin)
	for i := 0; i < 3; i++ {
		var j, k int
		sc.Scan()
		fmt.Sscanf(sc.Text(), "%d %d", &j, &k)
		if j == 1 {
			a++
		} else if j == 2 {
			b++
		} else if j == 3 {
			c++
		} else if j == 4 {
			d++
		}
		if k == 1 {
			a++
		} else if k == 2 {
			b++
		} else if k == 3 {
			c++
		} else if k == 4 {
			d++
		}
	}

	if a == 2 && b == 2 && c == 1 && d == 1 {
		fmt.Println("YES")
	} else if a == 1 && b == 2 && c == 2 && d == 1 {
		fmt.Println("YES")
	} else if a == 1 && b == 1 && c == 2 && d == 2 {
		fmt.Println("YES")
	} else if a == 2 && b == 1 && c == 1 && d == 2 {
		fmt.Println("YES")
	} else if a == 2 && b == 1 && c == 2 && d == 1 {
		fmt.Println("YES")
	} else if a == 1 && b == 2 && c == 1 && d == 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  cout << max(c-(a-b),0) << endl;
}

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

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;


ll P(ll a, ll x) {
  ll res = 1;
  while(x > 0) {
    if(x & 1) res = res * a % mod;
    a = a * a % mod;
    x >>= 1;
  }
  return res;
}

ll nCr(ll n, ll r) {
  ll tmp = n - r;
  if(tmp == 0 || r == 0) return 1;
  if(tmp > r) swap(tmp,r);

  ll sum = 1;
  for(ll i = n; i > n - tmp; i--) sum = sum * i % mod;
  ll sum2 = 1;
  for(ll i = tmp; i >= 1; i--) sum2 = sum2 * i % mod;

  return sum * P(sum2,mod-2) % mod;
}
  
int main() {
  ll n,m,k;
  cin >> n >> m >> k;

  ll ans = 0;
  for(ll i = 1; i < n; i++) {
    ans = (ans + i * (n - i)  * m * m ) % mod;
  }
  for(ll i = 1; i < m; i++) {
    ans = (ans + i * (m - i) * n * n ) % mod;
  }
  // cout << nCr(2,0) << endl;
  cout << ans * nCr(n * m - 2, k - 2) % mod << endl;
  
}

  
  


Measured memory_bytes: 256
n, k = map(int, input().split())
s = input()
l = sum([i.count('L')-1 for i in s.split('R') if i.count('L') >= 2])
r = sum([i.count('R')-1 for i in s.split('L') if i.count('R') >= 2])
print(min(l+r+2*k, n-1))

Measured memory_bytes: 43504
/* 만든 사람 <xrssa> */
/* 불타오르네, 불타오르네, 불타오르네 */
#include <bits/stdc++.h>
using namespace std;

#define f(i,n)        for(int i=0;i<n;i++)
#define fab(i,a,b)    for(int i=a;i<b;i++)
#define fa(elem, arr) for(auto &elem:arr)
#define all(a)        a.begin(),a.end()

void solve(){
    int n,m;cin>>n>>m;
    map<string,pair<int,int>> ar;
    int ac=0,penal=0;
    f(i,m){
        string id,res;
        cin>>id>>res;
        if(ar[id].first==0){
            if(res=="WA") ar[id].second+=1;
            else {
                ar[id].first=1;
                penal+=ar[id].second;
                ac+=1;
            }
        }
    }
    cout << ac << " " << penal << "\n";
}

int main()
{   ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // 여러 테스트 사례 사용
    solve();
    return 0;
}


Measured memory_bytes: 11264
#include<iostream>
using namespace std;
struct node
{
    int a,b,c,d;
}b[55];
int n,m,q;
int a[15];
int ans;
void dfs(int dep,int las)
{
    if(dep==n+1)
    {
        int k=0;
        for(int i=1;i<=q;i++)
        {
            if(a[b[i].b]-a[b[i].a]==b[i].c)
            {
                k+=b[i].d;
            }
        }
        ans=max(ans,k);
        return;
    }
    for(int i=las;i<=m;i++)
    {
        a[dep]=i;
        dfs(dep+1,i);
    }

}
int main()
{
    cin>>n>>m>>q;
    for(int i=1;i<=q;i++)
        cin>>b[i].a>>b[i].b>>b[i].c>>b[i].d;
    dfs(1,1);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3228
# -*- coding: utf-8 -*-

N, K = map(int, input().split())

N_dict = {}
for i in range(N):
    a, b = map(int, input().split())
    if a not in N_dict:
        N_dict[a] = b
    else:
        N_dict[a] += b

# dictをkeyでソート
N_sorted = sorted(N_dict.items(), key=lambda x: x[0])

cnt = K
for n in N_sorted:
    cnt -= n[1]
    if cnt <= 0:
        print(n[0])
        exit()

Measured memory_bytes: 15044