akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main( void ) {
	int i, n, a[ 10 ], bTop, cTop;

	for ( scanf( "%d", &n ); n--; puts( i == 10 ? "YES" : "NO" ) ) {
		for ( i = 0; i < 10; i++ )
			scanf( "%d", a + i );

		bTop = cTop = 0;
		for ( i = 0; i < 10; i++ )
			if ( a[ i ] > bTop )
				bTop = a[ i ];
			else if ( a[ i ] > cTop )
				cTop = a[ i ];
			else
				break;
	}

	return 0;
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define pd pair<double, double>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define DBG(v) cerr << #v << " = " << (v) << endl;
ll INF = (1ll<<61);

using namespace std;

int main(int argc, char* argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll a, b; cin >> a >> b;
    for(int x = 1; x < 1e6; x++){
      if((int) (x * 0.08) == a && (int) (x * 0.1) == b){
        cout << x << endl; return 0;
      }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int a = x > y ? x : y;
        int b = x > y ? y : x;
        while(b != 0){
            int c = a % b;
            a = b;
            b = c;
        }
        System.out.println(a);
    }
}

Measured memory_bytes: 26052
#include<iostream>
#include<cstdio>
using namespace std;
typedef pair<int,int> p;

int main()
{
	int w,n; cin>>w>>n;
	int ans[w];
	p sticks[n];
	char tmp;
	for(int i=0;i<n;i++)
	{
		cin>>sticks[i].first>>tmp>>sticks[i].second;
	}


	for(int i=0;i<w;i++)
	{
		int now=i+1;
		for(int j=0;j<n;j++)
		{
			if(sticks[j].first==now) now=sticks[j].second;
			else if(sticks[j].second==now) now=sticks[j].first;
		}
		ans[now-1]=i+1;
	}
	for(int i=0;i<w;i++) cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 1160
#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 <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <math.h> // sqrt()
#include <iomanip>
#define rep(i , n) for (int i = 1; i <= (int)(n); i++)
#define repz(i , n) for (int i = 0; i < (int) n; i++)
#define repi(i , r, n) for (int i = r; i <= (int)(n); i++)
#define repd(i , r, n) for (int i = r; i >= (int)(n); i--)


using namespace std;

int findigit(int64_t num){
    string var = to_string(num);
    return int( var.size());
}
int F( int a , int64_t b){
    return max( findigit(a), findigit(b));
}

int main(){
    int64_t n;
    cin >> n;
    int ans = 100000;
    rep(i , sqrt(n)){
        if ( n % i == 0){
            ans = min( ans , F(i, n / i));
        }
    }
    
    cout << ans << endl;


        
}


Measured memory_bytes: 256
n = int(input())
p = list(int(input()) for i in range(n))
q =[0]*(n+1)
for i in range(n):
    q[p[i]] = i
maxlen = 1
len =1
for i in range(1,n):
    if q[i] < q[i+1]:
        len +=1
    else:
        maxlen = max(maxlen,len)
        len = 1
maxlen = max(maxlen,len)
print(n-maxlen)

Measured memory_bytes: 65368
N,K=map(int,input().split())
A=list(map(int,input().split()))

M=[N]*N

for i in range(K):
    L=[0]*(N+1)
    for j in range(N):
        L[max(0,j-A[j])]+=1
        L[min(N,j+A[j]+1)]-=1
        
    S=0
    for j in range(N):
        S+=L[j]
        A[j]=S

    if A==M:
        break

for i in range(N):
    print(A[i],end=" ")
print()


Measured memory_bytes: 151652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n ,x) for (int i = x; i < (int)(n); ++i)
#define repBack(i, n) for (int i = n; i >= 0; --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N;
    cin >> N;
    vector<p> A(N);
    rep(i,N){
        int a;
        cin >> a;
        A[i] = p(a,i);
    }
    sort(A.begin(),A.end());
    rep(i,N){
        cout << A[i].second+1 << " ";
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main{
	static Scanner sc = new Scanner(System.in);

	static int n = Integer.parseInt(sc.next());

	static int[] a = new int[n];

	public static void main(String[] args) {

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}

		int q = Integer.parseInt(sc.next());
		for (int i = 0; i < q; i++) {
			int b = Integer.parseInt(sc.next());
			if (solve(0, b)) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}

	}

	private static boolean solve(int i, int sum) {
		if (sum == 0)
			return true;
		if (i >= n)
			return false;
		return (solve(i + 1, sum) || solve(i + 1, sum - a[i]));

	}
}

Measured memory_bytes: 26624
#include<bits/stdc++.h>
using namespace std;
#define lli long long int

int main() {
	lli i,j,k,n,t;
	cin>>n>>t;
	lli w[n],v[n];
	for(i=0;i<n;i++)
	cin>>w[i]>>v[i];
	lli a[n+1][t+1];
	for(i=0;i<=n;i++)
	a[i][0]=0;
	for(i=0;i<=t;i++)
	a[0][i]=0;
	for(i=1;i<=n;i++)
	{
	    for(j=1;j<=t;j++)
	    {
	        if(w[i-1]>j)
	        a[i][j]=a[i-1][j];
	        else
	        a[i][j]=max(a[i-1][j],v[i-1]+a[i-1][j-w[i-1]]);
	    }
	}
	cout<<a[n][t];
	return 0;
}

Measured memory_bytes: 82460
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> vec(N,0);
  vector<int> order(N,0);
  for(int i=0; i<N; i++){
    cin>>vec.at(i);
  }
  for(int i=0; i<N; i++){
    order.at(vec.at(i)-1)=i+1;
  }
  for(int i=0; i<N-1; i++){
    cout<<order.at(i)<<' ';
  }
  cout<<order.at(N-1)<<endl;
  
}
  

Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = s.length();
    if (n <= k)
    {
        cout << s;
    }
    else
    {
        s = s.substr(0, k) + "...";
        cout << s;
    }
}

Measured memory_bytes: 3600
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {
    int N;

    cin >> N;
    if(N==1){
        cout << "Yes" << endl;
        cout << 2 << endl;
        cout << "1 1" << endl;
        cout << "1 1" << endl;
        return 0;
    }

    int x = 0;
    int k = 0;
    vector<int> X;
    for (int i = 1; i <= N; ++i) {
        x += i;
        X.push_back(x);
        if (x == N) {
            k = i;
            break;
        }
        if (x > N) {
            cout << "No" << endl;
            return 0;
        }
    }


    cout << "Yes" << endl;
    cout << k + 1 << endl;

    vector<vector<int>> R;
    for (int i = 0; i < k + 1; ++i) {
        vector<int> v;
        R.push_back(v);
    }

    R[0].push_back(1);
    R[1].push_back(1);
    for (int i = 0; i < X.size() - 1; ++i) {
        int x = X[i];
        int x2 = X[i + 1];
        for (int j = x + 1; j <= x2; ++j) {
            R[j - (x + 1)].push_back(j);
            R[2 + i].push_back(j);
        }
    }


    for (int i = 0; i < k + 1; ++i) {
        cout << k;
        for (int j = 0; j < k; ++j) {
            cout << " " << R[i][j];
        }
        cout << endl;
    }


    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <map>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> t_1,x_1,y_1;
    for(int i=0;i<n;i++){
        int t,x,y;
        cin >> t >> x >> y;
        t_1.emplace_back(t);
        x_1.emplace_back(x);
        y_1.emplace_back(y);
    }
    if(n==1){
        if(abs(x_1[0])<=n && abs(y_1[0])<=n){
            cout << "Yes" << endl;
            return 0;
        }
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i=0;i<n-1;i++){
        int cmp_t = t_1[i+1]-t_1[i];
        int d_1 = abs(x_1[i]-x_1[i+1])+abs(y_1[i]-y_1[i+1]);
        if(d_1<=cmp_t){
            if(cmp_t%2!=d_1%2){
                cout << "No" << endl;
                return 0;
            }
            else continue;
        }
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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



const int N = 1e5 + 5;



int n, x, y;
vector < int > q;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    long long ans = 0;
    for(int i = 1; i <= n; i++){
        cin >> x >> y;
        q.push_back(x + y);
        ans -= y;
    }
    sort(q.rbegin(), q.rend());
    for(int i = 0; i < (int)q.size(); i += 2){
        ans += q[i];
    }
    cout << ans;
}


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

typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<bool> > vvb;
typedef map<int, bool> mib;

typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vpll;

typedef vector<string> vs;

typedef long double ld;

#define _GLIBCXX_DEBUG

#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n-1); i >= 0; --i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << '\n'
#define debug3(x, y, z) cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << '\n'
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

#define fst first
#define snd second
#define pb push_back
#define mp(x,y) make_pair((x),(y))

const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

signed main() {
    int N;

    cin >> N;

    vector<int> As(N);
    REP(i, N) {
        cin >> As.at(i);
    }

    // エラトステネスの篩っぽいことをする!
    sort(ALL(As));
    int max_a = As.at(N-1);

    vb Alive(max_a+1, true);
    // int min_a = As.at(0);
    // REP(a, min_a) {
    //     Alive.at(a) = false;
    // }

    map<int, bool> saw;

    REP(i, N) {
        int a = As.at(i);

        // 同じ値を2度やらない
        if (saw.count(a)) {
            Alive.at(a) = false;
            continue;
        }
        saw[a] = true;


        if (!Alive.at(a)) {
            continue;
        }

        for(int b = a+a; b <= max_a; b += a) {
            Alive[b] = false;
        }
    }

    // 残っているものを数える
    int ans = 0;
    REP(i, N) {
        int a = As.at(i);
        if (Alive.at(a)) {
            // debug(a);
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 13500
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        t: f64,
        x: f64
    }
    println!("{}", t / x);
}


Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,n) for(int j=0;j<n;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef vector< vector < int> > vee;
typedef vector<pair<ll,ll> > vepa;
typedef set<int>se;
typedef map<int,int> mpp;
const ll N=1e5+5;
ll arr[N],A[N],ARR[N];
bool visited[N]={};
ll cnt[N],freq[N];
bool f,ff;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
  ll n,m,sum=0,count(0);
  cin>>n>>m;
  rep(i,n&&cin>>arr[i])
  {
      sum+=arr[i];
  }
  rep(i,n)
  {
      if(arr[i]*4*m>=sum) count++;
  }
  if(count>=m)
    puts("Yes");
    else
    puts("No");
go;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 
 #define ll long long
 #define endl "\n"
 
 const int mxn = 2001;
 ll dp[mxn][mxn];

 void selfmax(ll &a, ll b){
    a=max(a,b);
 }
 
 int main(){
     //
     //freopen("input.txt", "r", stdin);
     //
     ios::sync_with_stdio(0);
     cin.tie(0);
     int n; cin>>n;
     vector<pair<int,int>> a(n+1);

     for (int i=1; i<=n; ++i){
        cin>>a[i].first;
        a[i].second = i;
     }
     ll ans=0;
     sort(a.begin()+1, a.end());
     for (int i=n; i>=1; --i){
        for (int j=1; i+j-1<=n; ++j){
            ll score = 1LL * a[i].first * abs(a[i].second-j);
            if (i==1)
                ans=max(ans, dp[j][j]+score);
            else{
                selfmax(dp[j+1][i+j-1], (dp[j][i+j-1]+score));
                selfmax(dp[j][i+j-2], (dp[j][i+j-1]+1LL*a[i].first*abs(i+j-1-a[i].second)));
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 26276
#include<iostream>
#include<cstring>
using namespace std;
int main(){
    string s,t;
    int count=0;
    cin>>s>>t;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]) count++;
    }
    cout<<count;
    return 0;
}


Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
//#define db double
#define all(x) x.begin(), x.end()
#define SZ(x) (int)(x.size())
#define mem(x, y) memset(x, y, sizeof(x))
#define what_is(x) cerr <<  "Line " << __LINE__ << ": " << #x << " is " << (x) << endl;
#define suf_zero(x) __builtin_ffs(x)
#define pre_zero(x) __builtin_clz(x)
#define num_one(x) __builtin_popcount(x)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define INFI 2000000009
#define INFLL (ll)1e18+7
#define fi first
#define se second
#define lson l, mid, rt<<1
#define rson mid+1, r, rt<<1|1
#define PII pair<int, int>
#define rep(i, begin, end) for(__typeof(end) i =(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
void err(istream_iterator<string> it) {cerr<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " , ";
    err(++it, args...);
}
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/hash_policy.hpp>
//using namespace __gnu_pbds;
//mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1e9+7;
ll qp(ll b, ll n){ll r=1;b%=mod;if(n<0) n+=mod-1;for(;n;n>>=1, b=b*b%mod)if(n&1) r=r*b%mod;return r;}
//#define RG register
///////////// BOUND /////////////////
//tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> T;
/////////////// MACRO ///////////////
const int maxn = 4e5+7;
ll fac[maxn], finv[maxn];
ll C(int n, int m)
{
    if(n<m||m<0) return 0;
    return fac[n]*finv[m]%mod*finv[n-m]%mod;
}
int main()
{
    int n, m, a, b;cin>>n>>m>>a>>b;
    fac[0]=finv[0]=1;
    for(int i=1;i<maxn;++i) fac[i] = fac[i-1]*i%mod;
    finv[maxn-1] = qp(fac[maxn-1], mod-2);
    for(int i=maxn-2;i>=1;--i) finv[i] = finv[i+1]*(i+1)%mod;
    ll ans = C(n+m-2, n-1);
    for(int i=0;i<b;++i)
        ans = (ans-C(n-a-1+i, i)*C(a-1+m-1-i, m-1-i)%mod+mod)%mod;
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <stdio.h>

int main(void) {
	int i, t, n, s, f, total;
	/*
	1行目 １日の目標時間t（整数）
	2行目 勉強の回数 n（整数）
	3行目 第1の勉強の開始時刻s 終了時刻f（整数 整数；半角空白区切り）
	：
	n+2行目 第nの勉強の開始時刻s 終了時刻f
	*/
	
	while(scanf("%d\n", &t)==1) {
		if(!t) break;
		total = 0;
		
		scanf("%d\n", &n);
		for(i=0;i<n;i++) {
			scanf("%d %d\n", &s, &f);
			total = total + f- s;
		}
		
		t -= total;
		if(t > 0) {
			printf("%d\n", t);
		} else {
			printf("OK\n");
		}
	}
	
	return 0;
}

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

set<string> ss;
string a[200048],s;
int tot=0,k;

int main ()
{
    cin>>s>>k;
    int i,j,n=int(s.size());
    for (i=0;i<=n-1;i++)
        for (j=1;j<=5;j++)
        {
            if (i+j-1>=n) break;
            ss.insert(s.substr(i,j));
        }
    set<string>::iterator it=ss.begin();
    for(int i=1;it!=ss.end();it++,i++)
    	if (i==k){
    		cout<<*it<<endl;
    		break;
    	}
    return 0;
}

Measured memory_bytes: 3200
class RollingHash():
    def __init__(self, s, base, mod):
        self.mod = mod
        self.pw = pw = [1]*(len(s)+1)

        l = len(s)
        self.h = h = [0]*(l+1)

        v = 0
        for i in range(l):
            h[i+1] = v = (v * base + ord(s[i])) % mod
        v = 1
        for i in range(l):
            pw[i+1] = v = v * base % mod
    def get(self, l, r): #S[l:r]indexでいうl文字目からr-l文字目。r-l文字。
        return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod

    def check(self, d):
        ma = {}
        for i in range(N-d+1): #0からN-dまで
            p = self.get(i,i+d)
            if p in ma:
                if i - ma[p] >= d: #d文字以上離れているか
                  return True
            else:
                ma[p] = i
        return False
            
              
N =int(input())
S = str(input())

base1 = 1007
mod1 = 10**9+7

RH = RollingHash(S,base1,mod1)

left = 0
right = N//2+1
while right - left >1:
  mid = (left+right)//2
  if RH.check(mid): #こちらがokの方
    left = mid
  else:
    right = mid

print(left)      


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

#define F                      first
#define S                      second
#define pb                      push_back
#define endl                    '\n'
#define all(x)                  x.begin(),x.end()
#define pii                     pair<int,int>
#define pll                     pair< long long int, long long int> 
#define fast                    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define SZ(x)                   ((int)x.size())

#define FOR(i,a,b)              for(int i = a; i < b; ++i)
#define REV(i,a,b)              for(int i = a; i >= b; --i)
#define FORE(i,a,b)             for(int i = a; i <= b; ++i)

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve();

int main()
{
        fast;
        solve();
}

const int N = 3000+2;

ld dp[N][N];

void solve() {
        int n;
        cin >> n;
        std::vector<ld> p(n);
        FOR(i,0,n) cin >> p[i];

        dp[0][0] = 1;
        FOR(j,0,n+1) {
                FOR(i,1,n+1) {
                        if(j-1 >= 0)
                                dp[i][j] += dp[i-1][j-1]*p[i-1];
                        dp[i][j] += dp[i-1][j]*(1.00 - p[i-1]);
                }
        }
        ld ans = 0;
        FOR(i,1,n+1) {
                int h = i;
                int t = n - i;
                if(h > t) {
                        ans += dp[n][h];
                }
        }
        cout << fixed << setprecision(10) << ans << endl; 
}

Measured memory_bytes: 141056
def euc(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    return euc(a, b%a)

if __name__ == '__main__':
    N = int(input())
    
    A = list(map(int, input().split()))
    
    L = [0]*(N+1)
    R = [0]*(N+1)
    
    for i in range(N):
        L[i+1] = euc(L[i], A[i])
    
    for i in range(N-1, -1, -1):
        R[i] = euc(R[i+1], A[i])
        
    max_gcd = 0
    for i in range(N):
        max_gcd = max(max_gcd, euc(L[i], R[i+1]))
    print(max_gcd)

Measured memory_bytes: 14488
#include <iostream>
#include <vector>
#include <tr1/unordered_map>
#include <queue>
#include <cstdio>
#include <algorithm>
using namespace std;

int X,Y;
struct NODE{
	int x,y,z,cost,fc;
	NODE(int x,int y,int z,int cost,int fc):
	x(x) , y(y) , z(z) , cost(cost) , fc(fc) {}
};
bool operator < (const NODE &a,const NODE &b){
	return a.cost != b.cost ? a.cost > b.cost : a.fc > b.fc;
}

int x[5][1000];
int y[5][1000];
int sz[5];
int main(){
	while(cin >> X >> Y && X){
		int sx,sy,gx,gy;
		for(int i = 0 ; i < 5 ; i++) sz[i]=0;
		
		for(int i = 0 ; i < Y ; i++)
			for(int j = 0 ; j < X ; j++){
				char c; scanf(" %c",&c);
				if(c == 'S'){
					sx = j , sy = i;
				}else if( c == 'G'){
					gx = j , gy = i;
				}else if( c != '.'){
					c = c - '1';
					x[c][sz[c]] = j;
					y[c][sz[c]++] = i;			
				}
			}
		priority_queue<NODE> Q;
		tr1::unordered_map< int , int > memo[5][5];
		
		if(!!sz[0] + !!sz[1] + !!sz[2] + !!sz[3] + !!sz[4] >= 4){
			for(int i = 0 ; i < 5 ; i++){
				Q.push(NODE(sx,sy,(i+1)%5,0,i));
			}
			while(Q.size()){

				NODE q = Q.top(); Q.pop();

				
				if(q.z == 10){
					cout << q.fc+1 << " " << q.cost << endl;
					goto exit;
				}
				if(memo[q.z][q.fc][(q.x<<12)|q.y] < q.cost) continue;
				if(q.z == q.fc){
					Q.push(NODE(gx,gy,10,q.cost+abs(q.x-gx)+abs(q.y-gy),q.fc));
				}else{
					for(int i = 0 ; i < sz[q.z] ; i++){
						NODE t = NODE(x[q.z][i],y[q.z][i],(q.z+1)%5,q.cost+abs(q.x-x[q.z][i])+abs(q.y-y[q.z][i]),q.fc);
						if( !memo[t.z][t.fc].count((t.x<<12)|t.y) || t.cost < memo[t.z][t.fc][(t.x<<12)|t.y])
							memo[t.z][t.fc][(t.x<<12)|t.y] = t.cost,Q.push(t);
					}
				}
			}
		}
		cout << "NA" << endl;
		exit:;
	}
		
}

Measured memory_bytes: 0
//=======================================
// abc143c
//
//  2019/10/19
//=======================================

#include <bits/stdc++.h>
using namespace std;

int main(int argc, char* argv[])
{
	cin.tie(0);
  ios::sync_with_stdio(false);

  int n; cin >> n;
  string s; cin >> s;
  int cnt=1;

  char t; t=s[0];
  for(int i=1; i<n; ++i)
  {
    if(t==s[i]) {}
    else
    {
      t=s[i];
      cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 512
def distribute(n, person, min, max, mode="even"):
    # n 個を person 人に分配する
    # 返り値は [[a (個), a 個もらう人数], ...]
    # 分配できないときは None を返す
    if person==0 and n==0:
        return []
    elif not min*person <= n <= max*person:
        return None
    elif mode=="even":
        q, m = divmod(n, person)
        if m==0:
            return [[q, person]]
        else:
            return [[q, person-m], [q+1, m]]
    elif mode=="greedy":
        if max==min:
            return [[max, person]]
        n -= min * person
        q, m = divmod(n, max-min)
        if m==0:
            return [[min, person-q], [max, q]]
        else:
            return [[min, person-1-q], [min+m, 1], [max, q]]
    else:
        raise ValueError("'mode' must be 'even' or 'greedy'.")

import numpy as np
N, A, B = map(int, input().split())
Ans = np.arange(N, 0, -1, dtype=np.int64)
Ans[:A] = np.flipud(Ans[:A])
c = N-A
D = distribute(c, B-1, min=1, max=A, mode="greedy")
if D is None:
    print(-1)
    exit()
idx = A
for p, n in D:
    for n_ in range(n):
        Ans[idx:idx+p] = np.flipud(Ans[idx:idx+p])
        idx += p
print(" ".join(str(int(a)) for a in Ans))


Measured memory_bytes: 37072
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    string S;
    cin>>S;
    int N = (int)S.size();

    long long M = 998244353;
    vector<long long> T(2*N+1);
    T[0] = 1;
    int B = 0;
    int R = 0;
    for (int i=0; i<2*N; i++)
    {
        int pB = B;
        if (i<N)
        {
            B += S[i]-'0';
            R += 2-(S[i]-'0');
        }

        vector<long long> P = T;
        T = vector<long long>(2*N+1);
        for (int b=0; b<=pB; b++)
        {
            if (B-b == 0)
            {
                T[b] += P[b];
                T[b] %= M;
            }
            else if (R-(i-b)==0)
            {
                T[b+1] += P[b];
                T[b+1] %= M;
            }
            else
            {
                T[b] += P[b];
                T[b] %= M;
                T[b+1] += P[b];
                T[b+1] %= M;
            }
        }

        //for (long long t: T)
        //    cout<<" "<<t;
        //cout<<endl;
    }
    cout<<T[B]<<endl;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int i=1,k;
		while(i<=x){
			if(i%3==0){
				System.out.printf(" %d",i);
			}else{
				k=i;
				while(k!=0){
					if(k%10==3){
						System.out.printf(" %d",i);
						break;
					}else{
						k=k/10;
					}
				}
			}
		i++;
		}
		System.out.printf("\n");
	}
}

Measured memory_bytes: 33760
#include <iostream>
#include <algorithm>
#define db double 
using namespace std;
int main(){
	int n,p;
	db t,in,a,h[1010],ans;
	cin>>n;
	cin>>t>>a;
	for(int i=1;i<=n;i++){
		cin>>in;
		h[i]=t-in*0.006;
		h[i]=a-h[i];
		if(h[i]<0)h[i]=-h[i];
	}
	ans=h[1];
	p=1;
	for(int i=2;i<=n;i++){
		if(ans>h[i]){
			p=i;
			ans=h[i];
		}
	}
	cout<<p;
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	string s;
	cin >> s;
	int n = s.size();
	map<char, int> data;
	rep(i, n) {
		char now = s[i];
		data[now]++;
	}
	bool flag = true;
	for (auto p : data) {
		int value = p.second;
		if (value % 2 == 1) flag = false;
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

int		main(void)
{
	int a, b, c, d;

	cin >> a >> b >> c >> d;
	vector<bool> alice(101, false);
	vector<bool> bob(101, false);
	for (int i = a + 1; i <= b; i++)
		alice[i] = true;
	for (int i = c + 1; i <= d; i++)
		bob[i] = true;
	int cnt = 0;
	
	for (int i = 0; i < 101; i++)
	{
		if (alice[i] && bob[i])
			cnt++;
	}
	cout << cnt << endl;
}



Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine();
        string[] strinputArray = input.Split(' ');
        int[] intinputArray = Array.ConvertAll<string, int>(strinputArray, delegate (string value) { return int.Parse(value); });
        if (intinputArray[0] > intinputArray[1])
        {
            Console.WriteLine("a > b");
        }
        else if (intinputArray[0] == intinputArray[1])
        {
            Console.WriteLine("a == b");
        }
        else if (intinputArray[0] < intinputArray[1])
        {
            Console.WriteLine("a < b");
        }
    }
}



Measured memory_bytes: 15968
#include <iostream>
#include <cstdio>
#include <algorithm>
#define PII pair<int, int>
#define F first
#define S second

using namespace std;

int n, m, ans;
PII a[100005];
int cp[100005];
bool v[100005];

int fnd(int p)
{
    if(p <= -1) return -1;
    if(!v[p]) return p;
    else return cp[p] = fnd(cp[p]);
}

int main()
{
//    freopen("input.txt", "r", stdin);
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i++)
    {
        scanf("%d%d", &a[i].S, &a[i].F);
    }
    for(int i = 0; i < m; i++) cp[i] = i - 1;
    sort(a, a + n, greater<PII>());
    for(int i = 0; i < n; i++)
    {
        if(fnd(m - a[i].S) <= -1) continue;
        int t = fnd(m - a[i].S);
        v[t] = true;
        ans += a[i].F;
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int[] alphabet = new int[26];
 
        do {
            String s = input.nextLine();
            for (char c : s.toCharArray()){
                if ((c < 'A' || 'Z' < c) && (c < 'a' || 'z' < c)) continue;
                alphabet[Character.toLowerCase(c)- 'a']++;
            }
        } while (input.hasNext());
 
        for (char c = 'a'; c <= 'z'; c++){
            System.out.println(c + " : " + alphabet[c - 'a']);
        }
    }
}


Measured memory_bytes: 26232
import sys
import os

def file_input():
    f = open('Beginner_Contest_162/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    N=int(input())
    S=input()
    # print(S)
    R=S.count('R')
    G=S.count('G')
    B=S.count('B')

    sum=R*G*B
    # print(sum)
    for i in range(N-2):
        # print(i)
        for j in range(i+1,-(-(N+i)//2)):
            k=2*j-i
            # print("i:"+str(i)+" j:"+str(j)+" k:"+str(k))
            if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
                sum-=1
                # print(S[i]+S[j]+S[k])


    print(sum)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>

using namespace std;
typedef long long ll;

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

    vector<ll> temp;
    temp.push_back(a[0] * a[2]);
    temp.push_back(a[0] * a[3]);
    temp.push_back(a[1] * a[2]);
    temp.push_back(a[1] * a[3]);
    sort(temp.begin(), temp.end(), greater<ll>());
    cout << temp[0] << endl;
    return 0;
}

Measured memory_bytes: 3628
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var counts = Enumerable.Repeat((int)1e9, 26).ToArray();
            var answer = "";
            for (var i = 0; i < N; i++)
            {
                var s = Console.ReadLine();
                var tmp = new int[26];
                for (var j = 0; j < s.Length; j++)
                {
                    tmp[s[j] - 'a']++;
                }

                for (var j = 0; j < tmp.Length; j++)
                {
                    counts[j] = Math.Min(counts[j], tmp[j]);
                }
            }

            for (var i = 0; i < counts.Length; i++)
            {
                for (var j = 0; j < counts[i]; j++)
                {
                    answer += Convert.ToChar('a' + i);
                }
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 28216
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var dict = new Dictionary<string, int>();
            var dict2 = new Dictionary<int, List<string>>();
            var max = 0;

            var list = new List<string>();
            foreach (var i in Enumerable.Repeat(0, N))
            {
                list.Add(Console.ReadLine());
            }

            list.Sort(StringComparer.OrdinalIgnoreCase);

            string oldItem = null;
            int count = 0;
            foreach (var i in Enumerable.Range(0, list.Count + 1))
            {
                if (i == 0)
                {
                    oldItem = list[i];
                    count++;
                }
                else
                {
                    if (i < list.Count && oldItem == list[i])
                    {
                        count++;
                    }
                    else
                    {
                        if (dict2.ContainsKey(count))
                        {
                            dict2[count].Add(oldItem);
                        }
                        else
                        {
                            dict2.Add(count, new List<string> { oldItem });
                        }

                        if (i < list.Count)
                        {
                            count = 1;
                            oldItem = list[i];
                        }
                    }

                    if (count > max)
                    {
                        max = count;
                    }
                }
            }

            var answerList = dict2[max];
            foreach (var i in answerList)
            {
                Console.WriteLine(i);
            }
        }
    }
}


Measured memory_bytes: 33368
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N;
  cin>>N;
  vl L(N);
  rep(i,N) cin>>L[i];
  
  ll ans=0;
  sort(all(L));
  
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      for(int k=j+1;k<N;k++){
        if(L[i]!=L[j]&&L[j]!=L[k]&&L[k]!=L[i]&&L[i]+L[j]>L[k]) ans++;
      }
    }
  }
  cout<<ans<<endl;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	int num[3];
	num[0] = a + b;
	num[1] = a - b;
	num[2] = a * b;
	int ans = num[0];
	for (int i = 1; i < 3; i++) {
		if (ans < num[i]) {
			ans = num [i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define DEKAI 2000000000
#define MAX 500000

int cnt;
int L[MAX/2+2],R[MAX/2+2];

void merge(int A[],int left,int mid,int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; ++i)
	{
		L[i] = A[left + i];
	}
	for (int i = 0; i < n2; ++i)
	{
		R[i] = A[mid + i];
	}
	L[n1] = R[n2] = DEKAI;
	int i = 0;
	int j = 0;
	for (int k = left; k < right ; ++k)
	{
		cnt++;
		if (L[i] <= R[j])
		{
			A[k] = L[i];
			i++;			
		}
		else
		{
			A[k] = R[j];
			j++;
		}
	}
}

void mergesort(int A[],int left,int right)
{
	if (left+1 < right)
	{
		int mid = (left + right)/2;
		mergesort(A,left,mid);
		mergesort(A,mid,right);
		merge(A,left,mid,right);
	}
}

int main()
{
	int n,A[MAX];
	cnt = 0;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> A[i];
	}

	mergesort(A,0,n);

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

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


Measured memory_bytes: 6900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

bool debug = 0;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<bool> red(n, false);
    vector<int> ball(n, 1);
    red[0] = true;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        if (red[x]) red[y] = true;
        --ball[x], ++ball[y];
        if (ball[x] == 0) red[x] = false;
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (red[i]) cnt++;
    }
    cout << cnt << endl;
}

int main() {
    if (debug) {
        while (true) {
            cout << "********" << endl;
            solve();
        }
    } else {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3740
#!usr/bin/env python3
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LIR(n):
    return [LI() for i in range(n)]

def solve():
    def add(i,x):
        while i < len(bit):
            bit[i] += x
            i += i&-i
    def sum_(i):
        res = 0
        while i > 0:
            res += bit[i]
            i -= i&-i
        return res
    n,Q = LI()
    c = LI()
    c = [0]+c
    q = [[i,LI()] for i in range(Q)]
    q.sort(key = lambda x:x[1][1])
    bit = [0]*(n+2)
    i = 1
    p = [None]*(n+1)
    ans = [0]*Q
    s = 0
    for ind,(l, r) in q:
        l -= 1
        while i <= r:
            ci = c[i]
            j = p[ci]
            if j is not None:
                add(j,1)
            else:
                s += 1
            p[ci] = i
            i += 1
        ans[ind] = s-l+sum_(l)
    for i in ans:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 235868
//
//  AT2391 [ABC058A] ι⊥l.cpp
//  Algorithm
//
//  Created by SkyGao on 2020/2/13.
//  Copyright © 2020 skygao. All rights reserved.
//

#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#define re register
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(b-a==c-b)
        printf("YES");
    else
        printf("NO");
    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  string s; cin >> s;
  vector<int> W(N, 0), E(N, 0);
  for (int i = 0; i < N; ++i) {
    if (s[i] == 'W') { ++W[i]; }
    else { ++E[i]; }
    if (i > 0) {
      W[i] += W[i - 1];
      E[i] += E[i - 1];
    }
  }
  int ans = INF;
  for (int i = 0; i < N; ++i) {
    ans = min(ans, W[i] - (s[i] == 'W') + E[N - 1] - E[i]);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define forn for(int i=0;i<n;i++)
#define pb push_back
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int sum=0;
    int arr[n];
    forn cin>>arr[i];
    sort(arr,arr+n);
    for(int i=0;i<n-1;i++) sum+=arr[i];
    sum+=arr[n-1]/2;
    cout<<sum<<endl;
    return 0;

 

}

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

long long gcd(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (a % b == 0) {
		return b;
	} else {
		return gcd(b, a % b);
	}
}

long long lcm(long long a, long long b) {
	return a * b / gcd(a,b);
}

long long cnt_divisible(long long A, long long d) {
	return A / d;
}

int main() {
	long long A, B, C, D;
	long long ans = 0;
	cin >> A >> B >> C >> D;
	long long G = lcm(C, D);
	ans += B - A + 1;
	ans -= cnt_divisible(B, C) - cnt_divisible(A - 1, C);
	ans -= cnt_divisible(B, D) - cnt_divisible(A - 1, D);
	ans += cnt_divisible(B, G) - cnt_divisible(A - 1, G);
	cout << ans << 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;
typedef pair<int,int>P;

int main(){
	int n,h,w;cin>>n>>h>>w;
	int cnt=0;
	rep(i,n){
		int a,b;scanf("%d%d",&a,&b);
		if(a>=h&&b>=w)cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int A,B,C,X,Y;cin>>A>>B>>C>>X>>Y;
	int a,b;
	if(X > Y){
        if(A < 2*C) a = A * (X-Y);
        else a = 2*C * (X-Y);
    }else{
        if(B < 2*C) a = B * (Y-X);
        else a = 2*C * (Y-X);
    }
	if(A + B > 2 * C) b = min(X , Y) * 2 * C; 
	else b = min(X , Y) * (A + B);
	cout<<a + b<<endl;
}

Measured memory_bytes: 256
using System;
 
namespace ConsoleApp12
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            if (a % 2 == 0)
                Console.WriteLine(a / 2);
            else if (a % 2 > 0)
                Console.WriteLine(a / 2 + 1);
 
        }
    }
}

Measured memory_bytes: 11220
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		Arrays.sort(s);
		boolean diff = true;
		for(int i = 0; i < s.length - 1; i++) {
			if(s[i] == s[i + 1]) {
				diff = false;
				break;
			}
		}
		if(diff) System.out.println("yes");
		else System.out.println("no");
	}
}

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

int main() {
    int n, m;
    cin >> n >> m;
    int ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            ans++;
        }
    }
    for (int i = 0; i < m; i++){
        for (int j = i + 1; j < m; j++){
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main() {
	map<string, int>mp;
	int N;
	cin >> N;
	string S[N + 1];

	for (int i = 0; i < N; i++) {
		cin >> S[i];
		mp[S[i]]++;
	}
	bool flag = true;
	for (int i = 0; i < N - 1; i++) {
		if (S[i][S[i].size() - 1] != S[i + 1][0]) {
			flag = false;
		}
	}
	for (auto p : mp) {
		int x = p.second;
		if (x >= 2) {
			cout << "No";
			return 0;
		}
	}
	if (flag)cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pow107 int(pow(10,9) + 7)
#define F(i,x,n) for(int i = x; i < n ; ++i)

bool comp(pair<int, int> a, pair<int, int> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

inline bool pn(long int x){
    if(x <= 1)return false;
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i <= (3 + int(sqrt(x)))/2; ++i){
        if((x != i && x % i == 0) || (x != (3 + int(sqrt(x)) - i) && x % (3 + int(sqrt(x)) - i) == 0))
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

long int Func2(long int n,long int m){
    long int s2 = 1,
        r = 1;
    for(long int i = 1; i <= m; ++i){
        s2 = (s2*(n - (i - 1))/i) % (pow107);
    }
    return s2;
}

bool secsort(pair<int, int> a, pair<int, int> b){
    if(a.second == b.second)return a.first > b.first;
    else return a.second > b.second;
}

long int GCD(long int a,long int b){
    if(b == 0)return a;
    return GCD(b,a%b);
}

long int LCM(long int a,long int b){
    return a/GCD(a,b)*b;
}

void warfl(vector<vector<int> > &dist, int n){
  for(int k=0; k<n; k++){
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
        dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
      }
    }
  }
  return;
}
//#define long long long

const int MAX = 1000000;
const int MOD = 1e9+7;

long mpow(long x, long n){
    long ans = 1;
    while(n != 0){
        if(n%2==1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n/2;
    }
    return ans;
}

long mfact(long n){
  long ans = 1;
  for(long i=2; i<=n; i++){
    ans = ans*i % MOD;
  }
  return ans;
}

long mcomb(long n, long m){ //aCbをmod計算
    if(n == 0 && m == 0) return 1;
    if(n < m || n < 0) return 0;
    long ans = mfact(n)*mpow(mfact(m), MOD-2) %MOD;
    ans = ans*mpow(mfact(n-m), MOD-2) %MOD;
    return ans;
}

long int jjjjj(long int n){
    long int x = 1;
    for(int i = 1; i <= n; ++i){
        x *=i;
    }
    return x;
}

int main(){
    const int N = 100001;
    bool f[N] = {};
    int c[N] = {};

    for(int i = 2; i <= N; ++i){
        if(!f[i]){
            for(int j = i*2; j <= N; j += i){
                f[j] = true;
            }
        }
    }

    for(int i = 3; i <= N; i += 2){
        if(!f[i] && !f[(i + 1)/2])c[i]++;
    }

    for(int i = 3; i <= N; ++i){
        c[i] += c[i - 1];
    }

    int n;
    cin >> n;

    for(int i = 0; i < n; ++i){
        int l,r;
        cin >> l >> r;

        cout << c[r] - c[l - 1] << endl;
    }

}

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

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> s(N);
    for(int i=0; i<M; i++){
        int a,b;
        cin >> a >> b;
        s.at(a-1)+=1;
        s.at(b-1)+=1;
    }

    for(int i=0; i<N; i++){
        cout << s.at(i) << endl;
    }
}

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

int main(){
  string b,t;
  cin >> b >> t;
  int ct = 0;
  int minct = t.size();
  for(int i = 0; i < (int)b.size(); i++){
    if(i+(int)t.size() > (int)b.size()) break;
    for(int j = 0;j < (int)t.size(); j++){
      if(b.at(i+j) != t.at(j)){
        ct++;
      }
    }
    minct = min(minct,ct);
    ct = 0;
  }
  cout << minct;
}   

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int a;
	string s;
	cin >> a;
	cin >> s;

	if(a >= 3200){
		cout << s << endl;
	}else{
		cout << "red" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define MAX_N 233

using namespace std;

int n;
char s[MAX_N];

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	if(s[1]!='A' || s[2]=='C' || s[n]=='C' || isupper(s[2]) || isupper(s[n]))
	{
		printf("WA\n");
		return 0;
	}
	int cnt=0;
	for(int i=3;i<n;i++)
	{
		if(s[i]=='C') cnt++;
		else if(isupper(s[i]))
		{
			printf("WA\n");
			return 0;
		}
	}
	if(cnt!=1) printf("WA\n");
	else printf("AC\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n>>s;
  if(n%2==1)cout << "No" << endl;
  else{
    for(int i=0; i<n/2; i++){
      if(s[i]!=s[i+n/2]){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256