akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
int main(){
int na[3],nb;
std::cin>>na[0]>>na[1]>>na[2];
if(na[1] > na[2]){
nb = na[2];
na[2] = na[1];
na[1] = nb;
}
if(na[0] > na[1]){
nb = na[1];
na[1] = na[0];
na[0] = nb;
}
if(na[1] > na[2]){
nb = na[2];
na[2] = na[1];
na[1] = nb;
}
std::cout<<na[0]<<" "<<na[1]<<" "<<na[2]<<std::endl;
return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	char s[51][51]={0};
	for(int i=0; i<h; i++){ scanf("%s", s[i]); }
	
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if( s[i][j] != '.' ){ continue; }
			int cnt=0;

			//上3か所
			for(int u=j-1; u<=j+1; u++){
				if( i-1 >= 0 && u >= 0 && s[i-1][u] == '#' ){ cnt++; }
			}
			//左
			if( j-1 >= 0 && s[i][j-1] == '#' ){ cnt++; }
			//右
			if( j+1 >= 0 && s[i][j+1] == '#' ){ cnt++; }
			//下3か所
			for(int u=j-1; u<=j+1; u++){
				if( i+1 >= 0 && u >= 0 && s[i+1][u] == '#' ){ cnt++; }
			}
			s[i][j] = 48+cnt;
		}
		printf("%s\n",s[i]);
	}
	return 0;
}

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

signed main(){
  int n;cin>>n;
  vector<int> a(n,0);
  for(int i=1;i<n;i++){
    int b;cin>>b;a[--b]++;
  }
  for(int i=0;i<n;i++)cout<<a[i]<<endl;
}


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

int main()
{
    string str1, str2;
    cin>>str1>>str2;
    sort(str1.begin() , str1.end());
    sort(str2.begin() , str2.end());
    reverse(str2.begin() , str2.end());
    if(str1 < str2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import product

N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i, j in product(range(N-M+1), range(N-M+1)):
    A_partial = [a[j:j+M] for a in A[i:i+M]]
    if A_partial == B:
        print('Yes')
        break
else:
    print('No')


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

using namespace std;

typedef long long ll;

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

	string S;
	cin >> S;

	int n = (int) S.size();
	ll dp[21][n];
	rep(j, n){
		if(S[j] == 'L'){
			dp[1][j] = j - 1;
		}else{
			dp[1][j] = j + 1;
		}
	}

	for(int i = 1; i < 20; i++){
		rep(j, n){
			dp[i+1][j] = dp[i][dp[i][j]];
		}
	}

	vector<ll> ans(n);
	rep(j, n) ans[dp[20][j]]++;

	cout << ans[0];
	rep(j, n-1){
		cout << " " << ans[j+1];
	}
	cout << endl;
}


Measured memory_bytes: 17616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

//b

int main() {
    string S;
    cin>>S;
    int l=sz(S);
    int ans=0;
    rep(i,l){
        int x=S.at(i)-'0';
        ans+=x;
        ans%=9;
    }
    if(ans==0){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3732
h,n = map(int,input().split())
a = [0 for _ in range(n)]
b = [0 for _ in range(n)]
for i in range(n):
    a[i],b[i] = map(int,input().split())
cost = [int(1e+9) for _ in range(h+1)]
cost[0] = 0
for i in range(h):
    for j in range(n):
        if i+a[j] <= h:
            cost[i+a[j]] = min(cost[i+a[j]],cost[i]+b[j])
        else:
            cost[-1] = min(cost[-1],cost[i]+b[j])
print(cost[-1])

Measured memory_bytes: 41708
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<String> weekList = new ArrayList<>();
		weekList.add("SUN");
		weekList.add("MON");
		weekList.add("TUE");
		weekList.add("WED");
		weekList.add("THU");
		weekList.add("FRI");
		weekList.add("SAT");

		String S = sc.next();
		int index = weekList.indexOf(S);

		System.out.println(7-index);

		sc.close();
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define MAX (ll)(1e5)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e18 + 3)
#define PI (double)(3.14159265)

using namespace std;
using ll = long long;

int main () {
	ll n;
	cin >> n;
	ll ar[n];
	ll ss = 0;
	for (ll i = 0; i < n; i++) {
		cin >> ar[i];
		ss += ar[i];
	}
	ll s = 0;
	ll mi = ss;
	for (ll i = 0; i < n; i++) {
		s += ar[i];
		if (abs (2 * s - ss) < mi) {
			mi = abs (2 * s - ss);
		}
	}
	cout << mi << "\n";
}
	



Measured memory_bytes: 1792
/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>*/
#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = {1,0,-1,0};
ll dy[4] = {0,1,0,-1};

int main(){
    ll n,k,ans=0;
	cin >> n >> k;
	vll v(n);
	rep(i,n)cin >> v[i];
	sort(reall(v));
	rep(i,k) ans += v[i];
	cout << ans << endl;
}  


Measured memory_bytes: 256
#include <array>
#include <cstddef>
#include <functional>
#include <type_traits>
#include <utility>

template <class Key, class T, Key Empty, std::size_t N,
	class Hash = std::hash<Key>>
	struct mu_hashmap {

	std::array<std::pair<Key, T>, N> table;
	Hash hash;

	explicit mu_hashmap(Hash hash = Hash()) : table(), hash(hash) {
		for (auto itr = table.begin(), end = table.end(); itr != end; ++itr) {
			itr->first = Empty;
		}
	}

	T& operator[](const Key key) {
		typename std::array<std::pair<Key, T>, N>::iterator itr =
			table.begin() + hash(key) % N;
		while (itr->first != key) {
			if (itr->first == Empty) {
				itr->first = key;
				break;
			}
			++itr;
			if (itr == table.end()) {
				itr = table.begin();
			}
		}
		return itr->second;
	}
};

#include<cstddef>
#include<cstdint>
#include<iostream>

int main() {
	using usize = std::size_t;
	using u32 = std::uint_fast32_t;
	using i64 = std::int_fast64_t;

	usize n;
	std::cin >> n;

	u32 ans = 0;
	i64 acc = 0;
	mu_hashmap<i64, u32, 200000ULL * 1000000000 + 1, 1ULL<<20> count;
	++count[acc];

	for (usize i = 0; i != n; ++i) {
		i64 a;
		std::cin >> a;

		acc += a;
		ans += count[acc];
		++count[acc];
	}

	std::cout << ans << std::endl;

	return 0;
}



Measured memory_bytes: 16640
// Special thanks to RCC.
#include <iostream>
#include <climits>
#include <queue>

template<typename T>
using max_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;

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

using lli = long long int;

int main() {
//    freopen("input.txt", "r", stdin);

    int N;
    lli res = LLONG_MIN;
    scanf("%d", &N);

    int a[3 * N];
    for (int I = 0; I < 3 * N; I++)
        scanf("%d", &a[I]);

    min_heap<int> min_pq;
    max_heap<int> max_pq;
    lli sum_left[N + 1], sum_right[N + 1];

    lli sum = 0;
    for (int I = 0; I < N; I++) {
        min_pq.push(a[I]);
        sum += a[I];
    }
    sum_left[0] = sum;
    // Calculate max sums for the reds cutting at the position K
    for (int I = 0 ; I < N; I++) {
        if (a[I + N] > min_pq.top()){
            sum -= min_pq.top();
            min_pq.pop();
            min_pq.push(a[I+N]);
            sum += a[I+N];
        }
        sum_left[I+1] = sum;
    }

    sum = 0;
    for (int I = (3 * N) - 1; I >= 2 * N; I--){
        max_pq.push(a[I]);
        sum += a[I];
    }
    sum_right[N] = sum;
    for (int I = N-1 ; I >= 0; I--) {
        if(a[I + N] < max_pq.top()){
            sum -= max_pq.top();
            max_pq.pop();
            sum += a[I+N];
            max_pq.push(a[I+N]);
        }
        sum_right[I] =  sum;
    }

    for (int I = 0; I <= N; I++) {
        res = std::max(res, sum_left[I] - sum_right[I]);
    }
    std::cout << res << "\n";

    return 0;
}

Measured memory_bytes: 3832
parseInt(x) = parse(Int,x)


function main()
  tmp = map(x -> parse(Int,x),split(readline()))
  N = tmp[1]
  M = tmp[2]
  mi,ma = map(x -> parse(Int,x),split(readline()))
  
  for line in readlines()
    A,B = line |> split |> x -> map(parseInt,x)
    ma = min(ma,B)
    mi = max(mi,A)
  end
  result = 0
  for i = 1:N
    if(mi <= i <= ma)
    	result += 1
    end
  end
  print(result)
end
main()

Measured memory_bytes: 168500
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.AbstractQueue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.AbstractCollection;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int M = in.nextInt();

            List<D.Item> list = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                D.Item item = new D.Item();
                item.A = in.nextInt();
                item.B = in.nextInt();
                list.add(item);
            }
            list.sort(Comparator.comparingInt(a -> a.A));

            long sum = 0;
            PriorityQueue<D.Item> que = new PriorityQueue<>((a, b) -> Integer.compare(b.B, a.B));
            for (int i = 1; i <= M; i++) {
                while (!list.isEmpty()) {
                    if (list.get(0).A > i) {
                        break;
                    }
                    que.add(list.remove(0));
                }
                if (!que.isEmpty()) {
                    D.Item item = que.remove();
                    sum += item.B;
                }
            }
            out.println(sum);
        }

        static class Item {
            int A;
            int B;

        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 42788
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    int h[n], a[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    sort(h, h+n);
    for(int i = 0; i < n-k+1; i++){
        a[i] = h[i+k-1] - h[i];
    }
    sort(a, a+(n-k+1));

    cout << a[0] << endl;
return 0;
}


Measured memory_bytes: 1024
def string():
    s = input()
    q = int(input())
    l = ''
    r = ''
    re = False
    for _ in range(q):
        t = input().split()
        if t[0] == '1':
            re = not re
        else:
            if re:
                if t[1] == '1':
                    r = r + t[2]
                else:
                    l = t[2] + l
            else:
                if t[1] == '1':
                    l = t[2] + l
                else:
                    r = r + t[2]
    s = l + s + r
    if re:
        s = s[::-1]
    print(s)
string()

Measured memory_bytes: 4552
import sys
import math
from collections import defaultdict,deque
from itertools import permutations
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()
sys.setrecursionlimit(10**6)
"""========main code==============="""

t=1
for _ in range(t):
    a,b,c=ml()
    k=ii()
    ans="No"
    while(k and b<=a):
        b*=2
        k-=1
    while(k and c<=b):
        c*=2
        k-=1
    if(c>b and b>a):
        ans="Yes"
    print(ans)    
    

Measured memory_bytes: 65272
//Catchharsh
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (int x,int n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x),n/2);
        else
        return x*power((x*x),(n-1)/2); 
    }
    vector<ll> seve;
    void  seveprime()
    {
      int prime[1000000]={0};
      for(int i=2;i*i<1000000;i++)
       {
        if(prime[i]==0)
         {
      	  for(int j=i*2;j<=1000000;j+=i)
           prime[j]=1;
         }
       }
       for(int i=2;i<=1000000;i++)
       {
       	if(prime[i]==0)
       		seve.pb(i);
       }
    }
    pair<ll,ll>  dp[3001][3001];
    int main()
    {   
         IOS; 
         ll n,m,i,j,k;
         cin>>n;
         vector<ll> v(n+1);
         for(i=1;i<=n;i++)
         	cin>>v[i];
         for(i=0;i<=n;i++)
         {
         	for(j=0;j<=n;j++)
         	{
         		dp[i][j].F=-1;
         		dp[i][j].S=-1;
         	}
         }
         for(i=1;i<=n;i++)
            {dp[i][i].F=v[i];dp[i][i].S=0;}
         // for(i=1;i<n;i++)
         // {
         // 	for(j=1;j<=n;j++)
         // 	{
         // 		if(j<i)
         // 			continue;
         //       if(i==j)
         //       	continue;
         // 		dp[i][j].F=max(dp[i+1][j].S+v[i],dp[i][j-1].S+v[j]);
         // 		if(dp[i][j].F==(dp[i+1][j].S+v[i]))
         // 			dp[i][j].S=dp[i+1][j].F;
         // 		else
         // 			dp[i][j].S=dp[i][j-1].F;
         // 		//cout<<dp[i][j].F<<" "<<dp[i][j].S<<endl;
         // 	}
         // }
       for(i=1;i<=n;i++)
       {
       	  for(j=1;j<=n;j++)
       	  {
       	  	k=i+j;
       	  	if(k<=n)
       	  	{
       	  	dp[j][k].F=max(dp[j+1][k].S+v[j],dp[j][k-1].S+v[k]);
       	  	  if(dp[j][k].F==dp[j+1][k].S+v[j])
       	  	  	dp[j][k].S=dp[j+1][k].F;
       	  	  else
       	  	  	dp[j][k].S=dp[j][k-1].F;
       	    }
       	  }
       }
         //   for(i=1;i<=n;i++)
         // {
         // 	for(j=1;j<=n;j++)
         // 	{
         // 		cout<<dp[i][j].F<<" "<<dp[i][j].S<<"     ";
         // 	}
         // 	cout<<endl;
         // }
         cout<<dp[1][n].F-dp[1][n].S;

     
    }

Measured memory_bytes: 141056
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

long long solve(long long N, long long M){
    if(N == 1 && M == 1) return 1;
    if(N == 1) return M - 2;
    return (N-2)*(M-2);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N, M;
    cin >> N >> M;
    if(N > M) swap(N, M);
    cout << solve(N, M) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

constexpr int mod = 1000000007;

// n = 12: [(2, 2), (3, 1)]
vector<pair<ll, int>> factorize(ll n) {
  vector<pair<ll, int>> res;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i) continue;
    res.emplace_back(i, 0);
    while (n % i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n, 1);
  return res;
}

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

  ll n;
  cin >> n;

  auto f = factorize(n);

  ll ans = 0;
  for (auto& p : f) {
    int num = p.second;
    int x = 1;
    while (num >= x) {
      num -= x;
      ans++;
      x++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=3e5,INF=1e8;
int N,p[MAX_N];
vector<int> piv;
int main(){
	cin>>N;
	REP(i,N){
		cin>>p[i];
		p[i]--;
	}
	int l,r;
	l=0;
	REP(i,N){
		if (p[i]==i){
			piv.push_back(i);
		}
	}
	bool ans=true;
	auto ite=piv.begin();
	while(l<N){
		if (ite==piv.end()){
			ans=false;
			break;
		}
		if (*ite==l){
			l++;
			ite++;
			continue;
		}
		if (*ite>l+1){
			ans=false;
			break;
		}
		while(1){
			if (ite+1==piv.end()){
				break;
			}
			if (*(ite+1)==*ite+1){
				ans=false;
				goto BREAK;
			}
			if (*(ite+1)>*ite+2){
				break;
			}
			if (*ite+3>=N){
				break;
			}
			if (ite+2==piv.end() || *(ite+2)>*ite+3){
				ite++;
			}else{
				break;
			}
		}
		r=*ite+2;
		if (r>N){
			ans=false;
			break;
		}
		int u,v;
		u=v=-1;
		for(int i=l;i<r;i+=2){
			if (l<= p[i] && p[i]<r){
				if (p[i]>i){
					if (u==-1){
						u=p[i];
					}else{
						if (u<p[i]){
							u=p[i];
						}else{
							ans=false;
							goto BREAK;
						}
					}
				}else{
					if (v==-1){
						v=p[i];
					}else{
						if (v<p[i]){
							v=p[i];
						}else{
							ans=false;
							goto BREAK;
						}
					}
				}
			}else{
				ans=false;
				goto BREAK;
			}
		}
		l=r;
		ite++;
	}
	BREAK:
	cout<<(ans ? "Yes" : "No")<<endl;
	return 0;
}

Measured memory_bytes: 3572
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
applyBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
applyBin op f g x = op (f x) $ g x
applyUni :: (a -> b -> c) -> (a -> b) -> a -> c
applyUni op f x = op x $ f x
applyTuple :: (a -> b, a -> c) -> a -> (b, c)
applyTuple (f,g) a = (f a, g a)
-- end of templete

f ([x,y]:ps) = f' 0 ps
  where
    f' r ([x1,y1]:ps'@([x2,y2]:_)) = let s = abs . (/2) $ (x1-x)*(y2-y) - (x2-x)*(y1-y) in f' (r+s) ps'
    f' r _ = r

main = f . map (map readDouble . wordsBy (==',')) . lines <$> getContents >>= print 

Measured memory_bytes: 3988
N = int(input())

a = input().rstrip().split(" ")
for i in range(N):
    a[i] = int(a[i])
    
cnt = 0
#print(a)
for i in range(N):
    if i == 0:
        continue
    else:
        if a[i] >= a[i - 1]:
            continue
        else:
            cnt += (a[i - 1] - a[i])
            a[i] = a[i - 1]

print(cnt)

Measured memory_bytes: 25204
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LLI(): return [int(x) for x in sys.stdin.readlines()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from bisect import bisect_left

def main():
    N, Q = LI()
    XST = []
    for _ in range(N):
        s, t, x = LI()
        XST.append([x, s, t])
    XST.sort()
    D = LLI()
    ans = [-1] * Q
    nexts = [-1] * Q
    for x, s, t in XST:
        i = bisect_left(D, s - x)
        end = bisect_left(D, t - x)
        while i < end:
            if nexts[i] == -1:
                ans[i] = x
                nexts[i] = end
                i += 1
            else:
                p = i
                i = nexts[i]
                nexts[p] = max(nexts[p], end)
    for y in ans:
        print(y)
    return

main()


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

int main(){
 	int n,k;
  	cin >> n;
  	cin >> k;
  	int h[n];
    int dp[n];
  	dp[0]=0;
  	for(int i=0;i<n;i++){
    	cin >> h[i];
		if(i==0)
          	dp[0]=0;
  		else
  			dp[i]=INT_MAX;
    }
        
   	for(int i=0; i<n;i++){
     for(int j=1;j<=k && i+j<n ;j++){
     	dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
     }
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_Training
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            Console.WriteLine((n + 1) / 2);
        }
    }
}


Measured memory_bytes: 11092
N = int(input())
xyh = sorted([list(map(int,input().split())) for _ in range(N)], key = lambda x: -x[2])
for Cx in range(101):
  mx, my, mh = xyh[0]
  for Cy in range(101):
    H = mh + abs(mx - Cx) + abs(my - Cy)
    if(all(h == max(H - abs(x - Cx) - abs(y - Cy), 0) for x,y,h in xyh)):
      print(Cx, Cy, H)
      exit()


Measured memory_bytes: 3064
(defun collatz (n)
    (if (evenp n)
        (/ n 2)
        (+ (* n 3) 1)))

(defun count-step (n c)
    (if (and (= c 1) (or (= n 1) (= n 2)))
        4
        (if (= n 1)
            (+ c 1)
            (count-step (collatz n) (+ c 1)))))

(let ((n (read)))
    (princ (count-step n 1)))


Measured memory_bytes: 3816
require 'mathn'

class Tank
	def initialize(*args)
		@l_x, @r_x, @l_height, @r_height = args
		@water = 0
		@dw = 0
	end

	def area
		(@r_x - @l_x) * 30
	end

	def lower_height
		@l_height < @r_height ? @l_height : @r_height
	end

	def time_to_fill
		@dw == 0 ? Float::INFINITY : (lower_height * area - @water) / @dw	
	end

	def water_height
		@water / area
	end

	attr_accessor :l_x, :r_x, :l_height, :r_height, :water, :dw
end

test_num = gets.to_i

test_num.times {
	n = gets.to_i
	board = (1..n).map{gets.split.map &:to_i}
	board.unshift [0, 50]
	board << [100, 50]

	m = gets.to_i
	faucet = (1..m).map{gets.split.map &:to_i}

	l = gets.to_i
	query = (0..l-1).map{|i| [i] + gets.split.map(&:to_i)}.sort_by(&:last)

	tanks = board.each_cons(2).map{|(x1, h1), (x2, h2)|
		Tank.new(x1, x2, h1, h2)	
	}

	faucet.each{|fx, a|
		tanks.find{|t| fx < t.r_x}.dw += a
	}


	time = 0
	ans = []
	loop do	
		dt = tanks.map{|tank|
			tank.time_to_fill	
		}.min

		while !query.empty? && time + dt >= query[0][2] 
			i, qx, t = query.shift
			tank = tanks.find{|t| qx < t.r_x}
			ans[i] = (tank.water + tank.dw * (t - time)) / tank.area
		end
		break if query.empty?

		tanks.each{|tank|
			tank.water += dt * tank.dw
		}

		tanks.sort_by.with_index{|t, i| [-t.water_height, i]}.each{|tank|
			next if tank.water_height < tank.lower_height

			if tank.water_height == 50
				tank.dw = 0
			elsif tank.l_height < tank.r_height
				l_tank = tanks.find{|t| t.r_x == tank.l_x}
				if l_tank.water_height == tank.water_height
					raise
				else
					l_tank.dw += tank.dw
					tank.dw = 0
				end
			else
				r_tank = tanks.find{|t| t.l_x == tank.r_x}
				if r_tank.water_height == tank.water_height
					tank.water += r_tank.water
					tank.dw += r_tank.dw
					tank.r_x = r_tank.r_x
					tank.r_height = r_tank.r_height
					r_tank.water = -1
				else
					r_tank.dw += tank.dw
					tank.dw = 0
				end
			end
		}
		tanks.reject!{|t| t.water < 0}

		time += dt
	end	

	puts ans.map(&:to_f)

}

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

int main() {
    int N, K;
    cin>>N>>K;
    long a[N];
    for(int i=0;i<N;++i){
        cin>>a[i];
    }

    map<int, int> S;
    long ans = 1e12;
    long tmpans;
    for(int bit=0;bit<(1<<N);++bit){
        tmpans = 0;
        for(int i=0;i<N;++i){
            S[i]=0;
        }
        int num = 0;
        for(int i=0;i<N;++i){
            if(bit&(1<<i)){
                num++;
                S[i]=1;
            }
        }
        if(num!=K)continue;
        if(S[0]==0)continue;
        long height = a[0];
        for(int i=1;i<N;++i){
            if(S[i]==1){
                if(height>=a[i]){
                    tmpans += height - a[i] + 1;
                    height++;
                }
                else height = a[i];
            }
            else{
                if(height<a[i])height = a[i];
            }
        }
        if(tmpans<ans)ans = tmpans;
    }
    cout<<ans<<endl;
}


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

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define sum(v) accumulate(all(v), 0)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define MOD 1000000007

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
     
using namespace std;

main {
  vector<double> t;
  double h;
  while(cin>>h) t.pb(h);
  sort(all(t));
  cout<<prec(32)<<t[t.size()-1]-t[0]<<endl;
  bye;
}

Measured memory_bytes: 3268
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

LL a, b, c, d;

LL calc(LL n){
	LL ret = n;
	ret -= n/c;
	ret -= n/d;
	ret += n/(lcm(c, d));
	return ret;
}

int main(){
	cin >> a >> b >> c >> d;
	cout << calc(b) - calc(a - 1) << endl;
}

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

int absolute(int a,int b){
	if(a-b<0) return b-a;
    else return a-b;
}
int Manha(vector<int>a,vector<int> b){
	return absolute(a.at(0),b.at(0))+absolute(a.at(1),b.at(1));
}
int main()
{
  int N,M; cin >> N >> M;
  vector<vector<int>> place(N,vector<int>(2));
  for(int i=0;i<N;i++){
  	cin >> place.at(i).at(0) >> place.at(i).at(1);
  }
  vector<vector<int>> point(M,vector<int>(2));
  for(int i=0;i<M;i++){
  	cin >> point.at(i).at(0) >> point.at(i).at(1);
  }
  
  for(int i=0;i<N;++i){
    int localmin = 1000000011;
    int temp = 51;
  	for(int j=0;j<M;++j){
      if( Manha(place.at(i),point.at(j)) < localmin ){
        localmin = Manha( place.at(i),point.at(j) );
        temp = j;
      }else if(Manha(place.at(i),point.at(j)) == localmin){
      	temp = min(temp,j);
      }
    }
    cout << temp+1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
  
#define repd(i,a,b) for ((i)=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for((i)=0; i<(n); ++i)
#define FOR(i, a, b) for((i)=(a); i<(b); ++i)
#define FORR(i, a, b) for((i)=(b); i>=(a); i--)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000; int i;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  int i=0,j=0;
  ll ans=0;
  ll tmp;
  int N,M; cin >> N >> M;
  ll K; cin >> K;
  vector<ll>A(N,0); cin >> A[0];
  FOR(i,1,N){cin >> tmp; A[i]=A[i-1]+tmp;} 
  vector<ll>B(M,0); cin >> B[0];
  FOR(i,1,M){cin >> tmp; B[i]=B[i-1]+tmp;} 

  int onlyA=0, onlyB=0;
  FORR(i,0,N-1){if(A[i]<=K){onlyA=i+1;break;}}
  FORR(i,0,M-1){if(B[i]<=K){onlyB=i+1;break;}}

  ans = max(onlyA,onlyB);
  int tmpM=M-1;
  rep(i,N){
      if(K<A[i]){break;}
      FORR(j,0,tmpM){
          if(A[i]+B[j]<=K){
              ll ans_tmp=i+j+2;
              ans=max(ans,ans_tmp);tmpM=j;break;}
      }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6416
#include <bits/stdc++.h>
using namespace std;
bool ok;
void dfs(int now)
{
    if (now == 0)
        ok = true;
    if (now < 0 || ok)
        return;
    dfs(now - 4);
    dfs(now - 7);
}
int main()
{
    ok = false;
    int n;
    cin >> n;
    dfs(n);
    cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import bisect
A,B,Q = map(int,input().split())
INF = 10**18
s = [-INF]+[int(input()) for i in range(A)]+[INF]
t = [-INF]+[int(input()) for i in range(B)]+[INF]
s.sort()
t.sort()
answer = []
for i in range(Q):
    x = int(input())
    sk = bisect.bisect_left(s,x)-1
    tk = bisect.bisect_left(t,x)-1
    ptn1 = abs(s[sk]-x) + min(abs(t[tk]-s[sk]),abs(t[tk+1]-s[sk]))
    ptn2 = abs(s[sk+1]-x) + min(abs(t[tk]-s[sk+1]),abs(t[tk+1]-s[sk+1]))
    ptn3 = abs(t[tk]-x) + min(abs(s[sk]-t[tk]),abs(s[sk+1]-t[tk]))
    ptn4 = abs(t[tk+1]-x) + min(abs(s[sk]-t[tk+1]),abs(s[sk+1]-t[tk+1]))
    answer.append(min(ptn1,ptn2,ptn3,ptn4))
for i in answer:
    print(i)


Measured memory_bytes: 17400
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

n = int(input())
A = list(map(int, input().split()))

acc =[0] * (n + 1)
for i in range(1, n + 1):
    acc[i] = acc[i - 1] + A[i - 1]

ans = INF
for i in range(1, n):
    now = abs(acc[i] - acc[0] - (acc[n] - acc[i]))
    ans = min(ans, now)
print(ans)


Measured memory_bytes: 32172
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fr(i, a, b) for(int i=a; i>=b; i--)
#define l long int
#define max 200000
using namespace std;
//ll MOD=1000000000000007;
int main()
{
l n,i;
cin>>n;
ll a[n],cnt=0;

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

for(i=1;i<n;i++)
{
	if(a[i]>=a[i-1])
	continue;
	else{
		cnt+=(a[i-1]-a[i]);
		a[i]=a[i-1];
	}
}
	cout<<cnt;
}






Measured memory_bytes: 5168
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
    int n;
    cin >> n;
    string s;
    cin >>s;
    vector<int>e(n+1,0),w(n+1,0);
    int maxw = 0;
    for(int i=1;i<=n;i++){
        if(s.at(i-1)=='W')e.at(i)++;
        if(s.at(i-1)=='E')maxw++;
        e.at(i)+=e.at(i-1);
    }
    for(int i=0;i<=n;i++){
        if(i==0){
            w.at(i)=maxw;
            continue;
        }
        if(s.at(i-1)=='E'&&i!=0)maxw--;
        w.at(i)=maxw;
    }
    ll ans = 10e14;
    for(int i=0;i<=n;i++){
        ll che = w.at(i)+e.at(i);
        ans = min(che,ans);
    }   
    cout << ans << endl;
}



Measured memory_bytes: 3076
#include <algorithm>
#include <iostream>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

const int MAX_N = 300;
const int MAX_K = 300;

ll dp[MAX_N + 2][MAX_N + 2];

void print_dp(int n, int k, ll table[MAX_N + 2][MAX_N + 2]) {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < k; j++) {
            cout << table[i][j] << " ";
        }
        cout << endl;
    }
}

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

    vector<int> h(N + 1, 0);
    for (int i = 1; i <= N; i++) {
        cin >> h[i];
    }

    for (int i = 0; i < MAX_N + 2; i++) {
        for (int j = 0; j < MAX_N + 2; j++) {
            // Avoid to use LONG_LONG_MAX
            // because it causes overflow.
            dp[i][j] = LONG_LONG_MAX / 2;
        }
    }

    // dp[x][y]: size is x, the most right one is y.
    dp[0][0] = 0;
    for (int x = 1; x <= N; x++) {
        for (int y = 1; y <= N; y++) {
            for (int z = 0; z < y; z++) {
                chmin(dp[x][y], dp[x - 1][z] + max(0, h[y] - h[z]));
            }
        }
    }

    // print_dp(N + 1, N + 1, dp);

    ll min = LONG_LONG_MAX;
    // x should start zero for edge case
    // where N == K (returning always zero.)
    for (int x = 0; x <= N; x++) {
        chmin(min, dp[N - K][x]);
    }

    cout << min << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int X,Y,Z;
    cin>>X>>Y>>Z;
    swap(X,Y);
    swap(X,Z);
    cout<<X<<" "<<Y<<" "<<Z;
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main(){
    input!{
        n:i64,
        an:[i64;5],
    }
    let min = an.iter().min().unwrap();
    let base = if n <= *min {
        1
    } else {
        if n % min == 0 {
            n / min
        } else {
            n / min + 1
        }
    };
    println!("{}",base+4);
}

Measured memory_bytes: 4352
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;

int main()
{
    int n,x;
    int ans=0;
    int now=0;
    string s;
    in n>>s;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='I')now++;
        else now--;

        ans=max(ans,now);

    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
p [(h,w=gets.split.map &:to_i),[w,h]].map{|t,u|(t/3..t/3+2).map{|i|[[u,t-i],[t-i,u]].map{|x,y|a=[x/2*y,(x+1)/2*y,u*i];a.max-a.min}}}.flatten.min

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using dijkstra = priority_queue<T, vector<T>, greater<T>>;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fbo find_by_order  // k th index
#define ook order_of_key   // strictly smaller than k
#define PI acos(-1.0)
#define inf 0x3f3f3f3f
#define max_ull 18446744073709551615
#define max_ll 9223372036854775807
#define lead_zero(x) __builtin_clzll(x)
#define trail_zero(x) __builtin_ctzll(x)
#define total_1s(x) __builtin_popcountll(x)
#define first_1(x) __builtin_ffsll(x)
#define log2_(x) __builtin_clz(1) - __builtin_clz(x)
#define isLeap(x) ((x % 400 == 0) || (x % 100 ? x % 4 == 0 : false))
#define QUERY           \
    int test;           \
    scanf("%d", &test); \
    for (int _T = 1; _T <= test; _T++)
#define FAST ios_base::sync_with_stdio(0), cin.tie(0)
#define all(v) v.begin(), v.end()
#define reunique(v) v.resize(std::unique(all(v)) - v.begin())
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define ff first
#define ss second
#define MERGE(v1, v2, v) merge(all(v1), all(v2), back_inserter(v))
#define MP make_pair
#define EB emplace_back
#define read freopen("input.txt", "r", stdin)
#define write freopen("output.txt", "w", stdout)
#define in_range(v, r, l) upper_bound(all(v), r) - lower_bound(all(v), l)
#define LCM(a, b) (a / __gcd(a, b)) * b;

ll rdn(int y, int m, int d) {
    /* Rata Die day one is 0001-01-01 */
    if (m < 3)
        y--, m += 12;
    return 365 * y + y / 4 - y / 100 + y / 400 + (153 * m - 457) / 5 + d - 306;
}
/* Direction arrays */
/*int dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1};                             */  // 4Direction
/*int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1};         */  // 8Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1};     */  // KnightDirection
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1};                */  // HexagonalDirection
/* int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; */


int main() {
    FAST;
    int k,n;
    ll ans1= 0,ans2 = 0;
    cin>>k>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    int maxdist = 0;
    int point = 0;
    for(int i=1;i<n;i++){
        if(v[i]-v[i-1]>maxdist){
            maxdist = v[i]-v[i-1];
            point = i;
        }
    }
    for(int i=point;i<n-1;i++){
        ans1+=v[i+1]-v[i];
    }
    for(int i=0;i<point-1;i++){
        ans1+=v[i+1]-v[i];
    }
    if(point!=0){
        ans1+=(k-v[n-1]+v[0]);
    }
    for(int i=1;i<n;i++){
        ans2+=v[i]-v[i-1];
    }
    cout<<min(ans1,ans2)<<"\n";
}


Measured memory_bytes: 1024
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <math.h>

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

typedef int long long ill;
typedef int long il;

using namespace std;
int main()
{
    int n;
    char s[100000];
    cin>>n;
    cin>>s;

    for(int i=0;i<strlen(s);i++){
        s[i]+=n;
        while(s[i]>'Z'){
            s[i]+=-'Z'+'A'-1;
        }
    }
    printf("%s\n",s);

    return 0;
}

Measured memory_bytes: 256
h,w,d = map(int, input().split())
a = []

for i in range(h):#h:高さ
    a.append([int(m) for m in input().split()])

q = int(input())
lr = []
for i in range(q):#h:高さ
    lr.append([int(m) for m in input().split()])

rea = []
for i in range(h * w):
    rea.append([])


for i in range(h):
    for j in range(w):
        rea[w*i+j].append(a[i][j])
        rea[w*i+j].append(i)
        rea[w*i+j].append(j)

rea.sort()

pre = []
for i in range(h*w):
    pre.append([])
p = 0
for i in range(h):
    if p == 1:
        break
    for j in range(w):
        if w * i + j + 1 <= d:
            lmn = 0
            pre[w * i + j].append(lmn)

            for k in range(0,h*w,d):
                if w*i+j + d + k < h*w:
                    lmn += abs(rea[w*i+j + k][1] - rea[w*i+j+d + k][1]) + abs(rea[w*i+j + k][2]- rea[w*i+j+d + k][2])
                    pre[w*i+j].append(lmn)
                else:
                    break
        else:
            p = 1
            break

for i in range(q):
    print(pre[(lr[i][0] - 1) % d][(lr[i][1] - 1)//d] - pre[(lr[i][0] - 1) % d][(lr[i][0] - 1)//d])

Measured memory_bytes: 47332
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    string a,b;
    cin>>a>>b;
    if(a.length()>b.length())
    {
        cout<<"GREATER";return;
    }
    else if(b.length()>a.length())
    {
        cout<<"LESS";return;
    }
    for(int i=0;i<a.length();i++)
    {
        if(a[i]>b[i])
        {
            cout<<"GREATER";return;
        }
        else if(a[i]<b[i])
        {
            cout<<"LESS";return;
        }
    }
    cout<<"EQUAL";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
//#define int long long int
#define ll long long int
#define ldouble long double
#define vin vector<int> 
#define rep(i,a,n) for(i=(a);i<(n);i++)
#define INF (int)100007

//setprecision()<<

using namespace std;

void fin(int i,int n,vin &a){
    rep(i,0,n){
        cin>>a.at(i);
    } 
} 

int digit(ll n ){
    int dig=0;
    while(n>0){
        n/=10;
        dig++;
    }
    return dig;
}

signed main() {
    ll N;
    cin>>N;
    ll A;
    int sA,sB;
    int res=INF;
    rep(A,1,(ll)sqrt(N)+1){
        if(N%A==0){
            sA=digit(A);
            sB=digit(N/A);
            res=min(res,max(sA,sB));
            // cout<<"sA "<<sA<<"sB "<<sB<<endl;
            // cout<<"res "<<res<<endl;
        }
        
    }

    cout<<res<<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++)

int main() {
  int N, A = 0, B = 0, sum = 0;
  cin >> N;
  rep(i, N){
    cin >> A >> B;
    sum = sum + B - A + 1;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3552
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
#define rep_re(i,s,n)for(int i = n;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_M = 100001;

double v[51];
int main() {
	ll n; cin >> n;
	rep(i, 0, n) cin >> v[i];

	sort(v, v + n);
	double ans = 0;
	rep(i, 1, n) {
		v[i] = (v[i] + v[i - 1]) / 2;
	}
	printf("%7f", v[n - 1]);

	return 0;
}


Measured memory_bytes: 256