akhauriyash/Code-Regression huggingface dataset:
W, H, N = map(int, input().split())
Q = [0,W,0,H]
for i in range(N):
    q = list(map(int, input().split()))
    if q[2]==1 and Q[0]<q[0]:
        Q[0]=q[0]
    elif q[2]==2 and Q[1]>q[0]:
        Q[1]=q[0]
    elif q[2]==3 and Q[2]<q[1]:
        Q[2]=q[1]
    elif q[2]==4 and Q[3]>q[1]:
        Q[3]=q[1]

print(max((Q[1]-Q[0]), 0)*max((Q[3]-Q[2]),0))

Measured memory_bytes: 3064
from collections import Counter

n=int(input())
s=[input() for i in range(n)]
a=Counter(s)
b=a.most_common()
c=list(a.values())
d=max(c)
e=[]

for i in range(len(b)):
    if b[i][1]==d:
        e.append(b[i][0])

e=sorted(e)
for i in range(len(e)):
    print(e[i])

Measured memory_bytes: 50804
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    float L;
    cin >> L;
    float LL;
    LL = L/3.0 * L/3.0 * L/3.0;
    printf("%f", LL);



}

Measured memory_bytes: 256
import sys
from fractions import gcd


def main():
    n, x = map(int, input().split())
    a = list(map(int, input().split()))

    a.sort()

    ans = 0

    for i in range(n):
        x -= a[i]

        if x < 0:
            break
        
        ans += 1
    
    if x > 0:
        ans -= 1
    
    print(ans)


if __name__ == '__main__':
    main()


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

int main()
{
  int x,a,b;

  cin >> x >> a >> b;

  if(b-a<=0){
  cout << "delicious" << endl;
  }else if(b-a>0 && b-a<x+1){
  cout << "safe" << endl;
  }else if(b-a>=x+1){
  cout << "dangerous" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
n = int(input())
i = 5
while True:
  if (n//(10**i) != 0):
    break
  i = i - 1
i = i + 1

if (i%2 == 0):
  i = i//2
  ans = 0
  for j in range(i):
    ans = ans + 9*10**(2*j)
  print(ans)
else:
  i2 = (i - 1)//2
  ans = 0
  for j in range(i2):
    ans = ans + 9*10**(2*j)
  tmp = 0
  for j in range(i - 1):
    tmp = tmp + 9*(10**j)
  ans = ans + n - tmp
  print(ans)


Measured memory_bytes: 9196
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

///////////////////////////


	
int main() {
	ll H, W;
	cin >> H >> W;
	ll s[100][100] = {};

	repn(i, H) {
		repn(j, W) {
			char c;
			cin >> c;
			if (c == '#') { s[i][j] = 1; }
		}
	}

	string ans = "Yes";
	
	repn(i, H) {
		repn(j,W){
			if (s[i][j] == 0) { continue; }
			if (s[i - 1][j] == 0 && s[i + 1][j] == 0 && s[i][j - 1] == 0 && s[i][j + 1] == 0) { ans = "No"; }
		}
	}

	cout << ans;

	system("PAUSE");
}

Measured memory_bytes: 512
#include<cstdio>
using namespace std;
int main(){
    int n,a[26],x,y,flag;
    char s[100][5];
    scanf("%d",&n);
    while(n){
        for(int i=0;i<n;i++){
            scanf("%s",s[i]);
        }
        x=y=0;
        flag=0;
        for(int i=0;i<26;i++){
            a[i]=0;
        }
        for(int i=0;i<n;i++){
            a[(s[i][0])%256-'A']++;
            if(a[(s[i][0])%256-'A']>x){
                x=a[(s[i][0])%256-'A'];
            }
            else if(a[(s[i][0])%256-'A']>y){
                y=a[(s[i][0])%256-'A'];
            }
            if(x>y+(n-i-1)){
                for(int j=0;j<26;j++){
                    if(x==a[j]){
                        printf("%c %d\n",j+'A',i+1);
                        flag=1;
                    }
                }
                break;
            }
        }
        if(!flag){
            printf("TIE\n");
        }
        scanf("%d",&n);
    }
}


Measured memory_bytes: 2736
n = int(input())
cake = 4
donut = 7
flag = 0
for c in range(n // cake + 1):
         for d in range(n // donut + 1):
                  if 4 * c + 7 * d == n:
                           flag = 1
if flag == 1:
         print("Yes")
else:
         print("No")


Measured memory_bytes: 2940
n = int(input())
t_list = list(map(int, input().split()))
m = int(input())
p_list = []
while True:
	try:
		p_list.append(list(map(int,input().split())))
	except:
		break
for p in p_list:
	p_index = p[0] - 1
	p_point = p[1]
	total = 0
	for num in range(0, n):		
		if num == p_index:
			total = total + p_point
		else:
			total = total + t_list[num]
	print(total)

Measured memory_bytes: 38512
a,b,c,k = map(int, input().split())
import sys
ans=0
k1 = k-a
if k1<=0:
    print(k)
    sys.exit()
else:
    ans+=a

k2 = k1-b
if k2<=0:
    print(ans)
    sys.exit()
else:
    ans=ans

print(ans-k2)


Measured memory_bytes: 9180
inning = $stdin.gets.to_i
Base = [0,1,3,7]

while inning > 0
  base = 0
  score = 0
  out = 0
  while out < 3
    event = $stdin.gets.chomp
    case event
    when "HIT"
      score += 1 if base == Base[3]
      base = (base << 1) + 1
      base = Base[3] if base > Base[3]
    when "HOMERUN"
      score += (Base.index(base) + 1)
      base = 0
    when "OUT"
      out += 1
    end
  end
  inning -= 1
  printf "%d\n", score
end

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

bool flip(bool f) {
    return !f;
}

int main() {
    deque<char> q;
    string S;  cin >> S;
    for (int i = 0; i < (int)S.size(); ++i) {
        q.push_back(S[i]);
    }
    // DUMP(q);

    bool rev = false;
    int Q;  cin >> Q;
    for (int i = 0; i < Q; ++i) {
        int t;  cin >> t;
        if (t == 1) rev = flip(rev);
        else {
            int f;  char c;  cin >> f >> c;  --f;
            if ((f & !rev) || (!f & rev)) q.push_back(c);
            else q.push_front(c);
        }
    }
    // DUMP(q);

    if (rev) {
        for (int i = q.size() - 1; i >= 0; --i) cout << q[i];
    }
    else {
        for (int i = 0; i < (int)q.size(); ++i) cout << q[i];
    }
    cout << endl;
}


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

int compare(const void* a, const void* b){
    return *(int*)a - *(int*)b;
}

int MIN(int a, int b){return a>b?b:a;}

int main(void){
    int n;
    scanf("%d", &n);
    int a[n];
    for(int i=0; i<n; i++){scanf("%d", &a[i]);}

    qsort(a, n, sizeof(int), compare);

    int min = a[0];
    int max = a[n-1];

    int sum = 0;
    int ans = 4000001;
    for(int i=min; i<=max; i++){
        sum = 0;
        for(int j=0; j<n; j++){
            sum += (i-a[j])*(i-a[j]);
        }
        ans = MIN(ans,sum);
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    ll n;
    cin >> n;
    cout << n*(n-1)/2 << endl;
}

Measured memory_bytes: 256
# ARC090C - Candies (ABC087C)
n = int(input())
arr = [list(map(int, input().rstrip().split())) for _ in range(2)]
ans = 0
for i in range(n):
    ans = max(ans, sum(arr[0][: i + 1]) + sum(arr[1][i:]))
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
typedef long long ll;
using namespace std;
vector<ll> v(444);
vector<ll> sum(444);
ll dp[444][444];
ll f(int l,int r){
    if(l==r)return 0;
    if(l>r)return 0;
    if(dp[l][r]!=-1)return dp[l][r];
    ll res=ll(1e18);
    for(int i=l;i<r;i++){
       if(l>0) res=min(res,f(l,i)+f(i+1,r)+sum[r]-sum[l-1]);
       else res=min(res,f(l,i)+f(i+1,r)+sum[r]);
    }
    return dp[l][r]=res;
}

int main(){
    int n;cin>>n;
    for(ll &i:v)cin>>i;
    sum[0]=v[0];
    for(int i=1;i<n;i++)sum[i]=sum[i-1]+v[i];
    for(int i=0;i<444;i++)for(int j=0;j<444;j++)dp[i][j]=-1;
    cout<<f(0,n-1);
    
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5 , M = 20;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);


int k;

vector < int > a;
int n;

ll mem[M][M][3][3];

ll dp(int i , int last , int f , bool b){

    if(i == n) return b ? 1ll : 0ll;

    ll &ret = mem[i][last][f][b];
    if(ret != -1) return ret;

    ret = 0;
    if(b == 0){
            int mx = a[i];
            if(f) mx = 9;
            for(int val = 0 ; val <= mx ; val ++){
                    ret += dp(i + 1 , val , (i > 0) | (val < a[i]) , val > 0);
            }
            return ret;
    }

    ret = 0;
    for(int x : {-1 , 0 , 1}){
            int val = last + x;

            if(val >= 0 && val <= 9){
                    if(val > a[i]){
                            if(f) ret += dp(i + 1 , val , f , b | (val > 0));
                    }
                    else {
                            ret += dp(i + 1 , val , f | (val < a[i]) , b | (val > 0));
                    }
            }
    }

    return ret;
}

bool calc(ll x){

    ll x2 = x;

    a.clear();

    while(x2){
            a.push_back(x2%10);
            x2 /= 10;
    }

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

    n = a.size();
    memset(mem , -1 , sizeof mem);

    ll ans = dp(0 , 0 , 0 , 0);
    return ans >= k;
}

void solve(int testCase){

    scanf("%lld" , &k);

    ll low = 0 , high = 3234566667 + 2;

    while(low < high){
            ll mid = low + (high - low) / 2;

            if(calc(mid)){
                    high = mid;
            }
            else {
                    low = mid + 1;
            }
    }

    printf("%lld\n" , high);

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000
#define NIL -1 

using namespace std;

typedef struct{
  int right;
  int left;
  int parent;
}Node;

Node T[MAX];

void inorder(int x){
  if(x == NIL) return;
  inorder(T[x].left);
  cout << " " << x;
  inorder(T[x].right);
}

void preorder(int x){
  if(x == NIL) return;
  cout << " " << x;
  preorder(T[x].left);
  preorder(T[x].right);
}

void postorder(int x){
    if(x == NIL) return;
    postorder(T[x].left);
    postorder(T[x].right);
    cout << " " << x;
}

int main(){
    int n, i, id, left, right, root = 0;
    char com[20];
    cin >> n;
    for(i = 0; i < n; i++) T[i].parent = NIL;
    for(i = 0; i < n; i++){
        cin >> id >> left >> right;
        T[id].left = left;
        T[id].right = right;
        if(left != NIL) T[left].parent = id;
        if(right != NIL) T[right].parent = id;
    }
    for(i = 0; i < n; i++){
        if(T[i].parent == NIL) root = i;
    }
    cout << "Preorder" << endl;
    preorder(root);
    cout << endl;

    cout << "Inorder" << endl;
    inorder(root);
    cout << endl;

    cout << "Postorder" << endl;
    postorder(root);
    cout << endl;

    return 0;
}


Measured memory_bytes: 3128
//Author: Lixiang
#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn=100005;
struct D{
	int a[maxn],N;
	void init(){
		scanf("%d",&N);
		for(int i=1;i<=N;i++)
			scanf("%d",&a[i]);
	}
	void work(){
		int ans1=0,ans2=0;
		for(int i=1;i<=N;i++)
			if(a[i]==i){
				swap(a[i],a[i+1]);
				ans1++;
			}
		printf("%d\n",ans1);
	}
}sol;
int main(){
	sol.init();
	sol.work();
	return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;

//namespace _2_A
//{
class Program
{
    static void Main(string[] args)
    {
        //????????????
        string a = Console.ReadLine();
        string[] b = a.Split(' ');
        int x = int.Parse(b[0]);
        int y = int.Parse(b[1]);

        //?????¶??????
        if (x < y)
        {
            Console.WriteLine("a < b");
        }
        else if (x > y)
        {
            Console.WriteLine("a > b");
        }
        else
        {
            Console.WriteLine("a == b");
        }

        
    }
}
//}

Measured memory_bytes: 8788
a, b, c = list(map(int , input().split()))
k = int(input())

if a == max(a, b, c):
    ans = a*2**k + b + c
elif b == max(a, b, c):
    ans = a + b*2**k + c
else:
    ans = a + b + c*2**k
print(ans)


Measured memory_bytes: 2940
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let mut v : Vec<i32> = get_vec();
    v.sort();
    println!("{}", if v[0] == 5 && v[1] == 5 && v[2] == 7 { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
n,a,b = map(int,input().split())

MOD=10**9+7
def comb(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%MOD
    for i in range(2,k+1):
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        ans=ans*(n-k+i)*inv[i]%MOD
    return ans

nCa = comb(n,a)
nCb = comb(n,b)

ans = (pow(2,n,MOD) - 1) - nCa - nCb
 
if ans < 0:
    print((ans+MOD)%MOD)
else:
    print(ans%MOD)

Measured memory_bytes: 10932
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip> 
#include <algorithm>
#include <queue>
#include <list>
#include <numeric>
#include <stack>
#include <unordered_map>
#include <map>
#include <set>

using namespace std;

#define sz(a) int((a).size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define watch(x) cout << #x << " : " << x << endl;

#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;

const int N = int(2e5)+10;
const int K = int(2e6)+10;
const int MOD = int(1e9)+7;
const int INF = int(1e9)+5;
const ll INF64 = 1e18;

int ok[6];

void solve () {
    for (int i=1;i<=5;i++) {
        int x;cin>>x;
        ok[x]++;
    }
    for (int i=1;i<=5;i++) {
        if (!ok[i]) {
            cout<<i<<endl;
            return;
        }
    }
}

int main () {
    FastIO
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int t;
    // cin>>t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define maxn 1000005
using namespace std;
int n,a[maxn],b[maxn],ta[maxn],tb[maxn],vis[maxn];
map<int,int> Ha; int tot=0;
int fa[maxn];
int getf(int x){return fa[x]==x?x:fa[x]=getf(fa[x]);}
int Merge(int x,int y)
{
	int fx=getf(x),fy=getf(y);
	if(fx!=fy) fa[fx]=fy;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n+1;ta[i]=a[i],i++)
	{
		if(i!=n+1) scanf("%d",&a[i]),a[n+1]^=a[i];
		if(!Ha[a[i]]) Ha[a[i]]=++tot;
	}
	for(int i=1;i<=n+1;tb[i]=b[i],i++)
	{
		if(i!=n+1)scanf("%d",&b[i]),b[n+1]^=b[i];
		if(!Ha[b[i]]) Ha[b[i]]=++tot;
	}
	n++;
	sort(ta+1,ta+n+1),sort(tb+1,tb+n+1);
	for(int i=1;i<=n;i++)
		if(ta[i]!=tb[i]) return (puts("-1"),0);
	for(int i=1;i<=2*n+tot;i++) fa[i]=i;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==b[i]&&i!=n) continue;
		Merge(i,i+n),Merge(i,2*n+Ha[a[i]]),Merge(i+n,2*n+Ha[b[i]]);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==b[i]&&i!=n) continue;
		if(i!=n) ans++;
		ans+=!(vis[getf(i)]),vis[getf(i)]=1;
		ans+=!(vis[getf(i+n)]),vis[getf(i+n)]=1;
	}
	printf("%d\n",ans-1);
	return 0;
}

Measured memory_bytes: 22016
# ABC131D - Megalomania
def main():
    n = int(input())
    arr = sorted(
        [tuple(map(int, input().rstrip().split())) for _ in range(n)], key=lambda x: x[1]
    )
    tasks = 0
    for i, j in arr:
        tasks += i
        if tasks > j:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()

Measured memory_bytes: 33456
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

template <typename T> inline constexpr bool chmin(T &a, T b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> inline constexpr bool chmax(T &a, T b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  ll n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  if (k < 2*n) {
    int now = 0;
    for (int i = 0; i < k; i++) {
      now = a[now];
    }
    cout << now + 1 << endl;
    return 0;
  }
  int now = 0;
  vector<int> visit(n, -1);
  visit[0] = 0;
  ll loop_sz;
  int i;
  for (i = 1; i <= n; i++) {
    now = a[now];
    if (visit[now] != -1) {
      loop_sz = i - visit[now];
      break;
    }
    visit[now] = i;
  }
  i = visit[now];
  k = ((k - i) % loop_sz + loop_sz) % loop_sz;
  for (ll i = 0; i < k; i++) {
    now = a[now];
  }
  cout << now + 1 << endl;
}


Measured memory_bytes: 4468
//C - A x B + C
//Hiia
#include <stdio.h>
#include <stdlib.h>//rannsuu, zettaichi(absolute)
#include <time.h>
//srand((unsigned int) time(0));
#include <math.h>//koudona keisann
#include <string.h>//hairetsu
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
typedef long long ll;
//#define N 998244353
#define M 1000000007
#define pi 3.1415926535897932384626433832

int gcd(int m,int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
int lcm(int m,int n){if((0==m)||(0==n))return 0;return(m*n/gcd(m, n));}
int fact(int x){if(x==1) return(x);else return(x*fact(x-1));}//Kaijou x!
int ruijou(int base,int exponent){int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

long long int llgcd(long long int m,long long int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
long long int lllcm(long long int m,long long int n){if((0==m)||(0==n))return 0;return(m*n/llgcd(m, n));}
long long int llfact(long long int x){if(x==1) return(x);else return(x*llfact(x-1));}//Kaijou
int llruijou(long long int base,long long int exponent){long long int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

int main()
{
  ll n,ans=0;
  scanf("%lld", &n);



  for(ll i = 1; i <= n-1; i++) {
    for(ll j = 1; j <= n-1; j++) {
      if(i*j<n){
        ans++;
      }
      else{
        break;
      }
    }
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 1736
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int n;
    int f = 0;
    int a, b;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d %d", &a, &b);
        if (a == b)
        {
            f++;
        }
        else
        {
            f = 0;
        }

        if (f >= 3)
        {
            printf("Yes");
            return 0;
        }
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    int ans = 0;

    if(n >= 2100){
        ans = 1;
    }else{
        int a = n / 100;
        int b = n % 100;
        if(a > 0){
            a--;
            b -= a * 5;
            if(b <= 5)ans = 1;
        }
    }

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[][][] F = new int[N][5][2];
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < 5; ++j) {
                for (int k = 0; k < 2; ++k) {
                    F[i][j][k] = sc.nextInt();
                }
            }
        }
        int[][] P = new int[N][11];
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < 11; ++j) {
                P[i][j] = sc.nextInt();
            }
        }

        System.out.println(solve(F, P));

        sc.close();
    }

    static int solve(int[][][] F, int[][] P) {
        int N = F.length;

        int result = Integer.MIN_VALUE;
        for (int code = 1; code < (1 << 10); ++code) {
            int profit = 0;
            for (int i = 0; i < N; ++i) {
                int c = 0;
                for (int j = 0; j < 10; ++j) {
                    if (F[i][j / 2][j % 2] == 1 && (code & (1 << j)) != 0) {
                        ++c;
                    }
                }

                profit += P[i][c];
            }

            result = Math.max(result, profit);
        }

        return result;
    }
}

Measured memory_bytes: 26216
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

void tanzaku(string S){
  int N = S.size();
  FOR(i,0,N+2){
    FOR(j,0,3){
      if(i == 0 && j == 0)cerr << "┏";
      else if(i == N+1 && j == 2)cerr << "┛";
      else if(i == 0 && j == 2)cerr << "┓";
      else if(i == N+1 && j == 0)cerr << "┗";
      else if(i == 0 || i == N+1)cerr << "━";
      else if(j == 0 || j == 2)cerr << "┃";
      else cout << S[i-1];
    }
    cerr << endl;
  }
  return;
}

int main(){
  int N,i;
  cin >> N >> i;
  tanzaku(to_string(N - i + 1));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < n; ++i)
using namespace std;
const int INF = 2147483647;
using ll = long long;
// cout << typeid('変数').name() << endl;

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i=0;i<n;i++){
        cin >> l.at(i);
    }
    sort(l.begin(),l.end());
    int ans=0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            int k=lower_bound(l.begin(),l.end(),l[i]+l[j])-l.begin();
            ans+=max(k-(j+1),0);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		int A, B ,C = 0;
		A = X;
		B = Y;
		C = Z;
		
		B = A;
		A = Y;
		C = A;
		A = Z;
		System.out.println(A + " " + B + " " + C);
	}
}

Measured memory_bytes: 39180
n = gets.to_i
r = Array.new

n.times do
    r.push(gets.to_i)
end

# initialize max
max_r = r[1] - r[0]
min_v = r[0] < r[1] ? r[0] : r[1]
# calc
for i in 2..n-1 do
    current = r[i] - min_v
    max_r = current if current > max_r
    min_v = r[i] if r[i] < min_v
end

puts max_r

Measured memory_bytes: 10472
//Joy Shree Kriskna
    #include<bits/stdc++.h>
    #define fast  ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define rep(i,n) for(i=0;i<n;i++)
    #define rep1(i,n) for(i=n-1;i>=0;i--)
    #define rep2(j,t) for(j=1;j<=t;j++)
    #define rep3(i,a,b) for(i=a;i<=b;i++)
    #define PI acos(-1)
    #define remove(s) s.erase(unique(s.begin(),s.end()),s.end());
    #define e return 0
    //#define lcm(a,b) ((a*b)/__gcd(a,b))
    #define endl "\n"
    #define al(v) v.begin(),v.end()
    #define ll long long
    using namespace std;
    int main()
      {
           fast;
           ll i,n=0,t;
           cin>>t;
           n=(t/500)*1000;
           i=t%500;
           n+=(i/5)*5;
           cout<<n;
      }
//arupsaha52
//1704052_Arup



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

const int NM = 1e5 + 10;
int lr[NM];

bool isPrime(int x){
    int i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q; cin>>q;
    lr[1] = 0;
    for(int i=1; i<NM; i+=2){
        int tmp;
        if(isPrime(i+2) && isPrime((i+2+1)/2)) tmp=1;
        else tmp = 0;
        lr[i+2] = lr[i] + tmp;
    }
    vector<int> ans;
    rep(i,q){
        int l, r;cin>>l>>r;
        int t = (l>1 ? lr[l-2] : 0);
        ans.push_back(lr[r]-t);
    }
    for(auto a : ans){
        cout<<a<<endl;
    }

}
// abc084_d

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
ll arr[100100],n,ans,temp1,temp2,temp3,a,b,c;
int main()
{
    cin>>a>>b>>c;
    if(a%2!=0|| b%2!=0 || c%2!=0)
    {
        cout<<"0"<<endl;
        return 0;
    }
    n=1;
    while(n<10001000)
    {
        temp1=a;
        temp2=b;
        temp3=c;
        a=(temp2+temp3)>>1;
        b=(temp1+temp3)>>1;
        c=(temp1+temp2)>>1;
        if(a%2!=0|| b%2!=0 || c%2!=0)
        {
            cout<<n<<endl;
            return 0;
        }
        n++;
    }
    cout<<"-1"<<endl;
return 0;
}


Measured memory_bytes: 384
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m=MI()
lis=LI()
u=UnionFind(n)
for i in range(m):
    x,y=MI()
    x-=1
    y-=1
    u.union(x,y)
count=0
for i in range(n):
    if u.find(lis[i]-1)!=u.find(i):
        count+=1
print(n-count)
            
    
        
        
    


    

Measured memory_bytes: 88756
n = int(input())
h = list(map(int, input().split()))
res = 0
now = 0
for i in range(1, n):
  if h[i] <= h[i-1]:
    now += 1
  else:
    res = max(res, now)
    now = 0
res = max(res, now)
print(res)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string S,T;
    cin >> S >> T;
    int s = S.size();
    int t = T.size();
    int ans = 10000;
    REP(i, s-t+1){
        int tmp = 0;
        REP(j, t){
            if(S[i+j]!=T[j])tmp++;
        }
        chmin(ans, tmp);
    }
    pr(ans);
}

Measured memory_bytes: 3628
n = int(input())
s = list(input())
a = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for i in range(len(s)):
    s[i] = a[a.index(s[i]) + n]
print(*s, sep="")

Measured memory_bytes: 4852
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<ll,int> P;

int main() {

	int n;
	string s;
	cin>>n>>s;
	int ls=s.length();

	queue<string> que;
	que.push(string("SS"));
	que.push(string("WW"));
	que.push(string("SW"));
	que.push(string("WS"));

	while(!que.empty()){
		string s1=que.front();que.pop();
		int l1=s1.length();
		string s2="S";
		string s3="W";
		if(l1>n+1){
			if((s1[0]==s1[n])&&(s1[1]==s1[n+1])){
				cout<<s1.substr(0,n)<<endl;
				return 0;
			}
			continue;
		}
		if(s1[l1-1]=='S'){
			if(s[(l1-1)%n]=='o'){
				if(s1[l1-2]=='S')s1+=s2;
				if(s1[l1-2]=='W')s1+=s3;
			}
			if(s[(l1-1)%n]=='x'){
				if(s1[l1-2]=='S')s1+=s3;
				if(s1[l1-2]=='W')s1+=s2;
			}
		}else{
			if(s[(l1-1)%n]=='x'){
				if(s1[l1-2]=='S')s1+=s2;
				if(s1[l1-2]=='W')s1+=s3;
			}
			if(s[(l1-1)%n]=='o'){
				if(s1[l1-2]=='S')s1+=s3;
				if(s1[l1-2]=='W')s1+=s2;
			}
		}
		que.push(s1);
//		cout<<s1<<endl;
	}
	cout<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 1540
def matrix_chmul(matrices):
    length = len(matrices)
    dp = [[0 for n in range(length)] for m in range(length)]
    rowcol = []
    for i in range(length):
        rowcol.extend(matrices[i])
    for i in range(1, length):
        for j in range(length - i):
            if i == 1:
                dp[j][i + j] = rowcol[j * 2] * rowcol[(i + j) * 2] * rowcol[(i + j) * 2 + 1]
            else:
                temp_min = float("inf")
                for k in range(0, i):
                    # print(i, j, k, dp[j][j + k], dp[j + k + 1][i + j])
                    dp[j][i + j] = min(temp_min, (dp[j][j + k] + dp[j + k + 1][i + j] + rowcol[j * 2] * rowcol[(j + k + 1) * 2] * rowcol[(i + j) * 2 + 1] ))
                    temp_min = dp[j][i + j]
        # print(dp)
    return dp[0][length - 1]

length = int(input())
matrices = [[0 for n in range(2)] for m in range(length)]
for _ in range(length):
    x, y = [int(n) for n in input().split(" ")]
    matrices[_] = x, y
print(matrix_chmul(matrices))


Measured memory_bytes: 5820
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define ff first
#define ss second
#define mkp make_pair    
#define mkt make_tuple
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vc vector<char> 
#define vll vector< pair<ll,ll> > 
#define pr pair<ll,ll>
#define mps map<string ,ll>
#define mpc map<char ,char>
#define mpl map<ll,ll>
#define tpl tuple<ll,ll,ll>
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;
//	   cin>>t;
	      while(t--)
{



ll n;
cin>>n;
cout<<(n*(n+1))/2;
ee;




}
return 0;
}



Measured memory_bytes: 3624
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));
        PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));

        int k = Integer.parseInt(br.readLine());

        HashSet<Long> set = new HashSet<>();
        LinkedList<Long> q = new LinkedList<>();
        for (long i = 1; i <= 9; i++) {
            q.add(i);
            set.add(i);
        }

        if (k <= 9) {
            pw.println(k);
            pw.close();
            return;
        }

        while (!q.isEmpty()) {
            long head = q.poll();

            ArrayList<Long> nbrs = new ArrayList<>();
            if (head % 10 != 0) nbrs.add(head % 10 - 1);
            nbrs.add(head % 10);
            if (head % 10 != 9) nbrs.add(head % 10 + 1);

            for (Long nbr : nbrs) {
                long val = head * 10 + nbr;
                if (set.contains(val)) continue;

                set.add(val);
                q.add(val);

                if (set.size() == k) {
                    pw.println(val);
                    pw.close();
                    return;
                }
            }
        }

        pw.close();
    }
}

Measured memory_bytes: 48468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fo(i,n) for(ll i=0;i<n;i++)
#define fok(i,k,n) for(ll i=k;i<n;i++)
#define ci(x) cin>>x
#define ci2(x,y) cin>>x>>y
#define co(x) cout<<x<<"\n"
#define co2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define deb1(x) cout<<#x<<" "<<x<<endl
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;	
constexpr ll INF = static_cast<ll>(1e18);


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	ci(s);
	int q;
	ci(q);
	deque< char> dq;
	for(int i=0;i<(int)s.length();i++){
		dq.pb(s[i]);
	}
	bool isrev=false;
	fo(i,q){
		int a;
		ci(a);
		if(a==1){
			isrev= !isrev;
		}
		else{
			int b;
			ci(b);
			char c;
			ci(c);
			if(b==1){
				if(!isrev){
					dq.pf(c);
				}
				else{
					dq.pb(c);
				}
			}
			else{
				if(isrev){
					dq.pf(c);
				}
				else{
					dq.pb(c);
				}
			}
		}
	}
	if(isrev){
		while(!dq.empty()){
			cout << dq.back();
			dq.pop_back();
		}
	}else{
		while(!dq.empty()){
		  cout << dq.front();
		  dq.pop_front();
		}
	}
	  cout << "\n";
}


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

import sys
def input(): return sys.stdin.readline().strip()

# 再帰呼び出しの回数制限(デフォルト1000)
sys.setrecursionlimit(10 ** 9)

N = int(input())
nodes = [[] for _ in range(N+1)]
for i in range(N-1):
    a, b, c = map(int, input().split())
    # nodes[出発ノード](到着ノード, コスト))
    nodes[a].append((b, c))
    # 無向グラフなのでこっちも入れる
    nodes[b].append((a, c))

memo = [0] * (N+1)
def dfs(cur, prev, dist):
    memo[cur] = dist
    for nxt, cost in nodes[cur]:
        if nxt == prev:
            continue
        dfs(nxt, cur, dist+cost)

Q, K = map(int, input().split())
dfs(K, -1, 0)

for i in range(Q):
    x, y = map(int, input().split())
    # 今回は全てKを経由するので、Kからの距離さえ分かれば全部出る
    print(memo[x] + memo[y])


Measured memory_bytes: 131760
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=100010;
const ll mod=1e9+7;


int main(){  
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  ll sum = 0;
  rep(i,n){
    cin >> a[i];
    sum += a[i];
  }
  priority_queue<ll> q;
  for(int i=1; i<ceil(sqrt(sum)); i++)if(sum%i==0){
    q.push(i);
    q.push(sum/i);
  }
  q.push(0); q.push(sum);

  ll ans = 1;
  while(!q.empty()){
    ll p = q.top(); q.pop();
    ll cnt = longinf;
    vector<ll> calc(n);
    rep(i,n) calc[i] = a[i]%p;
    sort(calc.begin(),calc.end());

    ll pl = 0;
    rep(i,n) pl += p - calc[i];
    ll mi = 0;
    rep(i,n){
      mi += calc[i];
      pl -= p-calc[i];
      cnt = min(cnt, max(pl,mi));
    }
    
    if(cnt<=k){
      ans = p;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    ll count=0;
    for(ll i=0;i<n-1;i++){
        if(s[i]!=s[i+1]) count++;
    }
    ll res=min(n-1,n-1-count+2*k);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3728
import math

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

if h * 360 / 12 +  m * 360 / 60 / 12 > m * 360 / 60:
    r = (h * 360 / 12 + m * 360 / 60 / 12 )- m * 360 / 60
else:
    r = m * 360 / 60 - (h * 360 / 12 + m * 360 / 60 / 12)

if r > 180:
    r = 360 - r

if r == 90:
    t = a ** 2 + b ** 2
    print(math.sqrt(t))
else:
    c = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(r))
    print(math.sqrt(c))

Measured memory_bytes: 9500
// #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

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

// combination
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll mod = 1e9+7;
int main() {
  int N,a,b;
  cin >> N;
  vector<vector<int>> tree(N);
  rep(i,N-1) {
    cin >> a >> b;
    a--;b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }

  vector<int> vd(N,0);
  int f=1,s=1;
  queue<int> qf,qs;
  qf.push(0);qs.push(N-1);
  vd[0]++;vd[N-1]++;

  while (!qs.empty() || !qf.empty()) {
    queue<int> qf2,qs2;

    while (!qf.empty()){
      auto t = qf.front();
      qf.pop();
      for (auto k:tree[t]) {
        if (vd[k]==0) {
          f++;
          vd[k]++;
          qf2.push(k);
        }
      }
    }
    swap(qf,qf2);

    while (!qs.empty()){
      auto t = qs.front();
      qs.pop();
      for (auto k:tree[t]) {
        if (vd[k]==0) {
          s++;
          vd[k]++;
          qs2.push(k);
        }
      }
    }
    swap(qs,qs2);
  }

  string ans = "Snuke";
  if (f>s) ans = "Fennec";
  cout << ans << endl;
}

Measured memory_bytes: 6144
H, W = map(int, input().split())

S = H * W
diff = 10 ** 12
for i in range(1, H-1):
    S_up = i * W
    S_under = W * ((H - i) // 2)
    S_middle = S - S_up - S_under
    S_max = max(S_up, S_under, S_middle)
    S_min = min(S_up, S_under, S_middle)
    diff = min(diff, abs(S_max - S_min))

for i in range(1, W-1):
    S_up = i * H
    S_under = H * ((W - i) // 2)
    S_middle = S - S_up - S_under
    S_max = max(S_up, S_under, S_middle)
    S_min = min(S_up, S_under, S_middle)
    diff = min(diff, abs(S_max - S_min))

for i in range(1, H):
    S_up = i * W
    S_under = (W // 2) * (H - i)
    S_middle = S - S_up - S_under
    S_max = max(S_up, S_under, S_middle)
    S_min = min(S_up, S_under, S_middle)
    diff = min(diff, abs(S_max - S_min))

for i in range(1, W):
    S_up = i * H
    S_under = (H // 2) * (W - i)
    S_middle = S - S_up - S_under
    S_max = max(S_up, S_under, S_middle)
    S_min = min(S_up, S_under, S_middle)
    diff = min(diff, abs(S_max - S_min))

print(diff)


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <map>
using namespace std;

#define EPS (1e-9)
#define EQ(a,b) (abs((a)-(b))<EPS)

typedef pair<int,int> P;
int main(){
  int n,pp;
  while(cin>>pp>>n&&!(n==0&&pp==0)){
    P lbp;
    double p=sqrt(pp);
    double lbval=-100000000;
    P ubp;
    double ubval=100000000.0;
    for(int i = 1; i <= n; i++){
      int bound=i*i*pp;
      int mm=bound-1;
      int m1=floor(sqrt(mm)+EPS);
      int m2=m1+1;
      if(m1<=n&&m1>=1&&!EQ(1.0*m1/i,p)&&((1.0*m1/i)<p)
    	 &&(lbval<1.0*m1/i)&&!EQ(lbval,1.0*m1/i)){
    	lbval=1.0*m1/i;
    	lbp=P(m1,i);
      }
      if(m2<=n&&m2>=1&&!EQ((1.0*m2/i),p)&&((1.0*m2/i)>p)
    	 &&(ubval>1.0*m2/i)&&!EQ(ubval,1.0*m2/i)){
    	ubval=1.0*m2/i;
    	ubp=P(m2,i);
      }
    }
    // ツ閉ェツ陛ェツづーツ個按津ィ
    // for(int i = 1; i <= n; i++){
    //   // ub/iツつェpツづヲツづィツ妥・ツつォツつュツづ按づゥツ催渉ャツづ蛍bツづーツ探ツつキ
    //   int ub=n;
    //   int lb=-1;
    //   while(ub-lb>1){
    // 	int med=(ub+lb)/2;
    // 	double val=(double)(med)/i;
    // 	if(p<val&&!EQ(p,val))
    // 	  ub=med;
    // 	else
    // 	  lb=med;
    //   }
    //   if(ub<=n&&ub>=1&&!EQ((1.0*ub/i),p)&&((1.0*ub/i)>p)
    // 	 &&(ubval>1.0*ub/i)&&!EQ(ubval,1.0*ub/i)){
    // 	ubval=1.0*ub/i;
    // 	ubp=P(ub,i);
    //   }
    //   lb=ub-1;
    //   if(lb<=n&&lb>=1&&!EQ(1.0*lb/i,p)&&((1.0*lb/i)<p)
    // 	 &&(lbval<1.0*lb/i)&&!EQ(lbval,1.0*lb/i)){
    // 	lbval=1.0*lb/i;
    // 	lbp=P(lb,i);
    //   }
    // }
    printf("%d/%d %d/%d\n",ubp.first,ubp.second,lbp.first,lbp.second);
  }
  return 0;
}

Measured memory_bytes: 900
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

string s;

ll pal(string s){
    ll n = SZ(s);
    for(ll i = 0 ; i < n ; i++) if(s[i] != s[n - i - 1])    return 0;
    return 1;
}

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

    cin >> s;
    if(pal(s) && pal(s.substr(0 , SZ(s) / 2)))  return cout << "Yes" << endl , 0;
    cout << "No" << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;

int main(void){
    // Your code here!
    int n;
    cin >> n;
    vector<int> p(n+1);
    p.at(0) = 0;
    FOR(i,1,n) cin >> p.at(i);
    int min = p.at(1);
    int count = 1;
    FOR(i,2,n) {
        if (p.at(i) < min ) {
            count++;
            min = p.at(i);
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 1024