akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;


struct P3{
  double x,y,z;
};
struct data{
  P3 p,v;
  double r,vr;
};

data D[222];

const double EPS = 1E-9;

double twi(double a){ return a*a; }

double check(P3 a,P3 va,double ra,double vra,P3 b, P3 vb,double rb,double vrb, double t){
  //  cout << sqrt( twi(a.x + va.x * t - b.x - vb.x * t ) +
  //            twi(a.y + va.y * t - b.y - vb.y * t ) +
  //             twi(a.z + va.z * t - b.z - vb.z * t ) ) - (ra - vra * t) - (rb - vrb * t) << endl;
  return sqrt( twi(a.x + va.x * t - b.x - vb.x * t ) +
               twi(a.y + va.y * t - b.y - vb.y * t ) +
               twi(a.z + va.z * t - b.z - vb.z * t ) ) - (ra - vra * t) - (rb - vrb * t);
}

struct event{
  double t;
  int p1,p2;
  event(){ p2 = -1; }
  bool operator<(const event e) const {
    return t < e.t;
  }
  event(double t,int p1){
    this->t = t; this->p1 = p1;
    p2 = -1;
  }
  event(double t,int p1,int p2) : t(t),p1(p1),p2(p2) {}
};

int main(){
  int n;
  while( cin >> n && n ){
    double F[222];
    fill(F,F+n,-1.0);
    vector<event> del;
    del.clear();
    for(int i=0;i<n;i++){
      double px,py,pz,vx,vy,vz,r,vr;
      cin >> px >> py >> pz >> vx >> vy >> vz >> r >> vr;
      D[i]=(data){(P3){px,py,pz},(P3){vx,vy,vz},r,vr};
      del.push_back( event( r/vr , i ) );
    }
    
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        
        double st = 0, ed = min( del[i].t, del[j].t );
        while( ed - st  > EPS ){
          //cout << st << " - " << ed << endl;
          double t1 = (ed-st)/3.0 + st;
          double t2 = (ed-st)/3.0*2.0 + st;
          double h1 = check(D[i].p,D[i].v,D[i].r,D[i].vr,D[j].p,D[j].v,D[j].r,D[j].vr,t1);
          double h2 = check(D[i].p,D[i].v,D[i].r,D[i].vr,D[j].p,D[j].v,D[j].r,D[j].vr,t2);
          //          cout << "(t1,t2) " << t1 << " " << t2 << " h1 = " << h1 << " h2 = " << h2 << endl;
          if( h1 < h2 ){
            ed = t2;
          } else {
            st = t1;
          }
        }
        if( check(D[i].p,D[i].v,D[i].r,D[i].vr,D[j].p,D[j].v,D[j].r,D[j].vr,ed) > EPS ) continue;
        st = 0.0;
        while( ed - st > EPS ){
          double t = (st+ed)/2.0;
          double h = check(D[i].p,D[i].v,D[i].r,D[i].vr,D[j].p,D[j].v,D[j].r,D[j].vr,t);
          //          cout << st << " - " <<ed << " t = " << t << " h = " << h << endl;
          if( h < EPS ) 
            ed = t;
          else
            st = t;
        }
        
        del.push_back( event(ed,i,j) );      
      }
    }

    sort(del.begin(),del.end());
    for(int i=0;i<del.size();i++){
      //cout << del[i].t << " "<< del[i].p1 << " "<< del[i].p2 << endl;
      if( del[i].p2 == -1 ){
        if( F[del[i].p1] < -EPS ) F[del[i].p1] = del[i].t;
      } else {
        if( F[del[i].p1] < -EPS && F[del[i].p2] < -EPS ) {
          F[del[i].p1] = del[i].t;
          F[del[i].p2] = del[i].t;
        }
      }
    }
    for(int i=0;i<n;i++){
      printf("%.10lf\n",F[i]);
    }
      
  }  
}

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

int main() {
  int n;
  cin >> n;
  vector<int> cnt(n, 0);
  rep(i, n) {
    if (i == 0) continue;
    int a;
    cin >> a;
    a--;
    cnt.at(a)++;
  }

  rep(i, n) cout << cnt.at(i) << endl;
}


Measured memory_bytes: 4052
import java.util.Scanner;

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

        int A = sc.nextInt();
        int B = sc.nextInt();

        System.out.println(solve(A, B) ? "Yay!" : ":(");

        sc.close();
    }

    static boolean solve(int A, int B) {
        return A <= 8 && B <= 8;
    }
}

Measured memory_bytes: 21844
// atcoder.cpp.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<stdio.h>
#include<string.h>
#include <math.h>
#include<stdlib.h>
#include<time.h>
#include<random>
using namespace std;
//std::random_device rnd;

//グロ変




int main()
{
	int a, b;
	cin >> a >> b;
	cout << a * b;


	return 0;

}




Measured memory_bytes: 3196
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
    "sort"
)

func main(){
    
    N := nextInt()
    _ = nextInt()
    S := nextStrings(N)
 
	sort.Strings(S)
 
	for _, x := range S {
        fmt.Print(x)
	}
    fmt.Print("\n")
 
 }
 
/* templates */
 
func Max(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r < a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Min(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r > a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Sum(a []int) (r int) {
    for i := range a {
        r += a[i]
    }
    return r
}
 
func Abs(a float64) float64 {
    if a < 0 {
        return -a
    }
    return a
}
 
type Pair struct {
    a, b int
}
 
type Pairs []Pair
 
func (p Pairs) Len() int {
    return len(p)
}
 
func (p Pairs) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}
 
func (p Pairs) Less(i, j int) bool {
    return p[i].b < p[j].b
}
 
var nextReader func() string
 
func init() {
    nextReader = NewScanner()
}
 
func NewScanner() func() string {
    r := bufio.NewScanner(os.Stdin)
    r.Buffer(make([]byte, 1024), int(1e+11))
    r.Split(bufio.ScanWords)
    return func() string {
        r.Scan()
        return r.Text()
    }
}

func nextString() string {
    return nextReader()
}
 
func nextInt64() int64 {
    v, _ := strconv.ParseInt(nextReader(), 10, 64)
    return v
}
 
func nextInt() int {
    v, _ := strconv.Atoi(nextReader())
    return v
}
 
func nextInts(n int) []int {
    r := make([]int, n)
    for i := 0; i < n; i++ {
        r[i] = nextInt()
    }
    return r
}

func nextStrings(n int) []string {
    r := make([]string, n)
    for i := 0; i < n; i++ {
        r[i] = nextString()
    }
    return r
}

func nextFloat64() float64 {
    f, _ := strconv.ParseFloat(nextReader(), 64)
    return f
}

Measured memory_bytes: 640
#include<stdio.h>

int n, q;
int A[20];
int m[200];

int solve(int, int);

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

    scanf("%d", &q);
   
    for(int i=0; i<q; i++){
        scanf("%d", &m[i]);
    }

    for(int i=0; i<q; i++){

    
        if(solve(0,m[i])){
            printf("yes\n");
        }
        else{
            printf("no\n");
        }
    }
    
}

int solve(i,m){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}


Measured memory_bytes: 2144
from sys import stdin
import math
N,M = [int(x) for x in stdin.readline().rstrip().split()]
mod = 10**9+7
nm = abs(N-M)
if nm == 0:
    ans = math.factorial(N)**2*2
    ans %= mod
    print(ans)
elif nm == 1:
    ans = math.factorial(N)*math.factorial(M)
    ans %= mod
    print(ans)
else:
    print(0)

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;

signed main() {
    ll N;
    cin>>N;
    vector<ll> p(N+1);
    rep(i,1,N+1){
        cin>>p[i];
    }
    vector<ll> v;
    ll k = 0;
    rep(i,1,N+1){
        if (p[i] == i){
            k++;
        }else{
            if (k>0){
                v.push_back(k);
            }
            k=0;
        }
    }
    if (k>0){
        v.push_back(k);
    }
    ll ans = 0;
    for (auto e: v){
        if (e == 1)
            ans++;
        else if (e%2==0)
            ans+=e/2;
        else
            ans+=e/2 + 1;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  str a, b, c; cin >> a >> b >> c;
  ll A = 0, B = 0, C = 0;
  char flag = 'a';
  for(ll i = 0;;i++)
  {
    if(flag == 'a')
    {
      flag = a[A];
      A++;
    }
    if(flag == 'b')
    {
      flag = b[B];
      B++;
    }
    if(flag == 'c')
    {
      flag = c[C];
      C++;
    }
    if(a.size() + 1 == A) {fin('A')return;}
    if(b.size() + 1 == B) {fin('B')return;}
    if(c.size() + 1 == C) {fin('C')return;}
  } 
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


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

int main() {
  int N;
  int s=0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    s += r-l+1;
  }
  cout << s << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from bisect import bisect
from operator import itemgetter
def inpl(): return list(map(int, input().split()))
g0 = itemgetter(0)

N = int(input())
ans = 0
R = sorted([inpl() + [i] for i in range(N)])
B = sorted([inpl() + [i] for i in range(N)])

edges = []

for i, r in enumerate(R):    
    B2 = sorted([(b[1], b[2]) for b in B[bisect(list(map(g0, B)), r[0]):]])
    edges.append([b[1] for b in B2[bisect(list(map(g0, B2)), r[1]):]])

searched = [False for _ in range(N)]
matched = [-1 for _ in range(N)]

def dfs(v):
    for u in edges[v]:
        if searched[u]:
            continue
        searched[u] = True
        if matched[u] == -1:
            matched[u] = v
            return True
        elif dfs(matched[u]):
            matched[u] = v
            return True
    return False

for i in range(N):
    searched = [False]*N
    ans += dfs(i)

print(ans)

Measured memory_bytes: 3188
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;

struct Edge{int to,from,cost;};

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define mp make_pair
#define PUTLINE cout<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

class Pos{
public:
	int x,y,z;
	bool operator==(const Pos &pos)const{
		return x==pos.x&&y==pos.y&&z==pos.z;
	}
	bool operator<(const Pos &pos)const{
		if(x<pos.x)return true;
		else if(x>pos.x)return false;
		if(y<pos.y)return true;
		else if(y>pos.y)return false;
		if(z<pos.z)return true;
		else return false;
	}
	bool operator>(const Pos &pos)const{
		if(x>pos.x)return true;
		else if(x<pos.x)return false;
		if(y>pos.y)return true;
		else if(y<pos.y)return false;
		if(z>pos.z)return true;
		else return false;
	}
};

set<Pos> pos;

int main() {
	int n,h;
	for(;;){
		cin>>n>>h;
		if(n==0&&h==0)break;
		string str;
		int a,b;
		int res=0;
		pos.clear();
		rep(i,h){
			cin>>str>>a>>b;
			a--;b--;
			Pos p;
			if(str=="xy"){
				rep(c,n){
					p.x=a;
					p.y=b;
					p.z=c;
					if(pos.find(p)==pos.end()){
						pos.insert(p);
						++res;
					}
				}
			}
			if(str=="xz"){
				rep(c,n){
					p.x=a;
					p.y=c;
					p.z=b;
					if(pos.find(p)==pos.end()){
						pos.insert(p);
						++res;
					}
				}
			}
			if(str=="yz"){
				rep(c,n){
					p.x=c;
					p.y=a;
					p.z=b;
					if(pos.find(p)==pos.end()){
						pos.insert(p);
						++res;
					}
				}
			}
		}
		cout<<n*n*n-pos.size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
N=int(input())
A=[int(i) for i in input().split()]
A.sort()
miss=0

if N%2==0:
    for i in range(int(N/2)):    
        if miss==1:
            break
        for j in range(2):
            if A[0]==2*i+1:
                A.pop(0)
            else:
                miss=1
                break
                
    if miss==1:
        print(0)
    else:
        print(int((2**int(N/2))%(10**9+7)))

else:
    if A[0]!=0:
        miss=1
        A.pop(0)
    else:
        A.pop(0)
    for i in range(int((N-1)/2)):
        if miss==1:
            break
        for j in range(2):
            if A[0]==2*i+2:
                A.pop(0)
            else:
                miss=1
                break
                
    if miss==1:
        print(0)
    else:
        print(int((2**int((N-1)/2))%(10**9+7)))



Measured memory_bytes: 13880
import java.util.Scanner;

public class Main {
	public static void main(String[] arg) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		System.out.print(aCheck(s)&&cCheck(s)&&sCheck(s)?"AC":"WA");
	}
	private static boolean aCheck(String str){
		return str.matches("^A.*");
	}
	
	private static boolean cCheck(String str){
		return str.matches("^.{2}.*C.*.{1}$");
	}
	
	private static boolean sCheck(String str){
		return str.matches("^.[a-z]*C[a-z]*$");
	}
}


Measured memory_bytes: 23252
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

vector<int> pos[26];

int main()
{
    string s, t;
    cin >> s >> t;

    for (int i = 0; i < s.size(); i++)
    {
        int c = s[i] - 'a';
        pos[c].push_back(i);
    }

    uint64_t len = 1;
    int lastPos = 0;
    for (int i = 0; i < t.size(); i++)
    {
        int c = t[i] - 'a';
        if (pos[c].empty())
        {
            cout << -1 << endl;
            return 0;
        }
        if (i == 0)
        {
            len += pos[c][0];
            lastPos = pos[c][0];
        }
        else
        {
            auto p = upper_bound(pos[c].begin(), pos[c].end(), lastPos);
            if (p == pos[c].end())
            {
                len += s.size() - lastPos + pos[c][0];
                lastPos = pos[c][0];
            }
            else
            {
                len += *p - lastPos;
                lastPos = *p;
            }
        }
    }

    cout << len << endl;

    return 0;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,A,B=MI()
    v=LI()
    v.sort(reverse =True)
    a=0#確定分
    b=0#選ぶ選択肢の個数
    L=[]#個数のリスト
    cnt=1
    temp=v[0]
    for i in range(1,N):
        if v[i]!=temp:
            L.append(cnt)
            cnt=1
            temp=v[i]
        else:
            cnt+=1
            
            
    L.append(cnt)
        
    cnt2=0    
    for i in range(len(L)):
        a=cnt2
        cnt2+=L[i]
        if cnt2>A:
            b=L[i]
            break
    temp1=0
    if a!=0:
        temp1=sum(v[:a])/a
    ans1=sum(v[:A])/A
    if a==A:
        b=0
      
    
    def cmb(n, r):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        temp=1
        for i in range(r):
            temp*=(n-i)
            
        for i in range(r):
            temp=temp//(i+1)
            
        return temp
        
        
    ans2=0
    if temp1>ans1:
        ans2=cmb(b,A-a)
    else:
        for i in range(A-a,B-a+1):
            ans2+=cmb(b,i)
        
    print(ans1)
    print(ans2)

main()


Measured memory_bytes: 38384
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

long long mul(long long a, long long b, long long m) {
    if (b == 0) return 0;
    long long res = mul(mod(a + a, m), b>>1, m);
    if (b & 1) res = mod(res + a, m);
    return res;
}

long long pow(long long a, long long n, long long m) {
    if (n == 0) return 1 % m;
    long long t = pow(a, n/2, m);
    t = mul(t, t, m);
    if (n & 1) t = mul(t, a, m);
    return t;
}

bool is_prime(long long n) {
    if (n == 2) return true;
    if (!(n & 1) || n <= 1) return false;
    int a[] = {2, 3, 5, 7, 11, 13, 17, -1};
    long long s = 0, d = n-1;
    while (!(d & 1)) { ++s; d = d>>1; }
    for (int i = 0; a[i] != -1 && a[i] < n; ++i) {
        long long x = pow(a[i], d, n);
        int t;
        if (x != 1) {
            for (t = 0; t < s; ++t) {
                if (x == n-1) break;
                x = mul(x, x, n);
            }
            if (t == s) return false;
        }
    }
    return true;
}

int N;
long long num;

int main() {
    while (cin >> N) {
        int res = 0;
        for (int i = 0; i < N; ++i) {
            cin >> num;
            num = num*2+1;
            if (is_prime(num)) ++res;
        }
         
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 1172
#define _USE_MATH_DEFINES
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n
x1 y1
..
xn yn

M PI
 */
int n;
long double x[100],y[100],theta[100];

int main(){
  cin>>n;

  if(n==2){
    REP(i,2){
      cout<<0.5<<endl;
    }
    return 0;
  }
    
  
  REP(i,n){
    cin>>x[i]>>y[i];
  }

  REP(i,n){
    long double t[100],dt[100];

    REP(j,n){
      if(j==i) continue;
      int j1 = j<i ? j : j-1;
      
      if(x[j]-x[i]==0.0){
        t[j1] = y[j]-y[i] > 0 ? M_PI/2 : -M_PI/2;
      } else {
        t[j1] = atan((y[j]-y[i])/(x[j]-x[i]));
        if(x[j]-x[i]<0) t[j1] = t[j1] + M_PI;
        if(t[j1] > M_PI) t[j1] -= 2 * M_PI;
      }
      LOG("t[%d]=%Lf\n",j1,t[j1]);
    }
    sort(t, t+n-1);
    
    REP(j,n-2){
      dt[j] = t[j+1] - t[j];
      LOG("dt[%d]=%Lf\n", j, dt[j]);
    }
    dt[n-2] = 2*M_PI - (t[n-2] - t[0]);      
    LOG("dt[%d]=%Lf\n", n-2, dt[n-2]);


    sort(dt,dt+n,greater<long double>());

    long double x = dt[0] - M_PI;

    if(x <= 0){
      cout<<0<<endl;
    } else {
      cout<< x/(2*M_PI) <<endl;
    }
    
  }



  return 0;
}


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

public class Main {


    private  static void solver(InputReader sc, PrintWriter out) throws Exception {
        long n = sc.nextLong();
        long sqrt = (long) Math.sqrt(n);
        long x=0,y=0;
        for(long i=sqrt;i>=1;i--){
            if(n%i==0){
               x  =i;
               y = (long) n/i;
                break;
            }
        }
        long ans =0;
        if(x!=0 && y!=0)
             ans = (x-1)+(y-1);
        else
            ans = n-1;
        out.println(ans);
    }
    private  static long gcd(long a, long b){
        if(b==0)
            return a;
        else
            return gcd(b,a%b);
    }

    public static void main(String[] args) throws Exception{
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong(){
            return Long.parseLong(next());
        }

        public long[] readLongArr(int n){
            long arr[] = new long[n];
            for(int i=0; i<n; i++){
                arr[i] = nextLong();
            }
            return arr;
        }
        public int[] readIntArr(int n){
            int arr[] = new int[n];
            for(int i=0; i<n; i++){
                arr[i] = nextInt();
            }
            return arr;
        }
    }
}
class Pair implements Comparable<Pair>{
    int x;
    String s;
    Pair(int x, String s){
        this.x = x;
        this.s = s;
    }
    public int compareTo(Pair p){
        return this.x-p.x;
    }
}

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

int main()
{
  int m[100][100];
  int n, u, k, i, j;
  int v[100];
  int a;
  cin >> n;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      m[i][j] = 0;
  for (i = 0; i < n; i++) {
    cin >> u >> k;
    for (j = 0; j < k; j++) {
      cin >> a;
      m[u-1][a-1] = 1;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (j == 0)
	cout << m[i][j];
      else
	cout << ' ' << m[i][j];
    }
    cout << endl;
  }
}



Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main(void)
{
    int H,W;
    cin>> H >> W;
    char s[H][W],m[H][W];
    for (int i=0;i<H; ++i){
        for (int j=0; j<W; ++j){
             cin>>s[i][j];
        }
    }
    for (int i=0; i<H; ++i){
        for (int j=0; j<W; ++j){

            if (s[i][j]=='.'){
                int count = 0;
                for (int k = i-1; k<=i+1; ++k){
                    for (int l = j-1; l<=j+1; ++l){
                            if (s[k][l]=='#' && 0 <= k && k < H && 0 <= l && l < W) count += 1;
                    }
               }
                cout << count;
            }

            else cout << '#';
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
string a,b;

int main(){
	cin >> a >> b;
	int n=stoi(a+b);
	
	int c=0;
	while(c*c<n){
		c++;
		if(c*c==n){cout << "Yes" << endl; return 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)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001001;
const int NMAX=8;
const int MOD=1000000007;
const int dbase=80*160;

int main()
{
	ll n;
	cin>>n;
	if (n%2==1) {
		cout<<0;
		return 0;
	}
	ll cnt=0;
	ll now=5;
	bool check=true;
	n/=2;
	while (check){
		ll temp=n/now;
		if (temp<1){
			check=false;break;

		}
		cnt+=temp;
		now*=5;

	}
	cout<<cnt;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						(int)2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
/* 最大公約数 */
ll gcd(ll a, ll b) 
{
	if (b == 0) return a;
	return gcd(b, a % b);
}

/* 最小公倍数 */
ll lcm(ll a, ll b) 
{
	ll gcdRes = gcd(a, b);
	return (a * (b / gcdRes));
}

int main()
{
	ll A, B;
	cin >> A >> B;
	cout << lcm(A, B) << endl;

	return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};



int main(){
  
  int a,b,t;
  cin >> a >> b >> t;
  int res = 0;
  for(int i = 1;i*a <= t;i++){
    res += b;
  }
  cout << res << endl;


  
  


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-10;

int main() {
	ll n;
	cin >> n;
	int c = 0;
	ll x = 100;
	while (x < n) {
		c++;
		x += x / 100;
	}
	cout << c << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){

    long long n, k, a, b;
    set<long long> smp;
    map<long long, long long> mmp;

    cin >> n >> k;
    for(int i=0; i < n; i++){
        cin >> a >> b;
        if(smp.find(a) != smp.end()){
            mmp[a] += b;
        }else {
            smp.insert(a);
            mmp[a] = b;
        }
    }

    vector<long long> vmp(smp.begin(), smp.end());
    sort(vmp.begin(), vmp.end());

    for(int i=0; i<n; i++){
        k -= mmp[vmp[i]];
        if(k <= 0){
            cout << vmp[i] << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 7680
n,m = map(int,input().split())
a = [False]*n
b = [0]*n
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'AC':
        a[p-1] = True
    if s == 'WA' and a[p-1] == False:
        b[p-1] += 1
correct = a.count(True)
penalty = 0
for i in range(len(a)):
    if a[i] == True:
        penalty += b[i]
print(correct, penalty)


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

int main(){
        int prime[999999];
        bool is_prime[1000000];
        int p =0;
        int n ;
        int i;
        while(cin >> n){
        for(i=0;i<=n;i++) is_prime[i] = true;
        is_prime[0] = is_prime[1] = false;
        for(i=2;i<=n;i++){
                if(is_prime[i]){
                        prime[p++] = i;
                        for(int j=2*i;j<=n;j+=i) is_prime[j] = false;
                }
        }
        cout << p << endl;
        p = 0;
        }
return 0;
}

Measured memory_bytes: 2132
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if(A >= 13)System.out.println(B);
		else System.out.println((A >= 6)? B/2 : 0);
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  int k[32];
  cin >> n;
  k[0]=1;
k[1]=1;
k[2]=1;
k[3]=2;
k[4]=1;
k[5]=2;
k[6]=1;
k[7]=5;
k[8]=2;
k[9]=2;
k[10]=1;
k[11]=5;
k[12]=1;
k[13]=2;
k[14]=1;
k[15]=14;
k[16]=1;
k[17]=5;
k[18]=1;
k[19]=5;
k[20]=2;
k[21]=2;
k[22]=1;
k[23]=15;
k[24]=2;
k[25]=2;
k[26]=5;
k[27]=4;
k[28]=1;
k[29]=4;
k[30]=1;
k[31]=51;
  cout << k[n-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n;
	while(cin >> n,n){
		int a[100];
		for (int i = 0; i < n; ++i) cin >> a[i];
		sort(a,a+n);
		int sum = 0;
		for (int k = 1; k < n-1; ++k){
			// cout << a[k] << " ";
			sum += a[k];
		}
		// cout << n << endl;
		cout << sum/(n-2) << endl;	
	}
	return 0;
}

Measured memory_bytes: 1180
/*                  ___
               :                
               ;                
              :                 
              ;                 
             /                  
           o/                   
         ._/\___,                
             \                  
             /                   
             `      
	bug
*/
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

using namespace std;
#define PI 3.14159265359
#define eps 1e-8
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define REP(i,n) FOR(i,0,n)
typedef long long int ll;
const int INF = 1<<29;
typedef long long ll;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

double tick() { 
	static clock_t oldticks;
	clock_t newticks = clock();
	double diff = 1.0 * (newticks - oldticks) / CLOCKS_PER_SEC; 
	oldticks = newticks;
	return diff;
}

inline int toInt(string s){
	return atoi(s.c_str());
}

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

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

inline bool isPrime(int n){
	ll j;
	j=sqrt(n);

	if(n<2)
		return 0;
	for(int i=2;i<=j;i++){
		if(n%i==0)
			return false;
	}
	return true;
}

int n,m;

int main(){
	ios_base::sync_with_stdio(false); //Fast I/O
	cin.tie(NULL);
	//freopen("in.txt","r",stdin);
	//freopen("output.txt","w",stdout);	

	cin >> n >> m;

	if(n%m)
		cout << 1 << endl;
	else
		cout << 0 << endl;		

    //cerr << tick();

	return 0;
	
}


Measured memory_bytes: 256
#include <stdio.h>
int main() { 
const int MAX_V=10000;
int prime[MAX_V+1];
	int i,k,v,n,p1,q1; 
	for(i=2;i<=MAX_V;i++) { 
		prime[i]=1;
	} 
	for(i=2;i*i<=MAX_V;i++) { 
		if(prime[i]) { 
			for(k=2*i;k<=MAX_V;k+=i) { 
				prime[k]=0;
			} 
		}
	} 
	while(1) { 
		scanf("%d",&n);
		if(n==0)break;
		for(i=2;i<=n;i++){
			if(prime[i-2] && prime[i]){
				p1=i-2;
				q1=i;
			}
		}
		printf("%d %d\n",p1,q1);
	} 
	return 0; 
}

Measured memory_bytes: 1740
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int n;
           cin>>n;
           int f=55555;
// エラトステネスのふるい
    bitset<1000010> is_prime(0); // 十分大きなサイズを確保 (ふるいの容量は1000010)
    for (int i = 2; i <= f; ++i) is_prime.set(i); // とりあえず全部ふるいに入れ( 000000000..001111111111111111...111111100)
    for (int i = 2; i <= f; ++i) {
        if (is_prime[i]) { // 素数 i を発見したら
            for (int j = i * 2; j <= f; j += i) {
                is_prime.reset(j); // i の倍数をふるい落とす
            }
        }
    }
           int cnt=0;
     rep(i,2,f){
       if(is_prime[i]&&i%5==1){
         cout<<i<<" ";
         cnt++;
         if(cnt==n){
           //cout<<cnt<<endl;
           break;
         }
       }
       
     }
          }

Measured memory_bytes: 3692
// problem: "https://atcoder.jp/contests/abc142/tasks/abc142_c"

#include<bits/stdc++.h>

using namespace std;

bool func(pair<int,int>p1,pair<int,int>p2)
{
    return p2.second > p1.second;
}

int main()
{
    int N,i;

    cin>>N;

    vector<pair<int,int>>V;

    for(i=0;i!=N;i++)
    {
        int x;
        cin>>x;

        V.push_back(pair<int,int>(i,x));
    }

    sort(V.begin(),V.end(),func);

    for(i=0;i!=N;i++)
        cout<<V[i].first+1<<' ';

    return 0;
}


Measured memory_bytes: 1780
//Tanzim bin nasir
#include<bits/stdc++.h>
typedef long long ll;
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    else
    gcd(b,a%b);
}
ll lcd(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
int main()
{
    int n,m;
    cin>>n>>m;
    if(m==n)
    cout<<"Yes\n";
    else
    cout<<"No\n";
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define LL long long
#define endl '\n'
using namespace std;

#define MAX 10000
#define INFTY (1 << 29)

// クラスカルのアルゴリズム
// 1. 辺を重みの昇順に整列する
// 2. 最小全域木の辺の集合をKとしてそれを空に初期化する
// 3. |最小全域木| = |頂点| - 1となるまでK or 辺が閉路を作らないような辺をKに追加する

class DisjointSet {
public:
    // rankは木の高さ(この数)，pは親
    vector<int> rank, p;

    DisjointSet() {}
    DisjointSet(int size)
    {
        // ベクターrankとpの大きさをsizeとして，足りない要素は0で補う
        rank.resize(size, 0);
        p.resize(size, 0);
        // すべての値を初期化する
        for (int i = 0; i < size; i++) {
            makeSet(i);
        }
    }

    void makeSet(int x)
    {
        // x番目の要素の親を自分自身にする
        // 木の高さ(子の数)も0で初期化する
        p[x] = x;
        rank[x] = 0;
    }

    bool same(int x, int y)
    {
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y)
    {
        link(findSet(x), findSet(y));
    }

    void link(int x, int y)
    {
        // 木の高さが高い方に木の高さが小さい方の親の親を設定する
        if (rank[x] > rank[y]) {
            // xの方が高いときはyの代表の親をxにする
            p[y] = x;
        } else {
            // それ以外はyをxの代表の親にする
            p[x] = y;
            if (rank[x] == rank[y]) {
                // 高さが同じ時は高さを一つ高くする
                rank[y]++;
            }
        }
    }

    int findSet(int x)
    {
        if (x != p[x]) { // xが代表でない(xの親がxでない)時
            p[x] = findSet(p[x]); // xの親の親が代表か調べる(これを再帰)
        }
        return p[x];  // xの属する集団の代表を返す
    }
};

class Edge {
    public:
    int source, target, cost;
    Edge(int source = 0, int target = 0, int cost = 0):
    source(source), target(target), cost(cost) {}
    bool operator < (const Edge &e) const {
        return cost < e.cost;
    }
};

int kruskal (int N, vector<Edge> edges) {
    int totalCost = 0;
    sort(edges.begin(), edges.end()); // 辺を整列する

    DisjointSet dset = DisjointSet(N + 1); // UFを作る

    for (int i = 0; i < N; i++) {
        dset.makeSet(i);
    }

    int source, target;
    for (int i = 0; i  < edges.size(); i++) {
        Edge e = edges[i];
        if (!dset.same(e.source, e.target)) { // sourceとtargetの親が同じでなければ
            // MST.push_back(e);
            totalCost += e.cost;
            dset.unite(e.source, e.target);
        }
    }
    return totalCost;
}

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

    int N, M, cost;
    int source, target;

    cin >> N >> M;

    vector<Edge> edges;
    for (int i = 0; i < M; i++) {
        cin >> source >> target >> cost;
        edges.push_back(Edge(source, target, cost));
    }

    cout << kruskal(N, edges) << endl;
    return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n;
void solve(){
	cin >> n;
	
	cout << n+n*n+n*n*n << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3648
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();

        if (s.Length == 2)
        {
            if (s[0] == s[1])
            {
                Console.WriteLine("1 2");
            }
            else
            {
                Console.WriteLine("-1 -1");
            }

            return;
        }

        for (int i = 0; i < s.Length - 2; i++)
        {
            if (s[i] == s[i + 1] ||
                s[i + 1] == s[i + 2] ||
                s[i + 2] == s[i])
            {
                Console.WriteLine($"{i + 1} {i + 3}");
                return;
            }
        }

        Console.WriteLine("-1 -1");
    }
}


Measured memory_bytes: 13280
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

int main(){
    stack<int> s;
    int n;
    scanf("%d", &n);
    s.push(n);
    char t[10];
    while(scanf("%s", t) != EOF){       
        if(t[0] == '+'){
            int f = s.top();
            s.pop();
            int p = s.top();
            s.pop();
            s.push(p+f);
        }else if(t[0] == '-'){
            int f = s.top();
            s.pop();
            int p = s.top();
            s.pop();
            s.push(p-f);
        }else if(t[0] == '*'){
            int f = s.top();
            s.pop();
            int p = s.top();
            s.pop();
            s.push(p*f);
        }else{
            s.push(atoi(t));
        }
    }
    cout << s.top() << '\n';
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(ll i=p;i<n;i++)
#define fr1(i,p,n) for(ll i=p;i>=n;i--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(15) << std::fixed;
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(0);
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n],b[n];
        fr(i,0,n) cin>>a[i]>>b[i];
        sort(a,a+n);
        sort(b,b+n);
        if(n%2!=0)
        {
            int x=a[n/2];
            int y=b[n/2];
            int ans=y-x+1;
            cout<<ans<<endl;
        }
        else
        {
            int x=a[n/2]+a[(n-1)/2];
            int y=b[n/2]+b[(n-1)/2];
            int ans=y-x+1;
            cout<<ans<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5152
n = int(input())
list = list(map(int, input().split()))
b = -1
cont = True

while cont:
  b += 1
  for i in range(n):
    if(list[i] % 2 == 0):
      list[i] = list[i] / 2
    else:
      cont = False
     
print(b)
      

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n, m; cin >> n >> m;
	vector<vector<int>> edg(n), eid(n);
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v;
		u--; v--;
		edg[u].push_back(v);
		eid[u].push_back(i);
	}
	double ans = 1e18;
	vector<double> dp(n);
	for (int i = -1; i < n; i++) {
		for (int j = 0; j < n; j++) dp[j] = 0.;
		for (int j = n - 2; j >= 0; j--) {
			int c = edg[j].size();
			double ma = 0.;
			for (int t = 0; t < c; t++) {
				dp[j] += dp[edg[j][t]];
				if (edg[j][t] != n - 1) {
					ma = max(ma, dp[edg[j][t]]);
				}
			}
			if (j == i && c > 1) {
				dp[j] -= ma;
				dp[j] /= (c - 1);
			}
			else {
				dp[j] /= c;
			}
			dp[j]++;
		}
		ans = min(ans, dp[0]);
	}
	printf("%.15f\n", ans);
	return 0;
}


Measured memory_bytes: 2432
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int cases = sc.nextInt();
    sc.nextLine();
    
    int[] data = new int[4];
    final int AC = 0;
    final int WA = 1;
    final int TLE = 2;
    final int RE = 3;

    for (int i = 0; i < cases; i++) {
      String answer = sc.nextLine();
      switch (answer) {
      case "AC":
        data[AC]++;
        break;
      case "WA":
        data[WA]++;
        break;
      case "TLE":
        data[TLE]++;
        break;
      case "RE":
        data[RE]++;
        break;
      default:
        break;
      }
    }

    System.out.println("AC x "+data[AC]);
    System.out.println("WA x "+data[WA]);
    System.out.println("TLE x "+data[TLE]);
    System.out.println("RE x "+data[RE]);
    
  }
}

Measured memory_bytes: 61068
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

n,m=map(int,input().split())
u=[list(map(int,input().split())) for i in range(m)]
s,t=map(int,input().split())
dic=[[] for i in range(n+1)]
for i in range(m):
    a,b=u[i]
    dic[a].append(b)
# print(dic)
itta=[[0]*3 for i in range(n+1)]
d=deque([[s,0]])
itta[s][0]=1
itta[t][0]=2
while d:
    tmp=d.popleft()
    
    # print(tmp)

    p,cnt=tmp
    for i in dic[p]:
        if itta[i][(cnt+1)%3]==1:
            continue
        elif itta[i][(cnt+1)%3]==2:
            print((cnt+1)//3)
            quit()
        else:
            itta[i][(cnt+1)%3]=1
            d.append([i,cnt+1])
    # print(itta)
print(-1)

Measured memory_bytes: 108760
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

constexpr int INF = 1<<30;

int n, m;
int c[20];
int dp[25][50010];

int main()
{
  scanf( "%d%d", &n, &m );
  rep( i, m )
    scanf( "%d", c+i );

  std::fill( (int*)dp, (int*)(dp+m+1), INF );
  dp[0][0] = 0;

  rep( i, m ) rep( j, n+1 )
  {
    if( j-c[i] >= 0 )
      dp[i+1][j] = std::min( dp[i+1][j], dp[i+1][j-c[i]]+1 );
    
    dp[i+1][j] = std::min( dp[i+1][j], dp[i][j] );
    //rep( k, j/c[i]+1 )
      //dp[i+1][j+c[i]*k] = std::min( dp[i+1][j+c[i]*k], dp[i][j]+k );
  }

  printf( "%d\n", dp[m][n] );
  
  return 0;
}


Measured memory_bytes: 6788
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
signed main(){
  ll n,a,ans;
  cin >> n;
  ans = n;
  vector<ll> v = divisor(n);
  for(auto i:v){
    ans = min(ans,i-1+(n/i)-1);
  }
  cout << ans << endl;
}


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

/** Problem0044 : Prime Number II **/
#define MAX 51000
int main()
{
	bool prime[MAX];
	int  input;
	
	for (int i=0; i<MAX; i++)
		prime[i] = true;
	
	prime[0] = false; prime[1] = false;
	
	for (int i=2; i<MAX; i++) {
		if (prime[i]) {
			for (int j=2; i*j<MAX; j++) {
				prime[i*j] = false;
			}
		}
	}
	
	while (cin >> input) {
		for (int i=input-1; i>1; i--) {
			if (prime[i]) {
				cout << i << " ";
				break;
			}
		}
		
		for (int i=input+1; i<51000; i++) {
			if (prime[i]) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

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

#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define print_upto(a,n)        for(int i=0;i<n;i++)    cout<<a[i]<<" "; cout<<endl
#define take(x,n)           for(int i=0;i<n;i++)  cin>>x[i];

#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"

#define ll long long
#define ff first
#define ss second
#define null NULL
#define all(c) (c).begin(),(c).end()
#define nl "\n"

#define ld long double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define mod 1000000007

typedef vector<ll> vl;
typedef vector< vl > vvl;
typedef pair< ll, ll> pll;
typedef map< ll, ll> mll;


int main() {

	// Use ctrl+shift+b ( second option )
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt" , "w" , stderr);
#endif

	ll x;
	cin>>x;

	if(x==1)
		cout<<"0"<<nl;	
	else
		cout<<"1"<<nl;


	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define lol long long
template<class A,class B>inline bool chmax(A &a,const B &b){return(b>a&&(a=b,true));}
template<class A,class B>inline bool chmin(A &a,const B &b){return(b<a&&(a=b,true));}
using namespace std;
lol mod=1e9+7;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin >>n>>m;
  vector<int> cost(m),key(m,0);
  for(int i=0;i<m;i++){
    int a,b;
    cin >>a>>b;
    cost[i]=a;
    while(b--){
      int c;cin >>c;
      key[i]|=(1<<(c-1));
    }
  }
  vector<lol> dp(1<<n,mod);
  dp[0]=0;
  for(int i=0;i<m;i++){
    for(int bit=0;bit<(1<<n);bit++){
      chmin(dp[bit|key[i]],dp[bit]+cost[i]);
    }
  }
  if(dp[(1<<n)-1]==mod) cout <<"-1\n";
  else cout <<dp[(1<<(n))-1]<<'\n';
  return (0);
}

Measured memory_bytes: 3680
from math import atan2, pi
a, b, x = map(int, input().split())
t = b - x / a / a
if 2 * t <= b:
    print(atan2(2 * t, a) * 180 / pi)
else:
    t = x / b / a
    print(atan2(b, 2 * t) * 180 / pi)


Measured memory_bytes: 38384