akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
  double q,x,EPS;
  while(true){
    cin >> q;
    if(q == -1)break;
    EPS = 0.00001*q;
    x = q/2;
    while(fabs(q-pow(x,3)) > EPS){
      x = x-(pow(x,3)-q)/(pow(x,2)*3);
    }
    printf("%.6f\n",x);
  }
  return 0;
}

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

using namespace std;

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

  vector<int> vec(n + 1);
  for (int i = 0; i < n; i++)
  {
    int a;
    cin >> a;
    vec[a] = i;
  }

  int ans = 1;
  int i = 2, cur = 1;
  while (i <= n)
  {
    while (vec[i] > vec[i - 1] && i <= n)
    {
      cur++, i++;
    }
    ans = max(ans, cur);
    cur = 1;
    i++;
  }
  cout << n - ans << endl;
  return 0;
}

Measured memory_bytes: 1024
/*
Stay innocent, be naive. 
But still dream big. 
Dream big to the point that it is beyond your ability and endeavour to achieve it. 
So dream big and don’t lose your innocence.
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N-1];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N-1; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         //
         int[] res = new int[N];
         res[0] = arr[0];
         res[N-1] = arr[N-2];
         for(int i=1; i < N-1; i++)
         {  
            if(i%2 <= 1)
               res[i] = Math.min(arr[i], arr[i-1]);
            else
               res[i] = Math.min(arr[i], arr[i+1]);
         }
         int sum = 0;
         for(int x: res)
            sum += x;
         System.out.println(sum);
      }
   }

Measured memory_bytes: 23252
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }
const int VX[] = { 0, 1, 0, -1 };
const int VY[] = { 1, 0, -1, 0 };
const long MOD = 1000000007;

int main() {
	//	--- I/O 高速化 ---
	cin.tie(0);
	ios::sync_with_stdio(false);
	// --- ここまで ---

	int a, b, c, d;

	cin >> a >> b >> c >> d;

	int L = a + b, R = c + d;

	if ( L == R)
	{
		cout << "Balanced" << endl;
	} else if (L > R)
	{
		cout << "Left" << endl;
	} else
	{
		cout << "Right" << endl;
	}


	return 0;
}



Measured memory_bytes: 256
def main():
    import heapq
    from sys import stdin
    input=stdin.readline
    class unionfind():
        #size:要素数,tree：unionfind木
        def __init__(self,size):#self,要素数
            self.size=size
            self.tree=[[i,1] for i in range(self.size)]#root,depth
        
        #rootを探す
        def root(self,index):
            if self.tree[index][0]==index:
                return index
            else:
                self.tree[index][0]=self.root(self.tree[index][0])
                return self.tree[index][0]
    
        #結合
        def unite(self,index1,index2):
            r1=self.root(index1)
            r2=self.root(index2)
            if r1!=r2:
                d1,d2=self.tree[r1][1],self.tree[r2][1]
                if d1<=d2:
                    self.tree[r1][0]=r2
                    self.tree[r2][1]=max(d1+1,d2)
                else:
                    self.tree[r2][0]=r1
                    self.tree[r1][1]=max(d2+1,d1)
    
        #同じか判定
        def same(self,index1,index2):
            r1=self.root(index1)
            r2=self.root(index2)
            return r1==r2
    
    n=int(input())
    xy=[list(map(int,input().split())) for _ in [0]*n]
    xyz=[xy[i]+[i] for i in range(n)]
    x_sort=sorted(xyz,key=lambda x:x[0])
    y_sort=sorted(xyz,key=lambda x:x[1])
    g=[]
    heapq.heapify(g)
    for i in range(n-1):
        heapq.heappush(g,[abs(x_sort[i+1][0]-x_sort[i][0]),x_sort[i][2],x_sort[i+1][2]])
    for i in range(n-1):
        heapq.heappush(g,[abs(y_sort[i+1][1]-y_sort[i][1]),y_sort[i][2],y_sort[i+1][2]])
    u=unionfind(n)
    cnt=0
    while g:
        d,i,j=heapq.heappop(g)
        if u.same(i,j)==False:
            cnt+=d
            u.unite(i,j)
    print(cnt)
main()

Measured memory_bytes: 77008
#include <cstdio>
#include <cctype>

int main(){
	char ch;
	
	while(1){
		scanf("%c", &ch);
		
		if(islower(ch)) printf("%c", toupper(ch));
		else if(isupper(ch)) printf("%c", tolower(ch));
		else printf("%c", ch);
		
		if(ch=='\n') break;
	}

	return 0;
}


Measured memory_bytes: 2520
import math
 
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
 
if __name__=='__main__':
  x=int(input())
  ans=get_sieve_of_eratosthenes(10**5+100)
  for i in ans:
    if i<x:
      continue
    else:
      print(i)
      break

Measured memory_bytes: 7448
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include<math.h>
using namespace std;
 int main(){
   int n; cin >> n;
   if(n==1) cout<< "Hello World"<<endl;
   if(n==2){
     int a,b; cin >> a>>b;
     cout << a+b <<endl;
   }
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef unsigned long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;
constexpr int mod = 1e9+7;

int main() {
  int x;
  cin >> x;
  cout << (x >= 30 ? "Yes" : "No") << endl;
  return 0;
}

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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            long N = long.Parse(s[0]);
            long M = long.Parse(s[1]);

            //SortedList<long, long> AB = new SortedList<long, long>();
            Dictionary<long, long> AB = new Dictionary<long, long>();
            long A0, B0;
            for (long i = 0; i < N; i++)
            {
                s = Console.ReadLine().Split(' ');
                A0 = long.Parse(s[0]);
                B0 = long.Parse(s[1]);
                if (AB.ContainsKey(A0))
            	{
                    AB[A0] += B0;
                }
                else
                {
                    AB.Add(A0, B0);
                }
            }

            var sortedAB = AB.OrderBy((X) => X.Key);

            long totalcost = 0;
            long totaldrink = 0;
            


            foreach (var item in sortedAB)
            {
                totalcost += item.Key * item.Value;
                totaldrink += item.Value;
                if (totaldrink > M)
                {
                    totalcost -= (totaldrink - M) * item.Key;
                    break;
                }
            }

            Console.WriteLine(totalcost);
            //Console.ReadLine();

        }




    }
}


Measured memory_bytes: 28228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;
typedef tuple<int,int,int> TP;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}
 
ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}
 
ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    string S;
    cin >> S;
    for(int i = 0;i < S.size();i++) {
        if(S.at(i) == '?') {
            S.at(i) = 'D';
        }
    }
    cout << S << endl;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
#define DBG(x) cerr << #x << “ = ” << (x) << endl
#define Rep(i,a,b) for (int i = a, to = b; i < to; i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

typedef long long Long;

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	int x,y;
    cin>>x>>y;
    if(4*x>=y&&y>=2*x&&(y-2*x)%2==0&&(4*x-y)%2==0){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
	return 0;
}

Measured memory_bytes: 3640
import string

def cyp(strr,n):
    nstrr=''
    for c in strr:
        if c in string.lowercase:
            ind=string.lowercase.index(c)
            nstrr+=string.lowercase[(ind+n)%26]
        else:
            nstrr+=c
    return nstrr
while(1):
    try:
        s=raw_input()
        for i in range(26):
            nstrr=cyp(s,i)
            if ('the' in nstrr) or ('this' in nstrr) or ('that' in nstrr):
                print nstrr
                break
    except:
         break

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	string s;
	cin >> s;
	if (s == "Sunny") cout << "Cloudy";
	if (s == "Cloudy") cout << "Rainy";
	if (s == "Rainy") cout << "Sunny";
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>

int main(void)
{
	int g[101];
	int a,b;
	while(1){
		for(int i=0;i<101;i++) g[i]=0;
		while(1){
			if(scanf("%d %d",&a,&b)==EOF) return 0;
			if(a==0&&b==0) break;
			g[a]++;
			g[b]++;
		}
		int odd=0;
		bool flag=true;
		if(g[1]%2!=1||g[2]%2!=1) flag=false;
		for(int i=3;i<101;i++){
			if(g[i]%2==1){
				flag=false;
				break;
			}
		}
		if(flag==true) printf("OK\n");
		else printf("NG\n");
	}
	return 0;
}

Measured memory_bytes: 996
#include<iostream>
#include<cstring>
using namespace std;
int main(){
    long long int n,ans=0,i,j,k;
    cin>>n;
    long long int a[n+1][n+1];
    bool p[n+1][n+1];
    memset(p,0,sizeof(p));
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            cin>>a[i][j];
    for(k=1;k<=n;k++)      
        for(i=1;i<=n;i++)
            for(j=1;j<=n;j++){
                if(a[i][j]==a[i][k]+a[k][j]&&k!=j&&k!=i&&i!=j)
                    p[i][j]=1;
                if(a[i][j]>a[i][k]+a[k][j]){
                    cout<<"-1"<<endl;
                    return 0;
                }
            }
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            if(p[i][j]==0)
                ans+=a[i][j];
    cout<<ans/2<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define FOR(i, a, b) for(i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define comp(a, b) comp(const void *a, const void *b)
#define MOD  1000000007

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;

void yes_or_no(char boolean){
    if(boolean){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}

int main(){
    ull N, d;
    scanf("%llu", &N);
    ull last = N % 11;

    if(last > 6){
        d = 2;
    }else if(last > 0){
        d = 1;
    }else{
        d = 0;
    }
    printf("%llu\n", d + (N/11) * 2);
    return 0;
}

Measured memory_bytes: 128
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let [a,b] = nextIntArray()
    let ans = []
    let tmp = ""
    for(let i = 0; i<a; i++){
        tmp += String(b)
    }
    ans.push(tmp)
    tmp = ""
    for(let i = 0; i<b; i++){
        tmp += String(a)
    }
    ans.push(tmp)
    ans.sort()
    console.log(ans[0])
}
Main()


Measured memory_bytes: 29572
package main

import "fmt"

func main(){
	var S string;

	fmt.Scan(&S);
	var week = [7]string {
		"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT",
	}

	for i := 0 ; i < 7 ; i++{
		if S == week[i] {
			fmt.Println(7-i);
			
		}
	}
}

Measured memory_bytes: 512
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end
N, a_list = gets_n_and_i_list

even_list = a_list.select.with_index{|e, i| i.even?}
odd_list  = a_list.select.with_index{|e, i| i.odd?}

even_h = even_list.group_by(&:itself).map{|k,v| [k, v.count] }.to_h
odd_h  = odd_list.group_by(&:itself).map{|k,v| [k, v.count] }.to_h

max_even = even_h.max{|x, y| x[1] <=> y[1]}
max_odd  = odd_h.max{|x, y| x[1] <=> y[1]}

dpp even_h
dpp odd_h

if max_even[0] != max_odd[0]
  puts N - max_even[1] - max_odd[1]
else
  me = max_even
  mo = max_odd
  even_h.delete(me[0])
  odd_h.delete(mo[0])
  max_even = even_h.max{|x, y| x[1] <=> y[1]}
  max_odd  = odd_h.max{|x, y| x[1] <=> y[1]}

  dpp max_even
  dpp max_odd

  if max_even.nil? && max_odd.nil?
    puts N/2
  elsif max_even.nil?
    puts N - me[1] - max_odd[1]
  elsif max_odd.nil?
    pp [N, max_even[1], mo[1]]
    puts N - max_even[1] - mo[1]
  else
    puts [N - me[1] - max_odd[1], N - max_even[1] - mo[1]].min
  end
end


Measured memory_bytes: 40952
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;


int n, mod, a, b, c, t;
typedef vector<vi> M;
inline M operator*(const M & a, const M &b){
	M c(a.size(), vi(b[0].size()));
	rep(i, c.size()) rep(j, c[0].size()){
		ll s = 0;
		rep(k, a[0].size()) s += (ll)a[i][k] * b[k][j] % mod;
		c[i][j] = s % mod;
	}
	return c;
}
inline M pow(M a, ll m){
	M res(a.size(), vi(a.size()));
	rep(i, a.size()) res[i][i] = 1;
	for(; m; m /= 2){
		if(m & 1) res = res * a;
		a = a * a;
	}
	return res;
}

int main(){
	while(cin >> n >> mod >> a >> b >> c >> t, n){
		M m(n, vi(n));
		rep(i, n){
			if(i) m[i][i - 1] = a;
			m[i][i] = b;
			if(i < n - 1) m[i][i + 1] = c;
		}
		m = pow(m, t);
		M s(n, vi(1));
		rep(i, n) cin >> s[i][0];
		s = m * s;
		
		rep(i, n) cout << s[i][0] << (i == n - 1 ? "\n" : " ");
	}
	return 0;
}

Measured memory_bytes: 1312
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'

int f(int n, int d) {
	return n / d;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int l, r, d;
    cin >> l >> r >> d;
    int ans = f(r, d) - f(l - 1, d);
    cout << ans << endl;
}

Measured memory_bytes: 3632
while True :
    n = int(input())
    if n == 0 :
        break
    
    count = 0
    for i in range(1, n) :
        s = 0
        for j in range(i, n) :
            s += j
            if s == n :
                count += 1
            if s > n :
                break
    print(count)


Measured memory_bytes: 5588
#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

int n, k;
int a[100000];
vector<int> child[100000];

int ans;


int dfs(int u) {
	int d = 0;
	for (int v : child[u])d = max(d, dfs(v) + 1);
	if (d == k-1 && a[u]!=0) {
		ans++;
		d = -1;
	}

	return d;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	rep(i, n) {
		cin >> a[i];
		a[i]--;
		if (i == 0 && a[i]) {
			ans++;
			a[0] = 0;
		}
		if(i)child[a[i]].push_back(i);
	}
	for (int v : child[0])dfs(v);
	cout << ans << endl;


	return 0;
}

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

int main(){
    char x;
    cin>>x;
    switch(x){
        case 'a':
        case 'i':
        case 'u':
        case 'e':
        case 'o':
            cout<<"vowel"<<endl;
            break;
        default:
            cout<<"consonant"<<endl;

    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace abc078_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine((x[0] - x[2]) / (x[1] + x[2]));
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
int main()
{
	int n, i;
	map<string, int> mp;
	string s;
	cin >> n;
	cin >> s;
	mp[s] += 1;
	rep(i, n - 1) {
		string c;
		cin >> c;
		mp[c] += 1;
		if (mp[c] > 1 || c[0] != s.back()) {
			cout << "No" << endl;
			exit(0);
		}
		s = c;
	}
	cout << "Yes" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(150) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<lli,lli>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  lli A,B,C,D,E,L,R,X,Y,W,H,N,M,K,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  rep(i,1,N)P[i]+=P[i-1];
  P.pb(0);Sort(P);
  map<lli,lli>Q;
  rep(i,1,N+1)if(P[i]==P[i-1])Q[P[i]]++;
  for(pint v:Q)sum+=(v.second+1)*(v.second)/2;
  Out(sum);
}

Measured memory_bytes: 4608
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000
#define MOD 1000000007
typedef long long ll;
typedef pair<string,pair<int,int> > P;

int dp[50000];

int main(){
    P a[110];
    int N,p;
    cin>>N;
    string s;

    for(int i=0;i<N;i++){
        cin>>s>>p;
        a[i].first=s;
        a[i].second.first=-p;
        a[i].second.second=i+1;
    }
    sort(a,a+N);

    for(int i=0;i<N;i++) cout<<a[i].second.second<<endl;
}


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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

// bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
//     return arg1.first > arg2.first;
// }

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

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

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

    vector<int> tri = {x, y, z};

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

    cout << tri.at(0)*tri.at(1)/2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, INF = 1e9;
string s;
vector<int> g[2000];

int sum(int v, int h, int p) {
	int c = h * (s[v] - '0');
	RF(e, g[v]) {
		if(e == p) { continue; }
		c += sum(e, h + 1, v);
	}
	return c;
}

struct A {
	int ma, mi, c;
	bool operator<(A b) { return (ma < b.ma); }
};

A dfs(int v, int p) {
	vector<A> va;
	RF(e, g[v]) {
		if(e == p) { continue; }
		A x = dfs(e, v);
		x.ma += x.c;
		x.mi += x.c;
		va.PB(x);
	}
	sort(RALL(va));
	
	A ans = { 0, 0, 0 };
	RF(e, va) {
		ans.ma += e.ma;
		ans.c  += e.c;
	}
	if(SI(va) > 0) { ans.mi = max(ans.ma % 2, va[0].mi - (ans.ma - va[0].ma)); }
	ans.c += (s[v] - '0');
	
	return ans;
}

int f(int v) {
	int s = sum(v, 0, -1);
	A x = dfs(v, -1);
	return (s % 2 == 0 && x.mi == 0 ? s / 2 : INF);
}

int main() {
	cin >> n >> s;
	inc(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].PB(b);
		g[b].PB(a);
	}
	
	int ans = INF;
	inc(i, n) { setmin(ans, f(i)); }
	
	cout << (ans == INF ? -1 : ans) << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#include <regex>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;
typedef pair< int, int > pii;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

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

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  string s;
  cin >> s;

  regex r("A{0,1}KIHA{0,1}BA{0,1}RA{0,1}");

  if(regex_match(s, r)) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fr(i,j,n)   for(int i=j;i<(n);++i)
#define bk(i,j,n)   for(int i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define MOD 1000000007
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long  ll;

ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

ll gcdExtended(ll a, ll b, ll *x, ll *y);

ll modInverse(ll b, ll m)
{
    ll x, y;
    ll g = gcdExtended(b, m, &x, &y);

    return (x%m + m) % m;
}

ll modDivide(ll a, ll b, ll m)
{
    a = a % m;
    ll inv = modInverse(b, m);
    return (inv * a) % m;
}

ll gcdExtended(ll a, ll b, ll *x, ll *y)
{
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1);

    *x = y1 - (b/a) * x1;
    *y = x1;

    return gcd;
}
ll mul(ll n,ll a)
{
    ll p=n-a;
    p++;
    ll j=1ll;
    ll s=1ll;
    while(p<=n)
    {
        ll o=modDivide(p,j,MOD);
        o%=MOD;
        s*=o;
        s%=MOD;
        p++,j++;

    }
    return s;
}
int main()
{
    run;
    ll n,a,b;
    cin>>n>>a>>b;

    ll i=modpower(2ll,n,MOD)-1+MOD;
    ll p1,p2;
    if(a<n)
     p1=mul(n,a);
     else
        p1=1;
     if(b<n)
    p2=mul(n,b);

    else
        p2=1;
    if(a==b)
        p1=0;
    i%=MOD;
    p1%=MOD;
    p2%=MOD;
    ll c=p1+p2;
    c%=MOD;





    ll uu=(i-c+MOD)%MOD;
    cout<<uu;






}


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

struct BIT{
  vector<int> bit;
  int n;
  //1-indexed
  BIT(){init(-1);}
  BIT(int n_){init(n_);}
  void init(int n_){
    n=n_;
    bit.clear();
    bit.resize(n+1,0);
  }
  int sum(int i){
    int s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
  void add(int i,int x){
    if(i==0) return;
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
  int sum0(int i){
    return sum(i+1);
  }
  void add0(int i,int x){
    add(i+1,x);
  }
};

struct StarrySky{
  int n;
  const int def=1LL<<55LL;
  vector<int> datm,data;
  StarrySky(){}
  StarrySky(int n_){init(n_);}
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    datm.clear();
    datm.resize(n*2-1,def);
    data.clear();
    data.resize(n*2-1,0);
  }
  void add(int a,int b,int x,int k,int l,int r){
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      data[k]+=x;
      return;
    }
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
    datm[k]=min(datm[k*2+1]+data[k*2+1],
		datm[k*2+2]+data[k*2+2]);
  }
  int query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return def;
    if(a<=l&&r<=b) return datm[k]+data[k];
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr)+data[k];
  }
  void add(int a,int b,int x){
    add(a,b,x,0,0,n);
  }
  int query(int a,int b){
    return query(a,b,0,0,n);
  }
};

signed main(){
  int n,e,t;
  cin>>n>>e>>t;
  int x[n+1];
  for(int i=0;i<n;i++) cin>>x[i];
  x[n]=e;
  
  int dp[n+1];
  int INF=1LL<<55LL;
  fill_n(dp,n+1,INF);
  dp[0]=x[0];

  BIT bit(n+1);
  StarrySky ss(n+1);
  
  for(int i=0;i<n;i++){
    bit.add0(i,-x[i]*2);
    bit.add0(i+1,x[i]*2);
  }
  ss.add(0,1,t-ss.def);
  int k=0,pre=0;
  for(int j=0;j<n;j++){
    bit.add0(0,2*(x[j]-pre));
    ss.add(0,k,2*(x[j]-pre));
    pre=x[j];
    while(k<=j&&bit.sum0(k)>=t){
      ss.add(k,k+1,bit.sum0(k)-t);
      k++;
    }
    /*
    cout<<"bit"<<endl;
    for(int i=0;i<=n;i++)
      cout<<i<<":"<<bit.sum0(i)<<endl;
    cout<<endl;
    cout<<"ss"<<endl;
    for(int i=0;i<=n;i++)
      cout<<i<<":"<<ss.query(i,i+1)<<endl;
    cout<<endl;
    */
    
    int res=ss.query(0,j+1);
    dp[j+1]=res+x[j+1];
    ss.add(j+1,j+2,(res+t)-ss.query(j+1,j+2));
    /*
    cout<<"k:"<<k<<endl;
    cout<<"res:"<<res<<endl;
    cout<<"dp[j+1]:"<<dp[j+1]<<endl;
    cout<<j<<":"<<res<<endl;
    cout<<"----------"<<endl;
    */
  }
  cout<<dp[n]<<endl;
  return 0;
}


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

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b) {
        cout << c << endl;
        return 0;
    }
    if (b == c) {
        cout << a << endl;
        return 0;
    }
    if (a == c) {
        cout << b << endl;
        return 0;
    }
    return 0;
}


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

using namespace std;

struct node{
	long long path  = -1;
	vector<int> childs;
};

int dfs(vector<node> &g,int v){
	if(g[v].path!= -1){
		return g[v].path;
	}else{
		int mx = 0;
		int cp;
		for(int i = 0;i < g[v].childs.size(); ++i){
			cp = dfs(g,g[v].childs[i]) + 1;
			if(cp > mx)
				mx = cp;
		}
		g[v].path = mx;
	}
	return g[v].path;
}

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

	int n,m;
	cin >> n >> m;
	vector<node> graph(n+1);
	for(int i = 0;i < m; ++i){
		int x,y;
		cin >> x >> y;
		graph[x].childs.push_back(y);
	}
	for(int i = 1; i <= n; ++i){
		if(graph[i].path == -1){
			dfs(graph,i);
		}
	}
	int mx =0;
	for(int i = 0;i < n; ++i){
		if(mx < graph[i+1].path){
			mx = graph[i+1].path;
		}
	}
	cout << mx;

	return 0;
}

Measured memory_bytes: 8576
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 1000
#define LL long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; --i)
#define FJ(i, a, b) for(int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _P fd[rt]
#define _L fd[rt << 1]
#define _R fd[rt << 1 | 1]
#define MID int mid = ((l + r) >> 1)
#define lson rt<<1 ,l, mid
#define rson rt<<1 | 1, mid + 1, r
#define PB push_back
#define SZ size
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define MP make_pair
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
const int MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-8;
inline void II(int &n){char ch = getchar(); n = 0; bool t = 0;
for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1;
for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;}
int n, h, w, k;
const int dir[4][2] = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};
char mp[N][N];
bool in(int x, int y){
    if(x >= 1 && x <= h && y >= 1 && y <= w) return 1;
    return 0;
}
int vis[N][N];
int X, Y;
int main(){
   // IN;
    SCC(h, w);
    scanf(" %d ", &k);
    FF(i, 1, h) SS(mp[i] + 1);
    FF(i, 1, h) FF(j, 1, w) if(mp[i][j] == 'S') X = i, Y = j;
    queue<PII>Q;
    Q.push(MP(X, Y));
    CL(vis, -1);
    vis[X][Y] = 0;
    while(!Q.empty()){
        PII u = Q.front();
        Q.pop();
        int x = u.first, y = u.second;
        FF(i, 0, 3){
            int xx = x + dir[i][0], yy = y + dir[i][1];
            if(in(xx, yy) && mp[xx][yy] == '.'){
                if(vis[xx][yy] == -1){
                    Q.push(MP(xx, yy));
                    vis[xx][yy] = vis[x][y] + 1;
                }
            }
        }
    }
    int ans = INF;
    FF(i, 1, h) FF(j, 1, w) if(vis[i][j] != -1 && vis[i][j] <= k){
        int u = i - 1, d = h - i, l = j - 1, r = w - j;
        int s1 = min(u, d), s2 = min(l, r);
        int s = min(s1, s2);
        if(s % k) s = s / k + 1;
        else s = s / k;
        if(s + 1 < ans) ans = s + 1;
    }
    PR(ans);
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
#include <set>
#include <map>
#include <unordered_map>
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    fast_io();

    ll n; std::cin >> n;
    std::vector<ll> a(n);
    for(int i=0; i<n; i++){
        std::cin >> a[i];
    }

    int axor = 0;
    for(int i=0; i<n; i++){
        axor = axor ^ a[i];
    }

    for(int i=0; i<n; i++){
        std::cout << (axor ^ a[i]) << " ";
    }

    return 0;
}


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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl

const long long MOD = 1000000007;


int main(){
    ll n;
    cin >> n;
    ll h[n];
    rep(i, n){
        cin >> h[i];
    }
    ll m = h[0]-1;
    for(ll i = 1; i < n; i++){
        if(h[i] < m){
            cout << "No" << endl;
            return 0;
        }else if(h[i] > m){
            m = h[i]-1;
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 1024
def read_input():
    n = int(input())

    names = []
    for i in range(n):
        names.append(input())

    return n, names


# MARCHのうち3つの取り出すパターンを作成
def initial_pattern():
    return [
        ['A', 'M', 'R'],
        ['A', 'C', 'M'],
        ['A', 'H', 'M'],
        ['C', 'M', 'R'],
        ['H', 'M', 'R'],
        ['C', 'H', 'M'],
        ['A', 'C', 'R'],
        ['A', 'H', 'R'],
        ['A', 'C', 'H'],
        ['C', 'H', 'R']]


def submit():
    n, names = read_input()

    name_file = {'M':[], 'A':[], 'R':[], 'C':[], 'H':[]}
    for n in names:
        if n[0] in 'MARCH':
            name_file[n[0]].append(n)

    count = 0
    initials = initial_pattern()

    for initial in initials:
        count += len(name_file[initial[0]]) * len(name_file[initial[1]]) * len(name_file[initial[2]])

    print(count)

if __name__ == '__main__':
    submit()


Measured memory_bytes: 60760
def solve():
    H, W = map(int,input().split())
    S = [list(input()) for i in range(H)]
    ans = []

    dx = (-1,0,1)
    dy = (-1,0,1)
    d_pattern = []
    for x in dx:
        for y in dy:
            if x == 0 and y == 0:
                continue
            d_pattern.append([y,x])

    for h in range(H):
        line = []
        for w in range(W):
            if S[h][w] == '#':
                line.append('#')
                continue

            cnt = 0
            for y, x in d_pattern:
                if 0 <= y+h < H and 0 <= x+w < W:
                    if S[y+h][x+w] == '#':
                        cnt += 1
            line.append(str(cnt))
        ans.append("".join(line))
    
    print(*ans, sep='\n')

if __name__ == '__main__':
    solve()

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

using namespace std;

bool isprimeNumber(int x){
  if (x == 2){
    return true;
  }

  if (x < 2 || x % 2 == 0){
    return false;
  }

  int i = 3;

  for (int i = 3; i <= sqrt(x); i+=2){
    if (x % i == 0){
      return false;
    }
  }

  return true;
}

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

  for (int i = 0; i < n; i++){
    int num;
    cin >> num;

    if (isprimeNumber(num)){
      count++;
    }
  }

  cout << count << endl;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (ll)4e18;
const int inf = 1001001001;
const int mod = 1000000007;

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	a--;
	ll num = lcm(c, d);
	ll res = b - b / c - b / d + b / num;
	ll res2 = a - a / c - a / d + a / num;
	ll ans = res - res2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define abs(a) ((a) > 0? (a) : (-a))
int N;

int main(void){
	int a,b;
	cin >> N >> a >> b;
	int a_dir = a-b > 0 ? -1: 1;
	int b_dir = -a_dir;
	for (;;){
		if (a+a_dir == b){
			if (a == 1 || a == N){
				cout << "Borys" << "\n";
				break;
			}
			a -= a_dir;
		} else {
			a += a_dir;
		}

		if (b+b_dir == a){
			if (b == 1 || b == N){
				cout << "Alice" << "\n";
				break;
			}
			b -= b_dir;
		} else {
			b += b_dir;
		}
	}
	/*
	int center = N>>1 + N&1;
	if((N&1) && (a == center) && (abs(b-center) == 1))
	{
		cout << "Boyris" << "\n";
	}
	else if (!(N&1) && (a == center) && (a == center)){
		cout << "Boyris" << "\n";
	}else{
		cout <<(abs(a-center) >= abs(b-center) ? "Alice" : "Boyris") << "\n";
	}
	*/
	return 0;
}

Measured memory_bytes: 256
/*2019/08/25 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
int llasc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
int lldesc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
/*
int asc_t(const void *a,const void *b){return ((struct_t*)a)->member - ((struct_t*)b)->member;}
int desc_t(const void *a,const void *b){return ((struct_t*)b)->member - ((struct_t*)a)->member;}
*/

int main(){
    int n,a[40],b[40],c[40];

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i++){
        scanf("%d",&b[i]);
    }
    for(int i=0;i<n-1;i++){
        scanf("%d",&c[i]);
    }

    int ans=0;
    int bef=-1;
    for(int i=0;i<n;i++){
        ans+=b[a[i]-1];
        if(bef+1==a[i]){
            ans+=c[a[i]-2];
        }
        bef=a[i];
    }

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

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    cout<<fixed<<setprecision(12);
    double a,b,c;
    cin>>a>>b>>c;
    double S,L,h;
    S=a*b*sin(acos(-1)*2*c/360)/2;
    //余弦定理を使う
    L=sqrt(a*a+b*b-2*a*b*cos((acos(-1)*2*c/360)))+a+b;
    h=b*sin((acos(-1)*2*c/360));
    cout<<S<<endl<<L<<endl<<h<<endl;
}



Measured memory_bytes: 3664
#include <stdio.h>
int main()
{
	int N,A,B;
	scanf("%d%d%d",&N,&A,&B);
	if(N==1)
	{
		if(A==B)
			printf("1");
		else
			printf("0");
	}
	else{
		if(A>B)
			printf("0");
		else
			printf("%lld",(long long)(B-A)*(N-2)+1);
	}
		
} 



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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

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

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


void solve() {
    int n;
    cin >> n;
    vi a = vi(n, 0);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    int freeCnt = 0;
    set<int> colors;
    for (int i = 0; i < n; ++i) {
        if (3200 <= a[i]) {
            freeCnt++;
            continue;
        }

        colors.insert(a[i] / 400);
    }

    int minC = colors.size();
    if(minC == 0) minC = 1;

    cout << minC << " " << colors.size() + freeCnt << "\n";
}


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

    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
//#define MOD (998244353)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

pair<int,pii> dp[3000][3000];
string s,t;
int n,m;

pair<int,pii> f(int i,int j){
    if(i==n || j==m)return {0,{-1,-1}};
    
    pair<int,pii> &ans=dp[i][j];
    
    if(ans!=pair<int,pii>(-1,pii(-1,-1)))return ans;
    
    if(s[i]==t[j]){
        ans={1+f(i+1,j+1).first,{i,j}};
    }else{
        if(f(i+1,j).first>f(i,j+1).first){
            ans=f(i+1,j);
        }else{
            ans=f(i,j+1);
        }
    }
    return ans;
}

signed main(){
    FASTER;
    for(int i=0;i<3000;i++)for(int j=0;j<3000;j++)dp[i][j]={-1,{-1,-1}};
    cin>>s>>t;
    n=s.size();
    m=t.size();
    
    int i=0,j=0;
    while(f(i,j).first!=0){
        pii p=f(i,j).second;
        i=p.first;
        j=p.second;
        cout<<s[i];
        i++,j++;
    }
}


Measured memory_bytes: 212096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int dp[100010];
const int mod = 1e9+7;

int main(){
   int n,m;
   cin >> n >> m;
   rep(i,m){
      int tmp;
      cin >> tmp;
      dp[tmp]= -1;
   }
   dp[0] = 1;
   rep(i,n){
      if (dp[i] == -1) continue;
      if (dp[i+1] != -1) {
         dp[i+1] += dp[i];
         dp[i+1] %= mod;
      }
      if (dp[i+2] != -1){
         dp[i+2] += dp[i];
         dp[i+2] %= mod;
      }
   }
   cout << dp[n] << endl;

  
  return 0;
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);
//ios::sync_with_stdio(false);

long double dp[3010][3010];

signed main(){
    ll n;cin>>n;
    vector<long double> p(n,0);
    rep(i,n)cin>>p[i];

    dp[0][0]=1;

    for(int i=0;i < n;i++)
    {
        for(int j=0;j < n+1;j++)//表の枚数
        {
            if(i<j)continue;

            dp[i+1][j+1]+=dp[i][j]*p[i];
            dp[i+1][j]+=dp[i][j]*(1-p[i]);
        }
    }

    long double ans=0;

    for(int i=n;n/2<i;i--){
        ans+=dp[n][i];
    }

    cout<<fixed<<setprecision(20)<<ans<<endl;
}

Measured memory_bytes: 139776
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Cryptography;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var h1 = int.Parse(spl[0]);
        var m1 = int.Parse(spl[1]);
        var h2 = int.Parse(spl[2]);
        var m2 = int.Parse(spl[3]);
        var k = int.Parse(spl[4]);


        long t1 = h1 * 60 + m1;
        long t2 = h2 * 60 + m2;

        return Math.Max( (t2 - t1) - k, 0);
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}

Measured memory_bytes: 27452
#include<stdio.h>
int main(void){
long long n,a[10000],i,x,max=-1000000,min=1000000,sum=0;
scanf("%lld",&n);
for(x=0;x<n;x++){scanf("%lld",&a[x]);
    if (min>a[x]){min=a[x];}
    if (max<a[x]){max=a[x];}
    sum=sum+a[x];
}
printf("%lld %lld %lld\n",min,max,sum);
return 0;
}

Measured memory_bytes: 676
def divisor(n):
    # 約数
    return [[i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0]


def main():
    N = int(input())
    rslt = divisor(N)
    print(rslt[-1][0] + rslt[-1][1] - 2)
    return


main()


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define MAXN 3005

double dp[MAXN];


int main(){
  int n; cin >> n;
  dp[0] = 1;
  for(int i=0; i<n; ++i) {
    double x; cin >> x;
    for(int j=i+1; j>=0; --j)
      dp[j] = ((j == 0) ? 0 : dp[j-1]*x) + (1-x)*dp[j];  
  }
  double res = 0;
  for(int i=0; i<=n; ++i){
    if(i > n-i)
      res += dp[i];
  }
  cout << fixed << setprecision(10) << res << "\n";
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    char S[100001];
    int i, j, n, Ans;
    scanf("%s",S);
    j = S[0];
    n = strlen(S);
    Ans = 0;
    for(i=1; i<n; i++){
        if(S[i] != j){
            ++Ans;
            j = S[i];
            }
        }
    printf("%d\n", Ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

typedef pair<int, int> P;

int N, M;

void print(double a[201][201]){
  for(int i = 0; i < N; ++i){
    for(int j = 0; j <= M; ++j){
      cout << a[i][j] << " ";
    }
    cout << endl;
  }
}

int main(){
  cin >> N >> M;
  vector<P> vec[201];
  for(int i = 0; i < N; ++i){
    int K;
    cin >> K;
    for(int j = 0; j < K; ++j){
      int S, H;
      cin >> S >> H;
      vec[i].push_back(make_pair(S, H));
    }
  }

  double V[201][201];
  for(int i = 0; i < N; ++i){
    for(int j = 0; j <= M; ++j){
      V[i][j] = 0;
    }
  }

  //print(V); cout << endl;
  
  for(int i = 0; i < N; ++i){
    double sum = 0;
    int p = 0;
    for(int j = 1; j <= M; ++j){
      if(p == vec[i].size()){
	break;
      }
      V[i][j] = V[i][j-1] + 1.0 / vec[i][p].first;
      if(abs(vec[i][p].first * vec[i][p].second + sum - j) < 1e-8){
	sum = j;
	++p;
      }
    }
  }

  //print(V);

  double dp[201][201];
  for(int i = 0; i <= N; ++i){
    for(int j = 0; j <= M; ++j){
      dp[i][j] = 0;
    }
  }

  for(int i = 0; i < N; ++i){
    for(int j = 0; j <= M; ++j){
      for(int k = 0; k + j <= M; ++k){
	dp[i+1][j+k] = max(dp[i+1][j+k], dp[i][j] + V[i][k]);
      }
    }
  }

  double ans = 0;
  for(int i = 0; i <= N; ++i){
    for(int j = 0; j <= M; ++j){
      ans = max(ans, dp[i][j]);
    }
  }
  printf("%.8f\n", ans);
}

Measured memory_bytes: 1880