akhauriyash/Code-Regression huggingface dataset:
import numpy as np
N = int(input())
A_cs = np.array([(-1)**i * int(x) for i,x in enumerate(input().split())]).cumsum()
print(*(np.array( [ (A_cs[N-1]-A_cs[i-1]-A_cs[i-1] if i!=0 and i%2==0 else -A_cs[N-1]+A_cs[i-1]+A_cs[i-1] ) for i in range(N) ] )))

Measured memory_bytes: 23132
n, k = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(2*k)]

box = [0]
for i in range(k):
    box = box + a[(i*2 + 1)]
box.remove(0)

c = len(list(set(box)))
print(n - c)

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

int a[5], ans;

int read()
{
	int x = 0, k = 1;
	char c; c = getchar();
	while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * k;
}

int main()
{
	a[1] = read(), a[2] = read(), a[3] = read();
	sort(a + 1, a + 4);
	for(int i = 1; i <= 2; i ++)
	{
		int t = (a[3] - a[i]) / 2;
		a[i] += t * 2;
		if(a[i] < a[3]) a[i] += 2, t ++;
		ans += t;
	//	cout << a[i] << " " << ans << endl;
	}
	if(a[1] == a[2] && a[2] == (a[3] + 1)) printf("%d\n", ans - 1);
	else if(a[1] == a[2] && a[2] == a[3]) printf("%d\n", ans);
	else printf("%d\n", ans + 1);
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  rep(i, n) {
    int num;
    cin >> num;
    a.at(i) = num;
  }
  vector<int> distance(n);
  for (int i = 0; i < n-1; i++) {
    distance.at(i) = a.at(i+1) - a.at(i);
  }
  distance.at(n-1) = k-a.at(n-1) + a.at(0);
  int max = 0;
  rep(i, n) {
    if (max < distance.at(i)) {
      max = distance.at(i);
    }
  }
  cout << k-max << endl;
}


Measured memory_bytes: 4800
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
int main() {
    int N ,K;
    cin >> N >>K;
    vector<int>A(N+1, 0);
    rep(i, 0, N){
        int index = 0;
        cin >> index;
        A[index]++;
    }
    sort(A.rbegin(), A.rend());
    
    ll ans = 0;
    for(int i = 0; i < K; i++){
        ans += A[i];
    }
    ans = N - ans;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
//------------------------------------------------------

ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll h[n];
    rep(i, n) cin >> h[i];

    ll lo = 1, hi = (ll) INF;
    ll mi = (lo + hi) / 2;

    rep(k, 100) {
        ll minus = b * mi;
        ll cnt = 0;

        rep(i, n) {
            ll hp = h[i] - minus;
            if (hp > 0) cnt += CEIL(hp, a - b);
        }
        if (cnt <= mi) hi = mi;
        else lo = mi;
        mi = (lo + hi) / 2;
    }

    cout << hi << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node {
  int key;
  struct node *right;
  struct node *left;
  struct node *parent;
};

typedef struct node* Nodepointer;
Nodepointer nil, root;

void insert(int k){
  Nodepointer x, y, z;
  y = nil;
  x = root;

  z = (Nodepointer)malloc(sizeof(struct node));
  z->key = k;
  z->left = nil;
  z->right = nil;
  
  while( x != nil ){
    y = x;
    if( z->key < x->key ) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if( y == nil ) root = z;
  else if( z->key < y->key ) y->left = z;
  else y->right = z;
}

void inorder(Nodepointer u){
  if( u == nil ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Nodepointer u){
  if( u == nil ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i ,x;
  char com[7];

  scanf("%d", &n);

  for( i = 0 ; i < n ; i++ ){
    scanf("%s",com);
    if( strcmp("insert",com) == 0 ){
      scanf("%d", &x);
      insert(x);
    }
    else if( strcmp("print",com) == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 25148
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int> > Matrix;
const int MOD = 1e9+7;


int main(){
    int sum=0;
REP(i,3){
    int a; cin>>a;
    sum+=a;
}

string res;
if(sum>=22)res="bust";
else if(sum<=21)res="win";
cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
ll inf = 1e10;

ll gcd(ll a, ll b){
  return (b != 0) ? gcd(b, a%b) : a;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  ll ans = 0;
  if(n == 1 && m == 1) ans = 1;
  else if(n == 1) ans = m-2;
  else if(m == 1) ans = n-2;
  else ans = (n-2)*(m-2);
  cout << ans << "\n";
  
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  string s;
  cin>>s;
  int n = s.length();
  set<char>se={'A','C','G','T'};
  REP(i,0,n){
    if(se.count(s[i])>0){
      s[i]='1';
    }else s[i]='0';
  }
  int cnt=0;
  int ma = 0;
  REP(i,0,n){
    if(s[i]=='1')cnt++;
    else cnt=0;
    ma=max(ma,cnt);
  }
  cout<<ma<<endl;

  return 0;
}


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

int main() {
    double r;
    double circumference, area;

    cin >> r;

    circumference = r * r * M_PI;
    area = 2 * M_PI * r;

    printf("%lf %lf\n", circumference, area);
}



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

using namespace std;
typedef long long ll;

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

  char s[6];
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]){
    cout << "Yes";
  }else{
    cout << "No";  }
}


Measured memory_bytes: 256
def f(n)
  if n==0
    return 1
  end
  return n*f(n-1)
end

cs = gets.chomp.split("")
cc = Hash.new(0)
cs.each do |c|
  cc[c]+=1
end
if cs.size.even?
  if cc.values.all?{|c| c.even?}
    puts f(cs.size/2)/cc.values.map{|c|f(c/2)}.inject(1){|x,y|x*y}
  else
    puts 0
  end
else
  if cc.values.one?{|c| c.odd?}
    puts f(cs.size/2)/cc.values.map{|c|f(c/2)}.inject(1){|x,y|x*y}
  else
    puts 0
  end
end

Measured memory_bytes: 2504
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <tuple>
namespace boost {template <class T>struct integer_iterator {T a;bool operator != (integer_iterator const & it) const { return a != it.a; }T operator * () const { return a; }integer_iterator & operator ++ () { ++ a; return *this; }integer_iterator operator ++ (int) { return { a ++ }; }};template <class T>struct integer_range {T l, r;typedef integer_iterator<T> iterator;iterator begin() const { return { l }; }iterator end  () const { return { r }; }};template <class T>integer_range<T> irange(T l, T r) { assert (l <= r); return { l, r }; }template <class T>struct integer_iterator_with_step {T a, d, i;bool operator != (integer_iterator_with_step const & it) const { return a != it.a or d != it.d or i != it.i; }T operator * () const { return a+d*i; }integer_iterator_with_step & operator ++ () { ++ i; return *this; }integer_iterator_with_step operator ++ (int) { return { a, d, i ++ }; }};template <class T>struct strided_integer_range {T l, r, s;typedef integer_iterator_with_step<T> iterator;iterator begin() const { return { l, s, 0 }; }iterator end  () const { return { l, s, (r - l) / s }; }};template <class T>strided_integer_range<T> irange(T l, T r, T s) { assert (s > 0 ? l <= r : s < 0 ? l >= r : false); return { l, r, s }; }}
typedef long long ll;
using namespace std;
using namespace boost;
#define endl "\n"
struct team_t { int id; int ac; int time; vector<int> wa; };
bool operator < (team_t const & a, team_t const & b) {
    return make_tuple(a.ac, - a.time, a.id) < make_tuple(b.ac, - b.time, b.id);
}
int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
    while (true) {
        int M, T, P, R; cin >> M >> T >> P >> R;
        if (M == 0 and T == 0 and P == 0 and R == 0) break;
        vector<team_t> team(T);
        for (int i : irange(0,T)) {
            team[i].id = i+1;
            team[i].ac = 0;
            team[i].time = 0;
            team[i].wa.resize(P);
        }
        for (int submission : irange(0,R)) {
            int m, t, p, j; cin >> m >> t >> p >> j; -- t; -- p;
            if (j == 0) {
                team[t].ac += 1;
                team[t].time += m;
                team[t].time += team[t].wa[p] * 20;
            } else {
                team[t].wa[p] += 1;
            }
        }
        sort(team.rbegin(), team.rend());
        cout << team.front().id;
        for (int i : irange(1,T)) {
            if (team[i-1].ac == team[i].ac and team[i-1].time == team[i].time) {
                cout << '=';
            } else {
                cout << ',';
            }
            cout << team[i].id;
        }
        cout << endl;
    }
    return 0;
}

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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int main() {
  _upgrade;
  int n;
  cin >> n;
  while (n) {
    int last = n % 10;
    if (last == 7) {
      cout << "Yes\n";
      return 0;
    }
    n /= 10;
  }
  cout << "No\n";
  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int N = 100100; 

int n, a[N], b[N], ans; 
ll num, c[2 * N]; 

int lb(int x) {
  return x & (-x); 
}

void add(int x, int d) {
  for(int i = x; i <= 2 * n + 2; i += lb(i)) {
    c[i] += d; 
  }
}

ll sum(int x) {
  ll ret = 0;
  for(int i = x; i; i -= lb(i))
    ret += c[i]; 
  return ret; 
}

bool check(int x) {
  memset(c, 0, sizeof(c)); 
  for(int i = 1; i <= n; i++) {
    b[i] = a[i] >= x ? 1 : -1;
    b[i] += b[i - 1];  
  }
  for(int i = 1; i <= n; i++) b[i] += n + 1; 
  ll t = 0; 
  add(n + 1, 1);
  for(int i = 1; i <= n; i++) {
    t += sum(b[i]); 
    add(b[i], 1); 
  }
    return t >= num - (num / 2 + 1) + 1; 
}

int main() {
  scanf("%d", &n); 
  for(int i = 1; i <= n; i++) 
    scanf("%d", &a[i]); 
  num = 1ll * n * (n + 1) / 2; 
  int l = 1, r = (int)1e9; 
  while(l <= r) {
    int mid = (l + r) >> 1; 
    if(check(mid)) {
      ans = mid; l = mid + 1; 
    }
    else r = mid - 1; 
  }
  printf("%d\n", ans); 
  return 0; 
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

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

    constexpr ll inf = 1e+17;
    int extra = n % 2 + 1;
    vector<vector<ll>> dp(n + 1, vector<ll>(extra + 2, -inf));
    dp[0][0] = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j <= extra; ++j){
            chmax(dp[i + 1][j + 1], dp[i][j]);
            ll now = dp[i][j];
            if((i + j) % 2 == 0)    now += a[i];
            chmax(dp[i + 1][j], now);
        }
    }

    cout << dp[n][extra] << endl;
}

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

int main() {
	
	int n; cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll A = 0;
	for (int i = 0; i < n; i++) {
		A = A ^ a[i];
	}
	for (int i = 0; i < n; i++) {
		cout << (A ^ a[i]) << " ";
	}
	cout << endl;
    return 0;
}

Measured memory_bytes: 4788
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
#include <tuple>
#include <map>
 
using namespace std;

typedef long long ll;

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

    int N, K;

    cin >> N >> K;

    int count = 0;

    for(int i = 0; i < N; i++) {
        int h;
        cin >> h;
        if(h >= K) {
            count++;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  vector<int> l(n), r(n);
  rep(i,n-1) l[i+1] = gcd(l[i], a[i]);
  for (int i = n-1; i >= 1; --i) r[i-1] = gcd(r[i], a[i]);
  int ans = 1;
  rep(i,n) ans = max(ans, gcd(l[i],r[i]));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1408
h, w = map(int, input().split())
a=[ list(input()) for _ in range(h)]
dp=[1]+[0]*(w-1)
for i in range(h):
    dp[0]=int(dp[0]==1 and a[i][0]=='.')
    for j in range(1,w): dp[j]=( (dp[j]+dp[j-1]) % 1000000007) if a[i][j]=='.' else 0
print(dp[-1])

Measured memory_bytes: 11892
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

 int main(){

 long long l,r;
 cin>>l>>r;

  if(r-l > 2019){
    cout<<"0"<<endl;
  return 0; }
 else {

   long long ans = 2018;

 for(long long i=l;i<=r;i++)
 {
    for(long long j=i+1;j<=r;j++)
     {
        ans = min(ans,i*j%2019);
    }
 }
    cout<<ans<<endl;
    return 0;
 }


 }


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld; 


#define F first
#define S second
#define pob pop_back
#define pb push_back
#define Time()	cerr << clock() * 1000 / CLOCKS_PER_SEC << "ms\n"
#define show(x)	cerr << #x << " = " << (x) << '\n'
#define inf 1e14
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define invec(v) for(auto& x : v)cin>>x;
#define Test int T;cin>>T;while(T--)
#define vec vector<ll> 
#define REP(i,j,k) for(int i=(j);(i)<(k);(i)++)
#define phi ((1+sqrt(5))/2)
#define endl '\n'



int main(){
	int n,sum=0;
	cin>>n;
	REP(i,1,n+1){
		REP(j,1,n+1){
			REP(k,1,n+1){
				sum+=__gcd(__gcd(i,j),k);
			}
		}
	}
	cout<<sum;
	
}


Measured memory_bytes: 3624
n = gets.to_i
w = gets.split.map(&:to_i)
ans = 10**4 + 1

(1..n).each do |t|
  s1 = 0
  s2 = 0
  (1..n).each do |j|
    s1 += w[j-1] if j-1 < t
    s2 += w[j-1] if j-1 >= t
  end
  ans = (s1 - s2).abs if (s1 - s2).abs < ans
end

puts ans


Measured memory_bytes: 1788
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <bits/stdc++.h>

using namespace std;

class CBridge {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        int n, m;
        cin >> n >> m;
        vector<vector<int>> graph(n + 1);
        vector<pair<int, int>> bridges;
        vector<int> visited(n + 1, false);
        for (int i = 0; i < m; ++i) {
            int a, b;
            cin >> a >> b;
            graph[a].emplace_back(b);
            graph[b].emplace_back(a);
            bridges.emplace_back(a, b);
        }
        int ans = 0;
        for (int j = 0; j < m; ++j) {
            visited.clear();
            visited.resize(n + 1, false);
            auto p = bridges[j];
            queue<int> q;
            q.push(1);
            while (!q.empty()) {
                int node = q.front();
                q.pop();
                visited[node] = true;
                for (const auto &next: graph[node]) {
                    if ((node == p.first && next == p.second) || (node == p.second && next == p.first)) continue;
                    if (visited[next]) continue;
                    visited[next] = true;
                    q.push(next);
                }
            }
            if (count(visited.begin(), visited.end(), false) == 1)ans++;
        }
        cout << m - ans << endl;
    }
};


int main() {
    CBridge solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <numeric>
#include <bitset>
#include <stack>
using namespace std;

class LessB
{
public:
  bool operator()(const pair<int, int>& lhs, const pair<int, int>& rhs)
  {
    if (lhs.second == rhs.second)
      return lhs.first < rhs.first;
    return lhs.second < rhs.second;
  }
};

int main()
{
  int N;
  while (cin >> N) {
    vector<pair<int, int> > AB(N);
    for (int i = 0; i < N; ++i)
      cin >> AB[i].first >> AB[i].second;
    sort(AB.begin(), AB.end(), LessB());

    const int INF = 1 << 30;
    vector<vector<int> > dp(N+1, vector<int>(N+1, INF));
    dp[0][0] = 0;
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N+1; ++j) {
	if (j < 1 || dp[i][j-1]+AB[i].first > AB[i].second)
	  dp[i+1][j] = dp[i][j];
	else
	  dp[i+1][j] = min(dp[i][j], dp[i][j-1]+AB[i].first);
      }
    }

    int ans = 0;
    for (int i = 0; i < N+1; ++i) {
      if (dp[N][i] < INF)
	ans = i;
    }

    cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = [I() for _ in range(n)]
ans = 0
for i in range(n):
    ans += a[i] // 2
    a[i] = a[i] % 2
    if i < n-1:
        if a[i+1] and a[i]:
            ans += 1
            a[i+1] -= 1
print(ans)

Measured memory_bytes: 44380
from collections import Counter

n=int(input())
*a,=map(int, input().split( ))
b=[a[i]-i for i in range(n)]
c =[-a[i]-i for i in range(n)]
bc=Counter(b)
cc=Counter(c)

ans=0

for k in bc:
    if k in cc:
        ans+= bc[k]*cc[k]
print(ans)

Measured memory_bytes: 147268
import java.util.Scanner;

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

		// 入力値の取得
		long A = sc.nextLong();
		long B = sc.nextLong();

		long answer = A * B / calcGcd(A, B);
		System.out.println(answer);

		sc.close();
	}

	static long calcGcd(long m, long n) {
		if (m < n) {
			long tmp = m;
			m = n;
			n = tmp;
		}
		long remainder = 0;
		while ((remainder = m % n) != 0) {
			m = n;
			n = remainder;
		}
		return n;
	}
}


Measured memory_bytes: 35648
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>
#include <queue>
#include <map>
#include <typeinfo>

using namespace std;

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

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } //最大公約数


int main() {

	//入力
	string s;
	cin >> s;

	int cnt = 0;
	int n = s.size();

	if (s.size() == 0 || s.size() == 1) {
		cout << 0 << endl;
		exit(0);
	}

	int cnt0 = 0;
	int cnt1 = 0;

	for (int i = 0; i < n; ++i) {
		if (s[i] == '0') {
			cnt0++;
		}
		if (s[i] == '1') {
			cnt1++;
		}			
	}

	cout << min(cnt0, cnt1) * 2 << endl;
	exit(0);
}

Measured memory_bytes: 512
import numpy as np
import sys
input = sys.stdin.readline


def main():
    n, m, q = map(int, input().split())
    counts = np.zeros((n+1, n+1), dtype=np.int32)
    for _ in range(m):
        from_, to = map(int, input().split())
        counts[:from_+1, to] += 1

    counts = np.cumsum(counts, axis=1)

    queries = np.array([list(map(int, input().split())) for _ in range(q)])
    ps = queries[:, 0]
    qs = queries[:, 1]
    res = counts[ps, qs]
    print(*res, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 45848
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;


void slove(int n){
    int card[202]={0},no[2],in,ba=0,ban=1;
    
    
    no[0]=no[1]=n;
    
    for(int i=0;i<n;i++){
        scanf("%d",&in);
        card[in]=1;
    }
    
    
    
    while(1){
        for(int i=ba+1;;i++){
            if(2*n<i){
                ba=0;
                ban=1-ban;
                break;
            }
            if(card[i]==ban){
                no[ban]--;
                card[i]=-1;
                ba=i;
                ban=1-ban;
                break;
            }
        }
        if(no[0]*no[1]==0){
            printf("%d\n%d\n",no[0],no[1]);
            return;
        }
    }
    
    
    return;
}

int main(){
    int n;
    while(1){
        scanf("%d",&n);
        if(!n) break;
        slove(n);
    }
    return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

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

  int ans=0;
  int count=0;
  for(int i=1;count<X;i++){
    count+=i;
    ans=i;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iostream>
#include<cstring>
using namespace std;
template<class _T>inline void read(_T &_a)
{
    bool f=0; char _c=getchar(); _a=0;
    while(_c<'0'||_c>'9'){ if(_c=='-') f=1; _c=getchar(); }
    while(_c>='0'&&_c<='9'){ _a=(_a<<3)+(_a<<1)-'0'+_c; _c=getchar(); }
    if(f) _a=-_a;
}

const int MAXN=1000002;
long long x,now=100;

int main()
{
    read(x);
    int ans=0;
    while(now<x)
    {
        ++ans;
        now=now*1.01;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;

const int COMB_MAX = 510000;
ll fac[COMB_MAX], finv[COMB_MAX], inv[COMB_MAX];

ll comb(ll a, ll b)
{
    if (a < b)
        return 0;
    if (a < 0 || b < 0)
        return 0;

    return fac[a] * (finv[b] * finv[a - b] % MOD) % MOD;
}

void combInit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < COMB_MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

    combInit();

    ll h, w, a, b, ans;
    cin >> h >> w >> a >> b;

    ans = 0;

    for (ll i = 1; i <= h - a; i++)
    {
        ans += comb(b - 1 + i - 1, min(b - 1, i - 1)) * comb(h - i + w - b - 1, min(h - i, w - b - 1));
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12160
#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
#include<cmath>
//#include<windows.h>
#include<algorithm>
#include<set>
const double eps = 1e-1;
using namespace std;
typedef long long ll;
map<int,int>play;
int main(){

    int n;
    scanf("%d",&n);
    int num=0;
    while(n--){
        int t;
        scanf("%d",&t);
        if(play[t]==1)play[t]--,num--;
        else play[t]++,num++;
    }
    printf("%d\n",num);
    return 0;
}
//Hello World Here I Come
//          0                 10
//        0 1 1                8
//      0 1 1 2 3              6
//    0 1 1 2 3 5 8            4
//  0 1 1 2 3 5 8 13 21        2
//0 1 1 2 3 5 8 13 21 34 55    0


Measured memory_bytes: 4864
N = int(input())
A = list(map(int, input().split()))

b = 10 ** 18
cnt = 1

for i in range(N):
    if (A[i] == 0):
        print(0)
        exit(0)

for i in range(N):
    a = A[i]
    if a > b:
        print(-1)
        exit(0)
    cnt *= a
    if cnt > b:
        print(-1)
        exit(0)
print(cnt)


Measured memory_bytes: 21636
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main() {

    int A,B,C,D;
    cin >> A >> B >> C >> D;
    
    if ((abs(A - B) <= D && abs(B - C) <= D) || abs(A - C) <= D)cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int a,b;
  while(cin>>a>>b){
    vi num(105,0);
    num[a]++;
    num[b]++;
    while(a+b>0){
      cin>>a>>b;
      num[a]++;
      num[b]++;
    }
    bool ans=true;
    if(num[1]%2==0 || num[2]%2==0){
      cout<<"NG"<<endl;
      ans=false;
      continue;
    }
    loop(i,3,105)if(num[i]%2){
      cout<<"NG"<<endl;
      ans=false;
      break;
    }
    if(ans)cout<<"OK"<<endl;
  }
}

Measured memory_bytes: 3008
#include<stdio.h>

int solve(int,int);
int n,A[2000];
int main() {
	int i,q,m[2000];
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		scanf("%d",&A[i]);
		}
		scanf("%d",&q);
		
		for(i=0;i<q;i++) {
		scanf("%d",&m[i]);
		}
		for(i=0;i<q;i++) {
			if(solve(0,m[i])==1)
			printf("yes\n");
			else printf("no\n");
		}
			return 0;
			}
			
		int solve(i, m) {
			int res;
   if (m == 0)
     return 1;
   if (i >= n)
   return 0;
   res = solve(i + 1, m) || solve(i + 1, m - A[i]);
   return res;
   }


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int n,x;
multiset <int, greater<int> > s;
multiset <int> v;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=0;i<(1<<n);i++)
    {
        cin>>x;
        s.insert(x);
    }
    v.insert(*s.begin());
    s.erase(s.begin());
    for(int i=0;i<n;i++)
    {
        vector <int> add_v;
        for(multiset <int>:: iterator it=v.begin();it!=v.end();it++)
        {
            if(s.lower_bound(*it-1)==s.end())
            {
                cout<<"No";
                return 0;
            }
            add_v.push_back(*(s.lower_bound(*it-1)));
            s.erase(s.lower_bound(*it-1));
        }
        for(int j=0;j<(int)add_v.size();j++)
            v.insert(add_v[j]);
    }
    cout<<"Yes\n";
    return 0;
}

Measured memory_bytes: 13304
while True:
    a,b = map(int,input().split())
    if a == 0 and b == 0: break
    for i in range(a):
        for j in range(b):
            if i == 0 or j == 0 or i == (a-1) or j == (b-1):
                print('#',end="")
            else:
                print('.',end="")
        print()
    print()


Measured memory_bytes: 7008
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int kai(int n){
	int sum = 0;
	while (n!= 0) {
		sum = sum + n% 10;
		n = n/10;
	}
	return sum;
}
int main() {
	int x;
	cin >> x;
	int ans = kai(x);
	if (x % ans == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll N=1000000007;
//ll power(ll a,ll b,ll mod)
//{
//    ll result=1;
//    while(b>0)
//    {
//        if(b%2==1)
//            result=(result*a)%mod;
//        a=(a*a)%mod;
//        b=b/2;
//    }
//    return result;
//}
//ll d,x,y;
//void extendedEuclid(ll a,ll b)
//{
//    if(b==0)
//    {
//        d=a; x=1; y=0;
//    }
//    else
//    {
//        extendedEuclid(b,a%b);
//        ll temp=x; x=y; y=temp-(a/b)*y;
//    }
//}
//ll modInverse(ll a,ll m)
//{
//    extendedEuclid(a,m);
//    return (x%m+m)%m;
//}
//ll lcm(ll a,ll b)
//{
//    if(a==0||b==0)
//        return 0;
//    return (a*b)/(__gcd(a,b));
//}
//void sieve(ll n)
//{
//    bool isPrime[n+1];
//    isPrime[0]=false; isPrime[1]=false;
//    for(ll i=2;i<=n;i++)
//        isPrime[i]=true;
//    for(ll i=2;i*i<=n;i++)
//    {
//        if(isPrime[i]==true)
//        {
//            for(ll j=i*i;j<=n;j+=i)
//                isPrime[j]=false;
//        }
//    }
//}
//bool isPowerOfTwo(ll n)
//{
//    return (n&&!(n&(n-1)));
//}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k,i,j; cin>>n>>k; ll A[n];
    for(i=1;i<=n;i++) cin>>A[i];
    for(i=k+1;i<=n;i++)
    {
        if(A[i-k]<A[i]) cout<<"Yes"<<endl;
        else  cout<<"No"<<endl;
    }
}


Measured memory_bytes: 5228
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    n = II()
    h = LI()
    dp = [0 for i in range(n)]
    dp[1] = abs(h[0] - h[1])
    for i in range(2,n):
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]))
    print(dp[n-1])
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I():
    return 
#J

#K

#L

#M
#N
# O
# P
# Q
# R
# S
# T
# U
# V
# W
# X
# Y
# Z


#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 55532
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define rep(i,n)for(ll i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll>P;

ll a[10];
map<P, bool>flag;

int main() {
	ll h, w, n; scanf("%lld%lld%lld", &h, &w, &n);
	vector<P>vec;
	rep(i, n) {
		ll a, b; scanf("%lld%lld", &a, &b);
		a--; b--;
		vec.push_back(P(a, b));
	}
	sort(vec.begin(), vec.end(), [](P a, P b) {return a.second < b.second; });
	stable_sort(vec.begin(), vec.end());
	rep(k, vec.size()) {
		for (ll i = -1; i <= 1; i++) {
			for (ll j = -1; j <= 1; j++) {
				ll f = vec[k].first + i, s = vec[k].second + j;
				if (f - 1 >= 0 && s - 1 >= 0 && f + 1 < h&&s + 1 < w && flag[P(f, s)] == false) {
					flag[P(f, s)] = true;
					ll cnt = 0;
					for (ll K = -1; K <= 1; K++) {
						for (ll t = -1; t <= 1; t++) {
							if (binary_search(vec.begin(), vec.end(), P(f + K, s + t)))cnt++;
						}
					}
					a[cnt]++;
				}
			}
		}
	}
	ll sum = (h - 2)*(w - 2);
	rep(i, 10)sum -= a[i];
	printf("%lld\n", sum);
	for (ll i = 1; i < 10; i++)printf("%lld\n", a[i]);
	return 0;
}

Measured memory_bytes: 58068
//include
//------------------------------------------
#include <bits/stdc++.h> // only for GCC

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

//clear memory
// ------------------------------------------
#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
   int n,m,a;
   string s="kogakubu10gokan";
   cin >> n >> m;
   rep(i,n){
      cin >> a;
      if(a<=m) cin >> s;
   }
   cout << s << endl;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  string s,t;
  cin >> s >> t;
  int i,j;
  string ans="Yes";
  for(char c='a';c<='z';c++){
    string cp;
    rep(i,s.size()){
     if(s.at(i)==c){
       cp+=t.at(i);
     }
    }
    sort(cp.begin(),cp.end());
    rep(i,cp.size()-1){
      if(cp.at(i)!=cp.at(i+1)){
        ans="No";
      }
    }
  }
  for(char c='a';c<='z';c++){
    string cp;
    rep(i,s.size()){
     if(t.at(i)==c){
       cp+=s.at(i);
     }
    }
    sort(cp.begin(),cp.end());
    rep(i,cp.size()-1){
      if(cp.at(i)!=cp.at(i+1)){
        ans="No";
      }
    }
  }
  cout << ans;
}
      

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

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

int main()
{
    int K, A, B;
    cin >> K >> A >> B;
    for (int i = A; i <= B;i++){
        if(i % K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  rep(i, N) cin >> h[i];
  
  vector<int> min(N);
  rep(i, N){
  	if(i==0) min[i] = 0;
    else if(i==1) min[i] = abs(h[i-1] - h[i]);
    else{
      if(min[i-2] + abs(h[i-2]-h[i]) <= min[i-1] + abs(h[i-1] - h[i]))
        min[i] = min[i-2] + abs(h[i-2]-h[i]) ;
      else min[i] = min[i-1] + abs(h[i-1]-h[i]) ;
    }
    //cout << min[i] << endl;
  }
  
  cout << min[N-1] << endl;
  return 0;
}

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

int main(){
	int Q=0;
	int C[101];
	int A[101];
	int N[101];
	int cun[101];
	cin>>Q;
	for(int i=0;i<Q;i++){
		cin>>C[i]>>A[i]>>N[i];
		cun[i]=0;
	}
	for(int i=0;i<Q;i++){
		
		while((A[i]>=1)&&(C[i]>=1)&&(N[i]>=1)){
			N[i]--;
			C[i]--;
			A[i]--;
			cun[i]++;
			
		}
		while((A[i]>=1)&&(C[i]>=2)){
			C[i]--;
			C[i]--;
			A[i]--;
			cun[i]++;
			
		}
		while(C[i]>=3){
			C[i]--;
			C[i]--;
			C[i]--;
			cun[i]++;
			
		}
	}
	for(int i=0;i<Q;i++){
		cout<<cun[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<fstream>
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include <cmath>
#include<string.h>
#include <stdio.h>
#include <unordered_map>
#include <queue>
#include<climits>
#include <iomanip>



using namespace std;
#define ll long long
#define clr(x) memset(x, 0, sizeof(x))
#define tcase ll t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define GCJ ll t;cin>>t;for(ll H=1;H<=t;H++){cout<<"CASE #"<<H<<": ";solve();}
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define endl "\n"
//comment out the above line when coding probs which require flushing the output





void solve()
{

    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        
    }
    int dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<endl;
}


int main()
{
    
    
    fast;
    //tcase
    // {
    solve();
    // }
    
}






Measured memory_bytes: 3960
package main

import "fmt"

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func main() {
	var n, a, b, c, d int
	fmt.Scan(&n, &a, &b, &c, &d)
	a-- // 0-indexed
	b--
	c--
	d--
	s := make([]byte, n)
	fmt.Scan(&s)
	for i := a; i < max(c, d); i++ {
		if s[i] == '#' && s[i+1] == '#' {
			fmt.Println("No")
			return
		}
	}
	ok := false
	if c < d {
		ok = true
	} else {
		for i := b; i <= d; i++ {
			if s[i-1] == '.' && s[i] == '.' && s[i+1] == '.' {
				ok = true
				break
			}
		}
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    string s;
    char pre;
    long long int ans[100010] = {};
    int same = 0;

    cin >> s;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'R') {
            same++;
        }
        else {
            if (same % 2) {
                ans[i-1] += same / 2 + 1;
                ans[i] += same / 2;
            }
            else {
                ans[i-1] += same / 2;
                ans[i] += same / 2;
            }
            same = 0;
        }
        if (same > 1) {
            ans[i-1] = 0;
        }
    }

    same = 0;

    for (int i = s.size()-1; i >= 0; i--) {
        if (s[i] == 'L') {
            same++;
        }
        else {
            if (same % 2) {
                ans[i+1] += same / 2 + 1;
                ans[i] += same / 2;
            }
            else {
                ans[i+1] += same / 2;
                ans[i] += same / 2;
            }
            same = 0;
        }
        if (same > 1) {
            ans[i+1] = 0;
        }
    }

    for (int i = 0; i < s.size(); i++) {
        cout << ans[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1536
use proconio::input;

fn main() {
  input! {
    n: usize,
    m: usize,
  }
  let mut wa = vec![0; n];
  let mut ac = vec![0; n];

  let mut score = 0;
  let mut penalty = 0;

  for _ in 0..m {
    input! {
      mut p: usize,
      s: String,
    }
    p -= 1;
    if ac[p] == 0 {
      if s == "AC" {
        ac[p] = 1;
        score += 1;
        penalty += wa[p];
      } else {
        wa[p] += 1;
      }
    }
  }
  println!("{} {}", score, penalty);
}


Measured memory_bytes: 3636
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}

debug dbg;

class BRingosFavoriteNumbers {
public:
	void solve(std::istream& in, std::ostream& out)
	{
        int d, n;
        in >> d >> n;
        if(d == 0){
            if(n == 100) out << 101 << endl;
            else out << n << endl;
        }else if(d == 1){
            if(n == 100) out << n*100 + 100 << endl;
            else out << n*100 << endl;
        }else if(d == 2){
            if(n == 100) out << n*10000 + 10000 << endl;
            else out << n*10000 << endl;
        }
	}
};


int main() {
	BRingosFavoriteNumbers solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
     int a,b,c,d;
     cin >> a >> b >> c >> d;
     
     int start,end,ans;
     
     start = max(a,c);
     end = min(b,d);
     
     ans = end - start;

     if(ans > 0)
          cout  << ans;
     else
          cout << 0;
     
    return 0; 
} 

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	string n;
	cin>>n;
	
	REP(i,3){
		if(n[i]=='7'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	
	cout<<"No"<<endl;
}


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

class Solve {
private:
	using pii = std::pair<int, int>;
	std::map<int, int> placeEmptySize;
	std::map<int, std::pair<int, int>> placeIdSize;
	std::map<int, std::vector<std::pair<int, int>>> idPlace;

	void writeCom()
	{
		int I, S;
		scanf("%d%d", &I, &S);
		idPlace[I];
		auto& vec{idPlace.find(I)->second};
		while (S)
		{
			if (S >= placeEmptySize.begin()->second)
			{
				vec.push_back({*placeEmptySize.begin()});
				S -= placeEmptySize.begin()->second;
				placeIdSize[placeEmptySize.begin()->first] = {I, placeEmptySize.begin()->second};
				placeEmptySize.erase(placeEmptySize.begin());
			}
			else
			{
				pii tmp{placeEmptySize.begin()->first, placeEmptySize.begin()->second};
				vec.push_back({tmp.first, S});
				placeEmptySize.erase(placeEmptySize.begin());
				placeIdSize[tmp.first] = {I, S};
				tmp.first += S;
				tmp.second -= S;
				placeEmptySize.insert(tmp);
				S = 0;
			}
		}
		return;
	}

	void deleteCom()
	{
		int I;
		scanf("%d", &I);
		auto it{idPlace.find(I)};
		for (auto& e: it->second)
		{
			placeEmptySize[e.first] = e.second;
			placeIdSize.erase(e.first);
		}
		idPlace.erase(it);
		return;
	}

	void readCom()
	{
		int P;
		scanf("%d", &P);
		auto tmp{placeEmptySize.upper_bound(P)};
		tmp--;
		if (tmp->first <= P && P < tmp->first + tmp->second)
			puts("-1");
		else
		{
			auto tmp2{placeIdSize.upper_bound(P)};
			tmp2--;
			std::cout << tmp2->second.first << std::endl;
		}
	}

public:
	bool is_last_query{};
	Solve()
	{
		int N;
		scanf("%d", &N);
		if (N == 0)
		{
			is_last_query = true;
			return;
		}
		placeEmptySize[0] = 1 << 30;
		for (int i{}; i < N; i++)
		{
			char com;
			scanf(" %c", &com);
			if (com == 'W')
				writeCom();
			else if (com == 'R')
				readCom();
			else
				deleteCom();
		}
		puts("");
	}
};

int main()
{
	while (!Solve().is_last_query);

	return 0;
}


Measured memory_bytes: 3808