akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n, tmp, sum=0;
    cin >> n;
    
    vector<int> a, c;
    for(int i=0; i<n; i++){
        cin >> tmp;
        a.push_back(tmp);
    }
    for(int i=0; i<n; i++){
        cin >> tmp;
        sum += tmp;
    }
    
    for(int i=0; i<n-1; i++){
        cin >> tmp;
        c.push_back(tmp);
    }
    
    for(int i=1; i<n; i++){
        if(a[i-1]+1 == a[i]){sum += c[a[i-1]-1];}
    }
    
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio		ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define For(i,a,b)               for(int i=a;i<b;i++)
#define input(a,n)	For(i,0,n)cin>>a[i]
#define pb                          push_back
#define minimum(a)					*min_element(a.begin(), a.end())
#define maximum(a)					*max_element(a.begin(), a.end())
#define f 	first
#define s 	second
#define nl cout<<endl
#define print(a,n)	For(i,0,n){cout<<a[i]<<' ';}nl
#define pii pair<int,int>
using namespace std;
typedef long long ll;

int main()
{
	fastio;
	int n;
	cin>>n;
	int a[n][3],ans[n][3];
	For(i,0,3)
	{
		cin>>a[0][i];
		ans[0][i]=a[0][i];
	}
	For(i,1,n)
	{
		For(j,0,3)
		{		
			cin>>a[i][j];
			ans[i][j]=a[i][j]+max(ans[i-1][(j+1)%3],ans[i-1][(j+2)%3]);
		}
	}
	cout<<max(ans[n-1][0],max(ans[n-1][1],ans[n-1][2]));
	return 0;
}

Measured memory_bytes: 2560
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

A, B, K = map(int, raw_input().split())

for i in range(K):
    if i % 2 == 0:
        B += A / 2
        A /= 2
    else:
        A += B / 2
        B /= 2

print A, B

Measured memory_bytes: 2812
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>

#define INF 1000000000000000
#define MAX 100010
#define ll long long
#define P pair<ll,ll>
using namespace std;

vector<pair<ll,ll>> G[MAX],H[MAX];
ll d[MAX],s,t,y[MAX],snu[MAX],ans[MAX],V,E;
bool used[MAX];
priority_queue<P,vector<P>,greater<P>> que;

void dijkstra(int s){
	for(int i=0;i<V;i++){
		d[i] = INF;
		used[i] = false;
	}
	que.push({0,s});
	while(!que.empty()){
		P p = que.top();
		que.pop();
		ll x = p.second;
		if(used[x]) continue;
		used[x] = true; d[x] = p.first;
		for(P e: G[x]){
			if(d[e.first]>d[x]+e.second){
				que.push({d[x]+e.second,e.first});
			}
		}
	}
}

void dijkstra2(int s){
	for(int i=0;i<V;i++){
		d[i] = INF;
		used[i] = false;
	}
	que.push({0,s});
	while(!que.empty()){
		P p = que.top();
		que.pop();
		ll x = p.second;
		if(used[x]) continue;
		used[x] = true; d[x] = p.first;
		for(P e: H[x]){
			if(d[e.first]>d[x]+e.second){
				que.push({d[x]+e.second,e.first});
			}
		}
	}
}

int main(){
	cin >> V >> E >> s >> t;
	s--; t--;
	int i;
	for(i=0;i<E;i++){
		ll u,v,a,b;
		cin >> u >> v >> a >> b;
		u--; v--;
		G[u].push_back({v,a});
		G[v].push_back({u,a});
		H[u].push_back({v,b});
		H[v].push_back({u,b});
	}
	
	dijkstra(s);
	for(i=0;i<V;i++){
		y[i] = d[i];
	}
	
	dijkstra2(t);
	for(i=0;i<V;i++){
		snu[i] = d[i];
	}
	ans[V] = INF;
	for(i=V-1;i>=0;i--){
		ans[i] = min(ans[i+1],y[i]+snu[i]);
	}
	
	for(i=0;i<V;i++){
		cout << INF - ans[i] << endl;
	}
}

Measured memory_bytes: 20600
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::VecDeque;

fn main() {
    input! {
        n: usize,
        m: usize,
        es: [(usize1, usize1); m],
        s: usize1,
        t: usize1,
    }

    let mut g = vec![vec![]; n];

    for (u, v) in es {
        g[u].push(v);
    }

    let mut q = VecDeque::new();
    q.push_back((s, 0));
    let mut dist = vec![vec![None; 3]; n];
    dist[s][0] = Some(0);

    while let Some((cur, mo)) = q.pop_front() {
        if cur == t && mo == 0 {
            println!("{}", dist[cur][mo].unwrap() / 3);
            return;
        }
        for &v in g[cur].iter() {
            let no = (mo + 1) % 3;
            if dist[v][no].is_none() {
                dist[v][no] = Some(dist[cur][mo].unwrap() + 1);
                q.push_back((v, no));
            }
        }
    }

    println!("-1");
}


Measured memory_bytes: 18684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1e9 + 7;
int main()
{
    int n;
    cin >> n;
    vector<vector<ll>> d(n+1);
    for(ll i = 1; i <= n; i++)
    {
        ll a;
        cin >> a;
        d[a].push_back(i);
    }
    vector<int> depth(n+1);
    function<void(ll, ll)> dep = [&](ll v, ll dd)
    {
        depth[dd]++;
        for(auto to: d[v])
        {
            dep(to, dd+1);
        }
    };
    dep(0, 0);

    struct node
    {
        ll x, y, z;
        node(ll x, ll y, ll z) : x(x), y(y), z(z) {}
        void plus(node n)
        {
            ll nx = x * n.x % MOD;
            ll ny = (x * n.y + y * n.x) % MOD;
            ll nz = (x * n.z + y * (n.y + n.z) + z * (n.x + n.y + n.z)) % MOD;
            x = nx;
            y = ny;
            z = nz;
        }
    };

    function<deque<node>(ll)> dfs = [&](ll v)
    {
        deque<node> ret;
        ll sz = 0;
        for(auto to: d[v])
        {
            auto dq = dfs(to);
            if(ret.size() < dq.size()) swap(ret, dq);
            for(int i = 0; i < dq.size(); i++)
            {
                ret[i].plus(dq[i]);
            }
            sz = max(sz, (ll)dq.size());
        }
        for(int i = 0; i < sz; i++)
        {
            ret[i].x += ret[i].z;
            ret[i].z = 0;
        }
        ret.emplace_front(node(1, 1, 0));
        return ret;
    };

    auto ret = dfs(0);

    vector<ll> mod2(n+1);
    mod2[0] = 1;
    for(int i = 1; i <= n; i++)
    {
        mod2[i] = mod2[i-1] * 2 % MOD;
    }

    ll ans = 0;
    for(int i = 0; i < ret.size(); i++)
    {
        ans = (ans + ret[i].y * mod2[n+1-depth[i]]) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 177536
#include <stdio.h>

int main(void) {

    int N, M;
    int total;

    // input
    scanf("%d %d", &N, &M);

    total = (N * (N-1)) / 2 + (M * (M - 1)) / 2;

    printf("%d\n", total);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fi first
#define se second
#define pb push_back
#define mk make_pair
using namespace std;
typedef long long ll;
typedef long double lld;
const ll INF = 1e18;
const ll mod = 1e9+7;
 
ll fastpowMOD(ll a, ll p,ll MOD);
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; a %= MOD; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }
 
ll lcm(ll a,ll b){
	return (a*b)/__gcd(a,b);
}

void solve(){
	ll h,w,k;
	cin>>h>>w>>k;
	ll choices = 0;
	ll lb = 0;
	vector< vector<char> > grid(h,vector<char>(w,'?'));
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			cin>>grid[i][j];
		}
	}
	
	
	for(ll i=0;i<=(1LL<<h);i++){
		
		
		
		for(ll j=0;j<=(1LL<<w);j++){
			
				lb = 0;
				for(ll r=0;r<h;r++){
					for(ll c=0;c<w;c++){
						if((i & (1LL<<r)) && (j & (1LL<<c))){
							if(grid[r][c]=='#'){
								lb++;
							}
						}
					}
				}
				if(lb==k){
					choices++;
				}
				
			}
		}
		
		
		
		
	
	
	cout<<choices<<"\n";
	
}

int main(){
    fastio;
	solve();
	
}




Measured memory_bytes: 3672
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    x = int(readline())
    h = int(readline())
    if x == h == 0:
        return False
    write("%.16f\n" % (x*x + x*(x*x + 4*h*h)**.5))
    return True
while solve():
    ...



Measured memory_bytes: 5648
#include <stdio.h>
int main(void)
{
    int n,i;
    int a[10000] = {};
    int min,max;
    long int sum = 0;
 
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
 
    min = a[0];
    for(i=0;i<n;i++){
       if(min>a[i]) min = a[i];
    }
    max = a[0];
    for(i=0;i<n;i++){
       if(max<a[i]) max = a[i];
    }    
 
    for(i=0;i<n;i++){
      sum += a[i];
    }
     
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}
 

Measured memory_bytes: 648
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef pair<int, int> P;

const int MAX_N = 1010;

int A[MAX_N][MAX_N];
int node_number[MAX_N][MAX_N];

vector<int> graph[MAX_N * MAX_N];
int state[MAX_N * MAX_N];

bool dfs(int node, vector<int>& tsorted_node) {
    if (state[node] == GRAY) return false;
    if (state[node] == BLACK) return true;
    bool res = true;
    state[node] = GRAY;
    rep(i, 0, graph[node].size()) {
        res &= dfs(graph[node][i], tsorted_node);
    }
    tsorted_node.push_back(node);
    state[node] = BLACK;
    return res;
}

vector<int> tsort(int n) {
    bool is_ok = true;
    vector<int> res;
    rep(i, 0, n) {
        if (state[i] == BLACK) continue;
        is_ok &= dfs(i, res);
    }
    if (is_ok) {
        reverse(all(res));
        return res;
    }
    else return vector<int>(0);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    rep(i, 0, N) rep(j, 0, N - 1) {
        cin >> A[i][j];
        A[i][j]--;
    }
    rep(i, 0, N) rep(j, 0, N) node_number[i][j] = -1;
    int number = 0;
    rep(i, 0, N) rep(j, 0, N - 2) {
        if (node_number[i][A[i][j]] < 0) node_number[i][A[i][j]] = node_number[A[i][j]][i] = number++;
        if (node_number[i][A[i][j + 1]] < 0) node_number[i][A[i][j + 1]] = node_number[A[i][j + 1]][i] = number++;
        graph[node_number[i][A[i][j]]].push_back(node_number[i][A[i][j + 1]]);
    }
    vector<int> nodes = tsort(N * (N - 1) / 2);
    if (nodes.size() == 0) {
        cout << -1 << endl;
        return 0;
    }
    vector<int> dist(nodes.size(), 0);
    rep(i, 0, nodes.size()) {
        rep(j, 0, graph[nodes[i]].size()) {
            dist[graph[nodes[i]][j]] = max(dist[graph[nodes[i]][j]], dist[nodes[i]] + 1);
        }
    }
    int ans = 0;
    rep(i, 0, dist.size()) {
        ans = max(ans, dist[i]);
    }
    ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 55796
//No matter what happens in your life, believe in yourself.
#include<bits/stdc++.h>
using namespace std;
#define int long long 

const int mod=1e9+7;
const int inf=-1;
const int sz=1e5+2;

#define pi acos(-1)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define gap ' '
#define lb lower_bound
#define ub upper_bound
#define SIN(x) sin(x * pi / 180.0)
#define COS(x) cos(x * pi / 180.0)
#define popcnt(x) __builtin_popcount(x)
#define clr(x) memset(x,0,sizeof(x))
#define all(x) sort(x.begin(),x.end())
#define rall(x) reverse(x.begin(),x.end())
#define dbg puts("finding wrong")
#define case(x,y) printf("Case %lld: %lld\n",++x,y)
#define fastio ios::sync_with_stdio(false);cin.tie(0)

vector<int>adj[sz];
int vis[sz];

void bfs(int s)
{
    queue<int>q;

    q.push(s);
    vis[s]=1;

    while(!q.empty())
    {
        int u=q.front();
        q.pop();

        for(int i=0; i<(int)adj[u].size(); i++)
        {
            int v=adj[u][i];
            if(vis[v]==0)
            {
                vis[v]=1;
                q.push(v);
            }
        }
    }
}
void add(int u, int v)
{
    adj[u].pb(v);
    adj[v].pb(u);
}

signed main()
{
    int n, m, i, u, v;
    cin>>n>>m;
    for(i=1; i<=n; i++)vis[i]=0;
    for(i=0; i<m; i++)
    {
        cin>>u>>v;
        add(u,v);
    }
    int cnt=0;
    for(i=1; i<=n; i++)
    {
        if(!vis[i])
        {
            bfs(i);
            cnt++;
        }
    }
    cout<<cnt-1<<endl;
}


Measured memory_bytes: 10344
#include <bits/stdc++.h>
	using namespace std;
	int main() { 
	    
	    int a,b;
	    cin >> a >> b;

	    while(a && b){
	    	for(int i=0; i<a ;i++){
	    	for(int j=0 ;j <b;j++){
	    		if(i%2 ==0){
	    			if(j%2==0){
	    				cout << "#";
	    			}
	    			else{
	    				cout << ".";
	    			}
	    		}
	    		else{
	    			if(j%2 == 1){
	    				cout << "#";
	    			}
	    			else{
	    				cout << ".";
	    			}
	    		}

	    	}
	    	cout << endl;
	    	}
	    	cout << endl;
	    	cin >> a >> b;	
	    }
	    


	    return 0;
	}


Measured memory_bytes: 3088
h,w = map(int, input().split())
ar = []
for _ in range(h):
  ar.append(list(input()))

for i in range(h):
  for j in range(w):
    if ar[i][j] == '#':
      continue
    
    bomb = 0
    if i > 0:
      if j > 0 and ar[i-1][j-1] == '#':
        bomb += 1
      if ar[i-1][j] == '#':
        bomb += 1
      if j+1 < w and ar[i-1][j+1] == '#':
        bomb += 1
    if j > 0 and ar[i][j-1] == '#':
      bomb += 1
    if j+1 < w and ar[i][j+1] == '#':
      bomb += 1
    if i+1 < h:
      if j > 0 and ar[i+1][j-1] == '#':
        bomb += 1
      if ar[i+1][j] == '#':
        bomb += 1
      if j+1 < w and ar[i+1][j+1] == '#':
        bomb += 1
    ar[i][j] = str(bomb)

for i in range(h):
  print("".join(ar[i]))

Measured memory_bytes: 3188
//shan61916
#include <bits/stdc++.h>
    using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n" 
typedef long long ll;
typedef unsigned long long ull ;
typedef double dll ;
 
int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll a, b, c, d;
  cin >> a >> b >> c >> d ;
  if(c == 1 or d == 1) {
    cout << 0;
    return 0;
  }
  ll gc = c*d/ __gcd(c, d);
  ll com = 0;
  ll x = a/gc;
  if(gc*x < a) x++;
  ll y = b/gc ;
  com = (y - x) ;
  ll o = 0, t = 0;
  x = a/c;
  if(c*x < a) x++;
  y = b/c ;
  o = (y - x) ;
  // if(x != 0)o++;
  x = a/d;
  if(d*x < a) x++;
  y = b/d ;
  t = (y - x) ;
  cout << abs((b - a ) - (o + t - com)) ;
  return 0;
} //good night.

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

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

using namespace std;

char tmp[200];

int main(){
  int n,m;
  while( cin >> n >> m, n|m ){
    rep(i,n) tmp[i] = '#';
    rep(_,m){
      char c;
      cin >> c;
      if( c == 'A' ){
        rep(i,n) if( tmp[i] == '#' ) {
          tmp[i] = c;
          break;
        }
      } else if( c == 'B' ) {
        bool ok = false;
        for(int i=n-1;i>=0;i--) if( tmp[i] == '#' ) {
          int res = 0;
          if( 0 <= i-1 ) res += (tmp[i-1]=='A');
          if( i+1 < n  ) res += (tmp[i+1]=='A');
          if( res ) continue;
          tmp[i] = c;
          ok = true;
          break;
        }
        if( !ok ) {
          rep(i,n) if( tmp[i] == '#' ) {
            tmp[i] = c;
            break;
          }
        }
      } else if( c == 'C' ) {
        bool failed = false;
        rep(i,n) if(tmp[i]!='#') {
          failed = true;
          break;
        }
        if( !failed ) {
          tmp[n/2] = c;
        } else {
          rep(i,n) if( tmp[i] != '#' ){
            if( i+1 < n && tmp[i+1] == '#' ){
              tmp[i+1] = c;
              break;
            }
            if( 0 <= i-1 && tmp[i-1] == '#' ){
              tmp[i-1] = c;
              break;
            }
          }
        }
      } else {
        bool flag = true;
        rep(i,n) if( tmp[i] != '#' ) {
          flag = false;
          break;
        }
        if( flag ){
          tmp[0] = c;
        } else {
          int pos = -1, maxi = -1;
          rep(i,n)if(tmp[i]=='#'){
            int cost = 0, x = i;          
            while( 0 <= x-1 ) {
              x--;
              if( tmp[x] != '#' ) break;
              cost++;
            }
            if( x == 0 && tmp[x] == '#' ) cost = 200;
            int cost2 = 0;
            x = i;
            while( x+1 < n ){
              x++;
              if( tmp[x] != '#' ) break;
              cost2++;
            }

            if( x == n-1 && tmp[x] == '#' ) cost2 = 200;
            cost = min(cost,cost2);
            if( cost > maxi ){
              maxi = cost;
              pos = i;
            }
          }
          assert( pos != -1 );
          tmp[pos] = c;
        }
      }
    }
    rep(i,n) cout << tmp[i]; cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
main = do
    [_,x] <- ((fmap read . words) <$> getLine) :: IO [Int]
    xs <- (fmap (abs . subtract x . read) . words) <$> getLine
    print $ gcdL xs

gcdL :: [Int] -> Int
gcdL [x]    = x
gcdL (x:xs) = gcd x (gcdL xs) 

Measured memory_bytes: 36220
// Tazoe

#include <iostream>
using namespace std;

int main()
{
	int W[10];
	for(int i=0; i<10; i++){
		cin >> W[i];
	}

	int K[10];
	for(int i=0; i<10; i++){
		cin >> K[i];
	}

	for(int i=0; i<9; i++){
		for(int j=i+1; j<10; j++){
			if(W[i]<W[j]){
				int tmp = W[i];
				W[i] = W[j];
				W[j] = tmp;
			}
		}
	}

	for(int i=0; i<9; i++){
		for(int j=i+1; j<10; j++){
			if(K[i]<K[j]){
				int tmp = K[i];
				K[i] = K[j];
				K[j] = tmp;
			}
		}
	}

	cout << W[0]+W[1]+W[2] << ' ' << K[0]+K[1]+K[2] << '\n';

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

typedef long long lint;

int main(){
    int N;
    cin >> N;
    lint *a;
    a=new lint[3*N];
    for(int i=0;i<3*N;i++) cin >> a[i];

    lint *amax,*bmin;
    amax=new lint[N+1];
    bmin=new lint[N+1];

    priority_queue<lint> qa,qb;
    lint suma=0,sumb=0;
    for(int i=0;i<N;i++){
        qa.push(-a[i]);
        suma+=a[i];
    }
    for(int i=2*N;i<3*N;i++){
        qb.push(a[i]);
        sumb+=a[i];
    }
    amax[0]=suma;
    bmin[N]=sumb;

    for(int s=N;s<2*N;s++){
        lint q=qa.top();
        if(-q<a[s]){
            qa.pop();
            suma=suma+a[s]+q;
            qa.push(-a[s]);
        }
        amax[s-N+1]=suma;

        q=qb.top();
        if(q>a[3*N-s-1]){
            qb.pop();
            sumb=sumb+a[3*N-s-1]-q;
            qb.push(a[3*N-s-1]);
        }
        bmin[2*N-s-1]=sumb;
    }

    lint max=(-1000000000000000);
    for(int i=0;i<=N;i++){
        if(max<amax[i]-bmin[i]) max=amax[i]-bmin[i];
    }

    cout << max << endl;

    delete[] a,amax,bmin;
    return 0;
}

Measured memory_bytes: 5876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

pair<int, int> E[200001];
int H[100001], P[100001], PM[100001], Pm[100001];
bool V[100001], V2[100001];
int kotae[100001];
bool OK = true;
pair<int, int> sagasu(int A) {
	if (V[A]) return mp((int)1e7, 0);
	V[A] = true;
	PM[A] = 5e6;
	Pm[A] = -5e6;
	bool odd = false;
	bool even = false;
	if (P[A] != -1) {
		PM[A] = P[A];
		Pm[A] = P[A];
		if (P[A] & 1) odd = true;
		else even = true;
	}
	for (int i = H[A]; i; i = E[i].second) {
		auto p = sagasu(E[i].first);
		if (p != mp((int)1e7, 0)) {
			if (p.first < 4e6) {
				if (p.first & 1) odd = true;
				else even = true;
			}
			PM[A] = min(PM[A], p.first);
			Pm[A] = max(Pm[A], p.second);
		}
	}
	if (odd && even) OK = false;
	if (PM[A] < Pm[A]) OK = false;
	return mp(PM[A] + 1, Pm[A] - 1);
}
void sagasu2(int A, int M) {
	if (V2[A]) return;
	V2[A] = true;
	if (M + 1 <= PM[A] && M + 1 >= Pm[A]) kotae[A] = M + 1;
	else kotae[A] = M - 1;
	for (int i = H[A]; i; i = E[i].second) {
		sagasu2(E[i].first, kotae[A]);
	}
}

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


	int N = getint();
	for (int i = 1; i < 2 * (N - 1); i += 2) {
		int a = getint(), b = getint();
		E[i] = mp(a, H[b]);
		H[b] = i;
		E[i + 1] = mp(b, H[a]);
		H[a] = i + 1;
	}
	int K = getint();
	int v, p;
	rep1(i, N) P[i] = -1;
	rep(i, K) {
		v = getint();
		p = getint();
		P[v] = p;
	}

	sagasu(v);

	if (OK) {
		sagasu2(v, p - 1);
		*di++ = 'Y';
		*di++ = 'e';
		*di++ = 's';
		*di++ = '\n';
		rep1(i, N) putint(kotae[i]);
		fwrite_unlocked(dn, di - dn, 1, stdout);
	}
	else co("No");

	Would you please return 0;
}

Measured memory_bytes: 11776
#include <iostream>
#include <vector>
#include <string>

using namespace std;

const vector<string> keys = {
    "",
    ".,!? ",
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz"
};

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

    while (C-- > 0) {
        string s;
        cin >> s;

        int pos = 0;
        string res = "";
        for (int i = 0; i < s.length() - 1; i++) {
            int k = stoi(s.substr(i, 1));
            if (k == 0) {

            } else if (s[i] == s[i + 1]) {
                pos++;
            } else {
                res += keys[k].substr(pos % keys[k].length(), 1);
                pos = 0;
            }
        }

        cout << res << endl;
    }
}

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

using namespace std;

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

    vector<int> value(n), cost(n);

    for (auto &x : value)
        cin >> x;

    for (int &x : cost)
        cin >> x;

    int answer = 0;
    int sum = 0;

    for (int i = 0; i < n; i++)
    {
        if (cost[i] < value[i])
            sum += value[i] - cost[i];

        answer = max(answer, sum);
    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 3640
# operator.add(a, b)
# operator.mul(a, b)


class SegmentTree():
    """
    update, get を提供するSegmentTree

    Attributes
    ----------
    __n : int
        葉の数。2 ^ i - 1
    __dot :
        Segment function
    __e: int
        単位元
    __node: list
        Segment Tree
    """
    def __init__(self, A, dot, e):
        """
        Parameters
        ----------
        A : list
            対象の配列
        dot :
            Segment function
        e : int
            単位元
        """
        n = 2 ** (len(A) - 1).bit_length()
        self.__n = n
        self.__dot = dot
        self.__e = e
        self.__node = [e] * (2 * n - 1)
        for i in range(len(A)):
            self.__node[i + n - 1] = A[i]
        for i in range(n - 2, -1, -1):
            self.__node[i] = self.__dot(self.__node[2 * i + 1], self.__node[2 * i + 2])
    
    def update(self, i, c):
        i += self.__n - 1
        node = self.__node
        node[i] = c
        while i > 0:
            i = (i - 1) // 2
            node[i] = self.__dot(node[2 * i + 1], node[2 * i + 2])

    def get(self, l, r):
        vl, vr = self.__e, self.__e
        l += self.__n - 1
        r += self.__n - 1
        while (l < r):
            if (l % 2 == 0):
                vl = self.__dot(vl, self.__node[l])
                l += 1
            l = (l - 1) // 2
            if (r % 2 == 0):
                r -= 1
                vr = self.__dot(vr, self.__node[r])
            r = (r - 1) // 2
        return self.__dot(vl, vr)
    

# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A
def AOJ_DSL_2_A():
    n, q = map(int, input().split())
    e = (1 << 31) - 1
    A = [e] * n
    seg = SegmentTree(A, min, e)

    for i in range(q):
        t, x, y = map(int, input().split())
        if t == 0:
            seg.update(x, y)
        else:
            print(seg.get(x, y + 1))


# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B
def AOJ_DSL_2_B():
    from operator import add
    import sys
    n, q = map(int, input().split())
    e = 0
    A = [e] * n
    seg = SegmentTree(A, add, e)
    
    query = sys.stdin.readlines()
    for i in range(q):
        t, x, y = map(int, query[i].split())
        x -= 1
        if t == 0:
            A[x] += y
            seg.update(x, A[x])
        else:
            y -= 1
            print(seg.get(x, y + 1))


def ABC125_C():
    from fractions import gcd
    N = int(input())
    A = list(map(int, input().split()))
    
    seg = SegmentTree(A, gcd, 0)
    ans = 0
    for i in range(N):
        ans = max(ans, gcd(seg.get(0, i), seg.get(i + 1, N)))
    print(ans)


# AOJ_DSL_2_B()
ABC125_C()


Measured memory_bytes: 16128
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
#define rep0(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define rep1(kk, l1, l2)for(ll kk = l1; kk <= l2; kk++)
#define foritr(itr, A) for(set<ll>::iterator itr = A.begin(); itr != A.end(); itr++)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define cr(x) cerr << #x << " = " << x << "\n";
#define crA(x, A) cerr << #x << " = " << A[x] << "\n";
#define spacing cout << " ";
#define mmst(x, v) memset((x), v, sizeof ((x)));
#define bg(ms) (*ms.begin())
#define ed(ms) (*prev(ms.end(), 1))
#define addedge(a, b, c, v) v[(a)].pb(pi((b), (c))); v[(b)].pb(pi((a), (c)))
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, h, w, co_h, co_w, f=1;
pi colour[MAXN];
ll grid[106][106];
int main()
{
	cin >> h >> w >> n;
	FOR(i,0,n)
	{
		cin >> colour[i].f; colour[i].s = i;
	}
	mmst(grid, -1);
	sort(colour, colour+n, greater<pi>());
	for(ll i = 0; i < n; i++)
	{
		ll ind = colour[i].s;
		while(colour[i].f --)
		{
			grid[co_h][co_w] = ind;
          	co_h += f;
			if(co_h >= h || co_h < 0) { co_w++; f = (f == 1 ? -1 : 1); co_h += f; }
		}
	}
	FOR(i,0,h)
	{
		FOR(j,0,w)
		{
          if(grid[i][j] == -1)assert(0);
			cout << grid[i][j] + 1 << " ";
		}
		cout << "\n";
	}
}


Measured memory_bytes: 512
from heapq import*
def solve(x):
    s,*h=0,
    for i in range(len(x),0,-1):
        while x and x[-1][0]>=i:
            k,l,r=x.pop()
            heappush(h,(r-l,l,r))
        if h:s+=heappop(h)[1]
    return s+sum(r for _,_,r in x+h)
for _ in range(int(input())):
    n=int(input())
    x,y=[],[]
    for _ in range(n):
        k,l,r=map(int,input().split())
        if l>r:x+=(k,l,r),
        else:y+=(n-k,r,l),
    print(solve(sorted(x))+solve(sorted(y)))

Measured memory_bytes: 121068
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

int main()
{
	int n, c = 0;
	cin >> n;
	vector<int> a(n);

	for (int &x: a)
		cin >> x;

	for (auto i = a.begin(), e = a.end() - 1; i != e; i++)
		for (auto j = e; j != i; j--)
			if (*j < *(j - 1)) {
				swap(*j, *(j - 1));
				c++;
			}

	for (int &x: a)
		cout << (&x != &a[0] ? " " : "") << x;

	cout << endl << c << endl;
}


Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <map>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
main()
{
    int a,b;
    cin>>a>>b;
    if(b==1)cout<<0<<endl;
    else 
    {
        int ret=1;
        int c=a-1;
        while(a<b){ret++;a+=c;}
        cout<<ret<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=2*100000+10;

ll X;

int main(){
  cin>>X;
  ll ans=1;
  for(ll i=2;i<=ceil(sqrt(X));i++){
    ll tmp=i;
    for(ll j=0;tmp<=X;j++){
      if(tmp<=X)ans=max(tmp,ans);
      tmp*=i;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
V = list(map(int, input().split()))

v_even = defaultdict(int)
v_odd = defaultdict(int)

for k in range(n//2):
  v_even[V[2*k]] += 1
  v_odd[V[2*k + 1]] += 1

even_max = 0
even_max2 = 0
for k, v in v_even.items():
  if v > even_max:
    even_max2 = even_max
    even_max = v
    even_num = k
  else:
    even_max2 = max(even_max2, v)

odd_max = 0
odd_max2 = 0
for k, v in v_odd.items():
  if v > odd_max:
    odd_max2 = odd_max
    odd_max = v
    odd_num = k
  else:
    odd_max2 = max(odd_max2, v)

if  even_num != odd_num:
  print(n - even_max - odd_max)
else:
  print(n - max(even_max + odd_max2, even_max2 + odd_max))

Measured memory_bytes: 17312
n,W=map(int, input().split())
w=[0]*n
v=[0]*n
for i in range(n):
    x,y=map(int, input().split())
    w[i]=x
    v[i]=y
dp=[[0 for i in range(W+1)] for j in range(n+1)]
for i in range(n):
    for j in range(W+1):
        if j<w[i]:
            dp[i+1][j]=dp[i][j]
        else:
            dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i])
print(dp[n][W])
#print(dp)


Measured memory_bytes: 171528
#!/usr/bin/python3
#coding: utf-8

A, B, C, X, Y = (int(x) for x in input().split())

ret = 0
if A + B > C * 2:
    m = min(X, Y)
    X -= m
    Y -= m
    ret += m * C * 2

if X > 0:
    if A > C * 2:
        ret += X * C * 2
    else:
        ret += X * A

if Y > 0:
    if B > C * 2:
        ret += Y * C * 2
    else:
        ret += Y * B

print(ret)


Measured memory_bytes: 9016
// 2_abc131_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, l;
    cin >> n >> l;

    int ans = 0;
    ll m = INF;
    rep1(i, n){
        if(abs(m) > abs(l + i - 1)){
            m = l + i - 1;
        }
        ans += l + i - 1;
    }
    cout << ans - m << endl;
    return 0;
}


Measured memory_bytes: 256
MOD = 10**9+7

N = int(input())
count = [0] * 3
ans = 1

A = [int(x) for x in input().split()]

for i in range(N):
    sames = 0
    for j in range(3):
        if A[i] == count[j]:
            sames += 1

    if sames == 0:
        ans = 0
        break

    ans *= sames
    ans %= MOD

    for j in range(3):
        if A[i] == count[j]:
            count[j] += 1
            break
print(ans)



Measured memory_bytes: 52952
#!/usr/bin/env python
# -*- coding: utf-8 -*-

P, Q, R = map(int, input().split())

# 最小の組み合わせを探す
min_hour = 0

h1 = P + Q
h2 = Q + R
h3 = R + P

ans = min([h1, h2, h3])
print(ans)


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

int main() {
    int N;
    cin >> N;
    int ac=0, wa=0, tle=0, re=0;
    string s;
    for (int i = 0; i < N; i++) {
        cin >> s;
        if (s == "AC") ac++;
        else if (s == "WA") wa++;
        else if (s == "TLE") tle++;
        else re++;
    }
cout << "AC x " << ac << endl;
cout << "WA x " << wa << endl;
cout << "TLE x " << tle << endl;
cout << "RE x " << re << endl;
}

Measured memory_bytes: 3596
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int i = 0;
		while((a - 1) * i + 1 < b) {
			//if(a * i >= b) break;
			//else 
			i++;
		}
		System.out.println(i);
	}

}

Measured memory_bytes: 22740
A, B, C, D = map(int, input().split())
A -= 1
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd(a, b)

lcm = lcm(C, D)
# A
Ax = A // lcm
Ay = A // C
Az = A // D
AA = Ay + Az -Ax
a = A - AA
# B
Bx = B // lcm
By = B // C
Bz = B // D
BB = By + Bz -Bx
b = B - BB

print(b - a)

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

int main() {
    int n;
    cin>>n;
    printf("%d:%d:%d\n", n/3600, (n%3600)/60, n%60);
    
    return 0;
    
   
}



Measured memory_bytes: 3228
// https://atcoder.jp/contests/abc134/tasks/abc134_c

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define print(x) cout << x << endl;

int main() {
    int N; cin >> N;
    // int A[N]; rep(i, N) cin >> A[i];
    // vector<int> B(A, A+N);
    vector<int> A(N); rep(i, N) cin >> A[i];
    vector<int> B(N); rep(i, N) B[i] = A[i];

    sort(B.rbegin(), B.rend());
    // reverse(B.begin(), B.end());

    // rep(i, B.size()) cout << B[i] << " ";
    // cout << endl;

    rep (i, N) {
        if (A[i] == B[0]) {
            cout << B[1];
        } else {
            cout << B[0];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=1; i<(int)(n); i++)
int D, c[27], s[366][27];

int saga(int d, vector<int> &L){
  int S=0;
  REP(i, 27){ S+=c[i]*(d-L[i]); }
  return S;
}

int main(){
  cin >> D; D++;
  REP(i, 27){ cin >> c[i]; }
  REP(i, D){ REP(j, 27){ cin >> s[i][j]; } }
  int t[D]={}; vector<int> last(27, 0);

  REP(i, D){
    int a=1, S=-1000000, u=0;
    REP(j, 27){
      u=s[i][j]; u-=saga(i, last); u+=c[j]*last[j];
      if(S<=u){ a=j; S=u; }
    }
    t[i]=a; last[a]=i;
  }
  REP(i, D){ cout << t[i] << "\n"; }
}


Measured memory_bytes: 3668
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
  ll n,m,t,i,res=0;
  cin >> n;
  m=(ll)sqrt(n);
  for(i=m;i>0;i--)
    if(n%i==0){
      t=n/i;
      while(t>0){
        t/=10;
        res++;
      }
      cout << res << endl;
      return 0;
    }
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
typedef tree<string,null_type,less<string>,rb_tree_tag,tree_order_statistics_node_update> indexed_set2;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

int main()
{
    ll x;
    cin>>x;
    ll p = (x - 400)/200;
    cout<<8-p<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, h[125252];
	cin>>n;
	REP(i, n){
		cin>>h[i];
	}
	int ans=0, tmp=0;
	FORR(i, 0, n-1){
		if(h[i]>=h[i+1]){
			++tmp;
		}
		else{
			CHMAX(ans, tmp);
			tmp=0;
		}
	}
	CHMAX(ans, tmp);
	cout<<ans<<'\n';
	return 0;
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n;
    cin >> n;
    vector<ll> f(n, 0);
    REP(i, n){
        ll ai;
        cin >> ai;
        f.at(--ai)++;
    }
    sort(f.begin(), f.end());

    vector<ll> cs(n, 0);
    cs.at(0) = f.at(0);
    for(ll i = 1; i < n; ++i){
        cs.at(i) = cs.at(i - 1) + f.at(i);
    }

    vector<ll> ans(n, 0);
    for(ll k = 1; k <= n; ++k){
        ll lo = 0, hi = n / k + 1;
        while(lo < hi){
            const ll x = (lo + hi + 1) / 2;
            const ll idx = upper_bound(f.begin(), f.end(), x) - f.begin();
            ll sum = x * (f.size() - idx);
            if(idx > 0){
                sum += cs.at(idx - 1);
            }
            if(sum >= k * x){
                lo = x;
            }else{
                hi = x - 1;
            }
        }
        ans.at(k - 1) = lo;
    }
    REP(i, n){
        cout << ans.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 9472
S = input()
R = []
L = []
cnt = 1
n = 'R'
for i in range(len(S)-1):
    if(S[i] != S[i+1]):
        if(n == 'R'):
            R.append(cnt)
            n = 'L'
        else:
            L.append(cnt)
            n ='R'
        cnt = 1
    else:
        cnt += 1

if(n == 'R'):
    R.append(cnt)
    n = 'L'
else:
    L.append(cnt)
    n ='R'

ans = []

for i in range(len(R)):
    for j in range(R[i]-1):
        ans.append(0)
    total = R[i] + L[i]
    if(total % 2 == 0):
        ans.append(total // 2)
        ans.append(total // 2)
    else:
        if(R[i] > L[i]):
            if((total // 2) % 2 == 1): # 3 7
                if(abs(R[i] - L[i])// 2 % 2 == 0):# RRL
                    ans.append(total // 2)
                    ans.append(total // 2 + 1)
                else:
                    ans.append(total // 2 + 1)
                    ans.append(total // 2)
            else:
                if (abs(R[i] - L[i])//2 % 2 == 0):
                    ans.append(total // 2 + 1)
                    ans.append(total // 2)
                else:
                    ans.append(total // 2)
                    ans.append(total // 2 + 1)


        else:
            if ((total // 2) % 2 == 1):
                if (abs(R[i] - L[i])//2 % 2 == 0):
                    ans.append(total // 2 + 1)
                    ans.append(total // 2)
                else:
                    ans.append(total // 2)
                    ans.append(total // 2 + 1)
            else:
                if (abs(R[i] - L[i])//2 % 2 == 0):
                    ans.append(total // 2)
                    ans.append(total // 2 + 1)
                else:
                    ans.append(total // 2 + 1)
                    ans.append(total // 2)

    for j in range(L[i]-1):
        ans.append(0)

ansText = ""

for i in range(len(ans)):
    ansText += str(ans[i])
    if(i != len(ans)-1):
        ansText += " "

print(ansText)


Measured memory_bytes: 5680
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=100000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
//void swap(ll a,ll b){
//	ll d;
//	d=a;
//	a=b;
//	b=d;
//	return;
//}
ll mypow(ll x,int m){
	if(m==0)return 1;
	if(m%2==0){
		int x2=mypow(x,m/2);
		return x2*x2;
	}else{
		int x2=mypow(x,m/2);
		return x2*x2*x;
	}
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
//    	cout<<b<<endl;
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll dp[301][301][301]={};
ll n,k;
ll h[303];
P hd[303];
int d[303];
ll reg(ll m,ll hi,ll l){
	if(dp[m][hi][l]!=-1)return dp[m][hi][l];
	if(m==n)return 0;
	ll res=INF,myhi=hd[hi].first;
	if(hi==0)myhi=0;
	res=min(res,reg(m+1,d[m+1],l)+max(0LL,h[m+1]-myhi));
	if(l<k){
		res=min(res,reg(m+1,hi,l+1));
	}
//	cout<<m<<" "<<myhi<<" "<<l<<" "<<res<<endl;
	return dp[m][hi][l]=res;

}

int main() {
	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	h[0]=0;
	hd[0]=P(1,0);
	rep(i,1,n+1){
		cin>>h[i];
		hd[i]=P(h[i],i);
	}
	sort(hd,hd+n+1);
	rep(i,0,n+1){
		d[hd[i].second]=i;
	}
	cout<<reg(0,0,0)<<endl;
	return 0;
}


Measured memory_bytes: 213376
#include <stdio.h>
#include <limits.h>

long long min(long long a, long long b){
    return (a < b ? a : b);
}

int main(){
	long long n, ans = LONG_MAX;
	scanf("%lld", &n);
	for(long long i = 1; i * i <= n; i++){
		if(n % i == 0){
            ans = min(ans, i + n / i - 2);
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;
using P = pair<int,int>;
//int dy[4] = {-1,0,1,0};
//int dx[4] = {0,-1,0,1};


int main()
{
    int M,N,X;
    cin >> M >> N >> X;
    vector<vector<int>> data(M,vector<int>(N));
    vector<int> cost(M);
    
    for(int i=0;i<M;i++)
    {
        cin >> cost[i];
        for(int j=0;j<N;j++)
        {
            cin >> data[i][j];
        }
    }
    
    int ans = INT_MAX;
    
    for(int bit = 0;bit < (1<<M);bit++)
    {
        int money = 0;
        vector<int> temp(N,0);
        for(int i=0;i<M;i++)
        {
            if((1<<i) & bit)
            {
                money += cost[i];
                for(int j=0;j<N;j++)
                {
                    temp[j] += data[i][j];
                }
            }
            
        }
        bool ok = true;
        for(int j=0;j<N;j++)
        {
            if(temp[j]< X)
            {
                ok  =false;
                break;
            }
        }
        if(ok)
        {
            ans = min(ans,money);
        }
    }
    
    if(ans == INT_MAX) ans = -1;
    cout << ans << endl;
    return 0;
}


/*
int main()
{
    int N;
    cin >> N;
    
 
 int ans;
 cout << ans << endl;
    return 0;
}
*/

Measured memory_bytes: 3628
#include<iostream>
#include<fstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<ctime>
#include<random>
#include<algorithm>
#define ll long long
using namespace std;
ll s;
ll a[3000000];
bool flag[8000000];

ll myf(ll a)
{
    if (a&1) return (3*a+1);
    else return (a/2);
}

int main()
{
    cin>>s;
    a[1]=s;
    flag[a[1]]=1;
    for (int i=2; i<=2000000; ++i) 
    {
        a[i]=myf(a[i-1]);
        if (flag[a[i]])
        {
            cout<<i<<endl;
            return 0;
        }
        flag[a[i]]=1;
    }
    return 0;
}


Measured memory_bytes: 2304
fun main(args: Array<String>){
    
    val n = readLine()!!.toInt()
    val A = Array(n) { readLine()!!.toLong() }

    val nums = mutableMapOf<Long,Int>()
    for (a in A){
        if (nums.containsKey(a)){
            val tmp: Int = nums.get(a)!!
            nums[a] = tmp + 1
        } else {
            nums[a] = 1
        }
    }

    var ans = 0
    for ( (k,v) in nums ) {
        if (v % 2 == 1) { ans++ }
    }

    println(ans)
}

Measured memory_bytes: 45976
import numpy as np
M=int(input())
D=0
C=0
for i in range(M):
  d,c=map(int,input().split())
  D+=c*d
  C+=c
# 桁数を減らす処理はC-1回行われる

# 桁数を減らさない処理は総和から9減る。(D-1)//9回行われる。
print((C-1)+(D-1)//9)

Measured memory_bytes: 12504
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int n; cin >> n;
	cout << n*(n+1)/2;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            var input = Console.ReadLine().Split(' ');
            int count = int.Parse(input[0]);
            int count2 = int.Parse(input[1]);
            Console.WriteLine("{0} {1} {2:f5}", count / count2, count % count2, (double)count / count2);
        }
    }
}



Measured memory_bytes: 17952