akhauriyash/Code-Regression huggingface dataset:
n=int(input())
a=list(map(int,input().split()))
cnt=[0]*(n+1)
for i in range(n):
  cnt[a[i]]+=1
ans=0
for i in range(n+1):
  ans+=cnt[i]*(cnt[i]-1)//2
for i in range(n): 
    print(ans-cnt[a[i]]*(cnt[a[i]]-1)//2+(cnt[a[i]]-1)*(cnt[a[i]]-2)//2)

Measured memory_bytes: 24748
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=list(map(int,input().split()))
    from functools import reduce
    from fractions import gcd
    print(reduce(gcd,A))



resolve()

Measured memory_bytes: 81684
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = (to) - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define all(v) v.begin(), v.end()
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

struct UnionFind {
  V<int> p;

  UnionFind(int n) {
    p.resize(n);
    rep(i, n) {
      p[i] = i;
    }
  }

  int root(int i) {
    if(p[i] == i) {
      return i;
    }

    return p[i] = root(p[i]);
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);

    if(rx == ry) return;
    p[rx] = ry;
  }
};

int main() {
  int n, q;

  cin >> n >> q;

  UnionFind uf(n);

  rep(i, q) {
    int com, x, y;
    cin >> com >> x >> y;
    if(com == 0) {
      uf.unite(x, y);
    } else if(com == 1) {
      if(uf.same(x, y)) {
        cout << 1 << endl;
      } else {
        cout << 0 << endl;
      }
    }
  }
}


Measured memory_bytes: 3168
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  string ap = "abcdefghijklmnopqrstuvwxyz";
  string s;
  vector<int> sum(26,0);
  while(cin >> s){
    REP(i,s.size()){
      s[i] = tolower(s[i]);
      if(islower(s[i])) sum[s[i]-'a']++;
    }
  }
  REP(i,26){
    cout << ap[i] << " : " << sum[i] << endl;
  }
}


Measured memory_bytes: 3164
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main(){
  ll A=0,B=0,C=0,D=0,E=0,F=0,N=0,M=0,K=0,L=0,R=0,H=0,W=0;
  string S,T;
  cin >> S >> W;
  while(K<S.size()){
    cout << S[K];
    K+=W;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int X, A, B, N;
    cin >> X >> A >> B >> N;
    vector<string> s(N);
    for (auto &&i : s) {
        cin >> i;
        if (i == "nobiro")
            X += A;
        if (i == "tidime")
            X += B;
        if (i == "karero")
            X = 0;
        chmax(X, 0);
    }
    print(X);

    return 0;
}


Measured memory_bytes: 3252
# 解説AC
import sys
input = sys.stdin.readline
n=int(input())
R=[list(map(int,input().split())) for i in range(n)]
B=sorted([tuple(map(int,input().split())) for i in range(n)])
ans=0
for i in range(n):
    a,b=B[i][0],B[i][1]
    y=-1
    ind=-1
    for j in range(n):
        c,d=R[j][0],R[j][1]
        if c<a and d<b and y<d:
            ind=j
            y=d
    if ind>=0:
        ans+=1
        R[ind][0]=1000
        R[ind][1]=1000
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std;  
long INF=1000000000000000;
int main() {
    long N;
    cin>>N;
    
    long S=0;
    for(int i=0;i<12;i++){
        S+=(N/(long)pow(10,i))%10;
    }
    
    if(N%S==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner scn=new Scanner(System.in);
        int A = scn.nextInt();
        int B = scn.nextInt();
        if(B%A==0){
            System.out.println(A+B);
        }else{
            System.out.println(B-A);
        }
    }
}


Measured memory_bytes: 21844
/*
 * 
 * */

#pragma GCC optimize("Ofast", "unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define f first
#define s second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define debug(x) cout << #x << ":\t" << x << endl
#define _ << " " <<

#define s_time clock_t time_start = clock()
#define t_time cout << double(clock() - time_start) / 1000 << endl

using namespace std;
using namespace __gnu_pbds;

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

const int N = 50 + 3;
const ll M = 1e9 + 7;

ll n, m;
ll a[N][N], res[N][N], cnt;

void mul_mat(ll x[N][N], ll y[N][N]) {
	ll z[N][N];
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			z[i][j] = 0;
			for (int k = 1; k <= n; ++k) {
				z[i][j] = (z[i][j] + x[i][k] * y[k][j] % M) % M;
			}
		}
	}
	
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			x[i][j] = z[i][j];
		}
	}
}

int main(int argc, char** argv) {
//	mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
//	freopen("in", "r", stdin);
//	freopen("out", "w", stdout);
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	for (int i = 1; i < N; ++i) res[i][i] = 1;
	
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) cin >> a[i][j];
	}
	
	while (m) {
		if (m & 1) mul_mat(res, a);
		mul_mat(a, a);
		m >>= 1;
	}
	
	cnt = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) cnt = (cnt + res[i][j]) % M;
	}
	cout << cnt;
	
	return 0;
}

/*
 * 
 * */


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

typedef long long LL;
typedef long long ll;
#define SZ(a) int((a).size())
#define FOR(var,a,b) for(int var=(a);var<(b);var++)
#define REP(var,n) FOR(var,0,n)
#define INT(n) int n;scanf("%d",&n)

int main(){
  INT(h); INT(w); INT(a); INT(b);
  int MOD = 1000000007;
  function<int(int,int,int)> powmod = [&](int a, int b, int mod){
    if (b == 0){return 1;}
    else if (b % 2 == 1){return (int) ((LL) a * powmod((int)((LL)a * a % mod), b / 2, mod) % mod);}
    else {return powmod((int)((LL)a * a % mod), b / 2, mod);}};
  auto invmodp = [&](int a, int mod){ return powmod(a, mod - 2, mod);};
  int factmod[h + w - 1], factinvmod[h + w + 1]; factmod[0] = 1;
  FOR(i, 1, h + w - 1){factmod[i] = (int)((LL) factmod[i - 1] * i % MOD);}
  FOR(i, 0, h + w - 1){factinvmod[i] = invmodp(factmod[i], MOD);}
  auto combmod = [&](int n, int r){ return (int)(((LL)factmod[n] * factinvmod[r] % MOD) * factinvmod[n - r] % MOD); };
  int ans = combmod(h + w - 2, w - 1);
  if (1 < a){
    FOR(i, 0, b - 1){ans = (ans + MOD - (int)((LL)combmod(h - a + i, i) * combmod(a + w - i - 3, a - 2) % MOD)) % MOD;}
  }
  ans = (ans + MOD - (int)((LL)combmod(h - a + b - 1, b - 1) * combmod(a + w - b - 1, a - 1) % MOD)) % MOD;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int n;
double a,ra,dp[3000][2],ans;

int main()
{Tie
	cin>>n,dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		cin>>a,ra=(double)1-a;
		for(int j=0;j<=n;j++)
		{
			dp[j][i&1]=dp[j][i&1^1]*ra;
			if(j)
				dp[j][i&1]+=dp[j-1][i&1^1]*a;
		}
	}
	for(int i=n;i>n/2;i--)
		ans+=dp[i][n&1];
	cout <<fixed<< setprecision(10)<< ans<<'\n';
}

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

int main() {
    int h, m, s;
    cin >> s;
    h = s / 3600;
    s %= 3600;
    m = s / 60;
    s %= 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}



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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui M = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);i++)
#define FOR2(i,a,b) for (int i=(a);i<(b);i++)
#define MP make_pair
#define FAST ios_base::sync_with_stdio(false); cin.tie(0)

template<class T,class U>
 ostream &operator<<(ostream &os,const pair<T,U> &x) {
 return os<<"("<<x.first<<","<<x.second<<")";
 }

template<class T>
 ostream &operator<<(ostream &os,const vector<T> &x) {
    os << '[';
    if ( !x.empty() ) {
        std::copy (x.begin(), x.end(), std::ostream_iterator<T>(os, ","));
        os << "\b";
    }
    os << "]";
  return os;
 }
template<class T>
 ostream &operator<<(ostream &os,const vector<vector<T> > &x) {
    os << '[';
    if ( !x.empty() ) {
        for (auto v: x) os << v << ",";
        os << "\b";
    } else os << "[]";
    os << "]";
  return os;
 }


int main() {
    FAST;
  //  freopen ("in.txt", "r", stdin);
    int n; cin >> n;
    int t0,x0,y0;
    t0=y0=x0=0;
    FOR(i,n){
        int t,x,y;
        cin >> t>>x>>y;
        int tomove=abs(x-x0)+abs(y-y0);
        if (tomove>t-t0 || (tomove%2 != (t-t0)%2)){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";

    return 0;
}


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

class BinaryIndexedTree {
  public:
    BinaryIndexedTree(): n(0), a{} {};
    ~BinaryIndexedTree(){};
    int init(int n){
        this->n = n;
        this->a = std::vector<int>(n+1, 0);
        return 0;
    }
    void add(int id, int x){
        for(int i = id; i <= n; i += i & -i) a[i] +=x;
    }
    int sum(int from, int to){
        int sum = 0;
        for(int i = to; i > 0; i -= i & -i) sum += a[i];//add from 0 to 'to'                                                                                                                                                        
        for(int i = from - 1; i > 0; i -= i & -i) sum -= a[i];//sub from 0 to 'from - 1'                                                                                                                                            
        return sum;
    }
  private:
    int n;
    std::vector<int> a;
};

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    BinaryIndexedTree bit;
    int n;
    int q;
    std::cin >> n;
    std::cin >> q;
    bit.init(n);

    for(int i = 0; i < q; ++i){
        int op;
        std::cin >> op;
        if(op == 0){
            //add                                                                                                                                                                                                                   
            int id;
            int x;
            std::cin >> id;
            std::cin >> x;
            bit.add(id, x);
        } else {
            //getsum;                                                                                                                                                                                                               
            int from;
            int to;
            std::cin >> from;
            std::cin >> to;
            int sum = bit.sum(from, to);
            std::cout << sum << "\n";
        }
    }
    return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
long long modpow(long long x, int n) {
	long long r = 1;
	while (n > 0) {
		if (n&1) (r *= x) %= mod;
		n /= 2;
		(x *= x) %= mod;
	}
	return r;
}
long long modinv(long long x) {
	return modpow(x, mod-2);
}
int main() {
	int N;
	cin >> N;
	vector<long long> X(N);
	for (auto& x : X) cin >> x;
	long long aa = 1;
	for (int i = 2; i <= N-1; ++ i) aa = aa * i % mod;
	long long r = 0;
	for (int i = 0; i < N-1; ++ i) {
		r += (X[N-1] - X[i]) * aa % mod * modinv(i+1) % mod;
		r %= mod;
	}
	cout << r << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
  int n,i,a;
  
  scanf("%d",&n);
  
  int buka[n+1];
  
  for(i=0; i<n+1; i++)
    buka[i] = 0;
  
  for(i=2; i<n+1; i++){
    scanf("%d",&a);
    buka[a] ++;
  }
  for(i=1; i<n+1; i++)
    printf("%d\n",buka[i]);
  return 0;
}

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


vector<int> G[26];
vector<int> rG[26];
vector<int> vs;
bool used[26];
int cmp[26];

void init(){
	for(int i = 0; i < 26; ++i){
		G[i].clear();
		rG[i].clear();
		vs.clear();
		used[i] = false;
		cmp[i] = 0;
	}
}


void add_edge(int f, int t){
	G[f].push_back(t);
	rG[t].push_back(f);
}

void dfs(int v){
	used[v] = true;
	for(int i = 0; i < G[v].size(); ++i){
		if( !used[G[v][i]] ) dfs(G[v][i]);
	}
	vs.push_back(v);
}

void rdfs(int v, int k){
	used[v] = true;
	cmp[v] = k;
	for(int i = 0; i < rG[v].size(); ++i){
		if( !used[rG[v][i]] ) rdfs(rG[v][i], k);
	}
}

int scc(){
	for(int i = 0; i < 26; ++i) used[i] = false;
	vs.clear();
	for(int v = 0; v < 26; ++v){
		if( !used[v] ) dfs(v);
	}
	for(int i = 0; i < 26; ++i) used[i] = false;
	int k = 0;
	for(int i = (int)vs.size() - 1; i >= 0; --i){
		if( !used[vs[i]] ) rdfs(vs[i], k++);
	}
	return k;
}


bool solve(const vector<string> &v){
	init();
	int n = v.size();
	
	for(int i = 0; i < n - 1; ++i){
		bool f = true;
		for(int j = 0; j < v[i].size(); ++j){
			if( j >= v[i+1].size() ){
				return false;
			}
			if( v[i][j] != v[i+1][j] ){
				add_edge(v[i][j] - 'a', v[i+1][j] - 'a');
				break;
			}
		}
	}

	int k = scc();
	return k == 26;
}


int main(){
	int n;
	while( cin >> n, n != 0 ){
		vector<string> v(n);
		for(int i = 0; i < n; ++i){
			cin >> v[i];
		}

		cout << (solve(v) ? "yes\n" : "no\n");
	}
}

Measured memory_bytes: 1292
/* tempate
 *
 *
 */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    ll n = s.size();
    vector<ll> a(n, 0);
    ll ison = 0;
    ll start = 0;
    ll stop = 0;
    ll num_r = 1;
    ll num_l = 1;
    for(ll i = 0; i < n; i++){
        ll r, l;
        if(ison == 0 && s[i] == 'L'){
            r = i - 1;
            l = i;
            ison = 1;
        }
        if(ison == 1&& s[i] == 'R' || ison == 1 && i == n - 1){
            ison = 0;
            stop = i - 1;
            if(i == n - 1) stop++;
            num_r += (r - start) / 2 + (stop - r) / 2;
            num_l += (l - start) / 2 + (stop - l) / 2;
            a[r] = num_r;
            a[l] = num_l;
            start = i;
            num_r = 1;
            num_l = 1;
        }
    }
    for(ll i = 0; i < n; i++){
        cout << a[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1488
c = input().split()
c = list(map(int, c))
b = input().split()
b = list(map(int, b))
ans = 0
a = [0] * (c[0])
for n in range(c[0]):
	a[n] = input().split()
	a[n] = list(map(int, a[n]))
	tmp = 0
	for m in range(c[1]):
		tmp += b[m] * a[n][m]
	if tmp > -c[2]:
		ans += 1
print(ans)

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

fn main(){
    let x = read::<u32>();
    if x==1{
        println!("{}", 1);
    }else{
        let mut max = 1;
        for i in 2..x{
            let mut j : u32 = 2;
            let mut m = 0;
            while true{
                let p = i.pow(j);
                if p > x{
                    break;
                }else{
                    m = p;
                    j += 1;
                }
            }
            if m > max{
                max = m;
            }
        }
        println!("{}", max);
    }
}
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin.bytes().map(|c| c.expect("Error") as char) 
        .skip_while(|c| c.is_whitespace()).take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("Error")
}

Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

const double PI=acos(-1.0);

int L;
void input()
{
    cin>>L;
}

void solve()
{
    double a=1.0*L/3.0;
    cout<<fixed<<setprecision(10)<<a*a*a<<endl;
}

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

Measured memory_bytes: 3800
#include <stdio.h>
#include <set>
#include <iterator>
using namespace std;
int main(){
    int n,temp,k;
    set<int> s;
    set<int>::iterator u;
    scanf("%d",&n);
    while(n--){
        scanf("%d%d",&k,&temp);
        if(k==0){
            s.insert(temp);
            printf("%ld\n",s.size());
        }
        else if(k==1){
            if(s.find(temp)==s.end())printf("0\n");
            else printf("1\n");
        }
        else if(k==2)s.erase(temp);   
        else{
            u=s.lower_bound(temp);
            scanf("%d",&temp);
            while(u!=s.end()){
                if(*u>temp)break;
                printf("%d\n",*u);
                u++;
            }
        }
    }
}


Measured memory_bytes: 12016
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>a>>b;
    if(a==b) cout<<a*2;
    else cout<<(max(a,b)+max(a,b)-1);


    

    return 0;
}


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

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

  vector<int> A(N);
  rep(i,N){
    cin >> A.at(i);
  }

  int num=1, br=0;
  rep(i,N){
    if(num == A.at(i)){
      num++;
    }else{
      br++;
    }
  }

  if(br==N){
    cout << -1 << endl;
  }else{
    cout << br << endl;
  }

}

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

int main()
{
	int i, N, K, h[100001];
	scanf("%d %d", &N, &K);
	for (i = 1; i <= N; i++) scanf("%d", &(h[i]));
	
	const int sup = 1 << 30;
	int j, dp[100101];
	for (i = 2, dp[1] = 0; i <= N; i++) dp[i] = sup;
	for (i = 1; i < N; i++) {
		for (j = 1; j <= K; j++) if (dp[i] + abs(h[i+j] - h[i]) < dp[i+j]) dp[i+j] = dp[i] + abs(h[i+j] - h[i]);
	}
	printf("%d\n", dp[N]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2436
#include<iostream>
#include<vector>
#include<atcoder/dsu>

int main() {
  int N, M;
  std::cin >> N >> M;
  
  atcoder::dsu d(N);
  
  for (int i = 0; i < M; i++) {
    int a, b;
    std::cin >> a >> b;
    
    d.merge(a - 1, b - 1);
  }
  
  std::cout << d.groups().size() - 1 << std::endl;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  ll x;
  cin >> x;
  ll ans = x/500*1000;
  ans += (x%500)/5*5;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(int argc, const char * argv[]) {
    // insert code here...
    long long a, b, c, d, ac, ad, bc, bd, m;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    ac = a*c;
    ad = a*d;
    bc = b*c;
    bd = b*d;
    
    if(ac>ad){
        m = ac;
    }else{
        m = ad;
    }
    if(bc>=m){
        m = bc;
    }
    if(bd>=m){
        m = bd;
    }
  
  	printf("%lld\n", m);
    return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int h,w,v[25][25],m=0;
    cin>>h>>w;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            cin>>v[i][j];
        }
    }
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            int a=0;
            for(int k=0;k<h;++k){
                for(int l=0;l<w;++l){
                    if(i==k||j==l){
                    }
                    else{
                        int b;
                        b=min(abs(i-k),abs(j-l));
                        a+=v[k][l]*b;
                    }
                }
            }
            if(m==0){
                m=a;
            }
            if(m>a){
                m=a;
            }
        }
    }
    cout<<m<<endl;
}



Measured memory_bytes: 3136
h,w = map(int, input().split())
a = [list(input()) for i in range(h)]
for i in range(h):
    for j in range(w):
        a[i][j] = [a[i][j], False]

for i in range(h):
    count = 0
    for j in range(w):
        if a[i][j][0] == ".":
            count += 1
    if count == w:
        for j in range(w):
            a[i][j][1] = True

for i in range(w):
    count = 0
    for j in range(h):
        if a[j][i][0] == ".":
            count += 1
    if count == h:
        for j in range(h):
            a[j][i][1] = True

for i in a:
    flag = False
    for j in i:
        if not j[1]:
            print(j[0],end = "")
            flag = True
    if flag:
        print("")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <db,db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD=998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=100005;

int in[N+1];vi adj[N+1];
void solve()
{
int n,m;
cin>>n>>m;
int u,v;
for(int i=0;i<m;i++)
{
    cin>>u>>v;
    adj[u].pb(v);
    in[v]++;
}
queue<int>q;
vi topo;
for(int i=1;i<=n;i++)
if(!in[i])
q.push(i);
while(!q.empty())
{
    u=q.front();
    q.pop();
   topo.pb(u);
   for(int V:adj[u])
   {
       in[V]--;
       if(!in[V])
       q.push(V);
   }
}
int ans=0;int dp[n+1];
for(int i=n-1;i>=0;i--)
{
    u=topo[i];
    dp[u]=0;
    for(int V:adj[u])
    dp[u]=max(dp[u],1+dp[V]);
    ans=max(ans,dp[u]);

}
cout<<ans<<endl;



}




int32_t main()
{
    IOS;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        
        solve();
    }
    return 0;
}

Measured memory_bytes: 10996
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        double a = scanner.nextDouble();
        BigDecimal b = new BigDecimal(a);
        BigDecimal c = new BigDecimal(2);
        BigDecimal d = new BigDecimal(3.14159265359);

//        Integer b = scanner.nextInt();

        BigDecimal x = b.multiply(c).multiply(d);
        BigDecimal y = b.multiply(b).multiply(d);
        System.out.println(y + " " + x);
    }
}


Measured memory_bytes: 28120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dbl;
#define sqr(int) (int * int)
#define sqr3(int) (int * int * int)
#define pi M_PI
#define nl "\n"
#define vi vector<int>
#define vc vector<char>
#define vll vector<ll>
#define vd vector<dbl>
#define vf vector<float>
#define vs vector<string>

void solve(){
	int a,b;
	cin >> a >> b;
	if(a == b){
		cout << "Yes";
		return;
	}
	cout << "No";
}







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




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

double getdistance(double x1, double y1, double x2, double y2){
  double distance = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
  
  return distance;
}

int main(){
  double a, b , h, m;
  cin >> a >> b >> h >> m;
  
  double sitaA = 2*M_PI* (double)(h/12+m/60/12);
  double sitaB = 2*M_PI* (double)(m/60);
  
  double x1 = a * cos(sitaA);
  double y1 = a * sin(sitaA);
  double x2 = b * cos(sitaB);
  double y2 = b * sin(sitaB);
  
  cout << fixed << setprecision(20) << (double)getdistance(x1, y1, x2, y2) << endl;
}


Measured memory_bytes: 4148
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main(void)
{
    long long int sum=0,range=0,a1,b1,a2,b2;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=0,money;
    //vector <int> v;
    //float f,g,h;
    //int c,d,big=0;
    cin>>m>>n>>o;
    if(m+n+o>=22) cout<<"bust";
    else cout<<"win";
    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long n, a, b;
	cin >> n >> a >> b;
	if (n == 1 && a < b)  {
		cout << 0;
	} else if (b < a) {
		cout << 0; 
	} else {
		cout << ((a+b * (n-1)) - (a * (n-1) + b) + 1);
	}              
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc081/tasks/abc081_b
#include <bits/stdc++.h>
using namespace std;

int main(void)
{
  int N;
  cin >> N;
  int flag = 1;
  int count = 0;

  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
    if (A.at(i) % 2 == 1)
      flag = 0;
  }

  while(flag){
    for (int i = 0; i < N; i++){
      A.at(i) /= 2;
      if (A.at(i) % 2 == 1)
        flag = 0;
    }
    count += 1;
  }

  cout << count << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        int[][] childs = new int[n][];
        for (int i = 0; i < n; i++)
        {
            var data = Console.ReadLine().Split().Select(int.Parse).ToArray();
            childs[data[0] - 1] = data.Skip(2).Select(x => x - 1).OrderBy(x => x).ToArray();
        }

        int time = 0;
        int[] d = new int[n];
        int[] f = new int[n];
        Action<int> dfs = null;
        dfs = node =>
        {
            if (d[node] != 0) return;
            time++;
            d[node] = time;
            foreach (var item in childs[node])
            {
                dfs(item);
            }
            time++;
            f[node] = time;
        };
        for (int i = 0; i < n; i++)
        {
            dfs(i);
            Console.WriteLine($"{i + 1} {d[i]} {f[i]}");
        }
    }
}




Measured memory_bytes: 20480
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int table[101][101];



int main(){
    int h,w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n){
        cin >> v[i];
    }
    bool f = true;
    int cnt = v[0];
    int now = 1;
    int id=0;
    rep(i,h){
        rep(j,w){
            table[i][j] = now;
            cnt--;
            if (cnt == 0){
                cnt = v[now];
                now++;
            }
        }
    }
    rep(i,h){
        if (i%2 == 1) reverse(table[i],table[i]+w);
    }
    rep(i,h){
        rep(j,w) cout << table[i][j] << " ";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
	int a,b,c,d[200][200],x,y,sum1=0,sum2[200]={0},sum3=0;

	scanf("%d %d",&a,&b);
	for(y=0;y<=a;y++){
		for(x=0;x<b;x++){
			if(y==a){
				d[y][x]=sum2[x];
				sum3 += sum2[x];}
			else{
				scanf("%d",&c);
				d[y][x]=c;
				sum1 += c;
				sum2[x] += c;}
		}
		d[y][b]= sum1;
		sum1=0;
	}
	d[a][b]=sum3;
	for(y=0;y<=a;y++){
		for(x=0;x<=b;x++){
			printf("%d",d[y][x]);
			if(x != b)
				printf(" "); 
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 688
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN=1e5+10;
int main(){
    ll n,m;scanf("%lld %lld",&n,&m);
    ll sum=0;
    for(ll i=1;i<=m;i++){
        ll val;scanf("%lld",&val);
        sum+=val;
    }
    if(sum>n) printf("-1\n");
    else printf("%lld\n",n-sum);
    return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  LL now,bo,si,count;
  string s;
  while(1){
    cin >> s;
    if(s=="#") return 0;
    now=s.length()-1;
    count=0;
    while(now>=0){
      if(s[now]=='t'){
        now-=4;
      }else{
        now-=5;
      }
      count++;
    }
    now=s.length()-1;
    if(count<=2){
      if(s[now]=='t'){
        bo=90;
        now-=4;
      }else{
        bo=0;
        now-=5;
      }
      while(now>=0){
        if(s[now]=='t'){
          bo+=45;
          now-=4;
        }else{
          bo-=45;
          now-=5;
        }
      }
      cout << bo << endl;
    }else{
      si=1<<(count-2);
      if(s[now]=='t'){
        bo=90*(1<<(count-2));
        now-=4;
      }else{
        bo=0;
        now-=5;
      }
      count--;
      while(now>=0){
        if(s[now]=='t'){
          bo+=45*1<<(count-1);
          now-=4;
        }else{
          bo-=45*(1<<(count-1));
          now-=5;
        }
        count--;
      }
      cout << bo << "/" << si << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3140
#coding:utf-8

n,x = map(int, raw_input().split())
a = map(int, raw_input().split())

ans = 0
if a[0] > x:
    ans += a[0] - x
    a[0] = x

for i in range(len(a)-1):
    if a[i] + a[i+1] > x:
        ans += (a[i] + a[i+1]) - x
        a[i+1] -= (a[i] + a[i+1]) - x

        
            
print ans            
            



Measured memory_bytes: 11316
import qualified Data.ByteString.Char8 as B

main = B.getLine >>= B.putStrLn . solve

solve :: B.ByteString -> B.ByteString
solve = B.reverse . B.foldl ff B.empty
    where
        ff acc x
            | x == 'B' && not (B.null acc) = B.tail acc
            | x == 'B' = acc
            | otherwise = B.cons x acc


Measured memory_bytes: 380
N, Y=map(int,input().split())#二つの数字をペアで入力。この時スペース区切りでInt型に変換
ans = -1,-1,-1

for i in range(N+1):
    for j in range(N - i + 1):
        if i*10000 + j*5000 + (N-i-j)*1000 == Y: #肝となる判定ロジック
            print(i, j, N-i-j)
            exit()

print('-1 -1 -1')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
   	
int main() {
	long long int l, r;

	cin >> l >> r;
	vector<long long int> v;
	vector<long long int> v2;

	for (int i = 0; i < 5000; i++)
	{
		if (l+i <= r)
		{
			v.push_back( (l+i)%2019 );
			// a[i] = (l+i)%2019;
		}
		else
		{
			break;
		}
	}

	sort(v.begin(), v.end());

	for (int i = 0; i < v.size() - 1; i++)
	{
		for (int j = i+1; j < v.size(); j++)
		{
			v2.push_back((v[i]*v[j]) % 2019);
		}
	}

	sort(v2.begin(), v2.end());

	cout << v2[0];

	// cout << (v[0]*v[1]) % 2019;

    return 0;
}



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

int main(){
  int N,p=0;
  bool b = 1;
  cin >> N;
  vector<int> s(N);
  rep(i,N){
    cin >> s.at(i);
    p += s.at(i);
  }
  sort(s.begin(),s.end());
  if(p%10){
    cout << p << endl;
    b = 0;
  }else{
    rep(i,N){
      if((p-s.at(i))%10){
        cout << p - s.at(i) <<endl;
        b = 0;
        break;
      }
    }
  }
  if(b){
    cout << "0" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;

int n;
int ara[101];

void solve()
{
    cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i++){
        cin>>ara[i];
        if(i%2)
        {
            if(ara[i]%2)
                cnt++;
        }
    }
    cout<<cnt<<endl;
}

int main()
{
    solve();
}


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

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

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

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

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

mt19937 mrand(random_device{} ()); 

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

void precalc() {
}

const int maxn = (int) 1e5 + 5;
int n;
int a[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  return true;
}

void solve() {
  int d = 1;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int cnt = (a[i] - 1) / d;
    if (a[i] > d) {
      a[i] = 1;
    }
    ans += cnt;
    d = max(d, a[i] + 1);
  }
  printf("%lld\n", ans);
}

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


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int max=0;
  int j=0;
  for (int i=0; i<N; i++){
    cin >> A.at(i);
  }
  
  for (int i=0; i<N-1; i++){
    if (A.at(i)>=A.at(i+1)){
      j++;
      if (j>=max) max=j;
    }
    else{
      j=0;
    }
  }
  cout << max << endl; 
}


Measured memory_bytes: 768
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

    public void Proc()
    {
        string inpt = Reader.ReadLine();
        string ans = string.Join("", inpt.Reverse().Select(a => a.ToString()).ToArray());
        Console.WriteLine(ans);
    }


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"



w32nimda



";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long n,k;cin>>n>>k;
    string s;
    cin>>s;
    long cnt=0;
    for(int i=0;i<n-1;i++){
        if(s[i]=='R'&& s[i+1]=='R'){
            cnt++;
        }
    }
    for(int i=n-1;i>0;i--){
        if(s[i]=='L'&& s[i-1]=='L'){
            cnt++;
        }
    }
    while(cnt<n && k){
        k--;
        cnt+=2;
    }
    if(cnt>n-1){
        cnt=n-1;
    }
    cout<<cnt;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

void solve(long long N, vector<long long> A){
	for (ll i=0;i<N;i++) A[i]-=i+1;
	sort(A.begin(),A.end());
	ll mid=A[N/2];
	ll ans=0;
	for (ll i=0;i<N;i++) {
		ans+=abs(A[i]-mid);
	}
	printf("%lld\n",ans);
}

int main(){	
	ios_base::sync_with_stdio(false); cin.tie(0);
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, A);
	return 0;
}



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

typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<int> v;
  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  sort(v.begin(), v.end());
  
  int a = 0;
  int b = 0;
  for(int i = 0; i < v.size(); i++){
    if(i % 2 == 0){
      a += v[i];
    } else { 
      b += v[i];
    }
  }
  cout << abs(a - b) << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main()
{
    int n;
    double ans = 0;
    cin >> n;
    vector<double> a(n);
    rep(i,n){
        cin >> a[i];
        ans += 1/a[i];
    }
    ans = 1/ans;
    cout << ans << endl;

    return 0;
}

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


typedef struct data_t{
	int key;
	struct data_t *prev;
	struct data_t *next;
}DATA_T;


DATA_T HEAD;


void Insert(int key){

	DATA_T *p;


	if( (p = (DATA_T *)malloc(sizeof(DATA_T))) == NULL){
		printf("malloc error\n");
		exit(1);
	}

	p->key = key;
	p->prev = &HEAD;
	p->next = HEAD.next;
	HEAD.next->prev = p;
	HEAD.next = p;
}


void Delete(int key)
{
	DATA_T *p;

	for(p = HEAD.next; p != &HEAD; p = p->next){
		if(p->key == key){
			p->prev->next = p->next;
			p->next->prev = p->prev;
			free(p);
			break;
		}
	}
}


// 0:First 1:Last
void Delete_pos(int pos)
{
	DATA_T *p;

	if(pos == 1){
		p = HEAD.prev;
		HEAD.prev = p->prev;
		p->prev->next = &HEAD;
	}else{
		p = HEAD.next;
		HEAD.next = p->next;
		p->next->prev = &HEAD;
	}
	free(p);
}


int main()
{
	char in_str[30];
	DATA_T *p;
	char command[20];
	int key;
	int n;
	int i;


	fgets(in_str, sizeof(in_str), stdin);
	sscanf(in_str, "%d", &n);

	HEAD.next = &HEAD;
	HEAD.prev = &HEAD;

	for(i = 0; i < n; i++){
		fgets(in_str, sizeof(in_str), stdin);
		sscanf(in_str, "%s %d", command, &key);

		if(!strcmp(command, "insert")){
			Insert(key);
		}else if(!strcmp(command, "delete")){
			Delete(key);
		}else if(!strcmp(command, "deleteFirst")){
			Delete_pos(0);
		}else if(!strcmp(command, "deleteLast")){
			Delete_pos(1);
		}
	}


	for(p = HEAD.next; p != &HEAD; p = p->next){
		printf("%d", p->key);
		if(p->next != &HEAD)
			printf(" ");
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 32972
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
using namespace std;
typedef long long llint;
typedef long double ld;
#define inf 1e18

string s;
void solve(){
	cin >> s;
	llint cnt=0;
	llint ans=0;
	for(char x:s){
		if(x=='B'){
			cnt++;
		}
		else{
			ans+=cnt;
		}
	}
	cout << ans << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
#include <map>
using namespace std;
using P = pair<int,int>;
using ll = long long;
const int MOD=1e9+7;
int main(){
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}

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

N = int(input())

count_ab = 0
count_fb = 0
count_ea = 0
count_fbea = 0
for i in range(N):
    s = input()
    count_ab += s.count("AB")
    if s[0] + s[-2] == "BA":
        count_fbea += 1
    elif s[0] == "B":
        count_fb += 1
    elif s[-2] == "A":
        count_ea += 1

ans = count_ab
if count_fbea > 0:
    ans += count_fbea - 1
    if count_fb > 0:
        count_fb -= 1
        ans += 1
    if count_ea > 0:
        count_ea -= 1
        ans += 1
ans += min(count_fb, count_ea)
print(ans)

Measured memory_bytes: 3188