akhauriyash/Code-Regression huggingface dataset:
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '(L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

LL l[123456];
LL n,k,a,b;
int main(){
    CLR(l);
    cin>>n>>k;
    REP(i,n){
        cin>>a>>b;
        l[a]+=b;
    }

    REP(i,123456){
        k-=l[i];
        if(k<=0){
            cout<<i<<endl;
            return 0;
        }
    }

}


Measured memory_bytes: 1152
#include <stdio.h>
#include<math.h>

int main(void) {
	// your code goes here
	int l,r,d;
  scanf("%d %d %d",&l,&r,&d);
  int k,j;
  if(l%d!=0)
  k=l+d-(l%d);
  else
  k=l;
  j=r-r%d;
  printf("%d\n",(j-k)/d+1);
	return 0;
}

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


    public static void main(String[] args) {


        Scanner reader = new Scanner(System.in);

        int N = reader.nextInt();
        int M = reader.nextInt();
        int Total =0;
        int b=0;

        for (int i = 0; i <M; i++) {
            int A = reader.nextInt();

             Total +=A;

            if (Total>N){

             b=-1;
            } else {
                b = N-Total;


            }

        }

        System.out.println(b);


    }

}




Measured memory_bytes: 37908
def chk(r, c):
    cnt_in, cnt_out = 0, 0
    if (r, c) == (0, 0): cnt_in += 1
    if (r, c) == (H - 1, W - 1): cnt_out += 1
    if r - 1 >= 0:
        if a[r - 1][c] == '#': cnt_in += 1
    if r + 1 < H:
        if a[r + 1][c] == '#': cnt_out += 1
    if c - 1 >= 0:
        if a[r][c - 1] == '#': cnt_in += 1
    if c + 1 < W:
        if a[r][c + 1] == '#': cnt_out += 1
    return cnt_in == 1 and cnt_out == 1


H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]

bl = True
for r in range(H):
    for c in range(W):
        if a[r][c] == '#':
            if not chk(r, c):
                bl = False
                break
    else:
        continue
    break

print('Possible' if bl else 'Impossible')


Measured memory_bytes: 3064
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
    os<<endl;
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, map<T,S> const&M){
    for(auto e:M){
        os<<e;
    }
    os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;


//素因数分解
vector<int64> prime_factorization(int64 n){
    int64 copy = n;
    vector<int64> res;
    for(int64 i=2;i*i<=copy;i++){
        while(n%i==0){
            res.push_back(i);
            n/=i;
        }
    }
    if(n!=1) res.push_back(n);
    return res;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int64 N; cin >> N;
    auto prime = prime_factorization(N);
    sort(ALL(prime));
    cout << N << ": " << prime;
}


Measured memory_bytes: 3208
#include<iostream>
using namespace std;
int main()
{
   long long int n,m,a[101],i,c=0;
    double sum=0, p;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        sum+=a[i];
    }
   // cout<<sum;
   p=(1/(4*m*1.00))*sum;
   //cout<<p<<endl;
   for(i=0;i<n;i++)
   {
       if(a[i]>=p)
       {
           c++;
         //  cout<<"ON"<<endl;
       }
   }
   if(c>=m)
   {
       cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }
}


Measured memory_bytes: 256
(defun solve (n k)
  (let ((x (make-array n)))
   (dotimes (i n)
     (setf (aref x i) (read)))
   (loop for i to (- n k)
         minimize (let ((a (aref x i))
                        (b (aref x (1- (+ i k)))))
                    (if (> (* a b) 0)
                      (max (abs a) (abs b))
                      (let ((max-v (max (abs a) (abs b)))
                            (min-v (min (abs a) (abs b))))
                        (+ (* min-v 2) max-v)))))))
(princ (solve (read) (read)))

Measured memory_bytes: 59752
MOD = 998244353
module ModInt
  refine Integer do
    def +(b); (super b) % MOD; end
    def -(b); (super b) % MOD; end
    def *(b); (super b) % MOD; end
    def pow(b); super(b, MOD); end
    def /(b); self * b.pow(MOD - 2); end
  end
end
using ModInt

class FactTable
  attr_reader :fa, :fi
  def initialize(n)
    @fa = [1] * (n + 1)
    @fi = [1] * (n + 1)
    2.upto(n) { |i| fa[i] = fa[i - 1] * i }
    fi[n] = 1 / fa[n]
    n.downto(3) { |i| fi[i - 1] = fi[i] * i }
  end
 
  def nCk(n, m)
    fa[n] * fi[m] * fi[n - m]
  end
end
 
n,m,k = gets.split.map(&:to_i)
ft = FactTable.new(n)
 
ans = 0
0.upto(k) do |k|
  ans += (m-1).pow(n-1-k) * m * ft.nCk(n-1,k)
end
puts ans

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

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

    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
    }

//    for (int i = 0; i < N; i++) {
//        int next = a.at(i); // 次のボタンの位置
//        if ((next - 1) == i) {
//            // 次のボタンの位置にあるaiの値が現在のボタンの位置だった場合
//            cout << "-1" << endl;
//            return 0;
//        }
//    }

    bool is_finished = false;
    int curr = 1, count = 0;
    for (int i = 0; i < N; i++) {
        count++;
        int next = a.at(curr - 1);
        if (next == 2) {
            is_finished = true;
            break;
        } 
        curr = next;
    }
    cout << ((is_finished) ? count : -1) << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589
 
using namespace std;
        
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 4e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
        
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
        
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
        
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
        
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
        
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("lol.in", "r", stdin);
    //freopen("lol.out", "w", stdout);
}


signed main()
{
    Start();
    int n, x;
    cin >> n >> x;
    vector <int> a(n);
    cin >> a;
    vector <int> b(n);
    for (int i = 0; i < n; ++i)
    {
        int cur = a[i];
        for (int j = 0; j < n; ++j)
            cur = min(cur, a[(i - j + n) % n]), b[j] += cur;
    }
    int ans = 1e18;
    for (int i = 0; i < n; ++i)
        ans = min(ans, i * x + b[i]);
    cout << ans;
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

    vector<int> dp(100010,INF);
    rep(i,n){
        *lower_bound(all(dp),a[i])=a[i];
    }
    cout<<lower_bound(all(dp),INF)-dp.begin()<<endl;
}




Measured memory_bytes: 3620
#include <iostream>
#include "string.h"
#include <algorithm>
#include <vector>
using namespace std;

int main() {

    long long a, b, k;
    cin>>a>>b>>k;

    for (int i=0; i<k; i++) {

        if (i%2==0) {
            a = a/2;
            b += a;
        }
        else {
            b = b/2;
            a += b;
        }

    }

    cout<<a<<" "<<b<<endl;


    return 0;
}

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

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

#define int ll

vector<int> lunlun;

bool check(int n) {
  int pre = n % 10;
  while (n > 0) {
    int t = n % 10;
    n /= 10;
    if (abs(pre - t) > 1) {
      return false;
    }

    pre = t;
  }

  return true;
}

int digitadd(int p, int suf) {
  int ret = suf;
  int mul = 10;
  while (p > 0) {
    auto t = p % 10;
    p /= 10;
    ret += mul * t;
    mul *= 10;
  }

  return ret;
}

void dfs(int n, int lim) {
  if (n > lim) {
    return;
  } else {
    lunlun.push_back(n);
  }

  int suf = n % 10;
  int p1 = max(suf - 1, 0LL);
  int p2 = min(suf + 1, 9LL);
  int p3 = suf;

  if (suf != p1) {
    dfs(digitadd(n, p1), lim);
  }

  if (suf != p2) {
    dfs(digitadd(n, p2), lim);
  }

  dfs(digitadd(n, p3), lim);
}

signed main() {
  int k;
  cin >> k;
  for (int i = 1; i <= 9; ++i) {
    dfs(i, 3234566668);
  }

  sorti(lunlun);
  /*for (auto itr : lunlun) {
    cout << itr << " ";
  }*/
  cout << lunlun[k-1] << endl;
}

Measured memory_bytes: 1400
#include <stdio.h>

int bubbleSort(int *,int);

int main()
{
  int A[100],N,i,sw;

  scanf("%d",&N);
  for(i=0;i<N;i++)
    scanf("%d",&A[i]);

  sw = bubbleSort(A,N);
  
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",sw);

  return 0;

}

int bubbleSort(int A[],int N){
  int flag,i,j,sw,a;
  
  sw = 0;
  flag = 1;

  i=0;
  while(flag){
    flag = 0;
    for(j=N-1;j>=i+1;j--){
      if(A[j] < A[j-1]){
	a = A[j];
	A[j] = A[j-1];
	A[j-1] = a;
      flag = 1;
      sw++;
      }
    }
    i++;
  }
  return sw;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    for(ll i = k;i <= n+1;i++){
        ans = (ans+(i*n-i*(i-1)+1))%mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
n, K = map(int, input().split())
dp = [[0]*(n**2+1) for _ in range(n+2)]
dp[0][0] = 1
for i in range(n):
    ndp = [[0]*(n**2+1) for _ in range(n+2)]
    for j in range(i+2):
        for k in range(n**2+1):
            if k-2*j<0:
                continue
            ndp[j][k] = ((2*j+1)*dp[j][k-2*j]+(j+1)*(j+1)*dp[j+1][k-2*j]+dp[j-1][k-2*j])%(10**9+7)
    dp = ndp
print(dp[0][K])


Measured memory_bytes: 63196
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

int main(){
	int n,m;
	cin >> n >> m;
	
	int a[n][m];
	int b[m];
	int c;
	
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin >> a[i][j];
		}
	}
	
	for(int i=0; i<m; i++){
		cin >> b[i];
	}
	
	for(int i=0; i<n; i++){
		c = 0;
		
		for(int j=0; j<m; j++){
			c += a[i][j] * b[j];
		}
		
		cout << c <<endl;
	}
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
using ll = long long;
using ld = long double;

int main()
{
    ll K;
    cin >> K;
    auto f = [](const ll n) -> ld {
        int sum = 0;
        for (ll m = n; m > 0; m /= 10) { sum += m % 10; }
        return (ld)n / sum;
    };
    vector<ll> cand;
    for (ll i = 1; i < 1000000; i++) {
        string s = to_string(i);
        for (ll j = 0; j <= 15 and s.size() <= 16; j++) { cand.push_back(stoll(s)), s.push_back('9'); }
    }
    sort(cand.begin(), cand.end());
    reverse(cand.begin(), cand.end());
    vector<ll> ans;
    ld prev = 1e100;
    for (const ll e : cand) {
        const auto F = f(e);
        if (prev >= F) { ans.push_back(e), prev = F; }
    }
    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    for (int i = 0; i < K; i++) { cout << ans[i] << endl; }
    return 0;
}


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

using namespace std;

typedef long long int lli;

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

    int p, q, r;

    cin >> p >> q >> r;

    cout << min(p+q, min(q+r, r+p)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int n, l, ans = 0;
	cin >> n >> l;
	for (int i = l; i < l+n; i++) {
		ans = ans + i;
	}
	if (l > 0)ans = ans - l;
	if (l + n - 1 < 0)ans = ans - (n + l - 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#if 1

#include <bits/stdc++.h>
using namespace std;
long long ans,x;
long long minn = 1000000000000;
int n,cnt;

int main()
{
    scanf("%d",&n);
    for(int i = 1;i <= n;i++)
    {
        scanf("%lld",&x);
        if(x < 0)
        {
            cnt++;
            x *= -1;
        }
        ans += x;
        minn = min(x,minn);
    }
    if(cnt % 2 == 0) printf("%lld",ans);
    else printf("%lld",ans-2*minn);
}

#endif // 1++

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a[5],time=0,min=0;
  for (int i=0;i<5;i++) scanf("%d",&a[i]);
  for (int i=1;i<5;i++){
    if (a[i]%10==0);
    else{
      if (a[min]%10>a[i]%10) min=i;
    }
  }
  for (int i=0;i<5;i++){
    if (i==min) time+=a[i];
    else time+=(a[i]+9)/10*10;
  }
  printf("%d\n",time);
  return 0;
}


Measured memory_bytes: 128
N = int(input())
A = [x for x in input().split()]

B = [int(x[1]) for x in A]
C = [x[0] for x in A]
D = [int(x[1]) for x in A]
E = [x[0] for x in A]
F = [int(x[1]) for x in A]
G = [x[0] for x in A]

def bubbleSort(A, B, N):
    for i in range(0, N):
        for j in range(N-1, i, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                B[j], B[j-1] = B[j-1], B[j]
    return 0

def selectionSort(A, B, N):
    for i in range(0, N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]: minj = j
        A[i], A[minj] = A[minj], A[i]
        B[i], B[minj] = B[minj], B[i]
    return 0

def showArray(A, B, N):
    for _ in range(N):
        if _ == N-1:
            print(A[_], sep='', end='')
            print(B[_], sep='', end='')
        else:
            print(A[_], sep='', end='')
            print(B[_], sep='', end=' ')
    print()
    return 0

def isStable(A, B, C, D, N):
    for _ in range(1, 10):
        if A.count(_) > 1:
            if [B[i] for i, x in enumerate(A) if x == _] == [D[i] for i, x in enumerate(C) if x == _]:
                continue
            else:
                return 'Not stable'
    return 'Stable'

if __name__ == '__main__':
    bubbleSort(B, C, N)
    selectionSort(D, E, N)
    
    showArray(C, B, N)
    print(isStable(B, C, F, G, N))
    showArray(E, D, N)
    print(isStable(D, E, F, G, N))


Measured memory_bytes: 5632
#include <stdio.h>
int main(void){
    int H,W,i,j,k;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0) break;
        for(i=1; i<=H; i++){
            for(j=1; j<=W; j++){
                if(i>1 && i<H && j<W && j>1)
                printf(".");
                else printf("#");
            }
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}


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

const int INF = 1145141919;
const long long INFL = 1LL<<60;

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

double dp[3000][3000] = {};
vector<double> P;
int n;

double rec(int d, int x)
{
	if(dp[d][x])
	{
		return dp[d][x];
	}
	if(d == n)
	{
		if(n / 2 + n % 2 > x)
		{
			return 0;
		}
		else
		{
			return 1;
		}
	}
	double ret = 1;
	ret = rec(d+1, x+1) * P[d] + rec(d+1, x) * (1-P[d]);
	return dp[d][x] = ret;
}

int main()
{
	cin >> n;
	double in;
	for (int i = 0; i < n; ++i)
	{
		cin >> in;
		P.push_back(in);
	}
	for (int i = n / 2 + 1; i <= n; ++i)
	{
		dp[n][i] = 1;
	}
	for (int i = n; i > 0; --i)
	{
		for (int j = n; j > 0; --j)
		{
			dp[i-1][j-1] = dp[i][j] * P[i-1] + dp[i][j-1] * (1-P[i-1]);
		}
	}
	printf("%0.15lf\n", dp[0][0]);
}

Measured memory_bytes: 70656
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n,k,r,s,p;
string t;

int point(char c) {
    switch (c) {
        case 'r':
            return p;
        case 's':
            return r;
        case 'p':
            return s;
    }
    return -1;
}

int main() {
    cin >> n >> k >> r >> s >> p;
    cin >> t;

    VVi v(n+1, Vi(3, 0));
    ll res = 0;
    REP(i, k) {
        char c = t[i];
        int pc = point(c);
        switch (c) {
            case 'r':
                v[i][2] = pc; break;
            case 's':
                v[i][0] = pc; break;
            case 'p':
                v[i][1] = pc; break;
        }
        int j = i+k;
        while (j < n) {
            char d = t[j];
            int pd = point(d);
            v[j][0] = max(v[j-k][1], v[j-k][2]);
            v[j][1] = max(v[j-k][0], v[j-k][2]);
            v[j][2] = max(v[j-k][0], v[j-k][1]);
            switch (d) {
                case 'r':
                    v[j][2] += pd;
                    break;
                case 's':
                    v[j][0] += pd;
                    break;
                case 'p':
                    v[j][1] += pd;
                    break;
            }
            j += k;
        }
        res += max({v[j-k][0], v[j-k][1], v[j-k][2]});
    }
    std::cout << res << '\n';

    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
typedef tuple<int,int,int,int>T;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX =510000;
int main(){
  	int N,M;
  	cin >>N>>M;
  	priority_queue<ll>A;
  	rep(i,N){
      	ll x;
    	cin >>x;
      	A.push(x);
    }
  	ll sum=0;
  	rep(i,M){	
      	ll y=A.top();A.pop();
      	y/=2;
      	A.push(y);
    }
  	rep(i,N){
    	sum+=A.top();
      	A.pop();
    }
  	cout<<sum<<endl;
  	
  	
}


Measured memory_bytes: 1400
#include<stdio.h>
int main(void){
	int a,b,c,p;
	while(1){
		scanf("%d %d %d", &a, &b, &c);
		if (a==-1&&b==-1&&c==-1){break;}
		p=a+b;
		if(a==-1&&b>=0){printf("F\n");}
		else if(b==-1&&a>=0){printf("F\n");}
		else if(p>=80){printf("A\n");}
		else if(p>=65&&p<85){printf("B\n");}
		else if(p>=50&&p<65){printf("C\n");}
		else if(p>=30&&p<50&&c<50){printf("D\n");}
		else if(p>=30&&p<50&&c>=50){printf("C\n");}
		else if(p<30){printf("F\n");}
	}
	return 0;
}

Measured memory_bytes: 584
#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));
    
    }
}




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<stdio.h>

int main(){
	
    int a,b,c,n;
    scanf("%d %d %d",&a,&b,&c);
    for(int i=a ; i<=b ; i++){
        if(c%i==0){
            n++;
        }
    }
    printf("%d\n",n);
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("NO"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 200005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;


int n;
int rev(int x) {
  int res = 0;
  rep(i,n) {
    res = res<<1|(x&1);
    x >>= 1;
  }
  return res;
}

int main() {
  scanf("%d",&n);
  int n2 = 1<<n;
  vi a(n2);
  cin>>a;
  rep(i,n2) a[i]--;
  vi l(n2), r(n2,n2-1);
  rep(i,n2) {
    if (a[i] == -1) continue;
    l[i] = r[i] = a[i];
  }
  rep(i,n2)rep(j,n) if (i>>j&1) {
    maxs(l[i],l[i^(1<<j)]);
  }
  drep(i,n2)rep(j,n) if (i>>j&1) {
    mins(r[i^(1<<j)],r[i]);
  }
  v(vp) p(n2);
  rep(i,n2) {
    p[l[i]].pb(P(r[i],i));
  }

  PQ(P) q;
  vi as;
  rep(i,n2) {
    for (P np : p[i]) q.push(np);
    if (!sz(q)) dame;
    if (q.top().fi < i) dame;
    as.pb(q.top().se); q.pop();
  }

  vi ans(n2);
  rep(i,n2) ans[rev(as[i])] = i+1;
  cout<<"YES"<<endl;
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 24696
#include <stdio.h>
int main(){
    int N,A,B;
    scanf("%d %d %d",&N,&A,&B);
    int score,sum;
    
    for(int i=1;i<=N;i++){
        sum = i%10;
        if(i/10 != 0){
            sum = sum + ((i/10)%10);
        }
        if(i/100 != 0){
            sum = sum + ((i/100)%10);
        }
        if(i/1000 != 0){
            sum = sum + ((i/1000)%10);
        }
        if(i/10000 != 0){
            sum = sum + ((i/10000)%10);
        }
        
        if(sum > (A-1) && sum < (B+1)){
            score = score + i;
        }
    }
    printf("%d",score);
    return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int ma = 0;
	int x = 0;
	int n;
	cin>>n;
	string s;
	cin>>s;
	for(auto it:s)
	{
		if(it=='I') x++;
		else x--;
		ma = max(x,ma);
	}
	cout<<ma<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val r = Array(n) { ArrayList<Int>() }
    for (i in 1..m) {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() - 1 }
        r[a].add(b)
        r[b].add(a)
    }
    val ans0 = ArrayList<Int>()
    val ans1 = ArrayList<Int>()
    val w = BooleanArray(n)
    w[0] = true

    fun turn(v: Int): Int? {
        return r[v].firstOrNull { !w[it] }
    }
    fun path(ans: MutableList<Int>, vBegin: Int) {
        var v: Int? = vBegin
        while (v != null) {
            ans.add(v)
            w[v] = true
            v = turn(v)
        }
    }

    val v1 = turn(0)
    if (v1 != null) path(ans0, v1)
    val v2 = turn(0)
    if (v2 != null) path(ans1, v2)
    println(ans0.size + ans1.size + 1)
    ans0.reversed().forEach { print("${it + 1} ") }
    print("1 ")
    ans1.forEach { print("${it + 1} ") }
}


Measured memory_bytes: 75020
// At Corder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;
	cout << t << s << endl;
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

int main()
{
    long long n,a;
    cin>>n>>a;
    
    long long s=a;
    long long i=2;
    while(s%n!=0 ){
        s=a*i;
        i++;
    }
 
    cout<<s<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char s[100];
char a[100];
int main()
{
	gets(s);
   if(strlen(s)==2)
	{
		puts(s);
	}
	if(strlen(s)==3)
	{
		for(int j=2;j>=0;j--)
		{
			printf("%c",s[j]);
		}
		printf("\n");
	}
	return 0;
}

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

namespace _0642
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            int[] cells = ReadIntAr();

            int sum = 0;
            int max = 0;
            for (int i = 0 ; i < n ; i++)
            {
                if (cells[i] == 1) sum++;
                else sum = 0;
                max = Math.Max(max, sum);
            }
            Console.WriteLine(max + 1);

        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 17948
#include<bits/stdc++.h>
#define il inline
#define vd void
typedef long long ll;
il ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
ll A[100010],B[100010],ans[100010];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi();
	for(int i=2;i<=n;++i)A[i]=gi();
	A[1]=gi();
	B[1]=A[1];
	for(int i=1;i<n;++i)B[i+1]=A[i+1]-B[i];
	ans[n]=B[n]/2;
	ans[1]=A[1]-ans[n];
	for(int i=2;i<n;++i)ans[i]=A[i]-ans[i-1];
	for(int i=1;i<=n;++i)printf("%lld ",ans[i]*2);
	return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	ll h, w, d;
	cin >> h >> w >> d;

	vector<ll> x(h * w + 1), y(h * w + 1);
	rep(i, h) rep(j, w) {
		int a;
		cin >> a;
		x[a] = i;
		y[a] = j;
	}

	vector<ll> r(h* w + 1, 0);
	for (int s = h * w; s >= h * w - d + 1; s--)
	{
		for (int i = s - d; i >= 0; i -= d)
		{
			int cost = llabs(x[i + d] - x[i])
				+ llabs(y[i + d] - y[i]);
			r[i] = r[i + d] + cost;
		}
	}

	ll q;
	cin >> q;

	rep(i, q)
	{
		int ll, rr;
		cin >> ll >> rr;
		out(r[ll] - r[rr]);
	}

	return 0;
}

Measured memory_bytes: 3200
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right,bisect_left
from itertools import accumulate

def main():
    N, H = map(int, input().split())
    a = [None] * N
    b = [None] * N
    for i in range(N):
        a[i], b[i] = map(int, input().split())
    a.sort()
    b.sort()
    i = bisect_left(b,a[N-1])
    c = list(accumulate(b[i:][::-1]))
    # print(c)
    M = len(c)
    count = bisect_left(c,H)
    if count < M:
        print(count+1)
    else:
        print(count + (H-c[M-1] + a[N-1]-1)//a[N-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 17508
#include<cstdio>
#include<iostream>
using namespace std;
long long a,b,c;
int main() {
	cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0){
		cout<<0<<endl;
		return 0;
	}
	if(a>b){
		long long t=a;
		a=b;
		b=t;
	}
	if(b>c){
		long long t=c;
		c=b;
		b=t;
	}
	
	a=a*b;
	cout<<a<<endl;
	return 0;
}

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

int main(){
  int a, b;
  char op;
  
  while(1){
    cin >> a >> op >> b;
  
    if ( op == '?' ) break;
    if ( op == '+' ) cout << a+b << endl;
    if ( op == '-' ) cout << a-b << endl;
    if ( op == '*' ) cout << a*b << endl;
    if ( op == '/' ) cout << a/b << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int A,B,X;
    cin >> A >> B >> X;
    if(A<=X&&A+B>=X)    cout << "YES\n";
    else    cout << "NO\n";
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
//#include "graph.cpp"
#define ll long long
#define loop(i,n) for(int i=0 ; i<n ; ++i)
#define rep(i,x,n) for(int i=x ; i<=n ; ++i)
#define iteloop(type,data,name,it) for(type<data>::iterator it=name.begin() ;it!=name.end() ; ++it)
#define getOpp(x) (x^2)
#define NOT(x) (x^1)
using namespace std;
using namespace __gnu_pbds;

typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_set;
double a,b,t;
int main(){
    cin.sync_with_stdio(false), cin.tie(0) , cout.tie(0);
    cin>>a>>b>>t;
    cout<<floor((t+0.5)/a)*b<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;
ull L[87];

int main(){
   int N;

   L[0] = 2, L[1] = 1;

    repc (i, 2, 87) L[i] = L[ i - 1 ] + L[ i - 2 ];

    cin >> N;
    cout << L [N] << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication87
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] a = new long[4];
            a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long b = long.Parse(Console.ReadLine());
            long[] c = new long[4];
            c[0] = a[0] * 8;
            c[1] = a[1] * 4;
            c[2] = a[2] * 2;
            c[3] = a[3];
            Array.Sort(c);
            /*Console.WriteLine(c[0]);*/
            long[] d = new long[3];
            d[0]=a[0]*4;
            d[1]=a[1]*2;
            d[2]=a[2];
            Array.Sort(d);
            long com=0;
            long ans = 0;
            long anp = 0;
            if (b == 0)
                Console.WriteLine(0);
            if (b == 1)
                Console.WriteLine(d[0]);
            if (b > 1)
            {
                com = b % 2;
                if (com == 1)
                {
                    ans = (b - 1) / 2;
                    /*Console.WriteLine(ans);*/
                    anp += ans * c[0];
                    /*Console.WriteLine(anp);*/
                    anp += d[0];
                }
                else anp = (b / 2) * c[0];
                Console.WriteLine(anp);
                Console.ReadLine();
            }


        }
    }
}


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

int main(){
  int n, sum=0; cin >>n;
  vector<int>a(n);
  for(int i=0; i<n; i++){cin >>a[i];}
  for(int i=0; i<n-1; i++){
  for(int j=i+1; j<n; j++)
  {sum+=a[i]*a[j];}
  }
  cout <<sum;
return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONGINF 1000000000000000000
int main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	bool hoge = false;
	REP(i, s.length()) {
		if (s[i] == 'C') {
			hoge = true;
		}
		if (s[i] == 'F'&&hoge == true) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << 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 n=sc.nextInt();
		String s=sc.next();
		int sum=0;
		for(int i=0;i<n;i++) {
			if(s.substring(i,i+1).equals("R"))sum++;
		}
		System.out.println(sum>n/2?"Yes":"No");
	}
}

Measured memory_bytes: 23892
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  int n;
  cin >> n;

  int count = 0;
  while (true) {
    n = n / 3 + (n % 3 ? 1 : 0);
    count++;
    if (n == 1 || n == 0)
      break;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;

int N,M,C;
int B[21];
int A[21];
int ret;
signed main(){
    cin>>N>>M>>C;
    rep(i,M)cin>>B[i];
    rep(i,N){
        int ans=0;
        rep(j,M){
            int a;
            cin>>a;
            ans+=B[j]*a;
        }
        ans+=C;
        if(ans>0)ret++;
    }
    cout<<ret<<endl;

}

Measured memory_bytes: 256
import java.awt.Point;
import java.io.FileInputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	
	static Point wh;
	
	// -1 : a < b
	//  0 : a = b
	//  1 : a > b
	static int cmp(Point a, Point b)
	{
		int la = a.x*a.x + a.y*a.y;
		int lb = b.x*b.x + b.y*b.y;
		
		if(la < lb) return -1;
		if(la > lb) return 1;
		
		if(a.y < b.y) return -1;
		if(a.y > b.y) return 1;
		
		return 0;
	}
	
	static void start()
	{
		int w, h;
		Point min = new Point(200, 200);
		
		for(h = 1;h <= 150;h++)
			for(w = 1;w <= 150;w++)
			{
				if(h == wh.y && w == wh.x) continue;
				if(h >= w) continue;
				
				Point newp = new Point(w, h);
				if(cmp(wh, newp) == 1) continue;
				
				if(cmp(min, newp) == 1)
				{
					min = newp;
				}
			}
		
		System.out.printf("%d %d\n", min.y, min.x);
	}
	
	public static void main(String[] args)
	{
		
		Scanner sca = new Scanner(System.in);
		
		while(true)
		{
			int h = sca.nextInt();
			int w = sca.nextInt();
			if(h == 0) break;
			
			wh = new Point(w, h);
			start();
		}
	}
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 8010;
int x, y;
string s;
bool dp1[N * 2], dp2[N * 2];
bool t;
bool fx, fy;
int sum;

void update() {
    bool temp[N * 2];
    memset(temp, 0, sizeof temp);
    if (t) { // y
        if (!fy) {
            fy = true;
            dp2[N + sum] = true;
            dp2[N - sum] = true;
        } else {
            for (int i = 0; i < N * 2; ++i) {
                if (dp2[i]) {
                    if (i > sum)
                        temp[i - sum] = true;
                    if (i < N * 2 - sum)
                        temp[i + sum] = true;
                }
            }
            memcpy(dp2, temp, sizeof temp);
        }
    } else { // x
        if (!fx) {
            fx = true;
            if (s[0] == 'F') {
                dp1[N + sum] = true;
            } else {
                dp1[N + sum] = true;
                dp1[N - sum] = true;
            }
        } else {
            for (int i = 0; i < N * 2; ++i) {
                if (dp1[i]) {
                    if (i > sum)
                        temp[i - sum] = true;
                    if (i < N * 2 - sum)
                        temp[i + sum] = true;
                }
            }
            memcpy(dp1, temp, sizeof temp);
        }
    }

    sum = 0;
}

int main() {
    cin >> s >> x >> y;
    int n = s.length();
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'T') {
            if (sum)
                update();
            t = !t;
        } else {
            ++sum;
        }
    }
    if (sum)
        update();
    if (!fx)
        dp1[N] = true;
    if (!fy)
        dp2[N] = true;

    if (dp1[N + x] && dp2[N + y])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3716
#include <stdio.h>
#include <stdlib.h>

typedef enum {
  false,
  true
}boolean;

typedef struct {
	int a;
	int b;
	int c;
}edge;

typedef struct vsub{
	int v;
	int num;
	struct vsub **nexts;
	int *c;
}vertex;

boolean search(boolean *grave, vertex *ver, int sum, int dest, int border){
	if(sum >= border){
		return false;
	}
	if(sum < border && ver->v == dest){
		return true;
	}
	int i;
	for(i = 0; i < ver->num ;i++){
		if(grave[(ver->nexts)[i]->v] == false){
			grave[(ver->nexts)[i]->v] = true;
			if(search(grave , (ver->nexts)[i], sum + (ver->c)[i], dest, border) == true){
				grave[(ver->nexts)[i]->v] = false;
				return true;
			}
			grave[(ver->nexts)[i]->v] = false;
		}
	}
	return false;
}

int main(){
	int N, M, i, a, b, c, ans = 0;
	scanf("%d%d", &N, &M);
	edge E[M];
	vertex *V[N];
	for(i = 0; i < N; i++){
		V[i] = (vertex *)malloc(sizeof(vertex));
		V[i]->v = i;
		V[i]->num = 0;
		V[i]->nexts = (vertex **)malloc(sizeof(vertex *) * N);
		V[i]->c = (int *)malloc(sizeof(int) * N);
	}
	for(i = 0; i < M; i++){
		scanf("%d%d%d", &a, &b, &c);
		a--;
		b--;
		E[i].a = a;
		E[i].b = b;
		E[i].c = c;
		(V[a]->nexts)[V[a]->num] = V[b];
		(V[a]->c)[V[a]->num] = c;
		(V[a]->num)++;
		(V[b]->nexts)[V[b]->num] = V[a];
		(V[b]->c)[V[b]->num] = c;
		(V[b]->num)++;
	}
	boolean *grave;
	grave = (boolean *)malloc(sizeof(boolean) * N);
	for(i = 0; i < N; i++){
		grave[i] = false;
	}
	for(i = 0; i < M; i++){
		grave[E[i].a] = true;
		if(search(grave, V[E[i].a], 0, E[i].b, E[i].c) == true){
			ans++;
		}
		grave[E[i].a] = false;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define _USE_MATH_DEFINES
#include<math.h>

int main(void)
{
	double a,b,c,p,s,l,h;
	scanf("%lf %lf %lf",&a,&b,&c);
	p=c*M_PI/180;
	s=a*b*sin(p)*0.5;
	l=a+b+sqrt(a*a+b*b-2.0*a*b*cos(p));
	h=b*sin(p);
	printf("%lf\n%lf\n%lf\n",s,l,h);
	return 0;   
}

Measured memory_bytes: 648
n = int(input())
from collections import Counter
ss = []
for i in range(n):
    ss.append(input())
c = Counter(ss)
for w in ["AC", "WA", "TLE", "RE"]:
    if w in c.keys():
        print(f"{w} x {c[w]}")
    else:
        print(f"{w} x 0")

Measured memory_bytes: 16612
#include<cstring>
#include<cstdio>
#include<iostream>
#define max(a,b) (a>b?a:b)
int dp[305][305][305],mk,len;
char a[305];
int main(){
	scanf("%s%d",a+1,&mk);
	len=strlen(a+1);
	for(int i=1;i<=len;i++){
		for(int j=i;j>=1;j--){
			if(i==j){
				for(int k=0;k<=mk;k++) dp[j][i][k]=1;
				continue;
			}
			if(i-j==1){
				dp[j][i][0]=(a[i]==a[j]?2:1);
				for(int k=1;k<=mk;k++) dp[j][i][k]=2;
			}
			for(int k=0;k<=mk;k++)
				if(k){
					dp[j][i][k]=max(dp[j+1][i-1][k-1]+2,max(dp[j+1][i-1][k]+(a[i]==a[j])*2,max(dp[j+1][i][k],dp[j][i-1][k])));
				}
				else{
					dp[j][i][k]=max(dp[j+1][i-1][k]+(a[i]==a[j])*2,max(dp[j+1][i][k],dp[j][i-1][k]));
				}
		}
	}
	printf("%d\n",dp[1][len][mk]);
}

Measured memory_bytes: 110464