akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;

//-------------------------------------

using P = pair<double, double>; //x, y

P makeVec(P prev, P next)
{
    double x = next.first - prev.first;
    double y = next.second - prev.second;
    return P(x, y);
}

double calc(P prev, P next)
{
    double x1 = prev.first;
    double y1 = prev.second;
    double x2 = next.first;
    double y2 = next.second;
    return fabs((atan2(x1 * y2 - x2 * y1, x1 * x2 + y1 * y2) / PI) * 180.0);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<P> point(n);
    for (int i = 0; i < n; i++)
    {
        cin >> point[i].first >> point[i].second;
    }
    double ans = 1000000;
    sort(ALL(point));
    do
    {
        // cout << "dbg:";
        // for(int i=0;i<n;i++){
        //     if(i == n - 1){
        //         cout << "(" << point[i].first << ", " << point[i].second << ")" << endl;
        //     }else
        //     {
        //         cout << "(" << point[i].first << ", " << point[i].second << ")" << " ";
        //     }
        // }
        double tmp = 0;
        vector<P> vec;
        vec.push_back(P(1, 0));
        vec.push_back(makeVec(P(0, 0), point[0]));
        for (int i = 0; i < n; i++)
        {
            if (i == n - 1)
            {
                vec.push_back(makeVec(point[i], P(0, 0)));
            }
            else
            {
                vec.push_back(makeVec(point[i], point[i + 1]));
            }
        }
        for (int i = 0; i < vec.size() - 1; i++)
        {
            tmp += calc(vec[i], vec[i + 1]);
        }
        chmin(ans, tmp);
    } while (next_permutation(ALL(point)));
    cout << fixed;
    cout << setprecision(15) << ans << endl;
}


Measured memory_bytes: 3556
x = gets.to_i
0.upto(200) do |i|
  200.downto(0) do |j|
    [-1, 1].each do |p|
      [-1, 1].each do |q|
        if p * (i ** 5) - q * (j ** 5) == x
          puts "#{p * i} #{q * j}"
          exit
        end
      end
    end
  end
end

Measured memory_bytes: 14364
fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let n: u64 = s.trim().parse().unwrap();
	if n & 1 == 1 {
		println!("0");
		return;
	}
	let mut ans = 0;
	let mut d = 10;
	while d <= n {
		ans += n / d;
		d *= 5;
	}
	println!("{}", ans);
}


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

int main(){
	int n,a[100005]={},b[100005]={};
	cin>>n;
	for(int i=0; i<n/2; i++){
		int x,y;
		cin>>x>>y;
		a[x]++,b[y]++;
	}
	int amax=0,bmax=0,ai,bi;
	for(int i=0; i<100005; i++){
		if(amax<a[i])amax=a[i],ai=i;
		if(bmax<b[i])bmax=b[i],bi=i;
	}
	sort(a,a+100005,greater<int>());
	sort(b,b+100005,greater<int>());
	if(ai==bi)cout<<min(n-a[0]-b[1],n-a[1]-b[0])<<endl;
	else cout<<n-a[0]-b[0]<<endl;
}


Measured memory_bytes: 1024
N=int(input())
A=list(map(int,input().split()))
B=[A[i]-i-1 for i in range(N)]
B.sort()
if N%2==1:
  med=B[N//2]
else:
  med=(B[N//2-1]+B[N//2])//2
ans=0
for i in range(N):
  ans+=abs(B[i]-med)
print(ans)

Measured memory_bytes: 107672
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int n, ans = 0;
int x[] = {7, 3, 5};

bool valid (ll num) {
	if (!num) return false;
	int has[] = {0, 0, 0};
	while (num) {
		int p = num % 10;
		num /= 10;
		Foz(i, 3) if (p == x[i]) has[i] = 1;
	}
	return has[0] && has[1] && has[2];
}

void calc (ll num) {
	if (num > n) return;
	ans += valid(num);
	Foz(i, 3) calc(10 * num + x[i]);
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	cin >> n;
	calc(0);
	cout << ans << '\n';
}



Measured memory_bytes: 384
#include <iostream>
using namespace std;
 
int main(){
	int n,pm,pe,pj;
	
	while(cin >> n,n){
		for(int i=0;i<n;i++){
			cin >> pm >> pe >> pj;
			
			double me=(pm+pe)/2;
			double avg=(pm+pe+pj)/3;
			
			if(pm==100||pe==100||pj==100||me>=90||avg>=80){
				cout << "A" << endl;
			}
			else if(avg>=70||avg>=50&&(pm>=80||pe>=80)){
				cout << "B" << endl;
			}
			else cout << "C" << endl;
		}
	}
  return 0;
}

Measured memory_bytes: 0
from scipy import stats
import sys
def main():
    input = sys.stdin.readline
    n = int(input())
    As = list(map(int, input().split()))

    """
    ansinv = 0
    for i in range(n):
        ansinv += 1 / as[i]

    ans = 1 / ansinv
    """
    ans = stats.hmean(As) / n
    print(ans)
 
if __name__ == '__main__':
    main()

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
//#define int long long

bool solve(){
    int n; cin >> n;
    map<string, bool> word;
    char prev;
    string s;
    
    cin >> s;
    prev = *(s.end()-1);
    word[s] = true;
    rep(i, n-1){
        cin >> s;
        if(*s.begin() != prev || word.count(s)){
            return false;
        }
        word[s] = true;
        prev = *(s.end()-1);
    }
    return true;
}

signed main(){
    cout << (solve() ? "Yes" : "No") << endl;
}

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

int main(){
  long N,D,x,y,ab,c=0,X[2*(int)pow(10,5)],Y[2*(int)pow(10,5)];
  scanf("%ld",&N);
  scanf("%ld",&D);
  for(int n=0;n<N;n++){
    scanf("%ld",&x);
    scanf("%ld",&y);
    X[n]=x;
    Y[n]=y;
    if(sqrt(pow(X[n],2)+pow(Y[n],2))<=D){
      c++;
    }
  }
  // for(int n=0;n<N-1;n++){
  //   a=pow(X[n],2)+pow(Y[n],2);
  //   b=sqrt(a);
  //   if(b<=D){
  //     c++;
  //   }
  // }
  printf("%d\n",c);
return 0;
}

Measured memory_bytes: 5276
import java.io.*
import java.util.*

fun solve(H: Long){
    fun count(h: Long): Long =
        when(h){
            1L -> 1L
            else -> 1 + 2*count(h/2)
        }
    println(count(H))
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val H = sc.next().toLong()
    solve(H)
}



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

#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

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

    int a, b;
    cin >> a >> b;
    if(a == b){
        cout << string(a, (a + '0'));
    }
    else{
        if(a > b){
            cout << string(a, (b + '0'));
        }
        else{
            cout << string(b, (a + '0'));
        }
    }

}



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

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String S = fs.next();
        if (S.charAt(S.length()-1) != 's')
            System.out.println(S + "s");
        else
            System.out.println(S + "es");
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() { return Double.parseDouble(next());}
}




Measured memory_bytes: 36168
import sys
import math
import itertools
import collections

# H1,M1,H2,M2,K = map(int,input().split())
# H2 -= K//60
# M2 -= K % 60

# print((H2 - H1) * 60 + (M2 - M1))

def factorization(n):
    arr = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i]=cnt

    if temp!=1:
        arr[temp] = 1

    if arr==[]:
        arr[n] = 1

    return arr

factorization(24) 

## [[2, 3], [3, 1]] 
##  24 = 2^3 * 3^1

N = int(input())
dic = factorization(N)
cnt = 0

for key,value in sorted(dic.items()):
    if(N == 1):
        break
    for i in range(1,value+1):
        if(N % key ** i != 0):
            break
        N //= key ** i
        cnt += 1
print(cnt)

Measured memory_bytes: 68492
# 深さ優先探索
import functools


def eval_sum(s_index, i):
    # print(s_index, i)
    if i == len(s_index) - 1:
        return eval(functools.reduce(lambda x, y: x + y[0] + y[1], s_index, ''))
    else:
        return eval_sum(s_index[:], i + 1) + eval_sum(s_index[:i] + [[s_index[i][0], '+']] + s_index[i + 1:], i + 1)


s = input()
s_index = list(map(lambda x: [x, ''], s))

print(eval_sum(s_index, 0))


Measured memory_bytes: 3572
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] a = new int[n][2];
		for (int i = 0; i < n; i++) {
			a[i][0] = sc.nextInt();
			a[i][1] = sc.nextInt();
		}
		Arrays.sort(a, (c, b) -> c[0] - b[0]);
		long sum = 0;
		int idx = 0;
		while (m != 0) {
			if (m - a[idx][1] >= 0) {
				m = m - a[idx][1];
				sum += (long) a[idx][1] * a[idx][0];
				idx++;
			} else {
				sum += (long)a[idx][0] * m;
				m = 0;
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 91656
n = int(input())
statement = [[] for _ in range(n)]


for i in range(n):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split())
        if y == 1:
            statement[i].append([x-1, True])
        if y == 0:
            statement[i].append([x-1, False])

cnt = 0
for bit in range(2**n):
    honest = []
    for i in range(n):
        if (bit >> i) & 1:
            honest.append(i)
    flag = True
    for j in range(len(statement)):
        if j in honest:
            for k in honest:
                if [j, False] in statement[k]:
                    flag = False
                    break
        else:
            for k in honest:
                if [j, True] in statement[k]:
                    flag = False
                    break
        
        if not flag:
            break  
    if flag:
        cnt = max(cnt, len(honest))
print(cnt)


Measured memory_bytes: 9232
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


ll solve(){
  ll R,G,B,N; cin >>R >>G >>B >>N;
  ll res = 0;
  for (int i=0; i<=3000; i++){
    for (int j=0; j<=3000; j++){
      // 赤色の箱を i 個、緑色の箱を j 個買う
      // これに対応する青色の箱何個があればres++;
      ll sum = i * R + j * G;
      if (sum > N) continue;
      sum = N - sum;
      if (sum % B == 0) res++;
    }
  }
  return res;
}

int main() {
  ll res = solve();
  cout <<res <<endl;
}

Measured memory_bytes: 256
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = getLine >>= print . solve

solve :: String -> Int 
solve = count 0 0 
    where
        count acc c (x : xs)
            | x `elem` "ACGT" = count acc (c + 1) xs
            | otherwise = count (max acc c) 0 xs
        count acc c _ = max acc c
        

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 380
#include<stdio.h>
#include<algorithm>
#define ll long long
#define maxn 100010
using namespace std;

ll pre[maxn];
ll a[maxn];

int main()
{
    ll i,n,m,t = 1,sum = 0;

    scanf("%lld%lld",&n,&m);
    pre[0] = 0;
    for(i = 1; i <= n; i++)
    {
        scanf("%lld",&a[i]);
        pre[i] = (pre[i-1]+a[i])%m;
    }
    sort(pre+1,pre+n+1);

    for(i = 1; i <= n; i++)
    {
        if(pre[i] == pre[i-1])
            t++;
        else
        {
            sum += t*(t-1)>>1;
            t = 1;
        }
    }
    sum += t*(t-1)>>1;
    printf("%lld\n",sum);

    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;

const ll mod = 1e9+7;

void solve() {
    ll n, m, s, i, j, k, c[51], d[51], ans[51], vis[51][2501], sp[51][2501];
    vector < pair < ll ,  pair < ll , ll > > > graph[51];
    fo(i,51){graph[i].clear();ans[i]=1e14;fo(j,2501){vis[i][j]=0;sp[i][j]=1e14;}}
    cin>>n>>m>>s;
    fo(i,m) {
        ll xx, yy, zz, vv;
        cin>>xx>>yy>>zz>>vv;
        graph[xx].pb({yy,{zz,vv}});
        graph[yy].pb({xx,{zz,vv}});
    }
    Fo(i,1,n+1)cin>>c[i]>>d[i];
    priority_queue < pair < ll , pair < ll , ll > > , vector < pair < ll , pair < ll , ll > > >, greater < pair < ll , pair < ll , ll > > > > q;
    while(!q.empty())q.pop();
    s=min(s,2500ll);
    ll ii;Fo(ii,0,s+1){q.push({0,{1,s-ii}});sp[1][ii] = 0;}
    while(!q.empty()) {
        pair < ll , pair < ll , ll > > p = q.top();
        q.pop();
        ll tm = p.F, ct = p.S.F, sil = p.S.S;
        ans[ct] = min(ans[ct], tm);
        if(sp[ct][sil]!=tm)continue;
        if(vis[ct][sil]==1)continue;
        vis[ct][sil] = 1;
        for(auto x:graph[ct]) {
            if(sil<x.S.F)continue;
            if(sp[x.F][sil-x.S.F]>sp[ct][sil]+x.S.S) {
                sp[x.F][sil-x.S.F]=sp[ct][sil]+x.S.S;
                q.push({sp[x.F][sil-x.S.F], {x.F, sil-x.S.F}});
            }
        }
        if(sil<2500) {
            ll ii;
            for(ii=sil+1ll;ii<=sil+c[ct] and ii<=2500;ii++) {
                if(sp[ct][ii]>sp[ct][sil]+d[ct]) {
                    sp[ct][ii] = sp[ct][sil] + d[ct];
                    q.push({sp[ct][ii], {ct, ii}});
                }
            }
        }
    }
    Fo(i,2,n+1)cout<<ans[i]<<endl;
}

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


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

int main(){
	ll N; cin >> N;
	ll X[N], L[N];
	vector<pair<ll, ll>> c(N);
	for(int i=0; i<N; i++){
		cin >> X[i] >> L[i];
		c[i].first = X[i] + L[i];
		c[i].second = X[i] - L[i];
	}
	sort(c.begin(), c.end());
	int now = 1, ans = 1, p = 0;
	while(now < N){
		if(c[now].second < c[p].first) now++;
		else{
			ans++;
			p = now;
			now++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  int count=0;
  for(int i=A;i<=B;i++){
    string stri=to_string(i);
      int juge=1;
      int leni=stri.size();
    for(int k=0;k<leni;k++)
    {
      if(stri[k]!=stri[leni-1-k])
         {
           juge=0;
         }
    }
         if(juge==1){
           count++;
         }
     }
         cout<<count<<endl;
         return 0;
 }        
         


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

using namespace std;

typedef long long ll;

#define rep(i,m,n) for(ll i=m;i<n;i++)

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

 ll x,y;
  cin >> x >> y;
 if(abs(x-y)<=1) cout << "Brown" << endl;
 else cout << "Alice" << endl;


  
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MAX(a, b, c) max(max(a, b), c)
using namespace std;

int main(){
  int r,d,x;
  scanf("%d%d%d", &r, &d, &x);
  
  REP(i,10){
    x = r * x - d;
    cout << x << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n,m;
	cin >> n >> m;
	vector<ll> dp(1 << n, LLONG_MAX/2);
	dp[0] = 0;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		vector<int> c(b);
		vector<int> d(n,0);
		int bit = 0;
		REP(j, b) {
			cin >> c[j];
			d[c[j]-1] = 1;
		}
		REP(j, n) {
			bit *= 2;
			bit += d[j];
		}
		REP(i,1 << n) {
			int temp = bit | i;
			chmin(dp[temp], dp[i] + a);
		}
	}
	if (dp.back() == LLONG_MAX / 2) {
		put(-1);
	} else {
		put(dp.back());
	}
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    int ans = -1;
    for (int i = 1; i <= 50000; i++){
        if ((i * 8)/ 100 + i == N){
            ans = i;
        }
    }
    if (ans == -1) cout << ":(" << endl;
    else cout << ans << endl;
}


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

//macro-----------------------------------------------------------------------------------------
#define rep(i,a,b) for(int i=a;i<b;i++)
#define int long long
const int inf = 100100100100000;
const int mod = 1000000007;

//general_method--------------------------------------------------------------------------------
vector<int> cs(vector<int> arr){vector<int> ret = arr;rep(i,1,arr.size()){ret[i] += ret[i-1];}return ret;}

//io_method-------------------------------------------------------------------------------------
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
void print(int n){cout << n << endl;}
void print(vector<int> arr){cout << arr[0];rep(i,1,arr.size()) cout << " " << arr[i];cout << endl;}
void print(string s){cout << s << endl;}

//main_method-----------------------------------------------------------------------------------

int ceil(int a, int b){
    if(a%b == 0) return a/b;
    else return a/b + 1;
}

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

    string s = raw_input();

    int cnt[3]; rep(i,0,3) cnt[i] = 0;
    for(char e: s){
        if(e == 'a') cnt[0]++;
        if(e == 'b') cnt[1]++;
        if(e == 'c') cnt[2]++;
    }


    int t = min({cnt[0], cnt[1], cnt[2]});

    rep(i,0,3) {
        cnt[i] -= t;
        if(cnt[i] > 1){
            print("NO");
            return 0;
        }
    }
    print("YES");
    return 0;
    
    
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())	//昇順
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())	//降順
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF 1000000000000000000


using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

const ll MAX = 710000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    // 前処理
    COMinit();
	ll X,Y;
    cin>>X>>Y;
    if((2*X-Y)%3!=0 || (2*Y-X)%3 !=0){
        cout<<0<<endl;
        return 0;
    }

    ll a=(2*X-Y)/3;
    ll b=(2*Y-X)/3;

    ll ans=COM(a+b,a);

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

Measured memory_bytes: 16896
sa = input()
sb = input()
sc = input()

turn = "a"
while True:
  if turn == "a":
    if len(sa) == 0:
      print("A")
      break
    else:
      turn = sa[0]
      sa = sa[1:]
  elif turn == "b":
    if len(sb) == 0:
      print("B")
      break
    else:
      turn = sb[0]
      sb = sb[1:]
  else:
    if len(sc) == 0:
      print("C")
      break
    else:
      turn = sc[0]
      sc = sc[1:]

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

int main()
{
  char a[99],b[99];
  int i,j,k,x,s=0;
  scanf("%s%d",a,&x);
  for(;x--;)
    {
      scanf("%s",b);
      for(i=0;i<10;i++)
	{
	  if(a[0]==b[i])
	    {
	      k=0;
	      j=i;
	      while(1)
		{
		  //		  printf("j=%d k=%d a[j]=%c b[k]=%c\n",j,k,a[k],b[j]);
		  j++;
		  k++;
		  if(j>=10)
		    j=0;
		  if(a[k]=='\0')
		    {s++;i=11;break;}
		  if(a[k]!=b[j])
		    break;
		}
	    }
	}
    }
  printf("%d\n",s);
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef long double ld;
int n,S,T,K;
#define Maxn 55
#define V 30000010

int num[Maxn][2];
int bit[1<<18];
ll c[52][52];
int jb[52];

struct Node{
	int son[3];
	short int ad;
}tree[V];
int root,cnt=0;
void insert(int &k,int pos){
	if(!k)k=++cnt;
	if(pos==18){
		tree[k].ad++;
		return;
	}
	for(int i=0;i<2;++i)insert(tree[k].son[num[pos][i]],pos+1);
}
int lowbit(int x){return x&(-x);}

inline ll Mul(ll a,ll b,ll Mod){
	ll tmp=(a*b-(ll)((ld)a/Mod*b+1e-8)*Mod+Mod)%Mod;
	if(tmp<0)tmp+=Mod;
	return tmp;
}

void dfs(int k,int pos,int sta1,int sta2){
	if(pos==18){
		if(((S&sta1)==S)&&((T&sta2)==sta2)){
			if((bit[sta1]-bit[S]+bit[T]-bit[sta2])&1)jb[tree[k].ad]--;
			else jb[tree[k].ad]++;
		}
		return;
	}
	for(int i=0;i<3;++i)
	    if(tree[k].son[i]){
	    	if(i==0)dfs(tree[k].son[i],pos+1,sta1,sta2);
	    	if(i==1)dfs(tree[k].son[i],pos+1,sta1,sta2|(1<<pos));
	    	if(i==2)dfs(tree[k].son[i],pos+1,sta1|(1<<pos),sta2|(1<<pos));
		}
}

inline void rd(int &x){
	x=0;char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
}
 
int main(){
	rd(n);rd(K);rd(S);rd(T);
	c[0][0]=1;
	for(int i=1;i<=n;++i){
		c[i][0]=1;
		for(int j=1;j<=i;++j)
			c[i][j]=c[i-1][j]+c[i-1][j-1];
	}
	for(int i=1;i<(1<<18);++i)bit[i]=bit[i-lowbit(i)]+1;
	int a;
	for(int i=1;i<=n;++i){
		rd(a);
		for(int j=0;j<18;++j)
		    if(a&(1<<j)){
		    	num[j][0]=1;
		    	num[j][1]=2;
			}else{
				num[j][0]=0;
				num[j][1]=1;
			}
		insert(root,0);
	}
	dfs(root,0,0,0);
	ll Ans=0;
	ll Mod=(1ll<<n);
	for(int i=1;i<=50;++i){
		jb[i]%=Mod;
		if(jb[i]<0)jb[i]+=Mod;
		ll tmp=0;
		for(int j=1;j<=K;++j)tmp+=c[i][j];
	    Ans+=Mul(tmp,(ll)jb[i],Mod);Ans%=Mod;
	}
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 362676
def chmin(dp, idx, a, b):
    if a > b:
        dp[idx] = b
        return True
    else:
        return False
def dp(N, h):
    INF = 10 ** 9
    dp = [INF] * N
    dp[0] = 0
    for i in range(1, N):
        chmin(dp, i, dp[i], dp[i-1] + abs(h[i]-h[i-1]))
        if i < 2:
            continue
        chmin(dp, i, dp[i], dp[i-2] + abs(h[i]-h[i-2]))
    return dp
N = int(input())
h = list(map(int, input().split(' ')))
dp = dp(N, h)
print(dp[N-1])

Measured memory_bytes: 13924
#include <iostream>
#include <vector>

using namespace std;

int dh[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dw[] = {0, 1, 1, 1, 0, -1, -1, -1};

void dfs(int h, int w, int **c, int sh, int sw, int **seen, int t) {
    seen[sh][sw] = t;
    
    for (int i = 0; i < 8; i++) {
        int nh = sh + dh[i], nw = sw + dw[i];
        if (nh < 0 || h <= nh || nw < 0 || w <= nw || seen[nh][nw] != -1 || c[nh][nw] == 0)
            continue;
        
        dfs(h, w, c, nh, nw, seen, t);
    }
}

void solve(int h, int w) {
    int **c = new int*[h];
    int **seen = new int*[h];
    for (int i = 0; i < h; i++) {
        c[i] = new int[w];
        seen[i] = new int[w];
        for (int j = 0; j < w; j++) {
            cin >> c[i][j];
            seen[i][j] = -1;
        }
    }

    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (seen[i][j] == -1 && c[i][j] != 0) {
                dfs(h, w, c, i, j, seen, ans+1);
                ans++;
            }
        }
    }

    cout << ans << endl;
    
}

int main() {
    int h, w;
    while (1) {
        cin >> h >> w;
        if (h == 0 && w == 0)
            break;
        
        solve(w, h);
    }
    
    return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= 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
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll sum1 = 0, sum2 = 0;
  //+-+-
  ll ans1 = 0, ans2 = 0;

  //+-+-
  rep(i, n) {
    sum1 += a[i];
    if(i%2 == 0 && sum1 <= 0) {
      ans1 += 1-sum1;
      sum1 = 1;
    }
    else if(i%2 == 1 && sum1 >= 0) {
      ans1 += sum1+1;
      sum1 = -1;
    }
  }

  //-+-+
  rep(i, n) {
    sum2 += a[i];
    if(i%2 == 0 && sum2 >= 0) {
      ans2 += sum2+1;
      sum2 = -1;
    }
    else if(i%2 == 1 && sum2 <= 0) {
      ans2 += 1-sum2;
      sum2 = 1;
    }
  }
  cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 4012
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<random>
#include<ctime>
#include<cstdlib>
#include<unordered_map>
#include<string.h>
#include<iostream>
using namespace std;

int a[3][3];
signed main() {
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < 2; i++) {
		set<int>S;
		for (int j = 0; j < 3; j++) {
			S.insert(a[i][j] - a[i + 1][j]);
		}
		if (S.size() > 1) { puts("No"); return 0; }
	}
	for (int i = 0; i < 2; i++) {
		set<int>S;
		for (int j = 0; j < 3; j++) {
			S.insert(a[j][i] - a[j][i+1]);
		}
		if (S.size() > 1) { puts("No"); return 0; }
	}
	puts("Yes");
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
int x[100010];
int y[100010];
vector<int> V[100010];
int parent[100010];

void make_parent(int v, int p) {
  parent[v] = p;
  for (auto x : V[v]) {
    if (x != p) {
      make_parent(x, v);
    }
  }
}

int grundy(int v) {
  int s = V[v].size();
  if (v == 0) ++s;
  int ans;
  if (s == 1) {
    ans = 0;
  } else if (s == 2) {
    for (auto x : V[v]) {
      if (x != parent[v]) {
        ans = grundy(x) + 1;
      }
    }
  } else {
    ans = 0;
    for (auto x : V[v]) {
      if (x != parent[v]) {
        ans ^= (grundy(x) + 1);
      }
    }
  }
  // cerr << "grundy(" << v << ") = " << ans << endl;
  return ans;
}

int main () {
  cin >> N;
  for (auto i = 0; i < N-1; ++i) {
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
    V[x[i]].push_back(y[i]);
    V[y[i]].push_back(x[i]);
  }
  make_parent(0, -1);
  if (grundy(0) == 0) {
    cout << "Bob" << endl;
  } else {
    cout << "Alice" << endl;    
  }
}


Measured memory_bytes: 11520
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  double a;
  int i;

  while(scanf("%lf",&a)!=EOF){
    double sum=0;
    rep(i,5){
      sum+=a;//?\???°???????¶????
      a*=2;//??¶??°???????±???????
      sum+=a;//??¶??°???????¶????
      a/=3;//?\???°???????±???????
    }
    printf("%.8f\n",sum);
  }
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;


int f(vector<int> a){
  int N = a.size();
  vector<int> t(N);
  iota(ALL(t), 1);

  int ret = 0;

  do{
    if(t == a) break;
    ++ret;
  }while(next_permutation(ALL(t)));
  
  return ret;  
}




int main(){
  int N;
  while(cin >> N){
    vector<int> P(N), Q(N); cin >> P >> Q;

    int ans = abs(f(P) - f(Q));

    cout << ans << endl;

    
  }


  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb push_back
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int main() {
	ll S; scanf("%lld", &S);
	ll x = 1e9;
	ll t = S % x;
	if(t != 0) t = x - t;
	ll x2 = x, x1 = 1;
	ll y1 = (S + t) / x, y2 = t;
	printf("0 0 %lld %lld %lld %lld\n", x1, y1, x2, y2);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;

int main() {
  char s; cin >> s;
  if(s == 'A') cout << "T" << endl;
  if(s == 'T') cout << "A" << endl;
  if(s == 'C') cout << "G" << endl;
  if(s == 'G') cout << "C" << endl;

  return 0;
}



//EOF


Measured memory_bytes: 256
module Monoid
  module_function

  E = 0

  def op(x, y)
    return (x > y)? x : y
  end
end
  
class SegmentTree
  include Monoid
  attr_accessor(:node, :offset)
  
  def initialize(n)
    ofs = 1
    while ofs < n
      ofs <<= 1
    end
    
    @node = Array.new((ofs << 1) - 1, Monoid::E) # 0-indexed
    @offset = ofs - 1 # log2(n).ceil
  end

  def update(i, x) # 一点更新
    i += @offset
    @node[i] = x
    
    while i > 0
      i = (i - 1) >> 1
      @node[i] = Monoid::op(@node[(i << 1) + 1], @node[(i << 1) + 2])
    end
  end

  def query(l, r) # [l, r)
    l += @offset
    r += @offset

    res = Monoid::E
    while l < r
      if l & 1 == 0
        res = Monoid::op(res, @node[l])
      end
      if r & 1 == 0
        res = Monoid::op(res, @node[r - 1])
      end
      l = l >> 1
      r = (r - 1) >> 1
    end
    return res
  end
end

m = 3 * (10 ** 5)
n, k = $stdin.readline.chomp.split.map(&:to_i)
a = Array.new(n) { $stdin.readline.to_i }
seg = SegmentTree.new(m + 1)

res = 0
a.each do |x|
  l = [0, x - k].max
  r = [m, x + k].min
  v = seg.query(l, r + 1) + 1
  res = [res, v].max
  seg.update(x, v)
end
puts res

Measured memory_bytes: 24908
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	int A,B;
	cin >> A >> B;
	int ans = 0;
	int sum = 1;
	while(sum<B){
		ans++;
		sum += (A-1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
tmp=input()
n = int(tmp.split(" ")[0])
k = int(tmp.split(" ")[1])
 
h=[]
 
for i in range(n):
    h.append(int(input()))
 
h.sort()
 
x=int(0)
y=int(h[k-1]-h[0])
 
for i in range(n-k+1):
    x=h[i+k-1]-h[i]
    if x < y:
        y=x
 
print(y)

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  // std::cout << std::fixed << std::setprecision(10);

  ll N;
  scanf("%lld", &N);

  ll ans = 0;

  for (ll i = 0; i < 5; i++) {
    ll v;
    scanf("%lld", &v);

    ll cost = (N + v - 1) / v;

    ans = max(ans, cost);
  }

  cout << (ans + 4) << endl;
}


Measured memory_bytes: 256
#!/bin/ruby
class Team
  def initialize(t,p)
    @t=t
    @f=Array.new(p){0}
    @ac=Array.new(p){false}
    @time=0
  end
  attr_reader :t
  attr_accessor :f
  attr_accessor :time
  attr_accessor :ac
  def penalty
    p=0
    (0...f.size).each do |e|
      p+=20*f[e] if ac[e]
    end
    return time+p
  end
  def <(t)
    if @ac.count(true)!=t.ac.count(true) then
      return @ac.count(true)>t.ac.count(true)
    else
      return penalty<t.penalty
    end
  end
  def <=>(t)
    return -1 if self<t
    return 1 if t<self
    return 0
  end
end
                
loop do
  m,t,p,r=gets.split.map(&:to_i)
  break if m==0&&t==0&&r==0&&p==0
  teams=(0...t).map{|e|Team.new(e,p)}
  r.times do
    mk,tk,pk,jk=gets.split.map(&:to_i)
    if jk==0 then
      teams[tk-1].time+=mk;
      teams[tk-1].ac[pk-1]=true
    else
      teams[tk-1].f[pk-1]+=1
    end
  end
  teams.sort!{|a,b|((a<=>b)!=0)?a<=>b : -(a.t-b.t)}
  (0...teams.size-1).each do |e|
    print "#{teams[e].t+1}#{((teams[e]<=>teams[e+1])==0)? '=':','}"
  end
  puts teams[-1].t+1
end

Measured memory_bytes: 6148
n = int(input())
s1 = input()
s2 = input()
mod = 10 ** 9 + 7
if s1[0] == s2[0]:
  ans = 3
  flag = 1
  now = 1
else:
  ans = 6
  flag = 0
  now = 2
while now < n:
  if s1[now] == s2[now]:
    if flag:
      ans *= 2
    flag = 1
    now += 1
  else:
    if flag:
      ans *= 2
    else:
      ans *= 3
    flag = 0
    now += 2
  ans %= mod
print(ans)

Measured memory_bytes: 3316
#include<stdio.h>
int main(void)
{
    int K,A,B;
    int i;
  
    scanf("%d",&K);
    scanf("%d%d",&A,&B);
  
    if((A==B)&&(A%K==0)) { printf("OK\n"); return 0; }
    else{ 
      for(i=0;i<=B-A;i++){
        if((A+i)%K==0){
          printf("OK\n");
          return 0;
        }
      }
    }
  
    printf("NG\n");
      
    return 0;
}


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

    double N,sum=0;
    cin >> N;
    vector<double> data(N);
    vector<double> dataaa(N);
    rep(i,N){
        cin >> data.at(i);
        dataaa.at(i)=1/data.at(i);
        sum+=dataaa.at(i);
    }

    cout << setprecision(10) << endl;
    cout << 1/sum << endl;

    
}

Measured memory_bytes: 256
( 1..gets.to_i ).each do |i|
  if ( i % 3 == 0 || i % 10 == 3 )
    print " "+i.to_s
    next
  end
  j = i
  while ( j > 0 ) do
    j /= 10
    if ( j % 10 == 3 )
      print " "+i.to_s
      j = 0
    end
  end
end
puts

Measured memory_bytes: 6096
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
//不要再爆long long了！！！！！！！！不要再爆long long了！！！！！！！ 

int main()
{
	string a;
	cin>>a;
	cout<<a[0]<<a[1]<<a[2];
	return 0;
}

Measured memory_bytes: 3568