akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        boolean hasYellow = false;

        for (int i = 0; i < count; i++) {
            String color = sc.next();
            if (color.equals("Y")) hasYellow = true;
        }

        if (hasYellow) {
            System.out.println("Four");
        } else {
            System.out.println("Three");
        }
    }
}


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

int main()
{
  string S;
  cin >> S;
  char prev;
  bool flag = false;
  prev = S.at(0);

  for (int i = 1; i < S.size(); i++)
  {
    if (S.at(i) == prev)
    {
      flag = true;
      break;
    }
    prev = S.at(i);
  }
  
  if (flag) cout << "Bad" << endl;
  else cout << "Good" << endl;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>a>>b;
      if(a+b==15)Cout("+");
      else if(a*b==15)Cout("*");
      else Cout("x");
     

       
return 0;
}


Measured memory_bytes: 256
N = int(input())
T, A = [int(x) for x in input().split()]
H = list(map(int, input().split()))
min = 100000
result = 0

for i in range(N):
    if abs(A - (T-H[i]*0.006)) < min:
        min = abs(A - (T-H[i]*0.006))
        result = i+1

print(result)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define x first
#define y second
using namespace std;
const int N=100005;
int n,m,s,a[N];
int main(){
cin>>n>>m>>s;
if(s!=1e9){
    for(int k=1;k<=m;k++)
        a[k]=s;
    for(int k=m+1;k<=n;k++)
        a[k]=1e9;
    for(int k=1;k<=n;k++)
        cout<<a[k]<<' ';
}
else{
    for(int k=1;k<=m;k++)
        a[k]=s;
    for(int k=m+1;k<=n;k++)
        a[k]=1;
    for(int k=1;k<=n;k++)
        cout<<a[k]<<' ';
}
return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n, a[maxn], arrl, lazy, pos[maxn], val[maxn];
pair<int, int> arr[maxn];
deque<int> dq;

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

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < n; i++)
	{
		if (i && a[i] == a[i - 1])
			arr[arrl - 1].ss++;
		else
			arr[arrl++] = mp(a[i], 1);
	}
	/*for (int i = 0; i < arrl; i++)
		cerr << '@' << arr[i].ff << ' ' << arr[i].ss << endl;
	cerr << "__________________" << endl;*/

	for (int i = 1; i < arrl; i++)
		pos[i] = pos[i - 1] + arr[i - 1].ss;
	int head;
	if (arrl >= 2)
		head = (arr[arrl - 1].ff - arr[arrl - 2].ff + 1) % 2;
	else
		head = (arr[arrl - 1].ff + 1) % 2;
	for (int i = arrl - 2; i >= 0; i--)
	{
		int now = (arr[i].ss + 1) % 2, delta;
		if (i)
			delta = (arr[i].ff - arr[i - 1].ff - 1);
		else
			delta = arr[i].ff - 1;
		//cerr << '#' << i << ' ' << head << ' ' << now << endl;
		if (now == 0 && head == 0)
			lazy++;
		else if (now == 1 && head == 0)
		{
			lazy++;
			//cerr << "LAZY " << lazy << ':' << pos[i + 1] << endl;
			dq.pf(pos[i + 1] - lazy);
		}
		else if (now == 0 && head == 1)
		{
			lazy++;
			dq.pf(pos[i + 1] - lazy + 1);
		}
		else
			lazy++;
		lazy += delta;

		while (!dq.empty() && dq.back() + lazy >= n)
			dq.popb();

		head = 0;
		if (i)
		{
			head += arr[i].ff - arr[i - 1].ff - 1;
			head %= 2;
		}
		else
		{
			head += arr[i].ff - 1;
			head %= 2;
		}
	}
	//cerr << "END " << head << ' ' << dq.size() << endl;
	for (int i = 0; i < dq.size(); i++)
	{
		dq[i] += lazy;
		//cerr << '$' << dq[i];
	}
	//cerr << endl;
	val[0] = head;
	int pos = 0;
	for (int i = 1; i < n; i++)
	{
		if (pos < dq.size() && i == dq[pos])
		{
			pos++;
			val[i] = val[i - 1];
		}
		else
			val[i] = 1 - val[i - 1];
	}
	/*for (int i = 0; i < n; i++)
		cerr << '_' << val[i];
	cerr << endl;*/
	cout << (val[n - 1] ? "First" : "Second") << endl;
}



Measured memory_bytes: 2048
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int main(){
    ll R; cin >> R;
    cout<<setprecision(10)<< 2.0* 3.1415*R<<endl;
    return 0;
}


Measured memory_bytes: 3776
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	ll a;
	double b;
	cin >> a >> b;
	float x = b * 100;
	ll y = x;
	a *= y;
	a /= 100;
	cout << a<< endl;
	return 0;
}


Measured memory_bytes: 3712
#include<iostream>
using namespace std;
int t[1005];
int main(){
	int n,m;
	int a,b,c;
	int i,j,k;
	while(cin>>n>>m){
		if(!n)break;
		for(i=0;i<n;i++){
			cin>>t[i];
		}
		b=-1;
		for(i=0;i<n;i++){
			for(j=i+1;j<n;j++){
				a=t[i]+t[j];
				if(a>m)continue;
				if(a>b)b=a;
			}
		}
		if(b==-1)cout<<"NONE"<<endl;
		else cout<<b<<endl;
	}
}



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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

void get() {

}

class B105 {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n;
		in >> n;
		int sum = 0;
		for (int i = 1; i <= n; i += 2) {
			int num = 0;
			for (int j = 1; j * j <= i ; ++j) {
				if(i % j == 0) {
					if (i / j == j)num++;
					else num += 2;
				}
			}
			if(num == 8)sum ++;
		}
		out << sum << '\n';
	}
};


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

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <cstdio>
using namespace std;

struct NODE{
	int to;
	int bit;
	double cost;
	NODE(int to, double cost) : to(to) , cost(cost) {}
	NODE(int to, double cost,int bit) : to(to) , cost(cost) , bit(bit) {}
	NODE(){}
};
bool operator < (const NODE &a,const NODE &b){
	return a.cost > b.cost;
}
int main(){
	int t,n,m,s,g;
	while(cin >> t >> n >> m >> s >> g && t){
		s--;g--;
		int info[10];
		vector<NODE> v[31];
		for(int i = 0 ; i < t ; i++) cin >> info[i];
		for(int i = 0 ; i < m ; i++){
			int x,y,z;
			cin >> x >> y >> z;
			x--,y--;
			v[x].push_back(NODE(y,z));
			v[y].push_back(NODE(x,z));
		}
		bool used[31][1<<8] = {0};
		priority_queue<NODE> Q;
		Q.push(NODE(s,0,0));
		while(Q.size()){
			NODE q = Q.top(); Q.pop();
			if(used[q.to][q.bit]) continue;
			else used[q.to][q.bit] = true;
			if(q.to == g){
				printf("%.8f",q.cost);
				cout << endl;
				goto exit;
			}
			for(int i = 0 ; i < v[q.to].size() ; i++)
				for(int j = 0 ; j < t ; j++){
					if(q.bit>>j&1)continue;
					if(!used[v[q.to][i].to][q.bit|(1<<j)])
						Q.push(NODE(v[q.to][i].to, q.cost + v[q.to][i].cost / info[j] , q.bit|(1<<j) ) );
				}
		}
		cout << "Impossible" << endl;
		exit:;
	}
}

Measured memory_bytes: 7996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

const ll inf=1e9+7;

ll mult(ll n,ll m){//n^m%infを求める
    if(m==1){
        return n%inf;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%inf;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%inf;
    }
}

typedef pair<int,int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    string ans(s);
    rep(i,len(s)){
        if(s[i]=='A'){
            ans[i]='T';
        }else if(s[i]=='T'){
            ans[i]='A';
        }else if(s[i]=='C'){
            ans[i]='G';
        }else{
            ans[i]='C';
        }
    }
    for(auto itr:ans){
        cout<<itr<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int cnt = 0;
    rep(i, n) {
        int min_i = i;
        FOR(j, i, n) {
            if (a[j] < a[min_i]) min_i = j;
        }
        if (i!=min_i) {
            swap(a[i], a[min_i]);
            cnt++;
        }
    }

    rep(i, n) cout << a[i] << ((i<n-1) ? " " : "\n");
    cout << cnt << endl;
}


Measured memory_bytes: 3232
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

x_pls_y = []

for i in range(x):
    for j in range(y):
        x_pls_y.append(a[i]+b[j])
        
x_pls_y.sort(reverse=True)

xy_pls_z = []

for i in range(min(3000,x*y)):
    for j in range(z):
        xy_pls_z.append(x_pls_y[i]+c[j])
        
xy_pls_z.sort(reverse=True)

for i in range(k):
    print(xy_pls_z[i])

Measured memory_bytes: 151088
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool se(pair<int,int> x,pair<int,int> y){return x.second<y.second;}
int main(){
  int n,k;
  cin >> n >> k;
  long long int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);long long int sum=0,cnt=1,x;
  vector<pair<int,int>> v;
  for(int i=0;i<n;i++){
    if(cnt==1)x=a[i];
    if(x==a[i+1]) cnt++;
    if(x!=a[i+1]){
      v.push_back(make_pair(x,cnt));
      sum+=cnt;
       cnt=1;
    }
  }
  int s=v.size();
  if(s<=k) {
    cout << 0<<endl;
    return 0;
  }
  else{
  long long int ans=0,o=s;
  sort(v.begin(),v.end(),se);
  for(int i=0;i<s;i++){
    if(o<=k) {
      cout << ans <<endl; return 0;
    }
    o--;
    ans+=v[i].second;
  }
}
}


Measured memory_bytes: 3956
n=int(input())
al=[int(i) for i in input().split()]
bl=[int(i) for i in input().split()]
cl=[int(i) for i in input().split()]
cnt=sum(bl)
for i in range(n-1):
	if al[i]+1==al[i+1]:
		cnt+=cl[al[i]-1]
print(cnt)

Measured memory_bytes: 3064
n = gets.split(" ").map(&:to_i)

a = n[0]
b = n[0]
m = []

(0..a).each do |x|
  (0..b).each do |y|
    c = n[0] - x - y
    if c >= 0 and m.empty? and n[1] == 10000*x + 5000*y + 1000*c
      m << x
      m << y 
      m << c
    end
  end
end
if !m.empty?
  print m.join(' ')
elsif
  puts "-1 -1 -1"
end

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  repr(i, n, 0) {
    cin >> a[i];
    a[i]--;
  }

  vector<ll> path;
  set<ll> visited;
  ll now = 0;
  while (!visited.count(now)) {
    path.push_back(now);
    visited.insert(now);
    now = a[now];
  }

  int idx;
  for (int i = 0; i < path.size(); ++i) {
    if (path[i] == now) {
      idx = i;
      break;
    }
  }

  ll loop_start = idx;
  if (loop_start > k) {
    cout << path[k] + 1 << endl;
  } else {
    int loop_size = path.size() - loop_start;
    cout << path[(k - loop_start) % loop_size + loop_start] + 1 << endl;
  }
}

Measured memory_bytes: 15412
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int switch_n = Integer.parseInt(sc.next());
        int light_n = Integer.parseInt(sc.next());
        
        boolean[][] sw_to_light = new boolean[switch_n][light_n];
        
        for(int i=0;i<switch_n;i++){
            for(int j=0;j<light_n;j++){
                sw_to_light[i][j]=false;
            }
        }
        
        int connected_switch=0;
        int to_switch=0;
        for(int i=0;i<light_n;i++){
            connected_switch = Integer.parseInt(sc.next());
            for(int j=0;j<connected_switch;j++){
                to_switch = Integer.parseInt(sc.next());
                sw_to_light[to_switch-1][i] = true;
            }
        }
        
        boolean[] when_lit=new boolean[light_n];
        
        int tmp=0;
        for(int i=0;i<light_n;i++){
            tmp = Integer.parseInt(sc.next());
            if(tmp==1){
                when_lit[i]=true;
            }else{
                when_lit[i]=false;
            }
        }
        boolean[] light_state=new boolean[light_n];
        
        boolean all_lit=true;
        int count=0;
        
        for(int i=0;i <(1<<switch_n);i++){
            for(int j=0;j<light_n;j++){
                light_state[j]=false;
            }   //Initialization
            
            for(int j=0;j<switch_n;j++){
                if((i&(1<<j))>0){
                    for(int k=0;k<light_n;k++){
                        if(sw_to_light[j][k]) light_state[k]=!light_state[k];
                    }
                }
            }
            
            all_lit=true;
            for(int j=0;j <light_n;j++){
                if(light_state[j] != when_lit[j]) all_lit=false;
            }
            if(all_lit) count++;
        }
        
        //String s = sc.next();
        
        System.out.println(count);
    }
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int solve(int N, string &S){
	vector<char> X;
	char pre = '-';
	rp(i, 0, N){
		char s = S[i];
		if(pre != s){
			X.push_back(s);
			pre = s;
		}
	}
	return X.size();
}

int main(){
	int N; string S; cin>>N>>S;
	cout<< solve(N, S) <<endl;
}

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


int main() {
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> ans(n, 0);
    auto dis = [&](int a, int b) {
        return min(abs(a - b), min(abs(a - x) + abs(b - y), abs(a - y) + abs(b - x)) + 1);
    };
    for(int i = 1; i <= n; i++) {
        for(int j = i + 1; j <= n; j++) {
            ans[dis(i, j)]++;
        }
    }  
    for(int i = 1; i < n; i++) cout << ans[i] << '\n';
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

var C1, C2 string

func main() {
	fmt.Scan(&C1, &C2)

	if C1[0] == C2[2] && C1[1] == C2[1] && C1[2] == C2[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

/*  ----------------------------------------  */

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}
type SortBy []XY

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i].x == a[j].x {
		return a[i].y > a[j].y
	}
	return a[i].x > a[j].x
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>

#define ll long long
#define ld long double
#define ull unsigned long long
#define endl "\n"
#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define f(a, b, c) for(int a = b; a < c; a++)
#define fr(a, b, c) for(int a = b; a >= c; a--)
using namespace std;


//ll fact[1000001]; ll inv[1000001];
//ll primes[100007];
//ll arr[1000007];
//ll modPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//
//	ll halfpow = modPower(b, p / 2);
//	ll toReturn = (halfpow * halfpow) % mod;
//	if (p % 2)
//		toReturn = (toReturn * b) % mod;
//
//	return toReturn;
//}
//
//ll fastPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//	ll ans = fastPower(b, p / 2);
//	ans = (ans * ans);
//	if (p % 2 != 0)
//		ans = (ans * b);
//	return ans;
//}
//ll GcdRecursive(ll a, ll b) {
//	if (b == 0) return a;
//	return GcdRecursive(b, a % b);
//}
//ll modLCM(ll a, ll b) {
//	ll val = GcdRecursive(a, b);
//	ll tmp = ((a % mod) * (b % mod)) % mod;
//	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;
//	return finalVal;
//
//}
//ll LCM(ll a, ll b) {
//	return (a * b) / GcdRecursive(a, b);
//}
//void move1step(ll& a, ll& b, ll q) { // a and b by reference
//	ll c = a - q * b;
//	a = b;
//	b = c;
//}
//ll GcdIterative(ll a, ll b) {
//	while (b) move1step(a, b, a / b);
//	return a;
//}
//
//void pre(ll n) {
//
//	fact[0] = 1;
//	inv[0] = 1;
//
//	for (ll i = 1; i <= n; i++) {
//		fact[i] = (i * fact[i - 1]) % mod;
//		inv[i] = modPower(fact[i], mod - 2);
//		arr[i] = modPower(i, mod - 2);
//	}
//}
//
//ll npr(ll n, ll r) {
//	return ((fact[n] * inv[n - r]) % mod);
//}
//
//ll ncr(ll n, ll r) {
//	return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
//}
//
//void sieve(ll val) {
//	memset(primes, 1, sizeof primes);
//	primes[0] = primes[1] = false;
//	for (int i = 2; i <= val; i++) {
//		if (primes[i]) {
//			for (int j = i * i; j <= val; j += i) {
//				primes[j] = 0;
//			}
//		}
//	}
//
//}

const ll mod = 1e9 + 7;
const ll N = 3e3 + 7;
const ll inf = 1e9 + 5;





string s, t;
ll dp[N][N];
int main()
{
    MohamedMotaz;
    cin >> s >> t;
    memset(dp, 0, sizeof(dp));
    f(i, 1, s.size() + 1){
        f(j, 1, t.size() + 1){
            if (s[i - 1] == t[j - 1]){
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }else{
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    ll i = s.size(), j = t.size();
    string ans = "";
    while (i && j){
        if (dp[i][j] == dp[i - 1][j]) i--;
        else if (dp[i][j] == dp[i][j - 1]) j--;
        else{
            ans += s[i - 1];
            i--;
            j--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
}





Measured memory_bytes: 70912
#include <bits/stdc++.h>
#define N 1000500
using namespace std;
inline int rd() {
    int x=0,f=1;char ch=getchar();
    while (ch>'9'||ch<'0') {if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return x*f;
}
int n,k,mx,a[N];
int main() {
    n = rd(), k = rd();
    for (int _=1;_<=n;_++) a[_] = rd(), mx = max(mx, a[_]);
    int g = a[1];
    for (int _=2;_<=n;_++) g = __gcd(g, a[_]);
    if (k <= mx && (mx-k)%g == 0) puts("POSSIBLE"); else puts("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(void){
    int m[1000];
    int f[1000];
    int r[1000];
    char grade[1000];
    int i = 0;
    
    while(1){
        cin >> m[i] >> f[i] >> r[i];
        if(m[i] == -1 && f[i] == -1 && r[i] == -1){
            break;
        }
        ++i;
    }
    
    // ランクのを表示する
    for(int k = 0;k < i;++k){
        int totalScore = m[k] + f[k];
        if(m[k] == -1 || f[k] == -1){
            grade[k] = 'F';
        }
        else if(totalScore >= 80){
            grade[k] = 'A';
        }
        else if(totalScore >= 65){
            grade[k] = 'B';
        }
        else if(totalScore >= 50){
            grade[k] = 'C';
        }
        else if(totalScore >= 30 && r[k] >= 50){
            grade[k] = 'C';
        }
        else if(totalScore >= 30){
            grade[k] = 'D';
        }
        else{
            grade[k] = 'F';
        }
        
        cout << grade[k] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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

int main()
{
  INT(H);
  INT(W);
  INT(N);
  INT(y);
  INT(x);
  y--;
  x--;
  string S,T;
  cin >> S >> T;
  int aokiwinminx=0;
  int aokiwinmaxx=W-1;
  int aokiwinminy=0;
  int aokiwinmaxy=H-1;
  if(S[N-1]=='L') aokiwinminx++;
  if(S[N-1]=='R') aokiwinmaxx--;
  if(S[N-1]=='U') aokiwinminy++;
  if(S[N-1]=='D') aokiwinmaxy--;
  int flag = 0;
  REPR(i,N-2,0){
    if(T[i]=='L'){
      aokiwinmaxx=min(W-1,aokiwinmaxx+1);
    }else if(T[i]=='R'){
      aokiwinminx=max(0,aokiwinminx-1);
    }else if(T[i]=='U'){
      aokiwinmaxy=min(H-1,aokiwinmaxy+1);
    }else if(T[i]=='D'){
      aokiwinminy=max(0,aokiwinminy-1);
    }
    if(aokiwinmaxx<aokiwinminx||aokiwinmaxy<aokiwinminy){
      flag=1;
      break;
    }

    if(S[i]=='L'){
      aokiwinminx++;
    }else if(S[i]=='R'){
      aokiwinmaxx--;
    }else if(S[i]=='U'){
      aokiwinminy++;
    }else if(S[i]=='D'){
      aokiwinmaxy--;
    }    
    if(aokiwinmaxx<aokiwinminx||aokiwinmaxy<aokiwinminy){
      flag=1;
      break;
    }
  }

  if(aokiwinmaxx<x||aokiwinminx>x||aokiwinmaxy<y||aokiwinminy>y){
    flag=1;
  }


  if(flag==1){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 3924
a, b, c, d = map(int, list(input()))

N = 3
bcd = [b, c, d]
for i in range(2**N):
    tmp = a
    ch = str(a)
    for j in range(N):
        if i&1 == 0:
            tmp += bcd[j]
            ch += "+" + str(bcd[j])
        else:
            tmp -= bcd[j]
            ch += "-" + str(bcd[j])
        i >>= 1
    if tmp == 7:
        print(ch+"=7")
        break
    # print(ch)


Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main () {
  string s;
  cin >> s;
  if (s == "AAA" || s == "BBB"){
    cout << "No";
  }else{
    cout << "Yes";
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int A,B,C,X;
    cin >> A >> B >> C >> X;
    int ans=0;
    rep(i,A+1) rep(j,B+1) rep(k,C+1) if(500*i+100*j+50*k==X) ans++;
    cout << ans << endl;
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define Rep(i,n) for(ll i = 0; i <= n; i++)
#define REp(i,n) for(ll i = 1; i < n; i++)
#define REP(i,n) for(ll i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


struct UnionFind { // UnionFindTree
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int find(int x) {
    if(d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return false;
    if(-d[x] < -d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};


int main(){
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  V<V<int>> f(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    uf.unite(a,b);
    f[a].push_back(b);
    f[b].push_back(a);
  }
  V<V<int>> b(n);
  rep(i,k) {
    int c, d;
    cin >> c >> d;
    c--; d--;
    b[c].push_back(d);
    b[d].push_back(c);
  }
  rep(i,n) {
    int ans = uf.size(i);
    ans -= sz(f[i]);
    int cnt = 0;
    rep(j,sz(b[i])) {
      if(uf.same(i,b[i][j])) cnt++;
    }
    ans -= cnt;
    ans--;
    cout << ans << " ";
  }

}

Measured memory_bytes: 14700
#include "bits/stdc++.h"
using namespace std;

int n;
char c;
bool flag=false;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>c;
		if(c=='Y'){
			flag=true;
			break;
		}
	}
	if(flag==false)
		cout<<"Three";
	else
		cout<<"Four";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define fi first
#define se second


int main() {
    int n,m;
    cin>>n;
    vector<int>s(n);
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    cin>>m;
    vector<int>t(m);
    for(int i=0;i<m;i++){
        cin>>t[i];
    }

    sort(s.begin(),s.end());
    int ans=0;
    for(int i=0;i<m;i++){
        auto b = lower_bound(s.begin(), s.end(), t[i]);
        if(*b==t[i]){
            ans++;
        }
    }
    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 3356
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,k;
    scanf("%d%d%d",&a,&b,&k);
    int p=0;
    for(int i=100;i>=1;i--)
    {
        if(a%i==0&&b%i==0) p++;
        if(p==k)
        {
            cout<<i<<endl;return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>


using namespace std;

vector<pair<long, long>> prime_factorization(long n) {
    vector<pair<long, long>> res;

    for (long i = 2; i * i <= n; ++i) {
        if (n % i != 0) {
            continue;
        }

        long ex = 0;

        while (n % i == 0) {
            ex += 1;
            n = n / i;
        }

        res.emplace_back(i, ex);
    }

    if (n != 1) {
        res.emplace_back(n, 1);
    }

    return res;

}


long gcd(long a, long b) {
    if (a == 0)
        return b;
    if (b == 0)
        return a;


    if (a == b)
        return a;

    if (a > b)
        return gcd(a - b, b);
    return gcd(a, b - a);
}

int main() {

    long A, B;
    cin >> A >> B;

    long G = gcd(A, B);

    vector<pair<long, long>> ps = prime_factorization(G);

    long result = 1L + ps.size();

    cout << result << endl;

    return 0;

}

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

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double s = x/a;
  double rad;
  if (s >= a*b/2) {
    double h = (a*b-s)*2/a;
    rad = atan2(h,a);
  } else {
    double w = s*2/b;
    rad = atan2(b,w);
  }
  double PI = acos(-1);
  double deg = rad/(2*PI)*360;
  printf("%.10f\n", deg);
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define lli long long int 
#define pb push_back
#define vi vector<int>

int main()
{
	int n;
	cin>>n;
	int a[n+5];
	for( int i = 0; i < n; i++)
		cin>>a[i];

	lli ans = 0;
	for( int i = n-1; i >= 0; i-- )
	{
		if( a[i] > i || ( i != n-1 && a[i+1]-a[i] > 1 ) )
		{
			cout<<-1<<"\n";
			return 0;
		}
		else
		{
			if( i != n-1 && a[i] == a[i+1] - 1 )
				continue;
			else
			{
				ans = ans + a[i];
			}

		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 1024
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  foreach (i; 1..8) {
    auto p = 2 ^^ i;
    if (p > n) {
      writeln(2 ^^ (i - 1));
      break;
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  int r, g;
  scanf("%d %d", &r, &g);

  int ans = g * 2- r;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  a := nextString()

  count := 0
  for _, v := range a {
	  if string(v) == "1" {
		  count++
	  }
  }
  fmt.Println(count)
}

func nextString() (string) {
	sc.Scan()
	v := sc.Text()
	return v
}

func nextInt() (int) {
	sc.Scan()
	v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}

func nextFloat() (float64) {
	sc.Scan()
	v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}


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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

void solve(long long N, long long A, long long B) {
  cout << min(A,B) << " " << max(0ll, A + B - N) << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(N, A, B);
  return 0;
}


Measured memory_bytes: 256
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {

	long long A, B, K;

	cin >> A >> B >> K;

	for (long long i = A; i <= B; i++) {
		if ((i - A < K) || (B - i < K)) {
			cout << i << endl;
		}
	}

	return 0;

}

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

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long int   ll;
typedef long double     ld;
typedef pair<ll,ll>     pll;
typedef complex<ld>     cld;

#define all(x)          x.begin(),x.end()
#define Sort(x)         sort(all(x))
#define kill(x)         return cout << x << endl, 0;
#define Mp              make_pair
#define X               first
#define Y               second
#define sep             " "
#define endl            "\n"
#define fastio          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define ld_io           cout << setprecision(10) << fixed;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll pw(ll a, ll b, ll md) {
    if (!b)
        return 1;
    if (b & 1)
        return a * pw(a * a % md, b / 2, md) % md;
    return pw(a * a % md, b / 2, md) % md;
}

const ll MAXN = 1e3 + 10,
         INF  = 8e18,
         MOD  = 1e9 + 7,
         LOG  = 32;
//const ld PI   = M_PI;

ll n, m, mp[MAXN][MAXN], dp[MAXN][MAXN];
string s;

int main()
{
    fastio;
    //ld_io;

    cin >> n >> m;
    for (ll i = 1; i <= n; i++) {
        cin >> s;
        for (ll j = 1; j <= m; j++) {
            mp[i][j] = (s[j-1] == '.') ? 0 : 1;
        }
    }

    dp[0][1] = 1;
    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= m; j++) {
            if (mp[i][j]) continue;
            dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
        }
    }
    cout << dp[n][m] % MOD << endl;
    return 0;
}



Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> cnt(n);
    ll ans = 1;
    rep(i,n){
        if (a[i] == 0){
            ans *= 3 - cnt[a[i]];
        }else{
            ans *= (cnt[a[i]-1] - cnt[a[i]]);
        }
        cnt[a[i]]++;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3848
// AOJ 2301: Sleeping Time
// 2017.10.7 bal4u@uu

#include <stdio.h>
#include <math.h>

double p, e, t;

double combi(int k, double l, double r)
{
    double m = (l+r)/2.0;
    if (k == 0) return fabs(m-t) < e ? 1.0 : 0;
    if (l+e < t || t < r-e) return 0;
    if (l-e < t && t < r+e) return 1.0;
    if ((l+r)/2.0 >= t) return p*combi(k-1, m, r) + (1.0-p)*combi(k-1, l, m);
    else                return p*combi(k-1, l, m) + (1.0-p)*combi(k-1, m, r);
}
  
int main()
{
	int k, r, l;

	scanf("%d%d%d%lf%lf%lf", &k, &r, &l, &p, &e, &t);
	p = 1 - p;
	printf("%lf\n", combi(k, l, r));
	return 0;
}

Measured memory_bytes: 1828
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
//string b="12345";
//a = int(b[4]-48);
using namespace std;
int main()
{
	int N,f=0,ANS=0;
	string X;
	vector<pair<string, int>> A;
	cin >> N;

	for (int i = 0; i < N;i++) {
		pair<string, int> t;
		cin >> t.first;
		cin >> t.second;
		A.push_back(t);
	}
	cin >> X;
	for (int i = 0; i < N; i++) {
		if (X==A[i].first) {
			f = 1;
		}
		else if (f == 1) {
			ANS = ANS + A[i].second;
		}
	}
	cout << ANS << endl;
}

Measured memory_bytes: 256
import math
a,b,x = map(int,input().split())
if x <= a*a*b/2:
    print(90-math.degrees(math.atan2(2*x/(a*b),b)))
elif x > a*a*b/2:
    print(math.degrees(math.atan2(2*b-(2*x/(a**2)),a)))

Measured memory_bytes: 3060
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-9;
long double pi = acos(-1);

ll mod = 1e9+7;
template<typename T> void add(T &a,T b){a=(a+b)%mod;}
template<typename T> void sub(T &a,T b){a=(a+mod-b)%mod;}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int x,n;
    cin>>x>>n;
    int a[n];
    int used[1111]={};
    for(int i=0;i<n;i++){
        cin>>a[i];
        used[a[i]+111]=1;
    }
    int dif = 1e9;
    int ans = 0;
    for(int i=-111;i<111;i++){
        if(used[i+111])continue;
        if(chmin(dif,abs(x-i)))ans=i;
    }
    cout << ans << endl;
}

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

main()
{
	priority_queue<int> q;
	int n,k,m,i,j,len,ins;
	int flag=0;
	int cou=0;
	
	scanf("%d %d",&n,&k);
	ins=2*k+1;
	while(n>0)
	{
		n-=ins;
		cou++;
	}
	printf("%d",cou);
	
}

Measured memory_bytes: 256
A, B, C, D, E, F = map(int, input().split())

best = -1.0
a = ws = sg = 0

while 100 * a * A <= F:
    b = 0
    while True:
        w = 100 * (a * A + b * B)
        if w > F: break
        c = 0
        while w + c * C <= F and 100 * c * C <= w * E:
            d = 0
            while True:
                s = c * C + d * D
                if w + s > F or 100 * s > w * E:
                    break
                elif w + s != 0 and best < s / (w + s):
                    best = s / (w + s)
                    ws = w + s
                    sg = s
                d += 1
            c += 1
        b += 1
    a += 1
print(ws, sg)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    string s;
    cin>>s;
    bool flag=true;
    int n=s.size();
    rep(i,n){
        if(s[i]!=s[n-1-i])flag=false;
    }
    rep(i,n/2){
        if(s[i]!=s[n/2-1-i]){
            flag=false;
        }
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

using namespace std;
using ll = long long;

int main() {
    ll S;
    ll N = 1;
    cin >> S;
    while (S/(ll)pow(10,N)) {
        //cout << pow(10,N) << endl;
        //cout << S/pow(10,N) << endl;
        //cout << N << endl;
        N++;
    }
    //cout << N << endl;
    ll ans = 1000;

    for(int i = 0; i < N-2; i++) {
        ans = min(ans,abs(753 - (S/(int)pow(10,i))%1000));
    }
    cout << ans << endl;




    return 0;
}

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

using namespace std;

using ll = long long;

int main()
{	
	int n;
	vector<ll> v;
	cin >> n;
	vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, 0) );

	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		v.push_back(x);
	}

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

	cout << dp[0][n -1];
	return 0;	
}

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

const ll INF = 1e+18 + 10;
const int D = 60;
const int MAX_N = 2000005;
int to[D][MAX_N];

int main()
{
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> to[0][i];
        to[0][i]--;
    }

    for (int i = 0; i < D - 1; i++)
    {
        for (int j = 0; j < n; j++)
        {
            to[i + 1][j] = to[i][to[i][j]];
        }
    }

    int v = 0;
    for (int i = D - 1; i >= 0; i--)
    {
        ll l = 1ll << i;
        if (l <= k)
        {
            v = to[i][v];
            k -= l;
        }
    }

    cout << v + 1 << endl;

    return 0;
}

Measured memory_bytes: 50948
def g(N):
    if N%4==0:
        return N
    elif N%4==1:
        return 1
    elif N%4==2:
        return N+1
    else:
        return 0

def f(A,B):
    if A==0:
        return g(B)
    else:
        return g(A-1)^g(B)

A,B=map(int,input().split())
print(f(A,B))

Measured memory_bytes: 61972
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return 0
int main(){
    LL N;cin >> N;
    I vec1,vec2,vec3;
    REP(a,N){
        CIN(b);
        vec1.pb(b);
    }
    REP(a,N){
        CIN(b);
        vec2.pb(b);
    }
    REP(a,N){
        CIN(b);
        vec3.pb(b);
    }
    sort(ALL(vec1));
    sort(ALL(vec3));
    LL ans = 0;
    REP(a,N){
        LL one = lower_bound(ALL(vec1),vec2.at(a))-vec1.begin();
        LL three = upper_bound(ALL(vec3),vec2.at(a))-vec3.begin();
        ans += one*(N-three);
        //cout<<one<<" "<<N-three<<" "<<ans<<endl;
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 1912
#include<stdio.h>
char area[13][13];

int dfs(int nx, int ny){
	if(area[nx][ny] == '1'){
		area[nx][ny] = '0';
		if(area[nx-1][ny] == '1' && nx-1 >= 0){
			dfs(nx-1, ny);
		}
		if(area[nx+1][ny] == '1' && nx+1 <= 12){
			dfs(nx+1, ny);
		}
		if(area[nx][ny-1] == '1' && ny-1 >= 0){
			dfs(nx, ny-1);
		}
		if(area[nx][ny+1] == '1' && ny+1 <= 12){
			dfs(nx, ny+1);
		}
		return 1;
	}
	else{
		return 0;
	}
}

int main(void){
	int i, j;
	
	for(i = 0; i < 12; i++){
		for(j = 0; j < 12; j++){
			area[i][j] = '\n';
		}
	}
	while(1){
		int ans = 0;
		for(i = 0; i < 12; i++){
			if(scanf("%s", area[i]) != 1){
				return 0;
			}
		}
		
		for(i = 0; i < 12; i++){
			for(j = 0; j < 12; j++){
				if(dfs(i,j)){
					ans++;
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 544