akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#define MAX_R 2001
#define MAX_T 51
#define MAX_P 11
using namespace std;

void mysort(int ac[MAX_T], int sum[MAX_T], int rank[MAX_T], int n) {
  for (int i = 1; i <= n; i++) {
    for (int j = i; j > 1; j--) {
      if (ac[j - 1] < ac[j] || ac[j - 1] == ac[j] && sum[j - 1] > sum[j]
	  || ac[j - 1] == ac[j] && sum[j - 1] == sum[j] && rank[j - 1] < rank[j]) {
	swap(ac[j - 1], ac[j]);
	swap(sum[j - 1], sum[j]);
	swap(rank[j - 1], rank[j]);
      }
    }
  }
}

int main() {
  while (true) {
    int m[MAX_R], t[MAX_R], p[MAX_R], j[MAX_R];
    int ac[MAX_T], sum[MAX_T], wa[MAX_T][MAX_P], rank[MAX_T];
    int M, T, P, R;
    cin >> M >> T >> P >> R;
    if (M == 0 && T == 0 && P == 0 && R == 0) return 0;

    for (int i = 0; i < MAX_R; i++) {
      m[i] = t[i] = p[i] = j[i] = 0;
    }
    for (int i = 0; i < MAX_T; i++) {
      ac[i] = sum[i] = 0;
      for (int j = 0; j < MAX_P; j++) {
	wa[i][j] = 0;
      }
    }
    for (int i = 0; i < MAX_T; i++) {
      rank[i] = i;
    }
    
    for (int i = 0; i < R; i++) {
      cin >> m[i] >> t[i] >> p[i] >> j[i];
    }

    for (int i = 0; i < R; i++) {
      int team = t[i];
      int minute = m[i];
      int problem = p[i];
      if (j[i] == 0) {
	ac[team]++;
	sum[team] += minute + wa[team][problem] * 20;
      } else {
	wa[team][problem]++;
      }
    }

    mysort(ac, sum, rank, T);

    for (int i = 1; i <= T; i++) {
      if (i == T) {
	cout << rank[i] << endl;
      } else if (ac[i] == ac[i + 1] && sum[i] == sum[i + 1]) {
	cout << rank[i] << '=';
      } else {
	cout << rank[i] << ',';
      }
    }
  }
}

Measured memory_bytes: 3140
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		long mod = 1000000007;
		string s = Console.ReadLine();
		long[,] dp = new long[n+1,n];
    long[,] sums = new long[n+1,n+1];

    for(int i = 0; i < n; i++)
    {
      dp[1,i] = 1;
      sums[1,i+1] = i+1;
    }

    for(int i = 2; i <= n; i++)
    {
      for(int j = 0; j < n+1-i; j++)//左から0-indexで何番目を取るのか
      {
        if(s[i-2] == '>')
        {
          dp[i,j] = sums[i-1,n]-sums[i-1,j+1];
        }else
        {
          dp[i,j] = sums[i-1,j+1];
        }
        dp[i,j] += mod;
        dp[i,j] %= mod;
        sums[i,j+1] = sums[i,j] + dp[i,j];
        sums[i,j+1] %= mod;
        //Console.WriteLine(i+" "+j+" "+dp[i,j]);
      }
      for(int j = n+1-i; j < n; j++)
      {
        sums[i,j+1] = sums[i,j];
      }
    }

		Console.WriteLine(dp[n,0]);
	}
}

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

size_t primes[5555];

int main() {
  for (size_t i=2; i<std::sqrt(5555); i++) {
    if (primes[i] == 0) {
      for (size_t j=2; i*j<5555; j++) {
        primes[i*j] = 1;
      }
    }
  }

  size_t N;
  std::cin >> N;

  size_t n=0;

  for (size_t i=2; i<5555; i++) {
    if (primes[i] == 0 && i % 5 == 1) {
      std::cout << i;
      n++;

      if (n<N)
        std::cout << ' ';
      else
        break;
    }
  }

  std::cout << std::endl;

  return 0;
}


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

#define pb push_back
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define INF 1e18
#define MOD 1000000007
#define int long long
#define FOR(x, n) for(int i=x; i<n; i++)
#define print(x) cout << "[" << #x << ":" << x << "] "; 
#define println(x) cout << "[" << #x << ":" << x << "]\n"; 

int dx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 }; 
int dy[8] = { 0, 1, -1, 0, -1, 1, -1, 1 };  
double PI = acos(-1); 

int32_t main(){
	ios::sync_with_stdio(0); 
    cin.tie(0); 
	#ifndef ONLINE_JUDGE
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	int x; cin >> x;
	if(x == 0)
		cout << 1 << "\n";
	else
		cout << 0 << "\n";
	return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>
using namespace std;
int n;
long long sum=0;
int main(){
    scanf("%d",&n);
    for(register int i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0){
            sum+=i;
        }
    }
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 3828
#include<stdio.h>
int main(void)
{
 int N;
  double  x,sum=0.0,i;
 char u[3];
  scanf("%d",&N);
  
  for(i=1;i<=N;i++)
  {scanf("%lf %s",&x,u);
  if ( strcmp( u, "BTC" ) == 0 ) 
    x=x*380000.0;
  sum=sum+x;}
  printf("%lf\n",sum);
  return 0;}

Measured memory_bytes: 128
N = int(input())
S = [""]*N
for i in range(N):
    S[i] = input()

march = ['M','A','R','C','H']
dp = [0]*5

for s in S:
    for i in range(5):
        if march[i] == s[0]:
            dp[i] += 1

ans = 0
for x in range(5):
    for y in range(x+1, 5):
        for z in range(y+1, 5):
            ans += dp[x] * dp[y] * dp[z]

print(ans)


Measured memory_bytes: 9716
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();
    if (A * B >= C * D){
      System.out.println(A * B);
    }
    else{
      System.out.println(C * D);
    }
  }
}

Measured memory_bytes: 20684
#include <iostream>
#include <vector>
#include <list>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <iomanip>
#include <queue>
#include <map>
#include <unordered_map>
typedef long long ll;
using namespace std;

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

	std::vector<double> A(N);

	double ans_inv = 0.0;

	for(int i=0; i<N; i++){
		std::cin >> A[i];		
		ans_inv += 1/A[i];
	}

	double ans = 1./ans_inv;

	std::cout << std::setprecision(9) << ans << std::endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> 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); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

string s;

void _main() {
    cin >> s;
    int ans = INF;
    REP (i, SZ(s) - 2) {
        string t = s.substr(i, 3);
        int val = stoi(t);
        CHMIN(ans, abs(val - 753));
    }
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
  int x,y;
  cin >> x >> y;
  cout << x+(y/2) << endl;
}

Measured memory_bytes: 256
using System;

namespace A___Placing_Marbles
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var ans = 0;
            for(var i=0; i<3; i++)
            {
                if (s[i] == '1')
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}

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

using namespace std;

typedef long long LL;
int N;
char op[100010];
int v[100010];
LL INF = LL(1e17);
LL s1[100010],s2[100010];

//A-(B-(C-(D-E)))  = A-B+C-D+E  = A-(B-C) - (D-E)
vector <int> negpos; 

int main()
{
	scanf("%d",&N);
	scanf("%d",&v[1]);
	s1[0] = s2[0] = 0;
	op[1] = '+';
	for (int i=2;i<=N;i++)
	{
		scanf(" %c %d",&op[i],&v[i]);
		if (op[i] == '-') negpos.push_back(i);
	}
	for (int i=1;i<=N;i++)
	{
		s1[i] = s1[i-1] + LL(v[i]) * (op[i]=='+'?1:-1);
		s2[i] = s2[i-1] + LL(v[i]);
	}
	//for (int i=1;i<=N;i++)printf("%d %c %I64d %I64d\n",v[i],op[i],s1[i],s2[i]);
	LL ans = s1[N];
	int SZ = negpos.size();
	for (int i=0;i<SZ-1;i++)
	{
		int p1,p2;
		p1 = negpos[i];
		p2 = negpos[i+1];
		//printf("%d %d %I64d\n",p1,p2,s1[p1-1] - (s1[p2-1]-s1[p1-1]) + (s2[N]-s2[p2-1]));
		ans = max(ans,s1[p1-1] - (s2[p2-1]-s2[p1-1]) + (s2[N]-s2[p2-1]));
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 2808
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
int dfs(int x,int step)
{
	if(x%2)
		return step;
	dfs(x/2,step+1);
}
int main()
{
	int n,a[10005];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]%2==0)
			ans+=dfs(a[i],0);
	}
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 2003, inf = 2e9;
int n, k, q, a[N], b[N];

priority_queue <int, vector <int>, greater <int> > cur, pq;

int get(int x) {
	while (!pq.empty()) pq.pop();
	int len = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] < x) continue;
		len++;
		cur.push(a[i]);
		if (i == n || a[i + 1] < x) {
			int can = max(0, len - k + 1);
			while (can--) {
				pq.push(cur.top());
				cur.pop();
			}
			len = 0;
			while (!cur.empty()) cur.pop();
		}
	}
	if ((int)pq.size() < q) return inf;
	int res = 0;
	for (int i = 0; i < q; i++)
		res = max(res, pq.top()), pq.pop();
	return res;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n >> k >> q;
	for (int i = 1; i <= n; i++) cin >> a[i], b[i] = a[i];
	sort(b + 1, b + n + 1);
	int ans = inf;
	for (int i = 1; i <= n; i++)
		ans = min(ans, get(b[i]) - b[i]);
	cout << ans;
}


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

void call(int n); 
int main(){

	int A[4][11]={0};
	int B[4][11]={0};
	int C[4][11]={0};
	int D[4][11]={0};
	int b=0,f=0,r=0,v=0;
	int n;

	cin >> n;

	for(int i=0;i<n;i++){
		cin >> b >> f >> r >> v;

		if(b==1){//A
			A[f][r]+=v;
		}else if(b==2){//B
			B[f][r]+=v;
		}else if(b==3){//C
			C[f][r]+=v;
		}else if(b==4){//D
			D[f][r]+=v;
		}
	}

	for(int i=1;i<4;i++){
		for(int k=1;k<11;k++){
			cout << " " << A[i][k];
			if(k==10){
				cout << endl;
			}
		}
	}
	cout << "####################" << endl;
	
	for(int i=1;i<4;i++){
		for(int k=1;k<11;k++){
			cout << " " << B[i][k];
			if(k==10){
				cout << endl;
			}
		}
	}
	cout << "####################" << endl;

	for(int i=1;i<4;i++){
		for(int k=1;k<11;k++){
			cout << " " << C[i][k];
			if(k==10){
				cout << endl;
			}
		}
	}
	cout << "####################" << endl;

	for(int i=1;i<4;i++){
		for(int k=1;k<11;k++){
			cout << " " << D[i][k];
			if(k==10){
				cout << endl;
			}
		}
	}



return 0;
}

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

const int N = 202020;

inline char get(void) {
	static char buf[100000], *S = buf, *T = buf;
	if (S == T) {
		T = (S = buf) + fread(buf, 1, 100000, stdin);
		if (S == T) return EOF;
	}
	return *S++;
}
template<typename T>
inline void read(T &x) {
	static char c; x = 0; int sgn = 0;
	for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
	for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
	if (sgn) x = -x;
}

int n;
int p[N], q[N];
int f[N], T[N];

inline bool Check(int a, int b, int c) {
	return (a < b && b < c) || (b < c && c < a) || (c < a && a < b);
}

int main(void) {
	read(n);
	for (int i = 1; i <= n; i++) {
		read(p[i]); q[p[i]] = i;
	}
	T[n] = 0;
	for (int i = n - 1; i; i--) {
		if (T[i + 1] == 0) {
			if (q[i] > q[i + 1]) {
				T[i] = 1; f[i] = i + 1;
			}
		} else {
			if (Check(q[f[i + 1]], q[i], q[i + 1])) {
				T[i] = T[i + 1]; f[i] = f[i + 1];
			} else {
				T[i] = T[i + 1] + 1; f[i] = i + 1;
			}
		}
	}
	cout << T[1] << endl;
}

Measured memory_bytes: 3456
H, N = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(N)]

dp = [10**9 for _ in range(H+10**4+1)]
dp[0] = 0

for a, b in magic:
    for j in range(H+1):
        if dp[j+a] > dp[j] + b:
            dp[j+a] = dp[j] + b

print(min(dp[H:]))

Measured memory_bytes: 42220
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    while (cin >> n, n){
        stack<pair<int, int>> v;
        for (int i = 0; i < n; ++i) {
            int k;
            cin >> k;
            if(i % 2 == 0){
                if(v.empty()){
                    v.emplace(k, 1);
                }else {
                    auto x = v.top(); v.pop();
                    if(x.first == k){
                        v.emplace(k, x.second + 1);
                    }else {
                        v.emplace(x);
                        v.emplace(k, 1);
                    }
                }
            } else if (i % 2 == 1 && k == v.top().first){
                auto x = v.top(); v.pop();
                if(x.first == k){
                    v.emplace(k, x.second + 1);
                }else {
                    v.emplace(x);
                    v.emplace(k, 1);
                }
            } else if((i % 2 == 1 && k != v.top().first && v.size() <= 1)) {
                auto x = v.top(); v.pop();
                v.emplace(k, x.second+1);
            }else {
                auto x = v.top(); v.pop();
                auto y = v.top(); v.pop();
                v.emplace(k, x.second+y.second+1);
            }
        }
        int ans = 0;
        while(!v.empty()){
            ans += (1-v.top().first)*v.top().second; v.pop();
        }
        cout << ans << "\n";
    } 
    
    return 0;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define inf          INT_MAX
#define zer          INT_MIN
#define nl cout<<'\n' ; 
void prl(ll x) {cout << x <<'\n';}
void speed() { ios_base::sync_with_stdio(false);cin.tie(NULL);}
void checker(){ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);}

void solve()
{
	int n , k ; cin>>n>>k ; 

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

	vector<int> dp(n , inf) ; 

	// I defined dp as the minimum cost required to reach a certain pos i 

	dp[0]=0 ; 
	dp[1]=abs(h[1]-h[0]) ;

	for(int i=2; i<n ; i++)
	{
		for(int j=1 ; j<=k&&(i-j)>=0 ; j++)
		{
			dp[i] = min(dp[i] , dp[i-j]+abs(h[i]-h[i-j])) ; 
		}
	}

	cout<<dp[n-1] ; 
	
}

int main()
{
	speed();
    //checker() ; 
    int T = 1;
   // cin >> T;
    while (T--){
    solve();
}
}



Measured memory_bytes: 4020
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#include <map>
using namespace std;

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

template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }


int main() {
  int N,K; cin>>N>>K;
  vector<bool> dp(K+1, false);
  vector<int> a(N);
  REP(i,N) cin>>a[i];
  for(int i = 1; i <= K; i++) {
    bool tmp = false;
    REP(j, N) {
      int idx = i - a[j];
      if(idx >= 0) {
	if(dp[idx] == false) {
	  tmp = true;
	  break;
	}
      }
    }
    dp[i] = tmp;
  }
  cout << (dp[K] ? "First" : "Second") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll H[100100];

ll dp[100100];

int main() {
    fastio
    ll N;
    cin>>N;
    for(ll i=0;i<N;i++){
        cin>>H[i];
        dp[i]=0;
    }
    dp[0]=0;
    dp[1]=abs(H[1]-H[0]);
    dp[2]= abs(H[2]-H[0]);
    for(ll i=3;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]<<"\n";

    return 0;
}

Measured memory_bytes: 5144
H, W = gets.split.map(&:to_i)
c = 10.times.map do
  gets.split.map(&:to_i)
end
A = H.times.flat_map do
  gets.split.map(&:to_i)
end.select do |i|
  i != -1 && i != 1
end

not_one = [0, 2, 3, 4, 5, 6, 7, 8, 9]
near = Array.new(10, 999999)

not_one.each do |target|
  t = 999999
  q = [[1, 0, []]]
  q.each do |(e, cost, path)|
    not_one.each do |n|
      next if n == e
      next if path.include?(n)
      next if cost >= t
      if n == target
        if near[target] > cost + c[n][e]
          t = near[target] = cost + c[n][e]
        end
      else
        q << [n, cost + c[n][e], path + [n]]
      end
    end
  end
end

p A.map {|i| near[i] }.inject(:+) || 0


Measured memory_bytes: 3324
# coding: utf-8
import sys
import pprint
import math

def solve(arrb, arra):
    ret = 0
    len_arrb = len(arrb)
    if len_arrb == 0:
        return dist_all(arra)
    for i in range(len_arrb):
        arrb_t = arrb[:]
        pop_arrb = arrb_t.pop(i)
        ret += solve(arrb_t, arra + [pop_arrb])
    return ret

def dist_all(arr):
    sum_dist = 0
    for i in range(len(arr) - 1):
        sum_dist += dist(arr[i], arr[i + 1])
    return sum_dist

def dist(arr1, arr2):
    return (((arr2[0] - arr1[0]) ** 2) + ((arr2[1] - arr1[1]) ** 2)) ** 0.5

n = int(input())
xy = [[int(j) for j in input().split()] for i in range(n)]

print(solve(xy, []) / math.factorial(n))


Measured memory_bytes: 3956
while True:
    w, h = map(int, input().split())
    if w == 0: break
    goal = (w,h)
    vart = []
    hori = []
    for i in range(2*h-1):
        if i % 2 == 0:
            vart.append(list(map(int, input().split())))
        else:
            hori.append(list(map(int, input().split())))
    node = [[0 for i in range(h)] for i in range(w)]
    queue = [(0,0,1)]
    while queue:
        p = queue.pop(0)
        x, y, z = p[0], p[1], p[2]
        node[x][y] += 1
        if y-1 >= 0 and hori[y-1][x] == 0 and node[x][y-1] == 0:
            node[x][y-1] = node[x][y]
            queue.append((x,y-1,z+1))
        if y+1 < h and hori[y][x] == 0 and node[x][y+1] == 0:
            node[x][y+1] = node[x][y]
            queue.append((x,y+1,z+1))
        if x-1 >= 0 and vart[y][x-1] == 0 and node[x-1][y] == 0:
            node[x-1][y] = node[x][y]
            queue.append((x-1,y,z+1))
        if x+1 < w and vart[y][x] == 0 and node[x+1][y] == 0:
            node[x+1][y] = node[x][y]
            queue.append((x+1,y,z+1))
    print(node[w-1][h-1])

Measured memory_bytes: 7712
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int ans = 0;
    for(int i = x; i < 1000000; i++) {
      int p = 0;
      for(int j = 2; (j * j) <= i; j++) {
        if((i % j) == 0) {
          p++;
          break;
        }
      }
      if(p == 0) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
}

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


class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string[] inputStr = new string[3];
        int[,] input = new int[N+1,3];
        input[0,0] = 0; input[0,1] = 0; input[0,2] = 0;
        for(int i=1; i<=N; i++){
            inputStr = Console.ReadLine().Split(' ');
            for(int j=0; j<3; j++){
                input[i,j] = int.Parse(inputStr[j]);
            }
        }

        int distance; int time;
        string can = "Yes";

        for(int i=0; i<N; i++){
            distance = Math.Abs(input[i,1]-input[i+1,1]) + Math.Abs(input[i,2]-input[i+1,2]);
            time = input[i+1,0] - input[i,0];

            if(distance > time || distance%2 != time%2){
                can = "No";
                break;
            }
        }

        Console.WriteLine(can);
    }
}

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

int main() {
	int w, n,array[30],right,left;
	scanf("%d%d", &w, &n);
	for (int i = 1; i < w+1; i++) {
		array[i] = i;
	}
	for (int j = 0; j < n; j++) {
		scanf("%d,%d", &right, &left);
		swap(array[right], array[left]);
	}

	for (int i = 1; i <= w; i++) {
		printf("%d\n", array[i]);
	}

	return 0;
}


Measured memory_bytes: 3132
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;

typedef long long ll;

vector<int> bit_each(int i){
    vector<int> a;
    for(int j=0;j<10;j++){
        a.push_back(i%2);
        i/=2;
    }
    return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m,k[11],s[11][11],p[11];
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>k[i];
        for(int j=0;j<k[i];j++){
            cin>>s[i][j];
        }
    }
    for(int i=0;i<m;i++) cin>>p[i];
    int t;
    int ans=0;
    for(int i=0;i<pow(2,n);i++){
        vector<int> ii=bit_each(i);
        bool flag=1;
        for(int l=0;l<m;l++){
            t=0;
            for(int j=0;j<k[l];j++){
                t+=ii.at(s[l][j]-1);
            }
            t=t%2;
            if(t!=p[l]) flag=0;
        }
        if (flag==1) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

int main()
{
    int a, b, x, y, m;
    cin>>a>>b;
    if(b==0||b==1||b==2||b==3||b==4||b==5||b==6||b==7||b==8||b==9)
    {
        x=10;
    }
    else if(b==100)
    {
        x=1000;
    }
    else
    {
        x=100;
    }
    y = (a*x)+b;
    m = sqrt(y);
    if(m*m==y && y!=0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		if(s.equals("SSS")){
			System.out.println("0");
		}else if(s.equals("RSS")){
			System.out.println("1");
		}else if(s.equals("SRS")){
			System.out.println("1");
		}else if(s.equals("SSR")){
			System.out.println("1");
		}else if(s.equals("RSR")){
			System.out.println("1");
		}else if(s.equals("RRS")){
			System.out.println("2");
		}else if(s.equals("SRR")){
			System.out.println("2");
		}else if(s.equals("RRR")){
			System.out.println("3");
		}
	}

}


Measured memory_bytes: 35592
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  int r;
  cin>>r;
  double ans=2*pi*r;
  decimal(10);
  out(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T>
T gcd(T a, T b){
    T n = min(a,b);
    T m = max(a,b);
    if(n == 0){ return m;}
    else {
        return gcd(n, m % n);
    }
}

int main(void)
{
    ll N, M;
    
    string S, T;

    cin >> N >> M >> S >> T;

    ll L;
    bool match = false;
    if(N%M != 0 && M%N != 0){
        L = M*N / gcd(N, M);
        int i = 0;
        while(true){
            if(i * L/M >= N || i * L/ N >= M) break;

            if(S[i * L/M] == T[i * L/N]){
                match = true;
            } else {
                match = false;
                break;
            }
            i++;
        }

    } else {
        L = max(M, N);

        int step = max(M,N) / min(M,N);

        for(int i = 0; i < min(M,N); i++){
            if(M > N){
                if(S[i] == T[i*step]) match = true;
                else {
                    match = false;
                    break;
                }
            } else {
                if(S[i*step] == T[i]) match = true;
                else {
                    match = false;
                    break;
                }
            }
        }
    }

    if(match){
        cout << L << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3764
let () = 
    let (s, h, c, d) = (0, 1, 2, 3) in
    let arr = Array.make_matrix 4 13 false in
    let n = read_int () in
    for _ = 1 to n do 
        let (a, j) = Scanf.scanf "%c %d\n" (fun x y -> (x, y - 1)) in
	match a with
            | 'S' -> arr.(s).(j) <- true
            | 'H' -> arr.(h).(j) <- true
            | 'C' -> arr.(c).(j) <- true
            | 'D' -> arr.(d).(j) <- true
            | _   -> ()
    done;
    let f c = 
        Array.iteri (fun i v -> if not v then Printf.printf "%c %d\n" c (i + 1) ); in
    f 'S' arr.(s);
    f 'H' arr.(h);
    f 'C' arr.(c);
    f 'D' arr.(d);
;;


Measured memory_bytes: 2388
#!/usr/bin python3
# -*- coding: utf-8 -*-


def factor_osa(A):
    Max = max(A) + 1
    IsPrime = [True] * Max
    MinFactor = [-1] * Max
    Primes = []
    prim = {}
    dica = {}
    mxa = 0
    IsPrime[0], IsPrime[1] = False, False
    MinFactor[0], MinFactor[1] = 0, 1
    for i in range(2, Max):
        if IsPrime[i]:
            MinFactor[i] = i
            Primes.append(i)
            for j in range(i*2, Max, i):
                IsPrime[j] = False
                if MinFactor[j] == -1:
                    MinFactor[j] = i
    ret = []
    for a in A:
        res = []
        while a != 1:
            prime = MinFactor[a]
            exp = 0
            while MinFactor[a] == prime:
                exp += 1
                a //= prime
            res.append((prime, exp))
            if not prime in dica:
                dica[prime] = 1
            else:
                dica[prime] += 1
            mxa = max(mxa, dica[prime])
        ret.append(res)
    return [ret, mxa]

n = int(input())
a = list(map(int, input().split()))

aa = factor_osa(a)

from math import gcd        #for python3.8

def Gcd(lt):
    l = len(lt)
    ret = [1]*l
    ret[0] = lt[0]
    for i in range(1,l):
        ret[i] = gcd(ret[i-1], lt[i])
    return ret

if max(a) == 1:
    print('pairwise coprime')
    exit()

if aa[1] == 1:
    print('pairwise coprime')
elif Gcd(a)[-1]==1:
    print('setwise coprime')
else:
    print('not coprime')


Measured memory_bytes: 394868
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <bitset>
#include <utility>
#include <sstream>
#include <fstream>
#include <stack>
#include <cstdlib>
#include <complex>
#include <set>
#include <unordered_map>
#include <map>

using namespace std;

#define INF 1070000000LL
#define pb push_back
#define irep(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) irep(i,0,n)

typedef long long lint;
typedef pair<int, int> pint;
struct Edge{
    int to,weight;
};
typedef vector<vector<Edge> > Graph;

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


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

int main(){  
	int N;
	int L;
	cin >> N >> L;
	vector<string> list;
	string text = "";
	for(int i = 0; i < N; i++){
		string input;
		cin >> input;
		list.push_back(input);
	}
	sort(list.begin(), list.end());
	for(int i = 0; i < N; i++){
		text += list[i];
	}
	cout << text << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define num_digit(number, base) (((long long)(log10(number) / log10(base)))+1)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif

ll cnt[10][10];
int n;

inline ll power(ll a, ll p){
    ll res = 1, x = a;
    while (p){
        if (p & 1) res = (res * x);
        x = (x * x), p >>= 1;
    }
    return res;
}

void pre_cal()
{
    for (int num = 1; num <= n; num++){
        int first = num / power(10, num_digit(num, 10) - 1);
        int last = num % 10;
        if (last == 0){
            continue;
        }
        cnt[first][last]++;
    }
}

int main ()
{
    #ifdef Lollipop
        freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;
    cin >> n;
    pre_cal();
    ll res = 0;
    for (int i = 1; i <= 9; i++){
        for (int j = 1; j <= 9; j++){
            res += cnt[i][j] * cnt[j][i];
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int leg[3];
    int m, n;
    int x;
//    for (int i = 0; i< 3; i++){
//        cin>> leg[i];
//    }
//
//    //find biggest
//    m = 0;
//    n = 0;
//    for (int i = 0; i< 3; i++){
//        if (leg[i]>=m){
//            n = i;
//            m = leg[i];
//        }
//    }
//    m = 0;
//    for (int i = 0; i< 3; i++){
//        if (i==n){
//            continue;
//        }
//        m +=leg[i];
//    }
//    x = 0;
//    if (leg[n] >=m){
//        x = leg[n] - m+1;
//    }
//    cout<< x;
    //second problem
    int a;
    cin>> a;
    int input[a];
    for (int i = 0; i< a; i++){
        cin>> input[i];
    }
    m = 0;
    for (int i= 1; i< a-1; i++){
        if (input[i-1]< input[i] && input[i] <input[i+1]){
            m++;
        }
        if (input[i-1]> input[i] && input[i] >input[i+1]){
            m++;
        }
    }
    cout << m;
    //third problem
//    cin>> a;
//    m = 2;
//    for (int i = 2; i< a+1; i++){ //each time
//        int n = m%a;
//        if (n==0){
//            n = m;
//        }
//        cout<< n <<" ";
//        m+=i;
//    }
        //fourth problem
//    string s;
//    cin>> s;
//    for (int i= 0; i< s.length(); i++){
//
//
//
//    }
    
    
    return 0;
}

Measured memory_bytes: 256
Imports System

Module Program
    Sub Main(args As String())

        Dim tmp As String() = Split(Console.ReadLine(), " ")

        Dim A As Long = CLng(tmp(0))
        Dim B As Double = CDbl(tmp(1))
        Dim B2 As Long = CLng(B * 100)
        Dim ans As Long = Math.Floor((A * B2) \ 100)

        Console.WriteLine(ans)

    End Sub

End Module


Measured memory_bytes: 28392
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 500+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
LL w[N],v[N];
LL dp[N][N][N];
int main(){
    LL n,W;
    scanf("%lld%lld",&n,&W);
    for(int i=1;i<=n;i++)
        scanf("%lld%lld",&w[i],&v[i]);

    LL w1=w[1];
    for(int i=1;i<=n;i++)
        w[i]-=w1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int k=1;k<=n;k++){
                if(j>=w[i]){
                    dp[i][j][k]=max(dp[i-1][j][k],dp[i-1][j-w[i]][k-1]+v[i]);
                }
                else{
                    dp[i][j][k]=dp[i-1][j][k];
                }
            }
        }
    }

    LL res=0;
    for(int j=0;j<=300;j++){
        for(int k=0;k<=n;k++){
            if(k*w1+j<=W){
                res=max(res,dp[n][j][k]);
            }
        }
    }
    printf("%lld\n",res);

    return 0;
}

Measured memory_bytes: 198912
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans = 0
for i in range(n):
  for j in range(i):
    for k in range(j):
      if (a[k]!=a[j] and a[i]!=a[j] and a[k]+a[j] >a[i]):
        ans+=1
print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> a(m),b(m);
    vector<vector<int>> c(m,vector<int>(n));
    vector<int> v(m);
    rep(i, m)
    {
        cin >> a[i] >> b[i];
        int sum = 0;
        rep(j, b[i])
        {
            cin >> c[i][j];
            c[i][j]--;
            sum += (1 << c[i][j]);
        }
        v[i] = sum;
    }
    vector<int> dp(1<<n,INF);
    dp[0] = 0;
    rep(i,1<<n){
        rep(j,m){
            dp[i | v[j]] = min(dp[i | v[j]], dp[i] + a[j]);
        }
    }
    if(dp[(1<<n)-1]==INF){
        cout << -1 << endl;
    }else{
        cout << dp[(1 << n) - 1] << endl;
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
/*
  DP?????¨??????AOJ 2272????§£??????
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2272


  
*/


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

    char MAP[n][m];

    int i,j;
    for(i=0;i<n;i++){
	for(j=0;j<m;j++){
	    cin >> MAP[i][j];
	    // char????????°???int????????°??¨??????????????????
	    MAP[i][j]=MAP[i][j]-'0';
	}
    }
    
    
    int cost[n][m];
    cost[0][0]=0;
    for(j=1;j<m;j++)cost[0][j]=cost[0][j-1]+(int)MAP[0][j];
    for(i=1;i<n;i++)cost[i][0]=cost[i-1][0]+(int)MAP[i][0];
    //??????i,j??§???????????????????????????????????????????????????????????????????°????????????????????????????????¶?????????????
    for(i=1;i<n;i++){
	for(j=1;j<m;j++){
	    cost[i][j]=min(cost[i-1][j],cost[i][j-1])+(int)MAP[i][j];
	}
    }

    cout << cost[n-1][m-1] <<endl;
    return 0;
}

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

double expectation(int x) {
    return ((1.0 + (double)x) / 2.0);
}

int main() {
    std::cout<<std::fixed<<std::setprecision(100);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (ll i = 0; i < n; ++i) cin >> a.at(i);
    
    vector<double> sum(n);
    sum.at(0) = expectation(a.at(0));
    for (ll j = 1; j < n; ++j) sum.at(j) = sum.at(j - 1) + expectation(a.at(j));
    double p = 0;
    double ans = 0;
    for (ll l = 0; l < n - k + 1; ++l) {
        if (l == 0) p = sum.at(l + k - 1);
        else p = sum.at(l + k - 1) - sum.at(l - 1);
        ans = max(ans, p);
    }
    cout << ans << endl;
}


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

using namespace std;

bool Ok(double m, double x, double b, double a){
    double S=0;
    m=m/360.*2.*M_PI;
    if(tan(m)*b>=a){
        S+=a*a/2./tan(m)+a*(b-a/tan(m));
    }
    else{
        S+=b*b*tan(m)/2.;
    }
    return S >= x;
}

int main() {
    double a,b;
    cin>>a>>b;
    double x;
    cin>>x;
    int MAX=1000;
    double l=-1e-7;
    double r=90.+1e-7;
    x/=a;
    for(int i=0;i<MAX;i++){
        double m=(l+r)/2.;
        if(Ok(m, x, b, a)){
            r=m;
        }
        else l=m;
    }
    cout.precision(10);
    cout<<fixed<<(90.-r);
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#define N 100000
#define Q 50000
main(){
  int n,q,s[N],t[Q];
  int i,j,count=0;
  int left,right,mid;
 
  scanf("%d",&n);
  for(i=0; i<n; i++)
    scanf("%d",&s[i]);
  
  scanf("%d",&q);
  for(i=0;i<q; i++)
    scanf("%d",&t[i]);
  

  for(i=0; i<q; i++){
    left=0;
    right=n;
    while(left<right){
      mid=(left+right)/2;
      if(t[i]==s[mid]){
	count++;
	break;
      }
      if(t[i]>s[mid])
	left=mid+1;
      else if(t[i]<s[mid])
	right=mid;
    }
  }
  
  
  
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

int N;
double dp[303][303][303];

double dfs(int c1, int c2, int c3) {
    if (c1 == 0 && c2 == 0 && c3 == 0) {
        return 0.0;
    }
    if (dp[c1][c2][c3] >= 0.0) {
        return dp[c1][c2][c3];
    }
    double res = N;
    if (c1 > 0) {
        res += dfs(c1 - 1, c2, c3) * c1;
    }
    if (c2 > 0) {
        res += dfs(c1 + 1, c2 - 1, c3) * c2;
    }
    if (c3 > 0) {
        res += dfs(c1, c2 + 1, c3 - 1) * c3;
    }
    res *= 1.0 / (c1 + c2 + c3);
    return dp[c1][c2][c3] = res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    vector<int> A(N);
    int one = 0, two = 0, three = 0;
    rep(i, 0, N) {
        cin >> A[i];
        if (A[i] == 1) ++one;
        else if (A[i] == 2) ++two;
        else ++three;
    }
    int sum = one + two + three;
    rep(i, 0, sum + 1) rep(j, 0, sum + 1) rep(k, 0, sum + 1) {
        dp[i][j][k] = -1.0;
    }
    cout << fixed << setprecision(10) << dfs(one, two, three) << endl;
    return 0;
}

Measured memory_bytes: 217344
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N, M;
    cin >> N >> M;
    VI A(N);
    REP(i, N) cin >> A[i];

    int sum = 0;
    REP(i, N) sum += A[i];
    int cnt = 0;
    REP(i, N) {
        if (A[i] * 4 * M >= sum) {
            cnt++;
        }
    }

    cout << (cnt >= M ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var x = cin.nextInt();
            var y = cin.nextInt();

            var bill = new int[300];
            bill[0] = 0;
            bill[1] = 300000;
            bill[2] = 200000;
            bill[3] = 100000;

            var ans = 0;
            if(x == 1 && y == 1)
            {
                ans += 400000;
            }

            ans += bill[x] + bill[y];
            Console.WriteLine(ans);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N+ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }   

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

int main() {
  int K;
  string S;
  cin >> K >> S;
  
    if (S.size() <= K) {
      cout << S << endl;
    }
    else {
      for(int i = 0; i<K; i++){
        cout << S.at(i) ;
      }
      cout << "..." << endl;
    }
  
}

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

typedef long long ll;

vector<ll> a,p;

ll f(ll n, ll x){
	if(n==0) return (x<=0)?0:1;
	else if(x<=1+a[n-1]) return f(n-1,x-1);
	else return p[n-1]+1+f(n-1,x-2-a[n-1]);
}

int main(){
	ll n,x;
	cin >> n >> x;

	a.push_back(1);
	p.push_back(1);
	for(int i=0; i<n; i++){
		a.push_back(a[i]*2+3);
		p.push_back(p[i]*2+1);
	}
	
	cout << f(n,x) << endl;
	return 0;
}

Measured memory_bytes: 3616