akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.Ia;
		var b=sc.Ia;
		var c=sc.Ia;
		Array.Sort(a);
		Array.Sort(b);
		Array.Sort(c);
		var ba=new long[n+1];
		for(int i = 0,j=0;i<n;i++) {
			while(j<n&&b[i]>=c[j]){j++;}
			ba[i]=n-j;
		}
		for(int i = n-1;i>=0;i--) {
			ba[i]+=ba[i+1];
		}
		long ans=0;
		for(int i = 0,j=0;i<n;i++) {
			while(j<n&&a[i]>=b[j]){j++;}
			ans+=ba[j];
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 38248
n,q = map(int,input().split())
s = input()
ans =[0]
j = 0
for i in range(n-1):#どこにACという連続文字列があるかを調べる
    if s[i] == "A" and s[i+1] == "C":
        j += 1
        ans.append(j)
    else:
        ans.append(j)
# print(ans)
for i in range(q):
    l,r = map(int, input().split())
    print(ans[r-1]-ans[l-1])


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

#define ll long long int
#define inv(name,Type,size) vector<Type> name(size);for(int index=0;index<size;index++) cin>>name[index];
#define F(a,n,i) for(int i=a;i<n;i++)
#define FLL(a,n,i) for(long long int i=a;i<n;i++)
#define pb push_back
#define endl "\n"
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()

const int mod=1000000007;
const int modpro=988244353;

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


void solve(){
	int n;
	cin>>n;
	//if(n==3 || n==2){
		//cout<<n;
		//return;
	//}
	ll ans = 1;
	F(2,n,i){
		ll temp = 0;
		for(int j = 1;j*j<=i;j++){
			if(i%j==0){
				if(i == j*j) temp++;
				else temp+=2;
			}
		}
		ans+=temp;
		//ans*=2;
	}
	cout<<ans;
}

int main()
{

  //freopen("out", "w", stdout);
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
  //int t;cin>>t;while(t--) solve(),cout<<endl;
  solve();
  
  cerr<<endl << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << " ms\n";
}



Measured memory_bytes: 3800
import sys

input_int = lambda:int(input())
input_ints = lambda:map(int,input().split())
input_ints_list = lambda:list(input_ints())
input_str = lambda:input()
input_strs = lambda:input().split()
input_lines = lambda n,f:[f() for _ in range(n)]

import functools,fractions
gcd = lambda a:functools.reduce(fractions.gcd,a) # 最大公約数（リスト）
lcm_base = lambda a,b:(a*b)//fractions.gcd(a,b) # 最小公倍数(2値)
lcm = lambda a:functools.reduce(lcm_base,a,1) # 最小公倍数(リスト)

import itertools
permutations = lambda a,n:itertools.permutations(a,n) # 順列
combinations = lambda a,n:itertools.combinations(a,n) # 組み合わせ
product = lambda a,b:itertools.product(a,b) # 二つのリストの直積

init_array_1dim = lambda v,n:[v for _ in range(n)]
init_array_2dim = lambda v,n,m:[[v for _ in range(n)] for _ in range(m)]

import math
# 四捨五入はround
ceil = lambda a:math.ceil(a) # 切り上げ
floor = lambda a:math.floor(a) # 切り捨て

def dfs_graph(v,n,graph,visited):
	if all(visited):return 1
	ans = 0
	for i in range(n):
		if graph[v][i] == False:continue
		if visited[i]:continue
		visited[i] = True
		ans += dfs_graph(i,n,graph,visited)
		visited[i] = False
	return ans

def init_graph(n,a,directed=False):
    visited = init_array_1dim(False,n)
    graph = init_array_2dim(False,n,n)
    for e in a:
        graph[e[0]-1][e[1]-1] = True
        if not directed:graph[e[1]-1][e[0]-1] = True # 無向グラフの場合
    return visited,graph

def solution():
    N,M = input_ints()
    ab = input_lines(M,input_ints_list)
    visited,graph = init_graph(N,ab)
    visited[0] = True
    print(dfs_graph(0,N,graph,visited))

if __name__ == '__main__':
    solution()

Measured memory_bytes: 5144
N,M=map(int,input().split())
ans=[]
if N%2==1:
  for i in range(M):
    ans.append([i+1,N-i])
else:
  for i in range(M//2):
    ans.append([i+1,2*M-i+1])
  for j in range(M-M//2):
    ans.append([j+M//2+1,2*M-M//2-j])
for k in ans:
  print(*k,sep=' ')

Measured memory_bytes: 22596
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,AC=0,WA=0,TLE=0,RE=0;
  cin >> N;
  vector<string> S(N);
  for(int i=0;i<N;i++){
    cin >> S.at(i);
    if(S.at(i)=="AC") AC++;
    if(S.at(i)=="WA") WA++;
    if(S.at(i)=="TLE") TLE++;
    if(S.at(i)=="RE") RE++;
  }
  printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",AC,WA,TLE,RE);
  return 0;
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

signed main() {
    
    int a, b;
    cin >>a >>b;
    if(a==1) a=14;
    if(b==1) b=14;
    
    if(a==b) puts("Draw");
    else if(a<b) puts("Bob");
    else puts("Alice");
    
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


N, Q = map(int, input().split())
c = list(map(int, input().split()))

lr = []
for i in range(Q):
    l, r = map(int, input().split())
    lr.append([l, r, i])

lr.sort(key=lambda x: x[1])
# print("lr", lr)
rightest = [-1] * (N + 1)
current_q = 0
bit = Bit(N)
ans = [0] * Q

for i in range(N):
    if rightest[c[i]] != -1:
        bit.add(rightest[c[i]] + 1, -1)
    rightest[c[i]] = i
    bit.add(i + 1, 1)
    # print(bit.tree)

    while current_q < Q and lr[current_q][1] == i + 1:
        ans[lr[current_q][2]] = bit.sum(lr[current_q][1]) - bit.sum(lr[current_q][0] - 1)
        current_q += 1

for i in range(Q):
    print(ans[i])


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

c = [0] * N
d = [0] * N
for i in range(N):
    for j in range(i + 1, N):
        if A[i] > A[j]:
            c[i] += 1

    for j in range(i):
        if A[i] > A[j]:
            d[i] += 1

x = sum(c)
y = x + sum(d)
ans = (K * x + (K * (K - 1) // 2) * y) % (10**9 + 7)

print(ans)


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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] h = new int[n + 1], dp = new int[n + 1];
        StringTokenizer st = new StringTokenizer(br.readLine());

        for (int i = 1; i <= n; i++)
            h[i] = Integer.parseInt(st.nextToken());

        dp[2] = Math.abs(h[2] - h[1]);

        for (int i = 3; i <= n; i++)
            dp[i] = Math.min(dp[i - 1] + Math.abs(h[i] - h[i - 1]), dp[i - 2] + Math.abs(h[i] - h[i - 2]));

        System.out.println(dp[n]);
    }
}


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

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ar array
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod = 1e9 + 7;
const ll inf = 2e9 + 5;
double PI = 3.14159265358979323846;

const int N = 1e5+5;
vi dp(N,inf);

void solve() {

    int n;
    cin >> n;
    int h[n+1];
    for(int i = 1;i <= n;i++){
        cin >> h[i];
    }

    dp[1] =0;

    for(int i = 1;i<= n;i++){
        if(i-1 >= 1)dp[i] = min(dp[i], dp[i-1]+(abs(h[i]-h[i-1])));
        if(i-2 >= 1)dp[i] = min(dp[i], dp[i-2]+(abs(h[i]-h[i-2])));
    }
    cout << dp[n] << endl;

}

int32_t main()
{
    IOS
    // int T; cin >> T; while (T--)
    solve();
    return 0;
}


Measured memory_bytes: 4004
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N, A, B;
short a[40], b[40], c[40];

vector<vector<vector<short>>> dp(40);
short solve(short n, short A, short B){
	if(A < 0 || B < 0) return 4001;
	if(n == N){
		if(A == 0 && B == 0) return 0;
		else return 4001;
	}
	if(dp[n][A][B] != -1) return dp[n][A][B];
	return dp[n][A][B] = min(solve(n+1, A, B), (short)(solve(n+1, A-a[n], B-b[n])+c[n]));
}

signed main(){
	cin >> N >> A >> B;
	rep(i, N) cin >> a[i] >> b[i] >> c[i];
	short ans = 4001;
	rep(i, 40){
		dp[i].resize(401);
		rep(j, 401){
			dp[i][j].assign(401, -1);
		}
	}
	for(int i=1; i*A<=400&&i*B<=400; i++){
		ans = min(ans, solve(0, i*A, i*B));
	}
	if(ans > 4000) cout << -1 << endl;
	else cout << ans << endl;
}


Measured memory_bytes: 16812
import sys
from itertools import groupby


def input():
    return sys.stdin.readline()[:-1]


def solve():
    N = int(input())
    A = list(map(int, input().split()))
    if len(set(A)) == N:
        print('YES')
    else:
        print('NO')


if __name__ == "__main__":
    solve()


Measured memory_bytes: 25548
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)

int X;
signed main(){
	cin >> X;
	int a = X / 500;
	X -= 500*a;
	int b = X / 5;
	cout << 1000*a+5*b << endl;
}


Measured memory_bytes: 256
import Control.Monad
import Data.List
main = do
  [n,m] <- map read . words <$> getLine
  xyzs <- replicateM n $ map read . words <$> getLine
  print $ maximum [
    sum $ drop (n-m) $ sort $ map (sum . zipWith (*) ss) xyzs |
    ss <- replicateM 3 [-1,1]]

Measured memory_bytes: 3836
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())

ABCD = [tuple(map(int, input().split())) for i in range(Q)]

lst = [i for i in range(M)]

ans = 0

for tmp in combinations_with_replacement(lst, N):
  score = 0
  for a, b, c, d, in ABCD:
    if tmp[b-1] -tmp[a-1] == c:
      score += d
    ans = max(ans, score)
    
print(ans)

Measured memory_bytes: 9212
// Problem : A - Don't be late
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

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

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  lcm(x, y)   ((x) * (y) / __gcd(x, y))
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
    ll d,t,s; cin >> d >> t >> s;
    if(d <= s*t) cout << "Yes";
    else cout << "No";
}

int main(){
    IOS;
    solve();
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
using namespace std;
int main()
{
    char a[5];
    scanf("%s",a);
    int st=(a[0]-'0')*10+a[1]-'0';
    int en=(a[2]-'0')*10+a[3]-'0';
    if(st>12 && en>12)
        printf("NA\n");
    else if(st>0 || en>0){
        if(st>0 && st<=12 &&en>0 && en<=12)
            printf("AMBIGUOUS\n");
        else if(st>0 && st<=12)
            printf("MMYY\n");
        else if(en>0 && en<=12)
            printf("YYMM\n");
        else
            printf("NA\n");
    }
    else
        printf("NA\n");
   // printf("NA\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  char op;
  int ans = 0;
  cin >> A >> op >> B;
  if(op == '+'){
    ans = A + B;
  }
  else{
    ans = A - B;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) {
        a[i] -= (i+1);
    }


    sort(a.begin(), a.end());

    int x = a[n/2];
    if(n%2==0){
        x = a[n/2-1] + a[n/2];
        x/= 2;
    }

    ll ans = 0;
    for(auto i : a) {
        ans += abs(i - x);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

struct Point{
	int x,y;
};

int main(){
	while(true){
		int n;
		cin >> n;
		if(n==0){
			break;
		}
		vector<Point> plist(n);
		//宣言してしまえば普通の配列のように扱える。
		plist[0] = (Point){0,0};
		for(int i=0;i<n-1;i++){//[1,n)でもok
			int idx;//基準となる正方形
			int dir;//方向
			//idxの長方形のdirの方向に長方形がある
			cin >> idx >> dir;
			Point now = plist[idx];//実体渡し
			//数学でよく使う座標系に従う
			if(dir==0){//左
				now.x--;
			}else if(dir==1){//下
				now.y--;
			}else if(dir==2){//右
				now.x++;
			}else if(dir==3){//上
				now.y++;
			}
			plist[i+1] = now;
		}
		
		int minx=0;
		int maxx=0;
		int miny=0;
		int maxy=0;
		for(int i=0;i<n;i++){//[1,n)でおｋ
			minx = min(plist[i].x,minx);
			maxx = max(plist[i].x,maxx);
			miny = min(plist[i].y,miny);
			maxy = max(plist[i].y,maxy);
		}
		int width = maxx-minx+1;
		int height = maxy-miny+1;
		cout << width << " " <<height << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    int x;
    cin >> x;
    int ans = 1;
    rep(i, 2, x+1){
        int j = i;
        while(true){
            j=j*i;
            if(j>x)break;
            ans = max(j,ans);
        }
    }
    cout << ans << endl;
}


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

int main() {
  int n,k;
  string s;
  cin >> n >> k >> s;
  if (s.at(k-1) == 'A') {
    s.at(k-1) = 'a';
  }
  if (s.at(k-1) == 'B') {
    s.at(k-1) = 'b';
  }
  if (s.at(k-1) == 'C') {
    s.at(k-1) = 'c';
  }
  cout << s <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll factorial(ll n) 
{ 
    ll res = 1, i; 
    for (i = 2; i <= n; i++) 
        res *= i; 
    return res; 
}
void code()
{
    ll n;
    cin>>n;
    ll A[n],B[n];
    for(ll i=0;i<n;i++)
    {
        cin>>A[i];
    }
    for(ll i=0;i<n;i++)
    {
        cin>>B[i];
    }
    bool visited[n+1]={0},vis[n+1]={0};
    ll a=0,b=0;ll x=1;
    for(ll i=0;i<n;i++)
    {
            ll cnt=0;
            for(ll j=1;j<A[i];j++)
            {
                if(visited[j]==false)
                    cnt++;
            }
            a+=(factorial(n-i-1)*cnt);
            cnt=0;
            for(ll j=1;j<B[i];j++)
            {
                if(vis[j]==false)
                    cnt++;
            }
            b+=(factorial(n-i-1)*cnt);
          // cout<<a<<" "<<b<<endl;

        visited[A[i]]=true;
        vis[B[i]]=true;

    }
    cout<<abs(a-b);
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t=1;
    // cin>>t
    while(t--)
    {
        code();
    }
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
constexpr int mod=1e9+7;
int32_t main()
{
	
	int n=in();int k=in();
	vector<int> a(n);
	trav(i,a)i=in();sort(all(a));
	int l=0,r=n-1;
	int ans=1;
	if(k&1)
	{
		if(a[n-1]<0)
		{
			for(int i=n-1;i>=n-k;i--)
			{
				ans*=a[i];
				ans%=mod;
			}
			if(ans<0)cout<<(ans+mod)%mod;
			else cout<<ans%mod;
			return 0;
		}
		r--;k--;
	}
	
	while(k)
	{
		int lp=a[l]*a[l+1];
		int rp=a[r]*a[r-1];
		if(lp>rp)l+=2;
		else r-=2;
		
		k-=2;
	}

	for(int i=0;i<l;i++)
	{
		ans*=a[i];
		ans%=mod;
	}
	for(int i=r+1;i<n;i++){ans*=a[i];ans%=mod;}
	
	if(ans<0){ans+=mod;cout<<ans%mod;}
	else cout<<ans%mod;
	
	
}

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

int main() {
    int a, b, c, d;
    int ans = 0;
    cin >> a>>b>>c>>d;
    while(a> 0 && c > 0){
        ans ++;
        if(ans%2 == 1){
            c -= b;
        }else{
            a -= d;
        }
    }
    
    printf("%s",(ans%2 == 1)?"Yes":"No");

}

Measured memory_bytes: 3748
n = int(input())

sp = []

for i in range(n):
  s,p = map(str,input().split())
  sp.append([s,int(p),i+1])


sp.sort(key = lambda x:x[1],reverse = True)
sp.sort(key = lambda x:x[0])


for i in sp:
  print(i[2])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    int valid = 0;
    string ans = "NA";
    
    if(n%100 <= 12 && n%100>0){
        ans = "YYMM";
        valid += 1;
    }
    
    if(n/100 <= 12 && n/100 > 0){
        ans = "MMYY";
        valid += 1;
    }
    
    if(valid == 2){
        cout << "AMBIGUOUS" << endl;
    }else{
        cout << ans << endl;
    }
}

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

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define setIO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define trav(e, x) for (auto &(e) : (x))
#define pb(x) push_back(x)
#define eb(x...) emplace_back(x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define lc(i) 2*i
#define rc(i) 2*i+1
#define int long long
using namespace std;
using vi = vector<int>;
using ii = pair<int, int>;

const int MAXN = 1e5, INF = 1e9 + 5, MOD = 1e9 + 7;

signed main() {
    FAST_IO;
//    setIO("input.txt", "output.txt");

    int n;
    cin >> n;
    vi a(n);
    trav(x, a) cin >> x;
    int dp[n];
    dp[0] = a[0];
    for (int i = 1; i < n; i++) dp[i] = max(a[i], dp[i - 1]);
    int ans = 0;
    for (int i = 0; i < n; i++) ans += dp[i] - a[i];
    cout << ans;
}


Measured memory_bytes: 6304
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>



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

  int k,n;
  cin>>n>>k;
  priority_queue<P> q1;
  priority_queue<P,vector<P>,greater<P>> q2;

  rep(i,n){
    int t,d;
    cin>>t>>d;
    q1.push(P(d,t));
  }

  int ans=0,sum=0;
  vi v(n+1,0);
  int x=0;
  rep(i,k){
    P p=q1.top(); q1.pop();
    sum+=p.F;
    if(v[p.S]==0) x++;
    v[p.S]++;
    if(v[p.S]>1) q2.push(p);
  }
  ans=sum+x*x;

  rep(i,n-k){
    P p=q1.top();q1.pop();
    if(v[p.S]||q2.empty()) continue;
    P p2=q2.top();q2.pop();
    sum-=p2.F;
    sum+=p.F;
    v[p.S]++;
    x++;
    ans=max(ans,sum+x*x);
  }


  cout<<ans<<endl;

 

}

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

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

  int x[n][d];

  rep(i,n){
      rep(j,d){
          cin >> x[i][j]; 

      }
  }

  int ans =0;

  rep(i,n){
      
      for(int j=i+1;j<n;j++){
          double sum =0;
          for(int k=0;k<d;k++){
              sum = sum + (x[i][k] - x[j][k])*(x[i][k]-x[j][k]);
          }
          if(ceil(sqrt(sum)) == floor(sqrt(sum))){
              ans++;
          }


      }
  }

  cout << ans << endl;
}

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

int main()
{
	int i,j,k,n;
	cin>> n >> k;
	int cost[n];
	int h[n];
	for(i=0;i<n;i++)
	{
		cin >> h[i];
	}
	cost[0]=0;
	int temp,min;
	for(i=1;i<n;i++)
	{
		min=abs(h[i]-h[i-1])+cost[i-1];
		for(j=i-1;j>=(i-k)&&j>=0;j--)
		{
			temp=abs(h[i]-h[j])+cost[j];
			if(temp<min)
			min=temp;
		}
		cost[i]=min;
	}
	cout << cost[n-1] << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    int N;
    cin >> N; 
    int y = N / 15;
    cout << N*800 - y*200 << endl;

    return 0;
}

Measured memory_bytes: 3588
class UnionFind():
    def __init__(self,n):
        self.n=n
        # -1で親がいないことを示す
        self.parents = [-1] * (n+1)
        # unionの大きさ
        self.size = [1]*(n+1)

    def find(self,x):
        # 親がいない＝＞代表元xを返却
        if self.parents[x] == -1:
            return x
        else:
            # 親を辿って代表元を取得して自分の親も代表元にする
            self.parents[x]=self.find(self.parents[x])
            # それを返す
            return self.parents[x]

    def unite(self,x,y):

        xRoot = self.find(x)
        yRoot = self.find(y)

        if xRoot == yRoot:
            return

        # 今回は一つのユニオンの大きさが問題となるので、更新する
        if self.size[xRoot]>self.size[yRoot]:
            self.parents[yRoot] = xRoot
            self.size[xRoot] += self.size[yRoot]
            self.size[yRoot] = 0
        else:
            self.parents[xRoot] = yRoot
            self.size[yRoot] += self.size[xRoot]
            self.size[xRoot] = 0

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

for _ in range(M):
    a,b = map(int,input().split())
    tree.unite(a,b)

print(max(tree.size))


Measured memory_bytes: 82752
import java.util.*
import kotlin.math.min

fun main() {
    val builder = StringBuilder()

    val t = readInputLine().toInt()

    val primes = listOf(2L, 3L, 5L)

    repeat(t) {
        val (n, a, b, c, d) = readInputLine().split(" ").map { it.toLong() }

        val coinMap = mapOf(2L to a, 3L to b, 5L to c)

        // value -> cost
        val costMap = mutableMapOf<Long, Long>()

        // (value, cost)
        val queue = PriorityQueue<Pair<Long, Long>> { x, y -> x.second.compareTo(y.second) }

        queue.add(Pair(n, 0L))
        costMap[n] = 0L

        var ans = 1e18.toLong()

        fun addQueue(value: Long, cost: Long) {
            if (value < n + 100L && cost < ans && cost < costMap.getOrDefault(value, 1e18.toLong())) {
                costMap[value] = cost
                queue.add(Pair(value, cost))
            }
        }

        while (queue.isNotEmpty()) {
            val (current, cost) = queue.poll()

            if (cost >= ans) {
                break
            }

            if (current <= 2e18.toLong() && cost + current * d > 0L) {
                ans = min(ans, cost + current * d)
            }

            for (p in primes) {
                val mod = current % p
                addQueue(current / p, cost + mod * d + coinMap[p]!!)
                addQueue(current / p + 1L, cost + (p - mod) * d + coinMap[p]!!)
            }
        }

        builder.appendln(ans)
    }

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 59108
#include <stdio.h>

int main() {
    int n, m, x, a, l = 0, r = 0;
    scanf("%d %d %d", &n, &m, &x);
    for (int i = 0; i < m; ++i) {
        scanf("%d", &a);
        if (a < x) {
            l += 1;
        } else {
            r += 1;
        }
    }

    if (l < r) {
        printf("%d\n", l);
    } else {
        printf("%d\n", r);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s,t;
  while(cin >> s >> t && t!="X") {
    vector<string> v;
    string r="";
    s+='_';
    rep(i,s.size()) {
      if(isupper(s[i])) {
        if(r.size()) v.pb(r);
        r=tolower(s[i]);
      } else if(s[i]=='_') {
        if(r.size()) v.pb(r);
        r="";
      } else r+=s[i];
    }
    string ans="";
    if(t=="L") {
      rep(i,v.size()) {
        if(i) v[i][0]=toupper(v[i][0]);
        ans+=v[i];
      }
    } else if(t=="U") {
      rep(i,v.size()) {
        v[i][0]=toupper(v[i][0]);
        ans+=v[i];
      }
    } else {
      rep(i,v.size()) {
        if(i) ans+='_';
        ans+=v[i];
      }
    }
    pr(ans);
  }
}

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


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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

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

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}

int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    string a,b;
    cin>>a>>b;
    int n1=a.length(),n2=b.length();
    if(n2==0)
    {
    	cout<<0<<endl;
    	return 0;
    }

    int ans=1e9+1;
    for(int i=0;i<=n1-n2;i++)
    {
    	int curr=0;
    	for(int j=0;j<n2;j++)
    		curr+=(a[i+j]!=b[j]);
    	ans=min(ans,curr);
    }

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

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

template <class T>
inline void read(T &x) {
	static char ch; 
	static bool opt; 
	while (!isdigit(ch = getchar()) && ch != '-'); 
	x = (opt = ch == '-') ? 0 : ch - '0'; 
	while (isdigit(ch = getchar()))
		x = x * 10 + ch - '0'; 
	if (opt)
		x = ~x + 1; 
}

template <class T>
inline void putint(T x) {
	static char buf[45], *tail = buf; 
	if (!x)
		putchar('0'); 
	else {
		if (x < 0)
			putchar('-'), x = ~x + 1; 
		for (; x; x /= 10) *++tail = x % 10 + '0'; 
		for (; tail != buf; --tail) putchar(*tail); 
	}
}

template <class T>
inline bool tense(T &x, const T &y) {
	return y < x ? x = y, true : false; 
}

template <class T>
inline bool relax(T &x, const T &y) {
	return x < y ? x = y, true : false; 
}

template <class T>
inline T getAbs(const T &x) {
	return x < 0 ? -x : x; 
}

typedef long long s64; 
typedef long double ld; 
typedef std::vector<int> vi; 
typedef std::pair<int, int> pii; 
#define mp(x, y) std::make_pair(x, y)

const int mod = 1e9 + 7; 
inline void add(int &x, const int &y) {
	if (x += y, x >= mod) x -= mod; 
}
inline void dec(int &x, const int &y) {
	if (x -= y, x < 0) x += mod; 
}
inline int qpow(int x, int y) {
	int res = 1; 
	for (; y; y >>= 1, x = 1LL * x * x % mod)
		if (y & 1) res = 1LL * res * x % mod; 
	return res; 
}

const int MaxN = 1 << 18 | 5; 

int H, n, m; 
int p[MaxN], prod[MaxN], pinv[MaxN]; 

int s[MaxN], sum; 

void modify(int x, int opt) {
	if (x >= m) {
		int val = 1LL * prod[x] * prod[p[x]] % mod; 
		for (int y = p[x]; y; y >>= 1)
			(opt == 1 ? add : dec)(s[y], val); 
		return; 
	}
	modify(x << 1 | 0, opt); 
	modify(x << 1 | 1, opt); 
}

void query(int x) {
	if (x >= m) {
		int val = 1LL * prod[x] * prod[p[x]] % mod; 

		for (int y = p[x]; y > 1; y >>= 1) {
			add(sum, 1LL * val * pinv[y >> 1] % mod * s[y ^ 1] % mod); 
		}
		return; 
	}
	query(x << 1 | 0); 
	query(x << 1 | 1); 
}

int main() {
#ifdef orzczk
	freopen("a.in", "r", stdin); 
#endif

	read(H); 
	n = 1 << H, m = (n + 1) >> 1; 

	pinv[0] = 1, prod[1] = pinv[1] = 1; 
	for (int i = 2; i < n; ++i) {
		prod[i] = 1LL * prod[i >> 1] * i % mod; 
		pinv[i] = qpow(1LL * prod[i] * prod[i >> 1] % mod, mod - 2); 
	}

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

	int ans = 0; 
	for (int x = 1; x < m; ++x) {
		modify(x << 1, +1); 

		sum = 0; 
		query(x << 1 | 1); 
		ans = (ans + 1LL * sum * pinv[x]) % mod; 
		
		modify(x << 1, -1); 
	}

	std::cout << ans << '\n'; 

	return 0; 
}

Measured memory_bytes: 7232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
ll dp[100100][4];
int n,k;
ll s[100100][4];
int go(int idx,int p)
{
    if(idx==n)
        return 0;
    ll &ret=dp[idx][p];
    if(ret!=-1)
        return ret;
    ret=0;
    for(int i=0;i<3;i++)
        if(i!=p)
        ret=max(ret,s[idx][i]+go(idx+1,i));
return ret;
}
int main(){
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=0;i<n;i++)
        scanf("%lld%lld%lld",&s[i][0],&s[i][1],&s[i][2]);
    go(0,3);
    cout<<dp[0][3];
}


Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  double n,m,sum;
  sum=0;
  cin>>n>>m;
  vector<double> l;
  rep(i,n){
    double j;
    cin>>j;
    sum+=j;
    l.pb(j);
  }
  double border = sum/(4*m);
  int count = 0;
  rep(i,n){
    if(l[i]>=border){
      count++;
    }
  }
  if(m<=count){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }


}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;
LL INF = 100000007LL * 100000007LL;

LL lb(vector<LL>& a, LL obj) {
  LL l = a.size(), r = -1 ;
  while (abs(r - l) > 1) {
      LL c = (l + r) / 2;
      if (obj < a[c]) {
          l = c ;
      } else {
          r = c ;
      }
  }
  return l;
}

LL lb2(vector<LL>& a, LL obj) {
  LL l = a.size(), r = -1 ;
  while (abs(r - l) > 1) {
      LL c = (l + r) / 2;
      if (obj <= a[c]) {
          l = c ;
      } else {
          r = c ;
      }
  }
  return l;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  LL N;
  cin >> N;
  vector<LL> A(N);
  REP(i, N)
  {
    cin >> A[i];
  }

  vector<LL> dp(210000, INF);
  
  REP(i,N){
    LL idx = lb(dp, -A[i]);
    dp[idx] = -A[i];
  }

  LL ans = lb2(dp, INF);

  cout << ans << endl;
}


Measured memory_bytes: 2688
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void) {
    int n, i;
    double x[2][100];
    double d1=0, d2=0, d3=0, max, buf;

    scanf("%d", &n);
    for (i=0;i<n;i++) scanf("%lf", &x[0][i]);
    for (i=0;i<n;i++) scanf("%lf", &x[1][i]);
    for (i=0;i<n;i++) {
        buf=abs(x[1][i] - x[0][i]);
        d1+=buf;
        if (i==0) max=d1;
        if (buf>max) max=buf;
        d2+=abs(x[1][i] - x[0][i])*abs(x[1][i] - x[0][i]);
        d3+=abs(x[1][i] - x[0][i])*abs(x[1][i] - x[0][i]) \
            *abs(x[1][i] - x[0][i]);
    }
    printf("%.5lf\n%.5lf\n%.5lf\n%.5lf\n", d1, sqrt(d2), cbrt(d3), max);

    return 0;
}


Measured memory_bytes: 2104
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
//#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 300000;
int mod = 1e9 + 7;
int a[N], f[N];
string s;

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < n + n; i++){
        if (i % 2){
            if (s[i] == 'B') a[i] = -1;
            if (s[i] == 'W') a[i] = 1;
        } else{
            if (s[i] == 'B') a[i] = 1;
            if (s[i] == 'W') a[i] = -1;
        }
    }
    int ans = 1;
    int k = 0;
    for (int i = 0; i < n + n; i++){
        if (a[i] == 1) k++; else{
            ans = ans * k % mod;
            k--;
        }
        if (k < 0) ans = 0;
    }
    if (k != 0) ans = 0;
    f[0] = 1;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % mod;
    cout << ans * f[n] % mod;
}


Measured memory_bytes: 3408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
        private static int s_maxWater;
        private static int s_maxSugar;
        private static double s_maxDensity = double.MinValue;
        static void SolveA()
        {
            int n = ReadAndParseInt();
            var l = new int[n];
            var r = new int[n];
            for(int i=0;i<n;++i)
            {
                var o = ReadAndParseIntArr();
                l[i] = o[0];
                r[i] = o[1];
            }
            int ans = 0;
            for(int i=0;i<n;++i)
            {
                int li = l[i];
                int ri = r[i];
                ans += ri - li + 1;
            }
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13140
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

int baai(int a, int b, int c) {
  if (a == b && a == c) {
    return 1;
  }
  if (a == b || b == c || c == a) {
    return 3;
  }
  return 6;
}

int f(int n) {
  int ans = 0;
  for (int x = 1; x < 100; x++) {
    if (x * x + 2 * x >= n) {
      break;
    }
    for (int y = x; y < 100; y++) {
      if (y * y + 2 * y >= n) {
        break;
      }
      for (int z = y; z < 100; z++) {
        if (z * z + 2 * z >= n) {
          break;
        }
        if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
          ans += baai(x, y, z);
        }
      }
    }
  }
  return ans;
}

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cout << f(i) << endl;
  }
}

Measured memory_bytes: 3520
#include "bits/stdc++.h"

#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,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-12

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T & a, const T & b) { if (a > b) { 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; }

using ld = long double;


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

	ll k;
	ld r, l;
	cin >> k >> l >> r;
	ld p, e, t;
	cin >> p >> e >> t;
	ld a = l, b = r, pp = 1;
	auto check = [&](ld l, ld r, int cnt) {
		ld tmp = pow(2, cnt);
		ld left = l + (r - l) / tmp, right = r - (r - l) / tmp;
		if (t - e < left + EPS && t + e > right - EPS) return 1;
		if (right<t - e + EPS || left + EPS>t + e)return -1;
		return 0;
	};
	if (k == 0) {
		ld tmp = (l + r) / 2;
		if (t - e < tmp - EPS && tmp < t + e - EPS)cout << 1.0 << endl;
		else cout << 0.0 << endl;
		return 0;
	}
	int f = 1;
	ld ans = 0;
	REP(i, k) {
		ld mid = (a + b) / 2;
		int left = check(a, mid, k - i), right = check(mid, b, k - i);
		if (left == 1) {
			if (mid - EPS > t)ans += pp * (1 - p) / (f + 1);
			else ans += pp * p / (f + 1);
		}
		if (right == 1) {
			if (mid - EPS > t)ans += pp * p / (f + 1);
			else ans += pp * (1 - p) / (f + 1);
		}
		if (left == 0 && right == 0) {
			if (mid - EPS > t)pp *= p;
			else pp *= (1 - p);
			f = 0;
			a = mid;
		}
		else if (left == 0) {
			if (mid - EPS > t)pp *= (1 - p);
			else pp *= p;
			b = mid;
		}
		else if (right == 0) {
			if (mid - EPS > t)pp *= p;
			else pp *= (1 - p);
			a = mid;
		}
		else {
			break;
		}
	}
	f = 1;
	a = l;
	b = r;
	pp = 1;
	REP(i, k) {
		ld mid = (a + b) / 2;
		int left = check(a, mid, k - i), right = check(mid, b, k - i);
		if (left == 1) {
			if (mid - EPS > t)ans += pp * (1 - p) / (f + 1);
			else ans += pp * p / (f + 1);
		}
		if (right == 1) {
			if (mid - EPS > t)ans += pp * p / (f + 1);
			else ans += pp * (1 - p) / (f + 1);
		}
		if (left == 0 && right == 0) {
			if (mid - EPS > t)pp *= (1 - p);
			else pp *= p;
			f = 0;
			b = mid;
		}
		else if (left == 0) {
			if (mid - EPS > t)pp *= (1 - p);
			else pp *= p;
			b = mid;
		}
		else if (right == 0) {
			if (mid - EPS > t)pp *= p;
			else pp *= (1 - p);
			a = mid;
		}
		else {
			break;
		}
	}
	cout << fixed << setprecision(12) << ans << endl;
}


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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e5+6;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int a,b;
bool valid(int k){
    if((int)((double)k*0.1)==b&&(int)((double)k*0.08)==a)return true;
    else return false;
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    
    scanf("%d %d",&a,&b);
    int ans =1e9;
    bool ok = false;
    for(int i=min(a,b);i<=N;i++){
        if(valid(i)){
            ans=min(i,ans);
            ok=true;
        }
    }
    if(ok)printf("%d",ans);
    else puts("-1");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <utility>
#include <set>
 
#define rep(i, n) for(int i = 0; i < n; i++)
 
using namespace std;
 
int main() {
  
  int n, m, l;
  cin >> n >> m >> l;

  vector<vector<long long int>> matA(n, vector<long long int>(m, 0));
  vector<vector<long long int>> matB(m, vector<long long int>(l, 0));
  vector<vector<long long int>> matC(n, vector<long long int>(l, 0));

  rep(i, n) rep(j, m) cin >> matA[i][j];
  rep(i, m) rep(j, l) cin >> matB[i][j];

  rep(i, n) rep(j, l) rep(k, m) matC[i][j] += matA[i][k] * matB[k][j];

  rep(i, n) {
    rep(j, l) {
      cout << matC[i][j];
      cout << (j < l - 1 ? " " : "\n");
    }
  }

  return 0;
}



Measured memory_bytes: 3256
from math import radians, sin, cos

a, b, r = map(float, raw_input().split())
r = radians(r)
h = b * sin(r)
c = (a**2 + b**2 - 2*a*b*cos(r))**0.5
l = a + b + c
s = a * h / 2
print s
print l
print h

Measured memory_bytes: 4456