akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n, q;
    cin >> n >> q;
    set<pair<int, pair<int, int> > > st;
    for(int i=0; i<n; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
    
        st.insert(make_pair(a-c, make_pair(c, 1)));
        st.insert(make_pair(b-c, make_pair(c, 0)));
    }

    auto it = st.begin();
    multiset<int> st2;
    while(q--)
    {
        int d;
        cin >> d;

        while(it != st.end() && it->first <= d)
        {
            pair<int, pair<int, int> > p = *it;
            if(p.second.second)
            {
                st2.insert(p.second.first);
            }
            else
            {
                auto it2 = st2.find(p.second.first);
                st2.erase(it2);
            }
            it++;
        }

        if(it==st.end() || st2.size() == 0)
            cout << -1 << endl;
        else
            cout << *(st2.begin()) << endl;
        
    }
    return 0;
}

Measured memory_bytes: 35584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int r, g, b, n;
    cin >> r >> g >> b >> n;

    int R = n / r;
    int B = n / b;
    int G = n / g;

    ll res = 0;
    for (int i = 0; i <= R; i++)
    {
        for (int j = 0; j <= G; j++)
        {
            int k = n - i * r - j * g;

            if (k % b == 0 && k >= 0)
                res++;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(long long a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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;
}

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    string S;
    cin >> S;
    S[3] = '8';
    cout << S << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
vector<pii> adj[1005];
ll dis[1005][1005];
ll temp[1005];

int main(){
   ll a,b,c,k;
   cin>>a>>b>>c>>k;
   ll s=0;
   while(b<=a){
   	  s++;
   	  b=b*2;
   }
   while(c<=b){
   	 s++;
   	 c=c*2;
   }
   if(s<=k){
   	  cout<<"Yes";
   }
   else{
   	  cout<<"No";
   }
   
   
   
   
   
}
	
 
    

Measured memory_bytes: 3660
#ABC127-A
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
a,b=IL()
if a>=13:
    print(b)
elif 6<=a<=12:
    print(b//2)
else:
    print(0)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ cin >> p.first >> p.second; return s;}
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    int N, M; cin >>N>>M;
    set<int> ac;
    map<int, int> wa;
    rep(i, M) {
        int p;
        string S;
        cin >> p >> S;
        if (S == "AC") {
            ac.emplace(p);
        } else {
            if (ac.count(p) == 0) {
                wa[p]++;
            }
        }
    }

    int penalty = 0;
    auto it = ac.begin();
    while (it != ac.end())
        penalty += wa[*it++];

    cout << ac.size() << " " << penalty << endl;
}


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



def solve():
  ## input
  N = int(input())
  An = [0] + list(map(int, input().split()))

  ## solve
  Retn = [0 for _ in range(N+1)]
  for i in range(N,0,-1):
    mul = 2
    while i*mul <= N:
      An[i] = An[i]+An[i*mul]
      mul += 1
    An[i] = An[i]%2
  
  M = An.count(1)
  print(M)
  for i,a in enumerate(An):
    if a==1:
      print(i)

solve()

Measured memory_bytes: 72540
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.next();
        String next = scanner.next();
        scanner.close();

        if (next.substring(0, input.length()).equals(input)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35720
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    vector<int> side(3);

    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> side[0] >> side[1] >> side[2];
        sort(side.begin(), side.end());
        if( side[2]*side[2] == side[1]*side[1] + side[0]*side[0])
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  int N;
  cin >> N;  
  string s;
  cin >> s;
  int c=0;
  for(int i=N-1;i>=0;i--){
    if(s[i]==')') c++;
    else{
      c--;
      c = max(c,0);
    }
  }
  string ans;
  rep(i,c) ans.pb('(');
  rep(i,N) ans.pb(s[i]);
  c=0;
  rep(i,ans.size()){
    if(ans[i]=='(') c++;
    else{
      c--;
    }
    c=max(c,0);
  }
  //  rep(i,ans.size()) cout << ans[i];
  //  cout <<""<<endl;
  rep(i,c) ans.pb(')');
  rep(i,ans.size()) cout << ans[i];
  cout <<""<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#define H 10000000
using namespace std;
string dic[H];
int char2int(char c) {
    if (c == 'A') return 1;
    else if (c == 'T') return 2;
    else if (c == 'G') return 3;
    return 4;
}
int str2int(string s) {
    int sum = 0;
    for (int i=s.size()-1; i>=0; i--) {
        sum *= 5;
        sum += char2int( s[i] );
    }
    return sum;
}
void insert(string s) {
    int i = str2int(s);
    dic[i] = s;
}
bool find(string s) {
    int i = str2int(s);
    if ( dic[i] != "" ) return true;
    else return false;
}
int main() {
    int n;
    cin >> n;
    string ord, str;
    for (int i=0; i<n; i++) {
        cin >> ord;
        cin >> str;
        if (ord[0] == 'i') {
            insert(str);
        } else {
            if ( find(str) ) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        }
    }
}


Measured memory_bytes: 97640
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<=n;i++)
	  for(int j=0;j<=m;j++)
	  {
		int tmp=i*m+j*n-i*j*2;
		if(tmp==k)
		{
			puts("Yes");
			return 0;
		}
	  }
	puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
void fail() { cout << "No\n"; exit(0); }
int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<pair<int, int>> X(N);
    for (int i = 0; i < N; i++) {
        int x; cin >> x; x--;
        X[i] = make_pair(x, i);
    }
    sort(begin(X), end(X));
    vector<int> A(N*N, -1);
    vector<int> rest(N, N);
    int curr = 0;
    for (int i = 0; i < N; i++) {
        if (A[X[i].first] != -1) fail();
        A[X[i].first] = X[i].second + 1;
        rest[X[i].second]--;
        int cnt = X[i].second;
        while (curr < X[i].first && cnt) {
            if (A[curr] == -1) {
                cnt--;
                A[curr] = X[i].second + 1;
                rest[X[i].second]--;
            }
            curr++;
        }
        if (cnt) fail();
    }
    for (int i = 0; i < N; i++) {
        while (rest[X[i].second]) {
            if (A[curr] == -1) {
                if (curr < X[i].first) fail();
                rest[X[i].second]--;
                A[curr] = X[i].second + 1;
            }
            curr++;
        }
    }
    cout << "Yes\n";
    for (auto a : A) cout << a << ' ';
    cout << '\n';
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

#define ll long long int
#define vi vector<int>
#define endl "\n"

int main() {
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  int n, k; cin >> n >>k;
  vi t(n);
  for (int i  =0; i < n; ++i) cin >> t[i];
  sort(t.begin(), t.end());
  int ans = 1000000005;
  for (int i = 0; i+k-1 <n; ++i) {
    ans = min(ans, t[i+k-1] - t[i]);
    /* cout << t[i+k-1] << ' ' << t[i] << endl; */
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

ll modinv(ll a, ll m = MOD) {
  ll b = m, u = 1, v = 0;
  while(b) {
    ll t = a / b;
    a -= t * b, swap(a, b);
    u -= t * v, swap(u, v);
  }
  u %= m;
  if(u < 0) u += m;
  return u;
}

int main() {
  int n, k;
  ll ma = 0, mi = 0, f[100001];
  f[0] = f[1] = 1;
  for(int i = 2; i < 100001; i++) f[i] = f[i - 1] * i % MOD;
  scanf("%d %d", &n, &k);
  vector<int> a(n);
  for(int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a.begin(), a.end());
  for(int i = k - 1; i < n; i++) {
    ma = (ma + f[i] * modinv(f[i - k + 1]) % MOD * modinv(f[k - 1]) % MOD *
                   a[i] % MOD) %
         MOD;
    mi = (mi + f[i] * modinv(f[i - k + 1]) % MOD * modinv(f[k - 1]) % MOD *
                   a[n - 1 - i] % MOD) %
         MOD;
  }
  ll o = ma - mi;
  while(o < 0) o += MOD;
  printf("%lld\n", o % MOD);
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>


int main(){
	int N,X,T;
	if(scanf("%d %d %d",&N,&X,&T)==1);

	if(N%X==0){
		printf("%d\n",(N/X)*T );
	}else{
		printf("%d\n",(N/X)*T+T );

	}


}

Measured memory_bytes: 1732
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

int main(){
  
  long long int N, tmp;
  std::vector<long long int> count(1e5);
  
  scanf("%lld", &N);
  
  for(long long int i = 0; i < 10; i++){
    std::cerr << count[i] << " ";
  }std::cerr << std::endl;

  
  for(int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    count[tmp-1]++;
  }
  
  for(long long int i = 0; i < 10; i++){
    std::cerr << count[i] << " ";
  }std::cerr << std::endl;
  
  long long int ans = 0;
  if(count[0] == N/2)ans++;
  for(int i = 1; i < 1e5; i++){
    count[i] = count[i-1] + count[i];
    if(count[i] == N/2){
      ans++;
    }
    if(count[i] > N/2)break;
  }
  
  for(long long int i = 0; i < 10; i++){
    std::cerr << count[i] << " ";
  }std::cerr << std::endl;
  
  std::cerr << "Answer:" << std::endl;
  std::cout << ans << std::endl;
  
  return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();
		int count = 0;
		for(long i = x; i <= y; i *= 2){
			count++;
		}
		System.out.println(count);
	}
}

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

namespace AtCoder200531
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inputs = Console.ReadLine().Split(' ').Select(s=>int.Parse(s)).ToArray();

            string answer = "No";

            for(int two = 0; two <= inputs[0]; two++)
            {
                if (2 * two + 4 * (inputs[0] - two) == inputs[1])
                {
                    answer = "Yes";
                }
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 28288
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;

import std.typecons;
alias Edge = Tuple!(int, "a", int, "b", int, "cost");

void main() {
    int n, m;
    scan(n, m);
    long x;
    scan(x);

    auto es = new Edge[](m);
    foreach (i ; 0 .. m) {
        int u, v, w;
        scan(u, v, w);
        u--, v--;
        es[i] = Edge(u, v, w);
    }

    es.sort!"a.cost < b.cost"();

    auto d = new long[](m);
    foreach (i ; 0 .. m) {
        auto uf = UnionFind(n);
        uf.unite(es[i].a, es[i].b);
        long wei = es[i].cost;

        foreach (j ; 0 .. m) {
            if (uf.same(es[j].a, es[j].b)) continue;
            uf.unite(es[j].a, es[j].b);
            wei += es[j].cost;
        }

        d[i] = wei;
    }

    auto ds = d.sort();

    debug {
        writeln("ds:", ds);
    }

    long f(long y) {
        return powmod(2, min(m, m - ds.lowerBound(y + 1).length.to!int + 1));
    }

    long ans = f(x - 1) - f(x);
    ans %= mod;
    if (ans < 0) ans += mod;

    writeln(ans);
}

immutable(long) mod = 10^^9 + 7;

long powmod(long x, long y) {
    return y > 0 ? powmod(x, y>>1)^^2 % mod * x^^(y&1) % mod : 1L;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

struct UnionFind {
    private {
        int _size;
        int[] _parent;
    }

    this(int N) 
    in {
        assert(N > 0);
    }
    body {
        _size = N;
        _parent = new int[](_size);
        foreach (i ; 0 .. _size) {
            _parent[i] = i;
        }
    }

    int findRoot(int x)
    in {
        assert(0 <= x && x < _size);
    }
    body {
        if (_parent[x] != x) {
            _parent[x] = findRoot(_parent[x]);
        }

        return _parent[x];
    }

    bool same(int x, int y)
    in {
        assert(0 <= x && x < _size);
        assert(0 <= y && y < _size);
    }
    body {
        return findRoot(x) == findRoot(y);
    }

    void unite(int x, int y)
    in {
        assert(0 <= x && x < _size);
        assert(0 <= y && y < _size);
    }
    body {
        int u = findRoot(x);
        int v = findRoot(y);

        if (u == v) return;

        _parent[v] = u;
    }
}

Measured memory_bytes: 4476
<?php
 
$sc = new Scanner();
 
$n = $sc->nextInt();
$T = $sc->nextInt();
$A = $sc->nextInt();
$h = [];
$index = 0;
$d = 1000000000000000;
for ($i = 0; $i < $n; $i++) {
    $tmp = $T - $sc->nextInt() * 0.006;
    if ($d > ($t = abs($tmp - $A))) {
        $d = $t;
        $index = $i+1;
    }
}
 
echo $index . PHP_EOL;
 
 
 
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    long d4=0,d2=0,dn=0;
    for(int i = 0; i < n; i++){
        long t;
        cin>>t;
        if(t%4==0)
            d4++;
        else if(t%2==0)
            d2++;
        else
            dn++;
    }
    if(d4>=(d2+dn)-1||(d4>=dn&&d2>1))
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;

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

const int MAXN = 101, MAXL = 101, MAXE = 10000;
long long INF = MAXN * MAXE;
typedef pair<int, int> pp;
typedef pair<int, pp> ppp;
struct edge{int to, dist, enemy;};

long long d[MAXN][MAXL];
int n, m, l;
int a, b, dist, e;

int main()
{
    while(cin >> n >> m >> l && n)
    {
        memset(d, INF, sizeof(d));
        vector<edge> g[MAXN];

        REP(m)
        {
            cin >> a >> b >> dist >> e;
            a--;
            b--;

            g[a].push_back((edge){b, dist, e});
            g[b].push_back((edge){a, dist, e});
        }

        priority_queue<ppp, vector<ppp>, greater<ppp> > que;
        que.push(ppp(0,pp(-l, 0)));
        REP(l + 1)d[0][i] = 0;

        int ans = 0;
        while(!que.empty())
        {
            ppp p = que.top(); que.pop();
            int nowe = p.first, nowl = -p.second.first, now = p.second.second;
            //cout << "es:" << nowe << " mo:" << nowl << " now:"<< now << endl;

            if(now == n -1 ){ans = nowe; break;}
                /*bool f = false;
                REP(nowl + 1)if(d[now][i] < nowe) f = true;
                if(f) continue;
            */

            REP(g[now].size())
            {
                edge ed = g[now][i];
                //cout <<"edge to:" << ed.to <<" dist:"<< ed.dist<<" enemy:" << ed.enemy << endl;

                if(nowl >= ed.dist &&( d[ed.to][nowl - ed.dist] > d[now][nowl]) )
                {
                    //cout <<"edge to:" << ed.to <<" dist:"<< ed.dist<<" enemy:" << ed.enemy << endl;
                    d[ed.to][nowl - ed.dist] = d[now][nowl];
                    que.push(ppp(d[ed.to][nowl - ed.dist], pp(-nowl+ ed.dist, ed.to)) ) ;
                }

                if(d[ed.to][nowl] > d[now][nowl] + ed.enemy)
                {
                    d[ed.to][nowl] = d[now][nowl] + ed.enemy;
                    que.push(ppp(d[ed.to][nowl], pp(-nowl, ed.to)));
                }
            }
        }
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1148
#include <iostream>
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)
typedef pair<double, double> dpair;

double det(dpair p1, dpair p2, dpair p3) {
	return (p2.first - p1.first) * (p3.second - p2.second) - (p2.second - p1.second) * (p3.first - p2.first);
}
int main() {
	int n;
	while(cin >> n && n) {
		vector<dpair> v;
		rep(i,n) {
			double x, y;
			scanf("%lf,%lf", &x, &y);
			v.push_back(make_pair(x,y));
		}
		sort(v.begin(), v.end());
		dpair conv[205];
		int k = 0;
		rep(i,n) {
			while(k > 1 && det(conv[k-2], conv[k-1], v[i]) <= 0) --k;
			conv[k++] = v[i];
		}
		for(int i = n - 2, t = k; i >= 0; --i) {
			while(k > t && det(conv[k-2], conv[k-1], v[i]) <= 0) --k;
			conv[k++] = v[i];
		}
		cout << n - k + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

const int MOD = 1000000007;

int main() {
	int N; cin >> N;
	string S; cin >> S;
	vector<int> x(26, 0);
	long long ans = 1;
	for (int i = 0; i < N; i++) {
		int y = S[i] - 'a';
		x[y]++;
	}
	for (int i = 0; i < 26; i++) {
		ans *= x[i] + 1;
		ans %= MOD;
	}
	cout << ans-1 << endl;
}





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

int main() {
	string s;
	cin >> s;

	if (s == "SUN") {
		cout << "7" << endl;
	}
	else if (s == "MON") {
		cout << "6" << endl;

	}
	else if (s == "TUE") {
		cout << "5" << endl;

	}
	else if (s == "WED") {
		cout << "4" << endl;

	}
	else if (s == "THU") {
		cout << "3" << endl;

	}
	else if (s == "FRI") {
		cout << "2" << endl;

	}
	else if (s == "SAT") {
		cout << "1" << endl;
	}
}

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


int main() {
	char str1[3];
	char str2[3];
	int j = 0;

	cin >> str1[0] >> str1[1] >> str1[2];
	cin >> str2[0] >> str2[1] >> str2[2];

	for (int i = 0; i < 3; i++) {
		if (str1[i] == str2[2 - i]) j++;
	}

	if (j == 3) {
		cout << "YES";
	}
	else
	{
		cout << "NO";
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <climits>
#include <cmath>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <stack>
#include <bitset>
using namespace std;
#define rep(i,a,b) for(int i=a; i<=b; i++)
#define fi first
#define se second
#define ll long long
#define ii pair<int, int>
int f[10005];

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen("Test.inp", "r", stdin);
	//freopen("RATING.out", "w", stdout);
	int n, d, a;
	cin >> n >> d >> a;
	vector <ii> b(n);
	for (ii &i : b) cin >> i.first >> i.second;
	sort(b.begin(), b.end(), [](ii a, ii b) {return a.first < b.first; });
	queue <ii> q;
	int sub = 0;
	ll ans = 0;
	for (ii i : b) {
		int x = i.first, h = i.second;
		while (q.size() && q.front().first < x) {
			sub -= q.front().second;
			q.pop();
		}
		h -= sub * a;
		if (h > 0) {
			int t = (h + a - 1) / a;
			ans += t;
			sub += t;
			q.push(ii(x + d * 2, t));
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
 
int main(){

    int x;
    cin >> x;

    int i = 2;
    int ans = 1;
    while(1){
        bool f = 1;
        for(int j = 2; pow(i, j) <= x; ++j){
            ans = max((int)pow(i,j), ans);
            f = 0;
        }
        if(f)break;
        ++i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<31)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, t, ans;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> t;
    vii a(n);
    ans = t;
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n-1) {
        if (a[i+1] <= a[i] + t)
            ans += a[i+1] - a[i];
        else
            ans += t;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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; }

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int MAX_N=100000;

int main(){
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    pair<ll,ll> pairs[MAX_N+5];
    rep(i,n){
        cin >> pairs[i].first >> pairs[i].second;
    }
    sort(pairs,pairs+n);
    ll now=0;
    ll ans=0;
    rep(i,n){
        if(now+pairs[i].second<=m){
            ans+=pairs[i].first*pairs[i].second;
        } else{
            ans+=pairs[i].first*(m-now);
            break;
        }
        now+=pairs[i].second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
require 'matrix'

class Matrix
  # v2.3 では代入不可
  def []=(i, j, x)
    @rows[i][j]=x
  end
end

n, m = gets.split.map(&:to_i)
rows = Array.new(n + m){gets.chomp.chars.map{|c| (c == '#') ? 1 : 0}}
a = Matrix.rows(rows.shift(n))
b = Matrix.rows(rows)
(n - m + 1).times do |i|
  (n - m + 1).times do |j|
    if a.minor(i, m, j, m) == b
      puts "Yes"
      exit
    end
  end
end
puts "No"

Measured memory_bytes: 3196
#include <iostream>

using namespace std;

int main() {
	int D;
	cin >> D;
	switch(D){
		case 25:
			cout << "Christmas" << endl;
			break;
		case 24:
			cout << "Christmas Eve" << endl;
			break;
		case 23:
			cout << "Christmas Eve Eve" << endl;
			break;
		case 22:
			cout << "Christmas Eve Eve Eve" << endl;
			break;
		default:
			break;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())

if N == 0:
    print(0)
else:
    ans = ""
    while N != 0:
        digit = abs(N%(-2))
        ans += str(digit)
        N -= digit
        N //= -2

    for i in reversed(range(len(ans))):
        print(ans[i],end="")

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    static List<Node> nodes = new List<Node>();
    static int time = 0;

    class Node
    {
        public bool visited = false;
        public int d_time = 0;
        public int f_time = 0;
        public List<int> adjacentIds;
    }

    static void Main(string[] args)
    {
    	// 行数を取得
        int n = int.Parse(Console.ReadLine().Split()[0]);

        // nodeを作成
        for (int i = 0; i < n; i++)
        {
            nodes.Add(new Node());
        }

        // nodeの中身設定
        for (int i = 0; i < n; i++)
        {
            List<int> nums = Console.ReadLine().Split().Select(str => int.Parse(str)).ToList();
            nodes[nums[0] - 1].adjacentIds = nums.GetRange(2, nums[1]).Select(id => id - 1).ToList();
        }

        // dfs
        while (nodes.Exists(node => node.d_time == 0))
        {
            dfs(nodes.Where(node => node.d_time == 0).ToList()[0]);
        }

        // 出力
        for (int i = 0; i < n; i++)
        {
            System.Console.WriteLine(string.Format("{0} {1} {2}", i + 1, nodes[i].d_time, nodes[i].f_time));
        }
    }

    static void dfs(Node node)
    {
        time++;
    	node.visited = true;
       	if (node.d_time == 0)
       	{
       		node.d_time = time;
       	}
        foreach (var adjacentId in node.adjacentIds)
        {
        	if (!nodes[adjacentId].visited)
        	{
	            dfs(nodes[adjacentId]);
	        }
        }
        time++;
        node.f_time = time;
    }
}



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


int main(){
	int n;
	ll k;
	int q;
	cin >> n >> k >> q;
	vector<int> a(q);
	rep(i,q){
		int tmp;
		cin >> tmp;
		a[i] = tmp-1;
	}
	vector<int> point(n);
	rep(i,q) point[a[i]]++;
	rep(i,n){
		if(point[i] > q-k){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	return 0;

}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <complex>

using namespace std;

int main()
{
  int N;
  scanf("%d ", &N);
  
  for (int i = 0; i < N; i++) {
    double xa, ya, ra, xb, yb, rb;
    scanf("%lf %lf %lf %lf %lf %lf ", &xa, &ya, &ra, &xb, &yb, &rb);
    complex<double> A(xa, ya), B(xb, yb);

    double k1 = fabs(ra - rb), k2 = ra + rb;
    double d = abs(A - B);
    int num;
    if (d < k1) {
      if (ra > rb) {
	num = 2;
      } else {
	num = -2;
      }
    } else if (k1 <= d && d <= k2) {
      num = 1;
    } else if (k2 < d) {
      num = 0;
    }
    
    printf("%d\n", num);
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int n , m;

void solve()
{
	int d , t , s;
	cin >> d >> t >> s;

	if(t*s >= d)cout << "Yes";
	else cout << "No";
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 3648
//LCS length and string together as output

#include<bits/stdc++.h>
#include<string>
# define MAX 3000
using namespace std;

int dp[MAX+1][MAX+1];
string getlcs(string& s,string& t,int len)
{
string LCS;
int i=0,j=0;
while(len>0)
{
    if(s[i]==t[j])
    {
        LCS.push_back(s[i]);
        i++;
        j++;
        len--;
    }
    else
    {
        if(dp[i][j+1]> dp[i+1][j])
        j++;
        else 
        i++;
        
    }
}
    return LCS;
    


}

int Lenlcs(string& s,string& t,int i,int j)
{

    if(i>=s.length() || j>=t.length())
    return 0;

    if(dp[i][j]!=-1)
    return dp[i][j];

    if(s[i]==t[j])
    return dp[i][j]=1+Lenlcs(s,t,i+1,j+1);

    else
    {
        return dp[i][j]=max(Lenlcs(s,t,i,j+1),Lenlcs(s,t,i+1,j));
    
    }
}
    









//     int m=strlen(x);
//     int n=strlen(y);
//     int dp[100][100];


//     //base case
//     for(int i=0;i<=m;i++)
//     dp[i][0]=0;
//     for(int j=0;j<=n;j++)
//     dp[0][j]=0;




// for(int i=1;i<=m;i++)
// {
//     for(int j=1;j<=n;j++)
//     {
//         int q=0;
//         if(x[i-1]==y[j-1])
//         {
//             q=1+dp[i-1][j-1];

//         }
//         else
//         {
//      q=max(dp[i-1][j],dp[i][j-1]);
//         }
//         dp[i][j]=q;
//     }

// }

// return dp[m][n];



string solve(string s,string t)
{  
     memset(dp,-1,sizeof dp);
    int len=Lenlcs(s,t,0,0);
    return getlcs(s,t,len);


}


int main()
{
    string str1,str2;
    cin>>str1;
    cin>>str2;

   // int ans=Lenlcs(str1,str2);
    //cout<<ans;
    cout<<solve(str1,str2);
    return 0;

}


Measured memory_bytes: 35968
#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; }
///////////////////////////////////////////////////////////////////////////////////
const ll MOD=998244353;
ll pow(ll x,ll y,ll mod){
    if(y==0) return 1;
    if(y&1) return x*pow(x,y-1,mod)%mod;
    ll p=pow(x,y/2,mod);
    return p*p%mod;
}
const ll MAX = 10000001;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    ll n;
    cin >> n;
    ll ans=pow(3,n,MOD);
    ll sub=0;
    COMinit();
    repi(i,1,(n+1)/2+1){
        ll a=COM(n,n/2+i);
        a *= pow(2,n-n/2-i,MOD);
        a%=MOD;
        sub+=a;
        sub%=MOD;
    }
    ans+=3*MOD;
    ans-=2*sub;
    ans%=MOD;
    print(ans);
    return 0;
}

Measured memory_bytes: 234624
#include <stdio.h>

int main(){
    int n,x;
    int count;
    scanf("%d %d",&n,&x);
    while(!(n==0&&x==0)){
        count=0;
        for(int i=1;i<=n;i++){
            for(int f=1;f<=i;f++){
                for(int l=1;l<=f;l++){
                    if(i+f+l==x&&(i!=f&&f!=l)){
                        count++;
                    }
                }
            }
        }
        printf("%d\n",count);
        
        scanf("%d %d",&n,&x);
    }
}


Measured memory_bytes: 2044
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        String str1 = scan.next();
        String str2 = scan.next();

        int a = Integer.parseInt(str1);
        int b = Integer.parseInt(str2);

        int answer = Math.max(0, a - b * 2);

        System.out.println(answer);

        scan.close();

    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define scl(n) scanf("%lld", &n)
#define pcl(n) printf("%lld\n", n)
#define pcl1(n) printf("%lld ", n)
#define dev(x) cout << #x << " " << x << " ";
#define PTT pair<ll, ll>

map<ll, ll> mp, mp1;
map<ll, ll>::iterator itr;
ll a[102];
int main()
{
    ll x, n;
    scl(x);
    scl(n);
    ll p;
    for (int i = 0; i < n; i++)
    {
        scl(p);
        a[p] = p;
    }
    if (n > 0)
    {
        ll mn = 120, j = 0;
        for (ll i = 0; i <= 101; i++)
        {
            if (!a[i])
            {
                ll z = abs(x - i);
                if (z < mn)
                {
                    mn = z;
                    j = i;
                }
            }
        }
        cout << j << endl;
    }
    else
    {
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/

ll n,m,c;
ll b[25],a[25][25];
int main(){FAST;
cin>>n>>m>>c;
for(ll i=0;i<m;i++)cin>>b[i];
for(ll i=0;i<n;i++)for(ll j=0;j<m;j++)cin>>a[i][j];
ll ans=0;
for(ll i=0;i<n;i++){
	ll s=0;
	for(ll j=0;j<m;j++){
		s+=a[i][j]*b[j];
	}
	if(s+c>0)ans++;
}
cout<<ans;
return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        int cnt = 0;
        
        for (int i = a; i <= b; i++) {
            if (c % i == 0) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 26264
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, i, j;
    cin >> n;
    long double p, dp[n+2] = {0};
    dp[1] = 1;
    for(i = 0; i < n; ++i) {
        cin >> p;
        for(j = i+2; j > 0; --j)
            dp[j] = dp[j]*(1-p) + dp[j-1]*p;
    }
    for(i = n/2+2, p = 0; i < n+2; ++i) p += dp[i];
    printf("%0.10Lf", p);
    return 0;
}

Measured memory_bytes: 3704
def select(S):
    for i in range(0, n):
        minj = i
        for j in range(i, n):
            if int(S[j][1]) < int(S[minj][1]):
                minj = j
        (S[i], S[minj]) = (S[minj], S[i])
    return S

def bubble(B):
    flag = True
    while flag:
        flag = False
        for j in reversed(range(1, n)):
            if int(B[j][1]) < int(B[j-1][1]):
                (B[j-1], B[j]) = (B[j], B[j-1])
                flag = True
    return B

n = int(input())
A = input().split(' ')

B = bubble(A[:])
print(" ".join(B[:]))
print("Stable")
S = select(A)
print(" ".join(S))
print("Stable" if " ".join(B) == " ".join(S) else "Not stable")

Measured memory_bytes: 7732
n,m=map(int,input().split())
x=[0]*m
y=[0]*m
for i in range(m):
  x[i],y[i]= input().split()

x=[int(l) for l in x]


ac=0
wa=0
aclist=[0]*n
walist=[0]*n
p=[0]*n

for i in range(m):
  if y[i]=='AC' and p[x[i]-1]==0:
    aclist[x[i]-1]+=1
    p[x[i]-1]=1
  elif y[i]=='WA' and p[x[i]-1]==0:
    walist[x[i]-1]+=1

for j in range(n):
  if 1==aclist[j]:
    ac+=1
    wa+=walist[j]
print(ac,wa)


Measured memory_bytes: 68956
#include <iostream>
#include <string>

using namespace std;

typedef long long ll;

int main() {
    string s;
    cin >> s;
    ll w = 0;
    ll ans = 0;
    for (ll i = 0; i < s.length(); i++)
        if (s[i] == 'W')
            w++;
    ll cnt = 0;
    for (ll i = 0; i < s.length(); i++) {
        if (s[i] == 'B') {
            cnt++;
            ans += (w+cnt-1 - i);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 832
from collections import deque

q = deque()

q.append('a')

n = int(input())

ans_list = []
flag = 0

if n != 1:
    while flag == 0:
        s = q.pop()
        if len(s) > n:
            flag = 1
        a = list(s)
        x = chr(ord('a')-1)
        a = map(ord,a)
        max_a = max(a)
        while ord(x) != max_a+1:
            x = chr(ord(x)+1)
            y = s + x
            q.appendleft(y)
            if len(y) == n:
                ans_list.append(y)
else:
    ans_list = ['a']

ans_list = sorted(ans_list)

for i in range(len(ans_list)):
    print(ans_list[i])


Measured memory_bytes: 61796
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
	//????????????????????????
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

	
	//?????????
	int n = Integer.parseInt(bf.readLine());
	String[] stringA = bf.readLine().split(" ");
	int q = Integer.parseInt(bf.readLine());
	String[] stringM = bf.readLine().split(" ");
	
	int[] intA = new int[n];
	int[] intM = new int[q];
	for(int i=0;i<n;i++){
		intA[i]=Integer.parseInt(stringA[i]);
	}
	for(int i=0;i<q;i++){
		intM[i]=Integer.parseInt(stringM[i]);
	}
	
	for(int i=0;i<q;i++){
		if(solve(0,intM[i],n,intA)){
			System.out.println("yes");	
		}else{
			System.out.println("no");
		}
	}
	}

	
	public static boolean solve(int i,int m,int n,int[] array){
		if(m==0){
			return true;
		}
		if(i >=n){
			return false;
		}
		boolean res = solve(i+1,m,n,array) || solve(i+1,m-array[i],n,array);
		return res;
	}
}

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

int main(){
    int N;
    cin >> N;
    bool ans = false;
    for (int i = 1; i <= 9; i++){
        for (int j = 1; j <= 9; j++){
            if (i * j == N) ans = true;
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define   ll    long long int
#define   sz    1000100
#define   pb    push_back
#define   py    printf("Yes\n")
#define   pn    printf("No\n")
#define   sc(a) scanf("%lld",&a)
#define   p    1000000007
const  double pi=acos(-1);

using namespace std;


ll bigmod(ll x,ll y)
{
    ll res=1;
    x=x%p;

    while(y>0)
    {
        if(y&1)
        {
            res=(res*x)%p;

        }
        y=y>>1;
        x=(x*x)%p;
    }

    return res;

}

ll find_ncr(ll n, ll r)
{
    ll m=max(r,n-r);
    ll i,j,s,d=1,k;
    s=1;

    for(i=m+1;i<=n;i++)
    {
        s=((s%p)*(i%p))%p;
    }

    m=min(r,n-r);

    for(i=1;i<=m;i++)
    {
        k=bigmod(i,p-2);
        d=((d%p)*(k%p))%p;
    }

    k=(s%p*(d%p))%p;

    return k;
}

int main()
{

    ll n,m,a,b,x,y,c,i,j,d,k,tw;

    cin>>n>>a>>b;

    tw=bigmod(2LL,n)-1;



    a=find_ncr(n,a);
    b=find_ncr(n,b);

    tw=(tw%p-(a%p+b%p)%p)%p;
    tw=(tw+p)%p;

    cout<<tw<<endl;


    return 0;
}


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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	ll k;
	cin >> k;

	cout << ((k % 2 == 0) ? (k * k / 4) : ((k / 2) * (k / 2 + 1))) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int h,w,i,j;
	while(1)
	{
		scanf("%d %d",&h,&w);
		if(h==0||w==0)
		{break;}
		for(i=0;i<h;i++)
		{
			for(j=0;j<w;j++)
			{
				if((i+j)%2==0){
					printf("#");
				}
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


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

int main()
{
    int N;
    char c;
    string S;
    cin >> N >> S;

    for (int i = 0; i < S.size();i++){
        if((S.at(i)+N)>=91){
            c = S.at(i) + N-26;
            cout << c;
        }
        else{
            c = S.at(i) + N;
            cout << c;
        }

    }
    

    cout << endl;

}

Measured memory_bytes: 256