akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define mod 1000000007
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
const int N=1e7;
void solve()
{
	int n;
	cin>>n;
	int ans=0;
	fora(i,1,n)
	{
		int a;
		cin>>a;
		if((i&1)&&(a&1))ans++;
	}
	cout<<ans<<endl;
}
int main()
{
	
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int t=1;
  	//cin>>t;
    while(t--)
   	solve();
}


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

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ar array
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod = 1e9 + 7;
const ll inf = 2e9 + 5;
double PI = 3.14159265358979323846;

void solve() {

    ld d,t,s;
    cin >> d >> t >> s;
    if(s < d/t){
        cout << "No";
    }else{
        cout << "Yes";
    }

}

int32_t main()
{
    IOS
    // int T; cin >> T; while (T--)
    solve();
    return 0;
}


Measured memory_bytes: 3736
n = int(input())
dp = [10 ** 18] * (n + 1)
dp[0] = 0

info = [[1, 1]]
for i in range(1, 10):
    info.append([6**i, 1])
for i in range(1, 10):
    info.append([9**i, 1])
    
for i in range(n):
    for w, v in info:
        if i + w >= n + 1:
            continue
        dp[i + w] = min(dp[i] + 1, dp[i + w])
print(dp[-1])

Measured memory_bytes: 41708
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("ride.in");ofstream coutt("ride.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 




signed main(){
    FASTER;
    int n;cin>>n;
    string s;cin>>s;
    if(n&1){
        cout<<"No";
    }else{
        if(s.substr(0,n/2)==s.substr(n/2)){
            cout<<"Yes";
        }else cout<<"No";
    }
}

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

bool eq(string &s, int i, string &t, int j) {
	if (i >= s.length()) return true;
	if (j >= t.length()) return true;
	if (s[i] == '?') return true;
	if (t[j] == '?') return true;
	if (s[i] == t[j]) return true;
	return false;
}

bool is_valid(string &A, string &B, int d) {
	for (int i = 0; i + d < A.length() && i < B.length(); i++) {
		if (eq(A, i + d, B, i) == false) return false;
	}
	return true;
}

void setFlag(string &A, string &B, bool flag[], int setLength) {
	for (int i = 0; i < setLength; i++) {
		flag[i] = is_valid(A, B, i);
	}
}

int solve(string &A, string &B, string &C) {
	bool I[2001] = {false};
	bool D[4001] = {false};
	bool J[4001] = {false};
	
	setFlag(A, B, I, A.length() + 1);
	setFlag(B, C, D, A.length() + B.length() + 1);
	setFlag(A, C, J, A.length() + B.length() + 1);
	
	//for (int i = 0; i < 20; i++) cout << I[i]; cout << endl;
	//for (int i = 0; i < 20; i++) cout << D[i]; cout << endl;
	//for (int i = 0; i < 20; i++) cout << J[i]; cout << endl;
	//cout << endl;
	
	int ret = 11451419;
	for (int i = 0; i <= A.length(); i++) {
		if (I[i] == false) continue;
		for (int j = i; j <= A.length() + B.length(); j++) {
			if (J[j] == false) continue;
			if (D[j - i]) {
				int res = max({(int)A.length(), (int)B.length() + i, (int)C.length() + j});
				ret = min(ret, res);
			}
		}
	}
	return ret;
}

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	
	int res1 = solve(a, b, c);
	int res2 = solve(a, c, b);
	int res3 = solve(b, a, c);
	int res4 = solve(b, c, a);
	int res5 = solve(c, a, b);
	int res6 = solve(c, b, a);
	int res = min({res1, res2, res3, res4, res5, res6});
	
	//cout << res1 << ", " << res2 << ", " << res3 << ", " << res4 << ", " << res5 << ", " << res6 << endl;
	cout << res << endl;
	return 0;
}

//自分の解法：
//文字列sのl文字目からr文字目を取ってきて文字列tを作ったとき、文字列sにおけるtの位置をlとする。
//文字列sにおける文字列a, b, cの位置をi0, j0, k0とおく(0≦i0,j0,k0)。このとき、i0, j0, k0のどれかは0である。
//よって、A,B,C = (a,b,c)の並べ替えとし、これを全て試すとしたとき、
//A,B,Cの文字列sにおける位置としては、0,i,j (0≦i≦j)の場合を考えれば十分である。
//
//i, jを固定する。このとき、
//条件を満たすsが存在すれば（validならば）sの長さはmax(|A|, |B|+i, |C|+j)が最小である。
//validの条件は、任意のk=0,1,2,…について、eq(A[k], B[k-i]) and eq(B[k-i], C[k-j]) and eq(A[k], C[k-j])となる。
//ただし、eq(x, y)は
//x == Null || y == Null || x == ? || y == ? || x == yである。(Nullは範囲外で文字が無いことを表す）
//!!! 推移律が成り立たないことに注意 !!!
//
//また、d = j - iとおくことで、validとは
//1. 任意のkについて、eq(A[k], B[k-i])     <-> 任意のkについて、eq(A[k+i], B[k])
//2. 任意のkについて、eq(B[k-i], C[k-i-d]) <-> 任意のkについて、eq(B[k+d], C[k])
//3. 任意のkについて、eq(A[k], C[k-j])     <-> 任意のkについて、eq(A[k+j], C[k])
//を全て満たすことと同値だと言える。
//
//1.を満たすようなi, 2.を満たすようなd, 3.を満たすようなjは互いに独立に決定でき、それぞれの集合をI, D, Jとおく。
//このとき、
//・I, D, Jからそれぞれ要素i, d, jを取ってくると
//・d = j - iを満たす <-> (i, d, j)の組み合わせがvalidとなる。また、そのようなものについて、
//・文字列sの長さの最小 = max(|A|, |B|+i, |C|+j)だった。よって、(i, j)を全部試し、条件を満たすdが存在するかを判定すれば良い。
//
//i, j(, d)として考えるべき値の最大値は、文字列の長さの最大値をN = max(|a|, |b|, |c|)とおくと、
//それぞれN, 2N(, 2N)くらいなので、O(N^2)で解ける。

Measured memory_bytes: 256
K,N = map(int, input().split())
A = list(map(int, input().split()))
x=A[0]

for l in range(N-1):
  if x<A[l+1]-A[l]:
    x=A[l+1]-A[l]

if x<K-A[N-1]+A[0]:
  x=K-A[N-1]+A[0]
print(K-x)

Measured memory_bytes: 25920
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
using namespace std;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<pair<int, int>>;
using VTIII = vector<tuple<int, int, int>>;
using Complex = complex<double>;
using LD = long double;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a==b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a==b)){ a=b; return true; } return false; }
template<typename T> inline bool isin(const T& x, const T& l, const T& r){ return l <= x and x < r; }
inline ostream& fcout(int n = 10){ return cout << fixed << setprecision(n); }
inline ostream& rcout(int n = 2){ return cout << right << setw(n); }
constexpr int64_t INF = numeric_limits<int64_t>::max();
constexpr int32_t INF32 = numeric_limits<int32_t>::max();
constexpr int64_t MOD = 1000000007LL;
constexpr long double PI = 3.14159265358979323846264338327950288;
constexpr double EPS = 1e-10;


int N;
string S[1000010];


int32_t main(){
    cin >> N;
    rep(i, 0, N) cin >> S[i];

    vector<PII> v;
    rep(i, 0, N){
        stack<char> s;
        rep(j, 0, SZ(S[i])){
            char t = ' ';
            if(!s.empty()) t = s.top();
            if(t == '(' and S[i][j] == ')') s.pop();
            else s.push(S[i][j]);
        }
        if(s.empty()) continue;
        string t;
        while(!s.empty()) t.push_back(s.top()), s.pop();
        reverse(ALL(t));
        int a = count(ALL(t), '(');
        int b = count(ALL(t), ')');
        if(b == 0) v.emplace_back(-INF, i);
       else if(a == 0) v.emplace_back(INF, i);
       else v.emplace_back(b-a, i);
    }

    sort(ALL(v));

    stack<char> s;
    rep(i, 0, SZ(v)){
        int u = v[i].second;
        rep(j, 0, SZ(S[u])){
            char t = ' ';
            if(!s.empty()) t = s.top();
            if(t == '(' and S[u][j] == ')') s.pop();
            else s.push(S[u][j]);
        }
    }

    if(s.empty()) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 51012
import java.util.Scanner;


public class Main {
	Scanner sc = new Scanner(System.in);
	
	void run(){
		char c[] = sc.next().toCharArray();
		int l = c.length;
		while(l-- != 0){
			System.out.print(c[l]);
		}
		System.out.println();
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

class aizu_judge
{
    static void Main()
    {
        int[] num = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine("{0} {1} {2:f5}", num[0] / num[1], num[0] % num[1], (double)num[0] / (double)num[1]);
    }
}

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

int main() {
  ll n,m;
  cin>>n>>m;
  ll ans=0;
  //////////////////
  if(n>m/2){
     ans=m/2;
  }
  else{
      m=m-2*n;
    ans=n+m/4;
      
  }
  cout<<ans<<endl;
}

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

#define IL __inline__ __attribute__((always_inline))

#define For(i, a, b) for (int i = a, i##end = b; i <= i##end; ++ i)
#define FOR(i, a, b) for (int i = a, i##end = b; i < i##end; ++ i)
#define Rep(i, a, b) for (int i = a, i##end = b; i >= i##end; -- i)
#define REP(i, a, b) for (int i = (a) - 1, i##end = b; i >= i##end; -- i)

typedef long long LL;

template <class T>
IL bool chkmax(T &a, const T &b) {
  return a < b ? ((a = b), 1) : 0;
}

template <class T>
IL bool chkmin(T &a, const T &b) {
  return a > b ? ((a = b), 1) : 0;
}

template <class T>
IL T mymax(const T &a, const T &b) {
  return a > b ? a : b;
}

template <class T>
IL T mymin(const T &a, const T &b) {
  return a < b ? a : b;
}

template <class T>
IL T myabs(const T &a) {
  return a > 0 ? a : -a;
}

const int INF = 0X3F3F3F3F;
const double EPS = 1E-10, PI = acos(-1.0);

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define OK DEBUG("Passing [%s] in LINE %d...\n", __FUNCTION__, __LINE__)
/*------------------------------header------------------------------*/

const int MAXN = 500 + 5;

int answer[MAXN][MAXN];

int main() {
  int k;
  scanf("%d", &k);
  if (k == 1) {
    printf("1\n1\n");
    exit(0);
  }
  int n = ((k + 3) / 4) << 1;
  for (int i = 0; i < n; i += 2) {
    FOR(j, 0, n) {
      answer[i][j] = (i + j) % n;
      answer[i + 1][j] = (i + 1 + j) % n >= k - n ? (i + 1 + j) % n : (i + 1 + j) % n + n;
    }
  }
  printf("%d\n", n);
  FOR(i, 0, n) {
    FOR(j, 0, n) {
      printf("%d ", answer[i][j] + 1);
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define P pair<long,long>
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){
    int n; cin>>n;
    vector<int> a(n*2);
    rep(i,n*2)cin>>a.at(i);
    sort(all(a));
    int ans=0;
    rep(i,n) ans+=a.at(i*2);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
main = putStrLn . solve . map read . words =<< getLine

solve :: [Int] -> String
solve [a, b]
    | a `mod` 3 == 0 = "Possible"
    | b `mod` 3 == 0 = "Possible"
    | (a + b) `mod` 3 == 0 = "Possible"
    | otherwise = "Impossible"


Measured memory_bytes: 508
#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

using pi = pair<int, int>;

typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update>Order_Set;

Order_Set X;

const int mxn = 2e5+100;
const int Mod = 1e9+7;

int arr[mxn], qs[mxn];
int bitOn[55];
map<int,int>Mp, cnt, op;
vector<int>Pi, Ans;
vector<int>G[mxn];
set<int>seet[mxn];

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

int visit[3][100005];
int n, k;

int main()
{
    ios::sync_with_stdio(false);

    int re[10][10] = {0};
    int n;
    cin>>n;
    for(int i=1 ; i<=n ; i++){
        int ld = i%10;
        int fd = i;
        while(fd > 9) fd/=10;
        re[fd][ld]++;
    }
    int Ans = 0;
    for(int i=1 ; i<=9 ; i++){
        for(int j=1 ; j<=9 ; j++){
            Ans+=(re[i][j]*re[j][i]);
        }
    }
    cout<<Ans<<endl;

    return 0;
}





Measured memory_bytes: 15488
#include <iostream>
#include <cmath>
#include <iomanip>
const double PI=acos(-1);
using namespace std;

int main(int argc, char *argv[])
{
  int a, b, c;
  cin >> a >> b >> c;
  cout << fixed;
  // S
  cout << setprecision(9) << (double)a*b*sin(PI*(double)c/180)/2.0 << endl;
  // L
  cout << setprecision(9) << (sqrt(pow((double)a, 2.0)+pow((double)b, 2.0)-2.0*(double)a*(double)b*cos(PI*c/180)) + (double)a +(double) b) <<  endl;
  // h
  cout << setprecision(9) << b*sin(PI*c/180) << endl;
  return 0;
}



Measured memory_bytes: 3460
#include <bits/stdc++.h>
using namespace std;
#define iinf 2000000000
#define linf 1000000000000000000LL
#define ulinf 10000000000000000000ull
#define MOD1 1000000007LL
#define hs 71LL
#define mpr make_pair
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef unsigned short US;
typedef pair < int , int > pii;
clock_t __stt;
inline void TStart(){__stt=clock();}
inline void TReport(){printf("\nTaken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);}
template < typename T > T MIN(T a,T b){return a<b?a:b;}
template < typename T > T MAX(T a,T b){return a>b?a:b;}
template < typename T > T ABS(T a){return a>0?a:(-a);}
template < typename T > void UMIN(T &a,T b){if(b<a) a=b;}
template < typename T > void UMAX(T &a,T b){if(b>a) a=b;}
char c[605][605];
int a[605][605],v[605][605];
int n;
int main(){
    // inputting start
    // 数据结构记得初始化！ n，m别写反！
    scanf("%d",&n);
    #ifdef LOCAL
        TStart();
    #endif
    // calculation start
    // 数据结构记得初始化！ n，m别写反！
    int i,j;
	for(i=0;i<n;++i) {
		scanf("%s",c[i]);
		for(j=0;j<n;++j){
			v[i][j]=v[i+n][j]=v[i][j+n]=v[i+n][j+n]=c[i][j]-'a';
		}
	}
	for(i=0;i<2*n;++i){
		for(j=0;j<2*n;++j){
			int &k=a[i][j];
			for(k=1;j+k<2*n && i+k<2*n;++k){
				if(v[i][j+k]!=v[i+k][j]) break;
			}
		//	cout<<a[i][j]<<'\t';
		}
		//cout<<endl;
	}
	int cnt=0;
	for(i=0;i<n;++i){
		for(j=0;j<n;++j){
			int k;
			for(k=0;k<n;++k){
				if(a[i+k][j+k]+k<n) break;
			}
			if(k==n) ++cnt;
		}
	}
	printf("%d\n",cnt);
    #ifdef LOCAL
        TReport();
    #endif
    return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int h = sc.nextInt(), w = sc.nextInt();
		for (int i = 0; i < h; i++) {
			String ss = sc.next();
			System.out.println(ss);
			System.out.println(ss);
		}
	}
}

Measured memory_bytes: 24020
#include <algorithm>
#include <cassert>
#include <iostream>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

int main() {
  int r;
  cin >> r;
  if (r < 1200) {
    cout << "ABC" << endl;
  } else if (r < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl enjoy_codeforces
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    lint a,b;std::cin>>a>>b;
    lint r=std::abs(a-b);
    std::cout<<(-1<=r&&r<=1?"Brown":"Alice")<<'\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<bitset>
#include<random>
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
typedef long long ll;

int main() {
	ll n;
	cin>>n;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];
	ll sum=accumulate(ALL(a),0);
	bitset<4000001> dp;
	dp[0]=1;
	REP(i,n) dp=dp|(dp<<a[i]);
	FOR(i,(sum-1)/2+1, 4000001) if(dp[i]==1) {
		cout<<i<<endl;
		return 0;
	}
}

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

using namespace std;

void solve() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> P(N, 0);
    for (int i = 0; i < Q; i++)
    {
        int a;
        cin >> a;
        a--;
        P[a]++;
    }
    
    for (int i = 0; i < N; i++)
    {
        if (P[i] + K - Q <= 0)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
        }
    }
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define N 300050
#define ll long long
#define x first
#define y second
#define all(v) v.begin(),v.end()
using namespace std;

int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
            cout.tie(NULL);
            int h,a;
            cin>>h>>a;
            int ans=0;
            while(h>0){
                h-=a;
                ans++;
            }
            cout<<ans;

            return 0;
}


Measured memory_bytes: 256
k, n = map(int, input().split())
a = list(map(int, input().split()))

#find distance
d_ls = []
for i in range(1, n):
  d = abs(a[i] - a[i-1])
  d_ls.append(d)

# final distance
d = k - sum(d_ls)
d_ls.append(d)

#delete maximum distance
d_ls.remove(max(d_ls))

print(sum(d_ls))


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

using namespace std;
using ll = long long;

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

	bool flg;
	cout << 0 << endl;
	string s;
	cin >> s;
	if (s == "Male") { flg = true; }
	else if (s == "Female") { flg = false; }
	else { return 0; }

	cout << N - 1 << endl;
	cin >> s;
	if (s == "Vacant") { return 0; }

	int low = 0, high = N - 1;
	for (int i = 0; i < 18; ++i) {
		int mid = (high + low) / 2;
		cout << mid << endl;
		cin >> s;
		if (s == "Vacant") { return 0; }

		if (flg) {
			if (mid % 2) {
				if (s == "Male") { high = mid; }
				else { low = mid; }
			} else {
				if (s == "Male") { low = mid; }
				else { high = mid; }
			}
		} else {
			if (mid % 2) {
				if (s == "Male") { low = mid; }
				else { high = mid; }
			} else {
				if (s == "Male") { high = mid; }
				else { low = mid; }
			}
		}
	}

	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\stdout", "w", stdout);
    }
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;

    //if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 256
from itertools import permutations
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))

array=[]

for i in range(1,n+1):
	array.append(i)

z=list(permutations(array,n))

a=z.index(p)
b=z.index(q)

print(abs((a+1)-(b+1)))

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define vpll        vector<pair<ll,ll>>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))


void solve(){
    int a[26]={0};
    string s;cin>>s;
    rep(i,0,s.length()){
        if(a[s[i]-'a']==1){
            cout<<"no";
            return;
        }
        a[s[i]-'a']++;
    }
    cout<<"yes";


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
bool visited[27]; 
signed main(){
	ios_base::sync_with_stdio(0);
	string s;
	cin>>s;
	for(int i=0;i<sz(s);i++) visited[s[i]-'a']=1;
	for(int i=0;i<26;i++){
		if(!visited[i]){
			cout<<char(i+'a');
			re 0;
		}
	}
	cout<<"None";
	re 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <vector>
#define MAX_R 100000
using namespace std;
int main(void) {
  int q;
  cin >> q;
  vector<int> l(q), r(q);
  for (int i = 0; i < q; i++) {
    cin >> l[i] >> r[i];
  }
  vector<bool> prime(MAX_R + 1, 1);
  vector<int> count(MAX_R + 1, 0);
  prime[0] = prime[1] = 0;
  for (int i = 2; i <= MAX_R; i++) {
    if (prime[i]) {
      for (int j = i * 2; j <= MAX_R; j += i) {
        prime[j] = 0;
      }
    }
  }
  for (int i = 3; i <= MAX_R; i++) {
    if (prime[i] && prime[(i + 1) / 2] && i % 2 == 1) {
      count[i] = count[i - 1] + 1;
    } else {
      count[i] = count[i - 1];
    }
  }
  for (int i = 0; i < q; i++) {
    cout << count[r[i]] - count[l[i] - 1] << endl;
  }
  return 0;
}

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

int main(void){
    int n,k;
    cin >> n >> k;
    vector<int>a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<bool>dp(k + 1);
    dp[0] = 0;
    for(int i = 1; i <= k; i++){
        for(int j = 0; j < n; j++){
            if((i - a[j]) >= 0 && !dp[i - a[j]]){
                dp[i] = 1;
                break;
            }
        }
    }
    if(dp[k]){
        cout << "First" << endl;
    }else
        cout << "Second" << endl;   
    return 0;
}

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

int main() {
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3 = x2 - (y2 - y1);
    int y3 = y2 + (x2 - x1);
    int x4 = x1 - (y2 - y1);
    int y4 = y1 + (x2 - x1);
    cout << x3 << " " <<  y3 << " " << x4 << " " << y4 << endl;
}

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

int h,w;
int X[4]={0,1,0,-1};
int Y[4]={-1,0,1,0};
char map[10][10];
string ans;

bool in(int y,int x){
  if(y<0 || x<0 || y>=h || x>=w)return false;
  return true;
}

char M(int muki){
  if(muki==0)return 'U';
  if(muki==1)return 'R';
  if(muki==2)return 'D';
  if(muki==3)return 'L';
}
void dfs(int y,int x,string s,int muki)
{
  int si=-1,sj=-1;
  for(int i=1;i<10;i++){
    int a=y+i*Y[muki],b=x+i*X[muki];
    if(!in(a,b))return;
    if(map[a][b]=='o'){
      si=a;
      sj=b;
      map[a][b]='.';
      s+=M(muki);
      if(s.length()>ans.length())ans=s;
      break;
    }
  }
  if(si!=-1 && sj!=-1){
    dfs(si,sj,s,muki);
    dfs(si,sj,s,(muki+1)%4);
    dfs(si,sj,s,(muki+3)%4);
    map[si][sj]='o';
  }
}
int main()
{
  int si,sj,muki;
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>map[i][j];
      if(map[i][j]!='.' && map[i][j]!='o'){
	si=i;
	sj=j;
	if(map[i][j]=='U')muki=0;
	if(map[i][j]=='R')muki=1;
	if(map[i][j]=='D')muki=2;
	if(map[i][j]=='L')muki=3;
	map[i][j]='.';
      }
    }
  }
  ans="";
  dfs(si,sj,"",muki);
  dfs(si,sj,"",(muki+1)%4);
  dfs(si,sj,"",(muki+3)%4);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1212
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var k = int.Parse(Console.ReadLine().Trim());
        var ret = 1;
        for (int i = 0; i < n; i++)
            if (ret * 2 < ret + k) ret *= 2;
            else ret += k;
        Console.WriteLine(ret);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int n,q; cin >> n >> q;
	// [S,T),X
	set<pair<int,pair<int,int>>> st;
	FOR(n){
		int s,t,x; cin >> s >> t >> x;
		// [s-x,t-x) are the starting positions of people that get stuck in this blockade
		st.insert({s-x,{1,x}});
		st.insert({t-x,{-1,x}});
	}
	FOR(q){
		int d; cin >> d;
		st.insert({d,{2,i}});
	}
	int ans[q];
	memset(ans,0,sizeof(ans));
	set<int> blocked;
	// if type 1 then add x to blocked
	// if type -1 remove from blocked
	// if type 2 then check if it is being blocked currently
	for(pair<int,pair<int,int>> xx : st){
		if(xx.second.first == 1){
			blocked.insert(xx.second.second);
		} else if(xx.second.first == -1){
			blocked.erase(xx.second.second);
		} else{
			if(blocked.empty()){
				ans[xx.second.second] = -1;
			} else{
				ans[xx.second.second] = *(blocked.begin());
			}
		}
	}
	for(int yy : ans) cout << yy << '\n';
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 51228
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
#include <atcoder/math>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()




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

	int t;
	cin >> t;
	rep(i, t) {
		int n, m, a, b;
		cin >> n >> m >> a >> b;
		cout << atcoder::floor_sum(n, m, a, b) << endl;
	}


	return 0;
}


Measured memory_bytes: 3636
from scipy.special import comb

def solve(num):
    ans = 0
    max_splitter = (num // 3) - 1
    for s in range(max_splitter + 1):
        if s == 0:
            ans += 1
        elif s == 1:
            ans += (num - 6) + 1
        else:
            sectors = s + 1
            mod = num - 3 * sectors
            ans += comb(mod + s, s, exact=True)
    return ans

src = int(input())
div = 10 ** 9 + 7
ans = solve(src)
print(ans % div)

Measured memory_bytes: 42404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

bool chmax(int &a, int b)
{
    if (b >= a)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int n;
    cin >> n;
    vector<bitset<10>> f(n);
    rep(i, n) rep(j, 10)
    {
        int a;
        cin >> a;
        f[i].set(j, a);
    }
    vvint p(n, vint(11));
    rep(i, n) rep(j, 11) cin >> p[i][j];

    int ans = INT32_MIN;
    for (int i = 1; i < 1024; i++)
    {
        bitset<10> b = i;
        int score = 0;
        rep(j, n)
        {
            int c = (f[j] & b).count();
            score += p[j][c];
        }
        chmax(ans, score);
    }

    cout << ans << endl;

    return 0;
}

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

int n,k;
string s,t;
int a[100005];

int main() {
  cin >> n;
  rep(i,n) cin >> a[i];
  bool ok=true;
  rep(i,n)if(a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0) ok=false;
  cout << (ok? "APPROVED" : "DENIED") << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (){
  int N;
  while (cin >> N && N > 0){
    int sum = 0;
    for (int i=1; i < N; i++){ //?¶?????§?????????°????¢???????
      int s = i;
      for (int j=s+1; s<N; j++) { //N??\?????????????????§??????????¶?????????????
	s += j;
      }
      if (s == N) //??´??£??????N????????£??????????????????
	sum += 1;
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 1160
N = int(input())
all = [1]
all.extend([9 ** i for i in range(1, 6)])
all.extend([6 ** i for i in range(1, 7)])
all.sort()
INF = 10 ** 12
dp = [INF] * (N + 1)
dp[0] = 0
def func_dp(n, k):
    if n - k >= 0:
        return dp[n - k]
    return INF
for i in range(1, N + 1):
    dp[i] = 1 + min([func_dp(i, j) for j in all])
print(dp[N])

Measured memory_bytes: 42476
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
using namespace std;
long int n;
#define PI 3.14159265358979323846  
int main() 
{

	double x, y, h, m;
	cin >> x >> y >> h >> m;
	double angle1 = m * 6;
	double angle2 = (h * 60 + m) * 0.5;
	double z = sqrt(x * x + y * y - x * y * 2 * cos(abs(angle1 - angle2) * PI / 180.0));
	printf("%0.20f", z);

}

Measured memory_bytes: 4100
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, M;
std::vector<ll> vs;
ll S[100010];

ll C( ll x )
{
  ll cnt = 0;

  rep( i, N )
  {
    ll c = vs.begin()+i+1-std::lower_bound( vs.begin(), vs.begin()+i+1, x-vs[i] );

    if( c >= 1 )
      cnt += 2*(c-1)+1;
  }

  return cnt;
}

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

  rep( i, N )
  {
    ll A;
    std::cin >> A;

    vs.emplace_back( A );
  }

  std::sort(all(vs));

  rep( i, N )
    S[i+1] = S[i]+vs[i];

  ll ng = vs[0]+vs[0]-1, ok = vs[N-1]+vs[N-1]+1;

  while( ok-ng > 1 )
  {
    ll mid = (ng+ok)/2;

    (C(mid) <= M ? ok : ng) = mid;
  }

  if( C(ok) < M )
    --ok;

  ll ans = 0, mi = INF, cnt = 0;

  rep( i, N )
  {
    ll idx = std::lower_bound( vs.begin(), vs.begin()+i+1, ok-vs[i] )-vs.begin();

    ans += 2*(S[i+1]-S[idx]+vs[i]*(i+1-idx));

    if( idx != i+1 )
    {
      ans -= 2*vs[i];

      cnt += 2*(i+1-idx-1)+1;

      chmin( mi, vs[i]+vs[idx] );
    }
  }

  if( cnt > M )
    ans -= (cnt-M)*mi;

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 1908
a,b,c,x,y = map (int,input().split())
max_xy = max(x,y)
count_x=0
count_y=0
p=0
p_min = c*2*max_xy

for i in range(0,max_xy+1):
    #c
    x_last = x-i
    y_last = y-i
    if x_last <0 : x_last=0
    if y_last <0 : y_last=0
    p = c*2*i + a*(x_last) + b*(y_last)
    p_min = min(p_min,p)
print(p_min)

Measured memory_bytes: 67448
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const int MOD = 1000000007;

struct mint
{
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD)
  {
  }
  mint operator-() const
  {
    return mint(-x);
  }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator^=(const mint a)
  {
    (x ^= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const
  {
    return mint(*this) += a;
  }
  mint operator-(const mint a) const
  {
    return mint(*this) -= a;
  }
  mint operator*(const mint a) const
  {
    return mint(*this) *= a;
  }
  mint operator^(const mint a) const
  {
    return mint(*this) ^= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const
  {
    return pow(MOD - 2);
  }
  mint &operator/=(const mint a)
  {
    return *this *= a.inv();
  }
  mint operator/(const mint a) const
  {
    return mint(*this) /= a;
  }
};
istream &operator>>(istream &is, const mint &a)
{
  return is >> a.x;
}
ostream &operator<<(ostream &os, const mint &a)
{
  return os << a.x;
}

struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < MOD);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main()
{
  long long N;
  scanf("%lld", &N);

  if (N == 1)
  {
    cout << 0 << endl;
    return 0;
  }
  mint sum = 1;
  mint zero = 1;
  mint nine = 1;
  mint t = 1;
  for (int i = 0; i < N; ++i)
  {
    sum *= 10;
    t *= 8;
    zero *= 9;
    nine *= 9;
  }
  cout << (sum - zero - nine + t) << endl;

  return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    long double a,b,h,m;
    cin >> a >> b >> h >> m;

    long double aco = cos((0.5 * (h*60+m)) * M_PI / 180);
    long double asi = sin((0.5 * (h*60+m)) * M_PI / 180);

    long double bco = cos((6.0 * m) * M_PI / 180);
    long double bsi = sin((6.0 * m) * M_PI / 180);

    long double x1 = a * aco;
    long double y1 = a * asi;
    long double x2 = b * bco;
    long double y2 = b * bsi;

    cerr << "("<<x1<<","<<y1<<")"<<endl;
    cerr << "("<<x2<<","<<y2<<")"<<endl;


    cout << sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)) << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};

const int NMAX=1000010; // we can calculate nCk until n is equal to NMAX
mint fact[NMAX],infac[NMAX];
void Make_Fact(){
  fact[0]=fact[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    fact[i]=fact[i-1]*(mint)i;
  }
}
void Make_InvFact(){
  infac[0]=infac[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    infac[i]=infac[i-1]/(mint)i;
  }
}
mint Comb(int n,int k){
  if(n<0||k<0||n-k<0) return 0;
  return fact[n]*infac[k]*infac[n-k];
}
mint Perm(int n,int k) {
  return fact[n]*infac[n-k];
}

int main()
{
  int n,m; cin >> n >> m;
  Make_Fact();
  Make_InvFact();
  mint res;
  rep(i,n+1) {
    if(i % 2 == 0) res += Comb(n, i) * Perm(m, i) * Perm(m - i, n - i) * Perm(m - i, n - i);
    else res -= Comb(n, i) * Perm(m, i) * Perm(m - i, n - i) * Perm(m - i, n - i);
  }
  cout << res.x << "\n";
  return 0;
}


Measured memory_bytes: 19228
#include<iostream>
using namespace std;
#include<algorithm>
#include<cmath>
#include<vector>
char a[60];
char b[60];
long long mod=1000000007;
int main()
{
	int n,i,j;
	long long sum;
	while(cin>>n)
	{
		vector<int>c;
		scanf("%s %s",a,b);
		for(i=0;i<n;i++)
		{
			if(a[i]==b[i])
				c.push_back(1);
			else
			{
				c.push_back(2);
				++i;
			}
		}
		if(c[0]==1)
			sum=3;
		if(c[0]==2)
			sum=6;
		for(i=1;i<c.size();i++)
		{
			if(c[i-1]==1)
				sum*=2;
			else if(c[i-1]==2&&c[i]==1)
				sum*=1;
			else if(c[i-1]==2&&c[i]==2)
				sum*=3;
		}
		sum=sum%mod;
		printf("%lld\n",sum);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
int main()
{
    int L,R,d,a=0,b=0,i;
    cin>>L>>R>>d;
    for (i = 0;i<=2*(R-L+1);++i) {
        if (((d*a)>=L)&&((d*a)<=R))
        {
            b++;
        }
        a++;
    }
    cout<<b;
    return 0;
}

Measured memory_bytes: 3620
N = int(input())
s = input()


def check_truth(a_0, a_1):
    a = [True for i in range(N)]  # True: Sheep, False: Wolf
    a[0] = a_0
    a[-1] = a_1
    for i in range(N):
        if a[i]:
            if s[i] == 'o':
                a[(i+1)%N] = a[i-1]
            else:
                a[(i+1)%N] = not a[i-1]
        else:
            if s[i] == 'o':
                a[(i+1)%N] = not a[i-1]
            else:
                a[(i+1)%N] = a[i-1]
    if a[0] != a_0 or a[-1] != a_1:
        return -1
    else:
        return a


p = [True, False]
for i in range(2):
    for j in range(2):
        ans = check_truth(p[i], p[j])
        if ans != -1:
            for k in range(N):
                if ans[k]:
                    print('S', end='')
                else:
                    print('W', end='')
            print()
            exit()
print(-1)

Measured memory_bytes: 5480
import java.util.Scanner;

public class Main{
  static int n;
  static int[] a;

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

    n = sc.nextInt();
    a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }

    int count = 0;
    for(int i = 0; i < n; i++){
      if(a[i] % 2 == 0){
        ++count;
      }
    }
    if(count == n){
      System.out.println("Yes");
      return;
    }


    int count2 = 0, count4 = 0;
    for(int i = 0; i < n; i++){
      if(a[i] % 4 == 0){
        ++count4;
      }
      else if(a[i] % 2 == 0){
        ++count2;
      }
    }

    if((n - (count2 / 2) * 2) / 2 <= count4){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 50340
def gcd(b, s):
    mod = b % s
    if mod != 0:
        return gcd(s, mod)
         
    else:
        return s
 
x, y = map(int, input().split())
b = max(x, y)
s = min(x, y)
a = gcd(b, s)
print(a)

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

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

class Vec;
Vec operator/(const Vec& v, const double& divisor);
Vec operator*(const double& scale, const Vec& v);

class Vec {
  using F = double;
  vector<F> container;

 public:
  Vec(size_t size) : container(size) {}
  Vec(initializer_list<F> elements)
      : container(elements.begin(), elements.end()) {}
  size_t dim() const { return container.size(); }
  F& operator[](const size_t size) { return container.at(size); }
  const F& operator[](const size_t size) const { return container.at(size); }
  Vec operator+(const Vec& other) const {
    Vec ret(*this);
    for (size_t i = 0; i < dim(); i++) ret[i] += other[i];
    return ret;
  }
  Vec operator-(const Vec& other) const { return (*this) + (-other); }
  Vec operator-() const { return -1.0 * (*this); }
  F inner(const Vec& other) const {
    F acc = 0;
    for (size_t i = 0; i < dim(); i++) {
      acc += (*this)[i] * other[i];
    }
    return acc;
  }
  F norm() const { return sqrt(inner(*this)); }
  Vec unit() const { return (*this) / this->norm(); }
  F ccw(const Vec& other) const {
    return (*this)[0] * other[1] - other[0] * (*this)[1];
  }
  Vec normal() const { return Vec({-(*this)[1], (*this)[0]}); }
};
Vec operator/(const Vec& v, const double& divisor) { return 1.0 / divisor * v; }
Vec operator*(const double& scale, const Vec& v) {
  Vec ret(v);
  for (size_t i = 0; i < ret.dim(); i++) ret[i] *= scale;
  return ret;
}

class Polygon {
  const vector<Vec>& vert;

 public:
  Polygon(const vector<Vec>& vert) : vert(vert) {}
  double area() const {
    const size_t n = vert.size();
    double acc = 0;
    for (size_t i = 0; i < n; i++) {
      acc += vert[i].ccw(vert[(i + 1) % n]);
    }
    return acc / 2.0;
  }
};

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

  vector<Vec> v;
  rep(i, n) {
    double x, y;
    cin >> x >> y;
    v.push_back(Vec({x, y}));
  }

  cout << fixed << setprecision(1) << Polygon(v).area() << endl;
  return 0;
}



Measured memory_bytes: 3292
#include <iostream>
#include <cstdio>

static const int P_MAX = 1000;
bool outed[P_MAX];
char buf[100];

int main(int argc, char* argv[]){
  while(true){
    int n, m;
    
    std::cin >> n >> m;
    
    if(n == 0 && m == 0){
      break;
    }
    
    for(int i = 0; i < n; i++){
      outed[i] = false;
    }
    
    int player = 0;
    int outed_count = 0;
    for(int i = 1; i < (m + 1); i++){
      if(outed_count < (n - 1) && outed[player]){
        while(outed[player]){
          player = (player + 1) % n;
        }
      }
      
      
      std::string str;
      std::cin >> str;
      
      if(outed_count >= (n - 1)){
        continue;
      }
      
      std::sprintf(buf,"%d", i);
      std::string fizzbuzz(i % 15 == 0 ? "FizzBuzz"
                                       : i % 5 == 0 ? "Buzz"
                                                    : i % 3 == 0 ? "Fizz"
                                                                 : buf);
      if(str != fizzbuzz){
        //std::cout << str << " " << player << std::endl;
        outed[player] = true;
        outed_count++;
      }
      
      player = (player + 1) % n;
    }
    
    bool first = true;
    for(int i = 0; i < n; i++){
      if(outed[i]){
        continue;
      }
      std::sprintf(buf,first ? "%d" : " %d", i + 1);
      std::cout << buf;
      if(first){first = false;}
    }
    std::cout << std::endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define MAX_N 1000

int n, m, ans;
int P[MAX_N+1];
vector<int> Q;

int BinarySearch(int q){
  int left = 0, right = Q.size();
  while(right - left > 1){
    int mid = (left + right) / 2;
    if(Q[mid] <= q) left = mid;
    else right = mid;
  }
  return left;
}

int main(void){
  while(cin >> n >> m && n != 0 && m != 0){
    P[0] = 0;
    for(int i = 1; i <= n; i++) cin >> P[i];
    Q.clear();
    for(int i = 0; i <= n; i++) for(int j = 0; j <= n; j++){
      int q = P[i] + P[j];
      Q.push_back(q);
    }
    sort(Q.begin(), Q.end());
    ans = 0;
    for(int i = 0; i < Q.size(); i++){
      if(Q[i] > m) break;
      int j = BinarySearch(m - Q[i]);
      int s = Q[i] + Q[j];
      if(s > ans) ans = s;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 5468