akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <climits>
#include <algorithm>
#include <cmath>

using namespace std;

template<typename T> 
void show(T a){
  for(auto i : a){ cout << i << " "; }
  cout << endl;
}
/*
//https://www.geeksforgeeks.org/find-divisors-natural-number-set-1/
int countDivisors(int n, vector<int>& list){
  int count = 1;
  for(int i = 1; i <= sqrt(n); i++){
    if(n % i != 0) continue;
    if(n/i == i){
      count++;
    }
    else{
      count += 2;
    }
  }
  list[n] = count;
}

int pow(int i, int j){
  for(int k = 0; k < j; k++)
    i *= k + 1;
  return i;
}
*/

vector<int> list(101, 0);
// 使われた回数がx以上の素数の数を探す
int findmorethan(int x){
  int count = 0;
  for(int i : list){
    if(i >= x) count++;
  }
  return count;
}

int main(int argc, char *argv[]){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  
  // https://img.atcoder.jp/abc114/editorial.pdf
  // dp の実装は難しい。なぜなら、約数100と約数10が、重複する部分があるので、これを避ける実装が難しい。
  int count = 0;
  int n;
  cin >> n;
  
  // https://img.atcoder.jp/abc114/editorial.pdf
  // 1-100までのすべての素の約数が、何回使われたのかを記載
  for(int i = 2; i <= n; i++){
    int num = i;
    for(int j = 2; j <= num; j++){
      while(num % j == 0){
        list[j] += 1;
        num = num / j;
      }
    }
  }
  
  //show(list);
  
 
  // 75 = 75 = 3 x 25 = 3 x 5 x 5 = 5 x 15
  int res = 0;
  // 75 = 75
  res += findmorethan(74);
  res += (findmorethan(2)-1) * findmorethan(24);
  res += (findmorethan(2)-2) * (findmorethan(4)-1) * findmorethan(4) / 2;
  res += (findmorethan(4)-1) * findmorethan(14);
  
  //cout << findmorethan(4) << endl;
  //cout << findmorethan(2) << endl;
  
  cout << res << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a,b,c;
	char op;
	while(1){
		cin >> a >> op >> b;
		if     (op=='+') c = a+b;
		else if(op=='-') c = a-b;
		else if(op=='*') c = a*b;
		else if(op=='/') c = a/b;
		else if(op=='?') return 0;
		cout << c << endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define lowbit(x) x&(-x)
#define iter set<int>::iterator

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;

const int N = 1e5+5;
const ll mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
const int exdir[4][2]={1,1,1,-1,-1,1,-1,-1};

ll qpow(ll x,ll y){
    ll ans=1,t=x;
    while(y>0){
        if(y&1)ans*=t,ans%=mod;
        t*=t,t%=mod;
        y>>=1;
    }
    return ans%mod;
}

void solve(){
    int t;cin>>t;
    set<int>s;
    for(int i=3;i<=55555;i++){
        if(i%10==3){
            int f=1;
            for(int j=2;j*j<i;j++)
                if(i%j==0)f=0;
            if(f)s.insert(i);
        }
    }
    for(int i:s){
        if(t)cout<<i<<' ';
        else break;
        t--;
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //int t;cin>>t;
    //while(t--)solve(),cout<<'\n';
    solve();
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef long long ll;  //ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<ll, ll> > PS;
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

// g++ -std=c++11 prac.cpp 
int main(){
    ll x,y,z,n,m=0,k,h,w,sum=0,ans=0,Max=-1e9,count=0,Min=1e9+1;
    string s,t,u;
    bool ok=true;
    cin >> n >> m;
    VL a(n);
    PS b(m);
    rep(i,n){ cin >> a[i];} sort(ALL(a));
    rep(i,m){ 
        cin >> x >> y;
        b[i] = make_pair(y,x);
    } 
    sort(RALL(b));
    int j=0;
    rep(i,n){
        if(a[i] < b[j].first && b[j].second > 0){
            a[i] = b[j].first;
            b[j].second--;
        }
        if(b[j].second == 0){
            j++;
        }   
    }
    rep(i,n){
        ans += a[i];
    }

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

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

vector<pii> adj[300];

int main() {
	fastio;
	int N, M, L;
	cin >> N >> M >> L;

	for (int a, b, c, i = 0; i < M; ++i) {
		cin >> a >> b >> c;
		adj[--a].push_back({ --b, c });
		adj[b].push_back({ a, c });
	}

	int dist[300][300], len[300][300]{};
	ini(dist, 0x3f);

	for (int i = 0; i < N; ++i) {
		using T = tuple<int, int, int>;
		priority_queue<T, vector<T>, greater<T>> PQ;
		bool vis[300]{};

		PQ.push(T{ 0, 0, i });
		dist[i][i] = 0;

		while (!PQ.empty()) {
			int cnt, val, now;
			tie(cnt, val, now) = PQ.top(); PQ.pop();

			if (vis[now]) continue;
			vis[now] = 1;
			dist[i][now] = cnt;

			for (auto &nxt : adj[now]) {
				int v = nxt.X, d = nxt.Y;
				if (L < d) continue;

				if (val + d > L) {
					if (dist[i][v] < cnt + 1 ||
						dist[i][v] == cnt + 1 && len[i][v] < d) continue;

					dist[i][v] = cnt + 1;
					len[i][v] = d;
					PQ.push(T{ cnt + 1, d, v });
				}
				else {
					if (dist[i][v] < cnt ||
						dist[i][v] == cnt && len[i][v] < val + d) continue;

					dist[i][v] = cnt;
					len[i][v] = val + d;
					PQ.push(T{ cnt, val + d, v });
				}
			}
		}
	}

	int Q;
	cin >> Q;

	for (int s, t; Q--; ) {
		cin >> s >> t;
		cout << (dist[--s][--t] == 0x3f3f3f3f ? -1 : dist[s][t]) << endl;
	}

	return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
int n,m,k,d,s,ss,pos;
int a[M],b[M],c[M],cur[M];//rezi
set<P> S;

int main()
{
	LL buf;
	int id;
	scanf("%lld", &buf);
	n = buf = min(buf, (LL)M);
	RI(m,k,d,s);
	REP(i,1,m) RI(a[i], b[i], c[i]);

	if(n>m)
	{
		printf("%d\n", d*k);
		return 0;
	}
	
	ss = s;
	REP(i,1,n) S.insert( MP(0,i) );
	pos = 1;
	REP(i,1,k)
	{
		s += d;
		while(pos<=m && a[pos]<=s)
		{
			id = c[pos];
			S.erase( MP(cur[id], id) );

			cur[id] = max(cur[id], a[pos]);
			cur[id] += b[pos];
			S.insert( MP(cur[id], id) );
			pos++;
		}

		s = max(s, (*S.begin()).F);
	}
	printf("%d\n",s-ss);
	return 0;
}

Measured memory_bytes: 7268
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
const int MOD=100000;
bool comb(string a,string b){
      REP(i,a.size())if(a[i]!=b[i])return a[i]<b[i];
}
vector<string> ans;
int A,B;
bool f(string s){
      int cntA=0,cntB=0;
      REP(i,s.size()){
            if(cntA>=5&&cntB<=3)return false;
            if(cntB>=5&&cntA<=3)return false;
            if(s[i]=='A')cntA++;
            else cntB++;
      }
      return true;
}
void rec(int a,int b,string s){
      if(s.size()>=(A+B)){
            if(A==a&&B==b&&f(s))ans.PB(s);
            return;
      }
      rec(a+1,b,s+"A");
      rec(a,b+1,s+"B");
      return;
}
int main(){
      cin>>A>>B;
      rec(0,0,"");
      sort(ALL(ans),comb);
      REP(i,ans.size())cout<<ans[i]<<endl;
}

Measured memory_bytes: 1220
#include<iostream>
#include<stdio.h>
using namespace std;
int a[200050], b[200050];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	    cin>>a[i]; 
	b[n/2]=a[0];
	if(n%2)
	{
		for(int i=0;i<n/2;i++)
		{
			b[i]=a[n-1-2*i];
			b[n-1-i]=a[n-2-2*i];
		}
	 }
	 else
	 {
	 	if(n>1)
	 	{	
		 b[n/2]=a[0];
	 	for(int i=0;i<n/2;i++)
		{
			b[i]=a[n-1-2*i];
			b[n-1-i]=a[n-2-2*i];
		 }
	    }
	  } 
	  for(int i=0;i<n;i++)
	      cout<<b[i]<<' '; 
} 

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

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

    if(s == t){
        cout << "Yes" << endl;
        return 0;
    }
    bool ok = false;
    for(int i = 0; i < (int)s.size(); i++){
        string chg;
        chg = s[s.size()-1] + s.substr(0, (int)s.size()-1);
        if(chg == t) ok = true;
        s = chg;
    }

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll bit[200010], num;
ll n, a, b, c[10010], ans[10010], su, number;
vector<ll> node[10010];
bool flag[10010];

ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= num)
	{
		bit[i] += x;
		i += i & -i;
	}
}

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

ll div(ll x)
{
	return po(x, mod - 2);
}

void dfs(ll point)
{
	ans[point] = c[number];
	flag[point] = true;
	number++;
	for (int i = 0; i < node[point].size(); i++)
	{
		if (flag[node[point][i]]) continue;
		dfs(node[point][i]);
	}
}

int main(void)
{
	cin >> n;
	for (int i = 1; i < n; i++)
	{
		cin >> a >> b;
		node[a].push_back(b);
		node[b].push_back(a);
	}
	for (int i = 0; i < n; i++)
	{
		cin >> c[i];
		su += c[i];
	}
	sort(c, c + n);
	reverse(c, c + n);
	dfs(1);
	cout << su - c[0] << endl;
	for (int i = 1; i <= n; i++)
	{
		cout << ans[i];
		if (i == n)
		{
			cout << endl;
		}
		else
		{
			cout << ' ';
		}
	}
	int www;
	cin >> www;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;

  long long ans = 0, w_cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'W') {
      ans += i - w_cnt;
      w_cnt++;
    }
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
package main
import(
  "fmt"
)
func main(){
  var a, b, c int
  fmt.Scan(&a, &b, &c)
  if a==b&&b!=c{
    fmt.Println("Yes")
  }else if a==c&&b!=a{
    fmt.Println("Yes")
  }else if b==c&&a!=b{
    fmt.Println("Yes")
  }else{
    fmt.Println("No")
  }
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1000000007;


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

    if (b % a == 0) {
        cout << a + b << endl;
    } else {
        cout << b - a << endl;
    }

}



Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

ans = [0] * N
for i in range(len(A)):
	ans[A[i]-1] = i+1

print(*ans)


Measured memory_bytes: 14576
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fast ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
#define endl "\n"
#define vst vector<string>
#define vll vector<ll>
#define sort(a) stable_sort(a.begin(),a.end())
#define sortd(a) stable_sort(a.begin(),a.end(),greater<int>())
#define vpr vector<pair<ll,ll>>
#define gcd(a,b) __gcd(a,b)

ll lcm(ll x,ll y){return (x*y*1LL)/gcd(x,y);}





int main()
{
    ll h1,h2,m1,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    if(m2<m1)
    {
        ll z=m2-m1+60+(h2-h1-1)*60;
        cout<<z-k<<endl;
    }
    else
    {
        ll z=m2-m1+(h2-h1)*60;
        cout<<z-k<<endl;
        
    }
    
}

    



Measured memory_bytes: 3632
# https://atcoder.jp/contests/abc088/tasks/abc088_b
n = input().split()[0]
a_list = list(map(int, input().split()))

alice_list = []
bob_list = []
sorted(a_list)

for i in range(len(a_list)):
    max_a = max(a_list)
    a_list.remove(max_a)

    if i % 2 == 0:
        alice_list.append(max_a)
    else:
        bob_list.append(max_a)

answer = sum(alice_list) - sum(bob_list)
print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define FINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int dy[4] = {-1,0,0,1};
int dx[4] = {0,-1,1,0};
int H,W;
string A[1010];
int dis[1010][1010];

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

  cin >> H >> W;
  REP(i,H) cin >> A[i];
  queue<pii> que;
  MINUS(dis);
  REP(i,H) REP(j,W) if (A[i][j] == '#') {
    que.emplace(i,j);
    dis[i][j] = 0;
  }
  int ans = 0;
  while (!que.empty()) {
    int y,x;
    tie(y,x) = que.front(); que.pop();
    REP(i,4) {
      int ny = y+dy[i];
      int nx = x+dx[i];
      if (IN(ny,0,H-1) && IN(nx,0,W-1) && dis[ny][nx] < 0) {
        dis[ny][nx] = dis[y][x]+1;
        que.emplace(ny,nx);
        CHMAX(ans,dis[ny][nx]);
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 25652
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
using namespace std;

int main() {
  int a[101] = {}, q;
  while (true) {
    int p, s;
    char c;
    cin >> p >> c >> s;
    if (p == 0 && s == 0)
      break;
    a[p] = s;
  }

  pair<int, int> b[101] = {make_pair(-1, -1)};
  for (int i = 1; i <= 100; ++i)
    b[i] = make_pair(a[i], i);
  sort(b, b + 101, greater<pair<int, int>>());

  int rank[101] = {}, s = 31, r = 0;
  for (int i = 0; i < 100; ++i) {
    if (b[i].first < s)
      ++r, rank[b[i].second] = r, s = b[i].first;
    else
      rank[b[i].second] = r;
  }

  while (cin >> q)
    cout << rank[q] << endl;
}


Measured memory_bytes: 3040
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
 
ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}


const int N = 200002;
int n, minpos[1<<27], DP[N];
char str[N];

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

    cin>>(str+1);
    n = strlen(str+1);

    for(int mask=0;mask<(1<<26);mask++)
    	minpos[mask] = MOD;

    DP[0] = 0;
    minpos[0] = 0;
    int mask = 0;
    for(int i=1;i<=n;i++){
    	mask ^= (1<<(str[i]-'a'));
    	DP[i] = 1 + DP[i-1];
    	DP[i] = min(DP[i], 1 + minpos[mask]);
    	for(int j=0;j<26;j++)
    		DP[i] = min(DP[i], 1 + minpos[mask^(1<<j)]);
    	minpos[mask] = min(minpos[mask], DP[i]);
    }

    assert(DP[n] != MOD);
    cout<<DP[n];
    return 0;
}




Measured memory_bytes: 264576
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
vector< vector<int> > ans;

void dfs(vector<int> v, int t, int sum) {
	if(sum == n) {
		ans.push_back(v);
		return;
	}

	for(int i = t; i >= 1; i--) {
		if(sum + i <= n) {
			vector<int> ret(v.begin(), v.end());
			ret.push_back(i);
			dfs(ret, i, sum + i);
		}
	}

	return;
}

int main() {
	while(cin >> n && n) {
		ans.clear();

		vector<int> v;
		dfs(v, n, 0);

		rep(i, ans.size()) {
			vector<int> t = ans[i];

			rep(j, t.size()) {
				cout << t[j];

				if(j == t.size()-1) cout << endl;
				else cout << " ";
			}
		}
	}

	return 0;
}

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    string s;
    map<char, int> m;
    cin >> s;
    for (int i = 0; i < 4; i++)
        m[s[i]]++;

    bool f = true;
    if (m.size() != 2)
        f = false;
    for (auto itr = m.begin(); itr != m.end(); itr++)
        if (itr->second != 2)
            f = false;
    if (f)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main {
    public static void main(String... args){
        Scanner scan = new Scanner(System.in);
       while(true){
           int h = scan.nextInt();
           int w = scan.nextInt();
           if(h == 0 && w == 0)break;


           for(int i = 0;i < h;i++){
               for(int j = 0;j < w;j++){
                   if(i == 0 || i == h-1)
                   System.out.print("#");
                   else{
                        if(j == 0 || j == w-1) System.out.print("#");
                        else  System.out.print(".");
                   }

               }
               System.out.println();
           }
           System.out.println();
       }
       scan.close();
    }
}


Measured memory_bytes: 33896
// ITP1_6_C:   Official House
// 2017.7.27
 
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int b, f, r, v;;
    int house[5][4][11];
    int i, n;
 
    for (b = 1; b <= 4; b++) {
        for (f = 1; f <= 3; f++) {
            for (r = 1; r <= 10; r++) house[b][f][r] = 0;
        }
    }
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d%d%d%d", &b, &f, &r, &v);
        house[b][f][r] += v;
    }
 
    for (b = 1; b <= 4; b++) {
        for (f = 1; f <= 3; f++) {
            for (r = 1; r <= 10; r++) printf(" %d", house[b][f][r]);
            putchar('\n');
        }
        if (b < 4) puts("####################");
    }
    return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;

const ll mod = 1000000007;



int main() {
	ll x;
	cin >> x;

	vector<ll> a5;



	for(int i = 0; i < 1000; i++) {
		a5.push_back(i * i * i * i * i);
	}

	for(int i = 0; i < 1000; i++) {
		for(int j = 0; j < i; j++) {
			if (a5[i] + a5[j] == x) {
				if (j == 0) {
					cout << i << " " << j << endl;
				} else {
					cout << i << " -" << j << endl;
				}
				return 0; 
			}
			if (a5[i] - a5[j] == x) {
				cout << i << " " << j << endl;
				return 0; 
			}
		}
	}

	return 0;
}


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

int n, m, q;
int seq[10];

int a[50], b[50], c[50], d[50];

int calc(int index, int ll) {
    int ans = 0;
    if (index == n) {
        for (int i = 0; i < q; i++) {
            if (seq[b[i]] - seq[a[i]] == c[i]) ans +=d[i];
        }
        return ans;
    }

    for (int i = ll; i <= m; i++) {
        seq[index] = i;
        ans = max(ans, calc(index + 1, i));
    }
    return ans;
}

int main() {
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    cout << calc(0, 1) << endl;
    return 0;
}

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


int main() {
	string S;
	cin >> S;
	int n = S.size() - 1;
	int count = 0;
	for(int i = 0; i < n; i++){
		if(S[i] != S[n]){
			count++;
			n -= 1;
		} else {
			n -= 1;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int>a(N);
    int count=0;
    for(int i=0; i<N; i++){
        cin>>a.at(i);
        if(i%2==0){
            if(a.at(i)%2==1){
                count++;
            }
        }
    }
    cout<<count<<endl;
}



Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>

using namespace std;

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

    for (int i = 1; i < 500001; ++i) {
        int v = i * 1.08;
        if (v == n) {
            cout << i;
            return 0;
        }
    }

    cout << ":(";

    return 0;
}


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

using namespace std;

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

    set<int> st;
    for (int i = 0; i < n; ++i) {
        int t;
        cin >> t;
        st.insert(t);
    }
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<char,int> CI;
//							1,   5,   10,  50,   100,  500, 1000
const char Roman[] = { 'I', 'V', 'X', 'L', 'C', 'D', 'M' };

int main()
{
//	cut here before submit 
//	freopen ("testcase.RF", "r", stdin );
	map<char,int> trans; trans.clear();
	int m = sizeof (Roman)/sizeof (Roman[0] );
//	vector<CI> trans (m );
	int curr = 1;
	rep (i, m ){
		if (i % 2 == 0 ){
			trans[Roman[i]] = curr;
		}else{
			trans[Roman[i]] = 5*curr;
			curr *= 10;
		} // end if
	} // end rep
/*
	rep (i, m ){
		cout << trans[i].first << ':' << trans[i].second << endl;
	} // end rep
*/


	string str = "";
	while (getline (cin, str ) ){
		int res = 0;
		int n = str.length();
		for (int i = 1; i < n; i++ ){
			int prev = trans[str[i-1]];
			int curr = trans[str[i]];
			if (prev >= curr ){
				res += prev;
			}else{
				res -= prev;
			} // end if
		} // end for
		res += trans[str[n-1]];
		printf ("%d\n", res );
	} // end loop
		
	return 0;
}

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

int main() {
  int A,B;
  cin >> A >> B;
  int count = 0;
  int accum = 1;
  while (B>accum) {
  accum+=A-1;
  count++;
  }
  
  cout << count <<endl;
 
}

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

int main(){
    int n,k;
    int ans = 0;
    cin >>n>>k;
    int h[n];
    for (int i = 0; i < n;i++)
    {
      cin >> h[i];
      if (h[i] >= k)
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import sys

import numpy as np

sys.setrecursionlimit(10000)
INF = float('inf')

W, B = list(map(int, input().split()))

# ↓こんな感じのやつつくって必要な分だけ消せばいい
# #################
# #.#.#.#.#.#.#.#.#
# #################
# #.#.#.#.#.#.#.#.#
# #################
# #.#.#.#.#.#.#.#.#
# #################
# .................
# .#.#.#.#.#.#.#.#.
# .................
# .#.#.#.#.#.#.#.#.
# .................
# .#.#.#.#.#.#.#.#.
# .................

np.set_printoptions(threshold=np.inf)

# 500個ずつ作るよ
HEIGHT = 82
WIDTH = 51
table = np.empty((HEIGHT, WIDTH), dtype=str)
table[:HEIGHT//2:2, :] = '#'
table[1:HEIGHT//2:2, ::2] = '#'
table[1:HEIGHT//2:2, 1::2] = '.'
table[HEIGHT//2::2, :] = '.'
table[HEIGHT//2 + 1::2, ::2] = '.'
table[HEIGHT//2 + 1::2, 1::2] = '#'

whites = 501
blacks = 501
for i in range(HEIGHT // 2):
    for j in range(WIDTH):
        if whites <= W:
            break
        if table[i][j] == '.':
            table[i][j] = '#'
            whites -= 1
for i in range(HEIGHT // 2, HEIGHT):
    for j in range(WIDTH):
        if blacks <= B:
            break
        if table[i][j] == '#':
            table[i][j] = '.'
            blacks -= 1

print(HEIGHT, WIDTH)
for t in table:
    print(''.join(t))



Measured memory_bytes: 21624
N,A,B = map(int,input().split())
H = [int(input()) for _ in [0]*N]

def binary_search(l,r,func):
    if func(l):return l-1
    if not func(r):return r
    while l+1<r:
        i = (l+r)//2
        if func(i):
            r = i
        else:
            l = i
    return l

def f(K):
    c = sum(max(0,(h-B*K-1)//(A-B)+1) for h in H)
    return c<=K

print(binary_search(0,10**9,f)+1)

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>void reg(vector<T> &ary,const T &elem){ary.emplace_back(elem);}
template<class T>bool chmin(T &a, const T &b) {return (b<a)?(a=b,1):0;}
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}

using R=long double; // __float128
const R EPS = 1E-12; // [-1000:1000]->EPS=1e-8 [-10000:10000]->EPS=1e-7
const R INF = 1E40;
constexpr R PI = acos(R(-1));
inline int sgn(const R& r){ return (r > EPS) - (r < -EPS);}
inline int sgn(const R& a, const R &b){ return sgn(a-b); }
inline R sq(R x){return sqrt(max<R>(x,0.0));}

using P=complex<R>;
using VP=vector<P>;
using L=struct{P s,t;};
using VL=vector<L>;
using C=struct{P c;R r;};
using VC=vector<C>;

constexpr P O = P(0,0);
istream& operator >> (istream& is,P& p){ R x,y;is >> x >> y; p=P(x,y); return is;}
ostream& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}

namespace std{
	bool operator <  (const P& a,const P& b){ return sgn(real(a-b))?real(a-b)<0:sgn(imag(a-b))<0;}
	bool operator == (const P& a,const P& b){ return sgn(real(a-b))==0 && sgn(imag(a-b))==0;}
}

inline R dot(P o,P a,P b){a-=o,b-=o; return real(conj(a)*b);}
inline R det(P o,P a,P b){a-=o,b-=o; return imag(conj(a)*b);}

enum RCC{OUT=1,ON_OUT=2,ISC=4,ON_IN=8,IN=16,ONS=10};
int rcc(C a,C b){ R d=abs(a.c-b.c);return bit(2+sgn(a.r+b.r-d)+sgn(abs(a.r-b.r)-d));}

VP contact(C c,P p){
	VP ret; R d=abs(p-c.c); 
	rep(i,2) reg(ret,c.c+(c.r+P(0,2*i-1)*sq(norm(d)-norm(c.r)))*c.r*(p-c.c)/norm(d));
	uniq(ret);
	return ret;
}

VP contact(C a,C b){
	VP ret; R d=abs(a.c-b.c); int r=rcc(a,b);
	rep(i,2) if(r<=8-6*i) rep(j,2){
		R r=a.r+(2*i-1)*b.r;
		reg(ret,a.c+(r+P(0,2*j-1)*sq(norm(d)-norm(r)))*a.r*(b.c-a.c)/norm(d));
	}
	uniq(ret);
	return ret;
}

int main(void){
	C c1,c2;
	P p;
	cin >> c1.c >> c1.r >> c2.c >> c2.r;
	//cin >> c1.c >> c1.r >> p;

	VP res=contact(c1,c2);
	//VP res=contact(c1,p);
	cout.precision(20);
	for(auto &p:res) cout << fixed << p << endl;
	return 0;
}

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

int main() {
 	int n;
  	cin >> n;
  	vector<int> ele(n, 0);
  	for (int i = 0; i < n; i++) cin >> ele[i];
  	double ans = 0;
  	sort(ele.begin(), ele.end());
  	ans = (ele[0] + ele[1]) / 2.0;
  	for (int i = 2; i < n; i++) ans = (ans + ele[i]) / 2.0;
    cout << ans << endl;
}

Measured memory_bytes: 256
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))
wa=sum(a)
l=math.ceil(wa/(4*m))
count=0
for i in range(n):
  if a[i]>=l:
    count+=1
if count>=m:
  print('Yes')
else:
  print('No')

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

int mat[100][100];
int vec[100];

int main(){
	int n, m;
	cin >> n >> m;
	
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin >> mat[i][j];
		}
	}
	for(int i=0; i<m; i++){
		cin >> vec[i];
	}
	for(int i=0; i<n; i++){
		int ans = 0;
		for(int j=0; j<m; j++){
			ans += mat[i][j] * vec[j];
		}
		cout << ans << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 3164
#include<stdio.h>
#define N 100

int main(){
  int i,j,min;
  int count=0;
  int A[N];
  int num;
  int mask;

  scanf("%d",&num);

  for(i=0;i<num;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0;i<num-1;i++){
    min=i;
    for(j=i;j<num;j++){
      if(A[j]<A[min]){
	min=j;
      }
    }
    if(i!=min){
      mask=A[i];
      A[i]=A[min];
      A[min]=mask;
      count++;
    }
  }

  for(i=0;i<num;i++){
    if(i!=0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");

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

  return 0;
}

Measured memory_bytes: 604
import sys
n, x = map(int, input().split())

num_of_all = {0:1}
for i in range(1, n):
    num_of_all[i] = 2 * num_of_all[i-1] + 3

num_of_P = {0:1}
for i in range(1, n):
    num_of_P[i] = 2 * num_of_P[i-1] + 1

def num_of_P_from_bottom(level, x):
    if level == 0:
        return 1

    prev_level_all = num_of_all[level-1]
    prev_level_P   = num_of_P[level-1]
    ret = 0

    if x <= 1:
        return 0
    elif x <= (2 + prev_level_all):
        if x == 2 + prev_level_all:
            ret += 1
        ret += num_of_P_from_bottom(level-1, x-1)
    else:
        ret += 1 + prev_level_P
        ret += num_of_P_from_bottom(level-1, x - (prev_level_all + 2))
    return ret

tmp = num_of_P_from_bottom(n, x)
print(tmp)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip> //setprecision()
using ll = long long;
using namespace std;

void monmo(){
    
}

int main() {
    ll a,b,v,w,t;
    cin>>a>>v>>b>>w>>t;
    if(a<b){
    for(ll i=0;i<t;i++){
        a+=v;
        b+=w;
    }
    
    if(a>=b){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
    }else{//bが左
    for(ll i=0;i<t;i++){
        a-=v;
        b-=w;
    }
    
    if(a<=b){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
    }
}


Measured memory_bytes: 3632
package main

import (
	"fmt"
	"math"
	"strconv"
)

func main() {
	var a, b string
	var i, n int
	fmt.Scanf("%s %s", &a, &b)

	i, _ = strconv.Atoi(a + b)
	n = int(math.Sqrt(float64(i)))

	if n*n == i {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main(){
  int N;
  int T[110];
  cin >> N;
  for(int i=0; i<N; ++i){
    cin >> T[i];
    }
  int M;
  cin >> M;
  int P[110];
  int X[110];
  for(int i=0; i<M; ++i){
    cin >> P[i] >> X[i];
    }
  int res=0;
  for(int i=0; i<N; ++i){
    res=res+T[i];
  }
  static int z=res;
  int A[110]={0};
  for(int i=0; i<M; ++i){
    int y=P[i];
    A[i]=z+X[i]-T[y-1];
  }
  for(int i=0; i<M; ++i){
    cout << A[i] <<endl;
  }
  }

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

#define MAX 128

int top;
int S[MAX] = {0};

void initialize(){
  top = 0;
}

int isEmpty(){
  return top == 0;
}

int isFull(){
  return MAX - 1 <= top;
}

int push(x){
  if (isFull())
    puts("over flow");
  top++;
  S[top] = x;
  return 0;
}

int pop(){
  if (isEmpty())
    puts("under flow");
  top--;
  return S[top + 1];
}
  
int main(void){
  char x[1];
  int tmp;
  initialize();

  while (scanf("%s", x) != EOF){
    switch(x[0]) {
    case '+':
      push(pop() + pop());
      break;
    case '-':
      tmp = pop();
      push(pop() - tmp);
      break;
    case '*':
      push(pop() * pop());
      break;
    default:
      push(atoi(x));
      break;
    }
  }
  printf("%d\n", pop());
  return 0;
}

Measured memory_bytes: 548
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
using namespace std;
int main(){

    int n;
    cin>>n;
    if(n==25){
        cout<<"Christmas"<<endl;
    }else if(n==24){
        cout<<"Christmas Eve"<<endl;
        
    }else if(n==23){
        cout<<"Christmas Eve Eve"<<endl;
    }else{
        cout<<"Christmas Eve Eve Eve"<<endl;
    }





return 0;
}


Measured memory_bytes: 256
let rec upper_bound l r p =
  if r <= 1 + l
  then l
  else let m = (l + r) / 2 in
       if p m
       then upper_bound m r p
       else upper_bound l m p

let () = Scanf.scanf "%d %d" @@ fun a b ->
  let ab = a * (if 100 <= b then 1000 else if 10 <= b then 100 else 10) + b in
  let n = upper_bound 0 1000 @@ fun n -> n * n <= ab in
  print_endline @@
    if n * n = ab then "Yes" else "No"

Measured memory_bytes: 384
S=input()
ans=0
nucreotides=["A","C","G","T"]
i=0
p=0

while i<=len(S)-1:
    if S[i] not in nucreotides:
        p=0
        i+=1
    else:
        p+=1
        if ans<=p:
            ans=p
        i+=1
        
print(ans)

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

using namespace std;

int calc(int y,int m,int d){
    int res=0;
    res+= 590*((y-1)/3);
    if(y%3==0){
        res+=390;
        res+=(m-1)*20;
        res+=d;
    }
    else if(y%3==2){
        res+=195;
        res+=39*((m-1)/2);
        if(m%2) res+=d;
        else res+=(d+20);
    }
    else{
        res+=39*((m-1)/2);
        if(m%2) res+=d;
        else res+=(d+20);
    }
    return res;
}

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

    int n;cin>>n;
    for(int i=0;i<n;i++){
        int y,m,d;cin>>y>>m>>d;
        cout<<590*333+1-calc(y,m,d)<<endl;
    }
}

Measured memory_bytes: 3124
// AtCoder ABC129: A - Airplane
// 2019.9.4 bal4u

#include <stdio.h>

int main()
{
	int i, s, t, P[5];
	
	scanf("%d%d%d", P, P+1, P+2);
	P[3] = P[0], P[4] = P[1];
	s = 1000;
	for (i = 0; i < 3; i++) {
		t = P[i] + P[i+1];
		if (t < s) s = t;
	}
	printf("%d\n", s);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>

//#define PI 3.141592653589

using namespace std;

int tama[10];

bool dfs(int i, int left, int right)
{
	if (i == 10) return true;
	
	bool ans = false;
	if (left < tama[i])
	{
		ans = dfs(i+1, tama[i], right);
	}
	if (right < tama[i])
	{
		ans = dfs(i+1, left, tama[i]);
	}
	
	return ans;
}

int main()
{
	int N;
	
	cin >> N;
	for (int i=0; i<N; i++)
	{
		for (int j=0; j<10; j++)
		{
			cin >> tama[j];
		}
		cout << (dfs(0, 0, 0) ? "YES" : "NO") << endl;
	}
	
	return 0;
}

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

int main(void) {
	char input[16];
	int len;
	int i;
	int ans = 0;

	scanf("%s", input);

	len = strlen(input);

	for(i = 0; i < len / 2 + len % 2; i++) {
		if(input[i] == '(') {
			if(input[len - 1 - i] != ')')
				ans++;
		}

		else if(input[i] == ')') {
			if(input[len - 1 - i] != '(')
				ans++;
		}

		else if(input[i] != input[len - 1 - i])
			ans++;
	}

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

	return 0;
}

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

#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() {
  cerr << "]\n";
}
template<typename T, typename ...Args> void DBG(T first, Args... args) {
  cerr << first; if (sizeof...(args))cerr<<", "; DBG(args...);
}

/////////////////////////// GLOBAL ///////////////////////////

/////////////////////////// GLOBAL ///////////////////////////

void solve() {
  int n, x, t;
  cin>>n>>x>>t;
  cout<<((n+x-1)/x)*t<<"\n";

}


int32_t main() {
  #ifndef ONLINE_JUDGE
  clock_t tStart = clock();
  freopen("in.txt", "r", stdin);
  //freopen("output.txt","w",stdout);
  #endif 
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  // cin >> t;
  for (int tt=1;tt<=t;tt++) {
    //cout << "Case #"<<tt<<": ";
    solve();
  }
  #ifndef ONLINE_JUDGE
    cerr << "\nRun Time -> "<<(double)(clock()-tStart)/CLOCKS_PER_SEC <<" sec\n";
  #endif
}


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

n = int(input())

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

ans = 0
active = 0

for i in range(n):
    if active >= h[i]:
        active = h[i]
    else:
        ans += h[i] - active
        active = h[i]
print(ans)

Measured memory_bytes: 3064
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << std::endl;
}

using namespace std;

int main() {
    int n; cin >> n;
    vector<ll> da(n+1);
    rip(i,n+1,0) cin >> da[i];
    vector<ll> dp(n+1, 1), dpp(n+1, 1);
    if(n == 0 && da[0] == 1) {
        cout << 1 << endl;
        return 0;
    }
    if(da[0]) {
        cout << -1 << endl;
        return 0;
    }
    rip(i,n,0) {
        dp[i+1] = min(dpp[i]*2, 1000000000000000LL);
        if(da[i+1] > dp[i+1]) {
            cout << -1 << endl;
            return 0;
        }
        dpp[i+1] = dp[i+1] - da[i+1];
    }
    ll ans = 0, now = 0;
    for(int i = n;i>-1;--i) {
        now = min(dpp[i], now);
        now += da[i];
        ans += now;
    }
    // vdeb(dp);
    // vdeb(dpp);
    cout << ans << endl;
}

Measured memory_bytes: 5632
unittest
{
	assert( [ "2", "1", "2" ].parse.expand.solve == "first" );
	assert( [ "3", "100000", "30000", "20000" ].parse.expand.solve == "second" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto as = new long[ n ];
	foreach( ref a; as )
	{
		input.popFront;
		a = input.front.to!( long );
	}
	return tuple( as );
}

auto solve( long[] as )
{
	return as.count!( ( a ) => a % 2 == 1 ) ? "first" : "second";
}


Measured memory_bytes: 3964
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	string s;
	int ans = 0;
	cin >> s;

	for (int i = 0; i < s.size(); i++)
	{
		switch (i % 2)
		{
		case 0: // g
			if (s[i] == 'p')
				ans--;
			break;
		case 1: // p
			if (s[i] == 'g')
				ans++;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
typedef long long ll;
const ll MOD = 1e9+7;


int main(){
  int n; cin >> n; string s; cin >> s;
  vector<int> A(4);
  rep(i, n){
    if(s.at(i)=='W') A[0]++;
    else A[1]++;
  }
  int ans = A[1], m;
      //cout << ans << endl;
  for(int j=1; j<n; j++){
    if(s.at(j-1)=='W') {A[2]++; A[0]--;}
    else {A[3]++; A[1]--;}
    if(s.at(j)=='W') m = A[1]+A[2];
    else m = A[1]+A[2]-1;
    ans = min(ans, m);
    //cout << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 900
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val packages = (0 until n).map { readLine()!!.toInt() }

    fun canLoadAllPackages(p: Int): Boolean {
        var i = 0
        for (j in 0 until k) {
            var w = 0
            while (i < n && w + packages[i] <= p) {
                w += packages[i]
                i++
            }
        }
        return i == n
    }

    var l = 0
    var r = 100000 * 10000
    var m: Int

    while (r - l > 1) {
        m = (l + r) / 2
        if (canLoadAllPackages(m)) {
            r = m
        } else {
            l = m
        }
    }

    println(r)
}


Measured memory_bytes: 45108
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        while (true) {
            int n = scanner.nextInt();
            int x = scanner.nextInt();
            if (n == 0 && x == 0) {
                scanner.close();
                return;
            }

            int count = 0;
            for (int a = 1; a <= n; a++) {
                for (int b = a + 1; b <= n; b++) {
                    for (int c = b + 1; c <= n; c++) {
                        if (a + b + c == x) {
                            count++;
                        }
                    }
                }
            }

            System.out.println(count);
        }
    }
}



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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    string n;
    cin>>n;

    n="0"+n;

    int ans=0,frag=0;

    rrep(i,n.length()-1){
        int num=(n[i]-'0')+frag;
        if(num<=5){
            ans+=num;
            frag=0;
            if(num==5 && (n[i-1]-'0')>=5){
                frag=1;
            }
        }else{
            ans+=10-num;
            frag=1;
        }
    }

    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 2308
#include <iostream>

using namespace std;

typedef long long ll;
#define x first
#define y second
#define mp make_pair

const int MAXN = 3000;
int n, t, a[MAXN + 5], b[MAXN + 5], dp[2][MAXN + 5];

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> t;
for(int i = 1 ; i <= n ; ++i){
	cin >> a[i] >> b[i];
}
for(int i = 1 ; i <= n ; ++i){
	for(int j = t - 1 ; j >= 0 ; --j){
		dp[1][j] = max(dp[1][j], dp[0][j] + b[i]);
		if(j >= a[i]){
			dp[0][j] = max(dp[0][j], dp[0][j - a[i]] + b[i]);
			dp[1][j] = max(dp[1][j], dp[1][j - a[i]] + b[i]);
		}
	}
}
cout << dp[1][t - 1] << endl;

return 0;
}



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

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) (x & (-x))
#define BIT(a,b) ((ll)(a&(1<<b))==0 ? false : true)

const ll MAXN=1e5+10;

ll a[MAXN];

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

    ll n;
    cin>>n;

    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }

    ll s=0,k=0,sum=0;

    for(ll i=0;i<n;i++)
    {
        if (i&1)
        {
            sum+=a[i];

            if (sum<=0)
            {
                s+=abs(sum)+1;
                sum=1;
            }
        }
        else
        {
            sum+=a[i];

            if (sum>=0)
            {
                s+=sum+1;
                sum=-1;
            }
        }
    }

    sum=0;

    for(ll i=0;i<n;i++)
    {
        if (i&1)
        {
            sum+=a[i];

            if (sum>=0)
            {
                k+=sum+1;
                sum=-1;
            }
        }
        else
        {
            sum+=a[i];

            if (sum<=0)
            {
                k+=abs(sum)+1;
                sum=1;
            }
        }
    }

    cout<<min(s , k);
    return 0;
}


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

int N;

int dp[101010];
int main(){
    cin >> N;
    for(int i = 0;i <= N;i++){
        dp[i] = 1e9;
    } 
    dp[0] = 0;
    for(int i = 6;i <= N;i *= 6){
        for(int j = i;j <= N;j++){
            dp[j] = min(dp[j],dp[j - i] + 1);
        }
    }
    for(int i = 9;i <= N;i *= 9){
        for(int j = i;j <= N;j++){
            dp[j] = min(dp[j],dp[j - i] + 1);
        }
    }

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


Measured memory_bytes: 640