akhauriyash/Code-Regression huggingface dataset:
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 100005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int h[SIZE];
    REP(i,n){
        cin >> h[i];
    }
    ll ans[SIZE];
    fill(ans+1,ans+n,INF);
    ans[0] = 0;
    REP(i,n-1){
        ans[i+1] = min(abs(h[i]-h[i+1])+ans[i],ans[i+1]);
        //REP(j,n)cout << ans[j] << " ";
        //cout << endl;
        ans[i+2] = min(abs(h[i]-h[i+2])+ans[i],ans[i+2]);
        //REP(j,n)cout << ans[j] << " ";
        //cout << endl;
    }
    cout << ans[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <bitset>
#define ll long long
using namespace std;


int main(){
  //cout<<1<<endl;
  int x1,x2,y1,y2=0;
  int x3,x4,y3,y4=0;
  
  cin>>x1>>y1>>x2>>y2;
  
  int vx=x2-x1; int vy=y2-y1;
  x3=x2-vy;y3=y2+vx;
  x4=x1-vy;y4=y1+vx;
  cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
  
 //cout<<"YES"<<endl;return 0;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int t,n,i,s;
  for(i=0;i<4;i++){
    scanf("%d%d",&t,&n);
    if(t==1)s=6000*n;
    else if(t==2)s=4000*n;
    else if(t==3)s=3000*n;
    else if(t==4)s=2000*n;
    printf("%d\n",s);
  }
  
  return 0;
}

Measured memory_bytes: 600
def main():
 from heapq import heappush, heappop
 import sys
 r=sys.stdin.readline
 def g(n,E,S,G):
  F=[1e7]*-~n;F[S],H=0,[(0,S)]
  while H:
   c,u=heappop(H)
   if u==G:return c
   for f,v in E[u]:
    t=c+f
    if t<F[v]:F[v]=t;heappush(H,(t,v))
  return-1
 def s(n,k):
  E=[[]for _ in[0]*-~n]
  for _ in[0]*k:
   f=r();p=map(int,f[2:].split())
   if'0'==f[0]:print(g(n,E,*p))
   else:c,d,e=p;E[c]+=[(e,d)];E[d]+=[(e,c)]
 for e in iter(r,'0 0\n'):s(*map(int,e.split()))
if __name__ == '__main__':
    main()


Measured memory_bytes: 6304
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define of(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
const ll mod=1e9+7;
int main()
{
  IOS
  ll r;
  cin>>r;
  double p=2*3.14159265*r;
  cout<<p<<kk;
  return 0;
}

Measured memory_bytes: 3800
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

vector<int> E[110000];

int main(){
    long long int N, K;
    cin >> N >> K;
    if(N == 1){
        cout << K << endl;
        return 0;
    }
    for(int i = 0; i < N - 1; i++){
        int a, b;
        cin >> a >> b;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    long long int ans = K * (K - 1) % MOD;
    for(int i = 1; i <= N; i++){
        long long int sz = E[i].size();
        for(int j = 0; j < sz - 1; j++){
            ans *= K - 2 - j;
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6392
//2020-05-03 21:21:37
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
ll f(ll x){
    return x*x*x*x*x;
}
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    ll X; cin >> X;
    int A = 1;
    while (f(A) - f(A-1) < 1000000000)
    {
        for (int B = -200; B < 200; B++)
        {
            if (f(A) - f(B) == X)
            {
                cout << A << " " << B << endl;
                return 0;
            }
        }
        A++;
    }
    
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int main() {
    string s;
    cin >> s;

    string t;
    t = s;

    int *a, *b;
    a = new int[s.size()];
    b = new int[s.size()];
    char p;
    if(s[0] == 'W') p = 'W';
    else p = 'B';
    int count = 0; 
    for(int i = 1; i < s.size(); i++) {
        if(p != s[i]) {
            count++;
            p = s[i];
        }
    }

    cout << count << endl;
}

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

  using namespace std;
  using namespace std::chrono; 

  typedef long long int ll;

  #define MOD (ll)(1e9+7)
  #define endl "\n"
  #define pb push_back
  #define TEST_CASES  ll t;cin>>t;while(t--)
  #define forn(i,a,n) for (int i = a; i < n; ++i)
  #define f first
  #define s second
  #define all(x) x.begin(), x.end()
  
  ll powD(ll x,ll y){
    ll res = 1;
    while(y > 0){
      if(y & 1)
        res = (res*x)%MOD;
      x = (x*x)%MOD;
      y = y>>1;
    }
    return res;
  }


  int main()
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    bool flag = 0;
    forn(i,0,k+1){
      forn(j,0,k+1){
        forn(p,0,k+1){
          if(i + j + p == k){
            int ta = a,tb = b,tc = c;
            forn(m,0,i)
              ta *= 2;
            forn(m,0,j)
              tb *= 2;
            forn(m,0,p)
              tc *= 2;
            if(tc > tb && tb > ta)
              flag = 1;
          }
        }
      }
    }
    if(flag)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
   
  

Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

char s[50];

int main()
{
	scanf("%s",s);
	if(s[0]=='S') printf("Cloudy\n");
	else if(s[0]=='C') printf("Rainy\n");
	else printf("Sunny\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n;
    cin>>n;
    vl as(n);
    cin>>as;

    vl ss(n + 1);
    rep(i, n) ss[i + 1] = ss[i] + as[i];
    map<ll, ll> mp;
    rep(i, n + 1) {
        mp[ss[i]]++;
    }
    ll ans = 0;
    for (auto m : mp) {
        ans += m.second * (m.second - 1) / 2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 15872
import java.util.*;

public class Main {
	double EPS = 10.e-08;
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			char [] data = sc.next().toCharArray();
			int n = data.length;
			int [] res = new int[n];
			// count L
			int count = 0;
			int rind = 0;
			for(int i =0; i < n; i++){
				if(data[i] == 'R') {
					rind = i;
					count =0;
				}
				else {
					count++;
					if(count % 2 == 0){
						res[rind]++;
					}
					else{
//						debug(rind);
						res[rind+1]++;
					}
				}
			}
//			debug(res);
			// count R
			count = 0;
			int lind = n-1;
			for(int i =n-1; i >= 0; i--){
				if(data[i] == 'L') {
					lind = i;
					count =0;
				}
				else {
					count++;
					if(count % 2 == 0){
						res[lind]++;
					}
					else{
						res[lind-1]++;
					}
				}
			}
			StringBuilder sb = new StringBuilder();
			for(int i = 0; i < n; i ++){
				sb.append(" " + res[i]);
			}
			System.out.println(sb.substring(1));
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 44020
N = int(input())
A = [[int(i) for i in input().split()] for j in range(2)]

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

for i in range(1, N):
    A[1][i] = max(A[0][i], A[1][i-1]) + A[1][i]

print(A[1][N-1])

Measured memory_bytes: 3064
A,B=map(int,input().split())
vA=[]
vB=[]
for i in range(10001):
    if int(i*0.08) == A: vA.append(i)
    if int(i*0.1) == B: vB.append(i)
        
ans=10000

for i in vA:
    if i in vB:ans=min(ans,i)
for i in vB:
    if i in vA:ans=min(ans,i)

if ans==10000: ans=-1        

print(ans)

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

int main(){
int N, a[100001];
int b[100001];//b[i]=1 : button i was ON.
int pos=1, count=0;
  
  cin >> N;
  for(int i=1; i<=N; ++i) {
    cin >> a[i];
    b[i] = 0;
  }
  
  while(pos != 2) {
    count++;
    b[pos] = 1;
    pos = a[pos];
    if(b[pos] == 1) {
      count = -1;
      break;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1152
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    vector<ll> B(N+1);
    FOR(i, 0, N){
        ll a;
        cin >> a;
        A[i] = a;

        B[a] = i;
    }
    // vprint(A);
    // vprint(B);

    set<ll> se;
    se.insert(-1);
    se.insert(N);

    ll sum = 0;

    FOR(a, 1, N+1){
        ll index = B[a];
        // br();
        // cout << "a " << a << " index " << index << endl;

        //auto it = lower_bound(ALL(se), index);
        auto it = se.lower_bound(index);
        
        ll right = *it;
        it--;
        ll left = *it;
        // pn(left);
        // pn(right);

        sum += a * (right-index) * (index-left);

        se.insert(index);
    }

    p(sum);

    
    return 0;
}

Measured memory_bytes: 12800
N, M = map(int, input().split(" "))

cards = list(map(int, input().split(" ")))
cards.sort()

replaces = []
for _ in range(M):
	b, c = map(int, input().split(" "))
	replaces.append((c, b))

replaces.sort()
replaces.reverse()

#print(cards)
#print(replaces)

replace_index = 0
for c, b in replaces:
	ended = False
	for i in range(b):
		if replace_index >= N:
			ended = True
			break
		elif cards[replace_index] < c:
			cards[replace_index] = c
			replace_index += 1
		else:
			ended = True
			break
	if ended:
		break

#print(cards)
print(sum(cards))


Measured memory_bytes: 20936
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) \
    do           \
    {            \
    } while (0)
#define dump(x) \
    do          \
    {           \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

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

void solve()
{
    int n;
    cin >> n;
    VI cnt(9);
    int r;
    REP(i, 0, n)
    {
        cin >> r;
        if (r < 3200)
            cnt[r / 400]++;
        else
            cnt[8]++;
    }
    int sum = 0;
    REP(i, 0, 8)
    {
        sum += (cnt[i] > 0);
    }
    if (cnt[8])
    {
        cout << max(1, sum) << " " << sum + cnt[8] << endl;
    }
    else
    {
        cout << sum << " " << sum << endl;
    }
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>                                                       
                                                                          
using namespace std;                                                      
                                                                          
void judgment(int,int,int);                                               
                                                                          
int main (void) {                                                         
  int a, b, c;                                                            
  cin >> a >> b >> c;                                                     
  judgment(a,b,c);                                                        
}                                                                         
                                                                          
void judgment(int x,int y,int z) {                                        
  if (x < y && y < z) {                                                   
    cout << "Yes" << endl;                                                
  } else {                                                                
    cout << "No" << endl;                                                 
  }                                                                       
}                                                                         
                                                                          
                                                                          
                                    

Measured memory_bytes: 3076
(defun read-list-from-string (str)
  (read-from-string (concatenate 'string "(" str ")")))

(defun read-num-from-string (str)
  (parse-integer str))

(defun read-list ()
  (read-list-from-string (read-line)))

(defun read-as-table (num)
  (let ((table nil)
	(lists (loop repeat num
		     for e = (read-list) then (read-list)
		     collect (cons (car e) (cadr e)))))
    (dolist (e (sort lists (lambda (x y) (<= (car x) (car y)))) (reverse table))
      (if (and table (= (caar table) (car e)))
	    (incf (cdar table) (cdr e))
	    (push e table)))))

(defun get-nth-min (num sorted)
  (labels ((inner-loop (rest acc)
	     (if (>= (+ acc (cdar rest)) num)
		 (caar rest)
		 (inner-loop (cdr rest) (+ acc (cdar rest))))))
    (inner-loop sorted 0)))

(defun solve ()
  (let* ((list (read-list))
	 (num (car list))
	 (limit (cadr list)))
    (princ (get-nth-min limit (read-as-table num)))
    (fresh-line)))

(solve)

Measured memory_bytes: 59752
import sys
from collections import Counter
N = int(input())
A = [int(_) for _ in input().split()]

counter = Counter(A)

if N % 2 == 0:
    for n in range(1, N, 2):
        if counter[n] == 2:
            continue
        else:
            print(0)
            sys.exit()

elif N % 2 == 1:
    if counter[0] == 1:
        for n in range(2, N, 2):
            if counter[n] == 2:
                continue
            else:
                print(0)
                sys.exit()
    else:
        print(0)
        sys.exit()
MOD = 10 ** 9 + 7
ans = 1
for n in range(N // 2):
    ans *= 2
    ans %= MOD

print(ans)

Measured memory_bytes: 14892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
//			int N = Integer.parseInt(str);
//			str = br.readLine();
			String[] s = str.split(" ",0);
			int a = Integer.parseInt(s[0]);
			int b = Integer.parseInt(s[1]);
			if((a+b)<10) {
				System.out.println(a+b);
			}else {
				System.out.println("error");
			}
//			long max  = 1000000007;
		}catch (Exception e) {
			System.exit(0);
		}
	}
}


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

const int mod = 1e9 + 7;
const int MAXN = 1e3 + 3;
long long dp[MAXN][MAXN];
char c[MAXN][MAXN];
int n, m;

void input();
void solve();

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	input();
	solve();
	return 0;
}

void input() {
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> c[i][j];
}

void solve() {
	dp[0][0] = 1;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (c[i][j] != '#') {
				if (i != 0)
					dp[i][j] += dp[i - 1][j];
				if (j != 0)
					dp[i][j] += dp[i][j - 1];
				dp[i][j] %= mod;
			}
	cout << dp[n - 1][m - 1] << endl;
}


Measured memory_bytes: 9088
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 2000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll n,ans;
char ch[maxn];
map <pair<string,string>,int> p;

int main()
{
	n=read(); scanf("%s",ch+1); int ed=(1<<n)-1;
	rep(s,0,ed)
	{
		string t1="",t2="";
		rep(i,1,n) if(s&(1<<(i-1))) t1+=ch[i]; else t2+=ch[i];
		p[make_pair(t1,t2)]++;
	}
	rep(s,0,ed)
	{
		string t1="",t2="";
		per(i,n,1) if(s&(1<<(i-1))) t1+=ch[i+n]; else t2+=ch[i+n];
		ans+=p[make_pair(t2,t1)];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 61060
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        pp: [u32;n] 
    }
    let mut cnt = 0;
    for i in 1..n-1 {
        if pp[i-1] < pp[i] && pp[i] < pp[i+1] ||
           pp[i-1] > pp[i] && pp[i] > pp[i+1] {
            cnt+=1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
// ARC 077C
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
int a[222222];
int main()
{
	int n,i,x;
	cin>>n;
	for(i=1;i<=(n/2)*2;i=i+1){
		cin>>x;
		if(i&1)
			a[(n+i+1)/2]=x;
		else
			a[(n-i+2)/2]=x;
	}
	if(n&1){
		cin>>x;
		cout<<x<<' ';
		reverse(a+1,a+n);
	}
	for(i=1;i<=(n/2)*2;i=i+1)
		cout<<a[i]<<' ';
	return 0;
}

Measured memory_bytes: 2944
#include<iostream>
using namespace std;
int main()
{
int a;
int sum=0;
int x,y;
int i;

for(i=0;i<4;i++)
{
cin >> a;
sum+=a;
}

x=sum/60;
sum%=60;
y=sum;

cout << x << endl;
cout << y << endl;

return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll N;
ll A[200010];

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

  cin>>N;
  ll sum=0;
  rep(i,N){
    cin>>A[i];
    sum+=A[i];
  }

  ll sum0=0;
  ll res=INF;
  rep(i,N-1){
    sum0+=A[i];
    ll sum1=sum-sum0;
    minch(res,(ll)abs(sum0-sum1));
  }
  cout<<res<<endl;

  return 0;
}


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

import bisect

def main():
    mod=10**9+7
    N,W=MI()
    w=[0]*N
    w2=[0,0,0,0]#結局4通りしかない
    v2=[[] for _ in range(4)]
    v=[0]*N
    for i in range(N):
        w[i],v[i]=MI()
    w1=w[0]
    for i in range(N):
        w[i]-=w1
        w2[w[i]]+=1
        v2[w[i]].append(v[i])
        
    for i in range(4):
        v2[i].sort(reverse=True)
        
    s=[[0] for _ in range(4)]
    for i in range(4):
        for j in range(len(v2[i])):
            s[i].append(s[i][-1]+v2[i][j])
     
    ans=0       
    for a in range(len(s[0])):
        for b in range(len(s[1])):
            for c in range(len(s[2])):
                for d in range(len(s[3])):
                    ww=b+2*c+3*d+w1*(a+b+c+d)
                    if ww<=W:
                        temp=s[0][a]+s[1][b]+s[2][c]+s[3][d]
                        ans=max(ans,temp)
                        
    print(ans)
                        
        
    

main()


Measured memory_bytes: 40432
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector< pair<pair<string, int>, int> > v(n);
    for(int i=0;i<n;++i){
        cin >> v[i].first.first >> v[i].first.second;
        v[i].first.second *= -1;
        v[i].second = i;
    }
    sort(v.begin(), v.end());

    for(int i=0;i<n;++i){
        cout << v[i].second+1 << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10,mod=998244353;
void plusle(int &a,int b){
    a+=b;if(a>=mod)a-=mod; return;
}
void minun(int &a,int b){
    a-=b; if(a<0)a+=mod; return;
}
int add(int a,int b) {
  a+=b;
  return a>=mod?a-mod:a;
}
int sub(int a,int b) {
  a-=b;
  return a<0?a+mod:a;
}
int mul(int a,int b) {
  return (int)((long long)a*b%mod);
}
struct BIT{
    vector<int> bit;
    int n;
    BIT(int _n){
            bit.resize(_n+5,0);
            n=_n+5;
    }
    void update(int idx,int val){
        for(;idx<n;idx+=(idx&(-idx)))
            bit[idx]+=val;
        return;
    }
    int get(int idx){
        int sum=0;
        for(;idx>0;idx-=(idx&(-idx)))
            sum+=bit[idx];
        return sum;
    }
    int get(int l,int r){
        return get(r)-get(l-1);
    }
};
struct pt{
    int x,y;
    pt():x(0),y(0){}
    void read(){
        scanf("%d%d",&x,&y);
    }
    bool operator <(const pt &a){
        return x==a.x?y<a.y:x<a.x;
    }
}p[maxn];
vector<int> ss,sss;
int ans,n;
int p2[maxn];

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        p[i].read();
        ss.push_back(p[i].x);
        sss.push_back(p[i].y);
    }
    ss.push_back((int)(-1e9-7));
    sss.push_back((int)(-1e9-7));
    sort(ss.begin(),ss.end());
    sort(sss.begin(),sss.end());
    ss.erase(unique(ss.begin(),ss.end()),ss.end());
    sss.erase(unique(sss.begin(),sss.end()),sss.end());
    for(int i=1;i<=n;i++){
        p[i].x=(int)(lower_bound(ss.begin(),ss.end(),p[i].x)-ss.begin());
        p[i].y=(int)(lower_bound(sss.begin(),sss.end(),p[i].y)-sss.begin());
    }
    p2[0]=1;
    for(int i=1;i<=n;i++){
        p2[i]=add(p2[i-1],p2[i-1]);
    }
    sort(p+1,p+1+n);
    int cur=0,u1,u2,d1,d2;
    BIT f1(n),f2(n);
    for(int i=1;i<=n;i++)
        f1.update(p[i].y,1);
    for(int i=1;i<=n;i++){
        int j=i,ct=0;
        while(p[j].x==p[i].x&&j<=n){
            f1.update(p[j].y,-1);
            ct++;
            j++;
        }
        j--;
        for(int k=i;k<=j;k++){
        u1=f1.get(p[k].y+1,n),u2=f2.get(p[k].y+1,n);
        d1=f1.get(p[k].y-1),d2=f2.get(p[k].y-1);
        plusle(ans,p2[n]-1);
        ///completely above
        cur = u1 + u2 + (j-k);
        minun(ans,p2[cur]-1);
        ///completely below
        cur = d1 + d2 + (k-i);
        minun(ans,p2[cur]-1);
        ///completely left
        minun(ans,p2[i-1]-1);
        ///completely right
        minun(ans,p2[n-j]-1);
        ///shitty four corners
        ///left-up
        plusle (ans,p2[u2]-1);
        ///left down
        plusle(ans,p2[d2]-1);
        ///right up
        plusle(ans,p2[u1]-1);
        ///right down
        plusle(ans,p2[d1]-1);
        }
        for(int k=i;k<=j;k++){
            f2.update(p[k].y,1);
        }
        i=j;
    }
    printf("%d\n",ans);
}

/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 5996
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  for(i=0;i<=VMAX;i++){
    C[i] = 0;
  }

  for(i=0;i<n;i++){
    scanf("%d",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1;i<=VMAX;i++){
    C[i] += C[i-1]; 
  }

  for(j=1;j<=n;j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i>1){
      printf(" ");
    }
    printf("%d",B[i]);
  }

  printf("\n");

  return 0;
}



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

int main() {
    //入力
    int N, A, B;
    cin >> N >> A >> B;

    //処理

    int result = 0;

    for(int i = 0; i < N; i++) {
        int currentNum = (i + 1);
        int currentSum = 0;
        while(true) {
            currentSum += currentNum % 10;
            currentNum = currentNum / 10;
            if(currentNum == 0) {
                break;
            }
        }

        if(currentSum >= A && currentSum <= B) {
            result += (i + 1);
        }

    }
    cout << result << endl;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 200010

ll N;
ll A[MAX_N] = {};

signed main()
{
    cin >> N;
    REP(i, N) { cin >> A[i]; }

    if(A[0] != 0) { printf("-1\n"); return 0; }

    ll ans = 0;
    for(ll i = N-1; i > 0; --i) {
        if(A[i] == 0) { continue; }
        if(A[i] == A[i-1] + 1) {
            ans++;
        }
        else if(A[i] <= A[i-1]) {
            ans += A[i];
        }
        else {
            printf("-1\n");
            return 0;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n,x,t;cin >> n >> x >> t;
    cout << ((n-1)/x+1)*t << endl;
}

Measured memory_bytes: 3580
#include<iostream>
#include <stdio.h>
using namespace std;

int main(){
    int n,i;
    int a[10000];
    int a_max,a_min;
    long a_sum;
    
    cin >> n;
    for (i=0;i<n;i++){
        //cin >> a[i];
        scanf("%d",&a[i]);
    }
    a_max=a[0];
    a_min=a[0];
    a_sum=0;
    
    for (i=0;i<n;i++){
        if (a_max < a[i])a_max=a[i];
        if (a_min > a[i])a_min=a[i];
        a_sum = a_sum + a[i];
    }

    cout << a_min << " "<< a_max << " "<< a_sum << endl;
    
    return 0;
}

Measured memory_bytes: 3260
#[allow(unused_macros)]
macro_rules! debug {
	($($a:expr),*) => {
		println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
	}
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(dead_code)]
const MOD: usize = 1e9 as usize + 7;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let h: usize = sc.read();
    let w: usize = sc.read();
    let n: usize = sc.read();
    let a = sc.read_vec::<usize>(n);

    let mut ai = vec![];
    for (i, x) in a.into_iter().enumerate() {
        ai.push((x, i + 1));
    }
    ai.sort();
    ai.reverse();

    let mut ans = vec![vec![0; w]; h];
    let mut k = 0;
    let mut j = 0;
    for (x, i) in ai.into_iter() {
        for _ in 0..x {
            if k % 2 == 0 {
                ans[k][j] = i;
            } else {
                ans[k][w - 1 - j] = i;
            }
            j += 1;
            if j == w {
                j = 0;
                k += 1;
            }
        }
    }

    for i in 0..h {
        for j in 0..w {
            print!("{}", ans[i][j]);
            if j == w - 1 {
                println!("");
            } else {
                print!(" ");
            }
        }
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}

#[allow(dead_code)]
fn yn(flag: bool) {
    if flag {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main()
{
    int H=0,W=0;
    while(1){
        cin>>H>>W;
        if(H==0 && W==0)break;
            for(int j=0;j<H;j++) {
                for(int i=0;i<W;i++) {
                if((i+j)%2==1)cout<<".";
                else cout<<"#";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3004
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;


namespace abc101_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();
            int n = input[0];
            int k = input[1];
            int[] arr = ReadLine().Split().Select(int.Parse).ToArray();
            int min = int.MaxValue;
            int p=0;
            double cnt=0;

            for(int i=0; i<arr.Length; i++){
                if(min>=arr[i]){
                    p=i;
                    min = arr[i];
                }
            }

            if(k == 2){
                cnt = n-1;
            }else{
                cnt = (double)(n-p-1)/(k-1)+(double)p/(k-1);
            }

            WriteLine(Ceiling(cnt));
        }

        /// 値のスワップ
        static void Swap<T>(ref T lhs, ref T rhs)
        {
            T temp;
            temp = lhs;
            lhs = rhs;
            rhs = temp;
        }


    }
}

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

using namespace std;
#define N 100010
ll n,f,g,h,a,b,c;
int main(){
    cin>>n;
    f=g=h=0;
    for(int i=0;i<n;i++){
     cin>>a>>b>>c;
     ll nf=0,ng=0,nh=0;
     nf=max(g,h)+a;
     ng=max(f,h)+b;
     nh=max(f,g)+c;
     f=nf,g=ng,h=nh;
    }
    cout<<max(f,max(g,h))<<endl;
 return 0;   
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, mn = 1001001001;
	cin >> n;
	vector<int> w(n);
	rep(snip_i, n){
		cin >> w.at(snip_i);
		mn = min(mn, w.at(snip_i));
	}
	vector<int> w2 = w;
	sort(w2.begin(), w2.end());
	vector<int> ww;
	rep(i, n){
		if(w.at(i) != w2.at(i)){
			ww.push_back(w.at(i));
		}
	}
	vector<int> ww2 = ww;
	sort(ww2.begin(), ww2.end());
	vector<int> wn(ww.size());
	rep(i, ww.size()){
		int now = ww.at(i);
		rep(j, ww2.size()){
			if(ww2.at(j) == now){
				wn.at(i) = j;
				break;
			}
		}
	}
	vector<int> grp(ww.size(), -1);
	int count = 0;
	bool end = false;
	ll ans = 0;
	while(!end){
		ll grpmn, grpsum = 0, grpc = 0;
		rep(i, wn.size()){
			if(grp.at(i) == -1){
				grpc++;
				grp.at(i) = count;
				grpsum = ww.at(i);
				grpmn = ww.at(i);
				int nx = wn.at(i);
				while(nx != i){
					grpc++;
					grp.at(nx) = count;
					grpsum += ww.at(nx);
					grpmn = min(grpmn, (ll)ww.at(nx));
					nx = wn.at(nx);
				}
				break;
			}
		}
		if(grpc == 0) break;
		ll add1 = grpsum + grpmn * (grpc - 2);
		grpsum = grpsum - grpmn + mn;
		ll add2 =grpsum + mn * (grpc - 2) + 2 * (grpmn + mn);
		ans += min(add1, add2);
		count++;
		// cerr << add1 << " " << add2 << " " << grpmn << " " << grpc << endl;
	}
	
	// rep(i, ww2.size()){
	// 	printf("%2d ", i);
	// }
	// cout << endl;
	// rep(i, ww.size()){
	// 	printf("%2d ", ww.at(i));
	// }
	// cout << endl;
	// rep(i, wn.size()){
	// 	printf("%2d ", wn.at(i));
	// }
	// cout << endl;
	// rep(i, ww2.size()){
	// 	printf("%2d ", ww2.at(i));
	// }
	// cout << endl;
	// rep(i, grp.size()){
	// 	printf("%2d ", grp.at(i));
	// }
	// cout << endl;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3160
def main():
    from sys import stdin, setrecursionlimit
    setrecursionlimit(10**6)
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]

    a, b = map(int, r.split())
    if a%b == 0:
        print(0)
    else:
        print(1)

if __name__ == '__main__':
    main()



Measured memory_bytes: 38256
S,T = input(),input()

dp = [[0]*(len(T)+1) for _ in range(len(S)+1)]

for i in range(1,len(S)+1):
  for j in range(1,len(T)+1):
    dp[i][j] = max(dp[i][j-1], dp[i-1][j], dp[i-1][j-1] + (S[i-1]==T[j-1]))

res = []
x,y = len(S),len(T)
v = dp[x][y]
while v > 0:
  if dp[x-1][y] == v:
    x -= 1
  elif dp[x][y-1] == v:
    y -= 1
  else:
    res.append(S[x-1])
    x -= 1
    y -= 1

  v = dp[x][y]

print(''.join(reversed(res)))

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


int main() {
    int N;
    cin >> N;
    vector<int> P(N), Q(N), A(N);
    rep(i,N) cin >> P.at(i);
    rep(i,N) cin >> Q.at(i);
    rep(i,N) A.at(i) = i + 1;
    int cnt = 0;
    int cntP = 0;
    int cntQ = 0;
    do {
        if (P == A) cntP = cnt;
        if (Q == A) cntQ = cnt;
        ++cnt;
    } while (next_permutation(A.begin(), A.end()));
    cout << abs(cntP - cntQ) << endl;
}



Measured memory_bytes: 3624
#include <iostream>
#include <cstring>
#define MOD 1000000007
using namespace std;

int n;
char s[100010];

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>s;
	cin>>n;
	int a=0;
	while(n>0&&s[a+1]){
		if(n>='z'-s[a]+1&&s[a]!='a'){
			n-='z'-s[a]+1;
			s[a]='a';
		}
		a++;
	}
	while(n>='z'-'a'+1)n-='z'-'a'+1;
	s[a]=((s[a]-'a'+n)%('z'-'a'+1))+'a';
	cout<<s;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
cin >> N;
int a=0;
bool b = false;
for(int i = 1; i < 5000; i++){
  int m = i*(i-1)/2;
  int M = i*(i+1)/2;
  if(m <= N && N < M){
    a+= i-1; // N =15の時、　a = 5
  }
  if(b) break;
}

int A[5000] = {0};
for(int i = 1; i <= a; i++){
  A[i]+= i;
}
for(int i = 1; i<= N-a*(a+1)/2; i++){
  A[a-i+1]+= 1;
}
for(int i = 1; i<=a; i++){
  cout << A[i] << endl;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
//keep coding
//-Roshan Mitra (SIT Pune) 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define f0(i,n) for(int i=0;i<n;i++) 
#define f1(i,n) for(int i=1;i<=n;i++)
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define pb push_back
#define MP make_pair
#define FF first
#define SS second
#define int long long
#define MOD 1000000007
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 int frogA(int ind,vector<int>&dp,int n,int arr[]){
     if(ind==n-1)
        return 0;
    if(dp[ind]!=-1)
        return dp[ind];
    int c1=INT_MAX;
    c1=abs(arr[ind]-arr[ind+1])+frogA(ind+1,dp,n,arr);
    int c2=INT_MAX;
    if(ind+2<=n-1){
        c2=abs(arr[ind]-arr[ind+2])+frogA(ind+2,dp,n,arr);
    }
    dp[ind]=min(c1,c2);
    return dp[ind];
 }
signed main()
{

 FIO;
 int n;
 cin>>n;
 int arr[n];
 for(int i=0;i<n;i++)
    cin>>arr[i];
 vector<int>dp(n+1,-1);
 cout<<frogA(0,dp,n,arr)<<endl;
   
}

Measured memory_bytes: 14252
#include <iostream>

using namespace std;

int main()
{
    int x, h=0;
    cin>>x;
    while (x != 0)
    {
    int q = x / 500;
    if (q>0)
    {
        h = h + (q * 1000);
        x = x - (500 * q);
    }
    int c = x / 5;
    if (c>0)
    {
        h = h + (c * 5);
        x = x - (5 * c);
    }
    else
    {
        break;
    }
    }
    cout<<h;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,a[300100];ll ans;
int main()
{
	n=read();
	for(int i=1;i<=n*3;++i)a[i]=read();
	sort(&a[1],&a[n+n+n+1]);
	for(int i=n+n+n-1,j=1;j<=n;++j,i-=2)ans+=a[i];
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<vector<int>> candies(2,vector<int>(n));
    
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
            cin>>candies.at(i).at(j);
        }
    }
    
    int ans=0;
    
    for(int i=0;i<n;i++){
        int pre=0;
        for(int j=0;j<n;j++){
            if(j<=i) pre+=candies.at(0).at(j);
            if(i<=j) pre+=candies.at(1).at(j);
        }
        ans=max(ans,pre);
    }
    
    cout<<ans<<endl;
    
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
using ll = long long;
using ull = unsigned long long;

int main() {
  int n; cin >> n;
  int cond = 0;
  rep(i, n) {
    int p; cin >> p;
    cond += (int)(i + 1 != p);
  };
  if (cond > 2) cout << "NO";
  else cout << "YES";
}


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

#define ii pair <ll, ll>
#define iii pair <ll, ii>
#define ll long long
#define X first
#define Y second

const int N = 2E5 + 10;

int n, Root[N], Ranked[N];
ii a[N], x[N], y[N];

void Input()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i].X >> a[i].Y;
}

int Find_Root(int u)
{
    if (u == Root[u]) return u;
    return Root[u] = Find_Root(Root[u]);
}

bool Union(int u, int v)
{
    u = Find_Root(u);
    v = Find_Root(v);
    if (u == v) return false;

    if (Ranked[u] > Ranked[v]) swap(u, v);
    Root[u] = v;
    Ranked[v] += Ranked[u];

    return true;
}

ll Modify(int u, int v)
{
    ll x = abs(a[u].X - a[v].X);
    ll y = abs(a[u].Y - a[v].Y);
    return min(x, y);
}

void Solve()
{
    ll res = 0;
    priority_queue <iii, vector <iii>, greater <iii> > PQ;
    for (int i = 1; i <= n; i++) x[i] = {a[i].X, i};
    for (int i = 1; i <= n; i++) y[i] = {a[i].Y, i};
    sort(x + 1, x + 1 + n);
    sort(y + 1, y + 1 + n);

    for (int i = 1; i < n; i++) {
        int u = x[i].Y;
        int v = x[i + 1].Y;
        ll Dist = Modify(u, v);
        PQ.push({Dist, {u, v}});

        u = y[i].Y;
        v = y[i + 1].Y;
        Dist = Modify(u, v);
        PQ.push({Dist, {u, v}});

    }
    for (int i = 1; i <= n; i++) Root[i] = i, Ranked[i] = 1;

    int k = n - 1;
    while (k && PQ.size()) {
        ll Distance = PQ.top().X;
        int u = PQ.top().Y.X;
        int v = PQ.top().Y.Y;
        PQ.pop();
        if (Union(u, v)) {
            k--;
            res += Distance;
        }
    }

    cout << res;
}

#define task "test"
int main()
{
    if (fopen(task ".inp", "r")) {
        freopen(task ".inp", "r", stdin);
        freopen(task ".out", "w", stdout);
    }
    int testcase = 1;
    /// cin >> testcase;
    while (testcase--) {
        Input();
        Solve();
    }
}




Measured memory_bytes: 16492
#include<bits/stdc++.h>
#define pii pair<int,int>
using namespace std;
map<pii, int>Map;
int n, res;
pii w[60];
int main() {
	int i, j, k;
	scanf("%d", &n);
	res = n;
	for (i = 1; i <= n; i++) {
		scanf("%d%d", &w[i].first, &w[i].second);
		Map[w[i]] = 1;
	}
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) {
			if (i == j)continue;
			int x = w[j].first - w[i].first, y = w[j].second - w[i].second;
			int c = 0;
			for (k = 1; k <= n; k++) {
				if (Map.count({ w[k].first + x,w[k].second + y }))c++;
			}
			res = min(res, n - c);
		}
	}
	printf("%d\n", res);
}



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

int main(){
int n; long long ans=1,m;
cin>>n>>m;
for(long long i = 1; i*i <= m; i++){
if(m%i == 0){
if(i*i == m){
if(m/i >= n) ans = max(ans,i);
}
else{
if(m/i >= n) ans = max(ans,i);
if(i >= n) ans = max(ans,m/i);
}
}
}
cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 256
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    string ans;
    fi>>ans;
    int ok = 0;
    for (auto it : ans)
    {
        if (it == 'C') ok |= 1;
        else
        if (it == 'F' && (ok&1)) ok |= 2;
    }
    fo << (ok == 3 ? "Yes" : "No") << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}

Measured memory_bytes: 256