akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, A, B; cin >> n >> A >> B; --A, --B;
    // vector<vector<bool>> m1(n, vector<bool>(n, false));
    // vector<vector<bool>> m2(n, vector<bool>(n));
    // function<bool(ll,ll)> dp = [&](ll a, ll b) {
    //     assert(0 <= a && a < n && 0 <= b && b < n);
    //     bool res = false;
    //     if (m1[a][b]) return m2[a][b];
    //     if ( a-1 >= 0 && a-1 != b && !dp(b, a-1) ) res = true;
    //     if ( a+1 < n && a+1 != b && !dp(b, a+1) ) res = true;
    //     return m1[a][b] = true, m2[a][b] = res;
    // };
    // if ( dp(A, B) ) {
    if ( abs(A - B) % 2 == 0 ) {
        cout << "Alice" << endl;
    }
    else {
        cout << "Borys" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define INF 1000000000
#define endl "\n"
#define all(s) s.begin(),s.end()
#define pb push_back
#define uno unordered_map
#define pi 3.1415926536
#define dig(a) fixed<<setprecision(a)
#define w(zz) int zz; cin>>zz; while(zz--)
#define foreach(var,i) for(auto i = var.begin();i!=var.end();i++)
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
ll power(ll a, ll n) {ll res = 1; while (n) {if (n % 2) {res *= a;} n >>= 1; a *= a;} return res;}
ll powerm(ll a, ll n, ll m) {ll res = 1; while (n) {if (n % 2) {res = (res * a) % m;} n >>= 1; a = (a * a) % m;} return res;}
using namespace std;
int main(){
	fast();
	string s;
	cin>>s;
	ll sum=0;
	for(char c: s){
		sum+=(c-'0');
	}
	cout<<(sum%9==0?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 3732
import math

a, b, h, m = map(int,input().split())

H = 1/3 #1分で動く短針角度
M = 6 #1分で動く長針の角度
g = 40 * (1/3)

M = m*6
h_ = 30*h
if(a >6):
  kakudo = abs((h_+m*(1/2))  - M)
  if(kakudo >= 360 - kakudo):
    kakudo = 360 - kakudo
  print(math.sqrt((a*a) + (b*b) - (2*a*b*(math.cos((math.radians(kakudo)))))))
if(a<6):
  kakudo = abs((h_+m*(1/2)) - M)
  if(kakudo >= 360 - kakudo):
    kakudo = 360 - kakudo
  print(math.sqrt((a*a) + (b*b) - (2*a*b*(math.cos((math.radians(kakudo)))))))

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

int main_()
{
    string w;
    cin >> w;
    vector<char> alphabets;
    for (char ch = 'a'; ch <= 'z'; ++ch)
    {
        alphabets.push_back(ch);
    }
    vector<int> counts;
    transform(
        alphabets.begin(), alphabets.end(),
        back_inserter(counts),
        [&w](auto ch) { return count(w.begin(), w.end(), ch); });

    if (all_of(counts.begin(), counts.end(), [](int c) { return c % 2 == 0; }))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define INF 1000000000
int main(){
  int n,k,ans=INF;
  cin>>n>>k;
  vector<int> h(n);for(int i=0;i<n;i++)cin>>h[i];
  sort(h.begin(),h.end());
  for(int i=0;i<n-k+1;i++){
    int temp=h[i+k-1]-h[i];
    ans=min(ans,temp);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
	int n,k;
	cin >> n >> k;
	string s;
	cin >> s;
	if (s[k - 1] == 'A') s[k - 1] = 'a';
	else if (s[k - 1] == 'B') s[k - 1] = 'b';
	else s[k - 1] = 'c';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,f=0,i,j,k,sum=0;
    cin>>k;
    for(i=1;i<=k;i++)
    {
        for(j=1;j<=k;j++)
        {
            for(n=1;n<=k;n++)
            {
                sum+=__gcd(i,__gcd(j,n));
            }
        }
    }
  cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using ll = long long;
typedef long long ll;

int gcd(int m, int n);
int lcm(int a, int b);

int main(void){
    using namespace  std;
    int N, M;
    cin >> N >> M; 
    vector<int> A(N);
    ll sum = 0;
    rep(i, N){
         cin >> A[i];
         sum += A[i];
    }
    sort(all(A), greater<int>());

    cout << (4*M*A[M-1]>=sum ? "Yes" : "No") << endl;

    return 0;
}

int gcd(int m, int n){
    int r;
    do{
        r = m % n;
        m = n;
        n = r;
    } while (r != 0);

    return m;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	int total=0; 
	vector<ll> a(n),b(31,0);
	for(int i=0;i<n;i++){
		cin >> a[i];
		for(int j=0;j<31;j++){
			if(a[i]&(1LL<<j)){
				b[j]++;
				break;
			}
		}
		total^=a[i];
	}
	int ans=0;
	for(int j=30;j>=0;j--){
		if(total&(1LL<<j)){
			if(b[j]){
				ans++;
				total=(total^(1LL<<j))^((1LL<<j)-1);
			}
			else{
				cout << -1 << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1152
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
a=i2()
b=1
for i in range(n):
 b*=a[i]
b-=1
c=0
for i in range(n):
 c+=b%a[i]
print(c)

Measured memory_bytes: 40304
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <deque>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i) = 0; (i) <= (n); (i)++)
using namespace std;

int N, Z, W;
int a[2000];

signed main()
{
	cin >> N >> Z >> W;
	REP(i, N) cin >> a[i];

	if (N == 1)
	{
		cout << abs(a[0] - W) << endl;
	}
	else
	{
		int n = abs(a[N - 1] - W);
		int m = abs(a[N - 2] - a[N - 1]);
		cout << MAX(n, m) << endl;
	}
}

Measured memory_bytes: 256
//
#include<set>
#include<map>
#include<stack>
#include<ctime>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
	bool f=0;int x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return !f?x:-x;
}
#define MAXN 200
#define INF 0x3f3f3f3f
int ma[MAXN+5];
struct Edge{
	int u,v,id,nxt;
}edge[MAXN*MAXN+5];
bool tag[MAXN*MAXN+5];
int ecnt,head[MAXN+5];
vector<int> G[MAXN+5];
inline void Addedge(int u,int v,int id){
	edge[++ecnt]=(Edge){u,v,id,head[u]},head[u]=ecnt;
	//printf("%d %d\n",u,v);
	return ;
}
bool vis[MAXN+5];
bool DFS(int u){
	if(vis[u]) return 0;
	vis[u]=1;
	for(int i=head[u];i;i=edge[i].nxt){
		int v=edge[i].v;
		if(tag[i]) continue;
		if(!ma[v]||DFS(edge[ma[v]].u)){
			ma[u]=i,ma[v]=i;
			return 1;
		}
	}
	return 0;
}
int a[MAXN+5][MAXN+5],b[MAXN+5][MAXN+5],c[MAXN+5][MAXN+5];
int main(){
	//freopen("sort.in","r",stdin);
	//freopen("sort.out","w",stdout);
	int n=read(),m=read();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			a[i][j]=read();
	//puts("//////////");
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			Addedge(i,n+(a[i][j]+m-1)/m,a[i][j]);
	//puts("//////////");
	for(int t=1;t<=m;t++){
		memset(ma,0,sizeof(ma));
		for(int i=1;i<=n;i++)
			if(!ma[i]){
				memset(vis,0,sizeof(vis));
				DFS(i);
			}
		for(int i=1;i<=n;i++)
			tag[ma[i]]=1,b[edge[ma[i]].u][t]=edge[ma[i]].id,c[edge[ma[i]].v-n][t]=edge[ma[i]].id;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			printf("%d",b[i][j]),putchar(j==m?'\n':' ');
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			printf("%d",c[i][j]),putchar(j==m?'\n':' ');
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
ll MIN = pow(10, 9);

ll ans(ll i, ll sum,ll X);

int main() {
    ll X;
    cin >> X;
    
    ll sum = 0,i = 1;

    while (X > sum) {
        sum += i;
        i++;
    }

    cout << i - 1;

}


Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int main()
{
	long long n,i,s=0,k,ma=1e9;
	cin>>n;
	long long m[n];
	for(i=0;i<n;i++)
	{cin>>m[i];}
	long long p[n];
	p[0]=m[0];
	k=m[n-1];
	for(i=1;i<n;i++)
	{
		p[i]=max(p[i-1],m[i]);
	}
	for(i=0;i<n;i++)
	{
		s=s+abs(p[i]-m[i]);
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 6724
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
typedef long long int ll;
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define m0(x) memset(x,0,sizeof(x))

int main(void){
	int x,y,ans;
	scanf("%d %d",&x,&y);
	ans = x+(y/2);
	printf("%d",ans);
	return 0;
}

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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	rep(i, 1, 6) {
		int t; cin >> t;
		if (!t) write(i);
	}
}


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


int main()
{
   unsigned long long int x;
   cin>>x;
  unsigned long long int start=100,sol=0;
   while(start<x)
   {
       sol++;
       start=start+start/100;
   }
   cout<<sol;




}


Measured memory_bytes: 3596
n = int(input())
a = sorted(list(map(int, input().split())))
c0 = a.count(0)

ans = "No"
if c0==n: ans = "Yes"
elif len(set(a)) == 2:
    c = a.count(a[-1])
    if c == (2*n)//3 and c0 == n//3: ans = "Yes"
elif len(set(a)) == 3:
    x,y,z = list(set(a))
    if a.count(x) == a.count(y) == a.count(z):
        if int(bin(x ^ y ^ z),2) == 0: ans = "Yes"
print(ans)

Measured memory_bytes: 20752
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(long long i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(long long i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using Int = long long;
using ll = long long;
using P = pair<Int,Int>;
using vi = vector<Int>;
using vvi = vector<vi>;
using vp = vector<P>;
using vvp = vector<vp>;

const Int INF = (1LL<<50);

vector<string> lis;
string ma = "3234566667";

void add(string cur, bool start){
  if(cur.size() == ma.size() + 1){
    if(start) lis.pb(cur);
    return;
  }
  char c = cur.back();
  if(start){
    for(Int j = -1; j <= 1; j++){
      char c2 = char(Int(c) + j);
      if(c2 >= '0' && c2 <= '9') add(cur + c2, start);
    }
  }else{
    for(char c2 = '0'; c2 <= '9'; c2++){
      add(cur + c2, c2 != '0');
    }
  }
} 

void solve(long long K){
  add("0", false);
  string ans = "";
  string temp = lis[K-1];
  rep(i, lis[K-1].size()){
    if(ans == "" && temp[i] == '0') continue;
    ans += temp[i];
  }
  cout << ans << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long K;
  scanf("%lld",&K);
  solve(K);
  return 0;
}


Measured memory_bytes: 14448
n = str(input())
k = int(input())
l = len(n)

def f(dig, under, num):
  if num > l - dig: return 0
  if num == 0: return 1
  if dig == l-1:
    if under: return int(n[dig])
    else: return 9
  if under:
    if n[dig] == '0':
      res = f(dig+1, True, num)
      #print(dig, under, num, res, 'aaa')
      return res
    else:
      res = f(dig+1, False, num)
      if int(n[dig]) > 1:
        res += (int(n[dig])-1) * f(dig+1, False, num-1)
      res += f(dig+1, True, num-1)
      #print(dig, under, num, res, 'bbb')
      return res
  else:
    res = f(dig+1, False, num)
    res += 9 * f(dig+1, False, num-1)
    #print(dig, under, num, res, 'ccc')
    return res

ans = f(0, True, k)
print(ans)

Measured memory_bytes: 9164
use std::io;

fn read_input() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s);
    s
}

fn wa() {
    println!("WA");
    std::process::exit(0);
}

fn solve(s: String) {
    let mut c = 0;
    for (i, j) in s.chars().enumerate() {
        match (i, j) {
            (0, 'A') => (),
            (0, _) => wa(),
            (1, 'A'...'Z') => wa(),
            (i, 'C') if i == 1 || i >= s.len() - 2 || c == 1 => wa(),
            (_, 'C') => c += 1,
            (_, 'A'...'Z') => wa(),
            (_, _) => (),
        }
    }
    if c == 0 {
        wa();
    }
    println!("AC");
}

fn main() {
    solve(read_input());
}


Measured memory_bytes: 4352
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll dp[110][4][4][4] ;
	for(int i=0;i<110;i++) for(int j=0;j<4;j++) for(int k=0;k<4;k++) for(int l=0;l<4;l++) dp[i][j][k][l] = 0 ;
	ll n ; cin >> n ;
	for(int i=0;i<4;i++) for(int j=0;j<4;j++) for(int k=0;k<4;k++) dp[3][i][j][k] = 1 ;
	dp[3][0][2][1] = dp[3][0][1][2] = dp[3][2][0][1] = 0 ;
//	for(int i=4;i<=n;i++){
//		for(int j=0;j<4;j++) for(int k=0;k<4;k++) for(int l=0;l<4;l++) for(int m=0;m<4;m++) dp[i][j][k][l] = (dp[i][j][k][l]+dp[i-1][m][j][k])%mod ;
//		for(int j=0;j<4;j++) dp[i][0][2][1] = (dp[i][0][2][1]+mod-dp[i-1][j][0][2])%mod ;
//		for(int j=0;j<4;j++) dp[i][0][1][2] = (dp[i][0][1][2]+mod-dp[i-1][j][0][1])%mod ;
//		for(int j=0;j<4;j++) dp[i][2][0][1] = (dp[i][2][0][1]+mod-dp[i-1][j][2][0])%mod ;
////		dp[i][0][3][2] = dp[i][0][2][3] = dp[i][3][0][2] = 0 ;
//		for(int j=0;j<4;j++) if(j!=0) dp[i][j][2][1] = (dp[i][j][2][1]+mod-dp[i-1][0][j][2])%mod ;
//		for(int j=0;j<4;j++) if(j&1)  dp[i][2][j][1] = (dp[i][2][j][1]+mod-dp[i-1][0][2][j])%mod ;
////		for(int j=0;j<4;j++) dp[i][j][3][2] = 0 ;
////		for(int j=0;j<4;j++) dp[i][3][j][2] = 0 ;
//	}
	for(int i=4;i<=n;i++){
		for(int j=0;j<4;j++){
			for(int k=0;k<4;k++){
				for(int l=0;l<4;l++){
					for(int m=0;m<4;m++){
						if(k==0&&l==2&&m==1){ continue ;}
						if(k==0&&l==1&&m==2){ continue ;}
						if(k==2&&l==0&&m==1){ continue ;}
						if(j==0&&l==2&&m==1){ continue ;}
						if(j==0&&k==2&&m==1){ continue ;}
						dp[i][k][l][m] = (dp[i][k][l][m]+dp[i-1][j][k][l])%mod ;
					}
				}
			}
		}
	}
	ll ans = 0 ;
	for(int i=0;i<4;i++) for(int j=0;j<4;j++) for(int k=0;k<4;k++) ans = (ans+dp[n][i][j][k])%mod ;
//	string s = "ACGT" ;
//	for(int i=0;i<4;i++) for(int j=0;j<4;j++) for(int k=0;k<4;k++) cout << s[i] << s[j] << s[k] << " : " << dp[n][i][j][k] << endl ;
	cout << ans << endl ;
}


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

using namespace std;

typedef long long ll;

/*
int memo[201][201];

int solve(ll x, ll y) {
	if (x < y) return solve(y, x);
	if (memo[x][y] != 0) return memo[x][y];
	if (x <= 1 && y <= 1) return -1;
	int res = -1;
	for (ll i = 1; 2 * i <= x; i++) {
		if (solve(x - 2 * i, y + i) == -1) {
			res = 1;
			break;
		}
	}

	if (res == 1) return memo[x][y] = res;

	for (ll i = 1; 2 * i <= y; i++) {
		if (solve(x + i, y - 2 * i) == -1) {
			res = 1;
			break;
		}
	}

	return memo[x][y] = res;
}*/

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	for (int i = 0; i <= 100; i++) {
		for (int j = i; j <= 100; j++) {
			cout << j << " " << i << " ";
			if (solve(j, i) == 1) cout << "A" << endl;
			else cout << "B" << endl;
		}
	}*/
	ll x, y;
	cin >> x >> y;
	if (x < y) swap(x, y);
	cout << (x - y <= 1 ? "Brown" : "Alice") << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
  private static long solve(int n, long[] a) {
    Arrays.sort(a);
    long sum = 0;
    for (int i = 0; i < n; i++) {
      sum += a[a.length - 2 - 2 * i];
    }
    return sum;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    long[] a = reader.nextLongArray(3 * n);
    out.println(solve(n, a));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
}

class Algorithm {
  private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  }
  
  public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  }
}



Measured memory_bytes: 57776
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

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

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    i64 n, a, b, c, d, e;
    scanf("%lld%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d, &e);
    i64 x = std::min({a, b, c, d, e});
    std::cout << ((n + x - 1) / x) + 4 << std::endl;
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
ll arr[100000] = {};
ll res[100000] = {};
ll solve(ll n){
	res[0] = 0;
	res[1] = res[0] + abs(arr[0] - arr[1]);
	for (int i = 2; i < n; i++){
		res[i] = min(res[i-2] + abs(arr[i] - arr[i - 2]),res[i-1]+ abs(arr[i] - arr[i - 1]));
	}
	return res[n-1];
}
int main(){
	ll n; cin >> n;
	for (ll i = 0; i < n; i++){
		cin >> arr[i];
	}
	cout<<solve(n);
	//getchar();
	//getchar();
	return 0;
}

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

int main()
{
 	ios_base::sync_with_stdio(false);
 	int N, K;
 	cin >> N >> K;
 	if(K%2==1) {
 		ll ans = N/K;
 		cout << ans*ans*ans;
 	} else {
 		ll ans1 = N/K;
 		ll ans2 = (N+K/2)/K;
 		cout << ans1*ans1*ans1 + ans2*ans2*ans2;
 	}
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_i

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    double p[n];
    for(int i = 0; i<n; i++) {
        cin >> p[i];
    }

    double dp[n+1][n+1] = { 0 };


    dp[0][0] = 1.0;
    
    for(int j = 1;j<=n;j++) {
        dp[0][j] = 0;
    }

    for(int j = 1; j <= n; j++){
        dp[j][0] = dp[j-1][0] * (1.0-p[j-1]);
    }

    for(int i = 1; i <= n;i++) {
        dp[i][i] = dp[i-1][i-1] * p[i-1];
    }

    for(int i = 1; i <= n;i++) {
        for(int j =1;j<i;j++) {
            dp[i][j] = p[i-1]*dp[i-1][j-1] + (1.0-p[i-1])*(dp[i-1][j]);
        }
    }
    double sum = 0;
    for(int i = (n/2) +1; i<=n;i++) {
        // cout << i << endl;
        sum += dp[n][i];
    }
    cout << setprecision(10) << fixed;
    cout << sum << endl;
}

Measured memory_bytes: 70528
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    string s = readln.chomp;

    long F(long p, long q) {
        long x2 = p + q,
             y2 = q - p;
        if (x2 % 2 == 1) return 0;
        if (y2 % 2 == 1) return 0;
        if (x2 < 0) return 0;
        if (y2 < 0) return 0;
        //writeln([x2, y2]);
        return 1;
    }
    
    long Ans = 0;
    Ans += F(0, s.to!int);
    for (int i = 1; i < s.length; i++) {
        if (s[i] == '0') continue;
        Ans += F(s[0 .. i].to!int, s[i .. $].to!int);
    }
    Ans += F(s.to!int, 0);
    writeln(Ans);
}

Measured memory_bytes: 1052
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());

		List<Integer> A = new ArrayList<Integer>();
		String[] get = br.readLine().split(" ");
		for(int i = 0;i<N;i++){
			A.add(Integer.parseInt(get[i]));
		}

		A.sort(null);

		int count = 0;
		int now=0,prev=A.get(0);

		int remove = 0;

		for(int i = 0;i<A.size();i++){
			now =A.get(i);
			if(now == prev){
				count++;
			}else{
				if(prev > count)remove += (count);
				else if(count > prev)remove += (count-prev);
				count = 1;
			}
			prev = now;
		}
		if(prev > count)remove += count;
		else if(count > prev)remove += (count-prev);
		System.out.println(remove);
	}
}


Measured memory_bytes: 49872
#include<iostream>
#include<vector>
#include<sstream>
#include<algorithm>
#include<cstdio>
using namespace std;
int v[] = {4,1,4,1,2,1,2,1};

string itos(int p)
{
  stringstream ss;
  for(int i=p;i<8+p;i++)
    ss << v[i%8];
  return ss.str();
}

int main()
{
  vector<int> p;
  p.resize(8);
  while(scanf("%d %d %d %d %d %d %d %d",&p[0],&p[1],&p[2],&p[3],&p[4],&p[5],&p[6],&p[7]) != EOF)
    {
      vector<string> ans;
      int mincost = (1<<29),minpos = -1;
      for(int i=0;i<8;i++)
	{
	  int cost = 0;
	  for(int j=0;j<8;j++)
	    cost += (p[j]-v[(i+j)%8]<=0)? 0:(p[j]-v[(i+j)%8]);
	  if(mincost == cost)
	    {
	      ans.push_back(itos(i));
	    }
	  else if(mincost > cost)
	    {
	      mincost = cost;
	      ans.clear();
	      ans.push_back(itos(i));
	    
	    }
	}
      
      if(ans.size() > 1)
	sort(ans.begin(),ans.end());
      for(int i=0;i<8;i++)
	{
	  cout << ans[0][i];
	  i==7?cout << endl:cout << " ";
	}
    }
  return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
#define int			long long
#define ld			long double

//yutaka1999

const int MX = 32;
int dp[MX];

bool cmp(pair<int,int> a, pair<int, int> b)
{
	return (a.first*b.second > b.first*a.second);
}

void solve()
{
	int n, T; cin >> n >> T;
	vector<int> z;
	vector<pair<int,int>> nz;
	for(int i=0; i<n; i++)
	{
		int a, b; cin >> a >> b;
		b++; b+=a;
		if(a==0) z.push_back(b);
		else { nz.push_back({a, b}); }
	}
	sort(nz.begin(), nz.end(), cmp);
	// dp[i] -> Min time to visit first i shops
	for(int i=0; i<MX; i++) dp[i] = T + 1;
	dp[0] = 0;
	for(int i=0; i<nz.size(); i++)
	{
		auto a = nz[i];
		for(int j=MX-2; j>=0; j--)
		{
			if(dp[j] > T) continue;
			dp[j+1] = min(dp[j+1], (a.first + 1)*dp[j] + a.second);
		}
	}
	sort(z.begin(), z.end());
	int ans = 0;
	for(int i=0; i<MX; i++)
	{
		if(dp[i] > T) continue;
		int del = T - dp[i];
		int pos = 0;
		while(pos < z.size() and del >= z[pos])
		{
			del -= z[pos];
			pos++;
		}
		ans = max(ans, pos + i);
	}
	cout << ans << endl;
}

signed main()
{	
	int T = 1; 
	// cin >> T;
	while(T--)
		solve();
	return 0;
}





Measured memory_bytes: 6256
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if 

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;
typedef vector<string> Vs;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=500000+19;

ll B[N];
int d[N],ans[N];
int n,D;

int main(){
	n=IN();D=IN();
	For(i,1,n+1) d[i]=IN();
	B[n+1]=1;
	for (int i=n;i;i--)
		if (B[i+1]<=d[i]/2){
			B[i]=B[i+1];
		} else{
			B[i]=B[i+1]+d[i];
		}
	For(i,1,n+1){
		ans[i]=(D>=B[i+1]);
		D=min(D,abs(D-d[i]));
	}
	for (int q=IN();q--;) puts(!ans[IN()]?"NO":"YES");
}

Measured memory_bytes: 9728
N = int(input())
A = [0]*N
B = [0]*N
for i in range(N):
  A[i],B[i] = map(int, input().split())
A.sort()
B.sort(reverse=True)
if N%2==1:
  mid = (N+1)//2-1
  ans = B[mid]-A[mid]+1
else:
  mid1 = N//2-1
  mid2 = N//2
  ans = (B[mid1]+B[mid2])-(A[mid1]+A[mid2])+1

print(ans)


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

int main( )
{
    string s;
    int i, j, k, l;
    cin >> s;
    int c1 = 0, c2 = 0, fl;
    l = (int) s.size();
    fl = 0;
    for (i = 0; i < l; i++) {
        if (s[i] == 'W') {
            if (fl == 0) {
                c1++;
                fl = 1;
            }
        }
        else {
            fl = 0;
        }
    }
    fl = 0;
    for (i = 0; i < l; i++) {
        if (s[i] == 'B') {
            if (fl == 0) {
                c2++;
                fl = 1;
            }
        }
        else {
            fl = 0;
        }
    }
    cout << (c1 + c2) - 1 << '\n';
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>

using u4t = std::uint32_t;
using i4t = std::int32_t;
using u8t = std::uint64_t;
using i8t = std::int64_t;

int main() {
  int N;
  std::cin>>N;
  int _min_min=1e9;
  int _min_max=1e9;
  int _max_min=0;
  int _max_max=0;
  int _minminc_min=1e9;
  int _minminc_max=0;
  int _maxmaxc_min=1e9;
  int _maxmaxc_max=0;
  std::vector<int> xx,yy;
  for(int i=0;i<N;i++){
    int x,y;
    std::cin>>x>>y;
    if(x>y)std::swap(x,y);
    xx.push_back(x);
    yy.push_back(y);
    int ominmin=_min_min,omaxmax=_max_max;
    _min_min=std::min(_min_min,x);
    _min_max=std::min(_min_max,y);
    _max_min=std::max(_max_min,x);
    _max_max=std::max(_max_max,y);
    if(_min_min!=ominmin){_minminc_min=1e9;_minminc_max=0;}
    if(_max_max!=omaxmax){_maxmaxc_min=1e9;_maxmaxc_max=0;}
    if(_min_min==x){
      _minminc_max=std::max(_minminc_max,y);
      _minminc_min=std::min(_minminc_min,y);
    }
    if(_max_max==y){
      _maxmaxc_max=std::max(_maxmaxc_max,x);
      _maxmaxc_min=std::min(_maxmaxc_min,x);
    }
  }
  int _min_max2=1e9;
  int _max_min2=0;
  for(int i=0;i<N;i++){
    int x=xx[i],y=yy[i];
    if(_min_min!=x&&_max_max!=y){
      _min_max2=std::min(_min_max2,y);
      _max_min2=std::max(_max_min2,x);
    }
  }
  int _max_comp=std::max({_maxmaxc_max,_minminc_max,_max_min2});
  int _min_comp=std::min({_maxmaxc_min,_minminc_min,_min_max2});
  for(int i=0;i<N;i++){
    int x=xx[i],y=yy[i];
    if(_min_comp<=x&&x<=_max_comp||_min_comp<=y&&y<=_max_comp)continue;
    int xdist=x<_min_comp?_min_comp-x:x-_max_comp;
    int ydist=y<_min_comp?_min_comp-y:y-_max_comp;
    int xy=xdist<ydist?x:y;
    _max_comp=std::max(_max_comp,xy);
    _min_comp=std::min(_min_comp,xy);
  }


  i8t ans = std::min(
    (i8t)(_max_max-_min_min)*(_max_comp-_min_comp),
    (i8t)(_max_max-_min_max)*(_max_min-_min_min));
  std::cout << ans<<std::endl;
  return 0;
}


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

#define rep(i, n)  for (int i = 0; i < (int) (n); i++)
#define Rrep(i, n) for (int i = ((int) n - 1); i >= 0; i--)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
#define INF 2e15
#define MOD 10e9 + 7

typedef vector <int> vint;
typedef long long    ll;



int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int h, w, n;
    cin >> h >> w >> n;
    if (h >= w) {
        if (n % h == 0) { cout << (int) (n / h) << endl; }
        else { cout << (int) (n / h) + 1 << endl; }
    }
    else {
        if (n % w == 0) { cout << (int) (n / w) << endl; }
        else { cout << (int) (n / w) + 1 << endl; }
    }



    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	scanner := makeScanner(8192)
	n := eGetLine(scanner)
	for _, r := range n {
		if r == '7' {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
const (
	TooLarge = math.MaxInt64
	TooSmall = math.MinInt64
)

func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	if n == 0 {
		return 1
	}
	if n == 1 {
		return a
	}
	if n%2 == 1 {
		return pow((a*a), n/2) * a
	}
	return pow((a * a), n/2)
}
func powMod(a, n, mod int) int {
	if n == 0 {
		return 1 % mod
	}
	if n == 1 {
		return a % mod
	}
	if n%2 == 1 {
		return powMod((a*a)%mod, n/2, mod) * a % mod
	}
	return powMod((a*a)%mod, n/2, mod)
}

func factoricalMod(n, count, mod int) int {
	if count == 1 {
		return n % mod
	}
	return (n % mod) * (factoricalMod(n-1, count-1, mod)) % mod
}

func combinationMod(n, a, mod int) int {
	x := factoricalMod(n, a, mod)
	y := factoricalMod(a, a, mod)
	y = powMod(y, mod-2, mod)
	return ((x % mod) * (y % mod)) % mod
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}

type ints []int

func ToString(slice []int) string {
	format := fmt.Sprint(slice)
	return fmt.Sprint(format[1 : len(format)-1])
}


Measured memory_bytes: 1748
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&a!=c)
	cout<<c<<endl;
	else if(a==c&&a!=b)
	cout<<b<<endl;
	else if(b==c&&b!=a)
	cout<<a<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    string s;
    cin>>s;
    cout<<s[0]<<SZ(s)-2<<s[SZ(s)-1]<<NL;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int x,a,b;
  cin>>x>>a>>b;
  if(x>a)
    a=x-a;
  else
    a=a-x;
  if(x>b)
    b=x-b;
  else
    b=b-x;
  if(a>b)
    cout<<"B"<<endl;
  else
    cout<<"A"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include<cstdio>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N;
  long long Y;
  
  cin >> N >> Y;
  
  int resx = -1;
  int resy = -1;
  int resz = -1;
  for (int i = 0; i <= N; ++i) {
    int x = i;
    for (int j = 0; j <= N; ++j) {
      int y = j;
      int z = N - (i + j);
      if (z >= 0 && (10000 * x + 5000 * y + 1000 * z == Y)) {
        resx = x;
        resy = y;
        resz = z;
        break;
      }
    }
  }
  
  cout << resx << " " << resy << " " << resz;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <cstdlib>
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  int h, w, d;
  cin >> h >> w >> d;
  const int hw = h*w;
  vector<pair<int,int>> inva(hw);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int a;
      cin >> a;
      inva[a-1] = pair<int,int>(i, j);
    }
  }
  vector<vector<int>> dists(d, vector<int>(1,0));
  for (int i = 0; i < d; i++) {
    auto& dist = dists[i];
    int s = 0;
    int py = inva[i].first;
    int px = inva[i].second;
    for (int j = i+d; j < hw; j+=d) {
      int y = inva[j].first;
      int x = inva[j].second;
      s += abs(py-y)+abs(px-x);
      dist.push_back(s);
      py = y;
      px = x;
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    auto& dist = dists[l%d];
    int lc = l/d;
    int rc = r/d;
    cout << dist[rc] - dist[lc] << endl;
  }
  return 0;
}


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

long long MOD = 1e9+7;
int MAX_INT = 1e9;

// 最大公約数
long long gcd(long long a, long long b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
// 最小公倍数
long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

// x^y%p
long long modpow(long long x, long long y, long long p=1) {
    long long res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0) {
        if (y & 1) res = res * x % p;
        y = y>>1;
        x = x * x % p;
    }
    return res;
}

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

  string s;
  int K;
  cin >> s >> K;

  set<string> s_substring;
  for(int i = 0; i < s.size(); i ++) {
    string tmp;
    for(int j = i; j < min((int)s.size(), i + 5); j++) {
      tmp.push_back(s[j]);
      s_substring.insert(tmp);
    }
  }

  int cnt = 0;
  string ans;
  for (string y : s_substring) {
    cnt++;
    if (cnt == K) {
      ans = y;
      break;
    }
  }

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


Measured memory_bytes: 4668
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b; 
	if(a%3==0)
	{
		cout<<"Possible";
		return 0;
	}
	if(b%3==0)
	{
		cout<<"Possible";
		return 0;
	}
	if((a+b)%3==0)
	{
		cout<<"Possible";
		return 0;
	}
	
	cout<<"Impossible";
	return 0;
}

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

using namespace std;
const int MAXN =1e5+10;
 
char s[MAXN][20];
long long int march[10];
int main(){
    int N =0;
    scanf("%d",&N);
    long long int ans =0;
    for(int i=0;i<N;i++){
        scanf("%s",&s[i]);
    }
    for(int i=0;i<N;i++){
        if(s[i][0]=='M')    march[0]++;
        if(s[i][0]=='A')    march[1]++;
        if(s[i][0]=='R')    march[2]++;
        if(s[i][0]=='C')    march[3]++;
        if(s[i][0]=='H')    march[4]++;
    }
    
    ans=march[0]*march[1]*march[2]+march[0]*march[1]*march[3]+march[0]*march[1]*march[4]+march[0]*march[2]*march[3]+march[0]*march[2]*march[4]+march[0]*march[3]*march[4]+march[1]*march[2]*march[3]+march[1]*march[2]*march[4]+march[1]*march[3]*march[4]+march[2]*march[3]*march[4];
    
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 2176
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	int n;
	while(cin>>n,n){
		int ans_max =0;
		int ans_min =INF;
		while(n--){
			int sum =0;
			for(int i =0;i <5;i++){
				int x;
				cin>>x;
				sum +=x;
			}
			ans_max=max(ans_max,sum);
			ans_min=min(ans_min,sum);
		}
		cout <<ans_max<<" "<<ans_min<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
/*input
6 6
*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 4;

int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);

  int a, b;
  cin >> a >> b;

  cout << ((a == b) ? (2 * a) : (2 * max(a, b) - 1));

  return 0;
} 

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

using namespace std;
int main(void){
    
    map<int, int> m;
    

    int n,q;
    
    cin >> n;
    int tmp;
    for(int i=0; i < n; i++){
        cin >> tmp;
        m[tmp]=1;
    }
    
    int count = 0;
    cin >> q;
    for(int i=0; i < q; i++){
        cin >> tmp;
        if(m[tmp]==1)count++;
        
    }
    cout << count << endl;
    return 0;
}



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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++) cin >> p.at(i);
  int count = 0;
  for(int i = 0; i < n; i++){
    if(p.at(i) != i+1) count++;
  }
  if(count > 2) cout << "NO" << endl;
  else cout << "YES" << endl;
}

Measured memory_bytes: 504
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

string S;

int main() {
    cin >> S;

    int N = S.length();
    int a = 0, b = 0;
    for (int i = 0; i < N; i++) {
        if(S[i]=='0'){
            if(i%2==0) a++;
            else b++;
        }else{
            if(i%2==0) b++;
            else a++;
        }
    }

    cout << min(a, b) << endl;
    return 0;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
typedef vector<vector<int>> Graph;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    double prob = 1.0 / pow(2, M), prob2 = 1.0;
    double ans = ((N - M) * 100 + M * 1900) * prob * prob2;
    rep(i, 1000) {
#ifdef DEBUG
        DUMP(ans);
#endif
        prob2 *= (1.0 - prob);
        ans += (i+2) * ((N - M) * 100 + M * 1900) * prob * prob2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
import math

N,M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
MOD = 10**9 + 7

if len(set(A)) < N or len(set(B)) < M:
    print(0)
    exit()

"""
・ある値がA、Bの両方にでてきた：場所がひとつに定まる
・片方にのみ出てき：もう一方の、ある値より最大値が大きくなる箇所に配置されうる。
　　たとえば１００について考えたとき、Aのみに１００がでてきたら、Bの１００より大きい列に配置されうる
・両方に出てこないとき：
　　たとえば１００がAにもBにも出てこないとき、Aの１００より大きい部分と、Bの１００より大きい部分に配置されうる。
　　一方で、１００より大きい値がその範囲に配置されているはずなので、その数だけ候補が減る

"""
A.append(0)
A.sort(reverse=True)
B.append(0)
B.sort(reverse=True)

cnt_gt_a = 0
cnt_gt_b = 0
ans = 1

for n in range(N*M, 0, -1):
    tmp = 0

    # ある値nの配置について考えている時に、「その行/列の最大はnより大きい値です」に出会うと、条件を満たせない
    #print(cnt_gt_a, cnt_gt_b)
    #print("~~~", A[cnt_gt_a],  B[cnt_gt_b], n)
    if A[cnt_gt_a] > n or B[cnt_gt_b] > n:
        print(0)
        print("---")
        exit()

    if A[cnt_gt_a] == n and B[cnt_gt_b] == n:
        # 両方にnが入っているので場所は一か所が決まる
        # 「今見ているｎより大きい値が最大値になる行・列がX個ありますよ」を表すcnt_gt_a,bに＋１する
        tmp = 1
        cnt_gt_a += 1
        cnt_gt_b += 1
    elif A[cnt_gt_a] == n:
        # A側にのみ入っている場合
        # 列方向について、最大がnより大きい列にnを配置できる（そうすると矛盾しない）
        tmp = cnt_gt_b
        cnt_gt_a += 1
    elif B[cnt_gt_b] == n:
        # Bのみに入っているとき
        # 行方向について、最大がnより大きい行に配置できる（そうすると矛盾しない）
        tmp = cnt_gt_a
        cnt_gt_b += 1
    else:
        # どちらにも出てこない
        # 行と列の、最大がｎより大きい所になら配置できるものの、既に使われているばしょいは配置できない
        # すべて使われていると負になりうるかもなので、0を最大としておく
        tmp = max(cnt_gt_a * cnt_gt_b - (N*M - n), 0)

    ans *= tmp % MOD
    ans %= MOD

print(ans)



Measured memory_bytes: 3572