akhauriyash/Code-Regression huggingface dataset:
use std::io;


fn main() {
    let a = read_one::<usize>();
    println!("{}", a + a.pow(2) + a.pow(3));
}


#[allow(unused)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}


#[allow(unused)]
fn read_one<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}


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

int tmp[5];

int main(){
	for(int i=1;i<=3;i++){
		cin >> tmp[i];
	}
	sort(tmp+1,tmp+4);
	for(int i=1;i<=2;i++){
		if(tmp[i]!=5){
			cout << "NO\n";
			return 0;
		}
	}
	if(tmp[3]!=7) cout << "NO\n";
	else cout << "YES\n";
	return 0;
}

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


using pqi = priority_queue<int>;

bool fueru(pqi& pq1, pqi& pq2) {
  pqi npq1, npq2;
  // cerr << pq1.size() << " " << pq2.size() << endl;
  while (!pq1.empty()) {
    int from = pq1.top(); pq1.pop();
    npq1.push(from);
    bool found = false;
    while (!pq2.empty()) {
      int to = pq2.top(); pq2.pop();
      if (to < from) { 
        found = true;
        npq1.push(to);
        break;
      }
      npq2.push(to);
    }
    if (!found) return false;
  }
  swap(pq1, npq1);
  while (!npq2.empty()) {
    pq2.push(npq2.top()); npq2.pop();
  }
  return true;
}

int main() {
  int n; cin >> n;
  pqi pq1, pq2;
  for (int i = 0; i < (1<<n); ++i) {
    int s; cin >> s;
    pq2.push(s);
  }
  pq1.push(pq2.top()); pq2.pop();
  for (int i = 0; i < n; ++i) {
    if (!fueru(pq1, pq2)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 4340
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  cin>>s;
  cin>>t;
  int ct=0;
  for(int i=0;i<s.length();i++)
  {
    if(s[i]==t[i])
      ct++;
  }
  cout<<ct;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N, K, C; cin >> N >> K >> C;
    string s; cin >> s;
    s += 'x';

    vector<int> pre(N+3), suf(N+3);
    for(int i=0; i<=N; i++) {
        chmax(pre[i+1], pre[i]);
        if(i+1-C-1 >= 0) chmax(pre[i+1], pre[i+1-C-1] + (s[i] == 'o'));
        chmax(pre[i+1], (int)(s[i] == 'o'));
    }
    for(int i=N; i>=0; i--) {
        chmax(suf[i+1], suf[i+2]);
        if(i+1+C+1 <= N+1) chmax(suf[i+1], suf[i+1+C+1] + (s[i] == 'o'));
        chmax(suf[i+1], (int)(s[i] == 'o'));
    }

    vector<int> ans;
    /*
    for(int i=0; i<N+2; i++) {
        fprintf(stderr, "i = %d: pre = %d, suf = %d, val = %c\n", i, pre[i], suf[i], i?s[i-1]:'_');
    }
    */
    for(int i=0; i<N; i++) {
        if(pre[i] + suf[i+2] < K) {
            // fprintf(stderr, "i = %d: pre = %d, suf = %d\n", i, pre[i], suf[i+2]);
            ans.emplace_back(i+1);
        }
    }
    for(auto e : ans) cout << e << endl;
    return 0;
}


Measured memory_bytes: 4216
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int main(){
	int n;
	scanf("%d",&n);
	long a;
	int odd=0,even=0;
	int i;
	for(i=0;i<n;i++){
		scanf("%ld",&a);
		if(a%2==0){
			even++;
		}else{
			odd++;
		}
	}
	
	if(odd%2==0){
		puts("YES");
	}else{
		puts("NO");
	}
	
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

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

  ll n;
  cin >> n;
  vll a(n);
  REP(i,n) cin >> a[i];

  ll q;
  cin >> q;
  REP(i,q){
    ll b, e, k;
    cin >> b >> e >> k;
    cout << count(a.begin()+b,a.begin()+e,k) <<endl;
  }
    
  return 0;
}




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

int main(){

    int a = 500;//infinite coin
    int b = 1;//limited

    int N,A;

    scanf("%d",&N);// harga
    scanf("%d",&A);//jumlah 1 yen

    int totalYen = b * A; //total

    int a2 = N % 500;
    int a3 = totalYen -  a2;

    if(a3 >=0){

        printf("Yes");

    }
    else{
        printf("No");
    }


    return 0;
}


Measured memory_bytes: 128
A = input()
B = input()

pw = ""
if len(A) == len(B):
    for i in range(len(A)):
        pw += A[i]
        pw += B[i]
    print(pw)
    exit()

else:
    for i in range(len(B)):
        pw += A[i]
        pw += B[i]
    print(pw + A[-1])
    exit()

Measured memory_bytes: 9068
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY puts("Yes")
#define NN puts("No")
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int solve(){
  int n;
  cin >> n;
  vector<int>v(n);
  rep(i,n)cin >> v[i];
  vector<bool>tmp(n,false);
  rep(i,n)if(i + 1 == v[i])tmp[i] = true;
  int ans = 0;
  rep(i,n - 1)if(tmp[i] && tmp[i + 1]){
    ans++;
    tmp[i] = false;
    tmp[i + 1] = false;
  }
  rep(i,n - 1){
    if(tmp[i] && !tmp[i + 1]){
      ans++;
      tmp[i] = false;
    }
    else if(!tmp[i] && tmp[i + 1]){
      ans++;
      tmp[i + 1] = false;
    }
  }
  cout << ans << endl;
  return 0;
}
int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;

int main() {
	ll N, P;
	cin >> N >> P;
	ll i = 2;
	ll ans = 1;
	while (i*i <= P) {
		if (P%i) {
			i++;
			continue;
		}
		int k = 0;
		while (P%i == 0) {
			k++;
			P /= i;
		}
		for (int j = 0; j < k / N; j++) ans *= i;
	}
	if (P > 0 && N == 1) {
		ans *= P;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll > P;
typedef pair<P,ll>Q;


int main(void){
    int n,m;
    cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
    return 0;
}

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

using namespace std;
int a, b, c;
int main()
{
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    scanf("%d%d%d", &a, &b, &c);
    cout << a+b+c - max(a, max(b, c));
    return 0;
}
/**/


Measured memory_bytes: 256
/* aman36 - Aman Raj */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define fast_io ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define pb push_back
#define ll long long
#define ld long double
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define pii pair<int, int>
#define F first
#define S second
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
#define vi vector <int>
#define mem(x, v) memset(x, v, sizeof(x));
#define int ll
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

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

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif

ll power(ll x, ll y, ll p) { 
    ll res = 1;
    x = x % p;  
    while (y > 0) {
        if (y & 1) 
            res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p; 
    }
    return res;
}

bool isPrime(int n) 
{
    if (n <= 1) return false; 
    if (n <= 3) return true; 
    if (n % 2 == 0 || n % 3 == 0) return false; 
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) return false; 
    return true; 
}

const ll INF = (ll)(8e18);
const ll NEGINF = (ll)(-6e18);
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const int M = 4000 + 5;
const int N = 1e5 + 5;
const int maxn = 1e5 + 5;

void solve() {
    int n, k;
    cin >> n >> k;

    int a[n];
    fori(n) cin >> a[i];

    int dp[k+1];
    mem(dp, 0);

    for(int i=1; i<=k; i++) {
        for(int j=0; j<n; j++) {
            if(i - a[j] >= 0 && dp[i - a[j]] == 0) dp[i] = 1;
        }
    }

    cout << (dp[k] ? "First" : "Second") << endl;
}

signed main() {
    fast_io;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    int tc = 1;
    // cin >> tc;

    for(int i=1; i<=tc; i++) {
        // cout << "Case #" << i << ": " ;
        solve();
    }

    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif

    return 0;
}

// read the question correctly
// read code carefully
// corner cases // int vs ll // cin vs scanf // clear structures // maths
// check if max, min set to INT_MAX instead of INF
// check constraint 

Measured memory_bytes: 4376
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;

int N;
vvi eg;

void dfs(vi& vis, int t, int x) {
  if (vis[x]>=0) return;
  vis[x] = t;

  for(int nx : eg[x]) {
    if (vis[nx]>=0) continue;

    dfs(vis, t+1, nx);
  }
}

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


  int V,U; cin>>N>>U>>V;
  U--;V--;
  eg = vvi(N);
  REP(i,N-1) {
    int A,B;cin>>A>>B;
    A--;B--;
    eg[A].push_back(B);
    eg[B].push_back(A);
  }

  vi vt = vi(N, -1);
  dfs(vt, 0, U);
  vi va = vi(N, -1);
  dfs(va, 0, V);

  int ans = 0;
  REP(i,N) {
    if (vt[i] < va[i]) {
      ans = max(ans, va[i]);
    }
  }
  ans--;

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
using namespace std;

int main() {
	long long int A, B; cin >> A >> B;
	if ((A + B) % 2 == 0) cout << (A + B) / 2 << endl;
	else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
 
/*------------------------------------------------------------------*/
 
int main(){
    string s; cin >> s;
    ll n = s.size();
    ll count = 0;
    ll ans = 0;
    rep(i, n){
        if(s[i] == 'B')count++;
        else ans += count;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
/*
 　　　　　／＞　 フ
 　　　　　| 　_　 _|
 　 　　　／`ミ _x 彡
 　　 　 /　　　 　 |
 　　　 /　  ヽ　　 ?
 　／￣|　　 |　|　|
 　| (￣ヽ＿_ヽ_)_)
 　＼二つ
  */

#include <queue>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MP make_pair
#define ll long long
#define fi first
#define se second
using namespace std;

template <typename T>
void read(T &x) {
    x = 0; bool f = 0;
    char c = getchar();
    for (;!isdigit(c);c=getchar()) if (c=='-') f=1;
    for (;isdigit(c);c=getchar()) x=x*10+(c^48);
    if (f) x=-x;
}

template<typename F>
inline void write(F x, char ed = '\n') {
    static short st[30];short tp=0;
    if(x<0) putchar('-'),x=-x;
    do st[++tp]=x%10,x/=10; while(x);
    while(tp) putchar('0'|st[tp--]);
    putchar(ed);
}

template <typename T>
inline void Mx(T &x, T y) { x < y && (x = y); }

template <typename T>
inline void Mn(T &x, T y) { x > y && (x = y); }

const int P = 1e9 + 7;
const int N = 3050;
ll f[N][N], g[N][N], m, n;
int main() {
    read(n), read(m);
    for (int i = 1;i <= n; i++) f[0][i] = 1;
    g[0][0] = 1;
    for (int i = 1;i <= m; i++) {
        for (int j = 0;j <= n; j++) {
            if (j) {
                f[i][j] = f[i-1][j-1], g[i][j] = (g[i-1][j-1] + g[i-1][j]) % P;
                if (j == 1) g[i][j] = (g[i][j] + f[i-1][j]) % P;
                else f[i][j] = (f[i][j] + f[i-1][j]) % P;
            }
            if (j < n) {
                g[i][j] = (g[i][j] + g[i-1][j+1] + g[i-1][j]) % P;
                if (j) f[i][j] = (f[i][j] + f[i-1][j+1] + f[i-1][j]) % P;
                else g[i][j] = (g[i][j] + f[i-1][j+1]) % P;
            }
        }
    }
    ll ans = 0;
    for (int i = 0;i <= n; i++) ans += g[m][i];
    write(ans % P);
}

Measured memory_bytes: 145816
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld long double
#define pp pair<ll,pair<ll,ll> >
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell 1000000007
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree<ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
const ll N = 1e5 + 55 ;
vector<ll> par(N,0) , rankk(N,1) , adj[N] ;
ll findPar( ll x )
{
    while( x != par[x] )
        x = findPar(par[x]) ;
    return x ;
}
ll uni( ll x , ll y )
{
    ll ans = 0 ;
    if( findPar(x) != findPar(y) )
    {
        ll px = findPar(x) , py = findPar(y) ;
        if( rankk[px] >= rankk[py] )
        {
            par[py] = px  ;
            ans -= ((rankk[px])*(rankk[px]-1))/2 ;
            ans -= ((rankk[py])*(rankk[py]-1))/2 ;
            rankk[px] += rankk[py] ;
            ans += ((rankk[px])*(rankk[px]-1))/2 ;
        }
        else
        {
			par[px] = py  ;
            ans -= ((rankk[px])*(rankk[px]-1))/2 ;
            ans -= ((rankk[py])*(rankk[py]-1))/2 ;
            rankk[py] += rankk[px] ;
            ans += ((rankk[py])*(rankk[py]-1))/2 ;
        }
    }
    return ans ;
}
void solve() 
{ 
    ll n , m , ini , x , y ;
    cin >> n >> m ;
    vector<pair<ll,ll> > v ;
    rep( i , 1 , n + 1 )
    {
        par[i] = i ;
        rankk[i] = 1 ;
    }
    ini = ( n*(n-1) ) / 2 ;
    rep( i , 0 , m )
    {
        cin >> x >> y ;
        v.pb( {x,y} ) ;
    }
    reverse(all(v));
    vector<ll> ans ;
    rep( i , 0 , m )
    {
        x = v[i].f ;
        y = v[i].s ;
        //cout << "ini : " << ini << "\n" ;
         ans.pb(ini);
        ini -= uni(x,y) ;
       
    }
    reverse(all(ans));
    for(auto it : ans )
        cout << it << "\n" ;
}  
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


Measured memory_bytes: 8688
#include <bits/stdc++.h>
using namespace std;
long long a,b,z;
int main()
{
    cin>>a>>b>>z;
    for(int i=1; i<=z; i++)
    {
        if(i%2!=0)
        {
            if(a%2!=0)a--;
            b+=a/2;
            a/=2;
        }
        else
        {
            if(b%2!=0)b--;
            a+=b/2;
            b/=2;
        }
    }
    cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int L = Integer.parseInt(in.next());
		double V = Math.pow((double)L / 3, 3);
		
		System.out.println(String.format("%.12f", V));
	}
}	

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

int main() {
  string a, b;
  cin >> a >> b;

  a+=b;
  int n=stoi(a), flg=0;

  for (int i=1; i*i<=n; i++) {
    if (i*i==n) flg=1;
  }

  cout << (flg ? "Yes": "No");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//モンスターのヒットポイント
		int h = sc.nextInt();
		//必殺技の種類
		int n = sc.nextInt();
		//アライグマの初期値
		int cr = 0;

		for (int i = 0; i < n; i++) {
			cr += Integer.parseInt(sc.next());

		}
		//同じ技を使わない
		if(cr >= h) {
			System.out.println("Yes");
		}
		//それ以外
		else {
			System.out.println("No");
		}
		sc.close();

	}

}

Measured memory_bytes: 58472
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right,value_type index[])
/* クイックソート
 * a     : ソートする配列 
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 * index: index配列
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            tmp = index[i]; index[i] = index[j]; index[j] = tmp;
            i++; j--;
        }
        quicksort(a, left, i - 1,index);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right,index); /* 分割した右を再帰的にソート */
    }
}


int dfs(int n,int N){
    if (n>N){
        return 0;
    }
    

    int ret;
    
    return ret;
}


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

    if(A<B){ //A>Bを保証
        int tmp=A;
        A=B;
        B=tmp;
    }
    for(int di=B;di>=0;di--){
        if(B%di==0 && A%di==0){
            K--;
            if(K==0){
                cout <<di << endl;
                return 0;
            }
        }
    }

    return 0;

    


}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
dp = [0, abs(h[0]-h[1])] + [float('inf')]*(n-2)
for i in range(2,n):
    dp[i] = min(dp[i], dp[i-1]+abs(h[i-1]-h[i]))
    dp[i] = min(dp[i], dp[i-2]+abs(h[i-2]-h[i]))
print(dp[-1])

Measured memory_bytes: 13928
//三重ループはTLEでした。
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int k,s;
  cin >>k>>s;
int count=0;
 
  for(int i=0;i <=k;i++){
  for(int j=0;j <=k;j++){
  int m=s-i-j;
   if(i+j+m==s && m<=k &&m >=0){
   count++;}
   }
  }
  cout <<count <<endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
  if A[i] >= B[i]:
    ans += B[i]
  else:
    ans += B[i]
    A[i+1] -= (B[i] - A[i])
    if A[i+1] < 0:
      ans -= abs(A[i+1])
      A[i+1] = 0
print(ans)

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

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int s = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (i * j + (n - i) * (m - j) == k) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;
u64 over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  string s;
  cin >> n >> s;
  bool ss[n];

  ss[0] = true; ss[1] = true;
  for (int i = 2; i < n; ++i) {
    if ((ss[i-1] && s[i-1]=='o' ) || (!ss[i-1] && s[i-1]=='x')) ss[i] = ss[i-2];
    else ss[i] = !ss[i-2];
  }
  if ((ss[n-1] && s[n-1]=='o' && ss[0]==ss[n-2]) || (ss[n-1] && s[n-1]=='x' && ss[0]!=ss[n-2]) ||
  (!ss[n-1] && s[n-1]=='o' && ss[0]!=ss[n-2]) || (!ss[n-1] && s[n-1]=='x' && ss[0]==ss[n-2])) {
    if ((ss[0] && s[0]=='o' && ss[1]==ss[n-1]) || (ss[0] && s[0]=='x' && ss[1]!=ss[n-1]) ||
    (!ss[0] && s[0]=='o' && ss[1]!=ss[n-1]) || (!ss[0] && s[0]=='x' && ss[1]==ss[n-1])) {
      for (int i = 0; i < n; ++i) cout << (ss[i] ? "S" : "W");
      cout << endl;
      return 0;
    }
  }

  ss[0] = true; ss[1] = false;
  for (int i = 2; i < n; ++i) {
    if ((ss[i-1] && s[i-1]=='o' ) || (!ss[i-1] && s[i-1]=='x')) ss[i] = ss[i-2];
    else ss[i] = !ss[i-2];
  }
  if ((ss[n-1] && s[n-1]=='o' && ss[0]==ss[n-2]) || (ss[n-1] && s[n-1]=='x' && ss[0]!=ss[n-2]) ||
  (!ss[n-1] && s[n-1]=='o' && ss[0]!=ss[n-2]) || (!ss[n-1] && s[n-1]=='x' && ss[0]==ss[n-2])) {
    if ((ss[0] && s[0]=='o' && ss[1]==ss[n-1]) || (ss[0] && s[0]=='x' && ss[1]!=ss[n-1]) ||
    (!ss[0] && s[0]=='o' && ss[1]!=ss[n-1]) || (!ss[0] && s[0]=='x' && ss[1]==ss[n-1])) {
      for (int i = 0; i < n; ++i) cout << (ss[i] ? "S" : "W");
      cout << endl;
      return 0;
    }
  }

  ss[0] = false; ss[1] = true;
  for (int i = 2; i < n; ++i) {
    if ((ss[i-1] && s[i-1]=='o' ) || (!ss[i-1] && s[i-1]=='x')) ss[i] = ss[i-2];
    else ss[i] = !ss[i-2];
  }
  if ((ss[n-1] && s[n-1]=='o' && ss[0]==ss[n-2]) || (ss[n-1] && s[n-1]=='x' && ss[0]!=ss[n-2]) ||
  (!ss[n-1] && s[n-1]=='o' && ss[0]!=ss[n-2]) || (!ss[n-1] && s[n-1]=='x' && ss[0]==ss[n-2])) {
    if ((ss[0] && s[0]=='o' && ss[1]==ss[n-1]) || (ss[0] && s[0]=='x' && ss[1]!=ss[n-1]) ||
    (!ss[0] && s[0]=='o' && ss[1]!=ss[n-1]) || (!ss[0] && s[0]=='x' && ss[1]==ss[n-1])) {
      for (int i = 0; i < n; ++i) cout << (ss[i] ? "S" : "W");
      cout << endl;
      return 0;
    }
  }

  ss[0] = false; ss[1] = false;
  for (int i = 2; i < n; ++i) {
    if ((ss[i-1] && s[i-1]=='o' ) || (!ss[i-1] && s[i-1]=='x')) ss[i] = ss[i-2];
    else ss[i] = !ss[i-2];
  }
  if ((ss[n-1] && s[n-1]=='o' && ss[0]==ss[n-2]) || (ss[n-1] && s[n-1]=='x' && ss[0]!=ss[n-2]) ||
  (!ss[n-1] && s[n-1]=='o' && ss[0]!=ss[n-2]) || (!ss[n-1] && s[n-1]=='x' && ss[0]==ss[n-2])) {
    if ((ss[0] && s[0]=='o' && ss[1]==ss[n-1]) || (ss[0] && s[0]=='x' && ss[1]!=ss[n-1]) ||
    (!ss[0] && s[0]=='o' && ss[1]!=ss[n-1]) || (!ss[0] && s[0]=='x' && ss[1]==ss[n-1])) {
      for (int i = 0; i < n; ++i) cout << (ss[i] ? "S" : "W");
      cout << endl;
      return 0;
    }
  }

  cout << -1 << endl;
  return 0;
}


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

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    for (int i = 0; i < M; i++) {
        cin >> B[i];
    }
    vector<vector<int> > A(N, vector<int> (M));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }   
    }
    int cnt = 0;
    vector<int> sum(N, 0);
    for (int i = 0; i < N; i++) {
        int sum = 0;
        for (int j = 0; j < M; j++) {
            sum += A[i][j] * B[j];
        }
        if (sum + C > 0) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  int A,B;
  int b=0;
  cin >> A >> B;
  for (int i=A; i<=B; i++){
    
    if(i/10000 == i%10 && i%10000/1000 == i%100/10){
      b++;
    }
    else
      b==b;
    
  }
  cout << b << endl;
    
    
}
   

Measured memory_bytes: 3600
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vint A(N + 1);
    rep(i, N + 1) cin >> A[i];
    int num = 0;
    
    vll max_node_num_v(N + 1);
    if (N == 0 && A[0] != 1) {
        cout << -1 << endl;
        return 0;
    }

    //max_node_num_v[0] = max_node_num;
    max_node_num_v[N] = A[N];
    for (int i = N - 1; i >=  0; i--) {
        max_node_num_v[i] = A[i] + max_node_num_v[i+1];
    }
    ll max_node_num = 1;
    ll ans = 1;

    REP(i, 1, N + 1) {
        if (max_node_num < LINF && (max_node_num - A[i - 1]) * 2 < A[i]) {
            cout << -1 << endl;
            return 0;
        }
        max_node_num = (max_node_num - A[i - 1]) * 2;
        if (max_node_num >= LINF) max_node_num = LINF;
        ans += min(max_node_num_v[i], max_node_num);
        //ans += max_node_num;
    }



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

Measured memory_bytes: 4480
# Σ_[i = 0 → n - 1]floor((a * i + b) / b)
# O(log(n + m + a + b))
def floor_sum(n, m, a, b):
    ans = 0
    if a >= m:
        ans += (n - 1) * n * (a // m) // 2
        a %= m
    if b >= m:
        ans += n * (b // m)
        b %= m
    y_max = (a * n + b) // m
    x_max = y_max * m - b
    if y_max == 0:
        return ans
    ans += (n - (x_max + a - 1) // a) * y_max
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a)
    return ans

t = int(input())
for _ in range(t):
    n, m, a, b = map(int, input().split())
    ans = floor_sum(n, m, a, b)
    print(ans)

Measured memory_bytes: 75844
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int N;
    cin >> N;
    vector<int> W(N);
    rep(i, N) cin >> W.at(i);

    int sum = 0;
    rep(i, N) {
        sum += W.at(i);
    }

    int S1 = 0, S2 = sum, minDiff = MOD;
    rep(t, N) { // T
        S1 += W.at(t);
        S2 -= W.at(t);
        minDiff = min(minDiff, abs(S2 - S1));
    }

    cout << minDiff << endl;

    return 0;
}


Measured memory_bytes: 3604
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}
#define int ll

void solve() {
	int s;
	cin >> s;
	map<ll,ll> gogo;
	for (int i = 1; i <= 100000; ++i) {
		ll now = 0;
		for (int q = i;; ++q) {
			now += q;
			gogo[now]++;
			if (now > 1e5) break;
		}
	}
	ll ans = 0;
	for (int i = 1; i <= 100000; ++i) {
		ll now = 0;
		for (int q = i;; ++q) {
			now += q;
			if (s % now == 0) {
				ans += gogo[s / now];
			}
			if (now > 1e5) break;
		}
	}
	cout << ans << endl;
}

#undef int
int main() {
	init();
	solve();
}


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  vs s(3);
  rep(i, 3) cin >> s[i];
  rep(i, 3) {
    char c = s[i][0];
    cout << (char)(c + 'A' - 'a');
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
 int n;
 cin>>n;
 
 int p[5000];
 
 for(int i=0;i<n;i++){
    cin>>p[i];
 }
 
 int min_sum=20000;
 
 for(int i=0;i<=p[0];i++){
    int q[5000];
    for (int j=0;j<n;j++){
        q[j]=p[j];
    }
 
    int sum=i;
    q[0]-=i;
 
    for(int j=0;j<=n-2;j++){
        if(q[j]<=0)  continue;
 
        sum+=q[j]*2;
        q[j+1]-=q[j];
    }
 
    if(q[n-1]>0){
        sum+=q[n-1];
    }
    min_sum=min(min_sum,sum);
 }
 cout <<min_sum<<endl;
 
 return 0;
}

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

int main(void){
    int ans=0,n,B[100];
    cin >> n;
	for(int i=0;i<n-1;i++){
		cin >> B[i];
	}

	for(int i=0;i<n;i++){
		if(i == 0){
			ans = ans + B[i];
		}else if(i == n-1){
			ans = ans + B[i-1];
		}else{
			if(B[i] < B[i-1]){
				ans = ans + B[i];
			}else{
				ans = ans + B[i-1];
			}
		}
	}
	cout << ans << endl;
}

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

int f(int n){
  if(n%2) return 3*n+1;
  return n/2;
}

int main(){
  int s;
  cin >> s;
  map<int,int> M;
  M[s] = 1;
  for(int i = 2; i <= 1000000; ++i){
    s = f(s);
    if(M[s] > 0){
      cout << i << endl;
      return 0;
    }
    M[s] = i;
  }
}


Measured memory_bytes: 256
#![allow(unused_macros)]
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(unused_imports)]
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => (::std::cmp::max($x, max!( $($y),+)));
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => (::std::cmp::min($x, min!( $($y),+)));
}

// solution 
use std::cmp;
use std::collections::{HashMap, HashSet, BTreeMap, BTreeSet};
fn main() {
    input! {
        N: usize,
        A: [i64; N],
    }

    let mut count = 0;
    for &a in A.iter() {
        if a < 0 {
            count += 1;
        }
    }
    let abs_a: Vec<usize> = A.iter().map(|a| a.abs() as usize).collect();
    let mut sum: usize = abs_a.iter().sum();
    if count % 2 == 1 {
        sum -= 2*abs_a.iter().min().unwrap();
    }
    println!("{}", sum);
}


Measured memory_bytes: 6396
import sys
from bisect import *
import math

input = sys.stdin.readline

N = int(input())
A = list(map(int,input().split()))
mod = 1000000007

cnum = A.count(0)
amax = max(A)

numind = [[] for i in range(amax+1)]
for i,ai in enumerate(A):
	numind[ai].append(i)

if cnum==0 or cnum>3:
	res = 0
else:
	res = 1
	for i in range(amax):
		if len(numind[i+1])==0 or len(numind[i+1])>3:
			res = 0
			break
		for order, j in enumerate(numind[i+1]):
			res = (res * (bisect(numind[i],j)-order)) % mod

	res = (res*math.factorial(3)//math.factorial(3-cnum)) % mod

print(res)

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

using namespace std;
#define  ll  long long
#define f first
#define s second
#define matrix vector<vector<ll>>
#define zero(n,m) matrix(n , vector<ll>(m,0))
#define one(n,m) matrix(n , vector<ll>(m,1))
#define pii pair<ll,ll>

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    string s,t;
    cin >> s >> t;

    ll ans = 1e9 , tmp=0;

    for(int i=0; i+t.size()-1 < s.size(); i++)
    {
        tmp=0;
        for(int j=0; j<t.size(); j++)
        {
            if (s[i+j] != t[j]) tmp++;
        }
        ans = min(ans , tmp);
    }

    cout << ans;


    return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int sx, sy, tx, ty;
int main() {
	cin >> sx >> sy >> tx >> ty;
	for (int i = 0; i != tx - sx; ++i)
		cout << 'R';
	for (int i = 0; i != ty - sy; ++i)
		cout << 'U';
	cout << 'R';
	for (int i = 0; i != ty - sy + 1; ++i)
		cout << 'D';
	for (int i = 0; i != tx - sx + 1; ++i)
		cout << 'L';
	cout << 'U';
	for (int i = 0; i != ty - sy; ++i)
		cout << 'U';
	for (int i = 0; i != tx - sx; ++i)
		cout << 'R';
	cout << 'U';
	for (int i = 0; i != tx - sx + 1; ++i)
		cout << 'L';
	for (int i = 0; i != ty - sy + 1; ++i)
		cout << 'D';
	cout << 'R' << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll A,B,N; cin >> A >> B >> N;
    ll x = min(B-1,N);
    cout << (ll)(A*x/B) - A*(ll)(x/B);
  	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
const int INF=1e9;
using namespace std;

int main(){
    int n, ans=1;
    cin>>n;
    while(ans<=n)ans*=2;
    cout<<ans/2<<endl;
}



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

int main(){
    int n,k;cin>>n>>k;
    vector<int> heights(n);for(int i=0;i<n;i++){cin>>heights[i];}

    int acc = 0;
    for (auto h: heights){
        if (h >= k){
            acc++;
        }
    }
    cout << acc << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int tap(int a,int A){
    int N;
    N=a+A-1;
    return N;
}


int main(void){
    int A,B;//入力
    cin>>A;
    cin>>B;
   
    int coun=0;//カウンター
    int num=1;
    
    while(B>num){
      num=tap(num,A);
      coun++;
    }

    cout<< coun <<endl;
    return 0;
}

Measured memory_bytes: 256
import bisect
# 計算量を大体で見積もってぶん投げればおｋ
# この問題だとO(a**0.25)
x = int(input())

for i in range(-1000, 1000):
    for j in range(-1000, 1000):
        if i ** 5 - j ** 5 == x:
            print(i, j)
            quit()

Measured memory_bytes: 9056
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	string S;
	cin >> S;
	int Z = S.size();
	string T = "keyence";
	int cnt = 0;
	rep(i, 8) {
		rep(j, 7) {
			if (i<=j) {
				if (S[j + (Z - 7)] == T[j]) {
					cnt++;
				}
			}
			else {
				if (S[j] == T[j]) {
					cnt++;
				}
			}	
		}
		if (cnt == 7) {
			cout << "YES" << endl;
			return 0;
		}
		cnt = 0;
	}
	cout << "NO" << endl;
}


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

using namespace std;

int main()
{
    double n;
    cin>>n;
    double ans=0;
    if(fmod(n,2)==1)
    {
        ans=(ceil(n/2))/n;
    }
    else
        ans=n/(2*n);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int a[] = new int[n];

		int sum = 0;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}

		Arrays.sort(a);

		boolean can = true;;
		for (int i = 1; i <= m; i++) {
			if (a[n - i] < (double)sum / (double)(4 * m)) can = false;
		}

		if (can) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();

	}
}

Measured memory_bytes: 21844
n = int(input())
a = [int(i) for i in input().split()]

a_sum = abs(a[0])
a_min = abs(a[0])
cnt = 0
if a[0] < 0:
    cnt += 1
for i in range(n - 1):
    a_min = min(a_min, abs(a[i+1]))
    a_sum += abs(a[i+1])
    if a[i + 1] < 0:
        cnt += 1
if cnt % 2 == 0:
    print(a_sum)
else:
    print(a_sum-a_min*2)


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    ii(n);
    if(n == 3){
        out(2); out("1 3"); out("2 3"); return 0;
    }
    
    bool f = n % 2; if(f) n--;
    vector<P> ans;
    for(int i = 1; i < n/2; i++){
        for(int j = i+1; j <= n-i; j++){
            ans.push_back(P(i, j));
            ans.push_back(P(j, n-i+1));
        }
    }
    if(f){
        for(int i = 1; i <= n; i++) ans.push_back(P(i, n+1));
    }

    out(ans.size());
    rep(i, ans.size()){
        out(to_string(ans[i].fi) + " " + to_string(ans[i].se));
    }
}


Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int ans=0;
	for(int i=0;i!=n;++i){
		int x;
		cin>>x;
		ans+=2*min(k-x,x);
	}
	cout<<ans;
}

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

#define int long long

using pii = pair<int, int>;
const int maxV = 111111;
vector<pii> G[maxV]; // 頂点情報のみのグラフ
int ans[111111];

int N;

// 木のDFS
void treeDFS(int from, int current, int dist) {
  if (dist % 2 == 1) {
    ans[current] = 1;
  }

  for (auto p : G[current]) {
    int to = p.first;
    int d = p.second;
    // 逆流を防ぐ
    if (to == from) continue;

    treeDFS(current, to, dist + d);
  }
}

// 木のDFSを呼び出す関数
void searchTree() {
  int root = 0; // 根
  int from = -1; // 根の親。根の親はないので-1を指定する
  treeDFS(from, root, 0);
}

signed main() {
  cin >> N;
  for (int i = 0; i < N-1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    G[u].push_back({v, w});
    G[v].push_back({u, w});
  }

  searchTree();

  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 10496
class Dice:
    def __init__(self):
        self.side = {"top": 0, "front": 0, "right": 0, "left": 0, "back": 0, "bottom": 0}

    # サイコロを東西南北、どちらか一方に転がした時、それぞれの面の変化
    def roll(self, direction):
        self.direction = direction
        if self.direction == "N":
            w = self.side["top"]
            self.side["top"] = self.side["front"]
            self.side["front"] = self.side["bottom"]
            self.side["bottom"] = self.side["back"]
            self.side["back"] = w
        elif self.direction == "S":
            w = self.side["top"]
            self.side["top"] = self.side["back"]
            self.side["back"] = self.side["bottom"]
            self.side["bottom"] = self.side["front"]
            self.side["front"] = w
        elif self.direction == "E":
            w = self.side["top"]
            self.side["top"] = self.side["left"]
            self.side["left"] = self.side["bottom"]
            self.side["bottom"] = self.side["right"]
            self.side["right"] = w
        elif self.direction == "W":
            w = self.side["top"]
            self.side["top"] = self.side["right"]
            self.side["right"] = self.side["bottom"]
            self.side["bottom"] = self.side["left"]
            self.side["left"] = w

    # サイコロの目を作成
    def create(self):
        for s, n in zip(dice.side, input().split()):
            dice.side[s] = int(n)

def simulation():
    for line in a:
        dir = random.sample("NSEW"*5, 20)
        for direction in dir:
            dice.roll(direction)
            if dice.side == line:
                return "No"
    else:
        a.append(dict(dice.side))

import random
n = int(input())
dice = Dice()
dice.create()
a = []; a.append(dict(dice.side))
    
for i in range(1, n):
    dice.create()
    judge = simulation()
    if judge == "No":
        print("No")
        break
else:
    print("Yes")



Measured memory_bytes: 8240
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int K, N; cin >> K >> N;
  int a[N]; rep(i,N) cin >> a[i];
  sort(a,a+N);
  reverse(a,a+N);
  if (a[0]<(K+1)/2) {
    cout << 0 << endl;
  }
  else if (K%2) {
    int k = a[0]-(K+1)/2;
    cout << 2*k << endl;
  }
  else {
    int k = a[0] - K/2;
    cout << 2*k-1 << endl;
  }


  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3628