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

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mi64 = ModInt<>;



signed main(){
    i64 h, w;
    cin >> h >> w;
    if((h + w) % 3){
        cout << 0 << endl;
        return 0;
    }
auto mpow = [](auto x, i64 y){
    auto z = x;
    decltype(x) val = y & 1 ? x : decltype(x)(1);
    while(z *= z, y >>= 1)
        if(y & 1)
            val *= z;
    return val;
};


auto calc_fact = [mpow]{
    constexpr i64 N = 2e6;
    vector<mi64> fact(N + 1, 1);
    vector<mi64> inv(N + 1, 1);
    for(i64 i = 1; i < N; ++i){
        fact[i + 1] = fact[i] * (i + 1);
        inv[i + 1] = mpow(fact[i + 1], MOD - 2);
    }
    return make_pair(fact, inv);
};
vector<mi64> fact, inv;
tie(fact, inv) = calc_fact();
auto ncr = [&fact, &inv](i64 n, i64 r){
    if(n < 0 || r < 0 || n < r)
        return mi64(0);
    return fact[n] * inv[r] * inv[n - r];
};

    i64 cnt = (h + w) / 3;
    i64 h_must = h - cnt;
    cout << ncr(cnt, h_must) << endl;
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>


using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

class BSnakeToy {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int N,K,L[100009];
    int ans = 0;
    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> L[i];
    sort(L, L+N, greater<int>());
    for(int i = 0; i < K; i++) ans += L[i];
    cout << ans << endl;
}
};


int main() {
	BSnakeToy solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 998244353
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
map<ll,ll> m;
void solve()
{
	ll k,a,b;
	cin>>k>>a>>b;
	ll x=a/k;
	ll y=b/k;
	if(x==y)
	{
		if((a%k!=0)&&(b%k)!=0)
			cout<<"NG";
		else
			cout<<"OK";
		return;
	}
	cout<<"OK";

}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
}

Measured memory_bytes: 3640
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int taro=0,hanako=0;
		String tcard,hcard;
		for(int i=0;i<n;i++){
			tcard=scan.next();
			hcard=scan.next();
			if(tcard.compareTo(hcard)<0){
				hanako+=3;
			}else if(0<tcard.compareTo(hcard)){
				taro+=3;
			}else{
				hanako+=1;
				taro+=1;
			}
		}
		System.out.printf("%d %d\n",taro,hanako);
		scan.close();
	}
}

Measured memory_bytes: 21032
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <utility>
using namespace std;

template<typename T> void fastin(T &num) {
  bool negative = false;
  T c;
  num = 0;
  c = getchar_unlocked();
  if (c == '-') {
    negative = true;
    c = getchar_unlocked();
  }
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
  if (negative) num *= -1;
}

struct task{
  int year, id;
};

int main(){
  int n, m; fastin(n); fastin(m);
  vector<task> v[101010];
  for (int i = 0; i < m; ++i) {
    int p, y; fastin(p); fastin(y);
    v[p].push_back({y, i + 1});
  }

  vector<int> ans1(m + 1), ans2(m + 1);

  for (int i = 1; i <= n; ++i) {
    if (v[i].empty()) continue;
    sort(v[i].begin(), v[i].end(), [](const task &x, const task &y){
      return x.year < y.year;
    });
  }

  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < (int)v[i].size(); ++j) {
      ans1[v[i][j].id] = i;
      ans2[v[i][j].id] = j + 1;
    }
  }

  for (int i = 1; i <= m; ++i) {
    cout << setfill('0') << right << setw(6) << ans1[i] << setfill('0') << right << setw(6) << ans2[i] << '\n';
  }

  return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

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

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    vector<int> a(n);
    for(int in=0;in<n;in++) {
        cin >> a.at(in); a.at(in)--;
    }

    int ans = 0, now = 0;
    
    for(int in=0;in<n;in++) {
        ans++;
        if(a.at(now)==1) {
            cout << ans << endl;
            return 0;
        }
        now = a.at(now);
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3772
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

double R;

signed main(){
	cin>>R;
	R=R*2*acos(-1);
	setdouble(10,R);cout<<endl;
	return 0;
}


Measured memory_bytes: 3780
//088B
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    int n, tmp;
    int alice=0, bob=0;
    cin >> n;
    vector<int>cards;
    cards.resize(n);
    rep(i, n){
        cin >> tmp;
        cards[i] = -tmp;
    } 
    sort(cards.begin(), cards.end());
    rep(i, n){
        if (i %2==0) alice-=cards[i];
        if (i %2==1) bob-= cards[i];
    }
    cout << alice-bob << endl;
}

Measured memory_bytes: 256
main = do
  mapM_ putStrLn aux

aux :: [String]
aux = map mulStr [(i,j)|i<-[1..9],j<-[1..9]]
      where
        mulStr::(Int,Int) -> String
        mulStr (i,j) = (show i)++"x"++(show j)++"=" ++ (show (i*j))

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

int ans;
string s;
int main(){
   cin >> s;
   if(((s[0]==s[1])&&(s[1]==s[2]))||((s[1]==s[2])&&(s[2]==s[3]))){
     cout << "Yes" << endl;
   }
   else{
    cout << "No" << endl;
   } 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    cin >> a;
    string s;
    cin >> s;
    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
}


Measured memory_bytes: 256
import collections
n = int(input())
moji = []
for i in range(n):
    moji.append(input())
ans = dict(collections.Counter(moji))
mx = max(ans.values())
ans = sorted(ans.items(),key=lambda x:x[0])
mx = [kv[0] for kv in ans if kv[1]==mx]
for i in mx:
    print(i)

Measured memory_bytes: 120272
#include <stdio.h>

main(){
  int n,r,p,c,i,j,a[50],b[50];
  while(1){
    scanf("%d%d",&n,&r);
    if(n==0&&r==0) break;
    for(i=0;i<n;i++) a[n-i-1]=i+1;
    for(i=0;i<r;i++){
      scanf("%d%d",&p,&c);
      for(j=0;j<c;j++) b[j]=a[p+j-1];
      for(j=p+c-2;j>=c;j--) a[j]=a[j-c];
      for(j=0;j<c;j++) a[j]=b[j]; 

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

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			boolean[][] e = new boolean[n][n+1];
			for(int i=0;i<n;i++){
				int m = sc.nextInt();
				while(m--!=0)e[i][sc.nextInt()]=true;
			}
			boolean[] f = new boolean[n+1];
			int K = sc.nextInt();
			while(K--!=0)f[sc.nextInt()]=true;
			List<Integer> l = new ArrayList<Integer>();
			for(int i=0;i<n;i++){
				boolean ok = true;
				for(int j=1;j<=n;j++)if(f[j]&&!e[i][j])ok=false;
				if(ok)l.add(i+1);
			}
			System.out.println(l.isEmpty()||l.size()>1?-1:l.get(0));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
use proconio::input;
use proconio::marker::{Chars, Usize1, Isize1};
use std::iter::Iterator;
use std::collections::HashSet;
use std::cmp::*;
use itertools::Itertools;
use superslice::Ext2 as _;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    mut a: [Isize1],
    }

    a.invert_permutation();

    println!("{}", a.iter().map(|a| a + 1).format(" "));
}


Measured memory_bytes: 3196
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;

int r,c;
char str[22][22];
string str2[22];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool visited[22][22][4][17];

bool dfs(int x,int y,int d,int m){
	if(visited[x][y][d][m])return false;
	visited[x][y][d][m]=true;
	//printf("%d %d %d %d\n",x,y,d,m);
	if(str[x][y]=='@')return true;
	if(str[x][y]=='>')d=0;
	if(str[x][y]=='<')d=2;
	if(str[x][y]=='^')d=3;
	if(str[x][y]=='v')d=1;
	if(str[x][y]=='_'){
		if(m==0)d=0;
		if(m!=0)d=2;
	}
	if(str[x][y]=='|'){
		if(m==0)d=1;
		if(m!=0)d=3;
	}
	if(str[x][y]>='0' && str[x][y]<='9')m=str[x][y]-'0';
	if(str[x][y]=='+')m=(m+1)%16;
	if(str[x][y]=='-')m=(m+15)%16;
	if(str[x][y]=='?'){
		bool ch=false;
		for(int i=0;i<4;i++){
			if(dfs((x+dx[i]+c)%c,(y+dy[i]+r)%r,i,m))ch=true;
		}
		return ch;
	}else{
		return dfs((x+dx[d]+c)%c,(y+dy[d]+r)%r,d,m);
	}
}

int main(void){
	scanf("%d %d",&r,&c);
	for(int i=0;i<r;i++){
		cin >> str2[i];
	}
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			str[j][i]=str2[i][j];
		}
	}
	memset(visited,false,sizeof(visited));
	printf("%s\n",dfs(0,0,0,0)?"YES":"NO");
	return 0;
}

Measured memory_bytes: 2456
#include <bits/stdc++.h>
     
    using namespace std;
     
    int main(void)
    {
      int N, Q;
     
      scanf("%d %d", &N, &Q);

      int K = N+Q;
      if(K%2 == 1){
          cout << "IMPOSSIBLE"<<endl;
      }
      else{
          cout << K/2<<endl;
      }

      return 0;
    }

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

using namespace std;
typedef long long ll;
typedef vector<ll> vi;

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

	int X, Y;
	cin >> X >> Y;
	if((Y&1) == 0 && 2*X <= Y && Y <= 4*X) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

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


#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long
#define ALL(a) a.begin(),a.end()
#define vi vector<int>

using namespace std;

double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

clock_t first_attempt = clock();
inline void cek_time(){
	clock_t cur = clock()- first_attempt;
	cerr<<"TIME : "<<(double) cur/CLOCKS_PER_SEC<<endl;
}
inline void OPEN (string s) {
	freopen ((s + ".in").c_str (), "r", stdin);
	freopen ((s + ".out").c_str (), "w", stdout);
}

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> bbst;
//find_by_order(idx) : i-th index 
//order_of_key(val)  : val has which index

//end of template

int n, m;
int main() {
	cin >> n >> m;
	
	ll ans = 0;
	rep(b, m + 1, n + 1) {
		ll cur = (ll) (b - m) * (n / b);
		ll rem = 0;
		if (n % b >= m) rem = (n % b) - m + 1;
		ans += cur + rem;
	}
	
	if (!m) ans = (ll) n * n;
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

//First Experience
public class Main{
	
	void run(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			char[] s = sc.next().toCharArray();
			int r1 = 0, r2 = 0;
			char r3 = ' ';
			boolean f = true;
			for(int i=0;i<s.length;i++){
				if(Character.isDigit(s[i]))r2=r2*10+s[i]-'0';
				else {
					if(r3==' ')r1=r2;
					else if(r3=='+')r1+=r2;
					else if(r3=='-')r1-=r2;
					else r1*=r2;
					r2 = 0;
					r3 = s[i];
				}
				if(r1<0||r2<0||10000<=r1||10000<=r2){
					f = false; break;
				}
			}
			System.out.println(f?r1:"E");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

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

    int M, K;
    cin >> M >> K;
    if (M <= 1) {
        if (K == 0) {
            for (int i = M; i >= 0; --i) cout << i << " ";
            for (int i = 0; i <= M; ++i) cout << i << " \n"[i == M];
            return 0;
        }
        cout << "-1" << endl;
        return 0;
    }
    if (K >= (1LL << M)) {
        cout << "-1" << endl;
        return 0;
    }
    for (int i = (1LL << M) - 1; i >= 0; --i) {
        if (i == K) continue;
        cout << i << " ";
    }
    cout << K << " ";
    for (int i = 0; i <= (1LL << M) - 1; ++i) {
        if (i == K) continue;
        cout << i << " ";
    }
    cout << K << endl;
}

Measured memory_bytes: 1792
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-3
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
int Scan() {
    int res=0, flag=0;
    char ch;
    if((ch=getchar())=='-') flag=1;
    else if(ch>='0'&&ch<='9') res=ch-'0';
    while((ch=getchar())>='0'&&ch<='9')  res=res*10+(ch-'0');
    return flag?-res:res;
}
void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
const int N=100005;
//Code begin...

VI a[N];
int size[N];

bool comp(const int &a, const int &b){return size[a]>size[b];}
void dfs(int x)
{
    int siz=a[x].size();
    size[x]=0;
    size[x]=max(size[x],siz);
    for (int i=0; i<siz; ++i) dfs(a[x][i]);
    sort(a[x].begin(),a[x].end(),comp);
    for (int i=0; i<siz; ++i) size[x]=max(size[x],size[a[x][i]]+i+1);
}
int main ()
{
    int n, x;
    scanf("%d",&n);
    FOR(i,2,n) scanf("%d",&x), a[x].pb(i);
    dfs(1);
    printf("%d\n",size[1]);
    return 0;
}


Measured memory_bytes: 15488
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
vector<int> A;
vector<int> B;
//=============================
void input()
{
    cin>>N>>M;
}
//=============================
void func(){}
//=============================
void solve()
{
    cout<<max({N+M,N-M,N*M})<<endl;
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    
    int N, K; cin >> N >> K;
    vi cnt(26, 0);
    rep(i,N) {
        string P; cin >> P;
        cnt[P[0] - 'A']++;
    }

    sort(rall(cnt));
    int ans = 0;
    while(true) {
        rep(i,K) {
            cnt[i]--;
            if(cnt[i] < 0) {
                cout << ans << endl;
                return 0;
            }
        }
        ans++;
        sort(rall(cnt));
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef int64_t lint;

int main(){
    lint n;
    cin >> n;
    vector<lint> p(n);
    vector<lint> s(n);
    rep0(i, n)
    {
        cin >> p[i];
        s[i] = p[i];
    }
    sort(all(s));
    lint d = 0;
    rep0(i,n)
    {
        if(p[i] != s[i])
        {
            d ++;
        }
    }
    cout << ((d<=2)?"YES":"NO") << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {

		// 入力
		Scanner sc = new Scanner(System.in);
		long n = Long.parseLong(sc.next()); // サイコロの面数
		long goal = Long.parseLong(sc.next()); // 目標点数

		double result = 0;
		for (int i = 1; i <= n; i++) {

			// iは、何度「2倍」するとgoalに届くか？
			int kaisuu = 0;
			int score = i;
			while (score < goal) {
				kaisuu++;
				score *= 2;
			}

			// i点からゴールできる確率をresultに足す
			result += 1.0 / Math.pow(2, kaisuu);

		}

		System.out.println(result / (n + 0.0));

	}
}

Measured memory_bytes: 35668
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef pair<ll,ll> l_l;
const ll INF = 10000000100;
int main(){
    ll N,M;
    cin >> N >> M;
    vector<l_l> G[N+1];
    for(int i=0; i<M; i++){
        int a,b,c; cin >> a >> b >> c;
        G[a].push_back(l_l(b,c));
        G[b].push_back(l_l(a,-c));
    }
    vector<ll> x(N+1,INF);
    for(int i=1; i<=N; i++){
        if(x[i]==INF){
            x[i]=0;
            queue<l_l> q;
            q.push(l_l(x[i],i));
            while(!q.empty()){
                l_l now=q.front();q.pop();
                ll nowpos=now.second;
                ll nowdist=now.first;
                for(auto Next: G[nowpos]){
                    ll newpos=Next.first;
                    if(x[newpos]==INF){
                        x[newpos]=nowdist+Next.second;
                        q.push(l_l(x[newpos],newpos));
                    }
                    else{
                        if(x[newpos]!=nowdist+Next.second){
                            cout << "No" << endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 14448
n = int(input())
x = list(map(int,input().split()))

y = max(x)
sub = y
res = 0
for i in range(n):
    if abs(float(y/2-x[i])) < sub and x[i] != y:
        sub = abs(float(y/2-x[i]))
        res = x[i]

print(y,res)


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

int main() {
	int N;
	cin >> N;
	int c_min;
	cin >> c_min;
	int count = 1;
	for (int i = 1; i < N; i++) {
		int P;
		cin >> P;
		if (c_min > P) {
			count++;
			c_min = P;
		}
	}
	cout << count << endl;
}


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

int main(){
	int age;
	
	cin >> age;
	
	if(age==1){
		cout << "Hello World" << endl;
	}
	if(age==2){
		int a,b;
		
		cin >> a >> b;
		cout << a+b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <iostream>
#include <queue>
#include <set>
#define ll long long
#define sf(a) scanf("%lld",&a)
#define pf(b) printf("%lld",b)
#define sp printf(" ")
#define nw printf("\n")
#define mp make_pair
#define pi pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define fast ios_base::sync_with_stdio(false)
using namespace std;

int main()
{
   string a;
   cin>>a;
   ll sum=0;
   for(auto e:a)
   	sum+=(e-'0');
   if(sum%9) cout<<"No";
   else cout<<"Yes";
}


Measured memory_bytes: 3368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;
const int MOD = 1'000'000'007;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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

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

int main()
{
    int h, w, m;
    cin >> h >> w >> m;
    set<P> st;
    vector<P> row(h), line(w);
    // indexを付与
    for (int i = 0; i < h; i++)
    {
        row[i].second = i;
    }
    for (int i = 0; i < w; i++)
    {
        line[i].second = i;
    }
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        st.insert(make_pair(a, b));
        ++row[a].first;
        ++line[b].first;
    }
    sort(row.begin(), row.end());
    reverse(row.begin(), row.end());
    sort(line.begin(), line.end());
    reverse(line.begin(), line.end());
    int row_maxi = row[0].first;
    int line_maxi = line[0].first;
    int maxi = 0;
    for (auto r : row)
    {
        if (r.first != row_maxi)
        {
            break;
        }
        for (auto l : line)
        {
            if (l.first != line_maxi)
            {
                break;
            }
            if (st.count(make_pair(r.second, l.second)))
            {
                maxi = max(maxi, r.first + l.first - 1);
            }
            else
            {
                maxi = max(maxi, r.first + l.first);
                cout << maxi << endl;
                return 0;
            }
        }
    }
    cout << maxi << endl;
    return 0;
}


Measured memory_bytes: 21976
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    int N,K; cin>>N>>K;
    vector<int> A(N+1,0);
    for(int i=0;i<N;i++){
        int a; cin>>a;
        A[a]++;
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    int count=0;
    int ans=0;
    for(int i=0;i<=N;i++){
        if(count<K){
            count++;
        }
        else{
            ans+=A[i];
        }
    }
    cout<<ans;
    return 0;
}

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

#define ll long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

#define Debug(x) cout<<(#x)<<" >> "<<(x)<<endl

using namespace std;

ll fastpow(ll angka,ll pangkat,ll MOD){
	ll res=1;
	while(pangkat){
		if(pangkat&1) res=(res*angka)%MOD;
		angka=(angka*angka)%MOD;
		pangkat=pangkat>>1;
	}
	return res;
}

ll fastpow(ll angka,ll pangkat){
	ll res=1;
	while(pangkat){
		if(pangkat&1) res=(res*angka);
		angka=(angka*angka);
		pangkat=pangkat>>1;
	}
	return res;
}

ll gcd(ll angka1,ll angka2){
	while(angka2){
		swap(angka1,angka2);
		angka2=angka2%angka1;
	}
	return angka1;
}

ll lcm(ll angka1,ll angka2){
	return (angka1/gcd(angka1,angka2))*angka2;
}

const ll mod=1e9+7;

ll dist(pll a,pll b){
	return abs(a.fi-b.fi)+abs(a.se-b.se);
}

/*
_________a.fi > b.fi && a.se > b.se

dist = a.fi - b.fi + a.se - b.se
dist = (a.fi+a.se) - (b.fi+b.se)


_________a.fi >b.fi && a.se < b.se

dist = a.fi - b.fi - a.se + b.se
dist = (a.fi - a.se) - (b.fi-b.se)

*/

void solve(){
	
	int n;
	cin>>n;
	
	vector<pll>v(n);
	for(int i=0;i<n;i++) cin>>v[i].fi>>v[i].se;
	
	pll p1=v[0],p2=v[0],p3=v[0],p4=v[0];
	
	for(int i=0;i<n;i++){
		if(v[i].fi + v[i].se > p1.fi + p1.se) p1=v[i];
		if(v[i].fi + v[i].se < p2.fi + p2.se) p2=v[i];
		
		if(v[i].fi - v[i].se > p3.fi - p3.se) p3=v[i];
		if(v[i].fi - v[i].se < p4.fi - p4.se) p4=v[i];
	}
	
	cout<<max({dist(p1,p2),dist(p3,p4)})<<endl;
	
}

int main(){
	
	fastio();

//	freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

	int t=1;
//	cin>>t;
	
	for(int tt=0;tt<t;tt++){
//		cout<<"Case "<<tt+1<<":\n";solve();
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 6360
def main():
    inf = 1 << 60
    n = int(input())
    v = list(map(int, input().split()))

    a = [{}, {}]
    for i,vi in enumerate(v):
        ai = i % 2
        if vi in a[ai].keys():
            a[ai][vi] += 1
        else:
            a[ai][vi] = 1

    b = []
    for i in range(0, 2):
        lst = sorted(list(a[i].items()), key=lambda e:e[1], reverse=True)
        b.append(lst)
        #print(lst)

    if b[0][0][0] != b[1][0][0]:
        return n - b[0][0][1] - b[1][0][1]
    b1 = -inf
    b2 = -inf
    if len(b[1]) >= 2:
        b1 = n - b[0][0][1] - b[1][1][1]
    if len(b[0]) >= 2:
        b2 = n - b[0][1][1] - b[1][0][1]
    if b1 > b2:
        if b2 >= 0:
            return b2
    else:
        if b1 >= 0:
            return b1
    if b[0][0][1] > b[1][0][1]:
        return n - b[0][0][1]
    else:
        return n - b[1][0][1]

ans = main()
print(ans)


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


int main() 
{
    double a, b, x;
    cin >> a >> b >> x;
    if(x<=a*a*b/2)
    {
        double ans = atan(a * b * b / 2.0 / x);
        ans = ans * (180.0 / 3.14159265359);
        printf("%.7lf\n", ans);
    }
    else
    {
        double ans = atan(2.0*b/a-(2.0*x/a/a/a));
        ans = ans * (180.0 / 3.14159265359);
        printf("%.7lf\n", ans);
    }


    return 0;
}



Measured memory_bytes: 384
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        n: usize,
        s: Chars,
    }

    if n % 2 == 0 && s[..n/2] == s[n/2..] {
        println!("Yes");
    } else {
        println!("No");
    }
    

    println!("", );
}


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

int main()
{
    int N;
    cin >> N;
    vector<pair<string, int>> list;
    for(int i = 0; i < N; ++i) {
        string stmp;
        cin >> stmp;
        bool flg = true;
        for(size_t j = 0; j < list.size(); ++j) {
            if(list[j].first == stmp) {
                ++list[j].second; flg = false; break;
            }
        }
        if(flg) list.push_back(make_pair(stmp, 1));
    }

    int M;
    cin >> M;
    for(int i = 0; i < M; ++i) {
        string stmp;
        cin >> stmp;
        for(size_t j = 0; j < list.size(); ++j) {
            if(list[j].first == stmp) {
                --list[j].second; break;
            }
        }
    }

    int ans = 0;
    for(size_t i = 0; i < list.size(); ++i) {
        ans = max(ans, list[i].second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
number = [int(x) for x in input().split()]
#S
#1 -> 2
#2 -> 6
#3 -> 3
#4 -> 4
#5 -> 1
#6 -> 5
order = input()

for i in range(len(order)):
    number_2 = [number[i] for i in range(len(number))]
    if order[i] == 'S':
        number[0] = number_2[4]
        number[1] = number_2[0]
        number[4] = number_2[5]
        number[5] = number_2[1]
    if order[i] == 'W':
        number[0] = number_2[2]
        number[2] = number_2[5]
        number[3] = number_2[0]
        number[5] = number_2[3]
    if order[i] == 'E':
        number[0] = number_2[3]
        number[2] = number_2[0]
        number[3] = number_2[5]
        number[5] = number_2[2]
    if order[i] == 'N':
        number[0] = number_2[1]
        number[1] = number_2[5]
        number[4] = number_2[0]
        number[5] = number_2[4]
    #print(number)

print(number[0])

Measured memory_bytes: 7740
# +2019までを調べれば十分

l, r = map(int, input().split())
ans = 10**9

for i in range(l, min(r+1, l+2020)):
  for j in range(i,  min(r+1, l+2020)):
    if i < j:
      ans = min(ans, (i * j)%2019)

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
int main (void){
    int a,b;
    scanf("%d",&a);
    scanf("%d",&b);
    int q[1000];
    int sum=0,w=0;
    for(int i=0;i<a;i++){
        scanf("%d",&q[i]);
        sum+=q[i];
        if(sum<=b){
            w++;
        }
    }
    w++;
    printf("%d",w);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var A = input[1];
            var B = input[2];
            var max = Math.Min(A, B);
            var min = A + B - N;
            if (min < 0) min = 0;

            Console.WriteLine(max + " " + min);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,f,n) for(int i=f; i<(n); i++)
int main()
{
  int n, q;
  cin >> n >> q;
  vector<int> ki[n];
  int ki_p[n] = {0};
  REP(i,0,n-1){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    ki[a].push_back(b);
    ki[b].push_back(a);
  }

  REP(i,0,q){
    int a, b;
    cin >> a >> b;
    a--;
    ki_p[a] += b;
  }

  queue<pair<int,int>> aa;
  aa.push({0,-1});
  while(aa.size()>0){
    int i = aa.front().first;
    for(int j:ki[i]){
      if(aa.front().second == j)continue;
      ki_p[j] += ki_p[i];
      aa.push({j,i});
    }
    aa.pop();
  }
  
  REP(i,0,n){
    cout << ki_p[i] << " ";
  }
  cout << endl;

  //--debug : end_stoper
  //string end_stoper; cin >> end_stoper;

  return 0;
}

Measured memory_bytes: 17420
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	int a=-1, z;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A'&&a==-1) {
			a = i;
		}
		if (s[i] == 'Z') {
			z = i;
		}
	}
	cout << z - a + 1 << endl;
	return 0;
}


Measured memory_bytes: 720
#include<iostream>
using namespace std;
int main()
{
	int n,r=0,b=0;
	string s;
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='R')r++;
		else b++;
	}
	if(r>b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn for(i=0;i<n;i++)
#define car cin>>h[i]
const int maxn=100001;
int h[maxn];
int dp[maxn];
int main()
{
     int n;
     cin>>n;
     int res;
     int i;
     forn car;
     dp[0]=0;
     dp[1]=abs(h[0]-h[1]);
     for( i=2;i<n;i++)
     {
         dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2] + abs(h[i] - h[i-2]));
     }
     cout<<dp[n-1]<<endl;
     return 0;
     
     
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int N; cin >> N;
  vector<vector<int>> F(N, vector<int>(10));
  for (int i = 0; i < N; i++) for (int j = 0; j < 10; j++) cin >> F[i][j];
  vector<vector<int>> P(N, vector<int>(10 + 1));
  for (int i = 0; i < N; i++) for (int j = 0; j <= 10; j++) cin >> P[i][j];

  int ans = -1000000000;
  for (int b = 1; b < 1 << 10; b++) {
    int sum2 = 0;
    for (int i = 0; i < N; i++) {
      int sum = 0;
      for (int j = 0; j < 10; j++) if (b & 1 << j && F[i][j]) sum++;
      sum2 += P[i][sum];
    }
    ans = max(sum2, ans);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
/*Shivam Bhalla */
/* f2016941@pilani.bits-pilani.ac.in */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iostream>
#include <string>
#include <cmath>
#include <cassert>
#include <bits/stdc++.h>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
long long maxv = 1e9;


int main(){
	string str;
	cin>>str;
	int case1=0; //start with 1;
	int case2=0; //start with 2;
	for(int i=0;i<str.length();i++){
		if(i%2==0){
			if(str[i]!='1')
				case1++;
		}
		else{
			if(str[i]!='0')
				case1++;
		}
	}
	for(int i=0;i<str.length();i++){
		if(i%2==0){
			if(str[i]!='0')
				case2++;
		}
		else{
			if(str[i]!='1')
				case2++;
		}
	}
	cout<<min(case1,case2);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <list>
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;

int main() {
    int n;
    cin >> n;
    double ans;
    int tmp = n;
    if (tmp % 2) ++tmp;
    tmp /= 2;
    // cout << tmp << "/" << n;
    ans = (double)tmp / (double)n;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#define MOD_TYPE 1

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

#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using Int = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;

/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9 + 10;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr istream &operator>>(istream &is, pair<T, U> &p) noexcept
{
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

void solve()
{
  int n, m;
  cin >> n >> m;
  vector<int> E[600];
  rep(i, m)
  {
    int s, t;
    cin >> s >> t;
    s--, t--;
    E[s].push_back(t);
  }

  double ans = LINF;
  rep(block, n)
  {
    double dp[610];
    dp[n - 1] = 0.0;
    for (int i = n - 2; i >= 0; i--)
    {
      double sum = 0.0, Max = 0.0, num = E[i].size();
      for (auto to : E[i])
      {
        sum += dp[to];
        chmax(Max, dp[to]);
      }
      if (i == block and E[i].size() >= 2)
      {
        num--;
        sum -= Max;
      }
      dp[i] = sum / num + 1.0;
    }
    chmin(ans, dp[0]);
  }
  cout << ans << "\n";
}

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

Measured memory_bytes: 4784
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N, M;
  cin>>N>>M;
  vector<vector<Int> > G(N);
  for(Int i=0;i<M;i++){
    Int u, v;
    cin>>u>>v; u--, v--;
    G[u].push_back(v);
    //G[v].push_back(u);
  }

  Int S, T;
  cin>>S>>T; S--, T--;

  vector<vector<Int> > D(N, vector<Int>(3, INF));
  D[S][0] = 0;
  queue<P> Q({P(S, 0)});
  while(!Q.empty()){
    Int pos, t; tie(pos, t) = Q.front(); Q.pop();
    Int cost = D[pos][t];
    if(pos == T && t == 0){
      cout<<cost/3<<endl;
      return 0;
    }
    for(Int to:G[pos]){
      Int nt = (t + 1)%3;
      Int ncost = cost + 1;
      if(D[to][nt] <= ncost) continue;
      D[to][nt] = ncost;
      Q.emplace(to, nt);
    }
  }

  cout<<-1<<endl;

  return 0;
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define hell  1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb   push_back


int main()
{
	ios;
	ll a,b,h,m;
	cin>>a>>b>>h>>m;
	double ang=abs(((360.0/(12*60))*(h*60+m))-(6*m));
	if(ang==0)cout<<abs(a-b);
	else if(ang==180)cout<<abs(a+b);
	else
	{
		// ang=ang%180;
		if(ang>180)ang=180-(ang-180);
		printf("%.15lf",sqrt((a*a)+(b*b)-2*a*b*cos(ang*(3.14159265358979/180))));
	}
}

Measured memory_bytes: 4184
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;


int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   pair<string,ll> arr[n];
   rep(n)
       cin>>arr[i].ff>>arr[i].ss;
   
   ll tot = 0;
   rep(n)
        tot+=arr[i].ss;
   string x;
   cin>>x;
   
   rep(n)
   {
       tot-=arr[i].ss;
       if(arr[i].ff == x)
            break;
   }
   
   cout<<tot;
   
   return 0;        
}  
   

Measured memory_bytes: 764
class Main {
	public static void main(String[] args) {
      	java.util.Scanner input = new java.util.Scanner(System.in);
      	String S = input.nextLine();
      	String T = input.nextLine();
    	 new Main().solve(S, T);
    }
  	private void solve(String s, String t) {
      if(s.length() >= t.length())
        System.out.print("No");
    	 if(s.equals(t.substring(0, s.length())))
          System.out.print("Yes");
        else
          System.out.print("No");
    }
}

Measured memory_bytes: 35672
#include <stdio.h>

int
main(int argc, char *argv[])
{
  long N, K;
  scanf("%ld%ld", &N, &K);
  
  if(K % 2 == 1){
    long ans0 = (N / K) * (N / K) * (N / K);
    printf("%ld\n", ans0);
  }
  else{
    long a, b;
    a = K / 2; b = N / a;
    if(b % 2 == 0){
      long ans1 = 2 * (N / K) * (N / K) * (N / K);
      printf("%ld\n", ans1);
    }
    else{
      long ans2 = (N/K +1) * (N/K + 1) * (N/K + 1) + (N/K) * (N/K) * (N/K);
      printf("%ld\n", ans2);
    }
  }
  
  return 0;
}


Measured memory_bytes: 128