akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

int divisorsCount(int x)
{
    int ret = 0;
    for (int i = 1; i * i <= x; ++i) {
        if (x % i == 0) {
            if (i * i == x) {
                ret += 1;
            } else {
                ret += 2;
            }
        }
    }
    return ret;
}

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

    int N;
    cin >> N;

    LL ans = 0;
    for (int i = 1; i <= N; i += 2) {
        if (divisorsCount(i) == 8) {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def solve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = []
    s = 0
    for j, a in enumerate(A):
        s += a * (1 if ((j % N) % 2 == 0) else -1)
    ans.append(str(s))
    for i in range(1, N):
        s = -s + 2 * A[i - 1]
        ans.append(str(s))
    return ans


def main():
    print(' '.join(solve()))


if __name__ == "__main__":
    main()


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

int a, b, k;

int main(void){
	cin >> a >> b >> k;
	for(int i = a; i <= b; i++){
		if(i < a+k || i > b-k) cout << i << endl;
	}
	return 0;
}


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


int main() {

    int n, x, l;
    cin >> n >> x;
    int ans = 1;
    int s = 0;
    rep(i,n) {
        cin >> l;
        s += l;
        if (s <= x) ans++;
    }
    cout << ans << 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 rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N; int K;
	while(~scanf("%d%d", &N, &K)) {
		int mask = 0;
		rep(i, K) {
			int D;
			scanf("%d", &D);
			mask |= 1 << D;
		}
		while(1) {
			int x = N;
			bool ok = true;
			do {
				ok &= ~mask >> (x % 10) & 1;
				x /= 10;
			} while(x);
			if(ok) break;
			++ N;
		}
		printf("%d\n", N);
	}
	return 0;
}


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

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

int main() {
	int n,y;
	cin>>n>>y;
	int a,b,c;
	a=b=c=-1;
	for(int i=0;i<=n;++i){
		for(int j=0;j<=n-i;++j){
			int k=n-i-j;
			int total=10000*i+5000*j+1000*k;
			if(total==y){
				a=i;
				b=j;
				c=k;
			}
		}
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
def keisan(patan):
    sujiretu=[]
    if len(patan)>1:
        for i in range(1,len(patan)):
            sujiretu.append((int(patan[i-1])+int(patan[i])) % 10 )
        return keisan(sujiretu)
    else:return patan
while(1):
    try:
        suuji=input("")
        suuji=keisan(suuji)
        print(suuji[0])
    except:break
                            



Measured memory_bytes: 5604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
 
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
 
#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
ll mod = 1000000000000000000;
inline int fast_expo(int base,int power,int modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    // int tmp=ans;
    return ans;
}
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
const int INF = (int)1e9;
//=========================CODE STARTS HERE=============================//
 
 
 
int main() {
 
	fast_cin();
 
	ll t;
	cin >> t;
	
	string s;
	cin>> s;
	
	fo(i, s.length()) {
		//if (t + int(s[i]) > int(toupper('z'))) {
			//cout << char()
		cout << char((t + int(s[i]) - 65) % (91 - 65) + 65);
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

int main()
{
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    cout << (min(A, B) + min(C, D)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
using namespace std;
using ll = long long;
const int INF = 999999999;

int N;
vector<int> V(21), C(21);

int dfs(int sumV, int sumC, int current) {
    if(current == N+1) {
        return sumV - sumC;
    }
    return max(dfs(sumV, sumC, current+1), dfs(sumV + V[current], sumC + C[current], current+1));
}

int main() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> V[i];
    for(int i = 1; i <= N; i++) cin >> C[i];

    int ans = dfs(0, 0, 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main( int argc, char *argv[] )
{
    int k;
    char s[110];

    scanf( "%d", &k );
    scanf( "%s", s );

    if( strlen( s ) > k ) {
        s[k] = '\0';
        strcat( s, "..." );
    }

    printf( "%s\n", s );
}


Measured memory_bytes: 1664
n = int(input())
a = list(map(int,input().split()))
b = [abs(a[0])]
for i in range(n-1):
    b.append(abs(a[i+1]-a[i]))
b.append(abs(a[-1]))
#print(b)
sumdis = sum(b)
a.append(0)
for i in range(n):
    print(sumdis + abs(a[i-1]-a[i+1]) - abs(a[i-1]-a[i]) - abs(a[i]-a[i+1]))

Measured memory_bytes: 14048
#include <bits/stdc++.h>
using namespace std;
long long a,b,c,d;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>a>>b>>c>>d;
if(a*b>c*d)cout<<a*b;
else cout<<c*d;


return 0;}



Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;


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

  if (a >= b + 2) {
    cout << a + a - 1 << endl;
    return 0;
  }

  if (b >= a + 2) {
    cout << b + b - 1 << endl;
    return 0;
  }

  cout << a + b << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  string S;
  long long K;
  cin >> S >> K;
  bool flag = true;
  int i;
  for(i=0; i<K&&flag==true&&i<S.size(); i++){
    if(S.at(i)!='1'){
      flag=false;
    }
  }
  i--;
  if(flag==true){
    cout<<'1'<<endl;
  }else{
    cout<<S.at(i)<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, m, a, b;
    cin >> n >> m;
    int cnt[n+1] = {};
    while (m--) {
        cin >> a >> b;
        cnt[a]++;
        cnt[b]++;
    }
    fore(i,0,n) {
        cout << cnt[i+1] << endl;
    }
}


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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N;
    cin>>N;
    vl A(N);
    long max = 0, sum = 0;
    REP(i, 0, N) cin >> A[i];
    REP(i, 0, N){
        if(A[i] <= max) sum += max - A[i];
        else max = A[i];
    }
    cout << sum << endl;
}

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

using namespace std;

int main(){
    long long n, k;
    cin >> n >> k;
    int ar[n];
    for(int i = 0; i < n; i++){
        cin >> ar[i];
    }
    vector<int> cicle;
    long long visited[n] = {0};
    long long index = 0, last_pueblo = 0;
    while(k--){
        last_pueblo = index;
        if(visited[index]){
            break;
        }
        visited[index] = 1;
        cicle.push_back(ar[index]);
        index = ar[index] - 1;
    }
    if(k <= 0)
        cout << ar[last_pueblo] << '\n';
    else{
        vector<int> new_cicle;
        vector<int>::iterator it = find(cicle.begin(), cicle.end(), ar[last_pueblo]);
        long long index = distance(cicle.begin(), it);
        for(int i = index; i < cicle.size(); i++){
            new_cicle.push_back(cicle[i]);
        }
        cout << new_cicle[(k + new_cicle.size()) % new_cicle.size()]<< '\n';

    }
    
}
       

Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
   int W,a,b;
   cin>>W>>a>>b;

   if(W>=abs(a-b)) cout << 0 << endl;
   else cout << abs(a-b)-W << endl;





}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
#include <chrono>
#include <fstream>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

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

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


int main() {
    ll x, k, d;
    cin >> x >> k >> d;
    if (x < 0) x *= -1;

    ll cnt_move = (x + d - 1) / d;
    ll p1 = x - d * cnt_move;
    ll p2 = p1 + d;
    
    if (cnt_move % 2 == k % 2) {
        if (cnt_move <= k) cout << abs(p1) << endl;
        else cout << abs(x - k * d) << endl;
    }
    else {
        cnt_move--;
        if (cnt_move <= k) cout << abs(p2) << endl;
        else cout << abs(x - k * d) << endl;
    }
}

Measured memory_bytes: 3628
n = int(input().rstrip())

def calc(target):
    result = 0
    count = 0
    if target % 2 == 0:
        print(-1)
        return
        
    for i in range(n):
        result = (result * 10 + 7) % target
        count += 1
        if result == 0:
            print(count)
            return
    
    print(-1)
    
calc(n)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

int main(void){
  int n, d;
  cin >> n >> d;

  cout << (n+2*d)/(2*d+1) << endl;
  return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline
    a1,b1 = map(int, input().split())
    a2,b2 = map(int, input().split())
    a3,b3 = map(int, input().split())
    ans = [0,0,0,0]
    ans[a1-1]+=1
    ans[b1-1]+=1
    ans[a2-1]+=1
    ans[b2-1]+=1
    ans[a3-1]+=1
    ans[b3-1]+=1
    if max(ans)==3:
        print('NO')
    else:
        print('YES')


Measured memory_bytes: 3064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

using Graph = vector<vector<int>>;

vector<bool> visited;
vector<LL> cost;

vector<LL> ans;
int n, q;

void dfs(const Graph &G, int v,LL val) {
	visited[v] = true; // v を訪問済にする
	val += cost[v];

	ans[v] = val;

	// v から行ける各頂点 next_v について
	for (auto next_v : G[v]) {
		if (visited[next_v]) continue; // next_v が探索済だったらスルー
		dfs(G, next_v,val); // 再帰的に探索
	}
}

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

	Graph G(n);

	for (int i = 0; i < n - 1; i++) {
		int a, b; cin >> a >> b;
		a--; b--;

		G[a].push_back(b);
		G[b].push_back(a);
	}

	cost.resize(n);

	for (int i = 0; i < q; i++) {
		int p; cin >> p;
		p--;
		int x; cin >> x;

		cost[p] += x;

	}

	visited.resize(n);
	ans.resize(n);
	
	dfs(G, 0, 0);

	for (int i = 0; i < n; i++) {
		cout << ans[i];

		if (i == n - 1) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}

	return 0;
}

Measured memory_bytes: 25856
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

//愚直シミュレーションより良い方法
int main() {

    ll K, T;
    cin >> K >> T;

    priority_queue<ll > que;

    for(ll i = 0; i < T; i++){
        ll t; cin >> t;
        que.push(t);
    }

    ll top = que.top();

    //一番多い数を持つ種類のケーキを１直線に並べて間を区切っていく
    //一直線で並べた時点で隣り合う数はa-1
    //そこに別の種類のケーキを奥ごとに隣り合う数は１へる
    //0になったらそれ以上減らないし，種類が３種類以上あってa-1以上の隙間を消せたら
    //全て同じ種類同士が隣合わないようにおける！

    cout << max(top - 1 - (K - top), 0LL) << endl;

}

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

typedef long long ll;
const int mod = 1e9 + 7;

ll N, K;
string S;

int main() {
    cin >> N >> K;
    cin >> S; 

    ll init_sum = 0;
    rep(i, N - 1) {
        if (S[i] == S[i + 1]) init_sum++;
    }

    cout << min(init_sum + 2 * K, N - 1) << endl; 
}

Measured memory_bytes: 512
n, m, k = [int(e) for e in input().split()]
a = [int(e) for e in input().split()]
b = [int(e) for e in input().split()]

i = 0
j = 0

total_max = 0

while i < n:
    if a[i] > k:
        break
    k -= a[i]
    i += 1
    
while j < m:
    if b[j] > k:
        break
    k -= b[j]
    j += 1

total_max = i + j
    
while i > 0 and j < m:
    k += a[i - 1]
    i -= 1
    while j < m:
        if b[j] > k:
            break
        k -= b[j]
        j += 1
    if total_max < i + j:
        total_max = i + j
    
print(total_max)


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

int main(void){
    string x;
    cin >> x;
    
    stack<char> s;
    for(int i = 0;i < x.size();i++){
        if(s.empty() || s.top() == 'T'){
            s.push(x[i]);
        } else {
            if(x[i] == 'T')s.pop();
            else s.push(x[i]);
        }
    }

    cout << s.size() << endl;
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  string s, t;
  cin >> s >> t;
  int n = sz(s);
  s += s;
  vii idx(26);
  rep(i,sz(s)) idx[s[i]-'a'].push_back(i+1);
  rep(i,sz(t)) {
    if(idx[t[i]-'a'].empty()) {
      cout << -1 << endl;
      return 0;
    }
  }
  ll ans = 0;
  int p = 0;
  rep(i,sz(t)) {
    int c = t[i]-'a';
    p = *upper_bound(all(idx[c]), p);
    if(p >= n) {
      ans += n;
      p -= n;
    }
  }
  ans += p;
  cout << ans << endl;
}

Measured memory_bytes: 1896
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <sstream>
using namespace std;

#define namefile ""
#define inifile freopen(namefile".inp","r",stdin); freopen(namefile".out","w",stdout)
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef unsigned int uint;
typedef unsigned long ulong;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;
typedef vector<int> VI;
typedef vector<long> VL;
typedef vector<string> VS;
typedef vector< VI > VVI;
typedef vector< VL > VVL;
typedef vector< PII > VPII;
typedef vector< PLL > VPLL;
typedef set<int> SETI;
typedef set<long> SETL;
typedef map<int,int> MII;
typedef map<long,long> MLL;

const long long MOD = 1e9+7;
const long long INFMAX = 1e9;
const long long INFMIN = -1e9;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const double epsilon = 1e-9;
const double PI = acos(-1.00);

int a,b;

int main()
{
    cin >> a >> b;
    cout << max(a+b, max(a-b,a*b));

    return 0;
}


Measured memory_bytes: 256
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)

#include <cstdio>
#include <vector>
#include <cstring>
#include <climits>

using namespace std;

int wait(int x) {
    int remain = x % 10;
    if (remain > 0) {
        return 10 - remain;
    }

    return 0;
}

int main() {
    int a;
    int res = 0;

    int W[5];
    int wait_max=0;

    int order_last = 0;

    REP(i, 5) {
        scanf("%d", &a);
        res += a;

        W[i] = wait(a);
        if (W[i] >= wait_max) {
            wait_max = W[i];
            order_last = i;
        }
    }

    REP(i, 5) {
        if (i != order_last) res += W[i];
    }

    printf("%d\n", res);

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
map<pair<int,int>,long long> F[20][20];
int n;long long a[20];
inline long long getdp(int l,int r,int lcnt,int rcnt)
{
	if(F[l][r].count(make_pair(lcnt,rcnt)))
		return F[l][r][make_pair(lcnt,rcnt)];
	if(l+1==r) return 0;
	long long ans=1e18;
	for(int mid=l+1;mid<r;mid++)
		ans=min(ans,getdp(l,mid,lcnt,lcnt+rcnt)+getdp(mid,r,lcnt+rcnt,rcnt)+a[mid]*(lcnt+rcnt));
	return F[l][r][make_pair(lcnt,rcnt)]=ans;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",a+i);
	printf("%lld\n",a[1]+a[n]+getdp(1,n,1,1));
}

Measured memory_bytes: 20108
import sys
from io import StringIO
import unittest

def resolve():
    n, m = map(int, input().split())

    h = list(map(int, input().split()))

    road = [[] for _ in range(n)]

    for _ in range(m):
        a, b = map(int, input().split())
        road[a - 1].append(b)
        road[b - 1].append(a)

    ans = 0

    for i, r in enumerate(road):
        if r == []:
            ans += 1
            continue
        elif h[i] > max([h[p - 1] for p in r]):
            ans += 1

    print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4 3
1 2 3 4
1 3
2 3
2 4"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """6 5
8 6 9 1 2 1
1 3
4 2
4 3
4 6
4 6"""
        output = """3"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 37304
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    vector<int> num(26);
    for (int i=0; i<s.size(); i++) {
        int idx;
        idx = s.at(i) - 'a';
        num.at(idx)++;
    }
    int cnt = 0;
    for (int i=0; i<26; i++) {
        if (num.at(i) == 0) {
            char c = 'a' + (char)i;
            cout << c << endl;
            break;
        }
        cnt++;
    }
    if (cnt == 26) cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

using namespace std;
int main(void){
    // Your code here!
    int N,t;
    int j = 0;
    int d[110] = {0};
    int d_out[110] = {0};
    cin >> N;
    for(int i=0; i<N; i++) cin >> d[i];
    //昇順ソート
    std::sort(d,d+N);
    for(int i=1; i<N; i++){
        if(d[i-1] == d[i]) ;
        else d_out[j++] = d[i-1];
        t = i;
    }
    d_out[j] = d[t];
    
    cout << ++j;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
    int a, b; //変数の宣言
    
    //入力
    scanf("%d %d", &a, &b);
    
    //出力
    if (a < b) {
        printf("a < b\n");
    }else if (a > b) {
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
    
    return 0;
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  string s;
  getline(cin, s);
  rep(i, s.size()) {
    if (s[i] >= 'a' && s[i] <= 'z') {
      s[i] = s[i] - 'a' + 'A';
    }
  }
  cout << s << '\n';
}



Measured memory_bytes: 3052
#include<bits/stdc++.h>
#define st first
#define nd second
using namespace std;
int a[(int)1e4 + 10];
const int mod = 1e9 +7 ;
map<int,int> mp;
int mul(int x,int y) {return 1LL * x * y % mod;}
int f_pow(int val,int idx){
    if(idx==0) return 1;
    if(idx==1) return val;
    int k = f_pow(val,idx>>1);
    k=mul(k,k);
    if(idx&1) k =mul(k,val);
    return k;
}

void plusle(int &x,int y) {
    x += y;
    x = x >= mod?x-mod:x;
    return;
}
int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1;i <= n;i++){
        scanf("%d",&a[i]);
        int x= a[i];
        int sq = sqrt(x);
        for(int j =2 ; j <=sq;j++){
            int ct = 0;
            while(x % j == 0) x/=j,ct++;
            if(ct > 0){
                if(mp.count(j)) mp[j] = max(ct, mp[j]);
                else mp[j] = ct;
            }
        }
        if(x > 1){
            if(!mp.count(x)) mp[x] = 1;
        }
    }
    if(mp.empty()) return !printf("%d",n);
    int lcm = 1;
    for(auto it: mp){
        lcm = mul(lcm,f_pow(it.st,it.nd));
    }
    int sum = 0;
    for(int i =1; i<=n;i++){
        plusle(sum , mul(lcm, f_pow(a[i],mod-2)));
    }
    printf("%d",sum);


}


Measured memory_bytes: 768
import java.util.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arrA = new int[n/2];
		int[] arrB = new int[n/2];
		for (int i = 0; i < n/2; i++) {
			arrA[i] = sc.nextInt();
			arrB[i] = sc.nextInt();
		}
		
		Arrays.sort(arrA);
		Arrays.sort(arrB);
		
		int maxA1 = 0;
		int maxA2 = 0;
		int maxB1 = 0;
		int maxB2 = 0;
		int countA = 0;
		int countB = 0;
		int maxA1Value = 0;
		int maxB1Value = 0;
		
		for (int i = 0; i < n / 2; i++) {
			if (i == 0) {
				countA = 1;
				countB = 1;
				continue;
			}
			if (arrA[i] == arrA[i - 1]) {
				countA++;
			} else {
				if (maxA1 < countA) {
					maxA2 = maxA1;
					maxA1 = countA;
					maxA1Value = arrA[i - 1];
				} else if (maxA2 < countA) {
					maxA2 = countA;
				}
				countA = 1;
			}
			if (arrB[i] == arrB[i - 1]) {
				countB++;
			} else {
				if (maxB1 < countB) {
					maxB2 = maxB1;
					maxB1 = countB;
					maxB1Value = arrB[i - 1];
				} else if (maxB2 < countB) {
					maxB2 = countB;
				}
				countB = 1;
			}
		}
		if (maxA1 < countA) {
			maxA2 = maxA1;
			maxA1 = countA;
			maxA1Value = arrA[n / 2 - 1];
		} else if (maxA2 < countA) {
			maxA2 = countA;
		}
		if (maxB1 < countB) {
			maxB2 = maxB1;
			maxB1 = countB;
			maxB1Value = arrB[n / 2 - 1];
		} else if (maxB2 < countB) {
			maxB2 = countB;
		}
		
		int maxA = 0;
		int maxB = 0;
		if (maxA1Value == maxB1Value) {
			if (maxA1 + maxB2 > maxA2 + maxB1) {
				maxA = maxA1;
				maxB = maxB2;
			} else {
				maxA = maxA2;
				maxB = maxB1;
			}
		} else {
			maxA = maxA1;
			maxB = maxB1;
		}
		System.out.println(n - maxA - maxB);
	}
	
	
}

Measured memory_bytes: 51028
#include <bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a << ": " << a << endl

int main() {
	int a, b, c; cin>>a>>b>>c;
	if(a== b && b != c){
		cout<<"Yes";
	}
	else if(b==c && a!=b){
		cout<<"Yes";
	}
	else if(a==c && a!=b){
		cout<<"Yes";
	}
	else cout<<"No";
	
}


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

long long gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
// int binary_search(int key) {
//     int ng = -1;
//     int ok = (int)a.size();
//     while(abs(ok - ng) > 1) {
//         int mid = (ok + ng) / 2;
//         if(isOK(mid, key))
//             ok = mid;
//         else
//             ng = mid;
//     }
//     return ok;
// }
// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> S(M); // switch
    for(size_t i = 0; i < M; i++) {
        int k;
        cin >> k;
        for(size_t j = 0; j < k; j++) {
            int s;
            cin >> s;
            S[i].push_back(s - 1);
        }
    }
    vector<int> C(M); // 条件
    for(size_t i = 0; i < M; i++) {
        cin >> C[i];
    }

    int ans = 0;
    for(int bit = 0; bit < (1 << N); bit++) {
        vector<bool> ison(N, false);
        for(int i = 0; i < N; i++) {
            if(bit & (1 << i)) {
                ison[i] = true;
            }
        }
        int allOn = 1;
        for(int i = 0; i < M; i++) {
            int sum = 0;
            for(auto s : S[i]) {
                sum += ison[s] ? 1 : 0;
            }
            allOn *= (sum % 2 == C[i]) ? 1 : 0;
        }
        ans += allOn;
    }
    cout << ans << endl;
}

Measured memory_bytes: 504
#include<iostream>
int n,d[200],x=0;
 
int main(){
    std::cin>>n;
    for (int i=1;i<=n;i++){
        std::cin>>d[i];
    }
    for (int i=1;i<=n-1;i++){
        for (int j=i+1;j<=n;j++){
            x+=d[i]*d[j];
        }
    }
    std::cout<<x;
    return 0;
}

Measured memory_bytes: 256
def compute():
  from sys import stdin
  A, B, K = list(map(int, stdin.readline().split()))
  
  cur = min(A,B) + 1
  while K>0 and cur>0:
    cur -= 1
    if (A%cur==0) and (B%cur==0):
      K-=1
  
  print(cur if K<1 else -1)

if __name__ == "__main__":
  compute()


Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;

using ll = long long;

ll X, K, D, ans;

int main()
{
    cin >> X >> K >> D;
    
    X = abs(X);

    if(X / D > K)
    {
        ans = X - K * D;
    }
    else
    {
        ll q = X / D;
        ll r = X % D;
        ll rk = K - q;
        if(rk % 2 == 0)
        {
            ans = r;
        }
        else
        {
            ans = D - r;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3192
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <complex>

using namespace std;
typedef long long ll;
typedef complex<double> Point;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define DEC(i, s) for (int i = (s); i >= 0; i--)

#define SIZE(v) (int)((v).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define FIND(m, w) ((m).find(w) != (m).end())

int n;
int ans;
double R;
Point points[3000];
pair<double, int> radian[30000];
bool used[3000];

int calc(int s) {
  int ret = 1;
  int m = 0;
  REP(i, n) {
    double d = abs(points[s] - points[i]) / 2.0;
    if (i == s || d * 2.0 > R * 2) { continue; }
    Point center = (points[s] + points[i]) / 2.0;
    Point vect = (points[i] - points[s]) * Point(0, -1);
    vect /= abs(vect);
    double l = sqrt(R * R - d * d);
    Point c1 = center + vect * l;
    Point c2 = center - vect * l;
    double arg1 = arg(c1 - points[s]) - EPS;
    double arg2 = arg(c2 - points[s]) + EPS;
    radian[m++] = pair<double, int>(arg1 + 0 * PI, (i + 1));
    radian[m++] = pair<double, int>(arg2 + 0 * PI, -(i + 1));
  }
  if (m / 2 < ans - 1) { return 0; }
  sort(radian, radian + m);
  MEMSET(used, false);
  int lsum = 1;
  REP(iter, 2) {
    REP(i, m) {
      int index = abs(radian[i].second) - 1;
      bool start = radian[i].second > 0 ? true : false;
      if (used[index] && !start) {
        used[index] = false;
        lsum--;
      } else if (!used[index] && start) {
        used[index] = true;
        lsum++;
      }
      ret = max(ret, lsum);
    }
  }
  return ret;
}

int main() {
  R = 1.0;
  while (scanf("%d", &n), n) {
    REP(i, n) {
      double x, y;
      scanf("%lf %lf", &x, &y);
      points[i] = Point(x, y);
    }
    ans = 0;
    REP(i, n) {
      ans = max(ans, calc(i));
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 1332
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	sc2(n,k);
	k=k*2+1;
	pr(ceil((ld)n/k));

	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

Measured memory_bytes: 256
n =int(input())
h = list(map(int,input().split()))
i = 0
res = 0
for _ in range(1,10000):
    i = 0
    while h[i] == 0:
        i += 1
        if i >n-1:
            break
    if i > n-1:
        break
    while h[i]>0:
        h[i] -= 1
        i += 1
        if i > n-1:
            break
    res += 1

print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100
vector<pair<int,int> > red,blue;
int used[MAX];
long long X,Y;
int A,B,C,D;
// int H;
// vector<int> thrower;

// int Rx[MAX];
// int Ry[MAX];
// int Bx[MAX];
// int By[MAX];
// int dp[1000000001];

int main(void){
    // Your code here!
    cin >> A >> B >> C >> D;
    
    
    cout << min(A,B) + min(C,D) << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct P
{
    int x,y;
    bool operator<(const P &a)const{
        //if(y!=a.y) return y>a.y;
        return max(x,-x)>max(a.x,-a.x);

    }

};
vector<int> v;
//bitset<4001000> b;
int i,n,d,m,k,a,b,c,e;
int o[1111];
int l[1111];
int j[1];
int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[1];
stack<int> s;
//set<int> s,s1;

//priority_queue<int,vector<int>,greater<int> > q;
queue<P> q;
string r;
//char r[1];
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
//v.resize(unique(v.begin(),v.end())-v.begin());
/*struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> p;//safe_map;
*/
bool as(P a,P b)
{
    if(a.y!=b.y)
    return a.y>b.y;
    return a.x>b.x;
}


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//rng();

int main()
{
    scanf("%d",&a);
    if(a%2==0)
    {
        for(int t=2;t<a;t++)
        {
            q.push({1,t});
            q.push({t,a});
            for(int h=t+1;h<a;h++)
            if(t+h!=a+1) q.push({t,h});
        }
    }
    else
    {
        for(int t=1;t<a;t++)
        q.push({a,t});
        for(int t=1;t<a;t++)
        {
            for(int h=t+1;h<a;h++)
            if(h+t!=a) q.push({t,h});
        }
    }
    printf("%d\n",q.size());
    for(;q.size();q.pop())
    {
        printf("%d %d\n",q.front().x,q.front().y);
        o[q.front().x]+=q.front().y;
        o[q.front().y]+=q.front().x;
    }
    //for(int t=1;t<=a;t++)
    //    printf("%d ",o[t]);
}




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

int main()
{
	int n;
	int a[10000];
	int b[10000];
	while (cin >> n, n)
	{
		for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
		int A = 0;
		int B = 0;
		for (int i = 0; i < n; i++)
		{
			if (a[i] > b[i])
			{
				A += a[i] + b[i];
			}
			else if (a[i] < b[i])
			{
				B += a[i] + b[i];
			}
			else
			{
				A += a[i];
				B += b[i];
			}
		}
		cout << A << ' ' << B << endl;
	}

	return 0;
}

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

int main(){
	// sengen
	string s;
	// nyuryoku
	cin >> s;
	int length = s.size();
	// keisan
	vector<int> alpha(26,0);
	for(int i=0;i<length;i++){
		int n = s.at(i) - 'a';
		alpha.at(n)++;
	}
	for(int i=0;i<27;i++){
		if(i<26){
			if(alpha.at(i) == 0){
				char c = i + 'a';
				cout << c;
				break;
			}
		}else{
			cout << "None" << endl;
			break;
		}
	}
}

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

int main(){
    int n;
    cin >> n;
    vector<array<int, 2>> A(n);
    for (int i = 0; i < n; i++)
        cin >> A[i][0] >> A[i][1];

    sort(A.begin(), A.end(), [](auto &l, auto &r){return l[1] > r[1];});
    int cur = 1e9;
    for (int i = 0; i < n; i++){
        cur = min(cur, A[i][1]);
        cur -= A[i][0];
    }

    puts(cur < 0 ? "No" : "Yes");
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

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


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

int main(){
	int n;
	scanf("%d", &n);
	multimap<string, int> s;
	for(int i = 0; i < n; i++) {
		int id;
		scanf("%d", &id);
		string key;
		cin >> key;
		if(id == 0) {
			int x;
			scanf("%d", &x);
			s.emplace(key, x);
		}else if(id == 1) {
			auto itr = s.find(key);
			for(; itr != s.end() && (*itr).first == key; itr++)
				printf("%d\n", (*itr).second);
		}else if(id == 2) {
			s.erase(key);
		}else if(id == 3) {
			string y;
			cin >> y;
			auto itr = s.lower_bound(key);
			for(; itr != s.end() && (*itr).first <= y; itr++)
				cout << (*itr).first << " " << (*itr).second << '\n';
		}
	}
}



Measured memory_bytes: 25020
#include <stdio.h>
    int n;
    long a[500000];
    int main(){
    	scanf("%d",&n);
    	long long sum=0;
    	for (int i=1;i<=n;i++){
    		scanf("%li",&a[i]);
    		a[i]=a[i]-i;	
    	}
    	sort(1,n);
    	a[0]=a[1];
    	for (int i=1;i<=n;i++){
    		a[i]=a[i]-a[0];
    		sum=sum+a[i];
    	}
    	long long ans=sum;
    	for (int i=2;i<=n;i++){
    		sum=sum-(a[i]-a[i-1])*(n-i+1)+(a[i]-a[i-1])*(i-1);
    		if (sum<ans)ans=sum;
    	}
    	printf("%lli",ans);
    	return(0);
    }
    int sort(int x,int y){
    	int l=x;
    	int r=y;
    	long m=a[(x+y)/2];
    	while (l<r){
    		while (a[l]<m)l++;
    		while (a[r]>m)r--;
    		if (l<=r){
    			long z=a[l];
    			a[l]=a[r];	
    			a[r]=z;
    			l++;
    			r--;
    		}
    	}
    	if (l<y)sort(l,y);
    	if (r>x)sort(x,r);
    }

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

#define REP(i, count) for(int i = 0; i < (count); i++)
#define REPR(i, first, last) for(int i = (first); i < (last); i++)
#define REPI(i, first, last) for(int i = (first); i <= (last); i++)

int solve(int n){

}


int main(){
	int n, k; cin >> n >> k;
	int h[100001]; REP(i, n)cin >> h[i];
	ll cost[100001] = {};
	REPR(i, 1, n){
		ll m = 9999999999;
		REPR(ik, 1, min(i, k) + 1){
			m = min(m, cost[i-ik] + abs(h[i]-h[i-ik]));
		}
		cost[i] = m;
	}
	cout << cost[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(void){
	
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(a==b){
		printf("a == b\n");
	}
	else if(a>b){
		printf("a > b\n");
	}
	else{
		printf("a < b\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
int A,B;
cin >> A >> B;
vector<char> S(A*B);
for(int i=0; i<A*B; i++)
{
    cin >> S.at(i);
}
int count=0;
for(int i=0; i<A+2; i++)
{
    for(int j=0; j<B+2; j++)
    {
        if(!(i==0||i==A+1)&&!(j==0||j==B+1))
        {
            cout << S.at(count);
            count++;
        }
        else
        {
            cout << "#";
        }
        if(j==B+1) cout << endl;
    }
}
}

Measured memory_bytes: 3592