akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
struct node
{
	 int c;
	 int num;
	 
};
struct node a[100005],b[100005];

bool cmp(node a,node b)
{
	 return a.c>b.c;
}
int main()
{for(int i=0;i<100005;i++)
{
	a[i].c=0;
	a[i].num=i;
	b[i].c=0;
	b[i].num=i;
}
	 int n;
	 cin>>n;
	  int jd=0,od=0,jx=1000000000,ox=1000000000;
	 vector<int>j,o;
	 int jmax=0,jmaxn=0,omax=0,omaxn=0;
	 for(int i=1;i<=n;i++)
	 {int t;
	 cin>>t;
	 
	 	if(i&1)
	 	{
	 	    j.push_back(t);
	 	    jd=max(jd,t);
	 	    jx=min(jx,t);
	 	    a[t].c++;
	 	  
	 	    if(a[t].c>jmax)
	 	    {
	 	    	jmax=a[t].c;
	 	    	jmaxn=t;
			 }
		 }
		 else
		 {   
		 	o.push_back(t);
		 	od=max(od,t);
		 	ox=min(ox,t);
		 	b[t].c++;
		 	if(b[t].c>omax)
	 	    {
	 	    	omax=b[t].c;
	 	    	omaxn=t;
			 }
		 }
	 	
	 }
	 if(jd==od&&jx==ox&&jd==jx)
	    {
	    	cout<<j.size()<<endl;
	    	return 0;
		}
	 sort(a,a+100005,cmp);
	 	 sort(b,b+100005,cmp);
	 	
	
	
	/* jd=max_element(j.begin(),j.end());
	  od=max_element(o.begin(),o.end());
	   jx=min_element(j.begin(),j.end());
	    ox=min_element(o.begin(),o.end());*/
	    
	    int jc=0,oc=0;
	    if(jmaxn==omaxn)
	    {    
	     
		   if(a[1].c>b[1].c)
	    	{
	    		jmaxn=a[1].num;
			}
			else
			{
				omaxn=b[1].num;
			}
				
		}
	    for(int i=0;i<j.size();i++)
	    {
	    	if(jmaxn!=j[i])
	    	{
	    		jc++;
	    		j[i]=jmaxn;
			}
		}
		
		  for(int i=0;i<o.size();i++)
	    {
	    	if(omaxn!=o[i])
	    	{
	    		oc++;
	    		o[i]=omaxn;
			}
		}
		cout<<jc+oc<<endl;
}

Measured memory_bytes: 2428
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

class UnionFindTree
    attr_accessor:par,:rank
    def initialize(n)
        @par=Array.new(n){|i| i}
        @rank=array(n,0)
    end

    def find(x)
        return x if @par[x]==x
        @par[x]=find(@par[x])
        return @par[x]
    end

    def union(x,y)
        x=find(x)
        y=find(y)
        return if x==y
        if @rank[x]<@rank[y]
            @par[x]=y
        else
            @par[y]=x
            @rank[x]+=1 if @rank[x]==@rank[y]
        end
    end

    def same?(x,y)
        return find(x)==find(y)
    end
end
N=gets.to_i
a=get_i.sort
ans=0
uft=UnionFindTree.new(N)
(N-1).times do|i|
  uft.union(i,i+1) if a[i+1]<=2*a[i]
  a[i+1]+=a[i]
end
ans=0
N.times do|i|
  ans+=1 if uft.same?(i,N-1)
end
puts ans

Measured memory_bytes: 12048
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}

const string YES = "Yes";
const string NO = "No";
#define judge(f) cout<<(f?YES:NO)<<"\n";

void solve(long long N, long long M, std::vector<long long> A){
    ll sum=vsum(A);
    ll cnt=0;
    for (long long i = 0; i < N; i++) {
        if(A[i]>=sum*1.0/(4*M)) cnt++;
    }
    judge(cnt>=M)
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

int main()
{
	fastio;
	lli x,n=100,i=0;
	cin>>x;
	while(n<x)
	{
		n=n+(lli)(n/100);
		i++;
		if(n>x)
			break;
//		cout<<n<<endl;
	}
	cout<<i;	
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
 
 
int main(){
    ll N; cin >> N;
    for(int i = 0; i < N; i++){
        char ch; cin >> ch;
        if(ch == 'Y'){
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;



}

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

const int INF = 1e9;
const int MAX = 55;
int n, m;
struct edge{
    int to;
    int cost;
};
vector<edge> G[MAX];
int D[MAX];

void dijkstra(int s, int x, int y){
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
    for(int i = 0; i < n; i++){
        D[i] = INF;
    }
    D[s] = 0;
    q.push({0, s});

    while(!q.empty()){
        pair<int, int> p = q.top();
        q.pop();
        int now = p.second;
        if(D[now] < p.first) continue;
        for(int i = 0; i < G[now].size(); i++){
            edge e = G[now][i];
            if((now == x and G[now][i].to == y) or (now == y and G[now][i].to == x)) continue; 
            if(D[e.to] > D[now] + e.cost){
                D[e.to] = D[now] + e.cost;
                q.push({D[e.to], e.to});
            }
        }
    }
}

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

    cin >> n >> m;

    vector<int> A(m), B(m);

    for(int i = 0; i < m; i++){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        G[A[i]].push_back({B[i], 1});
        G[B[i]].push_back({A[i], 1});
    }

    int ans = 0;
    for(int i = 0; i < m; i++){

        dijkstra(0, A[i], B[i]);

        for(int j = 0; j < n; j++){
            if(D[j] == INF){
                ans++;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int n, a[50];

int solve(int, int);

int main(){
  int q, m, i;

  scanf("%d", &n);
  for(i = 0;i < n;i++){
    scanf("%d", &a[i]);
  }
  scanf("%d", &q);
  for(i = 0;i < q;i++){
    scanf("%d", &m);
    if(solve(0, m)){
      printf("yes\n");
    }
    else printf("no\n");
  }
  return 0;
}

int solve(int i, int m){
  int res;

  if(m == 0) return 1;
  if(i >= n) return 0;
  res = solve(i+1, m) || solve(i+1, m-a[i]);
  return res;
}

Measured memory_bytes: 580
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;
const int MAX_N = 2 * 10e5 + 5;
int arr[MAX_N];


int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int a;
        scanf("%d", &a);
        arr[i] = a - i - 1;
    }
    sort(arr, arr + n);
    int mid = n / 2;
    int b;
    if (n % 2 == 0)
        b = (arr[mid] + arr[mid - 1]) / 2;
    else
        b = arr[mid];
    unsigned long long sum = 0;
    for (int j = 0; j < n; ++j) {
        sum += (unsigned long long) abs(arr[j] - b);
    }
    printf("%lld", sum);
    return 0;
}

Measured memory_bytes: 896
import collections
def main():
    n,z,w=map(int, input().split())
    a=[int(i) for i in input().split()]
    #途中選り好みしても結局a_n - a_n-1になる
    if(n==1):
        print((abs(w-a[0])))
    else:
        print(max(abs(a[n-1]-a[n-2]), abs(a[n-1]-w)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9668
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    string s; cin >> s;
    s = 'X' + s;
    ll ans = 0;
    REP(i, n){
        ans += (s[i] != s[i+1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
/*
g++ -std=c++14 -O2 -Wall a.cpp -o a && a
*/

//  io
#include <iostream>
//#include <fstream> //http://www.cplusplus.com/reference/fstream/fstream/
//#include <cstdio>
//#include <iomanip> //http://www.cplusplus.com/reference/iomanip/
//  util
#include <string>
//#include <cstring>
#include <algorithm>
//#include <utility>
//#include <functional> //http://www.cplusplus.com/reference/functional/
//#include <cstdlib>
//#include <cmath>
//#include <complex>
//#include <random>
//#include <bitset>
//  containers https://en.cppreference.com/w/cpp/container
#include <vector>
//#include <queue>
//#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//  time
//#include <ctime>
//#include <chrono>
//                  https://en.cppreference.com/w/cpp/header/chrono
//                  http://www.cplusplus.com/reference/chrono/

using namespace std;
typedef vector<int> arri;
typedef vector<float> arrf;
typedef pair<int, int> pairi;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 0x7fffffffffffffff;
const ll infneg = -0x7fffffffffffffff;

//int modadd(int a, int b) { return ((a += b) < mod) ? a : (a - mod); }
//int modmult(int a, int b) { return (int)((a * b) % mod) }

//file input routed to stdinout
/*
std::ifstream inFile("input.txt");
std::ofstream outFile("output.txt");
std::cin.rdbuf(inFile.rdbuf());
std::cout.rdbuf(outFile.rdbuf());
*/

int digCount(int a)
{
    int ret = 0;
    do
    {
        a /= 10;
        ret++;
    } while (a > 0);
    return ret;
}

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

    int N;
    cin >> N;

    int tot = 0;
    for (int i = 1; i <= N; i++)
    {
        if (digCount(i) % 2)
        {
            tot++;
        }
    }
    cout << tot;
}


Measured memory_bytes: 256
//
//  main.cpp
//  B - Judge Status Summary
//
//  Created by 李远铄 on 2020/8/7.
//  Copyright © 2020 李远铄. All rights reserved.
//

#include <iostream>
#include <string>

#define _DEBUG_
#ifdef _DEBUG_
#define debug(x) cout << #x << ": " << x << "  "
#define print_n printf("\n")
#define cout_n cout<<'\n'
#else
#define debug(x)
#define print_n
#define cout_n
#endif


using namespace std;
char s[10];
int a,w,t,r;
int main(int argc, const char * argv[]) {
    int n;
    scanf("%d",&n);
    while(n--){
        scanf("%s",s);
        if(s[0]=='A'){
            a++;
        }else if(s[0]=='W'){
            w++;
        }else if(s[0]=='T'){
            t++;
        }else if(s[0]=='R'){
            r++;
        }
    }
    printf("AC x %d\n",a);
    printf("WA x %d\n",w);
    printf("TLE x %d\n",t);
    printf("RE x %d\n",r);
    return 0;
}


Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e3+10;
int h,n,A[MAX],B[MAX];
int dp[MAX][10*MAX];
int solve(int idx,int rem){
    if(rem<=0)return 0;
    if(idx>n)return 1e9;
    if(dp[idx][rem]!=-1)return dp[idx][rem];
    int ret = B[idx] + solve(idx,rem-A[idx]);
    ret = min(ret,solve(idx+1,rem));
    return dp[idx][rem] = ret;
}
int main (){
    memset(dp,-1,sizeof dp);
    cin >> h >> n;
    for(int i=1;i<=n;i++){
        cin >> A[i] >> B[i];
    }
    cout<<solve(1 , h);
    //main();
    return 0;
}



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

main()
{
    int n;
    cin>>n;
    int a[n+1];
    map<int,int>m;
    ll ans=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        ans+=m[a[i]-i];
        m[-a[i]-i]++;
    }
    cout<<ans;
    return 0;
}


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

int main()
{
    int A, B;
    cin >> A >> B;

    int ans = 6 - (A + B);

    // for (int i = 1; i <= 3; i++)
    // {
    //     if (i != A && i != B)
    //         ans = i;
    // }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
S = input()

N = len(S)

ans = 'Yes'
for i in range(N//2):
    if S[i] != S[N-1-i]:
        ans = 'No'
        break

for i in range(N//4):
    if S[i] != S[int((N-1)/2)-1-i]:
        ans = 'No'
        break

for i in range(N//4):
    if S[int((N+3)/2)-1+i] != S[N-1-i]:
        ans = 'No'
        break

print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int cnt[200005];
int main(){
    int n, p;
    cin >> n >> p;
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    ll ans = 0;
    ll sum = 0;
    cnt[0]++;
    ll ten = 1;
    if(p == 2){
        rep(i,n){
            int k = s[i]-'0';
            if(k&1)continue;
            ans += n - i;
        }
    }else if(p == 5){
        rep(i,n){
            int k = s[i]-'0';
            if(k == 0 or k == 5){
                ans += n - i;
            }
        }
    }else{
        rep(i,n){
            int k = s[i] - '0';
            sum = (sum + k * ten) % p;
            ten *= 10;
            ten %= p;
            ans += cnt[(p + sum)%p];
//            cout << i << " " << sum  << " " << cnt[(p-sum)%p] << " " << cnt[sum]+1 << endl;
            cnt[sum]++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 644
#coding:utf-8
#1_10_C 2015.4.14
import math

while True:
    n = int(input())
    if n == 0:
        break
    scores = list(map(int,input().split()))
    ave = sum(scores)/n
    sd = math.sqrt(sum([(s - ave)**2 for s in scores])/n)
    print('{:.10f}'.format(sd))

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

#define M_W  10e5
int main() {
	vector<bool> D(M_W + 1, false);
	vector<long long> V(M_W + 1, 0);
	D[0] = true;
	V[0] = 0;
	int N, W;
	cin >> N >> W;
	while (N--) {
		int w, v;
		cin >> w >> v;
		for (int i = W; i >= 0; i--)
			if (D[i] && V[i] + v > V[i + w]) {
				V[i + w] = V[i] + v;
				D[i + w] = true;
			}
	}

	long long ans = 0;
	for (int i = W; i >= 0; i--) {
		if (D[i] && V[i] > ans) {
			ans = V[i];
		}
	}

	cout << ans << endl;
}

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

int main() {
  int N;
  int n;
  int i, l, r;
  cin >> N;
  
  for (i = 0; i < N; i++) {
    cin >> l >> r;
    n += r - l + 1;
  }
  cout << n << endl;
}


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

int main(){
    int n;
    std::cin >> n;

    std::vector<long> a(n);
    for(int i = 0; i < n; ++i){
        std::cin >> a.at(i);
    }

    int val;
    std::vector<long> diff;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            val = abs(a.at(i) - a.at(j));
            diff.push_back(val);
        }
    }

    std::cout << *max_element(diff.begin(), diff.end()) << std::endl;

    return 0;
}


Measured memory_bytes: 512
import copy 

n = int(input())
c = input().split()
c_sel = copy.deepcopy(c)

# check stability of default array
ord_dict_def = {}
for i in range(n) :
    if int(c[i][1]) in ord_dict_def.keys() :
        ord_dict_def[int(c[i][1])] += c[i][0]
    else :
        ord_dict_def[int(c[i][1])] = c[i][0]
        
# do bubble 
for i in range(n) :
    for j in range(n - 1, i, -1) :
        if int(c[j - 1][1]) > int(c[j][1]) :
            c[j - 1], c[j] = c[j], c[j - 1]

# check stability for bubble
ord_dict_bubble = {}

for i in range(n) :
    if int(c[i][1]) in ord_dict_bubble.keys() :
        ord_dict_bubble[int(c[i][1])] += c[i][0]
    else :
        ord_dict_bubble[int(c[i][1])] = c[i][0]
        
# do selection
for i in range(n) :
    cmin = i
    for j in range(i + 1, n) :
        if int(c_sel[j][1]) < int(c_sel[cmin][1]) :
            cmin = j
            
    if i != cmin :
        c_sel[i], c_sel[cmin] = c_sel[cmin], c_sel[i]

# check stability for selection
ord_dict_selection = {}

for i in range(n) :
    if int(c_sel[i][1]) in ord_dict_selection.keys() :
        ord_dict_selection[int(c_sel[i][1])] += c_sel[i][0]
    else :
        ord_dict_selection[int(c_sel[i][1])] = c_sel[i][0]
        
stability_bubble = "Stable"
stability_selection = "Stable"

for i in ord_dict_bubble.keys() :
    if ord_dict_def[i] != ord_dict_bubble[i] :
        stability_bubble = "Not stable"
        
    if ord_dict_def[i] != ord_dict_selection[i] :
        stability_selection = "Not stable"
        
print(" ".join(c))
print(stability_bubble)
print(" ".join(c_sel))
print(stability_selection)


Measured memory_bytes: 6352
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;

int main()
{
    int n,m;
    cin >> n >> m;
    
    char matrix[n+1][m+1];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin >> matrix[i][j] ;
        }
    }
    
    int dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    dp[1][1] = 1;
    
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            //goin right 
            if(j+1 <= m && matrix[i][j+1] != '#')
                dp[i][j+1] = (dp[i][j+1]%mod + dp[i][j]%mod)%mod;
                
            //goin down    
            if(i+1 <= n && matrix[i+1][j] != '#')
                dp[i+1][j] = (dp[i+1][j]%mod + dp[i][j]%mod)%mod;
                
        }
    }
    
    cout << dp[n][m] << endl;
    return 0;
}

Measured memory_bytes: 5120
#include <stdio.h>
#define SIZE 100
#define nil -1

typedef struct
{
    int par, right, left;
} node;

int n, dep[SIZE], hei[SIZE];
node t[SIZE];

int max(int, int);
int height(int);
void depth(int, int);
int sibling(int);

int main()
{
    int i, root = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
        t[i].par = t[i].left = t[i].right = nil;

    for (i = 0; i < n; i++)
    {
        int id, l, r;
        scanf("%d %d %d", &id, &l, &r);
        t[id].left = l;
        t[id].right = r;
        if (l != nil)
            t[l].par = id;
        if (r != nil)
            t[r].par = id;
    }

    for (i = 0; i < n; i++)
        if (t[i].par == nil)
            root = i;

    depth(root, 0);

    for (i = 0; i < n; i++)
    {
        int degcnt = 0;
        if (t[i].left != nil)
            degcnt++;
        if (t[i].right != nil)
            degcnt++;
        printf("node %d: parent = %d, ", i, t[i].par);
        printf("sibling = %d, ", sibling(i));
        printf("degree = %d, ", degcnt);
        printf("depth = %d, ", dep[i]);
        printf("height = %d, ", height(i));

        if (t[i].par == nil)
            printf("root\n");
        else if (t[i].left == nil && t[i].right == nil)
            printf("leaf\n");
        else
            printf("internal node\n");
    }

    return 0;
}

int max(int a, int b)
{
    return a > b ? a : b;
}
int height(int u)
{
    int a = 0, b = 0;
    if (t[u].left != nil)
        a = height(t[u].left)+1;
    
    if(t[u].right != nil)
        b = height(t[u].right)+1;

    return max(a,b);
}

void depth(int u, int d)
{
    if (u == nil)
        return;
    dep[u] = d;
    depth(t[u].left, d + 1);
    depth(t[u].right, d + 1);
}

int sibling(int u)
{
    int tmp;
    tmp = t[u].par;
    if (tmp == nil)
        return nil;

    if (t[tmp].left != u && t[tmp].left != nil)
        return t[tmp].left;

    if (t[tmp].right != u && t[tmp].right != nil)
        return t[tmp].right;

    return nil;
}



Measured memory_bytes: 2760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sn = new Scanner(System.in);
		int x = sn.nextInt();
		if(x < 1200){
			System.out.print("ABC");
		}else{
			System.out.print("ARC");
		}
	}

}


Measured memory_bytes: 20820
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

constexpr int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return x ? mod - x : 0;}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}

  friend ostream& operator << (ostream& os, const mint& m) noexcept {
    return os << m.x;
  }

  friend istream& operator<< (istream& is, mint& m) noexcept {
    return is >> m.x;
  }
};

ll dfs(const int& k, vector<vector<int>>& e, int now, int p = -1) {
  int num_color = k - (p == -1 ? 1 : 2);
  if (k < e[now].size()) {
    return 0;
  }
  mint case_num = 1;
  for (auto x : e[now]) {
    if (x == p) continue;
    // 子供について
    case_num *= num_color;
    num_color--;
  }
  for (auto x : e[now]) {
    if (x == p) continue;
    case_num *= dfs(k, e, x, now);
  }
  return case_num.x;
}

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

  int n, k;
  cin >> n >> k;
  vector<vector<int>> e(n);
  rep(i, n-1) {
    int a, b; cin >> a >> b; a--; b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }

  ll ans = (k * dfs(k, e, 0)) % mod;

  cout << ans << endl;

  return 0;
}


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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DFriendSuggestions {
public:

    std::vector<int> par;
    std::vector<int> rak; // number of the vertices

    void init(int n) {
      par.resize(n);
      rak.resize(n);
      for(int i=0; i<n; i++) {
        par[i] = i;
        rak[i] = 1;
      }
    }

    int find(int x) {
      if (par[x] == x) {
        return x;
      } else {
        return par[x] = find(par[x]);
      }
    }

    void unite(int x, int y) {
      x = find(x);
      y = find(y);
      if (x==y) return;
      if (rak[x] < rak[y]) {
        rak[y] += rak[x];
        par[x] = y;
      } else {
        rak[x] += rak[y];
        par[y] = x;
      }
    }

    bool same(int x, int y) {
      return find(x) == find(y);
    }

    vector<int> blocked[100005];
    vector<int> fri[100005];
    vector<int> roots;

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m, k; cin >> n >> m >> k;
      init(n);

      rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        unite(a, b);
        fri[a].push_back(b);
        fri[b].push_back(a);
      }

      rep(i, k) {
        int c, d; cin >> c >> d;
        c--; d--;
        blocked[c].push_back(d);
        blocked[d].push_back(c);
      }

      map<int, set<int>> mp;

      rep(i, n) {
        mp[find(i)].insert(i);
      }

      vector<int> ans(n);

      for(auto& e: mp) {
        set<int> st = e.second;
        for(auto f: e.second) {
          vector<int> erased;
          for(auto g: blocked[f]) {
            if (st.find(g) != st.end()) {
              st.erase(g);
              erased.push_back(g);
            }
          }
          for(auto g: fri[f]) {
            if (st.find(g) != st.end()) {
              st.erase(g);
              erased.push_back(g);
            }
          }
          ans[f] = st.size()-1;
          for(auto g: erased) {
            st.insert(g);
          }
        }
      }

      for(auto e: ans) {
        cout << e << ' ';
      }
      cout << endl;




    }
};

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

Measured memory_bytes: 23040
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)


    val n = sc.nextInt()
    val k = sc.nextInt()
    val s = sc.nextInt()

/*
    val random = Random()

    repeat(100000) {
        val n = 1 + random.nextInt(100)
        val k = random.nextInt(n + 1)
        val s = random.nextInt(100) + 1
*/

/*
        val n = 7
        val k = 5
        val s = 20
*/
        val res = buildString {
            if (n == k) {
                repeat(n) { append("$s ") }
            } else {
                if (s == 1) {
                    repeat(k) { append("1 ") }
                    repeat(n - k) { append("2 ") }
                } else if (s == 1e9.toInt()) {
                    repeat(k) { append("${1e9.toInt()} ") }
                    repeat(n - k) { append("2 ") }
                } else {
                    for (i in 0..k) {
                        if (i % 2 == 0) append("1 ")
                        else append("${s - 1} ")
                    }
                    repeat(n - k - 1) {
                        append("${s + 1} ")
                    }
                }
            }
        }
        println(res.trim())

/*
        if (!check(n, k, s, res)) {
            println("$n $k $s")
            println("Broken")
            return
        }
    }
*/
}

fun check(n: Int, k: Int, s: Int, res: String): Boolean {
    val a = res.trim().split(" ").map { it.toInt() }
    if (a.size != n) return false

    var c = 0
    for (l in 0 until n) {
        var sum = 0L
        for (r in l until n) {
            sum += a[r]
            if (sum == s.toLong()) c++
        }
    }
    //println(c)
    return c == k
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 41796
S = input()

T = ["dream", "dreamer", "erase", "eraser"]

S = S[::-1]
for i in range(4):
    T[i] = T[i][::-1]

can = True
i = 0
while i < len(S):
    can2 = False
    for t in T:
        if S[i:i + len(t)] == t:
            can2 = True
            i += len(t) - 1
    if can2 == False:
        can = False
        break
    i += 1

if can:
    print("YES")
else:
    print("NO")


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

int n, m, x, currentPrice;
int c[13], a[13][13], price[13], skill[13], ans = 1200000;
bool found;

bool cmp(int i, int j) {
    if (c[i] < c[j])
        return true;
    return false;
}

void findMinPrice(int next, int currentPrice, bool ok) {
    if (ok) {
        found = true;
        ans = min(ans, currentPrice);
        return;
    }
    
    if(next == n + 1) {
        if (!found)
            ans = -1;
        return;
    }

    for (int i = next; i <= n; i++) {
        ok = true;
        for (int j = 1; j <= m; j++) {
            skill[j] += a[price[i]][j];
            if(skill[j] < x)
                ok = false;
        }
        findMinPrice(i + 1, currentPrice + c[price[i]], ok);
        for (int j = 1; j <= m; j++)
            skill[j] -= a[price[i]][j];
    }
}

int main() {
    cin >> n >> m >> x;
    for (int i = 1; i  <= n; i++) {
        cin >> c[i];
        price[i] = i;
        for (int j = 1; j <= m; j++)
            cin >> a[i][j];
    }
    sort(price + 1, price + n + 1, cmp);

    for (int i = 1; i <= n; i++) {
        int ok = true;
        for (int j = 1; j <= m; j++) {
            skill[j] = a[price[i]][j];
            if(skill[j] < x)
                ok = false;
        }
        findMinPrice(i + 1, currentPrice + c[price[i]], ok);
        for (int j = 1; j <= m; j++)
            skill[j] -= a[price[i]][j];
    }

    if (found == false)
        cout << -1;
    else
        cout << ans;

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
using namespace std;

int main(){
	char a[4];
	cin>>a;
	if(strlen(a)==2)cout<<a<<"\n";
	else cout<<a[2]<<a[1]<<a[0]<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
const int maxn = 200+10;
int a[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i = 0 ;i < n ; i++)
	{
		scanf("%d",&a[i]);
	}
	int i = 0 ;
	int ans = 99999 , sum = 0;
	for(int i = 0 ; i < n ; i++)
	{
		sum = 0;
		while(a[i])
		{
			if(a[i]&1)
			{
				break;
			}
			a[i] /= 2;
			sum++;
		}
		ans = min(ans,sum);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
prev = -999
for i in a:
  i -= 1
  ans += b[i]
  if i == prev + 1:
    ans += c[prev]
  prev = i

print(ans)


Measured memory_bytes: 3060
n = int(input())
a = list(map(int,input().split()))
color = [0,0,0,0,0,0,0,0,0]
if min(a) >= 3200:
  print(1,len(a))
  quit()
for ai in a:
  if ai <= 3199:
    rnk = ai // 400
    color[rnk] += 1
  else:
    color[8] += 1

min_color = 0
for i in range(8):
  if color[i] > 0:
    min_color += 1
max_color = min_color + color[8]
print(min_color,max_color)

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

using namespace std;

typedef long long ll;
using pii = pair<int, int>;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

//--global--//



//----------//

int main(int argc, const char * argv[]) {
    //提出時、消す----//
 
    //--------------//
    
    int n;
    cin >> n;
    int *a;
    a = new int[MAX];
    int mi = INTINF;
    ll sum = 0;
    rep(i, n){
        cin >> a[i];
        if(a[i] > 0){
            mi = min(mi, a[i]);
            sum += a[i];
        }
        else{
            mi = min(mi, -a[i]);
            sum += -1*a[i];
        }
    }
    rep(i, n-1){
        if(a[i] < 0){
            a[i] *= -1;
            a[i+1] *= -1;
        }
    }
    bool lastisminus = false;
    if(a[n-1] <0)lastisminus = true;
    if(lastisminus){
        cout << (sum - mi*2) << endl;
    }
    else{
        cout << sum << endl;
    }
    
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int array[5];
	int i, j;
	
	for (i = 0; i < 5; i++){
		scanf("%d", array + i);
	}
	for (i = 0; i < 4; i++){
		for (j = 0; j < 4 - i; j++){
			if (array[j] < array[j + 1]){
				int tmp = array[j];
				array[j] = array[j + 1];
				array[j + 1] = tmp;
			}
		}
	}
	printf("%d", *array);
	for (i = 1; i < 5; i++){
		printf(" %d", array[i]);
	}
	puts("");
	
	return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <tuple>
#include <set>

signed main() {
  std::ios::sync_with_stdio(false);
  int N, M;
  std::cin >> N >> M;
  std::vector<int> ans(N);
  std::vector<int> L(M), R(M), D(M);
  std::vector<std::vector<std::pair<int, int>>> G(N);
  for (int i = 0; i < M; ++i) {
    std::cin >> L[i] >> R[i] >> D[i];
    G[L[i] - 1].emplace_back(D[i], R[i] - 1);
    G[R[i] - 1].emplace_back(-D[i], L[i] - 1);
  }
  if (M == 0) {
    std::cout << "Yes" << std::endl;
    exit(0);
  }
  std::set<int> bag;
  for (int i = 0; i < N; ++i) {
    bag.emplace(i);
  }
  while (!bag.empty()) {
    int k = *bag.begin();
    std::queue<int> que;
    ans[k] = 0;
    bag.erase(k);
    que.emplace(k);
    while (!que.empty()) {
      int u = que.front();
      que.pop();
      for (int i = 0; i < G[u].size(); ++i) {
        int d, v;
        std::tie(d, v) = G[u][i];
        if (!bag.count(v)) {
          if (ans[u] + d != ans[v]) {
            std::cout << "No" << std::endl;
            exit(0);
          }
        } else {
          ans[v] = ans[u] + d;
          que.emplace(v);
          bag.erase(v);
        }
      }
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}


Measured memory_bytes: 16256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.1415926535
#define MOD 1000000007
 
int main(){
  
  string S;
  cin >> S;
  
  if(S == "ABC")  cout << "ARC" << endl;
  else if(S == "ARC")  cout << "ABC" << endl;
  
  return 0;
}

Measured memory_bytes: 3628
def unbounded_knapsack(items, budget)
	table = [0]
	for i in 1..budget
		table[i] = 0
		items.each{|c, v|
			next if c > i
			x = table[i-c] + v
			table[i] = x if x > table[i]
		}
	end
	table[budget]
end

n_stock, n_day, budget = gets.split.map &:to_i

price = (1..n_day).map{ gets.split.map &:to_i }

price.each_cons(2){|a, b|
	cost_profit = a.zip(b).map{|x, y| [x, [y - x, 0].max]}
	budget += unbounded_knapsack(cost_profit, budget)
}
p budget

Measured memory_bytes: 9060
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int kazu = count(all(s), 'A');
    if (kazu == 0 || kazu == int(s.length()))
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		if (a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

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

int main()
{
  int a[5];
  int sum=0,max=0,temp=0;
  for(int i=0;i<5;i++){
    scanf("%d",&a[i]);
    bool p=1;
    if(a[i]%10==0) 
      p=0;   
    sum+=a[i]+p*(10-a[i]%10);
    if(max<(10-a[i]%10)&&a[i]%10!=0){ 
      max=10-a[i]%10;
      temp=i;  
    }
  }
  bool p=1; 
  if(a[temp]%10==0) 
    p=0;   
  sum-=p*(10-a[temp]%10);  
  printf("%d\n",sum);
  return 0;
}


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

using namespace std;

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

int here[100001];
int dp1[100001];
int dp2[100001];

int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0)break;
		
		rep(i,100001)here[i]=dp1[i]=dp2[i]=0;
		
		bool dpflg = false;
		
		rep(i,m){
			int a;
			cin>>a;
			if(a==0) dpflg=true;
			
			here[a]=1;
		}
		
		int maxi1 = 0;
		int maxi2 = 0;
		
		reps(i,1,n+1){
			if(here[i]==1)dp1[i] = dp1[i-1]+1;
			maxi1 = max(dp1[i], maxi1);
		}
		
		reps(i,1,n+1){
			if(here[i]==1)dp2[i] = dp2[i-1]+1;
			else dp2[i] = dp1[i-1]+1;
			maxi2 = max(dp2[i], maxi2);
		}
		
		if(!dpflg){
			printf("%d\n",maxi1);
		}else{
			printf("%d\n",maxi2);
		}
	}
}

Measured memory_bytes: 2316
#include <bits/stdc++.h> 
#define ll long long
using namespace std;
int main() 
{ 
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    ll dp[n][3]={0};
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
        dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
        dp[i][2]=max(dp[i-1][1]+c[i],dp[i-1][0]+c[i]);
    }
    ll ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 7092
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
string s;
int ans;
main(){
    cin>>s;
    r(i,s.size()/2){
        if(s[i]=='('&&')'==s[s.size()-1-i])continue;
        else if(s[i]==')'&&'('==s[s.size()-1-i])continue;
        else if(s[i]=='('&&'('==s[s.size()-1-i])ans++;
        else if(s[i]==')'&&')'==s[s.size()-1-i])ans++;
        else if(s[i]!=s[s.size()-1-i])ans++;
    }
    if(s.size()%2&&!isalpha(s[s.size()/2]))ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 3224
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (d, t, s) = InputLine.to_ia

  puts ((d <= t * s) ? 'Yes' : 'No')
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 14316
#include<stdio.h>

int main(void){
    double n,k;
    int i,j;
    double ans= 0.0;
    scanf("%lf %lf",&n,&k);
    double temp = 1/n;
    if(n>=k){
        ans += (n-k+1)/n;
        for(i=1;i<k;i++){
            for(j=i;j<k;j*=2){
                temp/=2;
            }
            ans += temp;
            temp = 1/n;
        }
    }else{
        for(i=1;i<n+1;i++){
            for(j=i;j<k;j*=2){
                temp/=2;
            }
            ans += temp;
            temp = 1/n;
        }
    }
    printf("%.15f",ans);
    return 0;
}


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

double backtrack(vector<double> &v,ll i,ll h,vector<vector<double>> &dp)
{

    if(i==v.size())
    {
        if(h<=v.size()/2)
            return 0;

        return 1;
    }
    if(dp[i][h]!=-1)
        return dp[i][h];
    
    double res=0;   

    res=v[i]*backtrack(v,i+1,h+1,dp) + (1-v[i])*backtrack(v,i+1,h,dp);
    dp[i][h]=res;
    return res;
    
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout.precision(20);
    ll n,i;
    cin>>n;
    vector<double> v(n);
    
    for(i=0;i<n;i++)
        cin>>v[i];
    

    vector<vector<double>> dp(n,vector<double>(n,-1));
    cout<<backtrack(v,0,0,dp)<<endl;

    return 0;
}

Measured memory_bytes: 71680
#include <bits/stdc++.h>
#define va first
#define vb second
#define lb lower_bound
#define ub upper_bound
#define pp push_back
#define ep emplace_back
#define all(v) (v).begin(),(v).end()
#define szz(v) ((int)(v).size())
#define psm partial_sum
#define acm accumulate
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
using ll = long long; using lf = long double;
using pii = pair<int,int>; using ppi = pair<int,pii>;
using pss = pair<short,short>; using pll = pair<ll,ll>;
const lf PI = 3.14159265358979323846264338L;
template <typename T>
inline T umax(T& u, T v){return u = max(u, v);}
template <typename T>
inline T umin(T& u, T v){return u = min(u, v);}
string S, T;
int main(){
    fio;
    cin >> S; S += 'X';
    for(int i = 0; i < szz(S); i++){
        if(S[i] == 'B' && S[i+1] == 'C') T += 'D', i++;
        else T += S[i];
    }
    int cnt = 0;
    ll ans = 0;
    for(int i = 0; i < szz(T) - 1; i++){
        if(T[i] == 'D') ans += cnt;
        else if(T[i] == 'A') cnt ++;
        else cnt = 0;
    }
    cout << ans << '\n';
}

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


int main()
{
	int i, x;
	
	for (i = 1; i < 10001; i++)
	{

		cin >> x;
		if (x != 0) {
			cout << "Case " << i << ": " << x << "\n";
		}
		else break;
	
	}
    return 0;
}




Measured memory_bytes: 2996
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
  -- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative

readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons

main = do
  s <- getLine
  t <- init <$> getLine
  putStrLn $ if s == t then "Yes" else "No"


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

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
const int  p=31,po=1,N=2e5+1, M=(ll)1e9+1 ;
const int mod = 998244353 ;

vl compute(string s){
        vl has(s.length());
        ll i;

        for(i=0;i<s.length();i++){
            if(i==0){
                has[i]=((s[i]-'a'+1))%mod;
            }
            else
                has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod;
        }
        return has;
}
vl ed[N],g[N],in(N);

// bool check(ll x){
//   ll i,j,k;
//   for(i=0;i<N;i++)  g[i].clear();
//   memset(in,0,sizeof(in));
//   ll tar=ed[x][0];
//   for(i=1;i<=m;i++){
//     if(ed[i][0]>tar){
//       g[ed[i][1]].pb(g[ed[i][2]]);
//       ++in[ed[i][1]];
//     }
//   }
  
// }
ll dp[101][(ll)1e5+1];
int main(){
 ios_base::sync_with_stdio(0);
  ll n,w,i;
  cin >> n >> w;
  vl a(n+1),b(n+1);
  for(i=1;i<=n;i++)
    cin >> a[i] >> b[i];
  // vl dp(w+1,0);
  // dp[0]=0;
  ll j;
  // for(i=1;i<=w;i++){
  //   for(j=1;j<=n;j++){
  //     if(i>=a[j]){
  //       // if(i==4) cout << dp[i-a[j]] << " " << b[j] << " " <<  dp[i-a[j]]+b[j] << "\n";
  //       dp[i]=max(dp[i],dp[i-a[j]]+b[j]);
  //       cout << i << " " << dp[i] << endl;
  //     }  
  //   }    
  //   cout << i << " " << dp[i] << " \n";
  // }
  
  for(i=1;i<=n;i++){
    for(j=1;j<=w;j++){
      if(a[i]>j)
        dp[i][j]=dp[i-1][j];
      else
        dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i]]+b[i]);
    }
  }
  // for(i=1;i<=n;i++)
  //   cout << dp[i][w] << " \n";
  cout << dp[n][w] ;
    return 0;
}

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

A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

manzoku=0


for i in range(N):
    ryori = A[i]

    manzoku+=B[ryori-1]

    if i!=0:
        if ryori-1 == ryori_pre:
            manzoku+=C[ryori_pre-1]

    ryori_pre = A[i]


print(manzoku)

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>>vii;
typedef vector<ll> vl;
typedef vector<vector<ll>>vll;
typedef pair <int, int> pii;
typedef pair<ll, ll> pll;


void solve(){
     
    return ;
}

int main(){
    int n;
    cin>>n;
    vi a(n+1, 0);
    for(int i = 1;i<=100;i++){
        for(int j =1;j<=100;j++){
            for(int k=1;k<=100;k++){
                if(i*i + j*j + k*k + i*j + j*k + k*i <=n){
                    a[i*i + j*j + k*k + i*j + j*k + k*i ] ++;
                }
            }
        }
    }
    for(int i = 1;i<=n;i++){
        cout<<a[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3532