akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class Main {
	
	public static class State implements Comparable<State> {
		int value, pos;
		
		public State (int value, int pos) {
			this.value = value;
			this.pos = pos;
		}

		@Override
		public int compareTo(State o) {
			return Integer.compare(this.value, o.value);
		}
	}
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int[] array = new int[N];
			for(int i = 0; i < N; i++) {
				array[i] = sc.nextInt();
			}
			
			int answer = 0;
			int min = Integer.MAX_VALUE;
			for(int i = 0; i < N; i++) {
				if(min > array[i]) {
					min = array[i];
					answer++;
				}
			}
			System.out.println(answer);

		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 47188
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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 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: 3624
#include <bits/stdc++.h>
using namespace std;
int ma;
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='o')ma++;
  }
  if(ma+15-s.size()>=8)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i,j,array[110][110],r,c;

  for(i=0;i<110;i++){
    for(j=0;j<110;j++)  array[i][j]=0;
  }

  scanf("%d%d",&r,&c);
  for(i=0;i<r;i++){
    for(j=0;j<c;j++)  scanf("%d",&array[i][j]);
  }

  for(i=0;i<r;i++){
    for(j=0;j<c;j++)  array[i][c]+=array[i][j];
  }
  for(j=0;j<=c;j++){
    for(i=0;i<r;i++)  array[r][j]+=array[i][j];
  }

  for(i=0;i<=r;i++){
    for(j=0;j<c;j++)  printf("%d ",array[i][j]);
    printf("%d\n",array[i][c]);
  }

  return 0;
}

Measured memory_bytes: 648
from collections import deque
N, *L = map(int, open(0).read().split())
dic = [[] for i in range(N+1)]
for a,b in zip(*[iter(L)]*2):
  dic[a] += [b]
  dic[b] += [a]
q = deque([1])
  
dist = [-1]*(N+1)
while q:
  v = q.popleft()
  for u in dic[v]:
    if dist[u]==-1:
      dist[u] = dist[v]+1
      q.append(u)
p = max(range(1,N+1),key=lambda x:dist[x])
dist = [-1]*(N+1)
dist[p] = 0
q = deque([p])
while q:
  v = q.popleft()
  for u in dic[v]:
    if dist[u]==-1:
      dist[u] = dist[v]+1
      q.append(u)
M = max(dist)
if M%3==1:
  print('Second')
else:
  print('First')

Measured memory_bytes: 52236
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
#include <list>
//AtCoderC++.cpp

using namespace std;


inline int ceileing(int a, int b) {
	return a % b == 0 ? a / b : a / b + 1;
}
int main() {
	int X; cin >> X;
	int steps;
	for (steps = 0; steps*(steps + 1) / 2 < X; ++steps);
	cout << steps << endl;
}

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

int main(){
	int n;
	int m[31] = {1, 1, 2};

	for(int i= 3; i <= 30; i++){
		m[i] = m[i-1] + m[i-2] + m[i-3];
	}
	while(cin >> n, n){
		cout << m[n] / (365 * 10) + 1 << endl;
	}
}

Measured memory_bytes: 1160
//Author : Sukarna Paul

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1)
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;




int main(){
    IOS
    //freopen("output.txt","w",stdout);
    long double L;
    cin>>L;
    cout<<fixed<<setprecision(9)<<pow(L/3.0,3.0)<<"\n";
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

using ll = long long;

int main(){
	int n;

	cin >> n;

	vector<ll> h;
	
	for (size_t i = 0; i < n; ++i) {
		ll tmp;
		cin >> tmp;
		h.push_back(tmp);
	}
	
	for (int i = n-2; i >= 0; --i) {
		if (h.at(i) > h.at(i+1)) {
			h.at(i) -= 1;
		}
	}

	string ret = "Yes";
	for (int i = 0; i < n-1; ++i) {
		if (h.at(i) > h.at(i+1)) {
			ret = "No";
		}
	}

	cout << ret << endl;
	
	return 0;
}

Measured memory_bytes: 1400
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        // Your code here!
        int[] S = Console.ReadLine().Select(x => int.Parse(x.ToString())).ToArray();
        int min = 1000;
        for(int i = 2; i < S.Length; i++)
        {
            int num = 100 * S[i - 2] + 10 * S[i - 1] + S[i];
            int dif = Math.Abs(753 - num);
            min = Math.Min(min, dif);
        }
        Console.WriteLine(min);
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define ll long long
#define N 2005
using namespace std;
inline int read(){
  int x = 0, f = 0;char ch = getchar();
  for (; ch <'0' || ch>'9'; ch = getchar()) if (ch == '-') f = 1;
  for (; ch >= '0'&& ch<='9'; ch = getchar()) x = (x<<1) + (x<<3) + ch - 48;
  return f ?-x :x;
}
int n, k, head[N], cnt, dis[N];
struct edge {
  int nxt, fir, to;
}e[N<<1];
inline void insert(int u, int v) {
  e[++cnt] = (edge) {head[u], u, v}; head[u] = cnt;
  e[++cnt] = (edge) {head[v], v, u}; head[v] = cnt;
}
int tmp, ans;
inline void dfs(int x, int fa, int Cnt) {
  tmp++;
  if (!Cnt) return;
  for (int y, i = head[x]; i; i = e[i].nxt)
    if((y = e[i].to) != fa)
      dfs(y, x, Cnt-1);
}
int main() {
  n = read(); k = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read();
    insert(u, v);
  }
  if (k&1) {
    for (int i = 1; i < n; i += 2) {
      tmp = 0;
      dfs(e[i].fir, e[i].to, k/2);
      dfs(e[i].to, e[i].fir, k/2);
      ans = max(ans, tmp);
    }
  } else {
    for (int i = 1; i <= n; i++) {
      tmp = 0;
      dfs(i, 0, k/2);
      ans = max(ans, tmp);
    }
  }
  printf("%d\n", n-ans);
  return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		HashMap hs = new HashMap();
		ArrayList<Integer> al = new ArrayList<Integer>();
		ArrayList<Integer> la = new ArrayList<Integer>();
		PrintWriter ou = new PrintWriter(System.out);
		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		int[][] c = new int[h][w];
		for(int i = 0 ; i < h ; i++){
			Arrays.fill(c[i] , 0);
			String s = sc.next();
			for(int j = 0 ; j < w ; j++){
				if(s.charAt(j) == '#') c[i][j] = 1;
			}
		}
		sc.close();
		long ans = 0;
		for(int i = 0 ; i < 1 << h ; i++){
			al.clear();
			for(int j = 0 ; j < h ; j++){
				if((1 & i >> j) == 1) al.add(j);
			}
			for(int j = 0 ; j < 1 << w ; j++){
				la.clear();
			    for(int kk = 0 ; kk < w ; kk++){
					if((1 & j  >> kk) == 1) la.add(kk);
				}
				int yono = 0;
				for(int ebi = 0 ; ebi < h ; ebi++){
					for(int shu = 0 ; shu < w ; shu++){
						if(c[ebi][shu] == 1 && al.contains(ebi) && la.contains(shu))yono++;
					}
				}
				if(yono == k) ans++;
			}
		}
		ou.print(ans + "\n");
		ou.flush();
	}
}

Measured memory_bytes: 41068
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;

const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;

void solve(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if (a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES";
    else cout << "NO";
}

int main()
{
    OP
    solve();
    return 0;
}    
    
    


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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



  cin >> n >> m;
  for (ll i = m - (n - 1); i <= m + (n - 1); i++) cout << i << " ";
  cout << endl;




  return 0;
}


Measured memory_bytes: 256
//
// Created by yozaam on 23/06/20.
//

//
// Created by yozaam on 12/06/20.
//

//
// Created by yozaam on 04/06/20.
//



/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>




#define fo(start,n) for(size_t i = start; i < n; ++i)


// unordered_map<int,int>mp;
// mp.reserve(1024);            //FAST UMAP
// mp.max_load_factor(0.25);
typedef long long ll;



using namespace std;



int main() {
    // your code goes here
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    double n , d;

    cin>>n>>d;int c = 0;

    while(n--){
        double x , y;
        cin>>x>>y;

        if(sqrt(x*x + y*y) <=d)c++;
    }

    cout<<c;
    
    return 0;
}
//
// Created by yozaam on 13/06/20.
//



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

const long long MOD = 1000000007;

// 階乗計算
long long factorial(int k){
  long long sum = 1ll;
  for (int i=1; i<=k; i++) {
    sum *= i;
    sum %= MOD;
  }
  return sum;
}

int main() {
  int N, M;
  cin >> N >> M;
  long long ans = 0ll;
  if (abs(N-M)==0) ans = 2*factorial(N)*factorial(M)%MOD;
  else if (abs(N-M)==1) ans = factorial(min(N, M))*factorial(min(N, M)+1)%MOD;
  cout << ans << endl;
}

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

int main( )
{
	int n, x;
	cin >> n >> x;
	int a = 0;
	int ans = 0;
	if( a <= x )
		ans ++;
	for( int i = 0; i < n; ++ i )
	{
		int t;
		cin >> t;
		a = a + t;
		if( a <= x )
			ans ++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
// Problem : E - Replace Digits
// Contest : AtCoder - ACL Beginner Contest
// URL : https://atcoder.jp/contests/abl/tasks/abl_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

// Macros

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int, int>
#define mii map<pii, int>
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(x) (int) x.size()
#define mod 998244353
#define EPS 1e-9
#define inf 1e10
#define PI acos(-1.0)
#define int long long
#define N 200005

// Solution

int n, q;

int binpow(int x, int y) {
  x %= mod;
  int res = 1;
  while (y) {
    if (y & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    y = y / 2;
  }
  return res;
}

int inv(int a) { return binpow(a, mod - 2); }

int INV = inv(9);

int f(int l, int r, int d) {
  int cur = binpow(10, n - r - 1);
  cur *= (binpow(10, r - l + 1) - 1 + mod) % mod;
  cur %= mod;
  cur *= d;
  cur %= mod;
  cur *= INV;
  cur %= mod;
  return cur;
}

int t[4 * N], lazy[4 * N];

void push(int v, int tl, int tr) {
  int tm = (tl + tr) / 2;
  if (lazy[v]) {
    t[v * 2] = f(tl, tm, lazy[v]);
    lazy[v * 2] = lazy[v];
    t[v * 2 + 1] = f(tm + 1, tr, lazy[v]);
    lazy[v * 2 + 1] = lazy[v];
    lazy[v] = 0;
  }
}

void update(int v, int tl, int tr, int l, int r, int d) {
  if (l > r) return;
  if (tl >= l && tr <= r) {
    t[v] = f(tl, tr, d);
    lazy[v] = d;
  } else {
    push(v, tl, tr);
    int tm = (tl + tr) / 2;
    update(v * 2, tl, tm, l, min(tm, r), d);
    update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, d);
    t[v] = t[v * 2] + t[v * 2 + 1];
  }
}

int get(int v, int tl, int tr, int l, int r) {
  if (l > tr || r < tl) return 0;
  if (tl >= l && tr <= r) return t[v];
  push(v, tl, tr);
  int tm = (tl + tr) / 2;
  int ret = 0;
  if (l <= tm) {
    ret += get(v * 2, tl, tm, l, r);
    ret %= mod;
  }
  if (r > tm) {
    ret += get(v * 2 + 1, tm + 1, tr, l, r);
    ret %= mod;
  }
  return ret;
}

void solve() {
  cin >> n >> q;
  int ans = f(0, n - 1, 1);
  update(1, 0, n - 1, 0, n - 1, 1);
  while (q--) {
    int l, r, d;
    cin >> l >> r >> d;
    l--, r--;
    int sum = get(1, 0, n - 1, l, r);
    int now = f(l, r, d);
    update(1, 0, n - 1, l, r, d);
    ans = (ans - sum + mod) % mod;
    ans = (ans + now) % mod;
    cout << ans << '\n';
  }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

  int tests;
  tests = 1;
  // cin>>tests;

  for (int test = 1; test <= tests; test++) {
    // cout<<"Case #"<<test<<": ";
    solve();
  }

  return 0;
}

Measured memory_bytes: 11816
#include <iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
int i=-1,j=0,mem;
    string str[1000]={""};
    char ch[1000];
    while(1){
        i++;
        scanf("%c",&ch[i]);
        if(ch[i]=='\n')break;
        if(ch[i]==' ')j++;
        else{
            if(ch[i]!=' '){
            str[j]+=ch[i];
            }
        }
    }
    for(int k=0;k<=j+1;k++){
        mem=str[k].find("apple");
        if(mem!=-1){
            str[k].replace(mem,5,"peach");
        }
        else{
            mem=str[k].find("peach");
            if(mem!=-1){
            str[k].replace(mem,5,"apple");            }
        }
    }
    for(int k=0;k<=j;k++){
        if(k==j)cout<<str[k]<<endl;
        else cout<<str[k]<<" ";
    }
            return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(b);i++)//no need to declare variable i
#define REP2(a,b) for(lo j=(a);j<(b);j++)
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(d);j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for((a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for((a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRvl(c) for (vl::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvll(c) for (vll::iterator it = (c).begin(); it != (c).end(); it++
#define INF 2000000000
#define gc getchar_unlocked
#define pc putchar_unlocked3
#define pb(a) push_back((a))
 
//UVa
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
 

lo cel(lo x,lo y){
	if(x%y<=1)return x/y;
	else return x/y +1;
}
 void solve(){
 	lo n;
 	cin>>n;
 	vl a(100001,0);
 	REP(100,106)a[i]=1;
 	REP(106,100001){
 		REP2(i-105,i-100+1){
 			if(a[j]==1){
 				a[i]=1;
 				break;
 			}
 		}
 	}
 	//REP(99,212)cout<<a[i]<<endl;
 	if(a[n])cout<<"1";
 	else cout<<'0';
 }

int main(){
	
	
 
	lo n;
	//cin>>n;
	//while(n--)
		solve();
	
	return 0;
}

Measured memory_bytes: 1024
from bisect import*
from math import*

n=int(input())
arr=list(map(int,input().split()))
arr.sort(reverse=True)
ans=1
z=0
for x in arr:
	ans*=x
	if ans>1000000000000000000:
		z=1
		break
if 0 in arr:
	print("0")
else:
	if z==1:
		print("-1")
	else:
		print(ans)

Measured memory_bytes: 84612
#include <bits/stdc++.h>
#include<utility>
#include<algorithm>

#define pan(i,n) for(ll i=0;i<n;i++)
#define pans(i,n,a) for(ll i=a;i<n;i++)
#define ll long long int
#define vi vector<ll>
#define vl vector<ll>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
#define inf 200007
#define P pair<ll,ll>
#define mp make_pair

using namespace std; 

int main(){
    ll n,h,slash=0,count=0,ans=0;
    cin>>n>>h;
    vector<P> v,q;
    pan(i,n){
        ll x,y;
        cin>>x>>y; 
        v.pb(mp(x,y));
        q.pb(mp(y,x));
    }
    sort(v.begin(),v.end());
    sort(q.begin(),q.end());
    
    slash=v[n-1].first;

    for(int i=n-1;i>=0;i--){
        if(ans<h)
            if(q[i].first>slash) ans+=q[i].first,count++;
        else 
            break;
    }
    if(ans<h){
        if((h-ans)%slash==0) count+=(h-ans)/slash;
        else if((h-ans)%slash>0) count+=((h-ans)/slash)+1;
    }
    cout<<count;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';



int main() {
    int n,a[3];
    cin >> n;
    for (int i = 0;i < 3;++i) cin >> a[i];
    vector<string> s(n);
    vector<P> x(n);
    for (int i = 0;i < n;++i) cin >> s[i];
    for (int i = 0;i < n;++i) x[i] = make_pair(s[i][0]-'A',s[i][1]-'A');
    /*
    if (a[0]+a[1]+a[2] <= 1) {
        int b[3];
        for (int i = 0;i < 3;++i) b[i] = a[i];
        for (int i = 0;i < n;++i) {
            if (b[x[i].first] == 0 && b[x[i].second] == 0) {
                cout << "No" << endl;
                return 0;
            }
            swap(b[x[i].first],b[x[i].second]);
        }
    }*/
    vector<int> ans(n);
    for (int i = 0;i < n;++i) {
        bool f[3] = {0,0,0};
        if (i+1 < n) f[x[i+1].first] = f[x[i+1].second] = true;
        if (a[x[i].second] > 0 && (f[x[i].first] || a[x[i].first] == 0)) {
            a[x[i].first]++;
            a[x[i].second]--;
            ans[i] = x[i].first;
        } else if (a[x[i].first > 0]) {
            a[x[i].first]--;
            a[x[i].second]++;
            ans[i] = x[i].second;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for (int i = 0;i < n;++i) cout << char('A'+ans[i]) << newl;
}

Measured memory_bytes: 7468
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

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

	static class TaskC {
		public void solve(int testNumber, Scanner sc, PrintWriter out) {

			int n = sc.nextInt();
			int[] a = sc.nextIntArray(n);

			int maxCost = Math.abs(a[0]) + Math.abs(a[n - 1]);
			int[] cost = new int[n];
			for (int i = 0; i < n - 1; i++) {
				cost[i] = Math.abs(a[i + 1] - a[i]);
				maxCost += cost[i];
			}

			out.println(maxCost - (Math.abs(a[0]) + cost[0]) + Math.abs(a[1]));
			for (int i = 1; i < n - 1; i++) {
				out.println(maxCost - (cost[i - 1] + cost[i]) + Math.abs(a[i + 1] - a[i - 1]));
			}
			out.println(maxCost - (Math.abs(a[n - 1]) + cost[n - 2]) + Math.abs(a[n - 2]));

		}

	}

	static class Scanner {
		private final InputStream in;
		private final byte[] buffer;
		private int ptr;
		private int buflen;

		public Scanner(InputStream in) {
			this.in = in;
			this.buffer = new byte[1024];
			this.ptr = 0;
			this.buflen = 0;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) return true;
			else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) return false;
			}
			return true;
		}

		private byte readByte() {
			if (hasNextByte()) return buffer[ptr++];
			return -1;
		}

		private boolean isPrintableChar(byte c) {
			return '!' <= c && c <= '~';
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
				ptr++;
			}
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public int nextInt() {
			if (!hasNext()) throw new NoSuchElementException();
			int n = 0;
			boolean minus = false;
			byte b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) throw new NumberFormatException();
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}

	}
}



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

int main(){
    ll n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    int total = 0;
    int nextval = 1;
    for(int i=0;i<n;i++){
        if(a.at(i) == nextval){
            nextval++;
        }else{
            total++;
        }
    }

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

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,f,n) for(int i=f;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;

signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    umap<int, int> mp1;
    umap<int, int> mp2;

    reps(i,1,n){
        int a;
        cin >> a;
        mp1[a - i]++;
        mp2[-a - i]++;
    }

    int res = 0;
    for(auto [x,y] : mp1){
        res += y * mp2[x];
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 26288
from bisect import bisect_right, bisect_left
from itertools import groupby, permutations, combinations
from fractions import gcd
import numpy as np
from sys import stdin, stderr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def cnt(x):
    if x == 1:
        return 1
    return 2 * cnt(x // 2) + 1


def main():
    H = int(input())
    return cnt(H)


if __name__ == "__main__":
    print(main())


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

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

    int n; cin >> n;
    string s1,s2; cin >> s1 >> s2;

    int ans = 1;
    int i = 0;
    bool tate = true;

    if(s1.at(i) == s2.at(i)){
        ans *= 3;
        i ++;
        tate = true;
    }else{
        ans *= 6;
        i += 2;
        tate = false;
    }

    if(i == s1.size()){
        cout << ans << endl;
        return 0;
    }

    for(;i < s1.size();){
        if(s1.at(i) == s2.at(i) && tate == true){
            ans *= 2;
            ans %= 1000000007;
            i ++;
            tate = true;
        }else if(s1.at(i) == s2.at(i) && tate == false){
            i ++;
            tate = true;
        }else if(s1.at(i) != s2.at(i) && tate == true){
            ans *= 2;
            ans %= 1000000007;
            i += 2;
            tate = false;
        }else{
            ans *= 3;
            ans %= 1000000007;
            i += 2;
            tate = false;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using i64 = long long;

i64 abs(i64 x) {
	return x < 0 ? -x : x;
}

const int N = 100000 + 7;

int n, s;
int x[N], p[N];

i64 dfs(int l, int r, i64 u, i64 v) {
	if (s < x[l]) return x[r] - s;
	if (s > x[r]) return x[l] - s;
	if (u + p[l] >= v + p[r]) {
		i64 t = dfs(l, r - 1, u + v + p[r], 0);
		return x[r] - (t > 0 ? x[r - 1] : x[l]) + abs(t);
	}
	if (u + p[l] < v + p[r]) {
		i64 t = dfs(l + 1, r, 0, u + v + p[l]);
		return x[l] - (t > 0 ? x[r] : x[l + 1]) - abs(t);
	}
}

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);

	scanf("%d%d", &n, &s);
	for (int i = 1; i <= n; ++i)
		scanf("%d%d", x + i, p + i);
	printf("%lld\n", abs(dfs(1, n, 0, 0)));
	return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
#define INF 0x3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn=1e4+10;
int main()
{
    int x;
    cin>>x;
    cout<<(x^1);
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    vector<int> vec1(5, 0);
    REP(i, n) if(a[i] % 4 == 0) vec1[4]++; else if(a[i] % 2 == 0) vec1[2]++; else vec1[0]++;

    if(vec1[4] >= n/2 || vec1[4] >= vec1[0]) cout << "Yes" << endl;
    else cout << "No" << endl;

}


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

int main(){
  ll N;
  string S;
  cin >> N;
  cin >> S;

  vector<ll> R(N);
  vector<ll> G(N);
  vector<ll> B(N);

  ll rsum = 0;
  ll gsum = 0;
  ll bsum = 0;
  for(ll i=N-1; i>=0; i--){
    if(S[i] == 'R') rsum += 1;
    if(S[i] == 'G') gsum += 1;
    if(S[i] == 'B') bsum += 1;
    R[i] = rsum;
    G[i] = gsum;
    B[i] = bsum;
  }

  ll sum = 0;
  for(ll i=0; i<N-2; i++){
    for(ll j=i+1; j<N-1; j++){
      ll l1 = S[i];
      ll l2 = S[j];
      ll last = 0;

      if(l1 == 'R' && l2 == 'G') last = B[j+1];
      if(l2 == 'R' && l1 == 'G') last = B[j+1];
      if(l1 == 'R' && l2 == 'B') last = G[j+1];
      if(l2 == 'R' && l1 == 'B') last = G[j+1];
      if(l1 == 'G' && l2 == 'B') last = R[j+1];
      if(l2 == 'G' && l1 == 'B') last = R[j+1];
      sum += last;
      ll k = j+j-i;
      if(k < N && S[i]!=S[j] && S[i]!=S[k] && S[j]!=S[k]){
        sum -= 1;
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,p,i,w=0,r=0;
    string s;
    cin>>n>>m;
    int a[n]={0},b[n]={0};
    for(i=0;i<m;i++)
    {
        cin>>p;
        cin>>s;
        if(s=="AC")
        {
            if(a[p-1]==0)
            {
                a[p-1]=1;
                r++;
                w+=b[p-1];
            }
        }
        else if(s=="WA")
        {
            if(a[p-1]==0)
            {
                b[p-1]++;
            }
        }
    }
    cout<<r<<" "<<w;
    return 0;
}

Measured memory_bytes: 1024
from collections import Counter
import numpy as np
n = int(input())
A = [0] + list(np.cumsum(list(map(int, input().split()))))
a = Counter(A[1:])
ans = 0
for x,y in a.items():
    if x == 0: ans += y
    if y >= 2:
        ans += y*(y-1)//2
print(ans)

Measured memory_bytes: 54052
N,K = map(int,input().split())
LR = [list(map(int,input().split())) for _ in range(K)]
LR = sorted(LR)

MOD = 998244353
dp = [0] * (N+1)
dp[1] = 1
for i in range(1,N):
  dp[i]%=MOD
  for l,r in LR:
    if i+l<=N:
      dp[i+l] += dp[i]
    if i+r+1<=N:
      dp[i+r+1] -= dp[i]
      
  if i!=1:
    dp[i+1] += dp[i]
    

print(dp[-1]%MOD)

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

int main()
{
  string S;
  cin >> S;
  sort(S.begin(), S.end());
  if (S[0] == S[1] && S[1] != S[2] && S[2] == S[3])
    cout << "Yes";
  else
    cout << "No";
  return 0;
}


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

void prians(bool answer) {
  if(answer)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

int n, k;

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

  prians((n + 1) / 2 >= k);
  return 0;
}

Measured memory_bytes: 256
from sys import stdin
N=int(stdin.readline().rstrip())
a=[N]+[0]*10000
for i in range(10000):
    if i !=0:
        if a[i-1]%2==0:
            a[i]=int((a[i-1]/2))
        else:
            a[i]=int((3*a[i-1]+1))
cnt=1
tmp=[]
for j in a:
    if str(j) in tmp:
        break
    else:
        tmp.append(str(j))
        cnt+=1
print(cnt)

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

using namespace std;

typedef pair<int, int> pi;
const int MAXN = 51;
int n, d, ans;
int arr[MAXN][MAXN];

bool solve(int x, int y) {
	int sum = 0;
	for (int i = 0; i < d; i++) {
		int val = (arr[x][i] - arr[y][i]) * (arr[x][i] - arr[y][i]);
		sum += val;
	}

	int tmp = sqrt(sum);

	if (tmp * tmp == sum) return true;
	return false;
}

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

	cin >> n >> d;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> arr[i][j];
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (solve(i, j)) {
				ans++;
			}
		}
	}

	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



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

	for (int i = 0; i < 3; i++) {
		//cout << str[i];
		if (str[i] == '1') str[i] = '9';
		else if (str[i] == '9') str[i] = '1';
	}

	cout << str;

	cout << endl;
	return 0;
}

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

int main() {
    string a;
    int sum=0, y;
    getline(cin,a);
    while(a!="0"){
        y=a.length();
        int i=0;
        sum=0;
        while(i<y){
            sum+=a[i]-48;
            i++;
    
        }
        cout << sum << endl;
        getline(cin,a);
       
    }
}


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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int n, k;
string s, sr;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n >> k >> s;
  sr = s;
  reverse(sr.begin(), sr.end());
  vector<string> v;
  for (int i = 0; i < n; i++) {
    string h = s.substr(i, n - i) + sr.substr(0, i);
    v.push_back(h);
  }
  sort(v.begin(), v.end());
  string r = v[0];
  k = min(k - 1, 15);
  for (int i = 0; i < k; i++) {
    int j = 0;
    while (j < n - 1 && r[j + 1] == r[j])
      j++;
    r = r.substr(0, j + 1) + r;
    r = r.substr(0, n);
  }
  cout << r << "\n";
}


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

ans = [[-1]*N for i in range(N)]

mx = 0
for i in range(N-1):
    for j in range(i+1,N):
        k = j-i
        a = 1
        while k&1==0:
            a += 1
            k >>= 1
        ans[i][j] = a
        mx = max(mx, a)

for i,row in enumerate(ans[:-1]):
    print(*(row[i+1:]))

Measured memory_bytes: 6000
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int n;
      cin>>n;

       map<string,int>p;

        for(int i=1;i<=n;i++){
           string s;
            cin>>s;

             if(p.find(s)==p.end()){

                p.insert(pair<string,int>(s,1));
             }
        }
        cout<<p.size();
}


Measured memory_bytes: 19180
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    int n,x,y,s=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x>>y;
        s+=y-x+1;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }
	sort(a.begin(), a.end(), greater<ll>());

	ll max_n = max(K, a[0]);
	int k = 0;
	while (pow(2, k) <= max_n) { ++k; }

	vector<int> d(k, 0);
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < k; ++j) {
			if ((a[i]>>j) & 1) {
				d[k - j - 1] += 1;
			}
		}
	}

	vector<int> wl(k);
	for (int i = 0; i < k; ++i) {
		wl[k - i - 1] = (K>>i) & 1;
	}
	bool ok = false;
	vector<int> x(k);
	for (int i = 0; i < k; ++i) {
		if (((N + 1) / 2) <= d[i]) {
			x[i] = 0;
			if (wl[i] > 0) { ok = true; }
		} else {
			if ((wl[i] == 1) || ok) {
				x[i] = 1;
			} else {
				x[i] = 0;
			}
		}
	}

	ll X = 0;
	for (int i = 0; i < k; ++i) {
		X *= 2;
		X += x[i];
	}

	ll res = 0;
	for (int i = 0; i < N; ++i) {
		res += (a[i] ^ X);
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 1024
#include"bits/stdc++.h"
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;
int64_t i,j,k,l;//preparation for
int main(){
    string b;
    cin>>b;
     if('A'<=b[0]&&b[0]<='Z'){
         cout<<"A";
     }
     else{
         cout<<"a";
     }

    return 0;
}

Measured memory_bytes: 3588
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int n,a[200005],ans;
signed main(){
	cin>>n;
	FOR(i,1,n)cin>>a[i];
	FOR(i,2,n){
		if(a[i]<a[i-1]){
			ans+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	}
	cout<<ans;
	RE 0;
}


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

using namespace std;

static constexpr int MAX_S = 100;

int a, b, c;
char s[MAX_S];

void input()
{
  scanf("%d %d", &a, &b);
}

void solve()
{
  printf("%d", a + b / 2);
}

int main()
{
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
// Try AtCoder
// author: Leonardone @ NEETSDKASU

[<EntryPoint>]
let main _ =
   let n = int <| stdin.ReadLine()
   seq { 1 .. n }
   |> Seq.map (fun _ -> stdin.ReadLine().Split(' ')
                                  |> Array.map int)
   |> Seq.sortBy (fun p -> Array.get p 1)
   |> Seq.head
   |> function [|x; y|] -> x + y
   |> printfn "%A"
   0

Measured memory_bytes: 30392
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int a, b, c; cin >> a >> b >> c;
    cout << (a - c) / (b + c) << endl;
}

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

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        var S = cin.next;
        int N = S.Length;
        var A = new int[3];
        for (int i = 0; i < N; i++)
        {
            A[S[i] - 'a']++;
        }
        var B = new int[3];
        B[0] = Math.Abs(A[0] - A[1]);
        B[1] = Math.Abs(A[1] - A[2]);
        B[2] = Math.Abs(A[2] - A[0]);
        if (B.Max() <= 1)
        {
            WriteLine("YES");
        }
        else
        {
            WriteLine("NO");
        }


    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13792
#include<iostream>
using namespace std;
int main()
{
  int n,t,i,j,jj;
  int a[4],p[3];
  cin >> n;
  for(i=3;i>=0;i--){
    a[i]=n%10;
    n/=10;
  }
  for(j=0;j<8;j++){
    jj=j;
    t=a[0];
    for(i=0;i<3;i++){
      p[i]=jj%2;
      jj/=2;
      if(p[i]>0)
        t+=a[i+1];
      else
        t-=a[i+1];
    }
    if(t==7)
      break;
  }
  for(i=0;i<3;i++){
    cout << a[i];
    if(p[i]>0)
      cout << "+";
    else
      cout << "-";
  }
  cout << a[3] << "=7" << endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.algorithm, std.array, std.range;

void main()
{
    for(string s_; (s_=readln().chomp()).length;)
    {
        auto NM = s_.split().map!(to!int)();
        immutable N=NM[0], M=NM[1];
        auto xy = new int[][M];
        foreach(ref a;xy) a=readln.split.map!(x=>x.to!int()-1).array();
        auto c = new int[N]; c[]=1;
        auto p = new bool[N]; p[]=false; p[0]=true;
        foreach(ref a;xy)
        {
            immutable x=a[0], y=a[1];
            ++c[y]; p[y]=p[y]||p[x];
            --c[x]; p[x]=p[x]&&c[x]!=0;
        }
        writeln(count(p,true));
    }
}

Measured memory_bytes: 10748
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{

    long long input;
    long long num;
    int i, j;
    
    scanf("%lld",&input);
    for (i = 0; i < input; i++) {
        scanf("%08lld",&num);
        printf("Case %d:\n",i + 1);
        for (j = 0; j < 10; j++) {
            num = pow(num, 2);
            num %= 1000000;
            num /= 100;
            printf("%lld\n",num);
        }

        
    }
    return 0;
}

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

int main(void){

    long int i, n, d, x, y, count=0;
    double a;

    scanf("%ld%ld",&n,&d);

    for(i=0;i<n;i++){
        scanf("%ld%ld",&x,&y);

        x*=x;
        y*=y;

        a = sqrt(x+y);
        if(a<=d){
            count++;
        }
    }

    printf("%ld",count);

    return 0;
}

Measured memory_bytes: 2148
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let c = a * b;
    if c % 2 == 0 {
        println!("Even")
    } else {
        println!("Odd")
    }
}


Measured memory_bytes: 2056
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces
gi = lambda : list(map(int,input().split()))
n, m = gi()
print((n * (n - 1)) // 2 + (m * (m - 1)) // 2)

Measured memory_bytes: 2940
S = input()
T = input()

ans = 0

for i in range(len(S)-len(T)+1):
  same = 0
  for j in range(len(T)):
    if S[i+j] == T[j]:
      same += 1
  else:
    ans = max(ans, same)
    
print(len(T) - ans)

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

using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a+b==15){
    cout << "+" << endl;
  }else if(a*b==15){
    cout << "*" << endl;
  }else{
    cout << "x" << endl;
  }
}

Measured memory_bytes: 256