akhauriyash/Code-Regression huggingface dataset:
// skip until line 65
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define MO(a) AS_MOD(a,mod)
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
struct Vec;
//set<int, Comparator> S;

// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
int main() {
    cout.precision(15);
    cout << fixed;
    ll A,V,B,W,T;
    cin >> A >> V >> B >> W >>T;

    if (abs(B-A) <=(V-W) *T) {
        cout << "YES"<<endl;
    } else {
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 3624
#include "iostream"
#include "vector"
using namespace std;

int main()
{
	int k;
	cin >> k;
	vector<int>a(k);
	for (int i = 0; i < k; i++)
		cin >> a[i];
	
	long long int max = 2, min = 2;

	for (int i = k - 1; i >= 0; i--) {
		max = max - max%a[i] + a[i] - 1;
		if (min%a[i] != 0)
			min = min - min%a[i] + a[i];
	}

	long long int checkmax = max, checkmin = min;

	for (int i = 0; i < k; i++) {
		checkmax = checkmax - checkmax%a[i];
		checkmin = checkmin - checkmin%a[i];
	}
	if (checkmax == 2 && checkmin == 2) {
		cout << min << " " << max << endl;
		return 0;
	}
	cout << -1 << endl;
	return 0;
}



Measured memory_bytes: 640
L,R = map(int,input().split())
if R - L >= 672:
  print(0)
else:
  l = L%2019
  r = R%2019
  if l > r:
    print(0)
  else:
    a = 2018
    for i in range(l,r):
      for j in range(i+1,r+1):
        a = min((i*j)%2019,a)
        if a == 1:
          print(a)
          exit()
    print(a)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define M 3010
#define MOD 1000000007
char s[M]; int sum[M];
int r[M];
int f[M][M];
int main() {
	int n, m; scanf("%d %d", &n, &m);
	scanf("%s", s + 1);
	for (int i = 1; i <= n; i ++) sum[i] = sum[i - 1] + (s[i] == '1');
	for (int i = 1; i <= n; i ++) r[i] = i;
	for (int i = 1; i <= m; i ++) {
		int x, y; scanf("%d %d", &x, &y);
		r[x] = max(r[x], y);
	}
	for (int i = 1; i <= n; i ++) r[i] = max(r[i - 1], r[i]);
	f[0][0] = 1;
	for (int i = 1; i <= n; i ++) {
		for (int j = 0; j <= sum[r[i - 1]]; j ++)
			if(f[i - 1][j]) {
				if(sum[r[i]] > j) (f[i][j + 1] += f[i - 1][j]) %= MOD;
				if(sum[r[i]] - j < r[i] - i + 1) (f[i][j] += f[i - 1][j]) %= MOD;
			}
	}
	cout << f[n][sum[n]];
	return 0;
}

Measured memory_bytes: 33920
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        ll N; cin >> N;
        ll ans = N - 1;
        rep1(i, 1, 1000010) {
            if (N % i == 0) {
                ans = min(ans, i + N / i - 2);
            }
        }
        cout<<ans<<endl;
return 0;
}



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

int main(){
    int n;
    cin >> n;
    vector<int> B;
    for(int i=0;i<n-1;++i){
        int b; cin >> b;
        B.push_back(b);
    }

    int a[n];
    fill(a, a+n, 10e8);
    for(int i=0;i<n-1;++i){
        a[i] = min(a[i], B[i]);
        a[i+1] = min(a[i+1], B[i]);
    }
    cout << accumulate(a, a+n, 0) << endl;

}


Measured memory_bytes: 256
import math
import fractions

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def bitlist(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

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

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

s = ""
for i in range(n):
    s+=a[i]
    s+=b[i]
print(s)

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



int main() {
  int N,id,sum = 0;
  double ave,sa = 100;
 
  cin >> N;

  int a[100];

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

  for(int i = 0;i < N;i++){
    sum = sum + a[i];
  }

  ave = (double)sum / N ;

  for (int i = 0;i < N;i++){
    if ( sa > abs(ave - a[i])){
      sa = abs(ave - a[i]);
      id = i;
    }
  }
  cout << id << endl;
}


Measured memory_bytes: 3552
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
l4,l2=[],[]
for k,v in c.items():
    if v>=4:l4.append(k)
    if v>=2:l2.append(k)
l4.sort(reverse=True)
l2.sort(reverse=True)
if len(l4)<=2:l4+=[0,0]
if len(l2)<=2:l2+=[0,0]
print(max(l4[0]*l4[1],l4[0]*l2[0],l2[0]*l2[1]))




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

#define pb push_back
#define ff first
#define ss second

const long long MAXN = 1e5 + 21, inf = 1e18 + 21, LG = 20;

int n;
int a[MAXN];
int nxt, tmp;
int ans;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
	cin >> a[i];

    int p = 0;
    while (p < n) {
	nxt = tmp = 1;
	for (int j = p + 1; j < n; j++) {
	    if (a[j] >= a[j - 1])
		nxt++;
	    else
		break;
	}
	for (int j = p + 1; j < n; j++) {
	    if (a[j] <= a[j - 1])
		tmp++;
	    else
		break;
	}

	p += max(tmp, nxt);
	ans++;
    }

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


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef pair<int, int> pi;

const int maxn = 2e5 + 5;
int c[maxn];

void add(int p, int v){
    for(int i = p;i < maxn;i += i & -i){
        c[i] += v;
    }
}

int sum(int p){
    int ret = 0;
    for(int i = p;i > 0; i -= i & -i){
        ret += c[i];
    }
    return ret;
}

string s;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> s;
    int n = s.length();
    long long ans = 0;
    for(int i = 0;i < n;i++){
        if(s[i] == 'B'){
            add(i + 1, 1);
        }else{
            ans += sum(i + 1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1300
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const int INF = 100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int A,B,C,D,E,F;cin >> A >> B >> C >> D >> E >> F;
    double maxi = 0.0;
    int WATER = A*100,SUGAR = 0;
    //水の入れる量を全探索
    for(int i = 0;i<=30;i++){
        for(int j = 0;j<=30;j++){
            if(i == 0 && j == 0) continue;
            int water = 100*A*i + 100*B*j;
            if(water > F) break;
            for(int k = 0;k<=1000;k++){
                for(int l = 0;l<=1000;l++){
                    int sugar = C*k+D*l;
                    if(water+sugar > F) break;
                    int border = E*(water/100);
                    if(border < sugar) break;
                    double per = ((double)100*sugar)/((double)water+sugar);
                    if(maxi < per){
                        WATER = water;
                        SUGAR = sugar;
                        maxi = per;
                    }
                }
            }
        }
    }
    cout << WATER+SUGAR << " " << SUGAR << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

static const ll MOD  = 1e9 + 7;
static const ll INF  = 1e18;
static const double EPS = 1e-10;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

int main(){
    int M, D;
    cin >> M >> D;
    int cnt = 0;
    for(int m = 1; m <= M; m++){
        for (int d = 1; d <= D; d++)
        {
            int d1 = d % 10;
            int d10 = (d - d1) / 10;
            if(d1 * d10 == m && d1 >= 2 && d10 >= 2) cnt++;
        }
    }
    cout << cnt << endl;
}

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

const int maxn = 100005;

int n, c, k;
int a[maxn];
int ans = 0;

void work() {
	for(int i=1; i<=n; i++) {
		ans ++;
		int take = c, t = a[i]+k;
		take --;
		while(a[i+1]<=t && take && i<=n) take--, i++;
	}
}

int main() {
	cin >> n >> c >> k;
	for(int i=1; i<=n; i++)
		cin >> a[i];
	sort(a+1, a+1+n);
	work();
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        boolean isOne = false;
        for (int i = 0; i < n; i++) {
            int temp = Integer.parseInt(sc.next());
            if (temp == 1) {
                isOne = true;
            }
            a[i] = temp;
        }
        if (!isOne) {
            System.out.println(-1);
            return;
        }
        int ans = 0;
        int num = 1;
        for (int i = 0; i < n; i++) {
            if (a[i] != num) {
                ans++;
            } else {
                num++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 51560
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x, ans=0;
    cin >> x;
    if(400<=x && x<=599) ans=8;
    else if(600 <=x && x<=799) ans=7;
    else if(800 <=x && x<=999) ans=6;
    else if(1000 <=x && x<=1199) ans=5;
    else if(1200 <=x && x<=1399) ans=4;
    else if(1400 <=x && x<=1599) ans=3;
    else if(1600 <=x && x<=1799) ans=2;
    else if(1800 <=x && x<=1999) ans=1;
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;
void solve(){
  int n; cin >> n;
  map<int, int> mp;
  for(int i = 2; i <= n; i++){
    int x = i;
    for(auto itr = mp.begin(); itr != mp.end();){
      if(x % itr->first == 0){
        itr->second++;
        x /= itr->first;
      }
      else itr++;
      if(x == 1) break;
    }
    if(x == i) mp[x]++;
  }
  unsigned long long ans = 1;
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    //cout << itr->first << " " << itr->second << endl;
    ans *= (itr->second + 1);
    ans %= 1000000007;
  }
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 256
#include<stdio.h>
//abc120-A
/*
int main(void)
{
	int a, b, c,d;
	scanf("%d %d %d", &a, &b, &c);

	if (b >= a * c)
	{
		printf("%d", c);
	}

	else
	{
		d = b / a;
		printf("%d", d);
	}
	return 0;
}
//abc120-B
int main(void)
{
	int a, b, k, tmp;
	int ans = 0, i, j;

	scanf("%d %d %d", &a, &b, &k);

	if (a < b)
	{
		tmp = a;
		a = b;
		b = tmp;
	}

	for (i = b; i > 0; i--)
	{
		if ((a % i + b % i) == 0)
		{
			ans += 1;
		}
		if (ans == k)
		{
			break;
		}

	}
	printf("%d", i);
	return 0;
}
//abc119-A
int main(void)
{
	int a, b, c;
	scanf("%d/%d/%d", &a, &b, &c);
	if (b < 5)
	{
		printf("Heisei");
	}
	else
	{
		printf("TBD");
	}

	
	return 0;
}
//abc119-b
int main(void)
{
	int a, i;
	float sum = 0;
	char s[15];
	float y;

	scanf_s("%d", &a);
	for (i = 0; i < a; i++)
	{
		scanf_s("%f", &y);
		scanf_s("%s", s, 15);
		if (strcmp(s, "JPY") == 0)
		{
			sum += y;
		}

		else
		{
			sum += y * 380000;
		}
	}
	printf("%f", sum);
	return 0;
}
//abc118-a
int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (b % a == 0)
	{
		printf("%d", a + b);
	}
	else
	{
		printf("%d", b - a);
	}

	return 0;
}*/

int main(void)
{
	int n,i,j,temp,total=0;
	int l[100];
	scanf("%d", &n);

	for (i = 0; i < n; i++)
	{
		scanf("%d", &l[i]);
	}

	for (i = 0; i < n; i++)
	{
		for (j = i + 1; j < n; j++)
		{
			if (l[i] < l[j])
			{
				temp = l[i];
				l[i] = l[j];
				l[j] = temp;
			}
		}
	}
	for (i = 1; i < n; i++)
	{
		total += l[i];
	}

	if (l[0] < total)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}



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

using namespace std;

int main(){

  int N, W;

  cin >> N >> W;
  
  vector <int> w(N);
  vector <int> v(N);
  long long dp[N][W+1] = {{0}};
  
  for(int i=0;i<N;i++){
    cin >> w[i] >> v[i];
  }

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

  cout << dp[N-1][W] << endl;

  return 0;
}

Measured memory_bytes: 78336
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn enum_primes(n: u64) -> Vec<u64>{
    let mut v: Vec<u64> = vec![];

    for i in 2..n+1{
        let mut is_prime = true;
        for div in 2..(i as f64).sqrt().ceil() as u64 + 1{
            if div < i && i%div == 0{
                is_prime = false;
                break;
            }
        }
        if is_prime{
            v.push(i);
        }
    }
    v
}

fn main(){
    let n = read_as_vec::<usize>()[0];

    let primes = enum_primes(55555);
    let primes5mod1 = primes.into_iter().filter(|x| x%5==1).collect::<Vec<u64>>();
    for i in 0..n{
        print!("{} ", primes5mod1[i]);
    }
    println!();
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef int32_t i32;

#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>=b;i--)
#define FILL(a,b,c) for(ll i=0;i<c;i++) a[i]=b;

#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()

#define endl "\n"
#define setpri(x) setprecision(x)
#define vp(x) cout<<#x<<" : "<< (x)<<" | "
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define forf(i,a,b) for(int i=a;i<b;i++)

#define INF 1e17+4
#define MINF 
#define MAX_INT 100000
#define MOD 1000000007
ll mod(ll n) { n %= MOD; if (n < 0) return n + MOD; else return n;}
// vector<int> adj[1000002];
// int vis[1000002],dep[1000002],siz[1000002];

// void dfs(ll cur,ll par)
// {
//     vis[cur]=1;siz[cur]=1;
//     for(auto x:adj[cur])
//     {
//         if(vis[x]!=1)
//         {
//             dep[x]=dep[cur]+1;
//             dfs(x,cur);
//             siz[cur]+=siz[x];
//         }    
//     }
// }

// bool sortfunc(const pair<int,int> &a, const pair<int,int> &b) 
// { 
//     return ;


void solve()
{
    int k;cin>>k;
    string s;
    cin>>s;
    if(k>=s.length())
        cout<<s<<endl;
    else
    {
        cout<<s.substr(0,k)+"...";
    }
        
}

signed main()
{
    FAST;
    
    // ll t;cin>>t;while(t--)
        solve();
 
    return 0;
}














Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

lint powint(lint x,lint y){
	if(y==0)return 1;
	if(y%2)return x*powint(x,y-1);
	lint a = powint(x,y/2);
	return a*a;
}

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;	
	double sum;
	cin>>n>>k;
	rep1(i,n){
		int num=1;
		while(num*i<k)num=num<<1;
		if(i<k)sum+=1.0/(num*n);
		else sum+=1.0/n;
	}
	dump(sum);
	printf("%.10f\n",sum);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>

#define max 4001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main()
{
    int n;
    double ans;
    
    scanf("%d", &n);
    
    if (n%2==0) {
        ans=(double)(n/2)/n;
    } else {
        ans=(double)(1+n/2)/n;
    }
    
    printf("%lf", ans);
    
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define de(x) cerr << #x << " = " << x << endl;

int main()
{
    int n, k, a,b;
    cin>>n>>k>>a>>b;
    cout << 1LL*a*min(k,n) + 1LL*max(0,n-k)*b;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool h[500000000];
int main(){
  int n,i,t=0,q[13];
  for(i=1;t<13;i*=5)q[t++]=i;
  cin>>n;
  while(n--){
    char a[10],b[14];
    scanf("%s %s",a,b);
    for(t=i=0;i<strlen(b);i++){
      if(b[i]=='A')t+=q[i]*1;
      if(b[i]=='C')t+=q[i]*2;
      if(b[i]=='G')t+=q[i]*3;
      if(b[i]=='T')t+=q[i]*4;
    }
    if(a[0]=='i')h[t]++;
    else{
      if(h[t])cout<<"yes"<<endl;
      else cout<<"no"<<endl;
    }
  }
}

Measured memory_bytes: 8424
def resolve():
    INF = 10 ** 18
    N, M = map(int, input().split())

    Box_key = []
    for i in range(M):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        s = sum(1 << (c - 1) for c in C)
        Box_key.append((s, a))

    # dp[i]: 集合iの宝箱を開ける最小コスト
    dp = [INF] * (1 << N)
    dp[0] = 0

    for s in range(1 << N):
        for i in range(M):
            ns = s | Box_key[i][0]
            cost = dp[s] + Box_key[i][1]
            dp[ns] = min(dp[ns], cost)

    if dp[(1 << N) - 1] == INF:
        print(-1)
    else:
        print(dp[(1 << N) - 1])


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 69576
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
const long long mod = 1000000007;
int ans[505][505];

void dfs(int l, int r, int level) {
	if (r - l < 1)return;
	int mi = (l + r) / 2;
	dfs(l, mi, level + 1);
	dfs(mi + 1, r, level + 1);
	for (int i = l; i <= mi; i++) {
		for (int j = mi + 1; j <= r; j++) {
			ans[i][j] = level;
		}
	}
	return;
}
void disp(int n) {
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			if (j != i+1)cout << ' ';
			cout << ans[i][j];
		}
		cout << endl;
	}
}

signed main() {
	int n; cin >> n;
	dfs(0, n - 1, 1);
	disp(n);
}

Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
using namespace std;

typedef long long ll;

int N,M; ll K; vector<ll> A,B;
void input()
{
    cin>>N>>M>>K;
    for(int i=0;i<N;++i){
        ll a; cin>>a; A.emplace_back(a);
    }
    for(int i=0;i<M;++i){
        ll a; cin>>a; B.emplace_back(a);
    }
}

void solve()
{
    vector<ll> sumA,sumB;
    sumA.emplace_back(0); sumB.emplace_back(0);
    ll sum=0;
    for(int i=0;i<N;++i){
        sum+=A[i];
        sumA.emplace_back(sum);
    }
    sum=0;
    for(int i=0;i<M;++i){
        sum+=B[i];
        sumB.emplace_back(sum);
    }
    // cout<<sumA[N-1]<<" "<<sumB[M]<<" "<<"\n";
    int ans=0; int maxj=M;
    for(int i=0;i<N+1;++i){
        if(sumA[i]>K) break;
        for(int j=maxj;j>=0;--j){
            if(sumA[i]+sumB[j]>K) continue;
            ans=max(i+j,ans);
            maxj=j;
            break;
            // cout<<sumA[i]<<" "<<sumB[j]<<" "<<i+j<<"\n";
        }
    }
    cout<<ans<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

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

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

  for(int i10 = 0; i10 <= N; i10++){
    for(int i5 = 0; i5 <= N - i10; i5++){
      int i1 = N - i5 - i10;
      if(i10 * 10000 + i5 * 5000 + i1 * 1000 == Y){
        cout << i10 << " " << i5 << " " << i1 << endl;
        return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

ul N, M,  T;
std::string S;
ul gcd(ul m, ul n) {
  if ((0 == m) || (0 == n)) return 0;
  while (m != n) {
    if (m > n)
      m = m - n;
    else
      n = n - m;
  }
  return m;
}  // gcd

ul lcm(ul m, ul n) {
  if ((0 == m) || (0 == n)) return 0;

  return ((m / gcd(m, n)) * n);  // lcm = m * n / gcd(m,n)
}  // lcm


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> S;
  if(S.size() !=2){
    std::reverse(S.begin(), S.end());
  }
  cout <<  S << endl;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <map>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i > (b); --i)
#define SZ(a) a.size()
#define ll long long
#define ull unsigned long long
using namespace std;



void str_sort(vector<string> &S, int N) {

	FOR(i, 0, N-1) {
		FOR(j, 0, N - 1 - i) {
			if (S[j] > S[j + 1]) {
				swap(S[j], S[j + 1]);
			}
		}
	}

}


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

	int N;
	int L;
	vector<string> S(110);
	cin >> N >> L;
	FOR(i, 0, N)
		cin >> S[i];

	str_sort(S, N);

	FOR(i, 0, N)
		cout << S[i];

	


	system("pause");
	return 0;
}

Measured memory_bytes: 504
object Main extends App {

  val Array(n, a, b) = io.StdIn.readLine.split(" ").map(_.toInt)

  val ans = (1 to n).par.foldLeft(0)( (acc,i) => {
      val sum = String.valueOf(i).map(_.asDigit).sum
      if(a <= sum && sum <= b ) acc + i else acc
    })

  println(ans)
}

Measured memory_bytes: 34772
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!(n:usize);
    println!("{}", n*(n+1)/2);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();    
    ArrayList<Integer> list = new ArrayList<>();
    int sum = 0;
    
    for(int i=0; i<N; i++) {
      list.add(sc.nextInt());
    }
    Collections.sort(list, Collections.reverseOrder());
    for(int j=0; j<list.size(); j++) {
      if(j % 2 == 0) {
        sum += list.get(j);
      } else {
        sum -= list.get(j);
      }
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 24276
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
int a[maxn],b[maxn];
long long dp[maxn];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        b[i]=a[i];
    }
    long long ans1=0,ans2=0;
    long long cur=0;
    for(int i=1;i<=n;i++){
        if(i%2==1){
            if(cur+a[i]<=0){
                ans1+=0-a[i]-cur+1;
                cur=1;
            }
            else{
                cur+=a[i];
            }
        }
        else{
            if(cur+a[i]>=0){
                ans1+=a[i]+cur+1;
                cur=-1;
            }
            else{
                cur+=a[i];
            }
        }
    }
    cur=0;
    for(int i=1;i<=n;i++){
        if(i%2==1){
            if(cur+a[i]>=0){
                ans2+=a[i]+cur+1;
                cur=-1;
            }
            else{
                cur+=a[i];
            }
        }
        else{
            if(cur+a[i]<=0){
                ans2+=0-a[i]-cur+1;
                cur=1;
            }
            else{
                cur+=a[i];
            }
        }
    }

    cout<<min(ans1,ans2)<<endl;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
from sys import stdin
import math

A = list(map(float, stdin.readline().split()))
a, b, c = A[0], A[1], A[2]

h = b * math.sin(math.pi * c / 180)
S = a * h / 2
d = math.sqrt(math.pow((a - (b * math.cos(c * math.pi / 180))), 2)+ math.pow(h, 2))
L = a + b + d

print(format(S,'.8f'))
print(format(L, '.8f'))
print(format(h, '.8f'))


Measured memory_bytes: 5704
#include <cstdio>
#include <iostream>
#include <string>

int main() {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (a + b == c || b + c == a || c + a == b) {
        puts("Yes");
    }
    else {
        puts("No");
    }
}

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

using namespace std;
using ll = long long;

ll solve(vector<ll> a){
	const int n = a.size();
	ll acc = 0, answer = 0;
	for(int i = 0; i < n; ++i){
		if(i % 2 == 0){
			const ll t = max(a[i], -acc + 1);
			answer += (t - a[i]);
			acc += t;
		}else{
			const ll t = min(a[i], -acc - 1);
			answer += (a[i] - t);
			acc += t;
		}
	}
	return answer;
}

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	const ll x = solve(a);
	for(int i = 0; i < n; ++i){ a[i] *= -1; }
	const ll y = solve(a);
	cout << min(x, y) << endl;
	return 0;
}



Measured memory_bytes: 1804
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main{
	
	static long mod = (int)1e9 + 7;
	

	public static void main(String[] args) throws Exception{

		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = fs.nextInt();
		int m = fs.nextInt();
		
		Node[] nodes = new Node[n];
		for(int i=0;i<n;i++) nodes[i] = new Node();
		
		for(int i=0;i<m;i++) {
			int a = fs.nextInt()-1, b = fs.nextInt()-1;
			if(nodes[a].set.add(b)) nodes[a].adjList.add(b);
			if(nodes[b].set.add(a)) nodes[b].adjList.add(a);
		}
		
		int ans = 0;
		
		for(int i=0;i<n;i++) {
			ans = Math.max(ans, dfs(nodes,nodes[i]));
		}
		
		out.println(ans);
		
		out.close();
		
		

		
	}
	
	static int dfs(Node[] nodes, Node node) {
		if(node.visited) return 0;
		int count = 1;
		node.visited = true;
		for(int i: node.adjList) {
			if(!nodes[i].visited) {
				count += dfs(nodes,nodes[i]);
			}
		}
		return count;
	}
	
	static class Node{
		ArrayList<Integer> adjList = new ArrayList<Integer>();
		HashSet<Integer> set = new HashSet<Integer>();
		boolean visited = false;
		
	}
	
	
	
	
	
	static class FastScanner{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		public String next(){
			while(!st.hasMoreElements()){
				try{
					st = new StringTokenizer(br.readLine());
				} catch(IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		
		public String nextLine() throws IOException {
			return br.readLine();
		}
		
		public int nextInt(){
			return Integer.parseInt(next());
		}

		public int[] readArray(int n){
			int[] a = new int[n];
			for(int i=0;i<n;i++)
				a[i] = nextInt();
			return a;
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
	


}

Measured memory_bytes: 163440
import java.util.*;
import java.io.*;
public class Main {
     public static void main(String[] args){
          Scanner sc =new Scanner(System.in);
int n = sc.nextInt();
int a = sc.nextInt();
if(n%500 <= a)
System.out.println("Yes");
else 
System.out.println("No");
}
}


Measured memory_bytes: 21716
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

int mi = 10000;

void dfs(int x, int v, int vs, int cov, const vector<int> &links) {
  if (v >= x) {
    return;
  }
  if (mi <= __builtin_popcount(vs)) {
    return;
  }
  //cout << "dfs(" << x << "," << v << "," << vs << ")" << endl;
  // cover without v
  if (links[v] != 0) {
    dfs(x, v + 1, vs, cov, links);
  }
  //cover with v
  vs |= 1 << v;
  cov |= 1 << v;
  cov |= links[v];
  if (cov == (1 << x) - 1) {
    mi = min(mi, __builtin_popcount(vs));
    return;
  }
  REP(i, v + 1, x) {
    if (vs & (1 << i)) {
      continue;
    }
    dfs(x, i, vs, cov, links);
    break;
  }
  return;
}


int solve(int x, const vector<PI> &edges, const VI &links) {
  ll es = 0;
  mi = x;
  dfs(x, 0, 0, 0, links);
  return mi;
}


int main(void){
  int x, y;
  while (cin >> x >> y && (x || y)) {
    vector<PI> edges;
    vector<int> link(x);
    REP(i, 0, y) {
      int a, b;
      cin >> a >> b;
      edges.push_back(PI(a, b));
      link[a] |= 1 << b;
      link[b] |= 1 << a;
    }
    cout << solve(x, edges, link) << endl;
  }
}

Measured memory_bytes: 3020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;

string s;
int n, a[100009];
ll f[100009][20];

int main(){
    cin >> s;
    n = s.length();
    for(int i = 1; i <= n; i++){
        a[i] = (s[i - 1] == '?' ? -1 : s[i - 1] - '0');
    }
    if(a[1] == -1) for(int i = 0; i <= 9; i++) f[1][i] = 1;
    else f[1][a[1]] = 1;
    for(int i = 2; i <= n; i++){
        if(a[i] == -1){
            for(int j = 0; j <= 9; j++){
                for(int k = 0; k <= 12; k++){
                    (f[i][(((k*10)%13)+j)%13] += f[i - 1][k] % mod) %= mod;
                }
            }
        }
        else{
            for(int j = 0; j <= 12; j++){
                (f[i][(((j*10)%13)+a[i])%13] += f[i - 1][j] % mod) %= mod;
            }
        }
    }
    printf("%lld\n", f[n][5] % mod);
    return 0;
}

Measured memory_bytes: 16512
# abc143_c.py
# https://atcoder.jp/contests/abc143/tasks/abc143_c

# C - Slimes /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 300点

# 問題文
# N匹のスライムが横一列に並んでいます。
# これらの色に関する情報が、長さ N の英小文字から成る文字列 S で与えられます。
# 左から i 番目のスライムは、 S の i文字目に対応する色を持っています。
# 同じ色を持ち隣接するスライムは融合し、色は変わらずに 1
# 匹のスライムとなります。このとき、融合した後のスライムは、融合する前の各スライムが隣接していた他のスライムと隣接した状態になります。
# 最終的に存在するスライムは何匹となるでしょうか。

# 制約
#     1≤N≤105
#     |S|=N
#     Sは英小文字から成る

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# S

# 出力
# 最終的に存在するスライムの数を出力せよ。

# 入力例 1
# 10
# aabbbbaaca

# 出力例 1
# 5

# 最終的に残るスライムを文字列で表すと、abacaとなります。

# 入力例 2
# 5
# aaaaa

# 出力例 2
# 1

# 全てのスライムが融合します。

# 入力例 3
# 20
# xxzaffeeeeddfkkkkllq

# 出力例 3
# 10


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    S = lines[1]
    N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    prev = ''
    cnt = 0

    for char in S:
        if prev != char:
            cnt += 1
            prev = char

    return [cnt]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['10', 'aabbbbaaca']
        lines_export = [5]
    if pattern == 2:
        lines_input = ['5', 'aaaaa']
        lines_export = [1]
    if pattern == 3:
        lines_input = ['20', 'xxzaffeeeeddfkkkkllq']
        lines_export = [10]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9396
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };
int main(){
    int H,W;
    cin>>H>>W;
    string A[H];
    rep(i,H) cin>>A[i];

    vector<vector<int>> dist(H,vector<int>(W,-1));
    queue<pair<int,int>> que;
    rep(y,H){
    rep(x,W){
        if(A[y][x]=='#'){
            dist.at(y).at(x)=0;
            que.push(mp(y,x));
        }
    }
    }
    while(!que.empty()){
        pair<int,int> n=que.front();
        que.pop();
        rep(i,4){
            int nx=n.S+dx[i], ny=n.F+dy[i];
            if(nx<0 || ny<0 || nx>=W || ny>=H) continue;
            if(dist.at(ny).at(nx)>=0) continue;
            if(A[ny][nx]=='#') continue;

            dist.at(ny).at(nx)=dist.at(n.F).at(n.S)+1;
            que.push(mp(ny,nx));
        }
    }
    int ans=0;
    rep(i,H){
        rep(j,W){
            ans=max(ans,dist.at(i).at(j));
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 13456
#include<iostream>

int main(){
    long int N, A, B, C, D, E;
    std::cin >> N >> A >> B >> C >> D >> E;

    long int min = std::min(std::min(std::min(std::min(A, B), C), D), E);

    int ans;
    if(min >= N){
        std::cout << 5;
        return 0;
    }
    
    if(N % min == 0){
        std::cout << N / min + 4;
        return 0;
    }
    std::cout << N / min + 5;
    
}

Measured memory_bytes: 256
# !/usr/bin/python3

"""
https://atcoder.jp/contests/abc152/tasks/abc152_b
Comparing starings.
"""

def solve(n, m):
    if n > m: print(f"{m}"*n)
    elif m >= n: print(f"{n}"*m)

    return

if __name__ == "__main__":
    n, m = list(map(int, input().split()))

    solve(n, m)


Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


bool isVowel(char c){
    return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}


bool prime[1000050];
void sieve() {
    fill(prime, prime + 1000050, 1);
    prime[0] = prime[1] = 0;

    for (int i = 2; i < 1000050; i++) {
        if (prime[i]) {
            for (int j = i * 2; j < 1000050; j += i) {
                prime[j] = 0;
            }
        }
    }
}

void mul(ll a[2][2], ll b[2][2]) {
    ll p = a[0][0] * b[0][0] + a[0][1] * b[1][0];
    ll q = a[0][0] * b[0][1] + a[0][1] * b[1][1];
    ll r = a[1][0] * b[0][0] + a[1][1] * b[1][0];
    ll s = a[1][0] * b[0][1] + a[1][1] * b[1][1];

    a[0][0] = p % mod;
    a[0][1] = q % mod;
    a[1][0] = r % mod;
    a[1][1] = s % mod;
}



int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int n;
    string s;
    cin >> n >> s;

    cout << ((count(s.begin(), s.end(), 'R') > count(s.begin(), s.end(), 'B')) ? "Yes" : "No");

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl

using namespace std;
using ll = long long;


int main() {
  int x, n; cin >> x >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  sort(all(p));

  vector<int> q;
  q.push_back(0);
  for (int i = 1; i <= 100; i++) {
    bool exist = false;
    rep(j, n) {
      if (p[j] == i) {
        exist = true;
        break;
      }
    }
    if (!exist) q.push_back(i);
  }
  q.push_back(101);

  int ans = q[0];
  int dist = abs(x - q[0]);

  rep(i, q.size()) {
    if (abs(x - q[i]) < dist) {
      ans = q[i];
      dist = abs(x - q[i]);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3632
import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	void run() throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long l = sc.nextLong();
		long t = sc.nextLong();
		long[] x = new long[n];
		long[] w = new long[n];
		long[] v = new long[n];
		long[] p = new long[n];
		int shift = 0;
		for (int i = 0; i < n; ++i) {
			x[i] = sc.nextLong();
			w[i] = sc.nextLong();
			v[i] = w[i] == 1 ? 1 : -1;
			p[i] = (x[i] + v[i] * t % l + l) % l;
			if (v[i] < 0) {
				shift += (l - x[i] + (-v[i]) * t - 1) / l % n;
			} else {
				shift -= (x[i] + v[i] * t) / l % n;
			}
			shift %= n;
		}
		while (shift < 0)
			shift += n;
		Arrays.sort(p);
		long[] ans = new long[n];
		for (int i = 0; i < n; ++i) {
			ans[i] = p[(i - shift + n) % n];
		}
		for (int i = 0; i < n; ++i) {
			System.out.println(ans[i]);
		}

	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 102636
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}

const M = 1000000007

func Solve() {
  var N int
  NextInt(&N)
  var P, X []int
  NextIntVec(&P)
  NextIntVec(&X)
  T := make([][]int, N)
  DP := make([][][]int, N)
  for i := range T {
    T[i] = make([]int, 2)
    T[i][0] = X[i]
    DP[i] = make([][]int, 2)
    for j := range DP[i] {
      DP[i][j] = make([]int, X[i] + 1)
      for k := range DP[i][j] { DP[i][j][k] = M }
    }
    DP[i][0][0] = 0
  }
  ans := "POSSIBLE"
  for i := N - 1; 0 <= i; i-- {
    T[i][1] = MinInt(DP[i][0]...)
    if T[i][1] == M {
      ans = "IMPOSSIBLE"
      break
    }
    if i == 0 { break }
    p := P[i - 1] - 1
    for k := range DP[p][1] { DP[p][1][k] = M }
    for j, t := range T[i] {
      for k := range DP[p][0] {
        if X[p] < k + t { break }
        DP[p][1][k + t] = MinInt(DP[p][0][k] + T[i][1 - j], DP[p][1][k + t])
      }
    }
    for k := range DP[p][1] { DP[p][0][k] = DP[p][1][k] }
  }
  Write(ans)
  return
}

func main() {
  Solve()
  Output()
}

Measured memory_bytes: 42624
module Main (main) where

import Control.Monad
import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe

main :: IO ()
main = do
  [[a],[b],[c],[d]] <- replicateM 4 readInts
  print . showAnswer $ solve (a,b,c,d)

type Input  = (Int, Int, Int, Int)
type Output = Int

solve :: Input -> Output
solve (a,b,c,d) = min a b + min c d

showAnswer :: Output -> Answer
showAnswer = Number

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)    = bool "No" "Yes" b
  show (YESNO b)    = bool "NO" "YES" b
  show (AB b)       = bool "B"  "A" b
  show (Number i)   = show i
  show (String s)   = s
  show (Compare o)  = ordering "<" "=" ">" o
  show (Compare2 o) = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

Measured memory_bytes: 380
#include<bits/stdc++.h>
#define ll long long
#define mod (ll)(1e9+7)
using namespace std;
const int maxn =2e5+5;
char m[maxn];
int main()
{

  cin>>m;
  ll ans=0,k=0;
  for(ll i=0;m[i]!='\0';i++)
  {
      if(m[i]=='B')
        k++;
      else
        ans+=k;
  }
  cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    string s;
    cin >> s;
    if(s=="RSR") print(1);
    else{
        int ctr=0;
        rp(i,3){
            if(s[i]=='R') ctr++;
        }
        print(ctr);
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3644