akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;
int binary_search(int key , std::vector<int>vector_name) {
    int left = 0, right = vector_name.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (vector_name[mid] == key) return mid;
        else if (vector_name[mid] > key) right = mid - 1;
        else if (vector_name[mid] < key) left = mid + 1;
    }
    return -1;
}
int main(void){
    int n;
    cin>>n;
    int a[100000];
    for(int i(0);i<n;i++){
        cin>>a[i];
    }
    vector<int>paper[1000];
    int key,j;
    for(int i(0);i<n;i++){
        j = a[i]%1000;
        key = binary_search(a[i],paper[j]);
        if(key >= 0){
            paper[j].erase(paper[j].begin()+key);
        }
        else{
            paper[j].push_back(a[i]);
            sort(paper[j].begin(),paper[j].end());
        }
    }
    int ans(0);
    for(int i(0);i<1000;i++){
        ans += paper[i].size();
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1408
n, m, x = map(int, input().split())
C = [0]*n
A = [[0]*m for i in range(n)]

for i in range(n):
    C[i], *A[i] = map(int, input().split())
    
ans = sum(C)
F = False
for i in range(1, 2**n+1):
    combs = bin(i)[2:].zfill(n)
    tmp_ans = 0
    tmp_skill = [0]*m
    f = True
    for comb_i, comb in enumerate(combs):
        if comb=='1':
            tmp_ans += C[comb_i]
            tmp_skill = [t+a for t, a in zip(tmp_skill, A[comb_i])]
    for t in tmp_skill:
        if t < x:
            f = False
            break
            
    if f:
        ans = min(ans, tmp_ans)
        F = True
    
print(ans if F else -1)

Measured memory_bytes: 9256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define IOS std::ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
const int N = 1e4+20;
const ll Mod = 1e5;
const int INF = 0x3f3f3f3f;
int a[N] = {0};
int b[N] = {0};
int g[N][N] = {0};
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  rep(i,10){
    c = a*c-b;
    cout<<c<<endl;
  }
	return 0;
}


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

int main(){
  int n, m, x, ans=1000000000; cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  for(int i = 0; i < n; i++){
  	cin >> c[i];
  	for(int j = 0; j < m; j++) cin >> a[i][j];
  }
  
  for(int bit = 0; bit < (1<<n); bit++){
    vector<int> b(m, 0);
    int nedann = 0;
  
  	for(int i = 0; i < n; i++){
    	if(bit & (1<<i)){
        	nedann += c[i];
        	for(int j = 0; j < m; j++) b[j] += a[i][j];
        }
    }
  
  	bool over = true;
  	for(int i = 0; i < m; i++) if(b[i]<x) over = false;
  	if(over) ans = min(ans, nedann);
  }
  
  if(ans!=1000000000) cout << ans << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
 
//#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define vvi vector <vi>
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
 
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
///*X.find_by_order("index")
///X.order_of_key("key")
 
#define deb(x) {x}
#ifndef local
	#define deb(x) ;
#endif
 
///----------------------------------------------------------------------------------

const int mod = 61559;
int n, k, arr[5005];
unsigned short Forward[5005][5005], backward[5005][5005][2], DP[5005][5005];
bitset <5005> vis[5005];
int fun(int ind, int rem)
{
	if (ind == n && rem == 0) return 1;
	if (ind == n) return 0;
	if (vis[ind][rem]) return DP[ind][rem];
	
	// I go
	vis[ind][rem] = 1;
	int res = 0;
	backward[ind][rem][1] = fun(ind+1, max(0, rem-arr[ind]));
	res = backward[ind][rem][1];
	
	
	// I dont go
	
	backward[ind][rem][0] = fun(ind+1, rem);
	res += backward[ind][rem][0];
	
	if (res >= mod) res -= mod;
	return DP[ind][rem] = res;
}
bool upper = true;
int fun2(int ind, int rem)
{
	if (rem < 0)
	{
		if (! upper) return 0;
		rem = 0;
	}
	if (ind == n && rem == 0) return 1;
	if (ind == n) return 0;
	if (vis[ind][rem]) return DP[ind][rem];
	vis[ind][rem] = 1;
	// I go
	
	int res = fun2(ind+1,rem-arr[ind]);
	
	// I dont go
	
	Forward[ind][rem] = fun2(ind+1, rem);
	res += Forward[ind][rem];
	
	if (res >= mod) res -= mod;
	return DP[ind][rem] = res;
}


void solve()
{
	
	cin >> n >> k;
	rep(i,0,n) cin >> arr[i];
	
	memset(vis, 0, sizeof vis);
	
	
	rep(i,0,k+1)fun(0, i);
	
	reverse(arr, arr+n);
	
	
	memset(vis, 0, sizeof vis);
	
	fun2(0, k);
	upper = false;
	
	memset(vis, 0, sizeof vis);
	rep(i,0,k)fun2(0, i);
	
	reverse(arr, arr+n);
	
	int ans = 0;
	
	rep(i,0,n)
	{
		int num_with_me = 0, num_without_me = 0;
		
		rep(j,0,k+1)
		{
				num_with_me += ( Forward[n-i-1][j] * backward[i][k-j][1]);
				num_without_me += ( Forward[n-i-1][j] * backward[i][k-j][0]);
			
		}
		if (num_without_me == num_with_me) ans++;
	}
	cout << ans << "\n";
}
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
 	
 	#ifdef local
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	clock_t qwertyuiop = clock();
	#endif
 
	int t = 1;
	//cin >> t;	
	rep(a,0,t)
	{
		//cout<<"Case #"<<a+1<<": ";
		solve();
		#ifdef local
			cout << "\n";
		#endif

	}
	
	#ifdef local
	{qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}


Measured memory_bytes: 199296
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/math/common_factor_rt.hpp>
#define USE_MATH_DEFINES
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
// namespace mp = boost::multiprecision;
// namespace mt = boost::math
// using Bint = mp::cpp_int;

bool linearSearch(int s[], int key, int n) {
    rep(i, n) {
        if (s[i] == key)
            return true;
    }
    return false;
}

int main() {
    int n, q, c = 0;
    cin >> n;
    int s[n];
    rep(i, n) cin >> s[i];
    cin >> q;
    int t[q];

    rep(i, q) {
        cin >> t[i];
        if (linearSearch(s, t[i], n))
            c++;
    }
    printf("%d\n", c);
}


Measured memory_bytes: 3256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<int> A,B,C;
int main() {
  cin >> N;
  A.resize(N);
  B.resize(N);
  C.resize(N);
  for (auto &val : A){
    cin >> val;
  }
  for (auto &val : B){
    cin >> val;
  }
  for (auto &val : C){
    cin >> val;
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  ll res = 0;
  for (int i = 0; i < B.size(); i++){
    int a = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
    int c = upper_bound(C.begin(), C.end(), B[i]) - C.begin();
    if (a - 1 >= 0 and a - 1 < N and c >= 0 and c < N){
      res += (ll)(a) * (N - c);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1408
S = input()
L = int(S[:2])
R = int(S[2:])

if L!=0 and R!= 0 and L <=12 and R<=12:
    print("AMBIGUOUS")
elif L!=0 and L<=12:
    print("MMYY")
elif R!=0 and R<=12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3060
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_N=2e5+3;


const unsigned long long B=1e12+7;

LL MOD=1000000007;
int main(){
    int A,B,M;
    cin>>A>>B>>M;
    vector<int>a(A),b(B);
    int mina=INT_MAX,minb=INT_MAX;
    REP(i,A){
        cin>>a[i];
        mina=min(mina,a[i]);
    }
    REP(i,B){
        cin>>b[i];
        minb=min(minb,b[i]);
    }
    int res=mina+minb;
    REP(i,M){
        int x,y,c;
        cin>>x>>y>>c;
        x--;y--;
        res=min(res,a[x]+b[y]-c);
    }
    cout<<res<<endl;
    return 0;
}


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

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

using f64 = double;
using f128 = long double;

template <typename T> using Vec = vector<T>;
template <typename K, typename V> using HashMap = unordered_map<K, V>;
template <typename T> using HashSet = unordered_set<T>;
template <typename T> using PQueue = priority_queue<T>;

using StrView = string_view;

auto solve(i64 const N, i64 const M) -> void {
  for (i64 i = 1; i <= M; i += 2) {
    i64 a = M - i / 2;
    i64 b = a + i;
    cout << a << " " << b << "\n";
  }
  for (i64 i = 2; i <= M; i += 2) {
    i64 a = i / 2;
    i64 b = N - i / 2;
    cout << a << " " << b << "\n";
  }
}

auto main() -> int {
  i64 N;
  scanf("%" SCNd64, &N);
  i64 M;
  scanf("%" SCNd64, &M);
  solve(N, M);
  return 0;
}


Measured memory_bytes: 3764
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;

typedef unsigned long long ull;
typedef pair<int,int> pii;

const int INF = 1010101010;

struct cmper{
	const vector<int> &v;
	explicit cmper(const vector<int> &w) : v(w) {}
	bool operator() (const pii &p, const pii &q) const{
		return v[p.second] < v[q.second];
	}
};

int main(){
	int s, r, a, b, c, qr;
	scanf("%d%d", &s, &r);
	vector<vector<pii> > G(s + 1);
	for(int i = 0; i < r; ++i){
		scanf("%d%d%d", &a, &b, &c);
		G[a].push_back(pii(c, b));
		G[b].push_back(pii(c, a));
	}
	scanf("%d%d%d", &a, &b, &qr);
	vector<int> xs(qr), ys(qr);
	for(int i = 0; i < qr; ++i){
		scanf("%d%d", &xs[i], &ys[i]);
	}

	vector<int> ds(s + 1, INF);
	priority_queue<pii> pq;
	vector<vector<int> > from(s + 1);
	pq.push(pii(0, a));
	ds[a] = 0;
	while(!pq.empty()){
		pii p = pq.top();
		pq.pop();
		int u = p.second;
		int d = -p.first;
		if(ds[u] != d){ continue; }

		for(size_t i = 0; i < G[u].size(); ++i){
			int v = G[u][i].second;
			int nd = d + G[u][i].first;
			if(ds[v] > nd){
				from[v].clear();
				pq.push(pii(-nd, v));
			}
			if(ds[v] >= nd){
				ds[v] = nd;
				from[v].push_back(u);
			}
		}
	}
	
	vector<char> vis(s + 1);
	queue<int> q;
	q.push(b);
	vis[b] = 1;
	vector<pii> es;
	while(!q.empty()){
		int u = q.front();
		q.pop();
		for(size_t i = 0; i < from[u].size(); ++i){
			int v = from[u][i];
			es.push_back(pii(v, u));
			if(!vis[v]){
				vis[v] = 1;
				q.push(v);
			}
		}
	}

	sort(es.begin(), es.end(), cmper(ds));

	vector<ull> dp(s + 1);
	for(int k = 0; k < qr; ){
		int t = min(k + 64, qr);
		fill(dp.begin(), dp.end(), 0ull);
		for(int i = k; i < t; ++i){
			dp[xs[i]] |= 1ull << (i - k);
		}
		for(size_t i = 0; i < es.size(); ++i){
			dp[es[i].second] |= dp[es[i].first];
		}
		for(int i = k; i < t; ++i){
			puts(dp[ys[i]] >> (i - k) & 1 ? "Yes" : "No");
		}
		k = t;
	}
}

Measured memory_bytes: 17176
def solve(n, list1):
    for i in range(n):
        list1[i] += [i+1]
    list1.sort(key=lambda x:[x[0], -x[1]])
    for i in range(n):
        print(list1[i][2])
        
n = int(input())
list1 = []
for i in range(n):
    list1 += [list(map(str, input().split()))]
    list1[i][1] = int(list1[i][1])
solve(n, list1)

Measured memory_bytes: 38384
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入


int main(){
    int N,C;
    cin >> N>>C;
    vector<vector<int>> D(C+2,vector<int>(C+2,0));
    vector<vector<int>> c(N+2,vector<int>(N+2,0));
    REP2(i,1,C+1){
        REP2(j,1,C+1){
            cin>>D[i][j];
        }
    }

    vector<vector<int>> v(3,vector<int>(C+1,0));
    REP2(i,1,N+1){
        REP2(j,1,N+1){
            cin>>c[i][j];
            v[(i+j)%3][c[i][j]]++;
        }
    }

    ll ans=INF;
    ll tmp;
    REP2(i,1,C+1){
        REP2(j,1,C+1){
            if(i==j) continue;
            REP2(k,1,C+1){
                
                if(j==k||i==k) continue;
                tmp=0;
                REP2(l,1,C+1){
                    tmp+=(v[0][l]*D[l][i]);
                    tmp+=(v[1][l]*D[l][j]);
                    tmp+=(v[2][l]*D[l][k]);
                }
                ans=min(ans,tmp);
            }   
        }
    }
    cout << ans << endl;

    


    
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

void all_enum(string R, string B, string &S, map<string,int> &m){
    int i=(int)R.size()+B.size();
    if(i==(int)S.size()){
        string key_=R+","+B;
        //cout << key_ << endl;
        if(m.count(key_)){
            m[key_]++;
        }else{
            m[key_]=1;
        }
        return;
    }
    
    all_enum(R+S[i],B,S,m);
    all_enum(R,B+S[i],S,m);
}

ll count_pattern(string R, string B, string &T, map<string,int> &m){
    int i=(int)R.size()+B.size();
    if(i==(int)T.size()){
        string key_=R+","+B;
        //cout << key_ << endl;
        if(m.count(key_)){
            return m[key_];
        }else{
            return 0;
        }
    }

    ll cnt=0;
    cnt+=count_pattern(R+T[i],B,T,m);
    cnt+=count_pattern(R,B+T[i],T,m);
    return cnt;
}

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    string T=S.substr(N,N);
    reverse(T.begin(),T.end());
    S=S.substr(0,N);

    map<string,int> m;

    all_enum("","",S,m);
    //cout << "_______" << endl;
    cout << count_pattern("","",T,m) << endl;

}

Measured memory_bytes: 33792
#もらうDP + 累積和
n, k = map(int, input().split())
mod = 998244353
li = []
for _ in range(k):
    l, r = map(int, input().split())
    li.append((l, r))
li.sort()
dp = [0]*(2*n+1)
s = [0] * (2*n+1)
dp[1] = 1
s[1] = 1
for i in range(2, n+1):
    for t in li:
        l, r = t
        dp[i] += s[max(i-l, 0)]
        dp[i] -= s[max(i-r-1, 0)]
        dp[i] %= mod
    s[i] = s[i-1] + dp[i]
    s[i] %= mod
print(dp[i]%mod)

Measured memory_bytes: 74180
n = gets.to_i
num = gets.strip.split.map(&:to_i)
ary = Array.new(n,0)
ary[0] = num[0]
ary[n-1] = num[n-2]
i = 1
if n != 2
  while i < n-1 do
    if num[i-1] >= num[i]
      ary[i] = num[i]
    else
      ary[i] = num[i-1]
    end
    i += 1
  end
end
puts ary.sum

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll x, K;
  cin >> x >> K;
  if (x > K) {
    x -= (x/K)*K;
  }
  ll ans = min(x, K-x);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1e9;
// const int mod = 1e9 + 7;
const int mod = 1e5;
using Graph = vector<vector<int>>;

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

    int n, m;
    cin >> n >> m;
    vi s(n);
    rep(i, n - 1) {
        cin >> s[i];
    }
    rrep(i, n - 1) {
        s[i] += s[i + 1];
    }

    auto getSum = [&](int& p, int a){
        int l = p, r = p + a;
        if (l > r) swap(l, r);
        p += a;
        return s[l] - s[r];
    };

    int p = 0;
    int ans = 0;
    rep(i, m) {
        int a;
        cin >> a;
        (ans += getSum(p, a)) %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3360
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    vector<pair<string, int>> v;

    ll ans = 0;

    for (int i = 0; i < n; i++) {
        string s;
        int t;
        cin >> s >> t;
        v.emplace_back(s, t);
        ans += t;
    }

    string x;
    cin >> x;

    for (const auto &p : v) {
        ans -= p.second;
        if (p.first == x)
            break;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
/*{{{*/
#include <bits/stdc++.h>
#ifdef LOCAL
int c_ = 0;
#define cout (c_?cerr:cout)
#define debug(...) \
{if(!c_++)cerr<<"\033[96;1m"; \
__VA_ARGS__; \
if(!--c_)cerr<<"\033[0m";}
#else
#define debug(...) {}
#endif
#define assrt(...) debug(\
if (not (__VA_ARGS__)) \
    exit((cerr << __LINE__ << ": " << #__VA_ARGS__ << '\n', 0));\
)
#define st first
#define nd second
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
using namespace std; using ll = long long;
template < typename t > using V = vector< t >;
template < typename t, size_t s > using A = array< t, s >;
void print() {cout << '\n';}
template< typename t, typename... v >
void print(const t& a, const v&... b)
{cout << a << (sizeof...(b)?" ":""); print(b...);}
template< typename t > void print_range(t a, const t& b)
{ while (a != b) cout << (*a++) << ' '; cout << '\n';}
#define dump(...) debug(print(#__VA_ARGS__,'=',__VA_ARGS__))
#define dump_range(...) debug(cerr<<#__VA_ARGS__ << ": "; print_range(__VA_ARGS__))
/*}}}*/

constexpr int nax = 2e5;

string s;

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

    cin >> s;

    int cnt = 0;
    ll res = 0;

    for (int i = (int)s.size() - 2; i >= 0; --i)
    {
        if (s[i] == 'B' and s[i + 1] == 'C') 
            ++cnt;
        if (s[i] == 'C' and s[i + 1] == 'B') 
            {}
        if (s[i] == 'B' and s[i + 1] == 'B') 
            cnt = 0;
        if (s[i] == 'C' and s[i + 1] == 'C') 
            cnt = 0;
        if (s[i] == 'A' and s[i + 1] == 'B') 
            res += cnt;
        if (s[i] == 'B' and s[i + 1] == 'A') 
            cnt = 0;
        if (s[i] == 'A' and s[i + 1] == 'C') 
            cnt = 0;
        if (s[i] == 'C' and s[i + 1] == 'A') 
            {}
        if (s[i] == 'A' and s[i + 1] == 'A')
            res += cnt;
    }

    print(res);
}

Measured memory_bytes: 720
// Problem : E - Logs
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define int long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define mod 998244353
#define bug cout<<"HY"<<endl
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define numize(A) A.numize(unique(A.begin(), A.end()) - A.begin())
typedef pair<int,int> P;
int power(int a,int b)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return (power((a*a)%mod,b/2))%mod;
    return (a*(power((a*a)%mod,b/2))%mod)%mod;
}
int modInv(int n)
{
    return power(n, MOD-2);
}
int nCr(int n, int r, int p=MOD)
{
   if (r==0)
      return 1;
    int Fact[n+1];
    Fact[0] = 1;
    for (int i=1 ; i<=n; i++)
    {
        Fact[i] = (Fact[i-1]*i)%p;
    }
    return (((Fact[n]* modInv(Fact[r])) % MOD) *(modInv(Fact[n-r]) % MOD)) % MOD;
}
double PI=3.14159265359;
void solve()
{
	int n,k,i;
	cin>>n>>k;
	int A[n];
	for(i=0;i<n;i++)
		cin>>A[i];	
	sort(A,A+n);
	double low=0,high=A[n-1];
	double ans=0;
	while(high-low>=.000001)
	{
		double mid=(low+high)/2;
		int cnt=0;
		for(i=0;i<n;i++)
		{
			int num=A[i]/mid;
			if(A[i]==num*mid)
				num--;
			cnt+=num;
		}
		ans=mid;
		if(cnt>k)
		{
			low=mid;
		}
		else
		{
			high=mid;
		}
	}
	// ans=(int)ans
	ans=ceil(ans);
	int f=ans;
	cout<<f<<endl;
}
int32_t main()
{
    boost;
    int  t=1;
    // cin>>t;
    while(t--)
    {
    	solve();
    }
}


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

using namespace std;

typedef pair<int, int> p;
typedef long long ll;
const int inf = 1000000007;

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll ans = floor(a * min(b - 1, n) / b);
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
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; }

int dy[]={0, 0, 1, -1, 1, -1, -1, 1};
int dx[]={1, -1, 0, 0, 1, 1, -1, -1};


int main() {
    cout<<fixed<<setprecision(10);

    ll n;cin>>n;
    vint a(n); rep(i,n) cin>>a[i];

    sort(ALL(a), greater<ll>());
    ll ans = a[0];

    rep(i,n-2){
        ans += a[1+i/2];
    }


    cout<<ans<<endl;

    return 0;

}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(a>0 && c>0){
  	c-=b;
    a-=d;
  }

  if(c<=0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;



int main(){
    ll K;
    cin >> K;
    ll A;
    cin >> A;
    ll B;
    cin >> B;
    ll a=(A-1)/K;
    ll b=B/K;
    if(a!=b){
        cout<<"OK"<<endl;
    }
    else cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC139_E___League
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var matches = new List<int>();
            var following = new Dictionary<int, List<int>>();
            var indegrees = new Dictionary<int, int>();
            var isRemaining = new Dictionary<int, bool>();
            for (int i = 1; i < N + 1; i++)
            {
                for (int j = i + 1; j < N + 1; j++)
                {
                    var match = MatchHash(i, j);
                    matches.Add(match);
                    following.Add(match, new List<int>());
                    indegrees.Add(match, 0);
                    isRemaining.Add(match, true);
                }
            }

            for (int i = 1; i < N + 1; i++)
            {
                var read = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                for (int j = 1; j < N - 1; j++)
                {
                    var prev = MatchHash(i, read[j - 1]);
                    var follow = MatchHash(i, read[j]);
                    following[prev].Add(follow);
                    indegrees[follow]++;
                }
            }

            var dailyMatches = new Queue<int>();
            foreach (int m in matches.Where(m => indegrees[m] == 0 && isRemaining[m])) dailyMatches.Enqueue(m);
            var day = 0;
            while (true)
            {
                var nextDayMatches = new Queue<int>();
                while (dailyMatches.Count() > 0)
                {
                    var current = dailyMatches.Dequeue();
                    isRemaining[current] = false;
                    foreach (int m in following[current])
                    {
                        indegrees[m]--;
                        if (indegrees[m] == 0) nextDayMatches.Enqueue(m);
                    }
                }
                day++;
                dailyMatches = nextDayMatches;
                if (dailyMatches.Count() == 0) break;
            }

            Console.WriteLine(isRemaining.Values.Count(m => m) > 0 ? -1 : day);
        }
        static int MatchHash(int A, int B)
        {
            return A > B ? A * 1000 + B : B * 1000 + A;
        }
    }
}


Measured memory_bytes: 132856
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

set<char> st[52];

int main(void){
	int i;
	string s,t;
	cin >> s >> t;
	for(i=(s.l_ength()-1); i>=0; --i){
		st[t[i]-'a'].insert(s[i]);
		st[s[i]-'a'+26].insert(t[i]);
	}
	for(i=0; i<52; ++i){
		if(st[i].l_ength()>1){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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

using namespace std;

#define endl "\n"
#define maxn 100000
#define OO 1e5
#define F first
#define S second
#define B begin()
#define E end()
#define PB push_back
#define int long long

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;

int32_t main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

//	freopen("name.in","r",stdin);
//	freopen("name.out","w",stdout);

    int n;
    cin >> n;
    int acum=0;
    int cant = n/500;
    acum+=cant*1000;
    n%=500;
    cant=n/5;
    acum+=cant*5;
    cout <<acum;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import Counter
def inpl(): return list(map(int, input().split()))

N = int(input())
a, b, c = 0, 0, 0
for x in inpl():
    if x%4 == 0:
        a += 1
    elif x%2 == 0:
        b += 1
    else:
        c += 1

if a+(b==0) >= c:
    print("Yes")
else:
    print("No")

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

int main(){
    int m,n;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);

    int total = 0;
    rep(i,n){
        total += a.at(i);
    }

int ccnt = 0;
    rep(i,n){
        if((a.at(i) * 4 * m) >= total){
            ccnt++;
            // cout << a.at(i) << " " << ccnt << endl;
        }
    }

    cout << ((ccnt>=m) ? "Yes" : "No") << endl;
} 

Measured memory_bytes: 256
//??\??????1????????¶????±?????????????d???????????????????????´???d????????¨??????2????????¶????????????????????????????¨???????????????????????????´????????????????????????
//?????????
//?????¶??¨??¶?????´??????x?????????y???????????´??°??§????????¨?????????????????????????????¢??§?????????
//????????\?????§???
//?????´??????????????????????????¶??¨??¶????????¶?????¨?????´?????????????????¢??????1??\???????????????????????????????????¢??§?????????
//?????´????????????????????????????????¶??¨??¶????????¶?????¨?????´?????????????????¢??????1???????????¨???????????§???????????¢ + 1??§?????????
//??????????????????????????¢??§?????????????????????????????????x?????? = y???????????´???????§?????????¢???d???2
//??????????????????????????????????????????2??????????????????
//
//???d * sqrt(2.0)??¨????????¨????????????sqrt(d * 2.0)??¨???????????????????????§2?????????????????????kiresou
//
//????¨????x?????????0?????????y?????????0?????¨????????????2?????????????????????????????????
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

double getDist(double diffx, double diffy) {
	double epx = max(diffx - (int)diffx, (int)diffx - diffx);
	double epy = max(diffy - (int)diffy, (int)diffy - diffy);
	if (epx > 1e-12 && epy > 1e-12)	//??????????????´??°??§??????
		return diffx + diffy;
	//diffx?????´??°
	if (epx <= 1e-12) {
		//y?????????1??????
		if (diffy < 1)
			return max(diffx, diffy) + 1;
		//y?????????1??\???
		return diffx + diffy;
	}
	//diffy?????´??°
	else {
		//x?????????1??????
		if (diffx < 1)
			return max(diffx, diffy) + 1;
		//y?????????1??\???
		return diffx + diffy;
	}
}

int main() {
	double d, ans = 0;
	cin >> d;
	for (double diffx = 1; diffx <= d; diffx++) {
		double diffy = sqrt(d * d - diffx * diffx);
		ans = max(ans, getDist(diffx, diffy));
	}
	ans = max(ans, d * sqrt(2.0));
	
	printf("%.14f\n", ans);
	return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
    int a,b;
    cin >> a >> b;
    if (a-2*b>0) {
        cout << a-2*b << "\n";
    } else {
        cout << 0 << "\n";
    }
}


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

int main(){
    int n;
    cin >> n;
    string a, b, c;
    cin >> a >> b >> c;
    int tmp = 0;
    for (int i = 0; i < n; i++){
        if (a[i] == b[i] && b[i] == c[i]) tmp += 0;
        else if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) tmp += 1;
        else tmp += 2;
    }
    cout << tmp << endl;
}

Measured memory_bytes: 256
import typing


class DSU:
    '''
    Implement (union by size) + (path compression)
    Reference:
    Zvi Galil and Giuseppe F. Italiano,
    Data structures and algorithms for disjoint set union problems
    '''

    def __init__(self, n: int = 0):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a: int, b: int) -> int:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        x = self.leader(a)
        y = self.leader(b)

        if x == y:
            return x

        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x

        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x

        return x

    def same(self, a: int, b: int) -> bool:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        return self.leader(a) == self.leader(b)

    def leader(self, a: int) -> int:
        assert 0 <= a < self._n

        if self.parent_or_size[a] < 0:
            return a

        self.parent_or_size[a] = self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]

    def size(self, a: int) -> int:
        assert 0 <= a < self._n

        return -self.parent_or_size[self.leader(a)]

    def groups(self) -> typing.List[typing.List[int]]:
        leader_buf = [self.leader(i) for i in range(self._n)]

        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)

        return list(filter(lambda r: r, result))


import sys
input = sys.stdin.readline
n, q = map(int, input().split())
uf = DSU(n)
res = []
for i in range(q):
    t, u, v = map(int, input().split())
    if t:
        res.append(int(uf.same(u, v)))
    else:
        uf.merge(u, v)
print("\n".join(map(str, res)))


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

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

signed main(){
    string s, t;
    cin >> s >> t;
    vector<vector<int>> dp(s.length()+1, vector<int>(t.length()+1,0));
    
    rep(i,s.length()){
        rep(j,t.length()){
            if(s[i]==t[j]){
                chmax(dp[i+1][j+1], dp[i][j]+1);
            }
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }
    
    string res;
    int i = s.length(), j = t.length();
  
    while(i > 0 && j > 0){
        if(dp[i][j] == dp[i-1][j]){
            i--;
        }else if(dp[i][j] == dp[i][j-1]){
            j--;
        }else if(dp[i][j] == dp[i-1][j-1]+1){
            i--; j--;
            res = s[i] + res;
        }
    }
    
    cout << res << endl;
}

Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  map<char, char> m;
  map<char, char> n;

  int l = s.size();
  for (int i = 0; i < l; i++) {
    char cs = s[i];
    char ct = t[i];

    if (m.find(cs) == m.end()) {
      m.insert(make_pair(cs, ct));
    } else {
      if (m[cs] != ct) {
        cout << "No" << endl;
        return 0;
      }
    }
    if (n.find(ct) == n.end()) {
      n.insert(make_pair(ct, cs));
    } else {
      if (n[ct] != cs) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
  return 0;

}


Measured memory_bytes: 776
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "YES";
    private static final String NO = "NO";
    private static final String IMPOSSIBLE = "IMPOSSIBLE";

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        System.out.println(solve(A, B));
    }

    private static String solve(int A, int B) {
        if ((A+B)%2 != 0) return IMPOSSIBLE;

        return String.valueOf((A+B)/2);
    }
}

Measured memory_bytes: 22224
#include <iostream>
#include <vector>
#define INF 99999999
using namespace std;


struct order{
	int start;
	int end;
	int kind;
};

struct edge{
	int from;
	int to;
	int cost;
	int time;
};


int dis[2][100][100];//種類、出発駅、各駅 cost:0 time:1
int counter=0;
//答えのカウンタ
edge Eg[3000];

int ans[100000];//答えの保存先
int flag=0;

//グローバルな配列 :dis, eg,ans

void shortest(int start,int N,int E,int KIND){//出発駅,N:フィールド幅,E:エッジ本数
	for(int i=0;i<N;i++)
	dis[KIND][start][i]=INF;
	
	dis[KIND][start][start]=0;
	
	if(KIND==0){
	while(true){
		bool update=false; //updateあればtrue
		
		for(int j=0;j<E;j++){//エッジでまわす
			edge es=Eg[j];
			if(dis[KIND][start][es.from]!=INF && 
						dis[KIND][start][es.to]>dis[KIND][start][es.from]+es.cost){
				dis[KIND][start][es.to]=dis[KIND][start][es.from]+es.cost;
				update=true;
			}
		}
		for(int j=0;j<E;j++){//エッジでまわす
			edge es=Eg[j];
			if(dis[KIND][start][es.to]!=INF && 
						dis[KIND][start][es.from]>dis[KIND][start][es.to]+es.cost){
				dis[KIND][start][es.from]=dis[KIND][start][es.to]+es.cost;
				update=true;
			}
		}
		if(!update) break;
		}
	}
	
	if(KIND==1){
	while(true){
		bool update=false; //updateあればtrue
		
		for(int j=0;j<E;j++){//エッジでまわす
			edge es=Eg[j];
			if(dis[KIND][start][es.from]!=INF && 
						dis[KIND][start][es.to]>dis[KIND][start][es.from]+es.time){
				dis[KIND][start][es.to]=dis[KIND][start][es.from]+es.time;
				update=true;
			}
		}
		for(int j=0;j<E;j++){//エッジでまわす
			edge es=Eg[j];
			if(dis[KIND][start][es.to]!=INF && 
						dis[KIND][start][es.from]>dis[KIND][start][es.to]+es.time){
				dis[KIND][start][es.from]=dis[KIND][start][es.to]+es.time;
				update=true;
			}
		}
		if(!update) break;
		}
	}
}

void solve(){
	int E,N,k;
	cin >> E >> N;
	if(E==0) {flag=1; return;}
	
	for(int i=0;i<E;i++){
		cin >> Eg[i].from >> Eg[i].to >> Eg[i].cost >> Eg[i].time;
		Eg[i].from--; Eg[i].to--; //駅の番号-1
	}
	cin>>k;
	order O[200];
	for(int i=0;i<k;i++){
		cin >> O[i].start >> O[i].end >> O[i].kind;
		O[i].start--; O[i].end--;//駅の番号-1
	}
	

	
	for(int x=0;x<k;x++){
		shortest(O[x].start,N,E,O[x].kind);
		ans[counter]=dis[O[x].kind][O[x].start][O[x].end];
		counter++;
	}
}



int main (){
	
	while(flag==0){
		solve();
	}
	
	for(int i=0;i<counter;i++)
	cout << ans[i]<<"\n";
}
	

Measured memory_bytes: 1304
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric> // accumulate
#include <queue>
#include <string>
#include <cmath> // sqrt
#include <map>
using namespace std;
typedef long long ll;

const ll INF = (1LL << 62);
ll dp[1010][1010];
const ll mod = 1000000007;
int main() {
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    for (int i = 0; i < h; i++) {
        cin >> a[i];
    }

    dp[0][0] = 1;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] == '#') {
                dp[i][j] = 0;
                continue;
            }
            if (i > 0) dp[i][j] += dp[i-1][j] % mod;
            if (j > 0) dp[i][j] += dp[i][j-1] % mod;
        }
    }

    cout << dp[h-1][w-1] % mod << endl;
}

Measured memory_bytes: 9216
n, m = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
flag = [False for i in range(n)]
ans = 0
for bit in range(1 << n):
    a = True

    for i in range(n):
        if bit & (1 << i):
            flag[i] = True
        else:
            flag[i] = False
    for i in range(m):
        count = 0
        for j in range(len(ks[i])):
            if j == 0:
                continue
            if flag[ks[i][j] - 1]:
                count += 1
        if count % 2 != p[i]:
            a = False
    if a:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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;
}

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int n;
int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}


void solve() {
  int n;
  cin >> n;
  int h[n];
  for(int i = 0;i < n;i++){
      cin >> h[i];

  }

  //尺取り方
  //i means left
  //j means right

  int ans = -1;
  int sum = 0;
  for(int i = 0;i < n-1;i++){
      if(h[i] >= h[i+1]){
          sum+=1;
    }else{
        ans = max(sum,ans);
        sum = 0;
    }
  }
    ans = max(sum,ans);
    cout << ans << endl;
}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int cnt[100005];

signed main()
{
    int N; cin>>N;
    REP(i,N){
        int a; cin>>a;
        cnt[a]++;
    }
    
    int ans=0;
    for(int i=1;i<100000;i++){
        ans=max(ans,cnt[i-1]+cnt[i]+cnt[i+1]);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
const long long MOD = 1e9+7, INF = 1e18;
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;}



signed main(){
	int N,S,T;
	cin>>N>>S>>T;
	cout<<'?'<<" "<<S<<" "<<T<<endl;
	cout.flush();
	int dist;
	cin>>dist;
	vector<pair<int,int>>v;
	FOR(i,1,N+1){
		if(i==S||i==T)continue;
		int s,t;
		cout<<'?'<<" "<<S<<" "<<i<<endl;
		cout.flush();
		cin>>s;
		cout<<'?'<<" "<<i<<" "<<T<<endl;
		cout.flush();
		cin>>t;
		if(s+t==dist)v.push_back({s,i});
	}
	sort(ALL(v));
	cout<<'!'<<" "<<S;
	REP(i,v.size()){
		cout<<" "<<v[i].second;
	}
	cout<<" "<<T<<endl;
}


Measured memory_bytes: 4652
from fractions import gcd
from collections import deque
n = int(input())
a = list(map(int, input().split()))
l = [0]
r = deque([0])
g = []
for i in range(n):
    l.append(gcd(l[i], a[i]))
    r.appendleft(gcd(r[-(i + 1)], a[-(i + 1)]))
r = list(r)

for i in range(n):
    g.append(gcd(l[i], r[i + 1]))
print(max(g))

Measured memory_bytes: 16148
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
const int N=1e5+5,M=N<<2;
int ans,s,t,tot,now,n,m,head[N],nex[M],to[M];
int d[N];
bool vv[N];
void add(int u,int v)
{
    to[++tot]=v;nex[tot]=head[u];head[u]=tot;
}
struct node
{
    int u,x;
    node(int u,int x):u(u),x(x){}
    bool operator<(const node&o)const
    {
        return x>o.x;
    }
};
set<pair<int,int>,int>mp;
int vis[N][3];
priority_queue<node>q;
pair<int,int>st[N*3];
int top;
void dfs(int u,int p)
{
    if(p==0)
    {
        if(d[u]>d[now]+1)
        {
            d[u]=d[now]+1;
            vv[u]=false;
            q.push(node(u,d[u]));
        }
        return;
    }
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];
        if(vis[v][p-1]) continue;
        vis[v][p-1]=true;
        st[++top]=make_pair(v,p-1);
        dfs(v,p-1);
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);
    }
    memset(d,inf,sizeof(d));
    scanf("%d%d",&s,&t);
    d[s]=0;
    memset(vv,true,sizeof(vv));
    vv[s]=false;
    q.push(node(s,d[s]));
    while(!q.empty())
    {
        now=q.top().u;q.pop();
        if(vv[now]||d[now]>=d[t]) continue;
        while(top)
        {
            vis[st[top].first][st[top].second]=false;
            top--;
        }
        vv[now]=true;
        dfs(now,3);
        if(now==d[t]) break;
    }
    if(d[t]!=d[0]) printf("%d\n",d[t]);
    else printf("-1\n");
} 

Measured memory_bytes: 5880
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int s = sc.nextInt();
    int w = sc.nextInt();
    
    if(s>w){
      System.out.println("safe");
    }
    else{
      System.out.println("unsafe");
    }
  }
}

Measured memory_bytes: 35788
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
  int n;cin>>n;
  double ans = 0;
  fol(i,n){
    double a;cin>>a;
    ans += (1.0/a);
  }
  cout << 1.0/ans << endl;
  return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace contest_Csharp
{
    class Program
    {


        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var vals = Console.ReadLine().Split(' ').
                Select(x => int.Parse(x)).ToList();
            var N = vals[0];
            var M = new int[N];

            for (int x = 1; x < 101; x++)
            {
                for (int y = 1; y < 101; y++)
                {
                    for (int z = 1; z < 101; z++)
                    {
                        if (x*x+y*y+z*z+x*y+y*z+z*x <=N)
                        {
                            M[x * x + y * y + z * z + x * y + y * z + z * x-1]++;
                        }
                    }
                }
            }
            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(M[i]);
            }
            //var ans = A.Where((x,i)=> (x%2==1 && i%2==0)).Count();


            //Console.WriteLine(ans);
            Console.Out.Flush();
        }





    }
}




Measured memory_bytes: 28036