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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  string s;
  cin >> s;

  ll n = s.size();
  ll i = 0;
  ll ans = 0;
  ll oneFlag = false;
  while(i < n){
    if(i == n-2 && s[i] == s[i+1]){
      ans++;
      break;
    }
    else if(i == n-1){
      ans++;
      i++;
    }
    else{
      if(oneFlag && s[i-1] == s[i]){
        oneFlag = false;
        i += 2;
        ans++;}
      else{
        oneFlag = true;
        i++;
        ans++;
      }
    }

  }
  
  cout << ans << endl;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int> v(n+1);

	for(int i=2; i<=n; ++i){
		int a;
		cin >> a;
		++v[a];
	}

	for(int i=1; i<=n; ++i){
		cout << v[i] << endl;
	}
}

Measured memory_bytes: 4056
#include<bits/stdc++.h>
#define     ll          long long
#define     MOD         10e9+7
#define     pb          push_back
#define     vll         vector<long long>
#define     vi          vector<int>
#define     vl          vector<long>
#define     pii         pair<int, int>
#define     pll         pair<ll,ll>
#define     mp          make_pair
#define     all(a)      (a).begin(),(a).end()
#define     rep(i,a,b)  for(int i=a;i<b;i++)
#define     MAX         100002 
#define     ios	      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;


int main() {
    
    ll x;
    cin >> x;
    if(x==0)cout <<"0\n";
    else cout << max((x/500)*1000+((x-(x/500)*500)/5)*5,(x/5)*5) <<"\n";
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),x = 0;
        Map<String,Integer> map = new LinkedHashMap<>();
        String[] items = {"AC","WA","TLE","RE"};
        for (String s: items) map.put(s,0);
        for (int i = 0; i < a; i++) {
            String ans = sc.next();
            map.put(ans,map.get(ans)+1);
        }
        for(int n:map.values()) System.out.println(items[x++] + " x " + n);
    }
}


Measured memory_bytes: 58672
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;

int main(void) {
  string s; cin >> s;
  if (s == "RRS" || s == "SRR") plexit(2)
  if (s == "RRR") plexit(3)
  if (s == "SSS") plexit(0)
  pl(1)
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
   if (N) os << " ";
   os << get<N>(t);
   out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
   os << "(";
   out<0,tuple<Ts...>,Ts...>(os, t);
   os << ")";
   return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
   os << "(" << e.to << ", " << e.cost << ")";
   return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
   int N; cin >> N;
   vector<LL> A(N);

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

   sort(A.begin(), A.end());

   vector<pair<int,int>> ans;
   for (int i = 1; i < N-1; ++i) {
      if (A[i] > 0) {
         ans.push_back({ A[0], A[i] });
         A[0] -= A[i];
      }
   }
   for (int i = 0; i < N-1; ++i) {
      if (A[i] <= 0) {
         ans.push_back({ A[N-1], A[i] });
         A[N-1] -= A[i];
      }
   }

   cout << A.back() << endl;
   for (auto p : ans) {
      cout << p.first << " " << p.second << endl;
   }

   return 0;
}


Measured memory_bytes: 3572
N = int(input())
# dicts = { 'aaa': 3, 'bbb': 2,,, }
dicts = {}
max_count = 0
max_strings = []

for i in range(N):
    Si = input()
    if Si in dicts:
        dicts[Si] += 1
    else:
        dicts[Si] = 1

    if dicts[Si] == max_count:
        max_strings.append(Si)
    if dicts[Si] > max_count:
        max_count = dicts[Si]
        max_strings = [Si]

max_strings.sort()
for str in max_strings:
    print(str)


Measured memory_bytes: 33420
#include<bits/stdc++.h>
#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<ll>
#define Max(a,b)    ((a)>(b)?(a):(b))
#define Min(a,b)    ((a)<(b)?(a):(b))
#define rep(i,a,b)  for (__typeof((b)) i=(a);i<(b);i+=1)
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define debug(a)    cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
using namespace std;
void solve(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a%2==0 || b%2==0 || c%2==0)cout<<0;
    else{
        vi x={a,b,c};
        sort(all(x));
        cout<<x[0]*x[1];
    }
}

int main(){
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
/*<----------------------------------------------------------------------->

<-------------------------------------------------------------------------->
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
long const M=1e9+7;
const long mxN =1e5+2 ;
const long mxNN =1e6+2 ;
void solve(){
    ll n , m ,x;cin >> n >> m ;
    ll sum =0 ;
    For(i,m){
        cin >> x ;
        sum+=x ;
    }
    cout << (n-sum<0?-1:n-sum) << endl;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << setprecision(20) << fixed ;
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}


Measured memory_bytes: 3652
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	o, e := next(), next()
	for i := 0; i < max(len(o), len(e)); i++ {
		if i < len(o) {
			putf("%c", o[i])
		}
		if i < len(e) {
			putf("%c", e[i])
		}
	}
	putf("\n")
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);

int main(){
    int n; sc(n)
    vector<int> A(n), dp(n+1,0);
    for (int i = 0; i < n; i++) sc(A[i])
    int tmp = abs(A[0]) + abs(A[n - 1]), ans;
    for (int i = 0; i < n - 1; i++) tmp += abs(A[i+1] - A[i]);
    for (int i = 0; i < n; i++){
        ans = tmp;
        if (i == 0){
            ans -= abs(A[0]) + abs(A[1] - A[0]);
            ans += abs(A[1]);
        }else if (i == n - 1){
            ans -= abs(A[n-1]) + abs(A[n-1] - A[n-2]);
            ans += abs(A[n-2]);
        }else {
            ans -= abs(A[i+1] - A[i]) + abs(A[i] - A[i-1]);
            ans += abs(A[i+1] - A[i - 1]);
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  i64 R, C, K, i, r, c;
  cin >> R >> C >> K;

  vvi items(R, vi(C, 0));
  REP(0, K, i) {
    i64 r, c, v;
    cin >> r >> c >> v;
    r--; c--;
    items[r][c] = v;
  }

  using vvvi = vector<vvi>;
  vvvi V(R, vvi(C, vi(4, 0)));
  V[0][0][0] = 0;
  if(items[0][0] != 0) {
    V[0][0][1] = items[0][0];
  }
  
  REP(1, C, c) {
    REP(0, 4, i) {
      V[0][c][i] = V[0][c-1][i];
      if(items[0][c] != 0 && i != 0) {
	V[0][c][i] = max(V[0][c][i], V[0][c-1][i-1] + items[0][c]);
      }
    }
  }

  REP(1, R, r) {
    V[r][0][0] = *max_element(all(V[r-1][0]));
    if(items[r][0] != 0) {
      V[r][0][1] = V[r][0][0] + items[r][0];
    }

    REP(1, C, c) {
      REP(0, 4, i) {
	V[r][c][i] = V[r][c-1][i];
	if(items[r][c] != 0 && i != 0) {
	  V[r][c][i] = max(V[r][c][i], V[r][c-1][i-1] + items[r][c]);
	}

	if(i == 0) {
	  V[r][c][i] = max(V[r][c][i], *max_element(all(V[r-1][c])));
	}
	if(i == 1 && items[r][c] != 0) {
	  V[r][c][i] = max(V[r][c][i], items[r][c] + *max_element(all(V[r-1][c])));
	}
      }
    }
  }

  cout << *max_element(all(V[R-1][C-1])) << endl;

  return 0;
}


Measured memory_bytes: 706008
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <set>
#include <queue>

using namespace std;

int main()
{
    string s; cin >> s;
    int k; cin >> k;
    set<string> ranking;
    priority_queue<pair<string,int>,
                   vector<pair<string,int>>,
                   greater<pair<string,int>>> q;
    for (int i = 0; i < s.size(); i++)
        q.push(make_pair(s.substr(i, 1), i));

    while (true) {
        string ss; int ii;
        tie(ss, ii) = q.top();
        q.pop();

        ranking.insert(ss);
        if (ranking.size() >= k)
            break;

        if (ii + ss.size() + 1 <= s.size())
            q.push(make_pair(s.substr(ii, ss.size()+1), ii));
    }
    cout << vector<string>(ranking.begin(),ranking.end())[k-1]
         << endl;
    return 0;
}

Measured memory_bytes: 640
//Caracal vs Monster
#include <iostream>
#include <math.h>
using namespace std;
int main() {
	long long h, i = 0;
	cin >> h;
	while (h > 0 && ++i)	h /= 2;
	long long x = 1;
	cout << (x << i) - 1 << endl;
	return 0;
}

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

int main()
{
    int n;
    cin>>n;
    int a[n];
    double re=0;

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

        cin>>a[i];

    }
    sort(a,a+n);

    re=a[0];

    for(int i=1;i<n;i++)
    {
        re=double(re+a[i])/2;
    }
    cout<<re<<endl;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    cin>>t;
	if(t>=30){
		cout<<"Yes"<<"\n";
	}
	else{
		cout<<"No"<<"\n";
	}
    return 0;
}

Measured memory_bytes: 3608
import bisect


n = int(input())
la = [int(w) for w in input().split()]
la_sum = [0]*(n)
ans = 10**10

la_sum[0] = la[0]
for i in range(1, n):
    la_sum[i] = la_sum[i-1] + la[i]


for i in range(0, n):
    l = la_sum[i]
    r = la_sum[-1]-la_sum[i]
    d = abs(l-r)
    ans = min(ans, d)
print(ans)


Measured memory_bytes: 31448
#include<iostream>

#define MAXN 10000
#define MAXQ 10000

using namespace std;

int main()
{
	int S[MAXN],T[MAXQ];
	int n,q;

	cin>>n;
	for( int i=0; i<n; i++ ) {
		cin>>S[i];
	}
	cin>>q;
	for( int i=0; i<q; i++ ) {
		cin>>T[i];
	}
	int cnt=0;
	for( int i=0; i<q; i++ ) {
		for( int j=0; j<n; j++ ) {
			if( T[i] == S[j] ) {
				cnt++;
				break;
			}
		}
	}
	cout<<cnt<<endl;
	
    return 0;
}

Measured memory_bytes: 1204
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char[] S = sc.next().toCharArray();
    int cnt = 0;
    for(int i=0; i<S.length/2; i++){
      if(S[i] != S[S.length-i-1]){
        cnt++;
      }
    }
    System.out.print(cnt);
  }
}


Measured memory_bytes: 22612
from collections import deque

N, M = map(int, input().split())
AB = [[] for _ in range(N+1)]
for i in range(M):
    A_tmp , B_tmp = map(int, input().split())
    AB[A_tmp].append(B_tmp)
    AB[B_tmp].append(A_tmp)

ans = [0]*(N+1)
visited = [False] * (N + 1)

q = deque()
q.append((1, -1))
while len(q) > 0:
    node, past = q.popleft()
    if visited[node]:
      continue
    ans[node] = past
    visited[node] = True
    for t in AB[node]:
        if visited[t]:
            continue
        q.append((t, node))
print("Yes")
for i in range(2, N+1):
    print(ans[i])


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

int n,A[1<<18],l[1<<18],r[1<<18];
vector<int> add[1<<18],del[1<<18];
struct cmp{
	bool operator()(int p,int q){
		return r[p]>r[q];
	}
};
priority_queue<int,vector<int>,cmp> q;

int main(){
	scanf("%d",&n);
	for(int i=0;i<1<<n;++i){
		scanf("%d",A+i);
		if(A[i])l[i]=r[i]=A[i];
		else l[i]=1,r[i]=1<<n;
	}
	for(int i=0;i<1<<n;++i)
		for(int j=0;j<n;++j)
			if(!(i>>j&1))l[i^(1<<j)]=max(l[i^(1<<j)],l[i]+1);
	for(int i=(1<<n)-1;i>=0;--i)
		for(int j=0;j<n;++j)
			if(i>>j&1)r[i^(1<<j)]=min(r[i^(1<<j)],r[i]-1);
	for(int i=0;i<1<<n;++i){
		if(l[i]>r[i])return puts("NO"),0;
		add[l[i]-1].push_back(i);
		del[r[i]-1].push_back(i);
	}
	for(int i=0;i<1<<n;++i){
		for(int x:add[i])q.push(x);
		if(!q.empty())A[q.top()]=i+1,q.pop();
		for(int x:del[i])
			if(!A[x])return puts("NO"),0;
	}
	for(int i=0,j=0;i<1<<n;++i){
		if(i>j)swap(A[i],A[j]);
		for(int k=1<<n-1;(j^=k)<k;k>>=1);
	}
	puts("YES");
	for(int i=0;i<1<<n;++i)printf("%d%c",A[i]," \n "[i+1==1<<n]);
	return 0;
}


Measured memory_bytes: 33536
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int x=sc.nextInt();
    int a=sc.nextInt();
    int b=sc.nextInt();
    if(a>=b)System.out.println("delicious");
    else if(a+x>=b)System.out.println("safe");
    else System.out.println("dangerous");
  }
}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c; cin >> a >> b >> c;
  int ans = min({a+b, a+c, b+c});
  cout << ans << endl;
}


Measured memory_bytes: 3608
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n = ns()
k = ni()
dp = [[[0]*2 for _ in range(k+1)] for _ in range(len(n)+1)]
dp[0][0][0] = 1
for i in range(len(n)):
    x = int(n[i])
    for j in range(k):
        dp[i+1][j+1][1] += dp[i][j][1]*9
        dp[i+1][j][1] += dp[i][j][1]
        if x > 0:
            dp[i+1][j][1] += dp[i][j][0]
            dp[i+1][j+1][1] += dp[i][j][0]*(x-1)
            dp[i+1][j+1][0] += dp[i][j][0]
        else:
            dp[i+1][j][0] += dp[i][j][0]
    dp[i+1][k][1] += dp[i][k][1]
    dp[i+1][k][x>0] += dp[i][k][0]
print(sum(dp[len(n)][k]))


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int N,A[2<<17];
int cnt[1<<20];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		cnt[A[i]]++;
	}
	int ans=0;
	for(int i=0;i<N;i++)
	{
		bool now=true;
		cnt[A[i]]--;
		for(int j=1;j*j<=A[i];j++)
		{
			if(A[i]%j==0)
			{
				if(cnt[j]||cnt[A[i]/j])
				{
					now=false;
					break;
				}
			}
		}
		cnt[A[i]]++;
		ans+=now;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 8124
N,M=map(int,input().split())
A=list(map(int,input().split()))
ans='No'
sum=0
b=1/(4*M)
c=0
for i in range(N):
  c+=A[i]
d=c*b
for i in range(N):
  if d<=A[i]:
    sum=sum+1
  if sum==M:
    ans='Yes'
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <string>
#include <ctype.h>

using namespace std;

void solve()
{
	string x;
	while (cin >> x)
	{
		if (x == "0")
		{
			break;
		}
		int ans = 0;
		for (int i = 0; i < x.size(); ++i)
		{
			ans += x[i] - '0';
		}
		cout << ans << endl;
	}
}

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

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  int lmax = 0;
  int rmin = 1000000;
  rep(i, m){
    int l, r;
    cin >> l >> r;
    lmax = max(lmax, l);
    rmin = min(rmin, r);
  }
  int ans = max(0, rmin - lmax + 1);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3596
n = int(input())
memo = []
memo1 = [0,0,0]
for i in range(n):
    s = input().split()
    s = [int(s[j]) for j in range(3)]
    if i==0:
        memo = s
    else:
        memo1[0] = max(memo[1],memo[2])+s[0]
        memo1[1] = max(memo[0],memo[2])+s[1]
        memo1[2] = max(memo[0],memo[1])+s[2]
        memo = [1*memo1[j] for j in range(3)]
print(max(memo))

Measured memory_bytes: 9152
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pll, int > a, pair < pll, int > b)//true for a before b
{
	ll val = a.F.F*b.F.S - a.F.S*b.F.F;
	if(val >= 0LL)
		return 1;
	return 0;
}

const int N = (1e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 8000;



void solve()
{
	ll n, m, ans = 0LL;
	cin >> n >> m;
	if(m > n)
		swap(m,n);
	if(n == 1)
	{
		cout << 1;
		return;
	}
	if(m == 1)
	{
		cout << max(0LL,n-2LL);
		return;		
	}
	if(m == 2)
	{
		cout << 0;
		return;
	}
	ans = (m-2LL)*(n-2LL);
	cout << ans;
	return;
}

int main()
{
	sws;
	// clock_t clk;
	// clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1;
	// cin >> t;
	while(t--)
		solve();
	// Code ends here

	// clk = clock() - clk;
	// cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <limits.h>
#include <assert.h>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long int
#define db double
#define ldb long double
#define MOD 1000000007
#define Fi first
#define Se second
#define INF INT_MAX
#define NINF INT_MIN
#define L_INF LLONG_MAX
#define L_NINF LLONG_MIN
#define gc getchar
#define sz(x) (int)(x).size()
#define pii pair<int,int>
#define pll pair<ll,ll>

void fsscan(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

void scani(int &x)
{
    register int c = gc();x = 0;int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

int main()
{
    fsscan();
    int n,x;
    cin>>n>>x;
    int a[n];
    int s=0;
    int maxo=INT_MAX;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        maxo=min(maxo,a[i]);
        s+=a[i];
    }
    int left=x-s;
    cout<<n+left/maxo;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,K=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7

B=[]
C=[]
Z=[]
 
for a in A:
    if a>0:
        B.append(a)
    elif a<0:
        C.append(-a)
    else:
        Z.append(0)
 
B.sort(reverse=True)
C.sort(reverse=True)
 
if K==len(B)+len(C):
    ANS=1
    for b in B:
        ANS=ANS*b%mod
    for c in C:
        ANS=ANS*(-c)%mod
 
    if len(C)%2==1 and Z!=[]:
        print(0)
    else:
        print(ANS)
    sys.exit()
 
if K>len(B)+len(C):
    print(0)
    sys.exit()
 
if B==[]:
    if Z==[] and K%2==0:
        ANS=1
        for i in range(K):
            ANS=ANS*(C[i])%mod
        print(ANS)
 
    elif Z==[] and K%2==1:
        ANS=1
        C.reverse()
        for i in range(K):
            ANS=ANS*(-C[i])%mod
        print(ANS)
        
    elif K%2==1:
        print(0)
        
    else:
        ANS=1
        for i in range(K):
            ANS=ANS*(C[i])%mod
        print(ANS)
 
    sys.exit()

if K<=len(B):
    S=1
    for i in range(K):
        S=S*B[i]%mod

    ind=0
    while True:
        if ind+1<len(C) and K-2-ind>=0 and C[ind]*C[ind+1]>B[K-1-ind]*B[K-2-ind]:
            S=S*C[ind]*C[ind+1]*pow(B[K-1-ind]*B[K-2-ind],mod-2,mod)%mod
            ind+=2
        else:
            break

    print(S%mod)

else:
    if (K-len(B))%2==0:
        S=1
        for i in range(len(B)):
            S=S*B[i]%mod

        for j in range(K-len(B)):
            S=S*C[j]%mod

        ind=0
        c_start=K-len(B)

        while True:
            if c_start+ind+1<len(C) and len(B)-2-ind>=0 and C[c_start+ind]*C[c_start+ind+1]>B[len(B)-1-ind]*B[len(B)-2-ind]:
                S=S*C[c_start+ind]*C[c_start+ind+1]*pow(B[len(B)-1-ind]*B[len(B)-2-ind],mod-2,mod)%mod
                ind+=2
            else:
                break

    else:
        S=1
        for i in range(len(B)-1):
            S=S*B[i]%mod

        for j in range(K-len(B)+1):
            S=S*C[j]%mod

        ind=0
        c_start=K-len(B)+1

        while True:
            if c_start+ind+1<len(C) and len(B)-3-ind>=0 and C[c_start+ind]*C[c_start+ind+1]>B[len(B)-2-ind]*B[len(B)-3-ind]:
                S=S*C[c_start+ind]*C[c_start+ind+1]*pow(B[len(B)-2-ind]*B[len(B)-3-ind],mod-2,mod)%mod
                ind+=2
            else:
                break

    print(S%mod)
    


Measured memory_bytes: 107628
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int a[1000001];
int main(){
    int n,l;
    cin>>n>>l;
    rep(i,n) cin>>a[i];
    deque<int> deq;
    rep(i,n){
        while(!deq.empty()&&a[deq.back()]>=a[i]) deq.pop_back();
        deq.pb(i);
        if(i>=l-1){
            int cur=deq.front();
            cout<<a[cur]<<(i==n-1?"":" ");
            if(cur==i-l+1) deq.pop_front();
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 7088
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {

			int a = sc.nextInt();
			int b = sc.nextInt();

			int p = b;
			if (a <= 5) {
				p = 0;
			} else if (a <= 12) {
				p = b / 2;
			}
			System.out.println(p);
		}
	}
}


Measured memory_bytes: 21716
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

struct Move
{
	int y,x,yd,xd;
	Move(int y,int x,int yd,int xd) :
		y(y),x(x),yd(yd),xd(xd) {}
};

signed main() {
	int h,w;
	std::cin >> h >> w;
	std::vector<std::vector<int> > a(h,std::vector<int> (w));
	rep(i,h) rep(j,w) std::cin >> a[i][j];
	std::vector<Move> moves;
	rep(i,h) {
		rep(j,w-1) {
			if(a[i][j]%2) {
				moves.emplace_back(i+1,j+1,i+1,j+2);
				a[i][j+1]++;
			}
		}
	}
	rep(i,h-1) {
		if(a[i][w-1]%2) {
			moves.emplace_back(i+1,w,i+2,w);
			a[i+1][w-1]++;
		}
	}
	print(moves.size());
	for(auto i:moves) {
		std::cout << i.y << ' ';
		std::cout << i.x << ' ';
		std::cout << i.yd << ' ';
		std::cout << i.xd << '\n';
	}


	return 0;
}


Measured memory_bytes: 8176
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<iomanip>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const int z = 1000000007;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> vec(n);
    REP(i, n) {
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end());
    int ans = 0;
    REP(i, k) {
        ans += vec[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    ll N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    ll dif = B - A;
    rep(i,0,N){
        ll u = N-1 - i;
        ll d = i; 
        //cout << u << " " << d << " " <<  u * C - d * D << "," << u * D - d * C << endl;
        if(u * C - d * D <= dif && dif <= u * D - d * C){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define anal         '\n'
#define mod 1000000007
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
  

 
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
      
int main(){
I_AM_SPEED;
#ifndef ONLINE_JUDGE  
      freopen("input.in", "r", stdin);
      freopen("output.in", "w", stdout);
#endif 

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
       
       ll N;
       cin >> N;
       string s = "";
       while(N){
           N--;
           s += (N%26 + 'a');
           N /= 26;
       }
       std :: reverse(s.begin(), s.end());
       cout << s;


//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//printclock; 
return  0 ;      
}        



   

Measured memory_bytes: 3608
import java.io.FileInputStream
import java.util.*


fun Scanner.nextChar(): Char {
    val line = this.findInLine(".")
    return if (line == null) { // 改行のとき
        this.nextLine() // 改行読み捨て
        this.nextChar()
    }
    else {
        line[0]
    }
}

fun Scanner.nextIntList(size: Int): List<Int> {
    val list = mutableListOf<Int>()
    for (i in 1..size) {
        list.add(this.nextInt())
    }

    return list
}

inline fun Int.times(body: (index: Int) -> Unit) {
    var index = 0
    while (index < this) {
        body(index)
        index++
    }
}

inline fun <T> Int.map(body: (index: Int) -> T): List<T> {
    var index = 0
    val list = mutableListOf<T>()
    while (index < this) {
        list.add(body(index))
        index++
    }
    return list
}


var sc: Scanner = Scanner(System.`in`)
fun main(args: Array<String>) {
    if (args.size > 0) {
        System.setIn(FileInputStream(args[0]))
    }
    sc = Scanner(System.`in`)

    problem()

}

fun problem() {

    var list = sc.nextIntList(3)
    list = list.sorted()

    val count = list[2] - list[1]
    var count2 = (list[2] - list[0] - count) / 2
    var ans = count + count2
    if (list[0] + count2 * 2 + count < list[2]) {
        ans++
        count2 += 2
    }
    if (list[0] + count2 * 2 + count > list[2]) {
        ans++
    }

    println(ans)

}



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

int main()
{
    int a,b;
    cin >> a >> b;
    int ans = 0;
    int flag;
    for(int i = a; i <= b; i++){
        string tmp = to_string(i);
        flag = 1;
        for(int j = 0; j < tmp.length(); j++){
            if(tmp[j] != tmp[tmp.length()-1-j]){
                flag = 0;
                break;
            }
        }
        if(flag) ans++;
    }
    cout << ans << endl;
}

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

int main(){
  while(1){
    int n,m;
    cin>>n>>m;
    if(!n) return 0;
    int c[15];
    rep(i,3){
      int x;
      cin>>x;
      rep(j,x){
        int y;
        cin>>y;
        c[y-1] = i;
      }
    }
    int o=0,p=1;
    rep(i,n){
      o += p*c[i];
      p *= 3;
    }
    int t = p-1;
    
    queue<int> que;
    int dist[15000000];
    
    rep(i,15000000) dist[i] = -1;
    dist[o] = 0;
    que.push(o);
    
    while(!que.empty()){
      int x = que.front();
      que.pop();
       
      int d[3] = {-1},e=x,g=1;
      rep(i,n){
        d[e%3] = g; 
        e/=3, g*=3;
      }
      if(d[0]>d[1]){ e = x + d[0]; if(dist[e]==-1){que.push(e); dist[e]=dist[x]+1;}}
      if(d[0]<d[1]){ e = x - d[1]; if(dist[e]==-1){que.push(e); dist[e]=dist[x]+1;}}
      if(d[1]>d[2]){ e = x + d[1]; if(dist[e]==-1){que.push(e); dist[e]=dist[x]+1;}}
      if(d[1]<d[2]){ e = x - d[2]; if(dist[e]==-1){que.push(e); dist[e]=dist[x]+1;}}
    }
    if(min(dist[t],dist[0])<=m){
      cout<<min(dist[t],dist[0])<<endl;
    }else{cout<<-1<<endl;}
  }
}


Measured memory_bytes: 61744
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

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

int main(){
  int n;
  while(cin >> n, n){
    vector<int> a(n+1);
    rep(i, n) cin >> a[i+1];
    int r;
    double b, v, e, f;
    cin >> b >> r >> v >> e >> f;
    
    double time[10010] = {0.0};
    
    for(int i = 0 ; i < 10010 ; i++){    
      if(i >= r) time[i+1] += 1.0/(v - e * (i-r)) + time[i];      
      else time[i+1] += 1.0/(v - f * (r-i)) + time[i];
    }
    
    double dp[10010];
    fill(dp, dp+10010, (1<<29));
    dp[0] = -b;
    
    for(int i = 0 ; i < n ; i++){
      for(int j = i+1 ; j < n+1 ; j++){
	double t = time[a[j] - a[i]] + b;
	dp[j] = min(dp[j], dp[i]+t);
      }
    }
    printf("%.4f\n", dp[n]);    
  }
  return 0;
}

Measured memory_bytes: 1408
# 入力　文字列1つ
w = input()

w_list = list(w)
alphabet = dict.fromkeys("abcdefghijklmnopqrstuvwxyz",0)
beautiful = True

for i in range(len(w)) :
    alphabet[w_list[i]] += 1

for i in alphabet :
    if alphabet[i]%2 != 0 :
        beautiful = False

if beautiful == True :
    print("Yes")
else :
    print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
typedef long long LL;
int main() {
	int n = 0, k = 0, x[100] = {},ans=0;
	std::cin >> n >> k;
	for (int i = 0; i < n; i++) { std::cin >> x[i]; }
	for (int i = 0; i < n; i++) {
		ans += std::min(std::abs((x[i]-0)*2),std::abs((x[i]-k)*2));
	}
	std::cout <<ans <<  std::endl;
}

Measured memory_bytes: 256
from bisect import bisect_right, bisect_left

N = int(raw_input())

A = map(int, raw_input().split())
B = map(int, raw_input().split())
C = map(int, raw_input().split())

A = sorted(A)
B = sorted(B)
C = sorted(C)

ans = 0
A_on_B = 0
C_under_B = 0
for y in B:
    A_on_B = bisect_left(A, y) 
    C_under_B = N - bisect_right(C, y) 
    ans = ans + A_on_B*C_under_B
print ans


Measured memory_bytes: 17704
#include<stdio.h>
int main(){
  int n, x, i=0;
  int a, b, c;
  while (1) {
    scanf("%d %d", &n, &x);
    if (n == 0 && x == 0) {
      break;
    }
    for (a = 1; a <= n; a++) {
      for (b = a + 1; b <= n; b++) {
        c = x - a - b;
        if (b < c && c <= n) {
          i++;
        }
      }
    }
    printf("%d\n", i);
    i= 0;
  }
}

Measured memory_bytes: 2720
#include <stdio.h>
#include <math.h>
int main(void) {
  long n,a[32],ad = 32,i,po,wa;
  scanf("%ld",&n);
  for (i = 0;i < 32;i++) {
      po = pow(2,i + 1);
      wa = n % po;
     if(wa < 0) wa += po;
      if (i % 2 == 0) {
          if ((pow(2,i) / 3 < wa) && (wa < pow(2,i + 2) / 3)) {
              a[i] = 1;
          } else {
              a[i] = 0;
          }
      } else {
          if ((pow(2,i + 1) / 3 < wa) && (wa < pow(2,i + 1) * 5 / 6)) {
              a[i] = 1;
          } else {
              a[i] = 0;
          }
      }
  }
  for (i = 32;i >= 0;i--) {
      if (a[i] == 1) {
          ad = i;
          break;
      }
  }
  if (ad == 32) {
      printf("0\n");
  } else {
      for (i = ad;i >= 0;i--) {
          printf("%ld",a[i]);
      }
      printf("\n");
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    int sum = 0;
    int maxi = -1;
    rep(i,n){
        int a;
        cin >> a;
        sum += a;
        maxi = max(maxi,a);
    }
    if (maxi < sum-maxi){
        P("Yes");
    }else{
        P("No");
    }
}

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


Measured memory_bytes: 256
#include <stdio.h>

int main()
{   char s[2];
    scanf("%c",s);
    if(s[0]=='a'||s[0]=='i'||s[0]=='u'||s[0]=='e'||s[0]=='o'){
    printf("vowel");
    }else printf("consonant");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    map<ll, vector<ll>> idx;
    Rep (i, N) {
        cin >> A[i];
        idx[A[i]].push_back(i);
    }
    vector<ll> w(N);
    for (auto kv : idx) {
        ll s = kv.second.size();
        kv.second.push_back(kv.second[0] + N);
        Rep (i, s) {
            w[kv.second[i]] = kv.second[i+1] - kv.second[i] + 1;
        }
    }

    vector<vector<ll>> a(100, vector<ll>(N, 0));
    a[0] = w;
    const ll LL_MAX = 1e18;
    Rep (i, 99) {
        Rep (j, N) {
            a[i+1][j] = a[i][j] + a[i][(j+a[i][j]) % N];
            a[i+1][j] = min(a[i+1][j], LL_MAX);
        }
    }

    ll now = 0;
    while (now <= N*K - 1) {
        ll to_go = N*K - 1 - now;
        for (ll i = 99; i >= 0; i--) {
            if (a[i][now % N] <= to_go) {
                now += a[i][now % N];
                break;
            }
        }
        if (a[0][now % N] > to_go) break;
    }

    vector<bool> exist(2e5+1, false);
    deque<ll> d;
    for (ll i = now % N; i < N; i++) {
        if (!exist[A[i]]) {
            d.push_back(A[i]);
            exist[A[i]] = true;
        } else {
            while (true) {
                ll t = d.back();
                d.pop_back();
                exist[t] = false;
                if (A[i] == t) break;
            }
        }
    }

    for (ll e : d) {
        cout << e << " ";
    }
    cout << "\n";
}

Measured memory_bytes: 184548
import java.util.Scanner;

public class Main {

	void run() {

		Scanner sc = new Scanner(System.in);

		while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();

			int tsum = 0;
			int hsum = 0;

			int anst = 0;
			int ansh = 0;

			int min = 200;

			if ((n | m) == 0) {
				break;
			}

			// taro
			int[] t = new int[n];
			for (int i = 0; i < n; i++) {
				t[i] = sc.nextInt();
				tsum += t[i];
			}

			// hanako
			int[] h = new int[m];
			for (int i = 0; i < m; i++) {
				h[i] = sc.nextInt();
				hsum += h[i];
			}

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					if (tsum - t[i] + h[j] == hsum - h[j] + t[i]) {
						if (min > t[i] + h[j]) {
							min = t[i] + h[j];
							anst = t[i];
							ansh = h[j];
						}
					}
				}
			}

			if ((anst | ansh) == 0) {
				System.out.println(-1);
			} else {
				System.out.println(anst + " " + ansh);
			}

		}

	}

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

Measured memory_bytes: 21032
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <cmath>
#include <cstdio>
using namespace std;

#define PI 4*atan(1);

int main(){
  int tmp, s = 0, m = 0;
  for(int i = 0; i < 4; i++){
    cin >> tmp;
    s += tmp;
  }
  for(int i = 0; s / 60 != 0; i++){
    if(s / 60 != 0){
      m += s / 60;
      s %= 60;
    }
  }
  cout << m << endl << s << endl;
}

Measured memory_bytes: 1164
H,W,N=map(int,input().split())
sr,sc=map(int,input().split())
S=input()
T=input()

Scount = {'L':[0],'R':[0],'U':[0],'D':[0]}
Tcount = {'L':[0],'R':[0],'U':[0],'D':[0]}

rev = {'L':'R','D':'U','U':'D','R':'L'}

for i in range(N):
    for c in 'LRUD':
        if S[i] == c:
            Scount[S[i]].append(Scount[c][-1]+1)
        else:
            Scount[c].append(Scount[c][-1])
    for c in 'LRUD':
        if T[i] == c:
            if c == 'L':
                Tcount[T[i]].append(min(Tcount[T[i]][-1]+1,  Scount['R'][i+1] + sc - 1))
            if c == 'R':
                Tcount[T[i]].append(min(Tcount[T[i]][-1]+1,  W + Scount['L'][i+1] - sc))
            if c == 'D':
                Tcount[T[i]].append(min(Tcount[T[i]][-1]+1,  H + Scount['U'][i+1] - sr))
            if c == 'U':
                Tcount[T[i]].append(min(Tcount[T[i]][-1]+1,  Scount['D'][i+1] + sr - 1))
        else:
            Tcount[c].append(Tcount[c][-1])

# print(Scount)
# print(Tcount)

for i in range(1, N+1):
    if (sc - (Scount['L'][i] - Tcount['R'][i-1]) < 1) or \
        (sc + (Scount['R'][i] - Tcount['L'][i-1]) > W) or \
        (sr + (Scount['D'][i] - Tcount['U'][i-1]) > H) or \
        (sr - (Scount['U'][i] - Tcount['D'][i-1]) < 1):
        print("NO")
        exit(0)

print("YES")


Measured memory_bytes: 29096
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <numeric>

using namespace std;

typedef pair<long long, long long> pl;

long long N, M, k, a, b, c, d, e, H, W,X;
long long A[200000] = {};
long long B[200000] = {};
long long C[200000] = {};
bool f;
bool ff;
string S, SS;
set <long long>sll;
pl buf;
vector <long long>vl[2];

long long GCD(long long g, long long gg) {
	long long r = min(g, gg);
	long long rr = max(g, gg);

	if (rr%r == 0) {
		return r;
	}
	else {
		GCD(r, rr%r);
	}

}

int main() {

	cin >> N;

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

	if (N == 2) {
		d = max(A[0], A[1]);
	}
	else {
		B[0] = A[0];
		B[1] = GCD(A[0], A[1]);
		for (int i = 2; i < N; i++) {
			B[i] = GCD(A[i], B[i-1]);
		}

		C[N-1] = A[N - 1];
		C[N-2] = GCD(A[N-1], A[N-2]);
		for (int i = N - 3; i >=0 ; i--) {
			C[i] = GCD(A[i], C[i+1]);
		}

		d = 1;
		d = max(d,B[N-2]);
		d = max(d,C[1]);

		for (int i = 0; i < N - 2; i++) {
			d = max(d, GCD(B[i], C[i + 2]));
		}

	}


	cout << d << endl;

	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
  int n,m,i,j,k,l;
  string a[55],b[55];
  cin >> n >> m;
  for (i=0;i<n;i++) cin >> a[i];
  for (j=0;j<m;j++) cin >> b[j];
  for (i=0;i<=n-m;i++){
    for (j=0;j<=n-m;j++){
      for (k=0;k<m;k++){
        for (l=0;l<m;l++) if (a[i+k][j+l]!=b[k][l]) break;
        if (l!=m) break;
      }
      if (k==m) break;
    }
    if (j!=n-m+1) break;
  }
  if (i!=n-m+1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
    x += y;
    if( x >= m )
        x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
    x -= y;
    if( x < 0 )
        x += m;
}

int main() 
{
    fastio();

    int n;
    cin>>n;
    set<string>s;
    for(int i=0;i<n;i++)
    {
        string now;
        cin>>now;
        s.insert(now);
    }
    cout<<s.size(),nl;  

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 19244
import math

a, b, h, m = map(int,input().split())

#短針の進んでいる角度
s = 30* h + m / 2
#長針の進んでいる角度
l = 6* m

#角度を求める
#短針の方が進んでいる場合
if s >= l:
  g = s - l
#長針の方が進んでいる場合
else:
  g = l - s

ga = min(g, (360 - g))
#cosを求める
cos = math.cos(math.radians(ga))

#余弦定理
ans = a**2 + b**2 - 2* a* b* cos

final = math.sqrt(ans)

print(final)

Measured memory_bytes: 9572