akhauriyash/Code-Regression huggingface dataset:
#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
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1'000'000'007;
constexpr ll mod2 = 998244353;
const double PI = 3.14159265358;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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 main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  if(N <= 5){
    vector<int> A = {2,5,63,20,30};
    for(int i=0; i<N; i++){
      cout << A[i] << " \n"[i+1==N];
    }
    return 0;
  }
  int sum = 0;
  vector<int> ans;
  vector<int> vec = {2,3,4,6};
  int now = 0;
  while(1){
    if(ans.size() == N) break;
    for(int i=0; i<4; i++){
      if(ans.size() == N) break;
      ans.emplace_back(now + vec[i]);
      sum += now + vec[i];
      sum %= 6;
    }
    now += 6;
  }
  if(sum == 2){
    ans.erase(ans.begin());
    ans.emplace_back(30000);
  }else if(sum == 3){
    ans.erase(ans.begin()+1);
    ans.emplace_back(30000);
  }else if(sum == 5){
    ans.erase(ans.begin()+1);
    ans.emplace_back(30000-2);
  }
  for(int i=0; i<ans.size(); i++){
    cout << ans[i] << " \n"[i+1==ans.size()];
  }
  return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF INT_MAX
#define inf LLONG_MAX
#define PI acos(-1)
using namespace std;

const int N = 1e6 + 5;

const LL mod = 1e9 + 7;

LL ksm(LL a, LL b) { LL ans = 1LL; while(b) { if(b & 1) ans = ans * a % mod; a = a * a % mod; b >>= 1; }  return ans; }

char a[N];
int fac[N];

void init(int n) {
    fac[0] = 0;
    rep(i, 1, n) {
        fac[i] = fac[i - 1];
        int tmp = i;
        while(tmp % 2 == 0) {
            fac[i]++;
            tmp = tmp / 2;
        }
    }
}

int C(int n, int m) {
    return fac[n] - fac[m] - fac[n - m];
}

void solve() {

    int n;

    scanf("%d", &n);

    scanf("%s", a + 1);

    bool flag0 = 0, flag1 = 0, flag2 = 0;

    rep(i, 1, n) {
        a[i]--;
        if(a[i] == '0') flag0 = 1;
        if(a[i] == '1') flag1 = 1;
        if(a[i] == '2') flag2 = 1;
    }
    if(flag0 + flag1 + flag2 <= 1) {
        puts("0"); return ;
    }

    init(n);

    int ans = 0;
    if(flag1) {
        rep(i, 1, n) {
            if(a[i] == '1') {
                if(C(n - 1, i - 1) == 0) ans ^= 1;
            }
        }
    }
    else {
        rep(i, 1, n) {
            if(a[i] == '2') {
                if(C(n - 1, i - 1) == 0) ans ^= 1;
            }
        }
        ans = ans * 2;
    }
    printf("%d\n", ans);
}


int main() {
//    int _; scanf("%d", &_);
//    while(_--) solve();
//
    solve();

    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int N;
int F[110][15];
int P[110][15];

int ans = -1e+9;
int a[10];

void func() {
  bool all_0 = true;
  REP(i,10) {
    if (a[i] != 0) all_0 = false;
  }
  if (all_0) {
    return;
  }
  int score = 0;
  int cnt[N] = {0};
  REP(i,N) {
    REP(j,10) {
      if (a[j]==1 && F[i][j]==1) {
        cnt[i]++;
      }
    }
    score += P[i][cnt[i]];
  }

  ans = max(ans,score);
}

void dfs(int pos) {
  if (pos == 10) {
    func();
    return;
  }
  a[pos] = 0; dfs(pos+1);
  a[pos] = 1; dfs(pos+1);
}

int main () {
  cin >> N;
  REP(i,N) REP(j,10) cin >> F[i][j];
  REP(i,N) REP(j,11) cin >> P[i][j];

  dfs(0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.text.*;
public class Main {
	static class Point{
		int x;
		int y;
		public Point(int xx, int yy){
			x = xx;
			y = yy;
		}
	}
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			int w = in.nextInt();
			int h = in.nextInt();
			if((w|h)==0) break;
			boolean[][] land = new boolean[h][w];
			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					if(in.nextInt()==1) land[i][j] = true;
					else land[i][j] = false;
				}
			}
			
			LinkedList<Point> queue = new LinkedList<Point>();
			int lands = 0;
			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					if(land[i][j]){
						lands++;
						land[i][j]=false;
						queue.add(new Point(i,j));
						while(!queue.isEmpty()){
							Point base = queue.poll();
							for(int x=-1; x<=1; x++){
								for(int y=-1; y<=1; y++){
									if(0<=base.x+x && base.x+x<h && 0<=base.y+y && base.y+y<w){
										if(land[base.x+x][base.y+y]){
											land[base.x+x][base.y+y] = false;
											queue.add(new Point(base.x+x,base.y+y));
										}
									}
								}
							}
						}
					}
				}
			}
			System.out.println(lands);
		}
	}
}

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

int main(){
  char c;
  while(scanf("%c", &c) != EOF) {
    if(c == '\n') {
      break;
    }
    if('a' <= c && c <= 'z') {
      c = c - 0x20;
    } else if ('A' <= c && c <= 'Z') {
      c = c + 0x20;
    }
    printf("%c", c);
  }
  printf("\n");
  return 0;
}



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

int main()
{
    int M, D, ans = 0;
    cin >> M >> D;

    for(int i = 1;i <= M;i++){
        for(int j = 1;j <= D;j++){
            int d1, d2;
            d1 = j / 10;
            d2 = j % 10;

            if(d1 >= 2 && d2 >= 2 && d1 * d2 == i){
                ans++;
            }
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
import heapq

#制約の厳しい方からみていく
#残り1日、残り2日ってかんじでうしろから見ていく
#N件のバイト,M日後までに得られる報酬の最大値
#間に合う日数の中で最大報酬のものを選ぶ
#⇒最大のものを選ぶ⇒優先度付きキュー
N,M = map(int,input().split())
#A日後に報酬B
AB =[]
for i in range(N):
    AB.append(list(map(int,input().split())))

#日数が少ない順でソート
AB = sorted(AB)

ans = 0
count = 0
q=[]

for i in range(1,M+1): #残り日数から考える
    while ( count < N) and (AB[count][0] <= i):
        heapq.heappush(q, (-1) * AB[count][1])
        count += 1
    if len(q):
        ans += (-1) * heapq.heappop(q)

print(ans)


Measured memory_bytes: 73688
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int a, b;


signed main(){
    cin >> a >> b;

    if(a > b) swap(a, b);

    rep(i, 0, b) cout << a;
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

namespace test1
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			int a = int.Parse(Console.ReadLine());
			int b = int.Parse(Console.ReadLine());
			int h = int.Parse(Console.ReadLine());

			int ans = (a + b) * h / 2;

			Console.WriteLine(ans);

#if DEBUG
			Console.Write("Press any key to continue.");
			Console.ReadKey();
#endif
		}
	}
}


Measured memory_bytes: 2648
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef double db;
const int mod = 1e9+7;
const int N = 400 + 5;
const int M = 400 + 5;
int n, m, k;
char s[N][N];
int a[N][N];
int g[M][M], dis[M][M];

bool ok(int x, int y){
    if(x<1||x>n||y<1||y>m||s[x][y]=='#') return 0;
    return 1;
}

int main(){
    scanf("%d%d", &n, &m);//<=20
    rep(i,1,n) scanf("%s", s[i]+1);
    int cnt=0;
    rep(i,1,n) rep(j,1,m) a[i][j] = ++cnt;
    memset(g,inf,sizeof(g));
    rep(i,1,n) rep(j,1,m){
        if(s[i][j]=='#') continue;
        int x=i+1, y=j;
        int u=a[i][j], v=a[x][y];
        if(ok(x,y)) g[u][v]=g[v][u]=1;
        x=i; y=j+1;
        u=a[i][j], v=a[x][y];
        if(ok(x,y)) g[u][v]=g[v][u]=1;
    }
    rep(i,1,cnt) g[i][i]=0;
    rep(k,1,cnt) rep(i,1,cnt) rep(j,1,cnt)
        if(g[i][j]>g[i][k]+g[k][j])
            g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
    int ans=-1;
    rep(i,1,cnt) rep(j,1,cnt)
        if(g[i][j]!=inf) ans=max(ans, g[i][j]);
    printf("%d\n", ans);
    return 0;
}
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     佛祖保佑      永无BUG


Measured memory_bytes: 896
#include <bits/stdc++.h>
#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 REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define VPII vector<pair<int,int> >
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const int SIZE = 1e6+5;
const LL INF = 1LL<<58;
const double eps = 1e-13;

char s[100009];

int main(){
	scanf("%s",s);
	int n=LEN(s);
	DRI(k);
	REP(i,n){
		if(s[i]=='a')continue;
		if('z'-s[i]<k){
			k-='z'-s[i]+1;
			s[i]='a';
		}
	}
	if(k){
		s[n-1]=((int)s[n-1]-(int)'a'+k)%26+'a';
	}printf("%s",s);
}


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

struct AlterCard {
  int count;
  int number;
};

bool comp(AlterCard a, AlterCard b) {
  return a.number > b.number;
}

int main() {
  int N, M;
  scanf("%d %d", &N, &M);

  int A[100010];
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }

  sort(A, A + N);

  AlterCard B[100010];
  for (int i = 0; i < M; ++i) {
    scanf("%d %d", &B[i].count, &B[i].number);
  }

  sort(B, B + M, comp);

  int pos = 0;
  for (int i = 0; i < M; ++i) {
    for (int j = 0; j < B[i].count; ++j) {
      if (pos >= N || A[pos] >= B[i].number) goto LOOP_END;
      A[pos] = B[i].number;
      ++pos;
    }
  }

LOOP_END:
  long long sum = 0;
  for (int i = 0; i < N; ++i) {
    sum += A[i];
  }

  cout << sum << endl;

  return 0;
}


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

#define all(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  vector<int> vec(3) ;
  rep(i, 3){
    cin >> vec.at(i) ;
  }
  sort(all(vec)) ;
  
  cout <<vec.at(2)-vec.at(0)<<endl ;
  
    return 0 ;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>

#define max(x, y)	(((x) > (y))? (x) : (y))
#define abs(x)		(((x) < 0)? (-1*(x)) : (x))

using namespace std;

int main() {
	int n,x,ans=0;
	int m[101];
	int i;

	memset(m,0,sizeof(m));
	cin >> n;
	
	for ( i = 0; i < n; i++ ) {
		cin >> x;
		m[x] = 1;
	}
	
	for (i=0;i<101;i++) 
	if (m[i])ans++;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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 main(int argc, char const *argv[]) {
  int a,b,c;
  cin >> a >> b >> c;
  if((a<c && c<b) || (a>c && c>b)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void c(int a,int b);

int main(void){
	int x,y;

	while(1){

		scanf("%d %d",&x,&y);
		if(x == 0 && y == 0){
			break;
		}

		c(x,y);
	}

}

void c(int a,int b){
	if(a > b){
		printf("%d %d\n",b,a);
	}else if(a <= b){
		printf("%d %d\n",a,b);
	}
}

Measured memory_bytes: 1028
def swap(list,i,j,count):
    if(list[j]<list[i]):
        list[i],list[j]=list[j],list[i]
        return 1
    return 0

def merge(list,left1,left2,right2,count):#ソート済みの２つの区間(list[left1]〜list[left2-1]と、list[left2]〜list[right2-1]）を結合する
    i=left1
    j=left2
    tmp_list=[]
    while(1):
        if(list[i] <=list[j]):
            tmp_list.append(list[i])
            i+=1
        else:
            tmp_list.append(list[j])
            j+=1
        if(i==left2):
            for k in range(j,right2):
                tmp_list.append(list[k])
            break
        if(j==right2):
            for k in range(i,left2):
                tmp_list.append(list[k])
            break
    for k in range(left1,right2):
        list[k]=tmp_list[k-left1]
    count[0]+=right2-left1
    

                
                
    
        



def merge_sort(list,left,right,count):#list[left]からlist[right]までの要素でマージソート
    if(right  == left ):
        return None
    if(left+1 == right):
        swap(list,left,right,count)
        count[0]+=2
    else:
        mid=(left + right)//2
        merge_sort(list,left,mid,count)
        merge_sort(list,mid+1,right,count)
        merge(list,left,mid+1,right+1,count)
        

n=int(input())
data=list(map(int,input().split()))
count=[0]
merge_sort(data,0,n-1,count)
print(" ".join(list(map(str,data))))
print(count[0])


Measured memory_bytes: 66704
#include<stdio.h>

int main(void)
{
	int i,n,max=0,h,count=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&h);
		if(h>=max){
			max=h;
			count++;
			}
		}
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 128
import numpy as np
import sys
sys.setrecursionlimit(10**6)

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

memo = np.zeros(N) - 1

def search(i):
  if i == 0:
    return 0
  elif i == 1:
    return abs(h[i] - h[i-1])
  if memo[i] != -1:
    return memo[i]
  
  c1 = search(i-1) + abs(h[i]-h[i-1])
  c2 = search(i-2) + abs(h[i]-h[i-2])
  memo[i] = min(c1,c2)
  return min(c1,c2)

print(int(search(N-1)))

Measured memory_bytes: 103100
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    int tmp = 0;
    for (int i = 0; i< N/R+1; i++){
        for (int j = 0; j<(N-i*R)/G+1; j++){
            if (N-i*R - j*G >= 0){
                if ((N-i*R - j*G)%B ==0 ){
                    tmp++;
                }
            }
        }
    }
    cout << tmp << endl;
}


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

int main()
{
	int j1, m1, s1, e1;
	std::cin >> j1 >> m1 >> s1 >> e1;
	int s = j1 + m1 + s1 + e1;

	int j2, m2, s2, e2;
	std::cin >> j2 >> m2 >> s2 >> e2;
	int t = j2 + m2 + s2 + e2;

	std::cout << std::max(s, t) << std::endl;

	return 0;
}

Measured memory_bytes: 1160
import math
import sys
from itertools import accumulate
from functools import reduce
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())
    = [list(list(sys.stdin.readline().rstrip())) for i in range(h)] #文字列を分解して二次元配列入力

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    n,m= map(int, sys.stdin.readline().split())
    a=[]
    for i in range(m):
        a += list(map(int, sys.stdin.readline().split()))
    for i in range(n):
        print(a.count(i+1))

Measured memory_bytes: 5244
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < a.length; ++i) {
            a[i] = sc.nextInt();
        }

        System.out.println(solve(a));

        sc.close();
    }

    static int solve(int[] a) {
        long mLength = a.length * (a.length + 1L) / 2;

        int result = -1;
        int lower = Arrays.stream(a).min().getAsInt();
        int upper = Arrays.stream(a).max().getAsInt();
        while (lower <= upper) {
            int middle = (lower + upper) / 2;

            if (computeNonLessNum(a, middle) >= (mLength + 1) / 2) {
                result = middle;
                lower = middle + 1;
            } else {
                upper = middle - 1;
            }
        }

        return result;
    }

    static long computeNonLessNum(int[] a, int pivot) {
        int prefixSum = 0;
        int[] prefixSums = new int[a.length + 1];
        for (int i = 1; i < prefixSums.length; ++i) {
            prefixSum += (a[i - 1] >= pivot) ? 1 : -1;
            prefixSums[i] = prefixSum;
        }

        return computeNonInversionNum(prefixSums, 0, prefixSums.length - 1);
    }

    static long computeNonInversionNum(int[] values, int beginIndex, int endIndex) {
        if (beginIndex == endIndex) {
            return 0;
        }

        int middleIndex = (beginIndex + endIndex) / 2;
        long result = computeNonInversionNum(values, beginIndex, middleIndex)
                + computeNonInversionNum(values, middleIndex + 1, endIndex);
        List<Integer> sorted = new ArrayList<>();
        int leftIndex = beginIndex;
        int rightIndex = middleIndex + 1;
        while (leftIndex != middleIndex + 1 || rightIndex != endIndex + 1) {
            if (rightIndex == endIndex + 1
                    || (leftIndex != middleIndex + 1 && values[leftIndex] <= values[rightIndex])) {
                result += endIndex - rightIndex + 1;

                sorted.add(values[leftIndex]);
                ++leftIndex;
            } else {
                sorted.add(values[rightIndex]);
                ++rightIndex;
            }
        }

        for (int i = beginIndex; i <= endIndex; ++i) {
            values[i] = sorted.get(i - beginIndex);
        }

        return result;
    }
}

Measured memory_bytes: 65672
#include<cstdio>
#include<cstring>

int main(){
    char s[201], t[101], p[101];
    
    scanf("%s %s", s, p);
    strcpy(t,s);
    strcat(s,t);
    
    if( strstr(s,p)== NULL)printf("No\n");
    else printf("Yes\n");
    
    return 0;
}


Measured memory_bytes: 2764
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	p := make([]int,n)
	
	diffCnt := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
		if i+1 != p[i] {
			diffCnt++
		}
	}
	if diffCnt <= 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 512
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int mod = 998244353;

int mul(int a, int b) {
  return (long long) a * b % mod;
}

void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

const int maxn = (int) 3e5 + 5;
char tmp[maxn];
int n;
string s;

bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  scanf("%s", tmp);
  s = tmp;
  return true;
}

void solve() {
  int res = 1;
  int x = 0, y = 0;
  int a = -1, b = -1;
  for (int i = 0; i < 3 * n; i++) {
    int c = (s[i] == 'R' ? 0 : (s[i] == 'G' ? 1 : 2));
    if (a == -1) {
      a = c;
      x = 1;
      continue;
    }
    if (a == c) {
      x++;
      continue;
    }
    if (b == -1) {
      b = c;
      y = 0;
    }
    if (b == c) {
      if (!x) {
        swap(a, b);
        x++;
        continue;
      }
      res = mul(res, x);
      x--;
      y++;
      continue;
    }
    if (!y) {
      b = c;
      if (!x) {
        swap(a, b);
        x++;
        continue;
      }
      res = mul(res, x);
      x--;
      y++;
      continue;
    }
    res = mul(res, y);
    y--;
  }
  for (int i = 1; i <= n; i++) {
    res = mul(res, i);
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
int main(void){
    int N, T;
    int t[200000+5];
    scanf("%d %d", &N, &T);
    for(int i=0; i<N; i++)scanf("%d", &t[i]);
    
    long long ans=0;
    for(int i=1; i<N; i++){
        if(t[i]-t[i-1]>T)ans+=T;
        else ans+=t[i]-t[i-1];
    }
    printf("%lld\n", ans+T);
    return 0;
}


Measured memory_bytes: 2456
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String ans = (s.equals("ABC")) ? "ARC" : "ABC";
		System.out.println(ans);
	}

}


Measured memory_bytes: 35436
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner (System.in);
		
		int N = sc.nextInt();
		
		int[] list = new int [N];
		
		for (int index=0; index<N; index++){
		    list[index]=sc.nextInt();
		}

        int count = 0;
        
		for (int index=1; index<N-1; index++){
		    if (list[index]<list[index+1]&&list[index]>list[index-1]){
		        count++;
		    } else if (list[index]>list[index+1]&&list[index]<list[index-1]){
		        count ++;
		    }
		}
		
		System.out.println(count);

		sc.close();
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a) {
	os << '{';
	for(int i=0;i<sz(a);i++)
	{
		if(i>0&&i<sz(a)-1)
			os << ", ";
		os << a[i];
	}
	os << '}';
    return os;
}
const int N=101;
const int K=1e5+5;
const int mod=1e9+7;
int add(int a,int b)
{
    a+=b;
    if(a>=mod)
        a-=mod;
    return a;
}
int sub(int a,int b)
{
    a-=b;
    if(a<0)
        a+=mod;
    return a;
}
int main()
{
    int n,k;
    scanf("%i %i",&n,&k);
    vector<int> a(n+1);
    for(int i=1;i<=n;i++)
        cin >> a[i];
    int dp[n+1][k+1];
    dp[0][0]=1;
    for(int i=1;i<=k;i++)
        dp[0][i]=0;
    for(int i=1;i<=n;i++)
    {
        int sums[k+1];
        sums[0]=dp[i-1][0];
        for(int j=1;j<=k;j++)
        {
            sums[j]=add(sums[j-1],dp[i-1][j]);
        }
        for(int j=0;j<=k;j++)
        {
            int tr=sums[j];
            int bottom=j-a[i]-1;
            if(bottom>=0)
                tr=sub(tr,sums[bottom]);
            dp[i][j]=tr;
        }
    }
    printf("%i\n",dp[n][k]);
    return 0;
}


Measured memory_bytes: 40064
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  string s;

  cin >> s;

  int N = 1;
  printf("%c", (s[0]+N)); 
  cout << endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
if k%2==1:
    print((n//k)**3)
else:
    m=k//2
    ans=(n//k)**3
    t=0
    for i in range(1,n+1):
        if i%k==m:
            t+=1
    print(ans+t**3)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
#include<cstring>
#include<cmath>
using namespace std;
int cnt;
int w,h;
char map[52][52];
void func(int y,int x)
{
    map[y][x]='0';
    int nx,ny;
    for(int dy=-1;dy<=1;dy++)
    {
        for(int dx=-1;dx<=1;dx++)
        {
            ny=y+dy;
            nx=x+dx;
            if(map[ny][nx]=='1'&&0<=ny&&0<=nx&&ny<h&&nx<w)
            {
                func(ny,nx);
            }
        }
    }
    return;
}
int main()
{
    while(cin>>w>>h,w)
    {
        cnt=0;
        for(int i=0;i<52;i++)
        {
            for(int j=0;j<52;j++)
            {
                map[i][j]='0';
            }
        }
        for(int i=0;i<h;i++)
        {
            for(int j=0;j<w;j++)
            {
                cin>>map[i][j];
            }
        }
        for(int i=0;i<h;i++)
        {
            for(int j=0;j<w;j++)
            {
                if(map[i][j]=='1')
                {
                    func(i,j);
                    cnt++;
                }
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 1340
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; int A[200010] = {}; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	sort(A, A+N); 
	for(int i = 0; i < N-1; i++){
		if(A[i] == A[i+1]){
			cout << "NO" << endl; return 0; 
		}
	}
	cout << "YES" << endl; 
}

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

using ll = long long;
static const int MAX = 1e5;
static const int INF = 1e9;

// 隣接リストを用いた幅優先探索 O(|V|+|E|)
int n;
vector<pair<ll, ll>> G[MAX]; // 頂点数がnのグラフを表す隣接リスト
vector<ll> d(MAX, INF); // 始点sから頂点iまでの最短距離をd[i]に記録
// main関数からこれらを削除すること

void bfs(int s) {
  queue<int> q;
  q.push(s);
  d[s] = 0;
  while(!q.empty()){
    int u = q.front();
    q.pop();
    for(int v = 0; v < G[u].size(); v++){
      if(d[G[u][v].first] == INF){
        d[G[u][v].first] = d[u] + G[u][v].second;
        q.push(G[u][v].first);
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  // 重み付き無向(有向)グラフの隣接リスト
  ll u, v, w;
  cin >> n;
  
  for(int i = 0; i < n - 1; i++){
    cin >> u >> v >> w;
    u--;
    v--;
    G[u].push_back(make_pair(v, w));
    G[v].push_back(make_pair(u, w)); // 有向グラフではこの行をコメントアウト
  }
  
  int q, k;
  cin >> q >> k;
  
  bfs(k - 1);
  
  int x, y;
  for(int i = 0; i < q; i++){
    cin >> x >> y;
    cout << d[x - 1] + d[y - 1] << endl;
  }
}

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

int keta(int n) {
    int cnt = 0;
    while (n) n /= 10, cnt++;
    return cnt;
}

int main() {
    int n; cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (keta(i) % 2) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
bool flg[10];
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N, K;
  cin >> N >> K;
  REP(i, K) {
    int d;
    cin >> d;
    flg[d] = true;
  }
  for (int i = N; i <= 100000; i++) {
    string s = to_string(i);
    bool ok = true;
    REP(j, (int)s.size()) {
      if (flg[s[j] - '0']) {
        ok = false;
        break;
      }
    }
    if (ok) {
      print(i);
      return 0;
    }
  }
}
// 9999 9 0 1 2 3 4 5 6 7 8

Measured memory_bytes: 256
<?php

  fscanf(STDIN,"%d %d",$A,$B);

  $flag = true;

  for($i=0;$i<=1000000 ;$i++){
    if((int)($i*0.08) == $A && (int)($i*0.1) == $B){
      echo $i."\n";
      $flag = false;
      break;
    }
  }


  if($flag){
    echo "-1\n";
  }


Measured memory_bytes: 4604
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
int N;
int R[200000];
int mi[200000],ma[200000];
int main(){
  cin>>N;
  FOR(i,0,N){
    cin>>R[i];
  }
  mi[0]=R[0];
  FOR(i,1,N){
    mi[i]=min(mi[i-1],R[i]);
  }
  ma[N-1]=R[N-1];
  ROF(i,0,N-1){
    ma[i]=max(ma[i+1],R[i]);
  }
  int ans=-INF*2;
  FOR(i,1,N){
    ans=max(ans,ma[i]-mi[i-1]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5412
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int sum = 0;
    int max = Integer.MIN_VALUE;

    for(int i = 0; i < n; i++){
      int p = sc.nextInt();
      max = Math.max(p, max);
      sum += p;
    }

    System.out.println(sum - max/2);
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }
 
int main(){
    ll n;
    cin >> n;
    vector<ll> h(n);
    for (ll i = 0; i < n; i++){
        cin >> h[i];
    }

    for (ll i = n - 1; i > 0; i--){
        if(h[i] < h[i-1]){
            if(h[i] >= h[i-1]-1){
                h[i-1]--;
            }else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1024
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

ll w,h,x,y;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
    
    cin>>w>>h>>x>>y;
    ll a = w * h;
    cout << a/2;
    if(a%2)cout << ".5";
    cout << " ";
    
    if(x * 2 == w && y * 2 == h)cout << 1 << endl;
    else cout << 0 << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a, b;
  cin >> n;
  cin >> a;
  cin >> b;
  int train, taxi;
  if(n*a < b) {
    cout << n*a << "\n";
  } else {
    cout << b << "\n";
  }
  
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static int five = 0;
    public static int seven = 0;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String text = scanner.nextLine();
        check(text.split(" ")[0]);
        check(text.split(" ")[1]);
        check(text.split(" ")[2]);
        System.out.println(five==2 && seven ==1 ? "YES":"NO");
    }
    public static void check(String str){
        int number = Integer.parseInt(str);
        if(number==5)five++;
        if(number==7)seven++;
    }

}

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

typedef struct _Node {
  int key;
  struct _Node *next, *prev;
} Node;

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init(void) {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  Node *cur = nil->next;
  int isf = 0;
  while(1) {
    if(cur == nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(void) {
  deleteNode(nil->next);
}

void deleteLast(void) {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(void) {
  int key, n, i;
  char com[20];
  scanf("%d", &n);
  init();
  for(i=0;i<n;i++) {
    scanf("%s%d",com, &key);
    if (com[0] == 'i') insert(key);
    else if(com[0] == 'd') {
      if(strlen(com) > 6) {
        if(com[6] == 'F')
          deleteFirst();
        else if(com[6] == 'L') deleteLast();
      } else deleteKey(key);
    }
  }
  printList();
  return 0;
}


Measured memory_bytes: 33940
n =int(input())
a = list(map(int, input().split()))

total = 0

for i in range(n - 1):
    if a[i] > a[i + 1]:
        b = a[i] - a[i + 1]
        total = total + b
        a[i + 1] = a[i]
print(total)

Measured memory_bytes: 32228
#include <bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin>>n;
  long long int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  
  long int dp[n]={0};
  for(int i=1;i<n;i++)
  {
    if(a[i]<=a[i-1])
      dp[i]=1+dp[i-1];
  }
  
  int m=*max_element(dp,dp+n);
  
  cout<<m;
}

Measured memory_bytes: 1792
n,y = map(int,input().split())
y //= 1000
temp = y//10
if temp > n:
    print("-1 -1 -1")
    quit()
for i in range(temp+1):
    zandaka = y - i * 10
    maisuu = n - i
    for k in range(maisuu+1):
        if k * 5 + maisuu - k == zandaka:
            print(str(i) + " " + str(k) + " " + str(maisuu-k))
            quit()

print("-1 -1 -1")
quit()


Measured memory_bytes: 3188
import heapq

N,M,R = map(int,input().split())
r = list(map(int,input().split()))
r = [a-1 for a in r]
paper = set()
T = [[] for i in range(N)]
for i in range(M):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    T[a].append((c,b))
    T[b].append((c,a))

inf = 1 << 60
memo = {}
def distance(a,b):
    #print('distance(',a,',',b,') =?')
    if (a,b) in memo.keys():
        #print('distance(',a,',',b,') =',memo[(a,b)])
        return memo[(a,b)]
    d = [inf] * N
    d[a] = 0
    q = []
    heapq.heappush(q, (0,a))
    try:
        while True:
            c, t = heapq.heappop(q)
            if t == b:
                memo[(a,b)] = c
                memo[(b,a)] = c
                #print('distance(',a,',',b,') =',c)
                return c
            for i in T[t]:
                if d[i[1]] > c + i[0]:
                    d[i[1]] = c + i[0]
                    heapq.heappush(q, (c + i[0], i[1]))

    except IndexError:
        pass

arrived = [False] * R
ans = inf

def calc(src, rest, total):
    global ans
    if total >= ans:
        return
    if rest == 0:
        ans = min(ans,total)
        return

    for i in range(R):
        if not arrived[i]:
            arrived[i] = True
            calc(r[i], rest-1, total + distance(src,r[i]))
            arrived[i] = False

for i in range(R):
    arrived[i] = True
    calc(r[i], R-1, 0)
    arrived[i] = False

print(ans)


Measured memory_bytes: 60376
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
int a[100001];
int main()
{
    int n;
    std::cin>>n;
    for(int i=1;i<=n;i++)std::cin>>a[i];
    std::sort(a+1,a+1+n);
    
    std::cout<<a[n]-a[1]<<std::endl;
}

Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, H1);
    IN(ll, M1);
    IN(ll, H2);
    IN(ll, M2);
    IN(ll, K);
    OUT((H2 - H1) * 60 + (M2 - M1) - K);
}

Measured memory_bytes: 3596
#include <cstdio>

using namespace std;

typedef long long ll;

int main(int argc,char * argv[])
{
	ll a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	int ct = 0;
	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
	{
		ct++;
		ll a2 = a;
		ll b2 = b;
		ll c2 = c;
		a = (b2+c2)/2;
		b = (a2+c2)/2;
		c = (a2+b2)/2;
		if (ct > 1000) break;
	}
	if (ct > 995) printf("-1\n");
	else printf("%d\n",ct);
	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    int arr[n][3], i;
    for(i=0;i<n;i++)
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    int dp[n][3];
    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];
    for(i=1;i<n;i++)
    {
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + arr[i][0], dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + arr[i][1], dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + arr[i][2];
       // cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << '\n';
    }
    cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]});
}

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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 100 * 1000 + 9;
const int MOD = 1e9 + 7;

ll memo[maxN];
int n, k;
bool visited[maxN];
vector<int> g[maxN];

void dfs0(int u, int foo = 0){
	visited[u] = true;
	memo[u] -= foo;
	int chCnt = 0;
	for(int i = 0, L = g[u].size(); i < L; i++){
		int v = g[u][i];
		if(visited[v]){
			continue;
		}

		dfs0(v, min(foo + 1, 2));
		memo[v] -= (ll)chCnt;
		chCnt++;
	}
}

void dfs1(int u){
	visited[u] = true;
	for(int i = 0, L = g[u].size(); i < L; i++){
		int v = g[u][i];
		if(visited[v]){
			continue;
		}

		dfs1(v);

	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n >> k;
	for(int i = 0; i < n - 1; i++){
		int u, v;  cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	
	for(int i = 1; i <= n; i++){
		memo[i] = k;
	}
	
	fill_n(visited + 1, n, false);
	dfs0(1);
	
	ll ans = 1;
	for(int i = 1; i <= n; i++){
		if(memo[i] < 0){
			cout << "0\n";
			return 0;
		}

		ans = (ans * (memo[i] % MOD)) % MOD;
	}

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

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long int
#define MAXN 100001
#define INF 100000

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
    map<int, int> mi;
    int n, m;
    scanf("%d %d", &n, &m);
    vi errors(n+1, 0);
    int corr = 0, inc = 0;
    for(int i = 0; i < m; i++){
        int p;
        string ans;
        scanf(" %d ", &p); cin >> ans;       
        if( ans == "WA" && !mi[p])
            errors[p]++;
        if(ans == "AC" && !mi[p]){            
            corr++;
            inc += errors[p];
            mi[p] = 1;
        }
    }    
    printf("%d %d\n", corr, inc);
    return 0;
}

Measured memory_bytes: 5376