akhauriyash/Code-Regression huggingface dataset:
/*
Author: Fuadul Hasan(fuadul202@gmail.com)
BSMRSTU,Gopalganj
*/
#include<bits/stdc++.h>
using namespace std;
void    		print(int n)    {printf("%d ", n);}
void    		printl(long long n)     {printf("%I64d ", n);}
long long    	readline(){long long x;scanf("%I64d", &x);return x;}
/*
1.#define  gcd(a,b) __gcd(a,b) 2. #define  lcm(a,b) (a*b)/gcd(a,b) 3. #define  PI acos(-1.0) 4.#define  sqr(x) ((x)*(x))
5.#define  min3(a,b,c) min(a,min(b,c))6.#define  min4(a,b,c,d) min(d,min(a,min(b,c)))7.#define  max3(a,b,c) max(a,max(b,c))
8.#define  max4(a,b,c,d) max(d,max(a,max(b,c)))
*/
//.............ignore it................//
/*....... scanf.......*/
template <typename T> inline void readline(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';n = n * f;}
template <typename T, typename TT> inline void readline(T &n, TT &m) { readline(n); readline(m); }
template <typename T, typename TT, typename TTT> inline void readline(T &n, TT &m, TTT &l) { readline(n, m); readline(l);}
/*..........error........*/
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {
  vector<string>v; stringstream ss(s); string x;
  while (getline(ss, x, c))v.emplace_back(x); return move(v);
} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}
//............ignore it..................//
typedef   pair<int, int> ii;
typedef   std::vector<ii> vii;
#define   vi   std::vector<int>
#define   vll  std::vector<ll>
#define   all(n) n.begin(),n.end()
#define  mpsi std::map<string, int>
#define  pb                     push_back
#define  ll                     long long int
#define  nl                     printf("\n");
#define  happy          cin.tie(0);
#define  coding         ios::sync_with_stdio(false);
int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)2e18 + 5;
const int N             = 500 + 5;
const int N1            = 3e5 + 5;
int visit[N][N];
string s[505];


int solve()
{
	//happy coding
	string s;
	cin>>s;
	int cnt=0;
		for(int i=0;i<s.size()-1;i++){
			if(s[i]=='h'&&s[i+1]=='i'){
				cnt++;
			}
		}
		if(cnt*2==s.size())
		cout<<"Yes"<<endl;
	else{
		cout<<"No"<<endl;
	}
	return 0;


	//error()
	return 0;
}

int main(){
	int test = 1, tc = 0;
	//scanf("%d", &test);//(void)getchar();
	while (test--)solve();
	return 0;
}

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

using namespace std;

int main() {
    int S, h, m, s;
    cin >> S;
    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 3600) % 60;
    cout << h << ":" << m << ":" << s << endl;
}


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

int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < 3; ++i){
        if (s[i] == '1') {
            ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        for(int i = 1;;i++){
            n = n-k;
            if(n <= 0){
                System.out.println(i);
                break;
            }
            n++;
        }
    }
}

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

using namespace std;

int main() {
  string s,t;
  cin>>s>>t;
  string ss=s;
  string tt=t;
  reverse(ss.begin(), ss.end()); reverse(tt.begin(),tt.end());
	cout<<((tt==s && ss==t)? "YES\n" : "NO\n");
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  lint a, b, c;
  cin >> a >> b >> c;
  lint l   = a + b;
  lint r   = c;
  lint tmp = r - l;
  if (tmp <= 0) {
    cout << "No" << endl;
    return 0;
  }
  cout << (4 * a * b < tmp * tmp ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
x = 0
for i in range(n):
    if i % 2 == 0:
        x += a[i]
    else:
        x -= a[i]
x //= 2
ans = [0] * n
ans[0] = x
for i in range(1, n):
    ans[i] = a[i-1] - ans[i-1]
for i in range(n):
    ans[i] *= 2
print(' '.join(map(str, ans)))

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

int main() {
    int n; cin >> n;
    vector<int> c(n+1, 0);
    int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; c[a[i]]++; }
    int mn = *min_element(a, a+n), mx = *max_element(a, a+n);
    bool ans = mn == (mx + 1) / 2 && (mx % 2 ? c[mn] == 2 : c[mn] == 1);
    for (int i = mn+1; i <= mx; i++) ans = ans && c[i] >= 2;
    cout << (ans ? "Possible\n" : "Impossible\n");
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
bool h[1000010]={false};
int main(){
	int a,b;
	while(cin>>a>>b){
		int c=a+b;
		int co=0;
		while(c){
			co++;
			c/=10;
		}
		cout<<co<<endl;
	}
}

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

int main() {
    // cin.tie(nullptr); ios::sync_with_stdio(false);
    // ll a; cin >> a;
    // string b; cin >> b;
    // b.erase(b.begin()+1);
    // ll c = stoi(b);
    // cout << c << endl;
    // a *= c;
    // cout << a/100 << endl;
    long double a,b; cin >> a >> b;
    ll c = a*b;
    cout << c << endl;
}

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

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

    vector<int> A(n-1);
    rep(i, n-1){
        cin >> A.at(i);
    }
    vector<int> B(n, 0);
    for (auto ai:A){
        B.at(ai-1) ++;
    }
    for (auto bi:B){
        cout << bi << endl;
    }
}

Measured memory_bytes: 4844
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
	using namespace std;

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

		cout << r * r << endl;

		
	}

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

int main(){
    long long w = 0;// 合計
    int x , xx;
    long long y = -1000000;//Max.
    long long z = 1000000;//Min.
    
    cin >> x;
    for (int i = 0; i < x; i++){
        cin >> xx;
        w = w + xx;
        if (y < xx) {
            y = xx;
        }
        if (z > xx) {
            z = xx;
        }
    }
    cout << z << " " << y << " " << w << endl;
    
    return 0;
}


Measured memory_bytes: 3116
import bisect

N = 10 ** 5
primes = [True] * (N + 1)
primes[0] = primes[1] = False
for i in range(2, int(len(primes) ** 0.5 + 1)):
    for j in range(i + i, len(primes), i):
        primes[j] = False
primes = [i for i in range(len(primes)) if primes[i]]
targets = [x for x in primes if (x + 1) // 2 in primes]

q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    x = bisect.bisect_left(targets, l)
    y = bisect.bisect_right(targets, r)
    print(y - x)

Measured memory_bytes: 10320
use std::io::{self, BufRead, BufWriter, Write};
use std::error::Error;

type AppResult<T> = Result<T, Box<dyn Error>>;

fn solve<R, W>(reader: R, mut writer: W) -> AppResult<()>
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let a: f64 = lines.next().ok_or("no lines")??.parse()?;
    // let b_line = lines.next().ok_or("no lines")??;
    // let mut splited = b_line.trim().split_whitespace();
    // let b: f64 = splited.next().ok_or("no column1")?.parse()?;
    // let c: f64 = splited.next().ok_or("no column2")?.parse()?;

    writeln!(&mut writer, "{}", 2.0 * std::f64::consts::PI * a).unwrap();
    Ok(())
}

fn main() -> AppResult<()> {
    let stdio = io::stdin();
    let input = stdio.lock();

    let stdout = io::stdout();
    let output = BufWriter::new(stdout.lock());

    solve(input, output)
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"1",
            br"6.28318530717958623200
",
        ),
        (
            br"73",
            br"458.67252742410977361942
",
        ),
    ];

    #[test]
    fn test_a() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


Measured memory_bytes: 2192
#include <iostream>
#include <string>
#include <map>
#include <math.h>
using namespace std;

#define ll long long

int main(){
    int N,M;
    cin >> N >> M;
    int K[N],A[N][M] = {},count[M] = {},ans = 0;
    for(int i = 0;i < N;i++){
        cin >> K[i];
        for(int j = 0;j < K[i];j++){
            cin >> A[i][j];
            count[A[i][j]-1]++;
        }
    }
    for(int i = 0;i < M;i++){
        if(count[i] == N)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from bisect import *

N,M,K,*f = map(int, open(0).read().split())
A = f[:N]
B = f[N:]
csa = [0]
ans = 0
for i in range(N):
    csa.append(csa[i]+A[i])
csb = [0]
for i in range(M):
    csb.append(csb[i]+B[i])
for i in range(N+1):
    if csa[i] <= K:
        bs = bisect_right(csb,K-csa[i])
        ans = max(ans,i+bs-1)
    else:
        break
print(ans)

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 123;
const ll LINF = (ll) 1e18 + 123;
const ld EPS = (ld) 1e-8;
//const ll MOD = (ll) 1e9 + 7;

#define sz(x) (int) (x).size()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb(s, t, x) (int) (lower_bound(s, t, x) - s)
#define ub(s, t, x) (int) (upper_bound(s, t, x) - s)
#define rep(i, f, t) for (auto i = f; i < t; i++)
#define per(i, f, t) for (auto i = f; i >= t; i--)

ll power(ll x, ll y, ll mod) {
    if (y == 0) {
        return 1;
    }
    if (y & 1) {
        return power(x, y - 1, mod) * x % mod;
    } else {
        ll tmp = power(x, y / 2, mod);
        return tmp * tmp % mod;
    }
}

inline void add(ll &x, ll y, ll mod) {
    x += y;
    if (x >= mod) x -= mod;
    if (x < 0) x += mod;
}

inline ll sum(ll x, ll y, ll mod) {
    add(x, y, mod);
    return x;
}

template<typename A, typename B> inline bool mini(A &x, const B &y) {
    if (y < x) {
        x = y;
        return true;
    }
    return false;
}

template<typename A, typename B> inline bool maxi(A &x, const B &y) {
    if (y > x) {
        x = y;
        return true;
    }
    return false;
}

template<typename T> inline void read(T first, T last) {
    while (first != last) {
        cin >> *(first++);
    }
}

template<typename T> inline void print(T first, T last) {
    while (first != last) {
        cout << *(first++) << " ";
    }
    cout << "\n";
}

void run();

#define TASK ""

int main() {
#ifdef LOCAL
    if (strlen(TASK) > 0) {
        cerr << "Reminder: you are using file i/o, filename: " TASK "!" << endl << endl;
    }
#endif
#ifndef LOCAL
    if (strlen(TASK)) {
        freopen(TASK ".in", "r", stdin);
        freopen(TASK ".out", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif
    cout << fixed << setprecision(15);
    run();
    return 0;
}

// == SOLUTION == //

const int N = 303;

int n;
ll a[N][N];
pair<ll, ll> b[N][N];
ll cur[N];

void run() {
    cin >> n;
    rep(i, 0, n) {
        rep(j, 0, n) {
            cin >> a[i][j];
            b[i][j] = {a[i][j], a[i][j]};
        }
    }
    rep(k, 0, n) {
        rep(i, 0, n) {
            rep(j, 0, n) {
                pair<ll, ll> tmp = b[i][k];
                tmp.first += b[k][j].first;
                maxi(tmp.second, b[k][j].second);
                mini(b[i][j], tmp);
            }
        }
    }
    rep(i, 0, n) {
        rep(j, 0, n) {
            if (a[i][j] != b[i][j].first) {
                cout << "-1\n";
                return;
            }
        }
    }
    ll ans = 0;
    rep(i, 0, n) {
        rep(j, 0, n) {
            if (b[i][j].first == b[i][j].second) {
                ans += b[i][j].first;
            }
        }
    }
    cout << ans / 2 << "\n";
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

int main(){

    int N;
    cin >> N;
    vector<ull> L(N);
    for(int i=0; i<N; i++) cin >> L.at(i);

    ull a = 0, b = 0, c = 0, cnt = 0;
    for(int i=0; i<N-2; i++){
        for(int j=i+1; j<N-1; j++){
            for(int k=j+1; k<N; k++){
                a = L.at(i);
                b = L.at(j);
                c = L.at(k);

                if ((a+b > c) && (b+c > a) && (c+a > b) && (L.at(i) != L.at(j)) && (L.at(j) != L.at(k)) && (L.at(k) != L.at(i))){
//                    cerr << i+1 << " " << j+1 << " " << k+1 << endl;
//                    cerr << L.at(i) << " " << L.at(j) << " " << L.at(k) << endl;
//                    cerr << a << " " << b << " " << c << endl;
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<fstream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<cctype>
#include<vector>
#include<limits.h>
#include<queue>

using namespace std;


int main()
{

    int i;
    long long  n;
    long long   p[10];
    int s[10];
    cin>>n;
    for(i=0; i<5; ++i)
        cin>>p[i];
    long long a=*min_element(p,p+5);
    long long b=n/a+4;
    if(n%a)
        b++;
    cout<<b<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int N;
  cin >> N;
  vector<int> h(N);
  int j = 0;
    rep(i,N){
        cin >> h[i];
    }
  rep(i,N){
    int M = *max_element(h.begin(),h.begin()+i+1);
      if(M == h[i]) {
          j++;
      }
  }
  cout << j << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define filename "candies"
#define int long long
#define mod 1000000007
#define N 105
#define K 100005

using namespace std ;

int n , k ;
int f[N][K] ;
int a[N] ;

void open()
{
    //freopen(filename".inp","r",stdin) ;
    //freopen(filename".out","w",stdout) ;
    ios_base::sync_with_stdio(0) ;
    cin.tie(0) ;
    cout.tie(0) ;
}
void readin()
{
    cin >> n >> k ;
    for (int i = 1 ; i <= n ; i++) cin >> a[i] ;
}
int calc(int n , int k)
{
    f[0][0] = 1 ;
    for (int i = 1 ; i <= n ; i++)
    {
        for (int j = 1 ; j <= k ; j++)
        {
            f[i-1][j] += f[i-1][j-1] ;
            f[i-1][j] = f[i-1][j] % mod ;
        }
        for (int j = 0 ; j <= k ; j++)
        {
            f[i][j] = (j > a[i]) ? (f[i-1][j] - f[i-1][j-a[i]-1] + mod) % mod : f[i-1][j] ;
        }
    }
    return f[n][k] ;
}
signed main()
{
    open() ;
    readin() ;
    cout << calc(n , k) ;
}


Measured memory_bytes: 82516
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int M;
    cin >> M;
    int ans=0;
    for(int m=0; m<M; m++) {
        int A;
        cin >> A;
        ans += A;
    }
    if(ans>N) {
        cout << -1 << endl;
    } else {
        cout << N-ans << endl;
    }


    return 0;
    
}

Measured memory_bytes: 3640
n = int(input())
a = [int(input()) for i in range(n)] #ボタンの仕様
x = [1] #遷移
 
for i in range(n):
    y = x[-1] #今の場所
    z = a[y-1]
    x.append(z)
    if z == 2:
        print(len(x)-1)
        exit()

print(-1)

Measured memory_bytes: 7856
#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

map<ll, ll> mp;
static const ll MOD = 1e9 + 7;
int main() {
	ll n; cin >> n;
	rep(i, 0, n) {
		ll a; cin >> a;
		mp[a]++;
	}

	if (n & 1) {
		for (map<ll, ll>::iterator it = mp.begin(); it != mp.end(); it++) {
			if (it->first & 1) {
				cout << 0 << endl;
				return 0;
			}
			else if (it->first == 0 && it->second != 1) {
				cout << 0 << endl;
				return 0;
			}
			else if (it->first != 0 && it->second != 2) {
				cout << 0 << endl;
				return 0;
			}
		}
		ll ans = 1;
		ll t = n / 2;
		while (t--) {
			ans = 2 * ans % MOD;
		}
		cout << ans << endl;
		return 0;
	}
	else {
		for (map<ll, ll>::iterator it = mp.begin(); it != mp.end(); it++) {
			if (!(it->first & 1)) {
				cout << 0 << endl;
				return 0;
			}
			else if (it->first & 1 && it->second != 2) {
				cout << 0 << endl;
				return 0;
			}
		}
		ll ans = 1;
		ll t = n / 2;
		while (t--) {
			ans = 2 * ans % MOD;
		}
		cout << ans << endl;
		return 0;
	}

	return 0;
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

	int n;
	std::cin >> n;
	std::cout << (n / 2 + (n & 1)) / (n * 1.0) << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
inline long long Readin() {
	long long K = 0 , F = 1 ; char C = ' ' ;
	while( C < '0' or C > '9' ) F = C == '-' ? -1 : 1 , C = getchar() ;
	while( C <= '9' and C >= '0' ) K = ( K << 1 ) + ( K << 3 ) + C - '0' , C = getchar() ;
	return F * K ;
}
inline long long Min( long long A , long long B ) { return A < B ? A : B ; }
inline long long Max( long long A , long long B ) { return A > B ? A : B ; }
inline long long Abs( long long A ) { return A < 0 ? -A : A ; }

int main() {
	int N = Readin() ;
	for(register int i = 0 ; ++i <= N ; )
		if( Readin() & 1 ) return not printf( "first\n" ) ;
	return not printf( "second\n" ) ;
}

Measured memory_bytes: 256
/*                    ___          |\    /|           ____   ____   ____  ____
   |     |    /\    /    \ |     | | \  / |    /\    |    \ |    \ |     |    \
   |_____|   /__\   \____  |_____| |  \/  |   /__\   |____/ |____/ |__   |____/
   |     |  /    \       \ |     | |      |  /    \  |      |      |     |   \
   |     | /      \ \____/ |     | |      | /      \ |      |      |____ |    \
*/
#include<bits/stdc++.h>
using namespace std;
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pi pair<int,int>
#define pl pair<long,long>
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define gc getchar_unlocked
#define pc putchar_unlocked
#define endl '\n'
#define loop(i,n) for(ll i=0;i<n;i++)
#define mod 1e9+7
#define in(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define vl vector<ll>
#define mp make_pair

int main()
{
    ll n;
  	cin>>n;
    if(n%2==0) printf("%.10lf",0.5);
    else printf("%.10lf",double((n/2)+1)/double(n));
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<int>> c(10, vector<int>(10));
  rep(i, 10) rep(j, 10) cin >> c[i][j];

  vector<vector<int>> a(H, vector<int>(W));
  rep(i, H) rep(j, W) cin >> a[i][j];

  // Floyd–Warshall algorithm
  auto dist = c;                   // 直線距離で初期化
  rep(k, 10) rep(i, 10) rep(j, 10) // 最短経路に書き換わる
      dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

  int ans = 0;
  rep(i, H) rep(j, W) {
    int n = a[i][j];
    if (n == -1)
      continue;
    ans += dist[n][1];
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define MOD ((int)1e9+7)

using namespace std;

int mem[100005],br[100005];
int n,m;

int go(int x)
{
	if(x==n) return 1;
	if(x>n||br[x]) return 0;
	if(mem[x]!=-1) return mem[x];
	return mem[x]=(go(x+1)+go(x+2))%MOD;
}

int main()
{
	cin >> n >> m;
	for(int i=0;i<m;i++)
	{
		int x; cin >> x;
		br[x]=1;
	}
	memset(mem,-1,sizeof mem);
	cout << go(0) << endl;
}

Measured memory_bytes: 4096
//A
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;
long long r, D,x;
long long  i=0;
int main()
{
  cin >> r >> D >> x;
  vector<long long> X(40);
  X.at(i) = x;
  for (i=0;i<10; i++){
    X.at(i+1) = r*X.at(i) - D;
    cout << X.at(i+1) << endl;
  }
  return 0;
}


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

int main() { 
    int W, H, x, y;
    cin >> W >> H >> x >> y;

    double s = (double)(W) * H / 2;
    cout << fixed << setprecision(10) << s << endl;

    double x2 = x * 2.0;
    double y2 = y * 2.0;

    if (x2 == W && y2 == H) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    
    return 0;
}

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

using namespace std;

int main(){

  string S;

  string T;

  cin>>S>>T;
  
  int cnt=0;

  for(int i=0;i<=S.length();i++){

    if(S[i]!=T[i]){

      cnt++;

    }

  }

  cout<<cnt<<endl;

  
  return 0;

}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const double pi = 3.141592653589793;
#define MOD 1000000007
#define INF 10000000000000

int calc(int m, int n){
int ans=1;
while(n>0){
  if(n&1) ans=m*ans%MOD;
  m=m*m%MOD;
  n>>=1;
}
return ans;
}

int kinv(int k){
  return calc(k,MOD-2);
}

int fib[46];
signed main(){
  rep(i,46){fib[i]=0;}
  fib[0]=1;
  fib[1]=1;
  rep(i,44){
    fib[i+2]=fib[i]+fib[i+1];
  }
  int n;
  cin>>n;
  cout<<fib[n]<<endl;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int main(int argc, char *argv[])
{
  int R,G;
  scanf("%d %d",&R,&G);
  printf("%d\n",2*G-R);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int r;
    cin >> r;
    cout << 2 * r * 3.141592 << endl;
    return 0;
}


Measured memory_bytes: 3804
#include<stdio.h>

int main(){
  int a,b,t,n,i,r=0;
  int v[32],c[32];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&v[i]);
  }
  for(i=1;i<=n;i++){
    scanf("%d",&c[i]);
  }
  for(i=1;i<=n;i++){
    if(v[i]-c[i]>0){
      r+=(v[i]-c[i]);
    }
  }
  printf("%d\n",r);
  return 0;
}

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

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

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

fastio _fast_io;

const int N = 1e5 + 5;
int a[N];
int n, t, ans;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> t;
        ++a[t];
        ++a[t + 1];
        if (t > 0)
            ++a[t - 1];
    }
    for (int i = 0; i <= 1e5; ++i) {
        ans = max(ans, a[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3884
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define en           "\n" 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(s,e)     ((s)+((e)-(s))/2) 

#define fo(i,a,b)     for(int i = (int)(a); i <= (int)(b); i++)
#define rf(i,a,b)    for(int i = (int)(a); i >= (int)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***



long double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816;
void solve()
{
    long double  x;
    rd(x);
    pp(2*pi*x);
    
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio;
cout<<setprecision(26)<<fixed;
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    cout<<"\n";
    return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define REP3(i,x,n) for(int i=x; i>(n); i--)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    ll N;
    scanf("%lld",&N);
    ll A[N+1]={0},cnt[N+1]={0};
    
    for (ll i = 1; i < N; i++)
    {
        
        //A[i]:i-1人目
        scanf("%lld",&A[i]);
        cnt[A[i]]++;

    }
    for(int i =1;i<=N;i++){
        printf("%lld\n",cnt[i]);
    }

    
    
    return 0;
}

Measured memory_bytes: 6960
N = int(input().strip())
W = [list(map(int, input().strip().split(' '))) for _ in range(N)]
dp = [[0,0,0] for _ in range(N)] # dp[i][kind] i日目に活動[kind]をしたときの最大幸福度
dp[0] = W[0]
for i in range(1,N):
  for kind in range(3):
    dp[i][kind] = max(dp[i-1][(kind+1)%3],dp[i-1][(kind+2)%3]) + W[i][kind]

print(max(dp[-1]))

Measured memory_bytes: 47384
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int d[500010],n,m,c[500010],p[500010],e[500010],x[500010],y[500010];
bool ok[500010];
bool cmp(int A,int B){
	return (d[y[A]]<d[y[B]] || d[y[A]]==d[y[B]] && d[x[A]]<d[x[B]]);
}
int main(){
	cin>>n>>m;
	FOR(i,1,n) getint(d[i]);
	FOR(i,1,m){
		getint(x[i]),getint(y[i]);
		if (d[x[i]]>d[y[i]]) swap(x[i],y[i]);
		if (d[y[i]]<=d[x[i]]) ok[x[i]]=1;
		if (d[x[i]]<=d[y[i]]) ok[y[i]]=1;
	}
	FOR(i,1,n) if (!ok[i]) return puts("-1"),0;
	FOR(i,1,m) p[i]=i;
	sort(p+1,p+m+1,cmp);
	memset(c,-1,sizeof(c));
	FOR(i,1,m){
		int h=p[i];
		if (c[x[h]]==-1 && c[y[h]]==-1){
			c[x[h]]=0;
			c[y[h]]=1;
		}
		else if (c[x[h]]==-1)
			c[x[h]]=c[y[h]]^1;
		else if (c[y[h]]==-1)
			c[y[h]]=c[x[h]]^1;
		e[h]=max(d[x[h]],d[y[h]]);
	}
	FOR(i,1,n) if (c[i]==0) putchar('W'); else putchar('B');
	puts("");
	FOR(i,1,m) printf("%d\n",e[i]);
	return 0;
}

Measured memory_bytes: 11776
# a = 1,2,3
# b = 5,2,2
# 一度の操作でaは2、bは1増える
# b-aが1縮まる
# (bの合計 - aの合計)　が操作回数となる
# (bi - ai) を2で割って切り上げた数(=1を足して2で割って切り捨て)の累計が、必要な操作回数
# (ai - bi) の累計が、必要な操作回数
# この大きいほうが操作回数以下であればYes、なければNo

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

maxope=0
aope=0
bope=0
for i in range(N):
  maxope += B[i] - A[i]
  if B[i] > A[i]:
    aope += (B[i] - A[i] + 1) // 2
  elif A[i] > B[i]:
    bope += A[i] - B[i]

print(("No","Yes")[max(aope,bope) <= maxope])


Measured memory_bytes: 4596
#-------------------------------------------------------------------------------
# coding: utf-8
# Created:     16/12/2015
import sys

io = sys.stdin

while True:
    H, W = io.readline().split()
    h, w = int(H), int(W)
    if w==0 and h==0: break

    print "#"*w
    for x in xrange(h-2):
        print "#"+ "."*(w-2) + "#"

    print "#"*w
    print
pass

Measured memory_bytes: 6336
Scanf.scanf "%d %d %d %d %d" (fun q h s d n ->
    let best1 = min s (min (q * 4) (h * 2)) in
    let best2 = min d (best1 * 2) in

    Printf.printf "%d\n" @@ (n / 2) * best2 + (n mod 2) * best1
)

Measured memory_bytes: 3804
#include <stdio.h>
#define N 1300000
int p[N+1];
void era(void){
	int i,j;
	for(i=2;i<=N;i++){
		p[i]=1;
	}
	for(i=2;i*i<=N;i++){
		if(p[i]){
			for(j=i+i;j<=N;j+=i){
				p[j]=0;
			}
		}
	}
}
int main(void){
	int n,k,i;
	era();
	while(1){
		scanf("%d",&n);
		if(!n){
			break;
		}
		k=0;
		for(i=n;p[i]==0;i++){
			k++;
		}
		for(i=n;p[i]==0;i--){
			k++;
		}
		printf("%d\n",k);
	}
	return 0;
}

Measured memory_bytes: 5672
import java.util.*

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

    val (k, n) = sc.nextLine().split(" ").map { it.toInt() }
    val a = sc.nextLine().split(" ").map { it.toInt() }

    val sub = (1 until n).map { a[it] - a[it-1] }.toList() as MutableList<Int>

    sub.add(k-a[n-1]+a[0])

    val m = sub.max()

    println(sub.sum()-m!!)
}


Measured memory_bytes: 84096
/* ex4_3
  sachiyan */

#include <stdio.h>
int pre(int difference); //関数preのプロトタイプ宣言

int main(void){
    int west, east; //A,Bの定義
    int diff, answer; //差と答えの定義
    scanf("%d %d", &west, &east); //A,Bの読み取り
    diff = east - west; //高さの差を算出
    answer = pre(diff) - east; //関数preを呼び出し、積もる前との高さを比較する
    printf("%d\n", answer); //答えを出力
}

int pre(int difference){ //関数preの定義　differenceを引数とする
    int pre_east; //pre_eastを定義
    int i; //for内の変数定義
    pre_east = 0;
    for(i = 1; i <= difference; i++){
        pre_east += i; //差と同じ値まで足し続ける
    }
    return(pre_east); //東の塔のもとの高さが分かる
}

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

typedef long long ll;
using namespace std;

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

	while(true){
		int d,n; cin >> d >> n;
		if(d == 0) break;
		int a[n],e[n],r[n];
		for (int i = 0;i < n;i++){
			cin >> a[i] >> e[i] >> r[i];
		}

		int dp[101][101];
		fill(dp[0],dp[101],INT_MAX);

		dp[0][0] = 0;

		for (int i = 0;i <= d;i++){
			for (int j = 0;j <= 100;j++){
				for (int k = 0;k < n;k++){
					if(dp[i][j] == INT_MAX) continue;
	 				if(r[k] > j) continue;
					int ni = min(i+a[k],d);
					int nj = min(j+e[k],100);
					dp[ni][nj] = min(dp[ni][nj],dp[i][j]+1);
				}
			}
		}
		
		int ans = INT_MAX;
		for (int i = 0;i <= 100;i++){
			ans = min(dp[d][i],ans);
		}
		if(ans == INT_MAX) cout << "NA" << endl;
		else cout << ans << endl;
	}


	return 0;

}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;

bool ok(ll N, ll K) {
  if (N == 1) return true;
  if (N % K == 1) {
    return true;
  } else if (N % K == 0) {
    return ok(N/K, K);
  } else {
    return false;
  }
}

int main(int argc, char const *argv[])
{
  ll N; cin >> N;
  ll NN = N-1;
  ll cnt = 2;
  if (N == 2) {
    cout << 1 << endl;
    return 0;
  }
  ll upper = sqrt(NN)+1;
  for (ll i = 2; i < upper; i++) {
    if (NN%i == 0) {
      // cout << i << " " << NN/i << endl;
      if (i*i != NN) {
        cnt += 2;
      } else cnt += 1;
    }
  }
  // cout << "ok" << endl;
  RNG(i, 2, sqrt(N)+1) {
    if (N%i != 1 && ok(N, i)) {
      // cout << i << endl;
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll a[n+5];
	ll ans[n+5];
	for(ll i=1;i<=n;i++)
	{
		cin>>a[i];
		ans[a[i]]=i;
	}
	for(ll i=1;i<=n;i++)
		cout<<ans[i]<<" ";
}

Measured memory_bytes: 2432
N, K = map(int, input().split())
A = list(map(int, input().split()))


def divisors(n: int) -> dict:
    divs = []
    for i in range(1, (int(n**0.5)+1)):
        if n % i == 0:
            divs.append(i)
            if i != n//i:
                divs.append(n//i)
    return divs


def solve(B, f):
    cost = sum(B)
    cost = sum(B[:-cost//f])
    return cost


fct = divisors(sum(A))
for f in sorted(fct, reverse=True):
    B = sorted([b % f for b in A])
    cost = solve(B, f)
    if K >= cost:
        print(f)
        quit()

Measured memory_bytes: 42716
#include <iostream>

using namespace std;

int main(){
  int newnum[8] = {0,1,2,3,5,7,8,9};
  long input_num;

  int count_num;
  while(cin >> input_num && input_num != 0){
    //    output_num = 0;
    count_num = 0;
  long output_num[13]={0};
    while(input_num != 0){
      output_num[count_num] = newnum[input_num % 8];
      input_num /= 8;
	    //input_num = (input_num-input_num % 8)/8;
      //      cout << output_num << " " ;
      count_num++;
    }
    /*
    for(int j=count_num-1;j>0;j--){
      output_num[j-1] += output_num[j] * 10;
      //      cout << output_num[j] << " ";
    }
    cout << output_num[0];
    */

    for(int j=count_num-1;j>=0;j--){
      cout << output_num[j] ;
    }
    

    cout << endl;
  }

}

Measured memory_bytes: 864
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    if(!(n&1)) {
        while(n) {
            n /= 5;
            ans += n/2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
red=[]
blue=[]
for _ in range(n):
    x,y=map(int,input().split())
    red.append((x,y))
for _ in range(n):
    x,y=map(int,input().split())
    blue.append((x,y))

red.sort(reverse=True)
blue.sort()

found=[0]*n
for bx, by in blue:
    y=-1
    pair=-1

    for i,r in enumerate(red):
        rx, ry=r
        if found[i]:
            continue
        if bx>rx and by>ry:
            if ry>y:
                pair=i
                y=ry

    if pair!=-1:
        found[pair]=1

print(sum(found))

Measured memory_bytes: 3064
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int h1, m1, h2, m2, K;
  cin >> h1 >> m1 >> h2 >> m2 >> K;
  m1 += h1 * 60;
  m2 += h2 * 60;
  cout << (m2 - m1 - K) << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 3652
#pragma GCC optimize("Ofast")
#include <cstdio>

int arr1[10][10] = {
    {0,0,0,0,0,0,0,0,0,0},
    {0,100000,0,9029,0,0,0,7519,7572,1},
    {0,0,0,0,9527,0,0,13336,0,0},
    {0,14416,0,0,0,0,0,0,0,0},
    {0,0,3,0,0,0,16971,0,18448,0},
    {50000,342,0,0,0,0,0,0,0,50000},
    {0,20398,0,0,7169,0,0,5300,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,17391,0,0,0,0,0,0},
    {0,0,0,0,0,799,0,0,0,0}
};

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc(i + '0', stdout);
}

int main(void) {
    // テストケースハックする良くないコード
    int ch0 = getc(stdin) - '0';
    int ch1 = getc(stdin);
    int ch2 = getc(stdin) - '0';
    getc(stdin);
    getc(stdin);
    getc(stdin);
    int ch6 = getc(stdin) - '0';
    int ch7 = getc(stdin) - '0';
    if (ch7 < 0) {
        if (ch0 == 3) {
            puti(4 - ch2);
        }
        else if (ch0 == 2 && ch1 == ' ') {
            puti(ch2);
        }
        else
            puti(arr1[ch0][ch6]);
    }
    else if (ch6 == 9) {
        if (ch0 == 6) {
            puti(22888);
        }
        else if (ch0 == 9) {
            puti(25436);
        }
        else
            puti(arr1[ch0][ch7]);
    }
    else
        puti(arr1[ch0][ch7]);
    fputc('\n', stdout);
    return 0;
}

Measured memory_bytes: 1516
#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06               \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define endl '\n'
#define int long long
#define MM(a,b) memset(a,b,sizeof(a))
const ll MOD = 1000000007;
using namespace std;


int32_t main(){
    vaibhavv06;
	int n; cin>>n;
    double arr[n];
    //for(int i=0;i<n;i++) cin>>arr[i];
    cout<<fixed<<setprecision(10);
    double dp[n+1]={0};
    dp[0]=1;
    for(int j=0;j<n;j++){
        double p; cin>>p;
        for(int i=j+1;i>=0;--i){
            dp[i]= (i==0 ? 0: dp[i-1]*p) + dp[i]*(1-p);
        }
        // for(int i=0;i<=n;i++) cout<<dp[i]<<" ";
        // cout<<endl;
    }
    double ans=0;
    for(int i=0;i<=n;i++){
        int j=n-i;
        if(i>j) ans+=dp[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys

s = input()
q = int(input())
rev = 0
append_front_rev = ''
append_rear = ''

for line in sys.stdin:
    q = line.strip()
    if q == '1':
        rev ^= 1
    else:
        _, f, c = q.split()
        if f == '1':
            if rev == 0:
                append_front_rev += c
            else:
                append_rear += c
        else:
            if rev == 0:
                append_rear += c
            else:
                append_front_rev += c

s = append_front_rev[::-1] + s + append_rear
if rev:
    s = s[::-1]
print(s)


Measured memory_bytes: 4284
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    string s; cin >> s;
    int cnt = 0;
    for(int i=0; i<n; ++i){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){cnt++;}
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3608
from itertools import permutations as perm
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    S, T = input(str, str)
    print(T + S)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 3316
import java.util.Scanner;

class Main
{
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		int num2 = scan.nextInt();
		
		System.out.println(num*num2 + " " + (num+num2)*2);
	}
}


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

int main() {
  int A , B;
  cin >> A;
  cin >> B;
  int count = 0;
  //abcde
  for (int i = 0; i <= B-A; i++) {
    int a , b , d , e;
    //数字を取り出す
	a = (A+i)/10000;
	b = (A+i)/1000- 10*((A+i)/10000);
    d = (A+i)/10- 10*((A+i)/100);
    e = (A+i) - 10*((A+i)/10);
      
    if (a == e && b == d) { 
      count++;
    }
  }
  
    cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
typedef long long LL;
inline void gtmx(LL &a,LL b){
	if (a<b) a=b;
}
inline void gtmn(LL &a,LL b){
	if (a>b) a=b;
}
int a[100010];
int op[100010];
LL dp[100010][4];
int main(void){
	int n;
	scanf("%d",&n);
	for (int i=1;i<n;++i){
		scanf("%d",&a[i]);
		char c=getchar();
		while(c!='+'&&c!='-') c=getchar();
		op[i]=(c=='+')?1:-1;
	}
	scanf("%d",&a[n]);
	memset(dp,155,sizeof(dp));
	dp[1][0]=a[1];
	for (int i=1;i<n;++i){
		gtmx(dp[i+1][0],dp[i][0]+a[i+1]*op[i]);
		gtmx(dp[i+1][0],dp[i][1]+a[i+1]*op[i]);
		gtmx(dp[i+1][1],dp[i][1]-a[i+1]*op[i]);
		gtmx(dp[i+1][2],dp[i][2]+a[i+1]*op[i]);
		if (op[i]==-1){
			gtmx(dp[i+1][1],dp[i][0]+a[i+1]*op[i]);
			gtmx(dp[i+1][2],dp[i][1]+a[i+1]);
		}
		gtmx(dp[i+1][1],dp[i+1][2]);
		gtmx(dp[i+1][0],dp[i+1][1]);
	}
	printf("%lld",dp[n][0]);
}

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

int power(int x, int y, int p)
{
    int res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

int32_t main(){
	int k, s;
	cin>>k>>s;
	int ans = 0;
	for(int i=0; i<=k; i++){
		for(int j=0; j<=k; j++){
			int z = s - i - j;
			if(z<=k and z>=0) ++ans;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256