akhauriyash/Code-Regression huggingface dataset:
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 2020 , inf = 2e9;
int a[N],n,f[N][N][2],Mx[N],Mn[N];

int main(){
    scanf("%d%d%d",&n,a,a+1);
    rep(i,0,n) scanf("%d",a+2+i);
    n+=2;
    rep(i,0,n) Mx[i]=-inf,Mn[i]=inf;
    per(i,0,n) per(j,i+1,n) rep(k,0,2) {
        int&x=f[i][j][k];
        if(j==n-1) x=abs(a[i]-a[j]);
        else if(k==0) x=Mx[j];
        else x=Mn[j];
        if(k==0) Mn[i]=min(Mn[i],x);
        else Mx[i]=max(Mx[i],x);
    }
    printf("%d\n",f[0][1][0]);
    return 0;
}


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

ll mod = 1000000007;

int main(){
	int n, in;
	cin >> n;
	int z = 0;
	vector<int> rgb(3);
	ll ans = 1;
	int f = 0;
	rep(i, n){
		cin >> in;
		int cou = 0;
		int k = -1;
		rep(j, 3) if(rgb[2-j] == in){ cou++; k = 2-j;}
		if(k == -1){ f = 1; break;}
		ans *= cou;
		if(ans >= mod) ans %= mod;
		rgb[k]++;
	}
	if(f == 0){
		cout << ans << endl;
	}else{
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
function main()
  
  (N,X) = map(x -> parse(Int,x), split(readline()))
  L = map(x -> parse(Int,x), split(readline()))
  
  D = zeros(Int,N+1)
  
  for i in 2:N+1
    D[i] = D[i-1] + L[i-1]
  end
  
  count = 0
  
  for i in 1:N+1
    if X >= D[i]
      count += 1
    end
  end
  
  println(count)
  
end

main()

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(a-x) > abs(b-x)) {
        cout << 'B' << endl;
    } else {
        cout << 'A' << endl;
    }
    return 0;
}


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

#include <algorithm>
#include <utility>
#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

void solve(ll N, vector<pair<pair<string, ll>, ll>> A) {
    sort(A.begin(), A.end());
    rep(i, N) { cout << A[i].second << endl; }
}

int main() {
    long long N;
    scanf("%lld", &N);
    vector<pair<pair<string, ll>, ll>> A(N);
    for (int i = 0; i < N; i++) {
        string S;
        ll P;
        cin >> S >> P;
        A[i] = make_pair(make_pair(S, -P), i + 1);
    }
    solve(N, move(A));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=1e5+100;
int n, m, par[maxn], arr[maxn];
vector<int>adj[maxn];
int root(int v)
{
    return v==par[v]?v:par[v]=root(par[v]);
}
bool unite(int a, int b)
{
    if(root(a)==root(b))return false;
    par[root(b)]=root(a);
    return true;
}
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        cin>>arr[i];
    for(int i=1; i<=n; i++)
        par[i]=i;
    for(int i=0; i<m; i++)
    {
        int a, b;
        cin>>a>>b;
        unite(a, b);
    }
    int ans=0;
    for(int i=1; i<=n; i++)
        if(root(i)==root(arr[i]))++ans;
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3456
k = gets.to_i
if k % 2 == 0 || k % 5 == 0
  puts -1
  exit
end
  
i = 1
L = k%7 == 0 ? (9*k)/7 : 9*k
mod = 10 % L
while true
  if mod == 1
    puts i
    break
  end
  i += 1
  mod = (10*mod) % L
end

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

using namespace std;

int main(){
int N,K; cin >> N >> K;
  vector<int> A(N); for(int i = 0; i < N; i++){ cin >> A[i];}
  sort(A.begin(),A.end());
  
  int j = 0;
    vector<int> vec;
  while( j < A.size()){
    int cnt = 1;
    while( j < A.size() - 1 && A[j] == A[j+1]){
      cnt++;  j++;}
    vec.push_back(cnt); j++;}
  
  sort(vec.begin(),vec.end());
  int sum = 0;
  if(vec.size() > K){
  for(int i = 0; i < vec.size() - K; i++){//vec.size() - K 種類書き換えたい
    sum += vec[i];}}
  
  cout << sum << endl; return 0;}
    
      

Measured memory_bytes: 2296
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))

Ans = [0]
for i in range(N):
  if(V[i]-C[i] > 0):
   Ans.append(V[i]-C[i])
ans = sum(Ans)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

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

  int ret = 0;
  int cur = 0;
  for (char& c : s) {
    if (c == 'R')
      ++cur;
    else
      cur = 0;
    ret = max(ret, cur);
  }
  cout << ret << endl;
  return 0;
}

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

using namespace std;

int n, m, a[1005], sum;

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a, a + n);
	sum =(int) ceil((double)(sum*1.0 / (4 * m)));
	if (a[n - m] >= sum)
		printf("Yes");
	else
		printf("No");
	return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	
	bool dp[k+1]; // false means second
	memset(dp, 0, sizeof(dp));
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	
	for(int i = 1; i <= k; i++) {
		for(int j = 0; j < n; j++) {
			dp[i] |= i - a[j] >= 0 ? !dp[i-a[j]] : false;
		}
	}
	cout << (dp[k] ? "First" : "Second");
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)

using namespace std;

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;

int main() {
//	cout << fixed << setprecision(15);
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) {
        cin >> a[i];
        a[i] -= i;
    }
    map<ll, int> mp;
    rep(i, n) mp[a[i]]++;
    ll ans = 0;
    rep(i, n) {
        ll tmpa = a[i];
        mp[a[i]]--;
        ll sum = i * (-2);
        ans += mp[sum - tmpa];
    }
    cout << ans << endl;
}


Measured memory_bytes: 27388
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    int k, n;
    cin >> k >> n;


    int maxa = 0;
    vector<int> a(n);
    cin >> a[0];

    for(int i=0;i<n-1;i++){
        cin >> a[i + 1];
        maxa = max(maxa, a[i + 1] - a[i]);
    }

    maxa = max(maxa, (k - a[n - 1]) + a[0]);

    cout << k - maxa << endl;

    return 0;
}


Measured memory_bytes: 1024
'''
https://qiita.com/Kerzival/items/6923c2eb3b91be86f19f
'''

class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

N,M = map(int,input().split())
uf = UnionFind(N)

for i in range(M):
    A,B = map(int,input().split())
    A -= 1
    B -= 1
    uf.Unite(A,B)

print(max([uf.Count(i) for i in range(N)]))

Measured memory_bytes: 94060
X,Y = map(int,input().split())

ans = []

for i in range(0,X+1):
    ans += [[i, X-i]]

f = 0
for i in range(len(ans)):
    if 2*ans[i][0] + 4*ans[i][1] == Y :
        print('Yes')
        f = 1
        exit()
    else:
        continue

if f == 0:
    print('No')

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

def main():
    S = input()
    cnt = 0
    for i in range(len(S)-1):
        if S[i]==S[i+1]:
            cnt += 1
    to_print = "Good" if cnt==0 else "Bad"
    print(to_print)

if __name__=='__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll pair<int,int>
#define mp make_pair
#define bp __builtin_popcountll
const int N = 10000005;
const int MOD = 1000000007;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
    ll a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    ll f1 = v*t - abs(b-a);
    ll f2 = t*w; 
    if(f1<f2)  cout<<"NO\n";
    else         cout<<"YES\n";
}

int main()
{
    FAST;
    ll t = 1;
   // cin >> t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

int main(){
    char Trump;
    while(cin >> Trump, Trump != '#'){
        vector<vector<string> > Cards(4, vector<string>(13, ""));
        rep(i, 4)rep(j, 13)cin >> Cards[i][j];
        int NS = 0, EW = 0, winner = 0;
        rep(turn, 13){
            char suit = Cards[winner][turn][1];
            rep(player, 4){
                if([&](const string& s, const string& t){
                        for(const auto x: {Trump, suit})if(s[1] == x ^ t[1] == x)return t[1] == x;
                        for(const auto x: "AKQJT")if(s[0] == x || t[0] == x)return s[0] != x;
                        return s < t;
                   }(Cards[winner][turn], Cards[player][turn]))winner = player;
            }
            (winner & 1? EW: NS)++;
        }
        cout << (NS < EW? "EW ": "NS ") << max(NS, EW) - 6 << '\n';
    }
    return 0;
}

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

int main() {
  int n, k; cin >> n >> k;
  vector<int>l(n); for(int i=0; i<n; i++) cin >> l[i];
 
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  
  int x=0;
  for(int i=0; i<k; i++) x+=l[i];
  
  cout << x << endl;
  
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	string S;
	cin >> S;
	if(S=="SAT")cout<<1;
	else if(S=="SUN")cout<<7;
	else if(S=="MON")cout<<6;
	else if(S=="TUE")cout<<5;
	else if(S=="WED")cout<<4;
	else if(S=="THU")cout<<3;
	else if(S=="FRI")cout<<2;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ALL(x) x.begin(), x.end()
 
typedef long long int lld;
typedef pair<int, int> pii;

const int maxn = 1e5 + 5;
const lld mod = 1e9 + 7;
vector<int> vec[maxn];
bool vis[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(15);
	cout << fixed;
 
	int n = 0, k;
	cin >> n >> k;

	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}

	lld ans = 1;

	queue<pii> que;
	
	que.emplace(1, 0);
	
	while (!que.empty()) {
		pii top = que.front();
		que.pop();

		if (vis[top.first])
			continue;
		vis[top.first] = true;

		//cout << top.first << ' ' << top.second << '\n';

		if (top.second >= k) {
			ans = 0;
			break;
		}

		ans = ans * (k - top.second) % mod;

		int cnt = 0;
		for (int i = 0; i < (int)vec[top.first].size(); i++) {
			if (vis[vec[top.first][i]])
				continue;

			cnt++;
			que.emplace(vec[top.first][i], min(top.second, 1) + cnt);
		}
	}

	cout << ans << '\n';





	
 
	return 0;
}

Measured memory_bytes: 7032
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

int main() {
  string N;
  cin >> N;
  
  if (count(all(N),'9') != 0) 
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-18;
const double INF = 1e9;



int main(){
	long num;
	long double w,h;
	char c1,c2;
	vector<long>res;
	while(cin>>num>>c1>>w>>c2>>h){
		if(w>=(25.0)*(h*h)+EPS)res.PB(num);
	}
	REP(i,SZ(res))cout<<res[i]<<endl;
	return 0;
}

Measured memory_bytes: 1252
loop do
  n = gets.to_i
  break if n==0
  hash = Hash.new
  names = Array.new
  n.times do
    name,*points = gets.chomp.split
    points.map!(&:to_i)
    w=0
    d=0
    points.each do |x|
      w+=1 if x==0
      d+=1 if x==2
    end
    hash[name]=w*n+d
    names << name
  end
  i=0
  ans = names.sort_by do |x|
    [-hash[x],i+=1]
  end
  puts ans
end

Measured memory_bytes: 2656
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll k,t;
    cin >> k >> t;
    vi a(t);
    rep(i,t) cin >> a.at(i);
    sort(a.begin(), a.end(), greater<>());
    ll mx = a.at(0);
    ll res = 0;
    if(k-mx<mx) res = 2*mx-k-1;
    cout << res << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N,T;
cin >> N >> T;

map<int,int> time;

rep(i,N) {
    int c,t;
    cin >> c >> t;
    time[c] = t;
}

int cost = INF;

for(auto x : time){
    if(x.second <= T) cost = min(cost, x.first);
}

if(cost == INF) cout << "TLE" << endl;
else cout << cost << endl;

return 0;
}

Measured memory_bytes: 256
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)

let () =
  let s = read_line () in
  range 0 (String.length s) 
  |> List.filter (fun i -> i mod 2 = 0)
  |> List.iter (fun i -> printf "%c" s.[i]);
  printf "\n"


Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;

const ll INF = 9223372036854775807;
const int inf = 2147483647;

int manhattan(int x1,int y1,int x2,int y2){
    return abs(x1-x2) + abs(y1-y2);
}

int main() {
    int h,w,d;
    cin >> h >> w >> d;
    int a[305][305];
    vector<vector<int>> b(h*w);
    vector<vector<int>> c(d);
    REP(i,h){
        REP(j,w){
            int c;
            cin >> c;
            a[i][j] = c;
            b[c-1].push_back(j);//x
            b[c-1].push_back(i);//y
        }
    }
    REP(j,d){
        int cnt = 0;
        for(int i=j;i<h*w;i+=d){
            if(j==i){
                c[j].push_back(0);
            }else{
                c[j].push_back(c[j][cnt-1]+manhattan(b[i][0], b[i][1], b[i-d][0], b[i-d][1]));
            }
            cnt++;
        }
    }
    int q;
    cin >> q;
    vector<ll> res(q);
    int l[100000],r[100000];
    REP(i,q){
        cin >> l[i] >> r[i];
    }
    REP(i,q){
        int lquo = (l[i]-1)/d;
        int lrem = (l[i]-1)%d;
        int rquo = (r[i]-1)/d;
        int rrem = (r[i]-1)%d;
        res[i]=(c[rrem][rquo]-c[lrem][lquo]);
    }
    REP(i,res.size()){
        put(res[i]);
    }
    return 0;
}


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

#define pb push_back
#define all(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

ll a[5], k;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	for (ll i = 0; i < 5; ++i) cin >> a[i];
	cin >> k;
	
	sort(a, a + 5);
	cout << (a[4] - a[0] > k ? ":(" : "Yay!");
	
	return 0;
}


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

const int N = 505, INF = 1e9;
int a[N][N];
int dis[N][N];
bool valid[N][N], done[N][N];

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

queue<int> q;

void SPFA() {
    while(q.size()) {
        int x = q.front(); q.pop();
        int y = q.front(); q.pop();
        for (int dir = 0; dir < 4; dir++) {
            int nx = x + dx[dir];
            int ny = y + dy[dir];
            if (valid[nx][ny] && dis[nx][ny] > dis[x][y] + !done[nx][ny]) {
                dis[nx][ny] = dis[x][y] + !done[nx][ny];
                q.push(nx);
                q.push(ny);
            }
        }
    }
}

void print(int n) {
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) {
            if (done[i][j]) cout<<"_ ";
            else cout<<dis[i][j]<<" ";
        }
        cout<<endl;
    }
}

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

    int n;
    cin>>n;

    for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) {
            dis[i][j] = INF;
            valid[i][j] = true;
        }
    }

    for (int i=1; i<=n; i++) {
        dis[1][i] = dis[i][1] = dis[n][i] = dis[i][n] = 0;
        q.push(1); q.push(i);
        q.push(i); q.push(1);
        q.push(n); q.push(i);
        q.push(i); q.push(n);
    }

    SPFA();
    int ans = 0;
    for (int i=1; i<=n*n; i++) {
        int z;
        cin>>z;

        int x = (z-1)/n+1;
        int y = (z-1)%n+1;
        ans += dis[x][y];

//        print(n);
//        cout<<x<<" "<<y<<" ---> "<<dis[x][y]-1<<endl<<endl;


        done[x][y] = 1;
        dis[x][y]--;
        q.push(x); q.push(y);
        SPFA();
    }
    cout<<ans<<endl;
}


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

const int mod = 1'000'000'007;
int main() {
    int s;
    cin >> s;
    vector<ll> dp(s+1);
    dp[0] = 1;
    ll x = 0;
    for (int i = 1; i < s+1; ++i) {
        if (i - 3 >= 0) {
            x += dp[i-3];
            x %= mod;
        }
        dp[i] = x;
    }
    cout << dp[s] << endl;
    return 0;
}


Measured memory_bytes: 3572
#include<stdio.h>
int main(void)
{
	int sum[1000];
	int i;
	int j;
	int k=0;
	char ar[1000];
	char n[10]={'0','1','2','3','4','5','6','7','8','9'};
		for(i=0;i<1000;i++){
	sum[i]=0;
	}
	while(1){
		for(i=0;i<1000;i++){
	ar[i]='0';
	}
	scanf("%s",ar);
		if(ar[0]=='0'){
			break;
		}
	for(i=0;i<1000;i++){
		for(j=0;j<10;j++){
			if(n[j]==ar[i]){
				sum[k]+=j;
			}
		}
	}
	k++;
	}
	
	for(i=0;i<=k;i++){
		if(sum[i]==0){
			break;
		}
	printf("%d\n",sum[i]);
	}
	return 0;
}

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


int main()
{
   
  
    int n,z=0; cin >> n;
    

        while (n != 0)
        {
            if(n>=2)
               n -= 2;
            else if (n == 1)
                n -= 1;
            z++;

        }

        cout << z;
    
    return 0;
    
   
    
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver2.1.7
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int, vector<int>, greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(Z,0,a.size()-1)cout<<a[Z]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lW,0,a.size()){Vout(a[lW]);}
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
 
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

int comb(int n, int r){  //  nCr (MOD環境下)
int a=1;for(int i=n;i>n-r;--i){a=a*i%MOD;}for(int i=1;
i<r+1;++i){a=a*mypow(i,MOD-2,MOD)%MOD;}return a%MOD;}
 
signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n,b,r;
  cin >> n >> b;
  r = n-b;
  
  int ans=1;
  
  rep(i,0,b){
    ans = 1;
    ans *= comb(b-1,i);
    if(r-i < 0) ans = 0;
    else ans *= comb(r+1,r-i)%MOD;
    cout << ans%MOD << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a,b,c;
int C=0;
int d=0;
while(cin>>a>>b){
c=a+b;
C=0;
d=1;
while(c>=d)
{
	C++;
	d*=10;
}
cout<<C<<endl;
}
}

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

using namespace std;

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

	long long n,m;

	cin >> n >> m;

	if (n ==1 && m== 1) cout << 1 << endl;
	else if (n == 1) cout << m-2 << endl;
	else if (m == 1) cout << n-2 << endl;
	else cout << (n-2)*(m-2) << endl;

	return 0;

}


Measured memory_bytes: 256
// D - Christmas

#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 Y[51]; // レベルLバーガーの層の数

ll count_patties(ll L, ll X) {
	if (L == 0) {
		//if (X == 1) return 1;
		if (X >= 1) return 1;
		else return 0;
	}

	ll M = Y[L] / 2 + 1;

	if (X == 1) {
		return 0;
	} else if (X < M) {
		return count_patties(L-1, X-1);
	} else if (X == M) {
		return count_patties(L-1, X-1) + 1;
	} else if (X < Y[L]) {
		return count_patties(L-1, Y[L-1]) + 1 + count_patties(L-1, X-M);
	} else {  // X == Y[L]
		return count_patties(L-1, Y[L-1]) * 2 + 1;
	}
}

int main() {
	ll N, X;
	cin >> N >> X;

	Y[0] = 1;
	for (int i=0; i<50; i++) {
		Y[i+1] = Y[i] * 2 + 3;
	}

	ll ans = count_patties(N, X);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define lli long long int
const ll mod=1000000007;
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    lli arr[n+1];
    lli cum[n+1];
    for(ll i=1;i<=n;i++)
    {
    	cin>>arr[i];
	}
	cum[0]=0;
	for(lli i=1;i<=n;i++)
	{
		cum[i]=cum[i-1]+arr[i];
	}
	lli sum=0;
	for(ll i=1;i<=n;i++)
	{
		sum+=(arr[i]*((cum[n]-cum[i])%mod));
		sum%=mod;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 6732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

bool check(ll e, ll sum, ll sugar) {
    return ((sugar * (100 + e)) <= (e * sum));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MIN / 2 + 1;
    ll a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    vector<ll> dp(f + 1, inf);
    dp[0] = 0;
    double per = -100;
    ll answs = 0, anss = 0;
    reps(i, 1, f + 1) {
        if ((i >= (100 * a)) && (dp[i - (100 * a)] != inf)) {
            dp[i] = max(dp[i], dp[i - (100 * a)]);
        }
        if ((i >= (100 * b)) && (dp[i - (100 * b)] != inf)) {
            dp[i] = max(dp[i], dp[i - (100 * b)]);
        }
        if ((i >= c) && (dp[i - c] != inf) && (check(e, i, dp[i - c] + c))) {
            dp[i] = max(dp[i], dp[i - c] + c);
        }
        if ((i >= d) && (dp[i - d] != inf) && (check(e, i, dp[i - d] + d))) {
            dp[i] = max(dp[i], dp[i - d] + d);
        }
        if (dp[i] == inf) continue;
        double tmp = (double)dp[i] / i;
        if (per < tmp) {
            per = tmp;
            answs = i;
            anss = dp[i];
        }
    }
    printf("%lld %lld\n", answs, anss);
    return 0;
}


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

pair<int,int> movement[] = { make_pair( 0,-1), make_pair(-1, 0), make_pair( 0, 1), make_pair( 1, 0)};

signed main() {
  int rows, cols;
  cin >> rows >> cols;
  vector<vector<int>> dist(rows, vector<int>(cols, -1));
  vector<string> grid(rows);
  rep(i,rows) cin >> grid[i];

  queue<pair<int,int>> q;
  dist[0][0] = 1;
  q.emplace(0,0);

  while(q.size() && dist[rows-1][cols-1] == -1) {
    auto [r,c] = q.front(); q.pop();
    for(auto [dr, dc] : movement) {
      int rr = r+dr, cc=c+dc;
      if(rr<0 || rr>=rows || cc<0 || cc>=cols) continue;
      if(grid[rr][cc] == '#') continue;
      if(dist[rr][cc] != -1) continue;
      dist[rr][cc] = dist[r][c] + 1;
      q.emplace(rr,cc);
    }
  }
  int d = dist[rows-1][cols-1];
  if(d==-1) cout << -1 << endl;
  else {
    int w = 0;
    rep(r,rows) rep(c,cols) if(grid[r][c]=='.') ++w;
    cout << w - d << endl;
  }

}


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

struct Point
{
    int x, y;
};

struct Res
{
    int x1, y1, x2, y2;
};

vector<Point> vec;
vector<Res> res;
int m[501][501];

int main()
{
    int H, W;
    bool d = false;
    int n = -1;

    scanf("%d %d", &H, &W);

    for(int y=1; y<=H; y++)
        for(int x=1; x<=W; x++)
            scanf("%d", &m[y][x]);

    for(int y=1; y<=H; y++)
    {
        if(!d)
        {
            for(int x=1; x<=W; x++)
            {
                if(m[y][x] % 2)
                {
                    if(n == -1)
                    {
                        n = m[y][x];
                        vec.push_back({x, y});
                        continue;
                    }
                    else
                    {
                        n = -1;
                        vec.push_back({x, y});

                        for(int i=0; i<vec.size()-1; i++)
                            res.push_back({vec[i].x, vec[i].y, vec[i+1].x, vec[i+1].y});

                        vec.clear();
                        continue;
                    }
                }

                if(n != -1)
                    vec.push_back({x, y});
            }

            d = true;
        }
        else
        {
            for(int x=W; x>=1; x--)
            {
                if(m[y][x] % 2)
                {
                    if(n == -1)
                    {
                        n = m[y][x];
                        vec.push_back({x, y});
                        continue;
                    }
                    else
                    {
                        n = -1;
                        vec.push_back({x, y});

                        for(int i=0; i<vec.size()-1; i++)
                            res.push_back({vec[i].x, vec[i].y, vec[i+1].x, vec[i+1].y});

                        vec.clear();
                        continue;
                    }
                }

                if(n != -1)
                    vec.push_back({x, y});
            }

            d = false;
        }
    }

    printf("%d\n", res.size());

    for(auto &i: res)
    {
        printf("%d %d %d %d\n", i.y1, i.x1, i.y2, i.x2);
    }

    return 0;
}


Measured memory_bytes: 5104
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  def taskA() = {
    val ans = sc.nextInt() match {
      case 7 | 5 | 3 => "YES"
      case _ => "NO"
    }
    println(ans)
  }

  def taskB() = {
    val s = sc.next()
    val n = s.length
    val ans = 0.until(n - 2).fold(10000) { (acc, x) =>
      val y = s.substring(x, x + 3).toInt
      Math.min(acc, Math.abs(y - 753))
    }
    println(ans)
  }

  taskB()
}


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

int main(){
	int h, w;
	cin >> h >> w;
	vector<vector<char>> c(h, vector<char>(w));
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			cin >> c.at(i).at(j);
		}
	}
	vector<vector<char>> ans(2*h, vector<char>(w));
	for(int i=0; i<2*h; i++){
		for(int j=0; j<w; j++){
			ans.at(i).at(j)=c.at(i/2).at(j);
		}
	}
	for(int i=0; i<2*h; i++){
		for(int j=0; j<w; j++){
			cout << ans.at(i).at(j);
		}
		cout << endl;
	}
}


Measured memory_bytes: 3588
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
c = [[0 for j in range(w)] for i in range(h)]
x, y = 0, 0
dx = 1

for k in range(n):
    for l in range(a[k]):
        c[y][x] = k + 1
        nx = x + dx
        if nx >= w:
            dx = - 1
            y += 1
        elif nx < 0:
            dx = 1
            y += 1
        else:
            x = nx

for i in range(h):
    for j in range(w):
        print(c[i][j], end = "\n" if j == w - 1 else " ")


Measured memory_bytes: 3920
import sys
input = sys.stdin.readline
n, m = map(int,input().split())
C = [list(map(int,input().split())) for i in range(m)]
for i in range(m):
    for j in range(2):
        C[i][j] -= 1

class UnionFind():  # DSU（disjoint set union, 素集合データ構造）と同じ
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def leader(self, x):  # xが属する連結成分の代表元
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.leader(self.parents[x])
            return self.parents[x]

    def size(self, x):  # xが属する連結成分のサイズ
        return -self.parents[self.leader(x)]

    def merge(self, x, y):  # xとyを辺でつなぐ
        x = self.leader(x)
        y = self.leader(y)
        if x == y:
            return x
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return x

    def same(self, x, y):  # xとyが連結かどうか
        return self.leader(x) == self.leader(y)

    def groups(self):  # 連結成分ごとの頂点リスト
        n = self.n
        leader_index = [-1] * n
        ind = 0
        for i in range(n):
            if self.parents[i] < 0:
                leader_index[i] = ind
                ind += 1
        ANS = [[] for i in range(ind)]
        for i in range(n):
            ld = self.leader(i)
            ANS[leader_index[ld]].append(i)
        return ANS

    def n_cc(self):  # グラフ全体の連結成分の数
        A = [i for i in self.parents if i < 0]
        return len(A)

U = UnionFind(n)
for i in range(m):
    U.merge(C[i][0],C[i][1])
print(U.n_cc()-1)

Measured memory_bytes: 86428
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    	int correct = sc.nextInt();
    	int test = sc.nextInt();
    	if(correct == test) {
          System.out.println("Yes");
        } else {
          System.out.println("No");
        }
  }
}

Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 1000;
int a[maxn], b[maxn], c[maxn];
int n;

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 0; i < n; i++) scanf("%d", &b[i]);
    for (int i = 0; i < n; i++) scanf("%d", &c[i]);
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    ll ans = 0;
    for (int i = 0; i<n; i++) {
        ll p = lower_bound(a, a + n, b[i]) - a;
        ll q = upper_bound(c, c + n, b[i]) - c;
        ans += p*(n - q);
    }
    printf("%lld\n", ans);
}


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

const ll mod=1000000007;

int main() {
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  if(a==0)cout<<1<<endl;
  else if(b==0)cout<<2<<endl;
  else  if(c==0)cout<<3<<endl;
  else if(d==0)cout<<4<<endl;
  else if(e==0)cout<<5<<endl;
}

Measured memory_bytes: 3572
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  4 15:01:58 2019

@author: kaned
"""
A,B,C,D=map(int,input().split())
L=A+B
R=C+D
if L>R:
    print('Left')
elif L<R:
    print('Right')
else:
    print("Balanced")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define vi vector<int>
#define pb emplace_back
#define all(x) (x).begin(), (x).end()
#define deb(x) cout << #x << " - " << x << endl;
const ll MOD = 1e9 + 7;
const ll INF = 1 << 29;
const ll MAX_N = 1e6 + 7;
using namespace std;

int main() {
    IOS;
    int n,flag=1; cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++){
        if(i%3==0||i%5==0) continue;
        sum+=i;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 100000000000000009
#define MOD 1000000007
#define int long long
using P = pair<int,int>;
signed main(){
  int n;
  cin >> n;
  vint a(n);
  rep(i,n) cin >> a[i];
  int ans = INF;
  for(int i = -100;i <= 100;i++){
    int temp = 0;
    rep(j,n){
      int AB = abs(a[j] - i);
      temp += pow(AB,2);
    }
    ans = min(ans,temp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

import numpy as np

def main():
    N, W = map(int, input().split())
    dp = [[0] * (W+1) for i in range(N+1)]
    dp = np.array(dp)
    #dp[i][j]  iまでをみてjの重さでの最大価値
    for i in range(1,N+1):
        w, v = map(int, input().split())
        dp[i][:] = dp[i-1][:]
        dp[i][w:W+1] = np.maximum(dp[i-1][w:W+1], dp[i-1][:W+1-w] + v)

#    print(dp)
    print(dp[N][W])

if __name__ == '__main__':
    main()

Measured memory_bytes: 170440
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;

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


int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    long long ans = 0;
    map<int, int> num_appear;
    set<int> s;
    REP(i, N){
        auto itr = s.lower_bound(i-A[i]);
        if(itr != s.end() and *itr == i-A[i]) ans += num_appear[*itr];
        s.insert(i+A[i]);
        ++num_appear[i+A[i]];
    }
    cout << ans << endl;

    return 0;
}

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

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

int parent[100005];
int sz[100005];
int find_parent(int ver)
{
    if(ver==parent[ver])
        return ver;
    return parent[ver]=find_parent(parent[ver]);
}

bool merge(int a,int b)
{
    a=find_parent(a);
    b=find_parent(b);
    if(a!=b)
    {
        if(sz[a]<sz[b])
            swap(a,b);
        sz[a]+=sz[b];
        parent[b]=a;
        return true;
    }
    return false;
}

signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif    

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

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

int main() {

    std::cout << std::fixed;
    std::cout << std::setprecision(10);

    int n;
    cin >> n;
    int x[8], y[8];
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    int a[8] = { 0,1,2,3,4,5,6,7 };
    long double sum = 0;
    int count = 0;
    do {
        count++;
        for (int i = 1; i < n; i++) {
            int d = (x[a[i]] - x[a[i - 1]]) * (x[a[i]] - x[a[i - 1]]) + (y[a[i]] - y[a[i - 1]]) * (y[a[i]] - y[a[i - 1]]);
            sum += std::sqrt((long double)d);
        }
    } while (next_permutation(a,a+n));
    cout << sum / count << endl;
    return 0;

}

Measured memory_bytes: 256
k = int(input())
#a = map(int,input().split())
#a_L = list(map(int,input().split()))
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[k-1])

Measured memory_bytes: 3060
import sys
input=sys.stdin.readline
N,C=map(int,input().split())
d=[list(map(int,input().split())) for i in range(C)]
c=[list(map(int,input().split())) for i in range(N)]
ans=10**18
mod0=[]
mod1=[]
mod2=[]
for i in range(N):
  for j in range(N):
    k=(i+j+2)%3
    if k==0:
      mod0.append((i,j))
    elif k==1:
      mod1.append((i,j))
    else:
      mod2.append((i,j))
cnt0=[0]*(C+1)
cnt1=[0]*(C+1)
cnt2=[0]*(C+1)
for c0 in range(1,C+1):
  for x,y in mod0:
    cnt0[c0]+=d[c[x][y]-1][c0-1]
for c1 in range(1,C+1):
  for x,y in mod1:
    cnt1[c1]+=d[c[x][y]-1][c1-1]
for c2 in range(1,C+1):
  for x,y in mod2:
    cnt2[c2]+=d[c[x][y]-1][c2-1]
ans=10**18
for c0 in range(1,C+1):
  for c1 in range(1,C+1):
    for c2 in range(1,C+1):
      if c1==c2 or c2==c0 or c0==c1:
        continue
      cnt=cnt0[c0]+cnt1[c1]+cnt2[c2]
      ans=min(ans,cnt)
print(ans)

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

int main(void){
  ll n,m,k; cin >> n >> m >> k;
  ll a[n],b[m];
  vector<ll> A;
  vector<ll> B;
  A.push_back(0);
  B.push_back(0);
  rep(i,n){
    cin >> a[i];
    A.push_back(A.at(i)+a[i]);
  }
  rep(i,m){
    cin >> b[i];
    B.push_back(B.at(i)+b[i]);
  }
  ll best = m;
  ll ans = 0;
  for(ll i = 0; i <= n; i++){
    ll prc = k-A.at(i);
    if(prc < 0) break;
    while(1){
      if(prc >= B.at(best)) break;
      best--;
      if(best < 0) break;
    }
    ans = max(ans,i+best);
  }
  cout << ans << endl;
  return 0;
}


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

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = MAP()

acc = list(range(N+2))
acc = list(accumulate(acc))

ans = 0
for i in range(K, N+2):
    ans += (acc[N+1] - acc[N+1-i]) - acc[i] + 1
    ans %= MOD
print(ans)


Measured memory_bytes: 27468
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int main()
{
    while(1){
        int n;
        scanf("%d",&n);
        if(n == 0){
            break;
        }
        string s[14];
        int d[14][14];
    	rep(i,n){
    		cin >> s[i];
    	}
        set<int> inc;
        rep(i,n){
            for(int j=i+1;j<n;j++){
                string s1,s2;
                int flag;
                if(s[i].length() > s[j].length()){
                    s1 = s[i];
                    s2 = s[j];
                    flag = 0;
                }else{
                    s1 = s[j];
                    s2 = s[i];
                    flag = 1;
                }
                rep(k,s1.length()-s2.length()+1){
                    bool ff = false;
                    rep(l,s2.length()){
                        if(s1[k+l] != s2[l]){
                            ff =true;
                            break;
                        }
                    }
                    if(!ff){
                        flag += 2;
                        break;
                    }
                }
                if(flag >= 2){
                    if(flag == 2){
                        inc.insert(j);
                    }else{
                        inc.insert(i);
                    }
                }
            }
        }
        vector<int> id;
        rep(i,n){
            if(inc.find(i) == inc.end()){
                id.push_back(i);
            }
        }
        int nn = id.size();
        rep(i,nn){
            rep(j,nn){
                if(i != j){
                    int cnt = 0;
                    for(int k=1;k<=min(s[id[i]].length(),s[id[j]].length());k++){
                        bool flag = false;
                        rep(l,k){
                            if(s[id[i]][s[id[i]].length()-k+l] != s[id[j]][l]){
                                flag = true;
                                break;
                            }
                        }
                        if(!flag){
                            cnt = k;
                        }
                    }
                    d[i][j] = cnt;
                }else{
                    d[i][j] = 0;
                }
            }
        }
        int dp[(1 << 14)][14];
        rep(i,1 << nn){
            rep(j,nn){
                dp[i][j] = -INF;
            }
        }
        rep(i,nn){
            dp[(1<<nn)-1][i] = 0;
        }
        for(int i=(1<<nn)-2;i>=0;i--){
            rep(j,nn){
                rep(k,nn){
                    if(!(i & (1<<k))){
                        dp[i][j] = max(dp[i][j],dp[i|(1<<k)][k] + d[j][k]);
                    }
                }
            }
        }
        int mx = 0;
        rep(i,nn){
            mx = max(mx,dp[(1<<i)][i]);
        }
        int sm = 0;
        rep(i,nn){
            sm += s[id[i]].length();
        }
        printf("%d\n",sm-mx);
    }
	return 0;
}

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

int main() {
  int i,j,n,q,count=0,size;
  int *S;
  int *T;
  scanf("%d",&n);
  if(n>10000) exit(8);
  S=(int *)malloc(n*sizeof(int));
  for(i=0;i<n;i++)
    {
      scanf("%d",&S[i]);
      if(S[i]<0 || S[i]>1000000000) exit(8);
    }
  scanf("%d",&q);
  if(q>500) exit(8);
  T=(int *)malloc(q*sizeof(int));
  for(i=0;i<q;i++)
    {
      scanf("%d",&T[i]);
      if(T[i]<0 || T[i]>1000000000) exit(8);
    }
  for(i=0;i<q;i++)
    {
      for(j=0;j<n;j++)
	{
	  if(S[j] == T[i])
	    {
	      count++;
	      break;
	    }
	}
    }
  /*for(i=0;i<q;i++)
    {
      if(linearSearch(&S[0],T[i],n) != EOF)
	{
	  count++;
	}
	}*/
  printf("%d\n",count);
  return 0;
}




Measured memory_bytes: 2108
import java.util.Scanner;

public class Main {
	
	public static int compute_maxprofit(int n, int[] R)
	{
		int min_buy = R[0];
		int max_profit = Integer.MIN_VALUE;
		for(int i = 1; i < n ; i++)
		{
			if(R[i] - min_buy > max_profit)
			{
				max_profit = R[i] - min_buy;
			}
			if(R[i] < min_buy)
			{
				min_buy = R[i];
			}
		}
		return max_profit;
	}
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] nums = new int[n];
		for(int i = 0; i < n ; i++)
		{
			nums[i] = in.nextInt();
		}
		System.out.println(compute_maxprofit(n,nums));
	}
}



Measured memory_bytes: 102256