akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ff first
#define ss second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define forn(i, n) for (int i = 0; i < n; i++)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;



int32_t main()
{
    fast

   int test=1;
    //cin>>test;
  
   

  while(test--)
  {
    
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.size();i++)sum+=(s[i]-'0');

        if(sum%9==0)cout<<"Yes";
    else cout<<"No";

// while ending
   }
  

return 0;
}

Measured memory_bytes: 3768
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)1e5
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){fast;
	ll i,n,j,f=0;string s;cin>>n>>s;
	for(i=1;i<n-1;i++){
		vi a(90,0);
		for(j=0;j<i;j++){
			if(s[j]-s[i]) a[s[j]]++;
		}for(j=i+1;j<n;j++){
			if(s[j]-s[i]){
				f+=a['R'+'G'+'B'-s[j]-s[i]];
				if(s[2*i-j]=='R'+'G'+'B'-s[j]-s[i]) f--;
			}
		}
	}cout<<f<<endl;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  s[k-1]-=('A'-'a');
  cout << s << endl;
}  


Measured memory_bytes: 256
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

string s;
signed main(){
    int cnt = 1;
    cin >> s;
    sort(all(s));
    char now = s[0];
    int n = s.size();
    if(n == 1){ 
        cout << "No\n";
        return 0;
    }   
    reps(i,n-1){
        if(now != s[i]){
            if(cnt % 2 != 0){ 
                cout << "No\n";
                return 0;
            }
            else{
                cnt = 1;
                now = s[i];
            }
        }
        else ++cnt;
    }   
    cout << "Yes\n";
    return 0;
}


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

int main() {
	int q;
	std::cin >> q;

	for (int i = 0; i < q; ++i) {
		int c, a, n;
		std::cin >> c >> a >> n;
		int step = 1;
		int count = 0;
		while (step != 4) {
			switch (step) {
			case 1:
				if (c > 0 && n > 0 && a > 0)
					--c, --a, --n, ++count;
				else
					++step;
				break;
			case 2:
				if (c >= 2 && a > 0)
					c -= 2, --a, ++count;
				else
					++step;
				break;
			case 3:
				if (c >= 3)
					c -= 3, ++count;
				else
					++step;
				break;
			}
		}

		std::cout << count << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;

int main(){

    int A,B;
    cin >> A >> B;
    if(A%2 == 0 or B%2 == 0){
        puts("No");
    }else{
        puts("Yes");
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int n;
long long dp[3005][3005];
long long prefix[3005][3005]={};
long long md = 1e9 + 7;
int main(){
	cin >> n >> s;
	for(int i = 0; i <= 3000; i++)
		for(int j = 0; j <= 3000; j++)
			dp[i][j] = 0;
	dp[n][0] = 1;
	prefix[n][0] = 1;
	for(int i = n-1; i >= 1; i--){
		for(int atas = n-1; atas >= 0; atas--){
			int bawah = n-i-atas;
			if(bawah < 0)dp[i][atas] = 0;
			else{
				if(s[i-1] == '<'){
					dp[i][atas] = (prefix[i+1][0] - prefix[i+1][atas] + md)%md;
				}else{
					dp[i][atas] = (prefix[i+1][atas] - prefix[i+1][atas + bawah] + md)%md;
				}
				prefix[i][atas] = (prefix[i][atas+1] + dp[i][atas])%md;
			}
		}
	}
	long long ans = 0;
	for(int i = 0; i < n; i++){
		ans += dp[1][i];
		ans %= md;
	}
	cout << ans;
}

Measured memory_bytes: 141184
#pragma GCC optimize(2)
#include <cstdio>
#include <cstring>
using namespace std;

char a[1100];
int e,w,n,s;

int main()
{
	scanf("%s",a+1);
	int l=strlen(a+1);
	for(int i=1;i<=l;i++) {
		if(a[i]=='E') e=1;
		if(a[i]=='W') w=1;
		if(a[i]=='N') n=1;
		if(a[i]=='S') s=1;
	}
	if(e==w&&n==s) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
ab = [0] * n
for i in range(n):
    a,b = inpl()
    ab[i] = (a+b,a,b)
ab.sort(reverse=True)
# print(ab)
x = 0
y = 0
for i,j in enumerate(ab):
    if i%2:
        y += j[2]
    else:
        x += j[1]
print(x-y)


Measured memory_bytes: 54732
n = gets.chomp
d = gets.chomp.split(" ").map(&:to_i);

m = gets.chomp
t = gets.chomp.split(" ").map(&:to_i);

d.sort!
t.sort!

idx = 0
t.each do |i|
	while true do
		if d[idx] > i then
			puts "NO"
			exit
		elsif d[idx] == i then
			idx += 1
			break
		elsif d[idx] < i then
			idx += 1
		elsif idx == d.size then
			puts "NO"
			exit
		end
	end

end

puts "YES"


Measured memory_bytes: 34448
n,k=map(int,input().split())
A=list(map(int,input().split()))
C=[0]
V=[0]*n
V[0]=1
now=0
for i in range(n):
    now=A[now]-1
    if V[now]==1:
        break
    else:
        V[now]=1
        C.append(now)
loop=C.index(now)
L=len(C)-loop
if k>loop:
    print(C[(k-loop)%L+loop]+1)
else:
    print(C[k]+1)

Measured memory_bytes: 32380
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;

/*----------macros----------*/

//input, output================
#define fastio                          \
std::ios::sync_with_stdio(false);       \
std::cin.tie(nullptr);                  \
std::cout.tie(nullptr)

#define endl '\n'
#define fcout(a)                        \
cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef vector<int>     Vi;
typedef vector<ll>      Vl;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF    = (ll)1e9 + 1;
constexpr ll INFll  = (ll)1e18 + 1;
constexpr ll MOD1   = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define psb push_back
#define epb emplace_back
#define psf push_front
#define mkp make_pair
#define fst first
#define snd second

//others================
#define sz(x)                           \
(int) x.size()

#define all(x)                          \
(x).begin(), (x).end()

#define rall(x)                         \
(x).rbegin(), (x).rend()

#define rep(i, n)                       \
for(int i = 0; (i) < (n); ++(i))

#define reps(i, n)                      \
for(int i = 1; (i) <= (n); ++(i))

#define rrep(i, n)                      \
for(int i = n - 1; (i) >= 0 ; --(i))

#define repbit(bit, n)                  \
for(int bit = 0; (bit) < (1 << (n)); ++(bit))

#define ifbit(bit, i)                   \
if((bit) & (1 << (i)))

#define CtoI(c)                         \
int((c)) - int('0')

#define ItoC(c)                         \
char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b)
{ return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b)
{ return a > b && (a = b, true); }

// Vi  dx = {1, 0, -1, 0},
//     dy = {0, 1, 0, -1};

// Vi  dx2 = { 1,1,0,-1,-1,-1,0,1 },
//     dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
fastio;

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

return 0;
}

Measured memory_bytes: 3620
# frozen_string_literal: true

n, m = gets.split.map(&:to_i)
addresses = m.times.map { gets.split.map(&:to_i) }

grouped = addresses.group_by {|address| address[0] }.each_with_object({}) {|(pref, v), h|
  h[pref] = v.map {|pair| pair[1] }.sort.each_with_object({}).with_index(1) {|(year, h), i|
    h[year] = i
  }
}

addresses.each {|address|
  city_num = grouped[address[0]][address[1]]
  puts "#{format('%06d', address[0])}#{format('%06d', city_num)}"
}

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

int main(){
    int n, c, k;
    cin >> n >> c >> k;

    vector<int> t(n);
    for(int i = 0; i < n; i++) cin >> t[i];

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

    int ans = 0, time = 0, p = 0;
    for(int i = 0; i < n; i++){
        if(time < t[i] || p >= c){
            time = t[i] + k;
            p = 0;
            ans++;
        }
        p++;
    }

    cout << ans << endl;
}



Measured memory_bytes: 640
my $input_string = <STDIN>;

my $A=0;
my $B=0;

($A, $B) = split(/ /, $input_string);

if($A%3 == 0 || $B%3 == 0 || ($A + $B)%3 == 0){
	print "Possible\n";
}
else{
	print "Impossible\n";
}


Measured memory_bytes: 640
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define diup(a, b) (a % b == 0 ? a / b : a / b + 1)
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

void Main()
{
	int a, b;
	cin >> a >> b;
	if (a == 1)	a = 14;
	if (b == 1)	b = 14;
	if (a > b)
		cout << "Alice";
	else if (a == b)
		cout << "Draw";
	else
		cout << "Bob";
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	char C; 
	cin >> C; 
	if(C == 'A') cout << 'T' << endl; 
	if(C == 'T') cout << 'A' << endl; 
	if(C == 'C') cout << 'G' << endl; 
	if(C == 'G') cout << 'C' << endl; 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] a = new int[n];
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int t = a[0];
		for (int i = 1; i < n; i++) {
			if (t == a[i]) {
				cnt++;
				a[i] = -1;
			} else {

			}
			t = a[i];
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
using namespace std;

const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};
double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) < -EPS) return -1; //cw
    if(dot(b,c) < -EPS) return +2; //c-a-b
    if(abs(c)-abs(b) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}

bool intersectSP(const L& s, const P &p){
    return abs(cross(s[0]-p, s[1]-p))<EPS  && dot(s[0]-p, s[1]-p)<EPS;
}
bool intersectSS(const L& a, const L& b){
    return ( ccw(a[0],a[1],b[0]) *ccw(a[0],a[1],b[1]) <= 0 ) &&
        ( ccw(b[0],b[1],a[0]) *ccw(b[0],b[1],a[1]) <= 0 );
}
double distanceLP(const L &l, const P &p) {
  return abs(cross(l[1]-l[0], p-l[0])) /abs(l[1]-l[0]);
}
double distanceSP(const L &s, const P &p) {
  if(dot(s[1]-s[0], p-s[0]) < EPS) return abs(p-s[0]);
  if(dot(s[0]-s[1], p-s[1]) < EPS) return abs(p-s[1]);
  return distanceLP(s, p);
}
double distanceSS(const L &s, const L &t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}

const int limit = 101*101/2;

int main(){
	int n;
	cin >> n;
	vector<L> line(n);
	for(int i=0; i<n; i++){
		int x1,y1,x2,y2;
		cin >> x1 >> y1 >> x2 >> y2;
		line[i] = L(P(x1,y1), P(x2,y2));
	}
	if(n > limit){
		cout << 0 << endl;
		return 0;
	}
	
	double ans = INF;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			ans = min(ans, distanceSS(line[i], line[j]));
		}
	}
	cout << fixed;
	cout << setprecision(6);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5640
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define int long long
using namespace std;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MAXIN(x) max_element(ALL(x)) - x.begin();
#define MIN(x) *min_element(ALL(x))
#define MININ(x) min_element(ALL(x)) - x.begin();
#define INF 1000000000000
#define MOD 100000070

#define MAXR 100000
#define PI 3.14159265358979323846

using namespace std;

signed main() {
    int k;
    string S;
    string ans;
    cin >> k >> S;
    if(S.size() > k){
        ans = S.substr(0, k);
        ans += "...";

    }else{
        ans = S;
    }


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

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

int main(void){
    int n, x;
    int l[105];
    int d1 = 0;
    int d, e;
    int data[105];

    cin >> n >> x;

    e = d1;
    data[0] = d1;

    for(int i = 0; i < n; i++){
        cin >> l[i];
        d = e + l[i];
        e = d;
        data[i+1] = d; 
    }

    int cnt = 0;
    for(int i = 0; i < n+1; i++){
        if(data[i] <= x){
            cnt++;
        }
    }
    cout << cnt << endl;
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,sum = 0,i;string s;cin >> n;bool sleep = false;
  pair<string,int> q[n];
  for(i=0;i<n;i++) cin >> q[i].first >> q[i].second;
  cin >> s;
  for(i=0;i<n;i++){
    if(sleep) sum += q[i].second;
    if(s==q[i].first) sleep = true;
  }
  cout << sum << "\n";
}

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

typedef long long lint;
typedef unsigned long long ulint;
#define MOD 1000000007

lint root(lint *uni, lint a){
    if(uni[a]<0) return a;
    return uni[a]=root(uni,uni[a]);
}
lint cnt(lint *uni, lint a){
    return -uni[root(uni,a)];
}
lint connect(lint *uni, lint ia, lint ib){
    lint a=root(uni, ia),b=root(uni, ib);
    if(a==b) return -a;
    if(uni[a]<uni[b]){
        uni[a]+=uni[b];
        uni[b]=a;
        return root(uni,a);
    }else{
        uni[b]+=uni[a];
        uni[a]=b;
        return root(uni,b);
    }
}

int main(){
    int N,M;
    cin >> N >> M;
    lint uni[200001];
    for(int i=1;i<=N;i++) uni[i]=-1;
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        if(a==1) connect(uni,a,b);
        if(b==N) connect(uni,a,b);
    }
    if(root(uni,1)==root(uni,N)) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;

    return 0;
}

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

int main() {
  int k, n;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  int sum = 0;
  rep(i, k) sum += a[i];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3628
M, D = map(int, input().split())
ans = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        d1 = d%10
        d10 = d//10
        if d1>=2 and d10>=2 and m==d1*d10:
            ans+=1
print(ans)

Measured memory_bytes: 39664
#include <iostream>

using namespace std;

int main(void){
	for(;;){
		int x, y;

		cin >> x >> y;
		if(!x && !y)
			break;

		if(x < y)
			cout << x << " " << y << endl;
		else
			cout << y << " " << x << endl;
	}
	return 0;
}



Measured memory_bytes: 3072
//https://atcoder.jp/contests/abc095/tasks/arc096_a
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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 main() {
  ll A,B,C,X,Y; cin>>A>>B>>C>>X>>Y;
  ll ans = X*A+Y*B;
  FOR(c,1,max(X,Y)+1){
    ll y=2*c*C;
    ll a=max(X-c,0LL);
    ll b=max(Y-c,0LL);
    y+=a*A+b*B;
    chmin(ans,y);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int a, b, c = 1001, e;
	cin >> a >> b;
	for (int h = 1; h <= a; h++) {
		cin >> e;
		c = min(c, e);
		b -= e;
	}
	cout << a + b / c << "\n";
	cin >> e;
}

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


using namespace std;

#define fastio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define print_vec(vec) for(int i=0;i<sz(vec);i++) cout << vec[i] << " ";
#define FORin(vec) for(int& x : vec) cin>>x;

void go(){
	int n;cin>>n;
	if(n<1200) cout << "ABC";
	else if(n<2800) cout << "ARC";
	else cout << "AGC";
}
int main(){
   
   fastio();
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}




Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  char a, b;
  cin >> a >> b;
  if (a < b) {
  	cout << "<\n";
  }else if (a > b) {
  	cout << ">\n";
  }else {
  	cout << "=\n";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
	int n,m;
	cin >> n >> m;
	priority_queue<int, vector<int>, greater<int> > al, bl;
	LOOP(i,m){
		int a,b;
		cin >> a >> b;
		if(a==1){
			al.push(b);
		}if(b==n){
			bl.push(a);
		}
	}
	int da=-2, db=-1;
	while(1){
		// cerr << da << ":" << db << endl;
		if(da<db){
			if(al.empty()){
				break;
			}
			da = al.top();
			al.pop();
		}else if(da>db){
			if(bl.empty()){
				break;
			}
			db= bl.top();
			bl.pop();
		}
		if(da==db){
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}


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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr ll MOD = (ll)1e9 + 7;
constexpr ll MOD2 = 998244353;
constexpr ll HIGHINF = (ll)1e18;
constexpr ll LOWINF = (ll)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template<typename T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template<typename... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
    ll N; cin >> N;
    V<ll> d(N);
    for(int i = 0; i < N; ++i){
        cin >> d[i];
    }
    sort(ALL(d));

    int ans = 0;
    for(int i = 1; i <= 100000; ++i){
        int j = lower_bound(ALL(d),i) - d.begin();
        if(j == (N-j)) ans++;
    }
    cout << ans << endl;


 

    return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

struct Data{
	int idx;
	int p;
	int q;
	int r;
	int cal;
};

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;

		vector<Data> food;
		for(int i=0;i<n;i++){
			int idx,p,q,r;
			//calc 4 9 4
			scanf("%d %d %d %d",&idx,&p,&q,&r);
			Data d = {idx,p,q,r,4*p+9*q+4*r};
			food.push_back(d);
		}

		int P,Q,R,C;
		scanf("%d %d %d %d",&P,&Q,&R,&C);
		vector<int> canEat;
		for(int i=0;i<food.size();i++){
			if(food[i].p <= P && food[i].q <= Q
				&& food[i].r <= R && food[i].cal <= C){
					canEat.push_back(food[i].idx);
			}
		}

		if(canEat.size() == 0) printf("NA\n");
		else{
			for(int i=0;i<canEat.size();i++){
				printf("%d\n",canEat[i]);
			}
		}
	}
}

Measured memory_bytes: 0
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,m = readInts()
A = [list(input()) for _ in range(n)]
B = [list(input()) for _ in range(m)]
def search(j,i):
    for k in range(m):
        for s in range(m):
            if A[j+k][i+s] != B[k][s]:
                return False
            else:
                continue
    return True
flag = False
for i in range(n-m+1):
    for j in range(n-m+1):
        if A[j][i] == B[0][0]:
            if search(j,i):
                print('Yes')
                exit()
print('No')


Measured memory_bytes: 10412
#include <stdio.h>
#include <iostream>
#define Re register int

int N,A[405];
long long s[405],f[405][405];

template <typename T> inline void read(T &var)
{
	T x=0; int w=0; char ch=0;
	while (!isdigit(ch)) w|=ch=='-',ch=getchar();
	while (isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	var=w?-x:x;
}
int main(int argc, char const *argv[])
{
	read(N);
	for (Re i=1; i<=N; ++i)
		read(A[i]),s[i]=s[i-1]+A[i];
	for (Re len=2; len<=N; ++len)
		for (Re i=1; i<=N-len+1; ++i)
		{
			int j=i+len-1; f[i][j]=0x3FFFFFFFFFFFFFFF;
			for (Re k=i; k<=j-1; ++k)
				f[i][j]=std::min(f[i][j],f[i][k]+f[k+1][j]+s[j]-s[i-1]);
		}
	printf("%lld\n",f[1][N]);
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int N; cin >> N;
    vector<int> a(N);
    REP(i,N) cin >> a[i];
    double mean = double(accumulate(a.begin(), a.end(), 0)) / N;
    int res = round(mean);
    int ans=0;

    REP(i,N){
        ans += (a[i]-res) * (a[i]-res);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

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

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

int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    long long sum=0;
    for(int i=0;i<n-k;i++)
    {
        sum+=a[i];
    }
    cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int s,w;
        s = sc.nextInt();
        w = sc.nextInt();
        if(s<=w){
            System.out.println("unsafe");
        }else {
            System.out.println("safe");
        }
        }


    }


Measured memory_bytes: 35820
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <map>
using namespace std;

int main(){
    int n, q, l, r, ans=0, array[100010]={};
    string s;
    cin >> n >> q >> s;
    for(int i=0; i<n-1; i++){
        array[i+1]=array[i];
        if(s[i]=='A' && s[i+1]=='C'){
            array[i+1]++;
        }
    }
    for(int i=0; i<q; i++){
        cin >> l >> r;
        cout << array[r-1]-array[l-1] << endl;
    }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int n;
double d,x,ans;
int main()
{
	cin>>n>>d>>x;
	for(int i=n;i>=1;i--)
	{
		ans+=d+(i-0.5)*x;
		d=((2*i+2)*d+5*x)/(2*i);
		x=(2*i+4)*x/(2*i);
	}
	printf("%.9lf",ans);
	return 0;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<end
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll N;
  cin>>N;
  vector<ll> v(N);
  cinv(v,0,N);

  ll res=1e9;
  ll inst=0;
  FOR(i,0,N){
    inst=0;
    while(v[i]%2==0){
      v[i]/=2;
      inst++;
    }
    res=std::min(res,inst);
  }
  cout<<res<<endl;

}


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

int main() {
    int n, j = 0, s = 0;
    cin >> n;
    int p[n], d[n];
    for (int i = 0; i < n; i++) d[i] = 0;
    for (int i = 0; i < n; i++) 
    {
        cin >> p[i];
        if (p[i] == i + 1) d[j]++;
        else j++;
    }
    for (int i = 0; i < n; i++)
        s = s + (d[i] + 1) / 2;
    cout << s;
}


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

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

    string s[n];

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

    sort(s, s + n);

    for(int i = 0; i < n; i++){
        cout << s[i];
    }    

    cout << endl;
}

Measured memory_bytes: 256
use proconio::{fastout, input};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        n: isize,
        list: [String; n],
    }

    let mut result = HashMap::new();
    for s in list {
        let s = s.to_string();
        match &*s {
            "AC" => {
                (*result.entry("AC").or_insert(0)) += 1;
            }
            "WA" => {
                (*result.entry("WA").or_insert(0)) += 1;
            }
            "TLE" => {
                (*result.entry("TLE").or_insert(0)) += 1;
            }
            "RE" => {
                (*result.entry("RE").or_insert(0)) += 1;
            }
            _ => {}
        }
    }

    println!("AC x {}", result.entry("AC").or_insert(0));
    println!("WA x {}", result.entry("WA").or_insert(0));
    println!("TLE x {}", result.entry("TLE").or_insert(0));
    println!("RE x {}", result.entry("RE").or_insert(0));
}


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

def divide(h,w):
    h,w = max(h,w),min(h,w)
    if h%2 and w%2:
        ret = [h//2*w, (h+1)//2*w]
    else:
        ret = [h*w//2, h*w//2]
    return ret

ans = 10**12

for i in range(1,H+1):
    s = [W*i] + divide(H-i,W)
    ans = min(ans,max(s)-min(s))
H,W = W,H
for i in range(1,H+1):
    s = [W*i] + divide(H-i,W)
    ans = min(ans,max(s)-min(s))
print(ans)



Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int L;
int A[200200];
int dp[5][200200];

int min(int a, int b, int c) {
    return min(a, min(b, c));
}

int min(int a, int b, int c, int d) {
    return min(a, min(b, c, d));
}

signed main() {
    cin >> L;
    rep(i, L) {
        cin >> A[i];
    }
    dp[0][0] = A[0];
    dp[1][0] = 2 * (A[0] == 0) + (A[0] % 2 == 1);
    dp[2][0] = (A[0] % 2 == 0);
    dp[3][0] = INF;
    dp[4][0] = INF;
    for (int i = 1; i < L; ++i) {
        dp[0][i] = dp[0][i - 1] + A[i];
        dp[1][i] = min(dp[0][i - 1], dp[1][i - 1]) + 2 * (A[i] == 0) + (A[i] % 2 == 1);
        dp[2][i] = min(dp[0][i - 1], dp[1][i - 1], dp[2][i - 1]) + (A[i] % 2 == 0);
        dp[3][i] = min(dp[2][i - 1], dp[3][i - 1]) + 2 * (A[i] == 0) + (A[i] % 2 == 1);
        dp[4][i] = min(dp[1][i - 1], dp[2][i - 1], dp[3][i - 1], dp[4][i - 1]) + A[i];
    }
    int ans = INF;
    rep(i, 5) {
        ans = min(ans, dp[i][L - 1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9600
n = input()
if len(n)<=1:
    ans = n
elif len(n)<=2:
    ans = 9
elif len(n)<=3:
    ans = int(n)-99+9
elif len(n)<=4:
    ans = 909
elif len(n)<=5:
    ans =int(n)-9999+909
else:
    ans = 90909
print(ans)

Measured memory_bytes: 3060
object Main {
  def solve(r: Int, g: Int, b: Int): String = {
    val n = r * 100 + g * 10 + b
    if (n % 4 == 0) "YES"
    else "NO"
  }

  def main(args: Array[String]): Unit = {
    val Seq(r,g,b): Seq[Int] = io.StdIn.readLine().split(' ').map(_.toInt)
    println(solve(r,g,b))
  }
}

Measured memory_bytes: 25292
<?php
list($H, $W, $K) = ints();
for($i = 0; $i < $H; $i++){
  foreach(str_split(trim(fgets(STDIN))) as $v){
    $map[$i][] = boolval($v); 
  }
}
$min = 10**10;
for($i = 0, $I = 2**($H-1); $i < $I; $i++){
  $over = 0;
  $line[0] = 0;
  $ii = $i;
  for($j = 1; $j < $H; $j++){
    $line[$j] = $line[$j-1] + ($ii & 1);
    $ii >>= 1;
  }
  $groupCount = $line[$H-1]+1;
  $counts = array_fill(0, $groupCount, 0);
  $fromJ = 0;
  for($j = 0; $j < $W; ++$j){
    for($k = 0; $k < $H; ++$k){
      if($map[$k][$j])$counts[$line[$k]]++;
    }
    if(max($counts) > $K){
      $counts = array_fill(0, $groupCount, 0);
      if($fromJ == $j)continue 2;
      $fromJ = $j;
      $over++;
      $j--;
    }
  }
  chmin($min, $over + popcount($i));
}
echo $min;
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}


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

typedef long long ll;

#define v(T) vector<T>
#define ttt(T) tuple<T, T, T>
#define pb push_back
#define mp make_pair
#define rep(i, s, n) for(int i=s;i<n;i++)
#define repeq(i,s,n) for(int i=s;i<=n;i++)
#define poiu(n) for(int i=0; i < n; i++)
#define MOD 1000000007
#define endl '\n'

template<typename T>
void max_self(T& a, T b) { a=a>b?a:b; }
template<typename T>
void min_self(T& a, T b) { a=a<b?a:b; }

using namespace std;
double n;


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

    cin >> n;
    double temp;

    if(n==1) {
        temp=1.0;
        cout << temp << endl;
        return 0;
    }
    

    if((int)n &1) {
        cout << ((n-1)/2+1)/(n) << endl;
    } else {
        cout << 0.5 << endl;
    }

    return 0;

}



Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;

int N, L;
int a[7];
//mx_pos mx_lv lv_mask used_mask
double dp[2][51][7][1<<5][1<<5];
int main()
{
	cin>>N>>L;
	for (int i=0; i<N; i++) cin>>a[i];
	sort(a, a+N);
	double ans = 0;
	int p = 0;
	dp[p][a[N-1]][0][0][0] = 1;
	for (int i=0; i<L; i++)
	{
		for (int j=0; j<N-1; j++)
		{
			int np = p^1;
			memset(dp[np], 0, sizeof(dp[np]));
			for (int mxi=0; mxi<=L; mxi++)
			{
				for (int mxj=0; mxj<N; mxj++)
				{
					if (MP(i,j+1)>=MP(mxi, mxj)) continue;
					for (int lv_mask=0; lv_mask<(1<<N-1); lv_mask++)
					{
						for (int used_mask=0; used_mask<(1<<N-1); used_mask++)
						{
							double &cur = dp[p][mxi][mxj][lv_mask][used_mask];
							if (cur==0) continue;
							dp[np][mxi][mxj][lv_mask][used_mask] += cur;
							//cerr<<i<<","<<j<<" "<<mxi<<" "<<mxj<<" "<<lv_mask<<" "<<used_mask<<":"<<cur<<endl;
							if (!((lv_mask>>j)&1))
							{
								for (int x=0; x<N-1; x++)
								{
									if ((used_mask>>x)&1) continue;
									int ni = mxi, nj = mxj;
									if (MP(i+a[x], j+1)>MP(ni, nj))
									{
										ni = i+a[x];
										nj = j+1;
									}
									if (MP(ni,nj)>MP(L,0)) ni = L, nj = 0;
									dp[np][ni][nj][lv_mask|(1<<j)][used_mask|(1<<x)] += cur/L;
								}
							}
						}
					}
				}
			}
			p = np;
		}
	}
	ans += dp[p][L][0][(1<<N-1)-1][(1<<N-1)-1];
	for (int i=1; i<=N-1; i++) ans /= i;
	cout<<fixed<<setprecision(11)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6016
def dfs(visited, s):  #
    global ans
    visited[s] = True
    for t in graph[s]:
        if not visited[t]:
            dfs(visited[:], t)
    if all(visited):
        ans += 1


N, M = map(int, input().split())  # N頂点, M辺存在する

graph = [[] for _ in range(N)]
visited = [False] * N

for _ in range(M):  # M辺を受け取る
    a, b = map(lambda x: int(x)-1, input().split())
    graph[a].append(b)
    graph[b].append(a)


ans = 0
dfs(visited, 0)

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  int n;cin>>n;
  bool y=false;
  for(int i=0;i<n;i++){
    char c;cin>>c;
    if(c=='Y')y=true;
  }
  cout << (y? "Four":"Three") << endl;
}


Measured memory_bytes: 256
n,q = map(int,input().split())

s = input()

t = [0]*(n+1)

for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2] == 'AC' else 0)
    
for i in range(q):
    l,r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 7748
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define FOREACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIGN(x) (((x)>0)?1:(((x)<0)?-1: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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
#define vv(t) vector< t > 
#define CHC(mp, x) if(mp.end() != mp.find(x))
#define CHCV(mp, x) if(mp.end() != find(ALL(mp), x))
template<typename T>
inline T lcm(T a, T b) {return a / __gcd(a, b) * b;}
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(long long N, std::vector<long long> x, std::vector<long long> y);

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(N, std::move(x), std::move(y));
}

void solve(long long N, std::vector<long long> x, std::vector<long long> y){
    vv(int) to(N);
    REP(i, N)to[i]=i;
    double sum=0.0;
    int cnt=0;
    do{
        REP(i, N-1){
            sum+=sqrt(pow(x[to[i]]-x[to[i+1]],2)+pow(y[to[i]]-y[to[i+1]],2));
        }
        cnt++;
    }while(next_permutation(ALL(to)));
    sum/=(double)cnt;
    cout << sum << el;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << "\n\n"
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N;
  cin >> N;

  vector<int> b(N);
  rep(i, N) {
    cin >> b[i];
    b[i]--;
  }

  vector<int> ans(N);
  rep(i, N) {
    int pos = -1;
    rep(j, N - i) {
      if (j == b[j]) {
        pos = j;
      }
    }

    if (pos == -1) {
      cout << -1 << '\n';
      return 0;
    }

    ans[i] = pos + 1;
    b.erase(b.begin() + pos);
  }

  reverse(all(ans));
  rep(i, len(ans)) {
    cout << ans[i] << "\n";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    queue<char> player[3];
    char c;
    string s;
    //input
    for(int i=0;i<3;i++){
        cin>>s;
        for(int j=0;j<s.size();j++){
            player[i].push(s[j]);
        }
    }
    
    int next_player = 0;
    while(!player[next_player].empty()){
        c = player[next_player].front();
        player[next_player].pop();
        if(c=='a')next_player=0;
        else if(c=='b')next_player=1;
        else if(c=='c')next_player=2;
    }
    if(next_player==0)cout<<"A"<<endl;
    if(next_player==1)cout<<"B"<<endl;
    if(next_player==2)cout<<"C"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    while(A>0&&C>0){
        C=C-B;        
        if(C>0){
            A=A-D;
        }
    }
    if(A>0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

int numFac(int x, VI &v) {
  int ret = 0;
  for(auto u : v) {
    if(u >= x - 1) ret++;
  }
  return ret;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VI fac(n + 1, 0);
  for(int i = 2; i < n + 1; ++i) {
    int tmp = i;
    for(int j = 2; j < i + 1; ++j) {
      while (tmp % j == 0) {
        fac[j]++;
        tmp /= j;
      }
    }
  }
  cout << (numFac(75, fac) + numFac(25, fac) * (numFac(3, fac) - 1) + numFac(15, fac) * (numFac(5, fac) - 1) + numFac(5, fac) * (numFac(5, fac) - 1) * (numFac(3, fac) - 2) / 2) << endl;
  return 0;
}


Measured memory_bytes: 256