akhauriyash/Code-Regression huggingface dataset:
#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;
    vector<int> qu(n);
    rep(i,n) {
        int a;
        cin >> a;
        a--;
        qu[a] = i+1;
    }
    rep(i,n) cout << qu[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1152
#![allow(non_snake_case)]
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let N:usize = sc.read();
    // let mut A:Vec<usize> = vec![];
    // let mut B:Vec<usize> = vec![];
    let mut ans:usize = 1_000_000_000;
//    let mut same = true;
    let mut sum:usize = 0;
    for _ in 0..N{
        let a:usize = sc.read();
        let b:usize = sc.read();
        // if a ! b{
        //     same = false;
        // }
        sum += b;
        if a > b{
            if b < ans{
                ans = b;
            }
        }
       // A.push(a);
       // B.push(b);
    }
    if ans == 1_000_000_000{
        println!("0");
    }else{
        println!("{}", sum - ans);
    }



}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}




Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <algorithm>

int h, w, k, s[10][1005], f[1005];
char t[1005];

bool check(int mask, int l, int r)
{
	for (int i = 0, c = 0; i < h; ++i)
	{
		c += s[i][r] - s[i][l];
		if (c > k)
			return false;
		if (mask >> i & 1)
			c = 0;
	}
	return true;
}

int solve(int mask)
{
	for (int i = 1; i <= w; ++i)
		f[i] = 200000;
	for (int i = 0; i < w; ++i)
	{
		int j = i;
		for (int step = 512; step; step >>= 1)
			if (j + step <= w && check(mask, i, j + step))
				j += step;
		if (j > i)
			f[j] = std::min(f[j], f[i] + 1);
	}
	return f[w] - 1;
}

int main()
{
	scanf("%d%d%d", &h, &w, &k);
	for (int i = 0; i < h; ++i)
	{
		scanf("%s", t + 1);
		for (int j = 1; j <= w; ++j)
			s[i][j] = s[i][j - 1] + t[j] - '0';
	}
	int ans = 1000000;
	for (int mask = 0; mask < 1 << h - 1; ++mask)
		ans = std::min(ans, solve(mask) + __builtin_popcount(mask));
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

int dp[45][405][405];
int a[40], b[40], c[40];
int suma, sumb;

int main() {
    int n, A, B;
    scanf("%d %d %d", &n, &A, &B);
    memset(dp, 0, sizeof dp);
    suma = sumb = 0;
    for(int i = 1; i <= n; i++) {
        scanf("%d %d %d", &a[i], &b[i], &c[i]);
        suma += a[i];
        sumb += b[i];
        dp[i][a[i]][b[i]] = c[i];
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= suma; j++) {
            for(int k = 1; k <= sumb; k++) {
                if(j >= a[i] && k >= b[i]) {
                    if(dp[i - 1][j - a[i]][k - b[i]] != 0 && ((dp[i - 1][j][k] > dp[i - 1][j - a[i]][k - b[i]] + c[i]) || dp[i - 1][j][k] == 0))
                        dp[i][j][k] = dp[i - 1][j - a[i]][k - b[i]] + c[i];
                    else dp[i][j][k] = dp[i - 1][j][k];
                }
                else dp[i][j][k] = dp[i - 1][j][k];
            }
        }
        if((dp[i][a[i]][b[i]] > c[i] && dp[i][a[i]][b[i]] != 0) || dp[i][a[i]][b[i]] == 0) dp[i][a[i]][b[i]] = c[i];
    }
    int ans = 5000;
/*
    for(int i = 1; i <= 3; i++) {
        for(int j = 1; j <= 6; j++) {
            for(int k = 1; k <= 6; k++) {
                printf("%d ", dp[i][j][k]);
            }
            printf("\n");
        }
        printf("\n");
    }
*/
    for(int i = 1; ; i++) {
        if(A * i > suma || B * i > sumb) break;
        if(dp[n][A * i][B * i] < ans && dp[n][A * i][B * i] != 0) ans = dp[n][A * i][B * i];
    }
    if(ans == 5000) printf("-1\n");
    else printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 29056
#include<iostream>
using namespace std;
int n,a[1000001],x,ans;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        if(x>n)
        {
            ans++;
        }
        else
        {
            a[x]++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]!=0)
        {
            if(a[i]<i)
            {
                ans+=a[i];
            }
            else
            {
             ans+=a[i]-i;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険                                   // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////
bool dp[80][80][80*160*2];

int main(){
	int h, w; cin >> h >> w;
	int a[h][w], b[h][w];
	rep(i,0,h) rep(j,0,w) cin >> a[i][j];
	rep(i,0,h) rep(j,0,w) cin >> b[i][j];

	int geta = 80*160;
	rep(i,0,h)
		rep(j,0,w)
			rep(k,-12800, 12800)
				dp[i][j][k+geta] = false;
	dp[0][0][a[0][0] - b[0][0] + geta] = true;
	dp[0][0][b[0][0] - a[0][0] + geta] = true;

	rep(i,0,h){
		rep(j,0,w){
			rep(k,-12800, 12800){
				if(i-1 >= 0 && k + a[i][j] - b[i][j] < 12800 && -12800 <= k + a[i][j] - b[i][j]){
					dp[i][j][k + a[i][j] - b[i][j] + geta] |= dp[i-1][j][k + geta];
					dp[i][j][k - a[i][j] + b[i][j] + geta] |= dp[i-1][j][k + geta];
				}
				if(j-1 >= 0 && k + a[i] - b[i] < 12800 && -12800 <= k + a[i] - b[i]){
					dp[i][j][k + a[i][j] - b[i][j] + geta] |= dp[i][j-1][k + geta];
					dp[i][j][k - a[i][j] + b[i][j] + geta] |= dp[i][j-1][k + geta];
				}
			}
		}
	}
	rep(k, 0, 12800){
		if(dp[h-1][w-1][k + geta]){
			cout << abs(k) << endl;
			return 0;
		}else if(dp[h-1][w-1][-k + geta]){
			cout << abs(k) << endl;
			return 0;
		}
	}

}

Measured memory_bytes: 160256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int a[5];
	int ans;
	rep(i,5){
		cin>>a[i];
		if(a[i]==0){
			ans=i+1;
		}
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,s=0;
	cin>>n;
	if(n%1000==0) cout<<'0';
	else
	{
       s+=n/1000+1;
       cout<<1000*s-n;
	}
	return 0;
 } 

Measured memory_bytes: 3616
#include <stdio.h>

int main(void){

  char number[1001];
  int i;
  int s;
  int num;

  while(1){
    for(i=0;i<1001;i++){
      number[i] = '0';
    }

    scanf("%s", number);
   if(*number == '0'){return 0;}
   else {
     s = 0;
     for(i=0;i<1001;i++){
       num  = number[i] - '0';
     s = s + num;
     }
   printf("%d\n", s + '0');
   }
  }
}

Measured memory_bytes: 536
#include<bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define vpii vector<pair<int,int> >
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back   
#define PB pop_back
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


void solve(){
    int n;
    cin>>n;
    n%=1000;
    if(n != 0)
    cout<<(1000-n);
    else cout<<"0";
}

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


Measured memory_bytes: 3616
L[3],n,r;
M(int*a,int*b){return*a-*b;}
main(){
	for(;scanf("%d%d%d%d",L,L+1,L+2,&n),*L;){
		qsort(L,3,4,M);
		for(;n--;){
			scanf("%d",&r);
			puts(L[0]*L[0]+L[1]*L[1]<r*r*4?"OK":"NA");
		}
	}
	exit(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	int n,m; cin >> n >> m;
	int ans=0;
	int ma=0;
	for(int i=0;i<m;i++){
		int a,b; cin >> a >> b;
		int cnt=max(0,n-a);
		ans+=cnt;
		ma=max(ma,cnt);
	}
	cout << ans-ma << endl;
}


Measured memory_bytes: 3068
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(1 + N);
	for (int i = 1; i <= N; ++i) {
		cin >> A[i];
	}
	int cnt = 0;
	for (int i = N; i >= 1; --i) {
		for (int j = i * 2; j <= N; j += i) {
			A[i] ^= A[j];
		}
		cnt += A[i];
	}
	cout << cnt << endl;
	for (int i = 1; i <= N; ++i) {
		if (A[i] == 1) {
			cout << i << ((--cnt) == 0 ? '\n' : ' ');
		}
	}
	return 0;
}

Measured memory_bytes: 3956
n,k = map(int, input().split())
lis = [i for i in range(n+1)]
rui = [0]*(n+2)
tmp = 0
for j in range(n+1):
    tmp += lis[j]

    rui[j+1] += tmp

ans = 0
for l in range(k,n+2):
    ans += rui[n+1]-rui[n-l+1]-rui[l] +1
ans %= 1000000007
print(ans)


Measured memory_bytes: 84380
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  vector<int>vec(3);
  rep(i,3) cin >> vec[i];
  sort(vec.begin(),vec.end());
  
  if(vec[0]==5 && vec[1] == 5 && vec[2] == 7)cout << "YES" << endl;
  else cout << "NO" << endl;
 
  return 0;
}


Measured memory_bytes: 256
n = int(input())
rs = []
for i in range(n):
    rs.append(int(input()))

tempmax = rs[-1]    
rmaxs = [0]*(n-1)
rmaxs[-1] = tempmax

for i in range(n-2,0,-1):
    if rs[i] > tempmax:
        tempmax = rs[i]
    rmaxs[i-1] = tempmax

ans = rmaxs[0] - rs[0]

for i in range(1,n-1):
    if rmaxs[i] - rs[i] > ans:
        ans = rmaxs[i] - rs[i]

print(ans)



Measured memory_bytes: 15172
// package app;

import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

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

        // final String N = sc.next();
        // final int M = sc.nextInt();
        // final int N = sc.nextInt();
        final int A = sc.next().charAt(0);
        final int B = sc.next().charAt(0);
        // final int D = sc.nextInt();

        // System.out.println();
        char op = '=';
        if ( A < B) {
            op = '<';
        } else if (A > B) {
            op = '>';
        }
        System.out.println(op);

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }
}

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

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int t = a + b;
    for(int i=c; i<=7200; i+=60)
    {
        if(i%t<=a)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

using namespace std;

int main() {
    string str;
    while(cin >> str) {
        map<char,int> m;
        m['I'] = 1;
        m['V'] = 5;
        m['X'] = 10;
        m['L'] = 50;
        m['C'] = 100;
        m['D'] = 500;
        m['M'] = 1000;

        int ans = 0;
        for(int i = 0; i < str.size(); ++i) {
            char c = str[i];
            if(i+1 < str.size()) {
                char c2 = str[i+1];
                if(m[c] < m[c2]) {
                    ans += m[c2]-m[c];
                    i++;
                    continue;
                }
            }
            ans += m[c];
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

priority_queue<int, vector<int>, greater<int> > pq;

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	pq.push(a);
	pq.push(b);
	pq.push(c);
	cout<<pq.top()<<" ";
	pq.pop();
	cout<<pq.top()<<" ";
	pq.pop();
	cout<<pq.top()<<"\n";
	return 0;
}


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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;


    
int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = (N-2)*(B-A)+1;
    if(N==1){
        if(A==B) cout << 1 << endl;
        else cout << 0 << endl;
    }
    if(N!=1){
        if(A<=B)cout << ans << endl;
        else cout << 0 << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int[] array = {a, b, c};
        Arrays.sort(array);
        System.out.println(array[0] + " " + array[1] + " " + array[2]);
    }
}

Measured memory_bytes: 17348
import collections
s = list(input())
#print(s)
c = collections.Counter(s)
l = list(c.items())
l = sorted(l, key = lambda x : x[1], reverse=True)
#print(l)

h = []
tmp = l[0][1]

for i in range(len(l)):
          h.append(l[i][0])


#print(h)

ans = []

for i in range(len(h)):
    tmp = [_ for _, x in enumerate(s) if x == h[i]]
#    print(h[i])
#    print(tmp)
    lll = []
    for j in range(len(tmp)):
        if j == 0:
            lll.append(tmp[j])
        else:
            lll.append(tmp[j] - tmp[j-1] - 1)
    lll.append(len(s) - tmp[len(tmp) - 1] - 1)
    ans.append(max(lll))
#    print(lll)


#print(ans)
print(min(ans))
            
        


Measured memory_bytes: 3316
let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( *^ ) x y = (x * y) mod m

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  Printf.printf "%d\n" @@
  Array.fold_left ( +^ ) 0 @@
  Array.init 62 @@ fun d ->
    let c0, c1 =
      Array.fold_left (fun (c0, c1) a ->
        if a land (1 lsl d) = 0
        then (c0 + 1, c1)
        else (c0, c1 + 1)) (0, 0) as_ in
    c0 *^ c1 *^ ((1 lsl d) mod m)



Measured memory_bytes: 6016
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int P_i, min = 1000000;
    int N;
    int ans = 0;
    
    cin >> N;
    
    for(int i=0; i<N; i++){
        cin >> P_i;
        if(P_i <= min){
            min = P_i;
            ans++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
N,D = map(int, input().split())

X = []
ans = 0

for i in range(N):
    X.append(list(map(int, input().split())))

for i in range(N-1):
    for j in range(i+1,N):
        f = 0
        for k in range(D):
            f += (X[i][k]-X[j][k])**2
        f = f**(1/2)
        if f.is_integer():
            ans += 1

print(ans)


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

using namespace std;

int main() {
  	vector<int> a(3);
  	for (int& x : a)
      	cin >> x;
  	sort(a.begin(), a.end());
  	cout << (a[0] == 5 && a[1] == 5 && a[2] == 7 ? "YES" : "NO");
  	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			int m = Integer.parseInt(scanner.next());
			int t = Integer.parseInt(scanner.next());
			int r = Integer.parseInt(scanner.next());
			if (m == -1 && t == -1 && r == -1) break;
			System.out.println(Judge(m, t, r));
		}
		scanner.close();
	}
	public static char Judge(int m, int t, int r) {
		if (m == -1 || t == -1) return 'F';
		if (80 <= m + t) return 'A';
		if (65 <= m + t) return 'B';
		if (50 <= m + t) return 'C';
		if (30 <= m + t) return 50 <= r ? 'C': 'D';
		return 'F';
	}
}

Measured memory_bytes: 17168
#include <iostream>

using namespace std;

int main(){
    int a, b, c, k;

    cin >> a >> b >> c >> k;

    int sum;
    int lest;

    if(a <= k){
        // 1をすべて使う
        sum += a;
        k -= a;

        if(b <= k){
            // 0をすべて使う
            k -= b;

            if(k == c){
                sum += -1 * c;
            }
            else{
                sum += -1 * k;
            }
        }
        else{
            sum += 0;
        }
    }
    else{
        sum += k;
    }

    cout << sum << endl;

    return 0;

}


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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve(){
    int n, d, x;
    cin >> n >> d >> x;
    int ans = 0;
    REP(i, n) {
        int a;
        cin >> a;
        ans += ceil((double)d / a);
    }
    ans += x;
    cout << ans << "\n";
}

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


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

i = 0
ret = 0
while i < n - 1:
    ii = i
    while i < n - 1:
        if h[i] < h[i+1]:
            break
        i = i + 1
    ret = max(ret, i-ii)
    i = i + 1
print(ret)



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

int main(){
    bool submitted[30] = {false};
    int id;

    for(int i=1; i<=28; i++){
        cin >> id;
        submitted[id-1] = true;
    }

    for(int i=0; i<30; i++){
        if(submitted[i] == false){
            cout << i+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
n = gets.to_i
s = gets.chomp!

array = s.split('')

i_j_k_sum = array.count('R') * array.count('G') * array.count('B')
count = 0

n.times do |i|
  n.times do |j|
    next if j <= i

    k = 2 * j - i
    next if k >= n || k <= j

    if array[i] != array[j] && array[i] != array[k] && array[j] != array[k]
      count += 1
    end
  end
end

puts i_j_k_sum - count


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

using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<vector<int>> cnt(6, vector<int>(n + 1));
	string tmp = "RGB";
	for (int i = 0; i < 3; ++i) {
		cnt[2 * i][0] = 0;
		for (int j = 0; j < n; ++j) {
			cnt[2 * i][j + 1] = cnt[2 * i][j] + (s[j] == tmp[i]);
		}
		cnt[2 * i][n] = 0;
		for (int j = n - 1; j >= 0; --j) {
			cnt[2 * i + 1][j] = cnt[2 * i + 1][j + 1] + (s[j] == tmp[i]);
		}
	}
	int p[3] = {0, 1, 2};
	ll ans = 0;
	do {
		for (int i = 0; i < n; ++i) {
			if (s[i] != tmp[p[0]]) {
				continue;
			}
			ans += cnt[2 * p[1]][i] * cnt[2 * p[2] + 1][i];
			for (int j = 1; i - j >= 0 && i + j < n; ++j) {
				if (s[i - j] == tmp[p[1]] && s[i + j] == tmp[p[2]]) {
					ans--;
				}
			}
		}
	} while (next_permutation(p, p + 3));
	cout << ans << endl;
}

Measured memory_bytes: 3760
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		var A = new long[N];
		Arrays.setAll(A, $ -> Long.parseLong(sc.get()));

		for (long l : A) {
			if (l == 0) {
				System.out.println(0);
				return;
			}
		}

		long result = 1;
		try {
			for (int i = 0; i < N; i++) {
				long l = A[i];
				result = Math.multiplyExact(result, l);
				if (result > 1000000000000000000L) {
					System.out.println(-1);
					return;
				}
			}
		}
		catch(ArithmeticException e){
			System.out.println(-1);
			return;
		}
		System.out.println(result);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 49688
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

string s;
int64_t cnt, ans;

int main() {
    string s;
    cin >> s;
    s += '#';
    rep(i, s.size()) {
        if (s[i] == 'A') cnt++;
        else if (s.substr(i, 2) == "BC") {
            ans += cnt;
            i++;
        } else {
            cnt = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
x, y = list(map(int, input().split()))

cnt = 0
if x == 1:
    cnt += 300000
elif x == 2:
    cnt += 200000
elif x == 3:
    cnt += 100000 
    
if y == 1:
    cnt += 300000
elif y == 2:
    cnt += 200000
elif y == 3:
    cnt += 100000 
    
if x == 1 and y == 1:
    cnt += 400000
    
print(cnt)

Measured memory_bytes: 3064
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;


ll MAX = 1000000000;


int main()
{
	ll S; cin >> S;
	ll x1, x2, y1, y12;

	if (S < MAX)
	{
		y12 = S;
		x2 = 1;
	}
	else
	{
		y12 = MAX;
		x2 = S/y12;
	}

	//cout << x2 << endl;
	//cout << y12 << endl;

	ll T = S - y12*x2;

	if (T == 0)
	{
		y1 = x1 = 0;
	}
	else
	{
		for (x1 = 1;; ++x1)
		{
			if (T%x1 == 0)
			{
				ll y2 = T / x1;
				if (y2 > MAX)continue;
				y1 = y12 - y2;
				break;
			}
		}
	}

	cout << "0 0 " << x1 << " " << y12 << " " << x1 + x2 << " " << y1 << endl;
	
	//cout << x2*y12 + x1*(y12 - y1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <queue>
#include <vector>
#include <iostream>
#include <cstdint>
#include <cstring>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;

	if (a < 2 * b)
	{
		cout << 0 << endl;
		return 0;
	}

	cout << (a - 2 * b) << endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	a=int(io())
	l = list(map(int, io().split()))
	isEven = len([x for x in l if x % 2 == 1]) % 2 == 0
	return 'YES' if isEven else 'NO'

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

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

bool prime[10000001];

int main(){
    fill_n(prime,10000000,true);
    prime[0]=prime[1]=false;
    for(int i=2;i<10000000;i++){
        if(!prime[i])continue;
        for(int j=2;i*j<10000000;j++)prime[i*j]=false;
    }
    int n;
    while(cin>>n,n){
        for(int i=n;i>0;i--){
            if(prime[i]&&prime[i-2]&&prime[i-6]&&prime[i-8]){
                cout<<i<<endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 10920
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001;
typedef pair<int,int> P;
#define foreach(ix,a) for(auto& (ix) : (a) 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,M;
  cin >>N>>M;
  vector<string>ma(N);
  rep(i,N)cin >> ma[i];
  
  int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
  int ans =0;
  
  rep(sx,N)rep(sy,M){
    if(ma[sx][sy] == '#')continue;
    queue <P> que;
    vector<vector<int>> d(N,vector<int>(M,INF));
    auto update=[&](int i,int j,int x){
      if(d[i][j]!=INF)return;
      d[i][j]=x;
      que.push(P(i,j));
    };
    update(sx,sy,0);
    while(!que.empty()){
      int i = que.front().first;
      int j=que.front().second; que.pop();
      rep(a,4){
        int nx = i + dx[a],ny = j +dy[a];
        if(0>nx||0>ny||nx>=N||ny>=M)continue;
        if(ma[nx][ny]=='#')continue;
          update(nx,ny,d[i][j]+1);
      }
    }
  rep(i,N)rep(j,M){
    if(d[i][j]==INF)continue;
    ans = max(ans,d[i][j]);}
}
cout<<ans<<endl;


}

Measured memory_bytes: 256
import sys
import copy

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    s = []
    for i in range(N):
        tmp = A[i]
        s.append(tmp)
        for j in range(i + 1, N):
            tmp += A[j]
            s.append(tmp)

    s.sort(reverse=True)
    M = s[0]
    ans = 0
    n = M.bit_length()
    for i in range(n):
        tmp = []
        for v in s:
            if 1 << (n - i - 1) & v:
                tmp.append(v)
        if len(tmp) >= K:
            ans += 1 << (n - i - 1)
            s = copy.deepcopy(tmp)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 28992
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m; cin >> n >> m;
    int l,r;
    int lans = 0,rans = 100000;

    for(int i = 0; i < m; i++){
        int l,r;
        cin >> l >> r;
        if(lans < l){
            lans = l;
        }
        if(rans > r){
            rans = r;
        }
    }
    if(rans - lans + 1 < 0){
        cout << 0 << endl;
    }else{
        cout << rans - lans + 1 << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int cnt = 0;
        for(int i=0; i<=a; i++){
          for(int j=0; j<=b; j++){
            for(int k=0; k<=c; k++){
              if(i*500 + j*100 + k*50 == x) cnt++;
            }
          }
        }
        System.out.print(cnt);
        
}
}


Measured memory_bytes: 23124
using System;

class Program
{
    static void Main(string[] args)
    {
        string line;
        while (true)
        {
            line = Console.ReadLine();
            int judge = int.Parse(line);
            if (judge == 0) break;


            int[] score = new int[judge];
            int sum = 0;

            for (int i = 0; i < judge; i++)
            {
                score[i] = int.Parse(Console.ReadLine());
                sum += score[i];
            }
            int max, min;
            min = max = score[0];
            for (int i = 0; i < judge; i++)
            {
                if (score[i] < min) min = score[i];
                if (score[i] > max) max = score[i];
            }
            int average = (sum - max - min) / (judge - 2);
            Console.WriteLine(average);
        }
    }
}

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

int comp(const void* a, const void* b)
{
    return *((int*)a)<*((int*)b);
}

int a[100];
int main(void)
{
    while (1) {
        int n, i, s;
        scanf("%d", &n);
        if (n==0) break;
        for(i=0;i<n;++i) scanf("%d", a+i);
        qsort(a, n, sizeof(int), comp);
        s=0;
        for(i=1;i<n-1;++i) s+=a[i];
        printf("%d\n", s/(n-2));
    }
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
int main(){
  while(1){
    int w,h,mp[20][20]={},dp[20][20] ={};
    cin >> w >> h;
    if(w==0 && h==0) break;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++) cin >> mp[i][j];
   

    int ans=0;   
    for(int i=0;i<w;i++) {
      if(mp[0][i]==0) dp[0][i] = 1;
      if(0 >=h-1)ans+=dp[0][i];
    }
    for(int i=0;i<h-1;i++)
      for(int j=0;j<w;j++) 
	for(int k=-1;k<=1;k++){
	  int nx=j+k,ny=i+1;
	  if(nx<0||nx>=w || mp[i][j] !=0) continue;
	  while(k==0&&mp[ny][nx]==2) ny+=2;
	  if(mp[ny][nx]!=0) continue;
	  dp[ny][nx]+= dp[i][j];
	  if(ny >= h-1) ans+=dp[i][j];
	}
    cout << ans <<endl;
  }
  return 0;
}

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

int main() {
  int N, C;
  cin >> N >> C;
  vector<int> p(C);
  for (int i = 0; i < C; i++) cin >> p[i];
  int sum = 0;
  for (int i = 0; i < C; i++) sum += p[i];
  cout << (sum + N) / (N + 1) << endl;
}


Measured memory_bytes: 3104
B = []
for _ in range(4):
    b = [[0] * 10 for _ in range(3)]
    B.append(b)
n = int(input())
for _ in range(n):
    b, f, r, v = map(int, input().split())
    B[b - 1][f - 1][r - 1] += v
for i in range(4):
    for j in range(3):
        for Bi in B[i][j]:
            print('', Bi, end='')
        print()
    if i == 3:
        break
    print('#' * 20)



Measured memory_bytes: 5636
#define _USE_MATH_DEFINES
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		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;
}

int c[100005], bou[100005];
bool vi[100005];

signed main() {
	int n;
	cin >> n;
	vector<P> ans;
	vector<pair<int,int>>p[100005];
	vector<int>g[100005];
	rep(i, n - 1) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		p[x].push_back({ y, i });
		p[y].push_back({ x,i });
		g[x].push_back(y);
		g[y].push_back(x);
	}
	int ma = 0, mat;
	rep(i, n) {
		sort(p[i].begin(), p[i].end());
		sort(g[i].begin(), g[i].end());
		if (g[i].size() > ma) {
			ma = g[i].size();
			mat = i;
		}
	}
	/*rep(i, n) {
		rep(j, g[i].size()) {
			cout << g[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;*/
	/*rep(i, n) {
		rep(j, p[i].size()) {
			cout << "{" << p[i][j].first << " " << p[i][j].second << "}" << " ";
		}
		cout << endl;
	}
	cout << endl;*/
	queue<int>que;
	que.push(0);
	vi[0] = true;
	bou[0] = -1;
	while (!que.empty()) {
		int now = que.front(); que.pop();
		rep(i, g[now].size()) {
			if (!vi[g[now][i]]) {
				if (c[now] == bou[now]) {
					c[now]++;
				}
				p[now][i].first = 10000000 + c[now];
				bou[g[now][i]] = c[now];
				c[now]++;
				vi[g[now][i]] = true;
				que.push(g[now][i]);
			}
		}
	}
	rep(i, n) {
		rep(j, p[i].size()) {
			if (p[i][j].first >= 10000000) {
				ans.push_back({ p[i][j].second,p[i][j].first });
			}
		}
	}
	sort(ans.begin(), ans.end());
	cout << ma << endl;
	rep(i, n - 1) {
		cout << ans[i].second - 10000000 + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 17652
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {

  std::string Sa, Sb, Sc;
  std::cin >> Sa >> Sb >> Sc;

  int a = 0, b = 0, c = 0;

  char next = 'a';
  while(1) {
    if ( next == 'a' ) {
      next = Sa[a];
      a++;
      if(a>Sa.size()) {
        std::cout << "A" << std::endl;
        return 0;
      }
    }
    else if ( next == 'b' ) {
      next = Sb[b];
      b++;
      if(b>Sb.size()) {
        std::cout << "B" << std::endl;
        return 0;
      }
    }
    else {
      next = Sc[c];
      c++;
      if(c>Sc.size()) {
        std::cout << "C" << std::endl;
        return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
n = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = input()
print(n[int(k)-1])

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

typedef long long ll;
typedef vector <bool> v_bool;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll N,D;
v_ll A;
int main(){
  cin >> N >> D;
  cout << (N+2*D)/(2*D+1) << endl;
}


Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<functional>
#include<map>
using namespace std;
typedef long long ll;
int main()
{
	string s;
	int a,b,i,no=0;
	cin>>a>>b;
	cin>>s;
	for(i=0;i<a;i++)
		if(s[i]<'0'||s[i]>'9')no=1;
	if(s[a]!='-')no=1;
	for(i=a+1;i<a+b+1;i++)
		if(s[i]<'0'||s[i]>'9')no=1;
	if(no)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define _START_ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _END_ return 0;

using namespace std;

int main()
{   
    _START_
    
    ll int n;
    cin >> n;
    int x = n / 1000;
    if (n % 1000)
    {
        x++;
    }
    int c = (x * 1000) - n;
    cout << c;
    
    _END_
}

Measured memory_bytes: 3648
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] l1 = new int[N];
        int min = 2000000000;
        for(int i = 0;i < N;i++)    l1[i] = sc.nextInt();
        heapsort(l1, N);
        for(int i = 0; i+K-1 < N;i++){
            min = Math.min(min, l1[i+K-1]-l1[i]);
        }
        System.out.println(min);
    }
    public static void heapsort(int[] list, int length){
        // public static void heapsort(int[] list, int[] list2, int length){
        // public static void heapsort(int[] list, int[] list2, int[] list3, int length){
            /**
             * make a heaptree
             */
            for(int i = 0;i < length;i++){
                int id = i;
                while(true){
                    if(id == 0) break;
                    int nextid = 0;
                    if(id%2 == 1)   nextid = id/2;
                    else    nextid = id/2-1;
                    if(list[id] > list[nextid]){
                        int tmp = list[id];    list[id] = list[nextid];    list[nextid] = tmp;
                        // int tmp2 = list2[id];    list2[id] = list2[nextid];    list2[nextid] = tmp2;
                        // int tmp3 = list3[id];    list3[id] = list3[nextid];    list3[nextid] = tmp3;
                    }else{
                        break;
                    }
                    id = nextid;
                }
            }
            /**
             * convert from heaptree to sortlist
             */
            int id2 = length-1;
            while(true){
                if(id2 == 0)    break;
                int tmp = list[0];    list[0] = list[id2];    list[id2] = tmp;
                // int tmp2 = list2[0];    list2[0] = list2[id2];    list2[id2] = tmp2;
                // int tmp3 = list3[0];    list3[0] = list3[id2];    list3[id2] = tmp3;
                int curid = 0;
                id2--;
                if(id2 == 0)    break;
                while(true){
                    int left = (curid+1)*2-1;
                    int rightnum = Integer.MIN_VALUE;
                    int right = (curid+1)*2;
                    if(right <= id2)    rightnum = list[right];
                    int mid = 0;
                    if(list[left] >= rightnum)  mid = left;
                    else    mid = right;
                    if(list[curid] < list[mid]){
                        int tmpp = list[curid];     list[curid] = list[mid];       list[mid] = tmpp;
                        // int tmpp2 = list2[curid];     list2[curid] = list2[mid];       list2[mid] = tmpp2;
                        // int tmpp3 = list3[curid];     list3[curid] = list3[mid];       list3[mid] = tmpp3;
                    }else{
                        break;
                    }
                    curid = mid;
                    if((curid+1)*2-1 > id2)   break;
                }
            }
        }
}

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

int main() {

	int n; cin >> n;
	vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];

	int reverse_ans = 0;
	int tmp = 1;
	for (int i = 0; i < n; i++) {
		
		if (a[i] == tmp) {
			reverse_ans++;
			tmp++;
		}

	}

	if (reverse_ans == 0) cout << -1 << endl;
	else cout << n - reverse_ans << endl;
	
	return 0;

}

Measured memory_bytes: 1024
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a,b,c,d,e,f = map(int,readline().split())
wf = f//100+1
water = [0]*(wf+31)
suger = [0]*(f+31)

water[0] = 1
suger[0] = 1

for i in range(wf):
    if water[i]:
        water[i+a] = 1
        water[i+b] = 1
for i in range(f):
    if suger[i]:
        suger[i+c] = 1
        suger[i+d] = 1

water = set(100*i for i in range(1,wf+1) if water[i])
suger = set(i for i in range(f+1) if suger[i])

ans_per = -1
ans_water = 0
ans_suger = 0

for w,s in itertools.product(water,suger):
    if w//100*e < s: #砂糖が溶け残る
        continue
    if w+s > f: #重量オーバー
        continue
    res = s/(w+s) #パーセンテージ
    if res > ans_per:
        ans_per = res
        ans_water = w
        ans_suger = s

print(ans_water+ans_suger,ans_suger)

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

int main() {
  string S;
  cin >> S;
  S.push_back('_');
  S.push_back('_');

  string s = "__";
  int ans = 0;
  for (int i = 0; i < S.length();) {
    if (s != S.substr(i, 1)) {
      s = S.substr(i, 1);
      i += 1;
    } else {
      s = S.substr(i, 2);
      i += 2;
    }
    ans++;
  }
  ans -= 2;
  cout << ans << endl;
}

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

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

int main() {
    ll H,W,h,w;cin>>H>>W>>h>>w;
    ll ans;
    ans=H*W-(H*w+W*h-h*w);
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
// Last Change: 05/20/2019 18:59:03.
//////////////////////////////////////////////////////////////////////////////
//すっきりバージョン。もう少し有効数字というか、数字の精度に意識を配る必要が
//あるかもしれない。
//
// Cの結果とC1の結果は微妙に違うものとなった。だが、ABCにおいてはどちらもACされ
//るアルゴリズムである。このことから得るべき教訓は、浮動小数問題は出力結果の違
//いに惑わされてはいけないということである。ちゃんと誤差が要求範囲に収まってい
//るかをよく確認すべきだ。
//////////////////////////////////////////////////////////////////////////////
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  ll N, K;
  cin >> N >> K;

  double ans = 0;
  ll two = 1;
  for (ll i = N; i >= 1; --i) {
    while (i * two < K) {
      two *= 2;
    }
    ans += 1.0 / N / two;
  }

  cout << fixed << setprecision(12) << ans << endl;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 1000000009
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()
 
//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    const int limbin = 500001;
    int fact[limbin], factinv[limbin] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,limbin)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();
        if(n<r) return 0;             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

int hi[90][10] = {};

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    rep(i,90)
    {
        int sd = 0 , cn = i;
        rep(j,10)
        {
            string l = to_string(cn);
            for(auto i : l)
                sd += (i-'0');
            cn++;
            hi[i][j] = sd;
        }
    }
    // cin >> t; 
    rep(i,t)
    {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}

int vis[10000001];

void solve() 
{   
    vi primes;
    int n , res = 0;
    cin >> n;
    repp(i,1,n+1)
    {
        res += (n/i)*(n/i+1)/2 * i;
    }
    cout << res << endl;
    // for(int i = 2 ; i <=100
}   

Measured memory_bytes: 3724
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

cnt=0
for a,b in zip(A,B):
  if a>b:
    cnt+=a-b
  else:
    cnt-=(b-a)//2
print('Yes' if cnt<=0 else 'No')

Measured memory_bytes: 4596