akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))

B = []
for i in range(M):
    B.append(list(map(int, input().split())))

B = sorted(B, key=lambda x: x[1], reverse=True)

j = 0
for b in B:
    for i in range(b[0]):
        if A[j] < b[1]:
            A[j] = b[1]
            j += 1
            if j == N:
                print(sum(A))
                sys.exit()
        else:
            print(sum(A))
            sys.exit()

print(sum(A))

Measured memory_bytes: 106912
#include <bits/stdc++.h>
using namespace std;
const double PI  = acos(-1.0);

#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{
    double x;
    cin >> x;
    cout << 2 * PI * x;
    return 0;
}



Measured memory_bytes: 3784
S = input()
T = input()
def calc(l):
    new_l = []
    adic = {}
    count = 0
    for c in l:
        if c in adic.keys():new_l.append(adic[c])
        else:
            new_l.append(count)
            adic[c] = count
            count += 1
    return new_l
if calc(S)==calc(T):print('Yes')
else:print('No')

Measured memory_bytes: 6832
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int N = sc.nextInt();
        int[] dist = new int[N];
        int tmp = 0;
        for (int i=0;i<N;i++) {
            int A = sc.nextInt();
            dist[i] = A-tmp;
            tmp = A;
        }
        dist[0] += K-tmp;

        int max = 0;
        for (int i=0;i<N;i++) {
            max = Math.max(max, dist[i]);
        }
        System.out.println(K-max);
    }
}

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

int main() {
	int N,cnt = 0;
  	bool Y_flag = 0,P_flag = 0
      ,G_flag = 0,W_flag = 0;
  	cin >> N;
  
  	string s[N+1];

  	for (int i = 1 ;i <= N; i++ )
      cin >> s[i];
  
  	for (int i = 1; i <= N; i++){
  		if (s[i] == "P") P_flag = 1;
  		else if (s[i] == "W") W_flag =1;
  		else if (s[i] == "Y") Y_flag = 1;
  		else if (s[i] == "G") G_flag = 1;
    }
  
  	if (P_flag == 1) cnt += 1;
    if(W_flag ==1) cnt += 1;
	if(G_flag == 1) cnt += 1;
	if(Y_flag ==1) cnt += 1;
  	
  	if (cnt == 3) cout << "Three" <<endl;
  	else if (cnt == 4) cout << "Four" << endl;
  	
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long m = sc.nextLong();
        if (n < m / 2) {
            System.out.println(n + (m - 2 * n) / 4);
        } else {
            System.out.println(m / 2);
        }
    }
}

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

int main(){
  int x;
  cin >> x;
  int sum = 0;
  sum += x/500 *1000;
  int a = x%500;
  sum += a/5 * 5;
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3584
//
//AtCoder Beginner Contest 107
//A
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int n, i;
    cin >> n >> i;

    cout << n-i+1 << endl;
    return 0;
}


Measured memory_bytes: 3516
#include<bits/stdc++.h>
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int n;
int u,v,x,y;
vector<int> ga[100100];
bool vis[100100];
int dist[2][100100];
queue<int> q;
void BFS(int s,int* dis){
	memset(dis,63,sizeof(dis));
	dis[s]=0;
	q.push(s);
	for(int i=1;i<=n;i++)
		vis[i]=false;
	vis[s]=true;
	while(q.size()){
		s=q.front();
		q.pop();
		for(int i=0;i<ga[s].size();i++){
			int t=ga[s][i];
			if(!vis[t]){
				dis[t]=dis[s]+1;
				vis[t]=true;
				q.push(t);
			}
		} 
	}
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>u>>v;
	for(int i=1;i<n;i++){
		cin>>x>>y;
		ga[x].push_back(y);
		ga[y].push_back(x);
	}
	BFS(u,dist[0]);//Takahashi
	BFS(v,dist[1]);//Aoki
	int mroad=dist[0][v];
	int tim=0,cand;
	for(int i=1;i<=n;i++){
		if(dist[0][i]==dist[1][i])//meet in middle of road
			cand=(mroad/2);
		else if(dist[0][i]>dist[1][i])//Aoki is faster
			cand=0;
		else{
			int rem=dist[1][i]-dist[0][i];
			cand=dist[0][i]+rem-1;
		}
		tim=max(tim,cand);
	}
	cout<<tim<<endl;
	return 0;
}


Measured memory_bytes: 6784
#![allow(non_snake_case)]

use std::io;
use std::io::prelude::*;

/// 素因子判定により高速化
fn is_prime(num: u32) -> bool {
    if num == 2 {
        return true;
    } else if num < 2 || num % 2 == 0 {
        return false;
    }

    let mut i = 3;
    let end = (num as f64).sqrt() as u32;
    while i <= end {
        if num % i == 0 {
            return false;
        }
        i += 2;
    }
    return true;
}

fn main() {
    let sin = io::stdin();
    let mut l_iter = sin.lock().lines();

    let _n: usize = l_iter.next().unwrap().unwrap().trim().parse().unwrap();

    let mut cnt = 0;
    for line in l_iter {
        let l = line.unwrap();
        let d: u32 = l.trim().parse().unwrap();
        if is_prime(d) {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}



Measured memory_bytes: 5044
l=[]
for i in range(3):
    l.extend(list(map(int,input().split())))
m=[0,0,0,0]
for i in range(1,5):
    m[i-1]=l.count(i)
if sorted(m) == [1,1,2,2]:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
import collections


class MaxFlow:
    """Dinic Algorithm: find max-flow
       complexity: O(EV^2)
       used in GRL6A(AOJ)
    """
    class Edge:
        def __init__(self, to, cap, rev):
            self.to, self.cap, self.rev = to, cap, rev

    def __init__(self, V):
        """ V: the number of vertexes
            E: adjacency list
            source: start point
            sink: goal point
        """
        self.V = V
        self.E = [[] for _ in range(V)]

    def add_edge(self, fr, to, cap):
        self.E[fr].append(self.Edge(to, cap, len(self.E[to])))
        self.E[to].append(self.Edge(fr, 0, len(self.E[fr])-1))

    def dinic(self, source, sink, INF=10**9):
        """find max-flow"""
        maxflow = 0
        while True:
            self.bfs(source)
            if self.level[sink] < 0:
                return maxflow
            self.itr = [0] * self.V
            while True:
                flow = self.dfs(source, sink, INF)
                if flow > 0:
                    maxflow += flow
                else:
                    break

    def dfs(self, vertex, sink, flow):
        """find augmenting path"""
        if vertex == sink:
            return flow
        for i in range(self.itr[vertex], len(self.E[vertex])):
            self.itr[vertex] = i
            e = self.E[vertex][i]
            if e.cap > 0 and self.level[vertex] < self.level[e.to]:
                d = self.dfs(e.to, sink, min(flow, e.cap))
                if d > 0:
                    e.cap -= d
                    self.E[e.to][e.rev].cap += d
                    return d
        return 0

    def bfs(self, start):
        """find shortest path from start"""
        que = collections.deque()
        self.level = [-1] * self.V
        que.append(start)
        self.level[start] = 0

        while que:
            fr = que.popleft()
            for e in self.E[fr]:
                if e.cap > 0 and self.level[e.to] < 0:
                    self.level[e.to] = self.level[fr] + 1
                    que.append(e.to)
N, M = map(int, input().split())
mf = MaxFlow(N)
rev_edge = []
for i in range(M):
    s, t = [int(x)-1 for x in input().split()]
    mf.add_edge(s, t, 1)
    mf.add_edge(t, s, 1)
    rev_edge.append((i+1, t, len(mf.E[t])-1))
source, sink = [int(x)-1 for x in input().split()]
print(mf.dinic(source, sink))
ans = []
for i, t, idx in rev_edge:
    e = mf.E[t][idx]
    if mf.E[e.to][e.rev].cap == 1:
        ans.append(i)
print(len(ans))
if ans:
    print(*ans, sep='\n')

Measured memory_bytes: 8836
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let a = Array.to_list @@ Array.init n @@ fun _ -> int_of_string @@ read_line ()

let () =
  if List.hd a != 0 then print_endline "-1"
  else
    let (sum, _) = List.fold_left (fun (sum, before) i ->
      if sum = -1 then (-1, i)
      else let t = i - before in
        if t > 1 then (-1,  i)
        else if t = 1 then (sum + 1, i)
        else (sum + i, i)
      ) (0, 0) @@ List.tl a in
    Printf.printf "%d\n" sum

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

using ll = long long;
using vi = vector<int>;
#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)
#define pb push_back
#define IN(i,a,b) (a<=i&&i<=b)

int di[] = {0,0,1,-1};
int dj[] = {1,-1,0,0};

ll gcd(ll a, ll b) {
	return a?gcd(b%a,a):b;
}
 
ll lcm(ll a, ll b) {
	return a/gcd(a,b)*b;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n; cin>>n;
	if (n==2) {
		cout << "4 7" << endl << "23 10" << endl;
	} else {
		ll a[n][n];
		int mxn = 1e5;
		int sieve[mxn];
		fill(sieve,sieve+mxn,0);
		vi primes;
		f(i,2,mxn) if (sieve[i] == 0) {
			primes.pb(i);
			for (int j = i; j <mxn; j+=i)
				sieve[j] = i;
		}
		ll x[2*n],y[2*n];
		int t = 0;
		for (int i = 0; i < 2*n; i+=2)
			x[i]=x[i+1]=primes[t++];	
		for (int j = 0; j < 2*n; j+=2)
			y[j]=y[j+1]=primes[t++];
		fr(i,0,n) y[i] = primes[t++];
		f(i,0,n) f(j,0,n) if (!((i+j)&1)) 	
			a[i][j] = x[n+i-j]*y[n+n-1-i-j];
		f(i,0,n) f(j,0,n) if ((i+j)&1) {
			ll w = 1;
			f(k,0,4) {
				int ni = i+di[k], nj = j+dj[k];
				if (IN(ni,0,n-1) && IN(nj,0,n-1)) 
					w = lcm(w,a[ni][nj]);
			}
			a[i][j] = w+1;
		}
		stringstream ss;
		f(i,0,n) f(j,0,n) ss << a[i][j] << " \n"[j+1==n];
		cout << ss.str();


	}

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif

	return 0;
}



Measured memory_bytes: 12736
let () =
    let main () =
        let n, k = Scanf.sscanf (read_line ()) "%d %d" (fun n k -> n, k) in
        let r, s, p = Scanf.sscanf (read_line ()) "%d %d %d" (fun r s p -> r, s, p) in
        let t = read_line () in
        let judge a b =
            match a, b with
            | 's', 'r' -> r
            | 'p', 's' -> s
            | 'r', 'p' -> p
            | _ -> 0
        in
        let z = "rsp" in
        let rec loop offset acc =
            let rec calc offset acc =
                if offset >= n then Array.fold_left max 0 acc else (
                    let newacc = [| 0; 0; 0 |] in
                    newacc.(0) <- max (acc.(1) + judge t.[offset] z.[0]) (acc.(2) + judge t.[offset] z.[0]);
                    newacc.(1) <- max (acc.(0) + judge t.[offset] z.[1]) (acc.(2) + judge t.[offset] z.[1]);
                    newacc.(2) <- max (acc.(0) + judge t.[offset] z.[2]) (acc.(1) + judge t.[offset] z.[2]);
                    calc (offset + k) newacc
                )
            in
            if offset = k then acc else loop (offset + 1) (acc + calc offset [| 0; 0; 0 |])
        in
        loop 0 0 |> Printf.printf "%d\n"
    in
    main ()

Measured memory_bytes: 4864
# ABC075C - Bridge
# find the number of bridges in a given undirected connected graph
# bridge := an edge whose removal disconnects a graph
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)


def dfs(v: int) -> None:
    seen[v] = 1  # make vertex v searched
    for u in g[v]:
        if not seen[u]:
            dfs(u)


def main():  # O(M(N + M))
    global g, seen
    N, M, *E = map(int, open(0).read().split())
    G = [[] for _ in range(N + 1)]
    for v, u in zip(*[iter(E)] * 2):
        G[v].append(u), G[u].append(v)
    bridges = 0
    for v, u in zip(*[iter(E)] * 2):
        g = [v.copy() for v in G]  # subgraph of G except E(v, u)
        g[v].remove(u), g[u].remove(v)
        seen = [0] * (N + 1)
        dfs(1)  # search from vertex 1
        bridges += 1 if 0 in seen[1:] else 0
    print(bridges)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
//vector<ll>adj[300005];
ll adj[503][503];
ll dp[503][503],arr[505][505];
int main()
{
    ll n,m,q,li,ri,pi,qi,i,j;
    cin>>n>>m>>q;
    while(m--)
    {
        cin>>li>>ri;
        adj[li][ri]++;
        //dp[li][ri]=1;
    }
    for(i=1;i<=n;i++)
    {
        dp[i][i]=adj[i][i];
        for(j=i+1;j<=n;j++)
        {
            dp[i][j]=dp[i][j-1]+adj[i][j];
        }
    }
    ll cnt;
    while(q--)
    {
        cnt=0;
        cin>>pi>>qi;
        for(i=pi;i<=qi;i++)
        {
            cnt+=dp[i][qi];
        }
        cout<<cnt<<'\n';
    }
    return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <string>

using namespace std;

int main() {
	string a;
	int n;
	int h;
	while (cin >> a) {
		if (a == "-") {
			break;
		}
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> h;
			a = a.substr(h) + a.substr(0,h);
		}
		cout << a << endl;
	}
	return 0;
}

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

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

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

    int pay = N * 800;
    int a = pay / 800;
    int discount = a / 15;
    int total = 0;

    rep (i, discount) {
        total = i * 200;
    }

    cout << pay - total << endl;

    return 0;
}

Measured memory_bytes: 3636
import sys

def binary_len(n):
    return len('{0:b}'.format(n))

def count_bits(As):
    bits = [0] * 40
    for a in As:
        for b in range(40):
            if (a & 1 << b) != 0:
                bits[b] += 1
    return bits


def main(N, K, As):
    #print('K: {0:b}'.format(K))
    # number of bits in reverse order; bits[0] if rightmost digit
    bits = count_bits(As)
    #print(bits)

    answer = 0

    k = K
    for digit in reversed(range(0, 40)):
        if (1 << digit) & k == 0:
            answer += (bits[digit]) * (1 << digit)
        elif bits[digit] <= N/2:
            # need to flip this bit
            k = k - (1 << (digit))
            answer += (N - bits[digit]) * (1 << digit)
        else:
            k = (1 << (digit)) - 1
            answer += (bits[digit]) * (1 << digit)

        #print("digit: {}".format(digit))
        #print("k:{}".format(k))
        #print("answer:{}".format(k))
    return answer


if __name__ == '__main__':
    line = sys.stdin.readline()
    N,K = [int(x) for x in line.strip().split(' ')]

    line = sys.stdin.readline()
    As = [int(x) for x in line.strip().split(' ')]

    assert N == len(As)
    print(main(N, K, As))

Measured memory_bytes: 16208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)

int main(){
    int H, W; cin >> H >> W;
    vector<vector<int> > A(H+1, vector<int>(W+1));
    rep(i , 1, H+1) rep(j, 1, W+1) cin >> A[i][j];
    rep(i , 1, H+1) rep(j, 1, W+1) {int t;cin >> t; A[i][j] = abs(A[i][j] - t);}

    bitset<12801> dp[81] = {};
    dp[0][6400] = 1;
    rep(i, 1, H+1){
        rep(j,1,W+1){
            int a = A[i][j];
            dp[j] = ((dp[j-1] | dp[j]) << a) | ((dp[j-1] | dp[j]) >> a);
        }
        dp[0][6400]=0;
    }

    rep(j , 0, 81){
        //cerr << dp[W][6400 + j] << endl;
        if(dp[W][6400 + j]){cout << j << endl; return 0;}
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
  	Cin(int, n, k);
    Cin(string, s);
  	s[k-1] += 32;
    Cout(s);
}

Measured memory_bytes: 256
#値の入力
A1, A2, A3 = map(int, input(). split()) 

#値が範囲内か
if 1 > A1 or A1 > 13:
    print("もう一度入力して下さい")
    A1 = int(input("A1:"))
if 1 >A2 or A2 > 13:
    print("もう一度入力して下さい")
    A2 = int(input("A2:"))
if 1 > A3 or A3 > 13:
    print("もう一度入力して下さい")
    A3 = int(input("A3:"))

#判定
if(A1+ A2+ A3 >= 22):
    print("bust")
else:
    print("win")


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vll = vector<long long>;
using vpi = vector<pair<int, int>>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)

const char nl = '\n';
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

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

    int n; cin >> n;
    vector<double> p(n);
    F0R (i, n) cin >> p[i];

    vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0));
    dp[0][0] = 1;
    FOR (i, 1, n) {
        F0R (j, i + 1) {
            dp[i][j] = (1 - p[i - 1]) * dp[i - 1][j];
            if (j > 0) {
                dp[i][j] += p[i - 1] * dp[i - 1][j - 1];
            }
        }
    }
    double ans = 0;
    F0R (i, n / 2 + 1) {
        ans += dp[n][n - i];
    }
    cout << setprecision(9) << ans << endl;

    return 0;
}


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

int gcd(int a, int b);

int main() {
    std::ios_base::sync_with_stdio(false);

    int N, M;
    string S, T;

    cin >> N >> M;
    cin >> S >> T;

    int64_t L = N * (int64_t)M / gcd(N, M);
    int k1 =L/N, k2 = L/M;
    int c = 0;
    for (int64_t i=0; c < N && i < L; ++c, i+=k1) {
        int j = i/k2;
        if (i%k2 != 0) continue;
        if (j < M && S[c] != T[j]) {
            cout << -1 << endl;
            goto l1;
        }
    }

    cout << L << endl;

l1:
    return 0;
}

int gcd(int a, int b) {
    if (a == 0) return b;
    return gcd(b%a, a);
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(signed)(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 9000000000000;
#define LX 100010
    // struct edge{ll from,to,cost;};
    // edge es[2010];
    ll N,A,B;
    ll h[LX];

bool Judge(int x){
    int count=0;
    ll cost;
    for(int i=N-1;0<=i;i--){
         cost=h[i]-B*x;
        if(cost<=0)break;
            count+=(cost/(A-B));
            if(cost%(A-B)!=0)count++;
        if(count>x)break;
    }
    DEB(count)DEB(x)TF(!(count>x))END
    if(count>x)return false;
    else return true;

}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>A>>B;
    REP(i,N)cin>>h[i];
    sort(h,h+N);
    int low=0,high=h[N-1]/B+1;
    ll mid;
    while(abs (high-low) > 1){
        mid=(high+low)/2;
        DEB(high)DEB(mid)DEB(low)END
        if(Judge(mid))high=mid;
        else low=mid;
    }
    if(!Judge(mid))mid++;
    cout<<mid;
}
//ABC063 D - Widespread


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

const int INF = 1 << 30;

int main()
{
    int w, n;
	int times = 0;
    while(cin >> w && w)
    {
		times++;
		cin >> n;

		vint now(w+1), last(w+1);

		rep(i, n)
		{
			int val, wei;
			char k;
			cin >> val >> k >> wei;

			if(i == 0)
			{
				fill(ALL(last), 0);
				last[wei] = val;
			}
			else
			{
				rep(i, w+1)
				{
					if(i < wei)
					{
						now[i] = last[i];
					}
					else
					{
						now[i] = max(last[i], last[i - wei] + val);
					}
				}


				last = now;
			}
		}

		int rv = 0, rw = 0;
		rep(i, w + 1)
		{
			if(rv < last[i])
			{
				rv = last[i];
				rw = i;
			}
		}

		cout << "Case " << times << ":" << endl << rv << endl << rw << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(ll i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)
#define REP(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    ll N;
    cin >> N;
    FOR(n,1,3501) FOR(h,1,3501) {
        ll child = h*n*N;
        ll mother = 4 * h * n - N * n - N*h;
        if(mother == 0) continue;
        if (child % mother != 0) continue;
        auto w = child / mother;
        if ( w > 0) {
            cout << h << " " << n << " " << w << endl;
            return;
        }
    }
}

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

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

#define F first
#define S second
#define pii pair<int, int>
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e6 + 10, mod = 1e9 + 7;

int dp[N], ps[N];

int main()
{
	int n, sum; cin >> n;
	dp[1] = n;
	dp[2] = (ll)n * n % mod;
	sum = (dp[1] + dp[2]) % mod;

	for (int i=3; i<=n; i++)
	{
		dp[i] = (((ll)sum - dp[i - 2] + mod) + (ll)(n - 1) * (n - 1)) % mod;
		dp[i] += (n - i + 2), dp[i] %= mod;
		sum += dp[i], sum %= mod;
	}
	cout << dp[n] << endl;
}


Measured memory_bytes: 6016
#!/usr/bin/env python3
import sys
import itertools

inf = float('inf')

def solve(N: int, C: int, D: "List[List[int]]", c: "List[List[int]]"):
    num_count = [[0] * C for i in range(3)]
    for i in range(N):
        for j in range(N):
            num_count[(i+j)%3][c[i][j]] += 1
    
    diff_sum = [[0] * C for i in range(3)]
    for i in range(C):
        for j in range(C):
            for n in range(3):
                diff_sum[n][j] += D[i][j] * num_count[n][i]

    res = inf
    for i, j, k in itertools.permutations(range(C), 3):
        s = diff_sum[0][i] + diff_sum[1][j] + diff_sum[2][k]
        if s < res:
            res = s
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = [ [ int(next(tokens)) for _ in range(C) ] for _ in range(C) ]  # type: "List[List[int]]"
    c = [ [ int(next(tokens))-1 for _ in range(N) ] for _ in range(N) ]  # type: "List[List[int]]"
    solve(N, C, D, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5492
function Main(input: string) {
    const splited = input.split('\n');
    const persons = parseInt(splited[0]);

    let opinions = [];
    let targetIndex = 1;

    for (let i = 0; i < persons; i++) {
        let opinionCount = parseInt(splited[targetIndex]);
        opinions.push([]);
        for (let j = 0; j < opinionCount; j++) {
            opinions[i].push(splited[targetIndex + 1 + j].split(' '))
        }
        targetIndex += opinionCount + 1;
    }

    const bitConvert = (bit: string, keta: number) => {
        return ('0000000000000000' + bit).slice(-keta);
    }

    let maxCount: number = 0;

    for (let bit = 0; bit < (1 << persons); bit++) {
        let tempCount: number = 0;
        let liarCheck = false;

        let bits = bitConvert(bit.toString(2), persons).split('').reverse();
        for (let i = 0; i < persons; i++) {
            if (bit & (1 << i)) {
                let targetOpinion = opinions[i];
                if (targetOpinion.some((v) => {
                    return bits[v[0] - 1] != v[1]
                })) {
                    liarCheck = true
                    break;
                }
                tempCount++;
            }
        }
        if (!liarCheck) {
            maxCount = Math.max(maxCount, tempCount);
        }
    }

    console.log(maxCount);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 10600
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>

int main(int argc, char* argv[])
{	
	int32_t N, cnt = 0;
	std::cin >> N;
	for (int32_t i = 0; i < N;++i)
	{
		int32_t l;
		std::cin >> l;
		cnt += ((i % 2 == 0) && (l % 2 != 0)) ? 1 : 0;
	}
	std::cout << cnt;
}


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

int solve(int x, int med1, int med2) {
  if (x <= med1) {
    return med2;
  } else if (x >= med2) {
    return med1;
  }
}

int main() {
  int i, n, med1, med2;
  cin >> n;
  vector<int> x(n), x2(n);
  for (i = 0; i < n; i++) {
    cin >> x[i];
  }

  x2 = x;
  sort(x2.begin(), x2.end());
  med1 = x2[n / 2 - 1];
  med2 = x2[n / 2];

  for (i = 0; i < n; i++) {
    cout << solve(x[i], med1, med2) << "\n";
  }

  return 0;
}


Measured memory_bytes: 3712
#include <stdio.h>

#define NUM 100

int main(void)
{
	int r,c;
	int i,j;
	int count[NUM + 1][NUM + 1] = { 0 };
	int count1[NUM][NUM];
	int sum = 0;
	scanf("%d %d", &r, &c);

	for (i = 0; i < r; i++){
		for (j = 0; j < c; j++){
			scanf("%d", &count1[i][j]);
			count[i][j] = count1[i][j];
		}
	}
	//??????????¨????
	for (i = 0; i < c; i++){
		for (j = 0; j < r; j++){
			count[r][i] += count1[j][i];
		}
		sum += count[r][i];//??¨??¨??????????¨?????????????
	}
	//??????????¨????
	for (i = 0; i < r; i++){
		for (j = 0; j < c; j++){
			count[i][c] += count1[i][j];
		}
	}
	//??¨??¨??????????¨????
	count[r][c] = sum;

	for (i = 0; i <= r; i++){
		for (j = 0; j <= c; j++){
			printf("%d", count[i][j]);
			if (j < c)
				printf(" ");
		}
		printf("\n");
	}

	return 0;
}

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

int main(){
  int A,B,M;
  cin >> A >> B >> M;
  vector<int> a(A);
  vector<int> b(B);
  int MINA=100010,MINB=100010;
  for(int i=0;i<A;i++){
    cin>>a[i];
    MINA=min(MINA,a[i]);
  }
  for(int i=0;i<B;i++){
    cin>>b[i];
    MINB=min(MINB,b[i]);
  }
  int MINX=MINA+MINB;
  for(int i=0;i<M;i++){
    int x,y,c;
    cin >> x >> y >> c;
    MINX=min(MINX,a[x-1]+b[y-1]-c);
  }
  cout << MINX << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    long long sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> a.at(i);
        sum += a.at(i);
    }
    
    long long x = a.at(0), y = sum - a.at(0);
  	long long ans = abs(x - y); 
    for(int i = 1; i < N-1; i++) {
        x += a.at(i);
        y -= a.at(i);
        ans = min(ans, abs(x-y));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> >vvi;
const ll MOD=1000000007LL;
int main(){
  ll n,a,b,c;
  cin>>n>>a>>b>>c;
  vector<ll>l(n);
  rep(i,n)cin>>l[i];
  ll MIN=INF;
  ll big=std::pow(4,n);
  for(ll bit=0;bit<big;bit++){
    ll k=bit;
    ll sumA=0,sumB=0,sumC=0,countA=0,countB=0,countC=0;
    for(int i=n-1;i>=0;i--){
      ll part=std::pow(4,i);
      if(k/part==0){
        countA++;
        sumA+=l[i];
      }
      if(k/part==1){
        countB++;
        sumB+=l[i];
      }
      if(k/part==2){
        countC++;
        sumC+=l[i];
      }
      k%=part;
    }
    
    if(countA>=1 && countB>=1 && countC>=1)MIN=min(MIN,(countA+countB+countC-3)*10+abs(sumA-a)+abs(sumB-b)+abs(sumC-c));

  }
  cout<<MIN<<endl;
}
    
    
  


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

const int MXN = 2e5, IINF = 1e9 + 10, INF = 1e18 + IINF + 10, MOD = 1000000007;
const ld PI = 4.0 * atanl(1.0), PREC = .000001;
const char nl = '\n';

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define ins insert

int n, m, t, a[MXN];

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

vi adj[MXN];

int main() {
  fast();
  cin >> n >> m;
  FOR(i, 0, m) {
    int u, v;
    cin >> u >> v;
    adj[u].pb(v);
    adj[v].pb(u);
  }
  FOR(i, 0, n) { cout << adj[i + 1].size() << nl; }

  return 0;
}



Measured memory_bytes: 8272
n, m = map(int, input().split())

ball = [1] * n
flag = [1] + [0] * (n-1)

for _ in range(m):
    x, y = map(int, input().split())
    x, y = x-1, y-1

    ball[x] -= 1
    ball[y] += 1

    if flag[x] == 1:
        flag[y] = 1

    if ball[x] == 0:
        flag[x] = 0

print(sum(flag))

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<long long> num(k, 0);
    // num[x] = kで割ってxあまる数が1以上N以下に何個あるか
    for (int i = 1; i <= n; ++i) num[i % k]++;
    long long res = 0;
    for (int a = 0; a < k; ++a) {
        int b = (k - a) % k;
        int c = (k - a) % k;
        if ((b + c) % k != 0) continue;
        res += num[a] * num[b] * num[c];
    }
    cout << res << endl;
}

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

int main()
{
    string s;
    cin >> s;
    
    int n = s.size();
    long long res = 0;
    
    for(int bit = 0; bit < 1 << (n - 1); ++bit)
    {
        long long tmp = 0;
        
        // move to next digit by multiplying 10
        for(int j = 0; j < n - 1; ++j)
        {
            tmp *= 10;
            tmp += s[j] - '0';
            
            // insert plus sign
            if(bit & (1 << j))
            {
                res += tmp;
                tmp = 0;
            }
        }
        // add tmp to result at the last digit
        tmp *= 10;
        tmp += s.back() - '0';
        res += tmp;
    }
    
    cout << res << "\n";
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

LL dp[100001];
LL mod = 1'000'000'007;

void solve()
{
    int N, M; cin >> N >> M;
    dp[0] = dp[1] = 1;
    array<int, 100001> isSafe;
    isSafe.fill(1);
    REP0(i, M)
    {
        int a; cin >> a;
        isSafe[a] = 0;
    }
    FOR(i, 2, N+1)
    {
        dp[i] = ( isSafe[i-1] * dp[i-1] + isSafe[i-2] * dp[i-2] ) % mod;
    }
    cout << dp[N] << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    solve();
    return 0;
}

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

using namespace std;

int main(){
  int i, n;
  double x, y, radian, Cos_theta, _theta, theta;
  char c;

  while(1){
    cin >> n;
    if(n == -1) break;

    x=0;
    y=0;
    radian=0;
    theta=0;

    for(i=0; i<n; ++i){
      x += cos(radian);
      y += sin(radian);
      radian = theta + M_PI/2;

      Cos_theta = (i+1)/(sqrt(i+1) * sqrt(i+2));
      _theta = acos(Cos_theta);
      theta += _theta;
    }

    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(2);
    cout << x << endl;
    cout << y << endl;

  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>

using namespace std;

int n;
string s;

int main(void)
{
	cin >> s;
	n = s.size();
	s = '#' + s;
	
	if(s[n] == '1' || s[1] == '0'){
		cout << -1 << endl;
		return 0;
	}
	for(int i = 1; i <= n-1; i++){
		if(s[i] != s[n-i]){
			cout << -1 << endl;
			return 0;
		}
	}
	
	int p = 1, id = 2;
	for(int i = 1; i <= n-1; i++){
		if(s[i] == '0'){
			cout << p << " " << id++ << endl;
		}else{
			cout << p << " " << id++<< endl;
			p = id-1;
		}
	}
	
	return 0;
}

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

double dp[301][301][301];

double solve(int x,int y,int z, int &n){
    if(x<0||y<0||z<0)
        return 0; // can return anything anyway gettig multiplied by 0
    if(x==0 && y==0 && z==0)
        return 0;
    if(dp[x][y][z]>-0.9)
        return dp[x][y][z];
    double ans = n+x*solve(x-1,y,z,n)+y*solve(x+1,y-1,z,n)+z*solve(x,y+1,z-1,n);
    return dp[x][y][z]=ans/(x+y+z);
}

int main()
{
    int n,one=0,two=0,three=0,x;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        if(x==1)
            one++;
        else if(x==2)
            two++;
        else
        {
            three++;
        }
        
    }
    memset(dp,-1,sizeof(dp));
    cout<<fixed<<setprecision(10)<<solve(one,two,three,n)<<"\n";
    return 0;
}

Measured memory_bytes: 216884
#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 = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

mint choose(ll n, ll a){
    mint x, y;
    x = 1; y = 1;
    rep(i,a){
        x *= (a - i);
        y *= (n - i);
    }
    y /= x;
    return y;
    }

int main(){
    ll n, k;
    cin >> n >> k;
    mint ans;
    for (int i = k; i < n + 2; i ++){
        ans += (mint(n) - mint(i) + 1) * mint(i) + 1;
    }
    cout << ans.x << endl;
}

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

using namespace std;

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

Measured memory_bytes: 3912
#include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <cctype>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;


int main(void) {
    long x, y;
    cin >> x >> y;

    if(abs(x - y) <= 1){
        cout << "Brown" << endl;
    }else{
        cout << "Alice" << endl;
    }

    return 0;
}


Measured memory_bytes: 888
#include<iostream>
typedef long long ll;
using namespace std;
ll parent[100001];
ll s[100001];
ll input[100001][2];
ll ans[100001];
ll sum;
ll Find(ll x)
{
	if (x == parent[x])
	{
		return x;
	}
	else
	{
		ll p = Find(parent[x]);
		parent[x] = p;
		return p;
	}	
}
void Union(ll x, ll y)
{
	x = Find(x);
	y = Find(y);
	if (x != y)
	{
		parent[y] = x;
		sum += s[x] * (s[x] - 1) / 2;
		sum += s[y] * (s[y] - 1) / 2;
		s[x] += s[y];
		sum -= s[x] * (s[x] - 1) / 2;
	}
}
int main()
{
	ll n, m;
	scanf("%lld %lld", &n, &m);
	for (int i = 1; i <= n; i++)
	{
		parent[i] = i;
		s[i] = 1;
	}
	for (int i = 0; i < m; i++)
		scanf("%lld %lld", &input[i][0], &input[i][1]);
	sum = n * (n - 1) / 2;
	for (int i = m - 1; i >= 0; i--)
	{
		ans[i] = sum;
		Union(input[i][0], input[i][1]);
	}
	for (int i = 0; i < m; i++)
		printf("%lld\n", ans[i]);
	return 0;
}

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

struct Card {char suit, value; };

void bubbletw(struct Card A[], int N){
    for(int i = 0;i<N;i++){
        for(int j = N-1;j>=i;j--){
            if(A[j].value < A[j-1].value){
                Card t =A[j]; A[j] = A[j-1]; A[j-1]=t;
            }
        }
    }
}

void selectiontw(struct Card A[],int N){
    for(int i=0;i<N;i++){
        int minj = i;
        for(int j=i;j<N;j++){
            if(A[j].value < A[minj].value)minj = j;
        }
        Card t = A[i]; A[i] = A[minj];A[minj] = t;
    }
}

void printw(struct Card A[], int N){
    for(int i=0; i<N; i++){
        if(i>0)cout<<" ";
        cout<<A[i].suit<<A[i].value;
    }
    cout<<endl;
}


bool isStabletw(struct Card C1[], struct Card C2[], int N){
    for (int i=0; i<N; i++){
        if(C1[i].suit != C2[i].suit)return false;
    }
    return true;
}

int main(){
    Card C1[100],C2[100];
    int Ntw;
    char chtw;

    cin >> Ntw;
    for(int i=0;i<Ntw;i++){
        cin >> C1[i].suit >> C1[i].value;
    }

    for(int i=0;i<Ntw;i++)C2[i]=C1[i];

    bubbletw(C1,Ntw);
    selectiontw(C2,Ntw);

    printw(C1,Ntw);
    cout << "Stable" << endl;
    printw(C2,Ntw);
    if (isStabletw(C1,C2,Ntw)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }

    return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX 110000

int n;
vector<pair<int,int>> G[MAX];
int dis[MAX], dis3[MAX];

void dfs1(int node, int previous){
	int maximum = 0;
	
	for(int i = 0; i < G[node].size(); i++){
		if(previous == G[node][i].first) continue;
		dfs1(G[node][i].first, node);
		maximum = max(maximum, dis[G[node][i].first] + G[node][i].second);
	}
	
	dis[node] = maximum;
}

int dfs2(int node, int previous, int pmax){
	vector<pair<int,int>> dis2;
	int res = 0;
	
	
	dis2.push_back(make_pair(pmax, previous));
	
	for(int i = 0; i < G[node].size(); i++){
		if(previous == G[node][i].first) continue;
		dis2.push_back(make_pair(dis[G[node][i].first] + G[node][i].second, G[node][i].first));
	}
	
	sort(dis2.begin(), dis2.end(), greater<pair<int,int>>());
	
	for(int i = 0; i < dis2.size() && i < 1; i++){
		dis3[node] += dis2[i].first;
	}
	
	
	for(int i = 0; i < G[node].size(); i++){
		if(previous == G[node][i].first) continue;
		int npmax = 0;
		if(dis2.size() && G[node][i].first != dis2[0].second) npmax = dis2[0].first;
		if(dis2.size() >= 2 && G[node][i].first == dis2[0].second)  npmax = dis2[1].first;
		dfs2(G[node][i].first, node, npmax + G[node][i].second);
		// dis3[node] = max(dis3[node], dis3[G[node][i].first]);
	}
	
}

signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	int s, t, w;
	int start = 0;
	int ans = 0;
	cin >> n;
	
	for(int i = 0; i < n-1; i++){
		cin >> s >> t;
		s--, t--;
		G[s].push_back(make_pair(t,1));
		G[t].push_back(make_pair(s,1));
	}
	
	dfs1(start,-1);
	
	dfs2(start, -1, 0);
	
	for(int i = 0; i < n; i++){
		cout<<(n-1)*2 - dis3[i]<<endl;
	}
	return 0;
}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO  = "No";

int func(int n, vi s) {
    int temp = s[0];
    // for (int i = 1; i < n; i++) {
    rep1(i, n - 1) {
        if (temp - 1 <= s[i]) {
            temp = max(temp, s[i]);
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

int main() {
    int n;
    cin >> n;
    vi s(n);
    rep(i, n) { cin >> s[i]; }
    func(n, move(s));
    return 0;
}


Measured memory_bytes: 640
#include <iostream>

int main()
{
    int points;
    std::cin >> points;

    int *value = new int[points];
    for (int i = 0; i < points; i++) std::cin >> value[i];

    int minValue  = value[0] < value[1] ? value[0] : value[1];
    int maxProfit = value[1] - value[0];
    for (int i = 2; i < points; i++)
    {
        if (value[i] < minValue)
        {
            minValue = value[i];
        }
        else
        {
            if (value[i] - minValue > maxProfit) maxProfit = value[i] - minValue;
        }
    }

    std::cout << maxProfit << std::endl;
}


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

int main(){
  int N,M,sum1,sum2;
  cin >> N >> M;
  vector<int>road1(M);
  vector<int>road2(M);
  vector<int>allsum1(N+1);
  vector<int>allsum2(N+1);      
  for(int i = 0; M > i ; i++){
    cin >> road1.at(i) >> road2.at(i);
  }
  for( int s = 1 ; N >= s ; s++){
    sum1 = 0;
    for( int i = 0; M > i ; i++){
      if( s == road1.at(i) ){
        sum1++;
      }
    }
    allsum1.at(s) = sum1;
  }
  for( int s = 1 ; N >= s ; s++){
    sum2 = 0;
    for( int i = 0; M > i ; i++){
      if( s == road2.at(i) ){
        sum2++;
      }
    }
    allsum2.at(s) = sum2;
  }
    for(int s = 1 ; N >= s; s++){
      cout << allsum1.at(s) + allsum2.at(s) << endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
   int N,R,ans;
   cin >> N >>R;
  
  if(N<10){
   ans = 1000 - 100*N + R;
  }
  else{
    ans = R;
  }
    
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256