akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

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

    if(X >= 30)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

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

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

    int ans = 0;
    for (int i = 0; i < s.size(); ++i)
        ans += s[i] != t[i];

    cout << ans;
}

Measured memory_bytes: 3772
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) (*find_by_order(i))
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
#define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/


void solve(){
    int n, c = 0, ans = 0;
    cin >> n;
    vl v(n+1), b(n+2, 0);
    for(auto &i : v)cin >> i;
    b[0] = 1;
    rep(i, 0, n+1){
        if(v[i] > b[i]){cout << -1; return;}
        else b[i+1] = min((b[i] - v[i])*2, (ll)1e13);
    }
    ans = v[n], c = ans;
    repc(i, n-1, -1, -1){
        c = min(c + v[i], b[i]);
        ans += c;
    }
    cout << ans;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 4784
# coding: utf-8
import time
import re
import math
import fractions

def main():
    N,A,B=map(int,input().split())
    count=0
    for a in range(1,N+1):
        s=str(a)
        total=0
        for b in s:
            total+=int(b)
        if A<=total and total<=B:
            count+=a
    print(count)
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#"YNeos"[True::2]
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
# global n,A,s,memo,mx,mn,L,B



Measured memory_bytes: 5044
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	string s;
	cin >> s;
	string yaki = "YAKI";

	if (s.substr(0, 4) == yaki) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc071.contest.atcoder.jp/tasks/arc071_a>
問題文============================================================
 すぬけ君は、文字列の書かれた紙から文字をいくつか切り抜いて、並び替えて別の文字列を作るのが好きです。
 
 明日になると、すぬけ君は文字列 S1,…,Sn のうちどれか 1 つが書かれた紙がもらえます。
 すぬけ君は文字列を作る事をとても楽しみにしているので、どんな文字列を作るか計画を立てることにしました。
 ただし、すぬけ君はまだどの文字列が書かれた紙がもらえるかを知らないため、
 どの文字列が書かれていた場合にも作れる文字列を考えることにしました。
 
 S1,…,Sn のどの文字列が書かれていても作れる文字列のうち、最長のものを求めてください。
 最長のものが複数ある場合は、辞書順で最小のものを求めてください。

=================================================================

解説=============================================================

 全ての文字で各単語がいくつ現れるかを確認する。
 答えの文字列に含まれる各単語の個数は、あらかじめ確認した個数の一番少ないものである。
 
 答えはa-zへ順番に作っていけば最小となるのは明らか
 
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<string> S(n);
    for(auto &in:S) cin >> in;
    vector<vector<int>> alpha(n,vector<int>(26,0));
    for(int x = 0; x < n;x++){
        string & s = S[x];
        for(int i = 0; i < (int)s.length();i++){
            alpha[x][s[i]-'a']++;
        }
    }
    string ans ="";
    for(int i = 0; i < 26;i++){
        int minv = INF;
        for(int j = 0; j < n;j++){
            minv = min(minv,alpha[j][i]);
        }
        ans += string(minv,'a'+i);
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main()
{
  let n=read::<i32>();
  let mut s=0;
  let mut m=0;
  for _ in 0..n{
    let x=read::<i32>();
    s+=x;
    if m<x{m=x}
  }
  println!("{}",s-m/2);
}

Measured memory_bytes: 4352
import math

def main():
    side,high,volume = list(map(int,input().split()))

    fullvolume = side * side * high
    space = fullvolume - volume

    if space < volume:
        prizm_high = space / (side * side / 2)
        angle = math.degrees(math.atan(prizm_high/side))
    else:
        prizm_high = volume / (high * side / 2)
        angle = 90 - math.degrees(math.atan(prizm_high/high))


    print(angle)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define oo int(1e9)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long ll;
const ll INF = (ll)(1e18);
int n, m;
vector<vector<int>> g;
vector<int> dp;

int dfs(int u){
    if (dp[u] != -1) return dp[u];
    int ans = 0;
    for (int v: g[u])
        ans = max(ans, dfs(v) + 1);
    return dp[u] = ans;    
}

int main() {
	cin.tie(0); ios::sync_with_stdio(0); cout.tie(0);
	cin >> n >> m;
	g.resize(n);
	for (int i = 0; i < m; i++){
	    int u,v ;
	    cin >> u >> v;
	    u--; v--;
	    g[u].push_back(v);
	    //g[v].push_back(u);
	}
	int ans = 0;
	dp.resize(n);
	fill(all(dp),-1);
	for (int u = 0; u < n; u++)
	    ans = max(ans,dfs(u));
	cout << ans;    
	return 0;
}

Measured memory_bytes: 8192
import sys

s = input()

if s[0] != "A":
    print("WA")
    sys.exit(0)

if s[1] < "a" or s[1] > "z":
    print("WA")
    sys.exit(0)


sub = s[2:-1]
has = False
for c in sub:
    if not has and c == "C":
        has = True

    elif "a" <= c <= "z":
        continue

    else:
        has = False
        break

if not has:
    print("WA")
    sys.exit(0)

if "a" <= s[-1] <= "z":
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3064
def main():
    kstring = input()

    elim_len = len(kstring) - 7

    for i in range(len(kstring) - elim_len + 1):
        cand_str = kstring[:i] + kstring[i+elim_len:]
        #print(cand_str)
        if cand_str == 'keyence':
            print('YES')
            return
    print('NO')
    return

main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

 
    int n;
    cin>>n;

    if(n == 3 || n == 5 || n == 7)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;

int main(){

    string S; 
    cin >> S;

    if (S == "ABC"){
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" << endl;
    }

}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
using P =  pair<int, int>;
using T = tuple<int, int ,int>;
const int INF = -1;
const int MAX = 1001;

vector<vector<int>> field(MAX, vector<int>(MAX, INF));    
// vector<vector<int>> dist(MAX, vector<int>(MAX, INF));
//fieldは黒点からの距離にする

int h,w;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
queue<P> que;

int bfs(){
    while(!que.empty()){
        P pos = que.front();
        que.pop();
        rep(i,4){
            int nx = pos.first + dx[i];
            int ny = pos.second + dy[i];
            if(0 <= nx && nx < h && 0 <= ny && ny < w && field[nx][ny] == INF){
                que.push(P(nx, ny));
                field[nx][ny] = field[pos.first][pos.second] + 1;
            }
        }
    }

    // cout << endl;
    // rep(i,h){
    //     // rep(j,w) printf("%d ", field[i][j]);
    //     rep(j,w) cout << field[i][j] << " ";
    //     cout << endl;
    // }
    // cout << endl;

    int res = 0;;
    rep(i,h) rep(j,w){
        if(res < field[i][j]){
            res = field[i][j];
            // cout << res << endl;
        }
    }
    return res;
}

int main(){
    cin >> h >> w;
    rep(i,h) rep(j,w){
        char a; cin >> a;
        if(a == '#'){
            field[i][j] = 0;
            que.push(P(i,j));
        }
    }
    int res = bfs();
    cout << res << endl;

    return 0;
}

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

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	if (c <= a + b + 1) cout << c + b << endl;
	else if (c > a + b + 1)cout << a + b + 1 + b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> p;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9



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

	int dif[n];
	for (int i = 0; i < n; i++) {
		if (a[i] == b[i]) {
			if (a[i] == c[i]) {
				dif[i] = 0;
			}
			else dif[i] = 1;
		}
		else if (b[i] == c[i] || a[i] == c[i]) dif[i] = 1;
		else dif[i] = 2;
	}
	
	int ans = 0;
	for (int i = 0; i < n; i++) ans += dif[i];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		Integer[] l = new Integer[n];
		for (int i = 0; i < l.length; i++) {
			l[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(l, Comparator.reverseOrder());
		int sum = 0;
		for (int i = 1; i < l.length; i++) {
			sum += l[i];
		}
		if (l[0] < sum) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
	int N;
	cin >> N;
	vector<ll> A(N),S(N+1);
	for(int i=0;i<N;i++){
		cin >> A[i];
		S[i+1] = S[i]+A[i];
	}
	ll ans = 1e18;
	auto sum = [&](int l,int r){
		return S[r]-S[l];
	};
	int l = 1,r = 3;
	for(int i=1;i<N;i++){
		while(true){
			ll s1 = abs(sum(l,0)-sum(i,l));
			ll s2 = abs(sum(l+1,0)-sum(i,l+1));
			if(s1>s2) l++;
			else break;
		}
		while(true){
			ll s1 = abs(sum(N,r)-sum(r,i));
			ll s2 = abs(sum(N,r+1)-sum(r+1,i));
			if(s1>s2) r++;
			else break;
		}
		ll ma = max({sum(l,0),sum(i,l),sum(r,i),sum(N,r)});
		ll mi = min({sum(l,0),sum(i,l),sum(r,i),sum(N,r)});
		ans = min(ans,ma-mi);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n;
    string s;
    cin>>n>>s;
    for(int i=0;i<s.size();i++){
        s[i]=s[i]+n;
        if(s[i]>'Z'){
            s[i]='A'+s[i]-'Z'-1;
        }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int tmp=b-a;
  int ans=0;
  for(int i=1;i<=tmp;i++){
    ans+=i;
  }
 // cout<<ans<<endl;
  cout<<ans-b<<endl;
}

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


bool check(string a,string b,int d){
  if(a.size()<b.size())swap(a,b);
  if(a==b) return 1;
  if(d==0)return 0;


  //erase
  for(int i=0;i<a.size();i++){
    string t = a;
    t.erase(t.begin()+i);
    if(check(t,b,d-1))return 1;
  }

  if(a.size()!=b.size()) return 0;

  //swap
  for(int i=0;i<(int)a.size()-1;i++){
    if(a[i]==a[i+1]||a[i+1]!=b[i])continue;
    swap(a[i],a[i+1]);
    if(check(a,b,d-1))return 1;
    swap(a[i],a[i+1]);
  }
  
  //change
  int cnt=0;
  for(int i=0;i<a.size();i++) cnt+=a[i]!=b[i];
  return cnt<=d;
}

int main(){
  int n,d;
  while(cin>>n,n){
    cin>>d;
    string str[201];
    for(int i=0;i<n;i++)cin>>str[i];
    sort(str,str+n);

    int cnt=0;    
    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++)
	if(check(str[i],str[j],d)) cout<<str[i]<<","<<str[j]<<endl,cnt++;
    cout<<cnt<<endl;
  }
  return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int a, b, c;cin >> a >> b >> c;
    string ans = "No";
    if(a <= c && c <= b) ans = "Yes";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    const int C = 2 * n + 1;
    const int ZERO = n;
    vector<double> pre(C), dp(C);
    dp[ZERO] = 1;
    for (int i = 0; i < n; ++i) {
        swap(pre, dp);
        double p;
        cin >> p;
        for (int j = 0; j < C; ++j)
            dp[j] = (j ? pre[j - 1] * p : 0) + (j + 1 < C ? pre[j + 1] * (1 - p) : 0);
    }
    cout << fixed << setprecision(16) << accumulate(begin(dp) + ZERO + 1, end(dp), 0.0) << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
long long mod = 1e9+7;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
//////////////////////////////////

int main() {
    string s, t; cin >> s >> t;
    vector<vector<int>> a(26);
    for(int i=0; i<s.size(); i++) {
        a[s[i]-'a'].push_back(i);
    }

    for(int i=0; i<t.size(); i++) {
        if(a[t[i]-'a'].size() == 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    long long ans = 0;
    int pos = 0;
    for(int i=0; i<t.size(); i++) {
        int tmp = t[i]-'a';
        auto itr = lower_bound(all(a[tmp]), pos);
        if (itr == a[tmp].end()) {
            ans += s.size() - pos + a[tmp][0] + 1;
            pos = a[tmp][0] + 1;
        } else {
            ans += *itr - pos + 1;
            pos = *itr + 1;
        }
    }

    cout << ans << endl;

    return 0;
}




// EOF


Measured memory_bytes: 1216
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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



















int main(){
    ll r, g, b, n;
    cin >> r >> g >> b >> n;
    ll ans = 0;
    REP(i, n + 1){
        REP(j, n + 1){
            ll B = n - r * i - g * j;
            if(B >= 0 && B % b == 0){
                ans++;
                // cerr << i << " " << j << " " << ans << endl;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
  int X;
  cin>>X;
  Yes(X>=30);
  return 0;
} 

Measured memory_bytes: 3632
# coding: utf-8
from __future__ import unicode_literals
from __future__ import print_function
import sys
import itertools

def move(x,y):
    xs = "R"*x if x > 0 else "L"*(-x)
    ys = "U"*y if y > 0 else "D"*(-y)
    return (xs, ys)

def main():
    sx, sy, tx, ty = map(int,sys.stdin.read().split())
    x = tx - sx
    y = ty - sy

    xs, ys = move(x,y)
    ans = ys + xs

    xs, ys = move(-x,-y)
    ans += ys + xs

    xs, ys = move(x+1,y+1)
    ans += "L" + ys + xs + "D" 

    xs, ys = move(-(x+1),-(y+1))
    ans += "R" + ys + xs + "U" 

    sys.stdout.write(ans)

if __name__ == '__main__':
    main()  


Measured memory_bytes: 3708
n = int(input())
ai = [int(input()) for i in range(n)]

ans = 0
nokori = 0

for i in range(n):
    if ai[i] % 2 == 1:
        if nokori == 1:
            nokori = 0
            ans += ai[i] // 2 + 1
        else:
            nokori = 1
            ans += ai[i] // 2
    elif ai[i] > 0:
        if nokori == 1:
            ans += ai[i] // 2
            nokori = 1
        else:
            ans += ai[i] // 2
            nokori = 0
    elif ai[i] == 0:
        nokori = 0

print(ans)

Measured memory_bytes: 50648
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int s[]=sc.nextIntArray(n);
        long ans=0;
        for (int i = 1; i <=n ; i++) {
        	int l=0,r=n-1;
        	long a=0;
        	boolean u[] = new boolean[n];
        	u[0]=u[n-1]=true;
			while(true) {
				r-=i;
				l+=i;
				if(l==r || r<=i || u[r] || u[l])break;
				a+=s[r]+s[l];
				u[r]=true;
				u[l]=true;
				ans=max(ans,a);				
			}
		}
        
        out.println(ans);
        out.flush();
    }
    



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

class P implements Comparable<P>{
	int x,w,id,ox;
	P(int id, int x, int w) {
		this.id=id;
		this.x=x;
		this.w=w;
	}

	public int compareTo(P p){
		if(x==p.x) {
			return w-p.w;
		}
		return x-p.x;
	}
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long[] nextLongArray(int size) throws IOException{
    	long r[] = new long[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextLong(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 346032
#include<bits/stdc++.h>
#define int long long
#define REP(i,a,n) for(int i=a;i<(n);i++)
#define REP_sz(i,s) for(int i=0;i<s.size();i++)
#define RE return
#define FILL(a,b) memset(a,b,sizeof(a))
#define SO(a) sort(all(a))
#define pb push_back
#define sz(a) a.size()
#define V vector
#define ld long double
#define viit(a) vector<int>::iterator a
#define msit1(a) map<string,int>::iterator a
#define miit(a) map<int,int>::iterator a
#define msit2(a) map<int,string>::iterator a
#define IT iterator
#define FOR(i,a,n) for(int i=a;i<=(n);i++)
#define B(s) s.back()
#define all(a) a.begin(),a.end()
#define ER1(a) a.erase(a.begin())
#define ER0(a) a.erase(a.end())
#define pii pair<int,int>
#define pause system("PAUSE")
#define cls system("CLS")
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	int n;
	string s;
	cin>>s>>n;
	REP(i,0,n)
	if(s[i]!='1'){
		cout<<s[i];
		return 0;
	}
	cout<<1;
    return 0;
}


Measured memory_bytes: 3628
n, y = gets.chomp.split(" ").map(&:to_i)

for a in 0..n
    for b in 0..n
        next if a + b > n
        if 10000 * a + 5000 * b + 1000 * (n - a - b) == y then
            printf "%d %d %d\n", a, b, n - a - b
            exit
        end
    end
end

puts "-1 -1 -1"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long H;
  cin>>H;
  if(H==1){
    cout<<1;
    return 0;
  }
  int n=0;
  long long count=0;
  while(H>0){
    H=floor(H/2);
    count+=pow(2,n);
    n++;
  }
  cout<<count;
}
      


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
 
void Main() {
  string s;
  cin >> s;
  rep(i,s.size()) {
    if(s[i]=='9') {
      pr("Yes");
      return;
    }
  }
  pr("No");
}
 
int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int n;
	cin >> n;

	vector<tuple<int, int, char, long, string>> a( n );
	for( int i = 0; i < n; ++i ) {
		tuple<int, int, char, long, string> x;
		cin >> get<0>( x )
			>> get<1>( x )
			>> get<2>( x )
			>> get<3>( x )
			>> get<4>( x );
		a[i] = x;
	}

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

	for( int i = 0; i < n; ++i ) {
		cout << get<0>( a[i] ) << ' '
			<< get<1>( a[i] ) << ' '
			<< get<2>( a[i] ) << ' '
			<< get<3>( a[i] ) << ' '
			<< get<4>( a[i] ) << '\n';
	}

	return 0;
}



Measured memory_bytes: 11132
import copy

N, L = map(int, input().split())

apple_taste = [L+i for i in range(N)]

pie_taste = sum(apple_taste)

min_diff = 100000
for i in range(N):
    ap = copy.deepcopy(apple_taste)
    ap[i] = 0

    pie_taste2 = sum(ap)
    diff = abs(pie_taste - pie_taste2)

    if diff < min_diff:
        min_diff = diff
        min_index = i


apple_taste[min_index] = 0

print(sum(apple_taste))

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#include <algorithm>
 
using namespace std;
 
int main(){
int N=0;
int R=0;
int NR=0;  
cin>>N>>R;
  
if(N<10){
NR=100*(10-N)+R;
}
else{
NR=R;
}  
cout<<NR<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

 map<ll,ll> factor(ll n){  //素因数とオーダーをマップで管理
  map <ll,ll> ord ;  
  for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            int res=0;
            while(n%i==0){
                n/=i;
                res++;
            }
            ord[i]=res;
        }
    }
if(n!=1) ord[n]++;
 return ord ;
 }
int main() {
   ll m,n ;cin>>m>>n ;

  auto ord=factor(n) ; 

  ll ans=1 ;
  for(auto p : ord ){
    ans*=pow(p.first,(p.second/m)) ;
  } 
  cout<<ans<<endl ;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void){
  
  vector<string>word(3);
  
  for(int i=0;i<3;i++){
    cin >> word[i];
  }
  
  char s = word[1][0];
  
  cout << "A" << s << "C" << endl;
  
  return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin >>n;
    vector<ll>a(n);
    set<string>s;
    ll free=0;
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        if(a[i]<400)s.insert("h");
        else if(a[i]<800)s.insert("ty");
        else if(a[i]<1200)s.insert("gr");
        else if(a[i]<1600)s.insert("mizu");
        else if(a[i]<2000)s.insert("ao");
        else if(a[i]<2400)s.insert("ki");
        else if(a[i]<2800)s.insert("ore");
        else if(a[i]<3200)s.insert("red");
        else free++;
    }
    ll mint,mx;
    if(s.empty()){
        mint=1;
        mx=free;
    }
    else {
        mint = s.size();
        mx = mint + free;
    }
    cout <<mint<<" "<<mx<<endl;
    return 0;
}

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

const int MAX = 2200000;
const int MOD = 1000000007;
ll fact[MAX], fact_inv[MAX], inv[MAX];
void comb_mod_init() {
  fact[0] = fact[1] = 1;          // 0,1の階乗は1
  fact_inv[0] = fact_inv[1] = 1;  // 1の逆元は1
  inv[1] = 1;                     // 1の逆元は1
  for (int i = 2; i < MAX; i++) {
    fact[i] = fact[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
  }
}
ll comb_mod(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}
ll pow_mod(ll n, ll m) {
  ll ret = 1;
  while (m > 0) {
    if (m & 1) ret = ret * n % MOD;
    n = n * n % MOD;
    m >>= 1;
  }
  return ret;
}

int main() {
  int k;
  string s;
  cin >> k >> s;
  int slen = s.size();
  comb_mod_init();
  ll ans = 0;
  for (int i = 0; i <= k; i++) {
    ll tmp = pow_mod(25, i);
    tmp = tmp * pow_mod(26, k - i) % MOD;
    tmp = tmp * comb_mod(i + slen - 1, i) % MOD;
    ans += tmp;
    ans %= MOD;
  }

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

Measured memory_bytes: 55964
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define vs vector<string>
#define ss second
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define tr1(x)                cout<<#x<<": "<<x<<endl
#define tr2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define tr4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl
#define tr3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define db1(x) cerr << #x << ": " << x <<'\n'
#define db2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define db3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<pair<string,int>, int> &a,const pair<pair<string,int>, int> &b)
{
    if(a.ff.ff == b.ff.ff) {
        return (a.ff.ss > b.ff.ss);
    }
    return (a.ff.ff<b.ff.ff);
}
int min(int a, int b){
    if(a<b){
        return a;
    }
    else{
        return b;
    }
}
int max(int a, int b){
    if(a>b){
        return a;
    }
    else{
        return b;
    }
}
int max(int a, int b, int c){
    return(max( max(a,b), c ));
}
int min(int a, int b, int c){
    return (min ( min(a,b) , c));
}
int poww(int a, int b)
{
    int res = 1;
    for(int i = 1; i<=b; ++i)
        res *= a;
 
    return res;
}
int findlcm(int arr[], int n)
{
    // Initialize result
    int ans = arr[0];
 
    // ans contains LCM of arr[0], ..arr[i]
    // after i'th iteration,
    for (int i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (__gcd(arr[i], ans)));
 
    return ans;
}
bool prime[100001];
void SieveOfEratosthenes(int n)
{
    memset(prime, true, sizeof(prime));
 
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
  }
}
 
//Define mx for maximum range and MOD for large numbers
#define mx 500005
#define mod 1000000007
 
// Declare all the variables and global functions here -
int n;
int a[101] = {0};
int32_t main(){
    IOS;
    int m;
    cin >> n >> m;
    a[0] = 0;
    int cnt = 0;
    rep(i, 1, n+1){
        cin >> a[i];
        a[i] += a[i-1];
        if(a[i] <= m){
            cnt++;
        }
    }
    cout << cnt+1 << endl;
}  

Measured memory_bytes: 256
S=input()
if S == 'hi':
  print('Yes')
elif S == 'hihi':
  print('Yes')
elif S == 'hihihi':
  print('Yes')
elif S == 'hihihihi':
  print('Yes')
elif S == 'hihihihihi':
  print('Yes')
else :
  print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#pragma comment(linker, "/stck:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.1415926535897932384626433832
#define ios() ios::sync_with_stdio(true)
#define inf 0x3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
vector<string>v;
map<string,int>mp;
int main()
{
    int n,m;
    string str;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        cin>>str;
        v.push_back(str);
        mp[str]++;
    }
    scanf("%d",&m);
    for(int i=0;i<m;i++)
    {
        cin>>str;
        mp[str]--;
    }
    int top=0;
    for(int i=0;i<v.size();i++)
    {
        top=max(top,mp[v[i]]);
    }
    printf("%d\n",top);
    return 0;
}

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

int main() {
   int N;
   cin >> N;
   map<string, int> ans;
   for(int i=0;i<N;i++) {
       string s;
       cin >> s;
       ans[s]++;
   }
   for (string s: {"AC", "WA", "TLE", "RE"}) {
       cout << s << " x " << ans[s] << endl;
   }
}

Measured memory_bytes: 3604
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		double w = sc.nextLong();
		double h=sc.nextLong();
		long x = sc.nextLong();
		long y=sc.nextLong();
		System.out.print((w*h)/2+" ");
		if(w/2==x && h/2==y){
			System.out.println(1);
		}else{
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 22740
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var A = cin.ReadInt;
            var B = cin.ReadInt;
            var ans = Min(A * N, B);
            WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 11220
#include<stdio.h>

int main(){
  int i,m,a[10000];
	long long int n;
	scanf("%lld%d",&m,&n);
	
	for(i=0 ; i<n ; i++)
		scanf("%d",&a[i]);
		
	for(i=0 ; i<n ; i++)
		m-=a[i];
	
	
	if(m<0)
		printf("-1\n");
	else
		printf("%d\n",m);
	return 0;
}

								


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

int main(){
  int N,K,P;
  cin >> N;

  for(int i=0; i<N; i++){
    cin >> K >> P;
    if(K%P!=0){
      cout << K%P << endl;
    }else{
      cout << P << endl;
    }
  }
}

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

int main(){
    int n;
    cin>>n;
    int ans=0;
    int hp=0;
    for (int i = 0; i < n; ++i) {
        int t;
        cin>>t;
        ans+=t;
        hp=max(hp,t);
    }
    ans-=hp/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque as dq
input = sys.stdin.readline
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
d = [-1, 0, 1, 0]
vis = [[0] * W for _ in range(H)]
Q = dq([])
res = 0
for i in range(H):
  for j in range(W):
    if vis[i][j] == 1: continue
    Q.append((i, j))
    w = 0
    b = 0
    while len(Q):
      p = Q.popleft()
      if S[p[0]][p[1]] == "#": b += 1
      elif S[p[0]][p[1]] == ".": w += 1
      vis[p[0]][p[1]] = 1
      for way in range(4):
        x = p[1] + d[way]
        y = p[0] + d[-1 - way]
        if 0 <= y < H and (0 <= x < W):
          if S[p[0]][p[1]] == S[y][x]:
            continue
          if vis[y][x] == 1: continue
          Q.append((y, x))
          vis[y][x] = 1
    res += b * w
print(res)

Measured memory_bytes: 55388
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        bool badFlag=true;
        int cnt=0;
        for(int i=0;i<n;i++){
            int a;
            cin>>a;
            if(a>=2)badFlag=false;
            if(a>0)cnt++;
        }
        if(badFlag)cout<<"NA"<<endl;
        else cout<<cnt+1<<endl;

    }
}

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

int main(){
  int N,L;
  cin>>N>>L;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  int Z=0;
  for(int i=1;i<N;i++){
    if(p[i]+p[i-1]>=L){
      Z=i;
      break;
    }
  }
  if(Z){
    cout<<"Possible"<<endl;
    for(int i=1;i<Z;i++){
      cout<<i<<endl;                  
    }
    for(int i=N-1;i>=Z;i--){
      cout<<i<<endl;
    }
  }
  else{
    cout<<"Impossible"<<endl;
  }
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define REP(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  string s;
  cin>>s;
  cout<<s[0]<<s[1]<<s[2]<<endl;
}

Measured memory_bytes: 3596
program C;
var x,y,w,h:longint;
    re:real;
begin
	readln(w,h,x,y);
	re:=w*h/2;
	writeln(re:0:9);
	if (x=(w/2)) and (y=(h/2)) then write(1)
	else write(0);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

const ll inf = 1LL<<60;

ll N, M, p;

// void shortest_path(int s){
//     for(int i=0; i<n; ++i) d[i] = inf;
//     d[s] = 0;

//     int cnt = 0;
//     while(cnt <= m){
//         ++cnt;
//         bool update = false;
//         for(int i=0; i<m; ++i){
//             Edge e = edge[i];
//             if(d[e.from] != inf && d[e.to] > d[e.from]+e.cost){
//                 d[e.to] = d[e.from] + e.cost;
//                 update = true;
//             }
//         }
//         if(!update) break;
//     }
    
// }

// bool find_negative_loop(){
//     for(int i=0; i<n; ++i) d[i] = 0;

//     for(int i=0; i<n; ++i){
//         for(int j=0; j<m; ++j){
//             Edge e = edge[j];
//             if(d[e.to] > d[e.from] + e.cost){
//                 d[e.to] = d[e.from] + e.cost;

//                 if(i == n-1) return true;
//             }
//         }
//     }

//     return false;
// }

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

    cin >> N >> M >> p;
    vector<ll> a(M), b(M), c(M);
    for(int i=0; i<M; ++i){
        cin >> a[i] >> b[i] >> c[i];
        --a[i]; --b[i]; c[i] = -c[i]+p;
    }

    vector<ll> d(N, inf);
 
    d[0] = 0;
    for(int loop=0; loop<N; ++loop){
        for(int i=0; i<M; ++i){
            if(d[a[i]] == inf) continue;
            d[b[i]] = min(d[b[i]], d[a[i]]+c[i]);
        }
    }
 
    ll ans = -d[N-1];
 
    vector<bool> nega(N, false);
 

    for(int loop=0; loop<N+5; loop++){
        for(int i=0; i<M; i++){
            if(d[a[i]] == inf) continue;
            if(d[b[i]] > d[a[i]]+c[i]){
                d[b[i]] = d[a[i]]+c[i];
                nega[b[i]] = true;
            }
 
            if(nega[a[i]]) nega[b[i]] = true;
        }
    }

    if(nega[N-1] == true || d[N-1] == inf){
        cout << -1 << endl;
        return 0;
    }

    cout << max(0LL, ans) << endl;
	
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N,M;
  cin>>N>>M;
  if(abs(N-M)>1){
    cout<<0<<endl;
    return 0;
  }
  long long j=1;
  for(long long i=1;i<=N;i++)
    j=j*i%1000000007;
  for(long long i=1;i<=M;i++)
    j=j*i%1000000007;
  if(N==M)
    cout<<j*2%1000000007<<endl;
  else
    cout<<j<<endl;
}

Measured memory_bytes: 3604
import sys
import heapq

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
mo = 10**9+7

def main():
    N = II()
    A = LI()
    A.sort(reverse=True)
    ans = 0
    hq=[]
    heapq.heapify(hq)
    heapq.heappush(hq,A[0]*-1)
    for i,a in enumerate(A[1:]):
        ans+=heapq.heappop(hq)*-1
        heapq.heappush(hq,a*-1)
        heapq.heappush(hq,a*-1)
    print(ans)

    

if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;

int main()
{
    char s[2000];
    scanf("%s",s);
    int k=strlen(s)/2;
    string s1="",s2="";
    for(int i=0;i<=k-1;i++)  s1.push_back(s[i]);
    for(int i=k+1;i<strlen(s);i++)s2.push_back(s[i]);
    if(s1==s2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i;
    int count =0 ;
    int x=0;
    int y=0;
    int a[6]={0};
    for(i=0;i<6;i++){
        scanf("%d",&a[i]);
    }

    for(i=0;i<6;i++){
        if(a[0]==a[i])
        count++;
    }
    if(count==2){
        x++;
    }else if(count==1){
        y++;
    }
    count =0 ;

    for(i=0;i<6;i++){
        if(a[1]==a[i])
        count++;
    }
    if(count==2){
        x++;
    }else if(count==1){
        y++;
    }
    count =0 ;

    for(i=0;i<6;i++){
        if(a[2]==a[i])
        count++;
    }
    if(count==2){
        x++;
    }else if(count==1){
        y++;
    }

    count =0 ;
    for(i=0;i<6;i++){
        if(a[3]==a[i])
        count++;
    }
    if(count==2){
        x++;
    }else if(count==1){
        y++;
    }
    count =0 ;

    for(i=0;i<6;i++){
        if(a[4]==a[i])
        count++;
    }
    if(count==2){
        x++;
    }else if(count==1){
        y++;
    }
    count =0 ;

    for(i=0;i<6;i++){
        if(a[5]==a[i])
        count++;
    }
    if(count==2){
        x++;
    }else if(count==1){
        y++;
    }

    if(x==4&&y==2){
        printf("YES");
    }else{
        printf("NO");
    }


}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
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);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  string s;cin>>s;
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()-1-i]){
      ans=false;
      break;
    }
  }
  cout<<btos(ans)<<endl;
  return 0;
}


Measured memory_bytes: 256