akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
//#define mod 1000000007
#define mod 998244353

int N,K;
int L[15],R[15];
int dp[200005];
signed main(){
    scanf("%lld %lld",&N,&K);
    rep(i,K){
        scanf("%lld %lld",&L[i],&R[i]);
    }
    rep(i,N)dp[i]=0;
    dp[0]=1;dp[1]=-1;
    rep(i,N){
        if(i!=0)dp[i]+=dp[i-1];
        dp[i]=(dp[i]+mod)%mod;
        rep(j,K){
            if(i+L[j]<N)dp[i+L[j]]+=dp[i]%mod;
            if(i+R[j]+1<N)dp[i+R[j]+1]-=dp[i]%mod;
        } 
        dp[i]=(dp[i]+mod)%mod;
    }
    printf("%lld\n",(dp[N-1]+mod)%mod);
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    cout << A[N - 1] - A[0] << endl;
    return 0;
}


Measured memory_bytes: 256
integer N
character(50) S
integer abc(ichar("a"):ichar("z")),ans(ichar("a"):ichar("z"))
read*,N
ans=huge(ans)
do i=1,N
  read*,S
  abc=0
  do j=1,len_trim(S)
    abc(ichar(S(j:j)))=abc(ichar(S(j:j)))+1
  end do
  do j=ichar("a"),ichar("z")
    ans(j)=min(ans(j),abc(j))
  end do
end do
S=""
do i=ichar("a"),ichar("z")
  S=trim(S)//repeat(char(i),ans(i))
end do
print"(A)",trim(S)
end

Measured memory_bytes: 768
#include <atcoder/lazysegtree>
#include <atcoder/modint>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
struct S { modint998244353 a, b; };
using F = int;
S op(S l, S r) { return S{l.a * r.b + r.a, l.b * r.b}; }
S e() { return S{0, 1}; }
F id() { return -1; }
S mapping(F f, S x) { return f == id() ? x : S{(x.b - 1) / 9 * f, x.b}; }
F composition(F f, F g) { return f == id() ? g : f; }
main() {
    F n, q;
    cin >> n >> q;
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(vector(n, S{1, 10}));
    while (q--) {
        F l, r, d;
        cin >> l >> r >> d;
        seg.apply(l - 1, r, d);
        cout << seg.all_prod().a.val() << '\n';
    }
}

Measured memory_bytes: 9788
//check check check
#include<iostream>
#include<vector>
#include<algorithm>
#include<fstream>
#include<queue>
#include<cstring>
#include<map>
#include<iomanip>

#define ll long long
#define pb(x) push_back(x)

using namespace std;

typedef pair<int,int> ii;

const int NMAX = 0;

string s1,s2;

int main()
{
    int n,i,j;

    cin>>s1>>s2;
    int cnt = 0;
    for(i = 0 ; i < 3 ; ++i)
        cnt += s1[i] == s2[i];

    cout<<cnt;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int A,B,c,d;
  scanf("%d%d",&A,&B);
  
  if(B%A==0)
  {
    c=A+B;
    printf("%d",c);
  
  }
  
  else
  {
    d=B-A;
    printf("%d",d);
  }
  
  return 0;
}


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

int main()
{
    int x;
    cin>>x;
    
    if(x>=400&&x<=599)
    {
        cout<<"8"<<endl;
    }
    else if(x>=600&&x<=799)
    {
        cout<<"7"<<endl;
    }
    else  if(x>=800&&x<=999)
    {
        cout<<"6"<<endl;
    }
    else  if(x>=1000&&x<=1199)
    {
        cout<<"5"<<endl;

    }
    else  if(x>=1200&&x<=1399)
    {
        cout<<"4"<<endl;
    }
    else  if(x>=1400&&x<=1599)
    {
        cout<<"3"<<endl;
    }
    else  if(x>=1600&&x<=1799)
    {
        cout<<"2"<<endl;
    }
    else  if(x>=1800&&x<=1999)
    {
        cout<<"1"<<endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define MAXN 100010
using namespace std;

struct city
{
	int p,y,pt;
	bool operator < (const city &a)const{
		return y<a.y;
	}
};

vector <city> a[MAXN],b;
int n,m,x,y;

bool cmp(city a,city b){return a.pt<b.pt;}

int main()
{
	scanf("%d %d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		scanf("%d %d",&x,&y);
		a[x].push_back((city){x,y,i});
	}
	for (int i=1;i<=n;i++)
	{
		if (!a[i].size()) continue;
		sort(a[i].begin(),a[i].end());
		for (int x=0;x<a[i].size();x++)
		{
			a[i][x].y=x+1;b.push_back(a[i][x]);
		}
	}
	sort(b.begin(),b.end(),cmp);
	for (int i=0;i<m;i++)
		printf("%06d%06d\n",b[i].p,b[i].y);
	return 0;
}

Measured memory_bytes: 8308
import Foundation

let input = readLine()!.componentsSeparatedByString(" ")
let N = Int(input[0])!
let M = Int(input[1])!

var cnt = Array(count: M, repeatedValue: 0)

for _ in 0 ..< N {
    let input = readLine()!.componentsSeparatedByString(" ")
    let K = Int(input[0])!
    for i in 0 ..< K {
        let A = Int(input[i+1])! - 1
        cnt[A] += 1
    }
}

var ans = 0
for i in 0 ..< M {
    if cnt[i] == N {
        ans += 1
    }
}

print(ans)


Measured memory_bytes: 7908
import math
from sys import stdin
data = stdin.readlines()

a = int(data[0])
b = [int(s) for s in data[1].split()]

i = 1
alice = 0
bob = 0
while i <= math.ceil(a/2):
    alice += b.pop(b.index(max(b)))
    if len(b) >= 1:
        bob  += b.pop(b.index(max(b)))
    i += 1
print(alice - bob)

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

int main() {
  ll n, k, q, x;
  cin >> n >> k >> q;
  vector<int> v(n+1, 0);
  
  for (int i = 0; i < q; i++) {
    cin >> x;
    v[x]++;
  }
  
  for (ll i = 1; i <= n; i++) {
    if (k - q + v[i] <= 0) cout << "No\n";
    else cout << "Yes\n";
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

#define INF INT32_MAX

int main() {
    int H, W; cin >> H >> W;
    int Ch, Cw; cin >> Ch >> Cw;
    Ch--, Cw--;
    int Dh, Dw; cin >> Dh >> Dw;
    Dh--, Dw--;
    vector<string> G(H);
    rep(i,H) {
        cin >> G.at(i);
    }
    G[Ch][Cw] = '.'; G[Dh][Dw] = '.';
    vector<vector<int>> V(H, vector<int>(W,INF));

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

    using triple = tuple<int, int ,int>;
    deque<triple> Q;
    Q.emplace_front(make_tuple(Cw,Ch,0));
    while (!Q.empty()) {
        auto [x, y, cnt] = Q.front(); Q.pop_front();
        if (x == Dw && y == Dh) {
            cout << cnt << endl;
            return 0;
        }

        rep(i,4) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx < 0 || nx >= W) continue;
            if (ny < 0 || ny >= H) continue;
            char c = G[ny][nx];
            if (c == '.' && cnt < V[ny][nx]) {
                Q.push_front(make_tuple(nx, ny, cnt));
                V[ny][nx] = cnt;
            }
        }

        for (int dx = -2; dx <= 2; dx++) {
            for (int dy = -2; dy <= 2; dy++) {
                if (dx == 0 && dy == 0) continue;
                int nx = x + dx;
                int ny = y + dy;
                if (nx < 0 || nx >= W) continue;
                if (ny < 0 || ny >= H) continue;
                char c = G[ny][nx];
                if (c == '.' && V[ny][nx] > cnt + 1) {
                    Q.push_back(make_tuple(nx, ny, cnt+1));
                    V[ny][nx] = cnt + 1;
                }
            }
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 9588
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		double x1=sc.nextDouble();
		double y1=sc.nextDouble();
		double x2=sc.nextDouble();
		double y2=sc.nextDouble();
		double l=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
		System.out.printf("%.8f\n",Math.sqrt(l));
	}
}

Measured memory_bytes: 28132
N = int(input())

for l in range(N):
    s = input()
    n = []
    for i in range(len(s)):
        n.append(int(s[i]))
    a,b = 0,0
    n.sort()
    for i in range(len(n)):
        a *= 10
        a += n[i]

        b *= 10
        b += n[len(n)-i-1]
    print(b-a)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*
 
 5/8/2020
 
 17:34-
 
 */

string A[11];
int H,W,K;

const int Inf=1e8;
void solve() {
  int res=H*W;
  REP(mask,1<<(H-1)) {
    VI gs(H,0);
    REP(i,H-1) {
      gs[i+1]=gs[i]+((mask>>i)&1);
    }
    int G=gs[H-1]+1;
    int w=0;
    VI cnt(G);
    int ans=__builtin_popcount(mask);
    REP(j,W) {
      VI cnt2(G);
      REP(i,H) cnt2[gs[i]]+=A[i][j]-'0';
      bool ok=true;
      REP(i,G) if(cnt[i]+cnt2[i]>K) {
        ok=false;
      }
      if(!ok) {
        if(w==0) {
          ans=Inf;
          break;
        } else {
          w=1;
          cnt=cnt2;
          ++ans;
        }
      } else {
        REP(i,G) cnt[i]+=cnt2[i];
        ++w;
      }
    }
    SMIN(res,ans);
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>H>>W>>K;
  REP(i,H) cin>>A[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 256
use std;
use std::collections::VecDeque;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

/*
ここまでテンプレ
*/
fn ord(a: (i32, i32), b: (i32, i32)) -> bool {
    if (a.0 < b.0) {
        true
    } else {
        false
    }
}
fn main() {
    let N = read::<i32>();
    println!("{}", N * N * N);
}


Measured memory_bytes: 2108
A,B = map(int,input().split())
 
Y = (B - 2*A) / 2
 
if not( Y.is_integer() ) or ( Y < 0) :
    print('No')
    exit(0)
else:
    X = A - Y
    if X < 0:
        print('No')
        exit(0)
print('Yes')

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=100010;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n,deg[maxn],p[maxn],a[maxn],b[maxn],c[maxn],d[maxn],ans,q[maxn],h,r,cnt,el,head[maxn],to[maxn],nxt[maxn];
inline void add(int u,int v){
	to[++el]=v;nxt[el]=head[u];head[u]=el; 
}
inline bool cmp(int x,int y){
	return deg[x]<deg[y];
}
int main(){
	n=read();
	FOR(i,1,n-1){
		a[i]=read();b[i]=read();
		deg[a[i]]++;deg[b[i]]++;
		add(a[i],b[i]);add(b[i],a[i]);
	}
	FOR(i,1,n) c[i]=read();
	if(n==1) return printf("0\n%d\n",c[1]),0;
	sort(c+1,c+n+1);
	h=1;r=0;
	FOR(i,1,n) if(deg[i]==1) q[++r]=i;
	while(h<=r){
		int u=q[h++];
		d[u]=c[++cnt];
		for(int i=head[u];i;i=nxt[i]){
			int v=to[i];
			if(--deg[v]==1) q[++r]=v;
		}
	}
	FOR(i,1,n-1) ans+=min(d[a[i]],d[b[i]]);
	printf("%d\n",ans);
	FOR(i,1,n) printf("%d ",d[i]);
}

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

int main()
{
    int n;
    cin >> n;
    vector<long> l(n+1);
    l[0] = 2;
    l[1] = 1;
    for(int i=2;i<=n;i++){
        l[i] = l[i-1] + l[i-2];
    }
    cout << l.back() << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3


def solve(N, S):
    l = 0
    r = len(S) - 1
    answer = 0
    while l < r:
        if S[l] == "R":
            l += 1
        elif S[r] == "W":
            r -= 1
        else:
            # S[l] == 'W' S[r] == 'R' l < r
            l += 1
            r -= 1
            answer += 1

    return answer


def main():
    N = int(input())
    S = input()
    answer = solve(N, S)
    print(answer)


if __name__ == "__main__":
    main()


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

int main(){
    int n;
    cin >> n;
    map<string, int> S;

    for(int i = 0; i < n; ++i){
        string input;
        cin >> input;
        // mapはキーがソートされた形で格納されるのでsort()すら不要
        // C++のmapでは存在しないキーをインクリメントするとき，自動でValueが0のコンテナを作る
        S[input]++;
    }

    int mx = 0;

    // 最大値を求める
    for(auto p : S){
        mx = max(mx, p.second);
    }

    // valueで最大値を持つもののみ出力
    for(auto p : S){
        if(p.second != mx) continue;
        cout << p.first << endl;
    }
}

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

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        long res = 0;
        for (int i = 1; i <= n; i++)
        {
            if (i % 3 != 0 && i % 5 != 0)
                res += i;
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 27476
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

void dfs(map<int, int> &chara, map<int, vector<int>> &g, int start)
{
    map<int, int> visited;
    deque<pair<int, int>> que;
    que.push_back({start, 0});
    while (!que.empty())
    {
        auto cur = que.front();
        que.pop_front();
        if (visited[cur.first])
            continue;
        chara[cur.first] = cur.second;
        visited[cur.first] = true;
        for (auto x : g[cur.first])
        {
            if (visited[x] == false)
            {
                que.push_back({x, cur.second + 1});
            }
        }
    }
}

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    map<int, vector<int>> g;
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    map<int, int> fennec, snuke;
    dfs(fennec, g, 0);
    dfs(snuke, g, n - 1);
    /*rep(i, n)
    {
        cerr << fennec[i] << " " << snuke[i] << endl;
    }*/
    int colnode = -1;
    int coldist = 1 << 30;
    rep(i, n)
    {
        if (fennec[i] == snuke[i] && snuke[i] < coldist)
        {
            coldist = snuke[i];
            colnode = i;
        }
    }
    int fnum = 0, snum = 0;
    rep(i, n)
    {
        if (fennec[i] < snuke[i])
        {
            fnum++;
        }
        else if (fennec[i] > snuke[i])
        {
            snum++;
        }
        else
        {
            fnum++;
        }
    }
    //cerr << fnum << " " << snum << endl;
    if (fnum > snum)
    {
        cout << "Fennec" << endl;
    }
    else
    {
        cout << "Snuke" << endl;
    }

    return 0;
}


Measured memory_bytes: 25216
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <stdio.h>
#include <math.h>
#include <utility>
#include <algorithm>
#include <sstream>

using namespace std;

int main() {
	string s;
	cin >> s;
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += s.at(i) == 'o' ? 1 : 0;
	}
	if (15-s.size()+cnt>=8) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}


Measured memory_bytes: 256
<?php
$t=(int)trim(fgets(STDIN));

#$s=$l%60;$l-=$s;$l/=60;$m=$l%60;$l-=$m;$l/=60;

$h=floor($t/3600);
$m=floor($t/60)%60;
$s=$t%60;

echo $h.':'.$m.':'.$s."\n";
#echo "{$h}:{$m}:{$s}\n";

Measured memory_bytes: 15312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
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; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) do{}while(0)
#endif




ll n;

int main(){
	cin >> n;
	vector<pii> v;
	auto f = [&](int a,int b){v.push_back({a,b});};
	auto f4 = [&](int a,int b, int aa, int bb){
		f(a,aa);
		f(a,bb);
		f(b,bb);
		f(b,aa);
	};
	
	ll n2 = n/2;
	ll odd = n%2;
	
	rep(i,n2-1){
		ll a = i+1;
		ll aa = i+2;
		ll b = n2*2-i;
		ll bb = n2*2-i-1;
		f4(a,b,aa,bb);
	}
	if ( odd ){
		f(n,1);
		f(n,n2*2);
		if ( n != 3 ){
			f(n,n2);
			f(n,n2+1);
		}
	}
	else {
		if ( n != 4 ){
			f4(n2,n2+1,1,n2*2);
		}
	}
	
	cout << v.size() << endl;
	for ( auto it : v )
		cout << it.first << " " << it.second << endl;
	
	return 0;
}




Measured memory_bytes: 3560
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

int main(){
    int A,B,C;

    cin >> A >> B >> C;

    if( A+ B + C >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
fl = []
N.times do
  f = gets.split(' ').map(&:to_i)
  fl.push(f)
end
pl = []
N.times do
  pr = gets.split(' ').map(&:to_i)
  pl.push(pr)
end

cand = []
[0, 1].repeated_permutation(10) do |k|
  next if !k.include?(1)
  sum = 0
  N.times do |i|
    time = 0
    0.upto(9) do |j|
      time += k[j] * fl[i][j]
    end
    sum += pl[i][time]
  end
  cand.push(sum)
end

puts cand.max

Measured memory_bytes: 1916
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, k;
	cin >> n >> k;

	vector<int> a(n);
	for(auto &x : a) cin >> x;

	auto possible = [&] (int v) {
		int ops = 0;
		for(auto &x : a) {
			if(x <= v) continue;
			if(ops + (x / v) > k) return false;
			ops += (x / v);
		}
		return true;
	};

	int lo = 1, hi = 1.1e9;
	while(lo < hi) {
		int md = (lo + hi) / 2;
		if(possible(md)) hi = md;
		else lo = md + 1;
	}

	cout << hi << '\n';
}

Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;

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

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

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
    long long x;
public:
    mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator^(const ll& t)const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream& operator<<(ostream& os, const mint& m) {
        os << m.x;
        return os;
    }
};

//////////////////////////

int main() {
    ll i, o, t, j, l, s, z;
    cin >> i >> o >> t >> j >> l >> s >> z;

    ll ans = o+i+j+l;

    ll c = i % 2 + j % 2 + l % 2;

    if (c == 1) { ans--; }
    if (c == 2) {
        if (i > 0 && j > 0 && l > 0) { ans--; }
        else { ans -= 2; }
    }
    cout << ans;


	system("PAUSE");
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end(), greater<int>());
  int ap = 0, bp = 0;
  rep(i, n) {
    if (i % 2 == 0) ap += a[i];
    else bp += a[i];
  }
  int ans = ap - bp;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3540
#include<stdio.h>
int main(void)
{
	double a,s;
	while(scanf("%lf %lf",&a,&s)!=EOF){
		if(a<35.50&&s<71.00){
			printf("AAA\n");
		}
		else if(a<37.50&&s<77.00){
			printf("AA\n");
		}
		else if(a<40.00&&s<83.00){
			printf("A\n");
		}
		else if(a<43.00&&s<89.00){
			printf("B\n");
		}
		else if(a<50.00&&s<105.00){
			printf("C\n");
		}
		else if(a<55.00&&s<116.00){
			printf("D\n");
		}
		else if(a<70.00&&s<148.00){
			printf("E\n");
		}
		else{
			printf("NA\n");
		}
		}
	return 0;
}

Measured memory_bytes: 1036
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/25/20 20:57:10
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,k; cin>>n>>k;
  vector<int> A(n); for (auto& a:A) cin>>a;
  for (int i = k; i < n; i++) {
    cout << (A[i] > A[i-k] ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 3988
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define _ << " " <<
#define all(v) v.begin(), v.end()

using namespace std;
using ll = long long;

const int mod = 1000000007;

vector<vector<int>> g;
vector<bool> used;

int cnt = 1;

void dfs(int v) {
	if (!used[v]) {
		cnt++;
		used[v] = true;
		for (int u : g[v]) {
			dfs(u);
		}
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin >> n >> m;
	g.resize(n + 1);
	used.resize(n + 1, false);
	while (m--) {
		int x, y, z;
		cin >> x >> y >> z;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (!used[i]) {
			cnt = 1;
			dfs(i);
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<string,ll> si;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<si> vsi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vsi> vvsi;


// bool sieve[100005];

// void sieveoferat()
// {
// 	for(ll p = 2; p*p<100005 ; p++)
// 	{
// 		if(sieve[p])
// 		{
// 			for(int j = p*p; j<100005; j+=p)
// 				sieve[j] = false;
// 		}
// 	}
// }

// void dp(sp_1, sp_2.....)
// {
// 	if()//exit statement
// 	if()//using the memoization 
// 	ll ans = //default/dummy answer
// 	//recursions
// 			//max/min
// 	return memo[][].. = ans;

// }

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 	cout.tie(NULL);
 	//memset(memo, -1, sizeof memo);
 	// memset(sieve, true, sizeof sieve);
 	// sieveoferat();
 	ll a, b;
 	cin>>a>>b;
 	a<b?cout<<0<<endl:cout<<10<<endl;
 	
	return 0;
}

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

namespace AtCoder.Abc172
{
    class C
    {
        public static void Main()
        {
            var k = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).Last();
            var a = ("0 " + Console.ReadLine()).Split(' ').Select(x => long.Parse(x)).ToArray();
            var b = ("0 " + Console.ReadLine()).Split(' ').Select(x => long.Parse(x)).ToArray();

            for (int i = 1; i < a.Length; i++)
                a[i] += a[i - 1];
            for (int i = 1; i < b.Length; i++)
                b[i] += b[i - 1];


            int max = 0;
            int j = b.Length - 1;
            for (int i = 0; i < a.Length; i++)
            {
                while (j >= 0 && a[i] + b[j] > k)
                    j--;

                if (j >= 0)
                    max = Math.Max(max, i + j);
                else
                {
                    while (i < a.Length && a[i] <= k)
                        max = Math.Max(max, i++);
                    break;
                }
            }
            Console.WriteLine(max);
        }
    }
}

Measured memory_bytes: 76032
a=-1,A=65,d;
char
*N="GKSOCNWLDFVTBRXHAJUPEMQI",
*E="PHLTIDOXQAGWECSUMBKVJFNR",
*R="BCDAFGHEJKLINOPMRSTQVWXU",
s[9];
main(c)
{
for(;c-48&&scanf("%s",s);a+=d/4+1)
{
(c=*s)<A?~a&&printf("%d\n",a),a=d=0:0;
d=c==78?d=N[d]-A:
c==69?d=E[d]-A:
c==82?d=R[d]-A:
c==83?d=N[N[N[d]-A]-A]-A:
c==87?d=E[E[E[d]-A]-A]-A:d;
d=c==76?d=R[R[R[d]-A]-A]-A:d;
}}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  set<char>s;
  while(n--){
    char c;cin>>c;
    s.insert(c);
  }
  if(s.size() == 3)cout<<"Three"<<endl;
  else cout<<"Four"<<endl;
  return 0;
}


Measured memory_bytes: 256
// In the name of God 
#include <bits/stdc++.h>

using namespace std ;

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

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = (int)1e5 + 10 ;

#define dec decrease 

int n , a [ N ] , inc [ N ] , dec [ N ] , dp [ N ] ; 

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n ;
	for ( int j = 0 ; j < n ; ++j )
		cin >> a [ j ] ; 
	for ( int j = 1 ; j < n ; ++j ) {
		if ( a [ j ] == a [ j - 1 ] ) {
			dec [ j ] = dec [ j - 1 ] ;
			inc [ j ] = inc [ j - 1 ] ; 
		}
		else if ( a [ j ] > a [ j - 1 ] ) {
			inc [ j ] = inc [ j - 1 ] ;
			dec [ j ] = j ; 
		}
		else {
			inc [ j ] = j ;
			dec [ j ] = dec [ j - 1 ] ; 
		}
	}
	dp [ 0 ] = 1 ; 
	for ( int j = 1 ; j < n ; ++j ) {
		dp [ j ] = dp [ j - 1 ] + 1 ;
		if ( !inc [ j ] || !dec [ j ] ) {
			dp [ j ] = 1 ;
			continue ;
		}
		dp [ j ] = min ( dp [ inc [ j ] - 1 ] + 1 , dp [ dec [ j ] - 1 ] + 1 ) ; 
	}
	cout << dp [ n - 1 ] << '\n' ; 
}


Measured memory_bytes: 3328
N, K = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

B = Array.new(N, 0)

K.times do
  B.fill(0)
  a.each_with_index do |c, i|
    l = (i - c) < 0 ? 0 : i - c
    r = (i + c) > N - 1 ? N - 1 : i + c

    B[l] += 1
    if r + 1 < N
      B[r + 1] -= 1
    end
  end

  min = N + 1
  1.upto(N - 1) do |i|
    B[i] += B[i - 1]
    min = B[i] < min ? B[i] : min
  end
  a = B.dup

  if min == N
    break
  end
end

puts a.join(" ")

Measured memory_bytes: 80608
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

ll cm(ll ind , vl &v)
{
    ll b = v[ind] ;
    ll sum = 0 ;
    ll n = ll(v.sz) ;
    forn(j , 0 , n - 1 ) {
       ll foo = abs(b - v[j]);
       sum = sum + foo ;
    }
    return sum ;
}

int main()
{
    ios;
    ll n ;
    cin >> n ;
    vl v;
    forn(i , 1 , n ) {
       ll x;
       cin >> x;
       v.pb(x) ;
    }
    forn(i , 1 , n ){
       v[i-1] = v[i-1] - i ;
    }
    sort(all(v));
    if(n <= 3){
    ll minn = 3e18 ;
    forn(i , 0 , n - 1) {
       ll b = v[i];
       ll sum =  0 ;
       forn(j , 0 , n - 1 ) {
          ll foo = abs(b - v[j]);
          sum = sum + foo ;
       }
       minn = min(minn , sum );
    }
    cout << minn << el ;
    }
    else {
        ll foo = n / 2 ;
        ll r1 = cm(foo , v);
        ll r2 = cm(foo - 1 , v) ;
        ll r5 = cm(foo + 1 , v) ;
        ll ans = min(r1 , min(r2 , r5));
        cout << ans << el ;
    }

}































Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  cout << (char)toupper(s1.at(0)) << (char)toupper(s2.at(0)) << (char)toupper(s3.at(0));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vs s(2);
    cin>>s[0]>>s[1];
    
    int res=1;
    bool tate;
    rep(i,n){
        if(s[0][i]==s[1][i]){
            if(i==0){
                res*=3; res%=MOD;
                tate=true;
            }else if(tate==true){
                res*=2; res%=MOD;
                tate=true;
            }else{
                res%=MOD;
                tate=true;
            }
        }else{
            if(i==0){
                res*=6; res%=MOD;
                tate=false;
            }else if(tate==true){
                res*=2; res%=MOD;
                tate=false;
            }else{
                res*=3; res%=MOD;
                tate=false;
            }
            i++;
        }
    }
    cout<<res<<endl;
}   

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        int r = Integer.parseInt(br.readLine());
        int rm = r;
        r = Integer.parseInt(br.readLine());
        int ans = r-rm;
        if(r<rm) rm = r;
        for(int i = 2; i<n; i++){
            r = Integer.parseInt(br.readLine());
            if(ans<r-rm) ans = r-rm;
            if(r<rm) rm = r;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 42192
#include <iostream>
#include <math.h>
#include <cstdio>
using namespace std;

int main(){
	double d1=0,d2=0,d3=0,di=0;
	int n,m,i,j;
	cin >> n;
	int x[n]={},y[n]={};
	for(i=0;i<n;i++){
		cin >> x[i];
	}
	for(i=0;i<n;i++){
		cin >> y[i];
	}
	for(i=0;i<n;i++){
		j=x[i]-y[i];
		if(j<0){
			j=j*(-1);
		}
		d1 += j;
		d2 += pow(j,2);
		d3 += pow(j,3);
		if(di<j){
			di=j;
		}
	}
	d2=pow(d2,1./2);
	d3=pow(d3,1./3);
	printf("%.8f\n%.8f\n%.8f\n%.8f\n",d1,d2,d3,di);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
    
  sort(vec.begin(), vec.end());
  
  int x = 1;
  
  for (int i = 0; i < N-1; i++) {
    if (vec.at(i) < vec.at(i+1)) {  
      x++;
    }  
  }
  
  cout << x << endl;
    
}


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

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef vector <ii> vii;
typedef vector <vi> graph;

int n;
ll arr[100010];
ll dp[100010];

ll piedra(int id) {
	if (id == n - 1) return 0;
	if (id >= n) return 1000000000;
	if (dp[id] != -1) return dp[id];
	ll temp1, temp2;
	temp1 = abs(arr[id] - arr[id + 1]) + piedra(id + 1);
	temp2 = abs(arr[id] - arr[id + 2]) + piedra(id + 2);
	return dp[id] = min(temp1, temp2);
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> arr[i];
	}
	for (int i = 0; i < 100010; ++i)
	{
		dp[i] = -1;
	}
	cout << piedra(0) << "\n";
    return 0;
}


Measured memory_bytes: 4992
lst = [int(input()) for i in range(5)]
k = int(input())

for i in range(5):
  for j in range(i+1,5):
    tmp = lst[j] - lst[i]
    #print(tmp)
    if tmp > k:
      break
  if tmp > k:
    print(":(")
    break
else:
  print("Yay!")

Measured memory_bytes: 3060
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    a=[parseInt(readline()) for i in 1:5]
    ans=cld(n,a[1])
    for i in 2:5
        if a[i]>=a[i-1]
            ans+=1
        else
            ans+=cld(n,a[i])-cld(n,a[i-1])+1
        end
        a[i]=min(a[i],a[i-1])
    end
    println(ans)
end
main()

Measured memory_bytes: 111836
//SLE
#include<iostream>
using namespace std;

int main()
{
	int a,b;
	cin >> a >> b;
	if (a>b)
		cout << "a > b" << endl;
	else if (a<b)
		cout << "a < b" << endl;
	else 
		cout << "a == b" << endl;
	return 0;
}


Measured memory_bytes: 3044
#include<stdio.h>
int A[100000000];
int n;

int binarySearch(int);

int main()
{
  int i,q,k,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&k);
      if(binarySearch(k)==1)count++;
    }
  printf("%d\n",count);
  return 0;
}
  
int binarySearch(int key)
{
  int  left = 0;
  int right = n;
  int mid;
  while (left < right)
    {
      mid = (left + right) / 2;
      if( A[mid] == key)return 1;
      if( key > A[mid]) left = mid+1;
      else if(key<A[mid]) right = mid;
    }
  return 0;
}



Measured memory_bytes: 2156
N=int(input())
H=list(map(int,input().split()))
A,a=0,0
C=[0]*N
H=H[::-1]
for i in range(N-1):
  if H[i]<=H[i+1]:
    A+=1
  else:
    C[a]=A
    a+=1
    A=0
C[a]=A
print(max(C))

Measured memory_bytes: 14228
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
ll Zero_xor(ll a){
     ll half;
     half = a / 2;
     if(a % 2 == 0){
          if(half % 2 == 0){
               return a;
          }else{
               return 1^a;
          }
     }else{
          if(half % 2 == 0){
               return 1;
          }else{
               return 0;
          }
     }
}
int main(){
     ll A,B;
     ll result,tempA,tempB;
     cin >> A >> B;
     tempA = Zero_xor(A-1);
     tempB = Zero_xor(B);
     result = tempA ^ tempB;
     if(A == 0){
          cout << tempB << endl;
     }else{
          cout << result << endl;
     }
     return 0;
}

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

int main()
{
    int sx, sy, tx, ty;
    scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
    for (int y = sy; y < ty; y++) {
        printf("U");
    }
    for (int x = sx; x < tx; x++) {
        printf("R");
    }
    for (int y = ty; y > sy; y--) {
        printf("D");
    }
    for (int x = tx; x > sx; x--) {
        printf("L");
    }
    printf("L");
    for (int y = sy; y < ty + 1; y++) {
        printf("U");
    }
    for (int x = sx - 1; x < tx; x++) {
        printf("R");
    }
    printf("D");
    printf("R");
    for (int y = ty; y > sy - 1; y--) {
        printf("D");
    }
    for (int x = tx + 1; x > sx; x--) {
        printf("L");
    }
    printf("U\n");
}

Measured memory_bytes: 256
n=int(input())
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))

s=[]
for i in range(n):
  for j in range(i+1,n):
    s.append((a[i][j],i,j))
s.sort()

c=0
for i in s:
  mn=10**10
  for j in range(n):
    if i[1]==j or i[2]==j:
      continue
    mn=min(mn,a[i[1]][j]+a[i[2]][j])
  if mn>a[i[1]][i[2]]:
    c+=a[i[1]][i[2]]
  elif mn<a[i[1]][i[2]]:
    c=-1
    break
print(c)

Measured memory_bytes: 76416
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    double ans = 0;
    rep(i,n){
        double x; cin >> x;
        string u; cin >> u;
        if(u == "JPY") ans += (double)x;
        else ans += (double)x * 380000.0;
    }
    ANS;

    return 0;
}

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

int main(){
  long n,m,i,cur,mod=1000000007;
  cin >> n >> m;
  vector<long> ans(n+1);
  for(i=0; i<m; i++){
    cin >> cur;
    ans[cur]=-1;
  }
  ans[0]=1;
  ans[1]+=1;
  for(i=2; i<=n; i++){
    if(ans[i]<0){
      ans[i]=0;
    }else{
      ans[i]=(ans[i-1]+ans[i-2])%mod;
    }
  }
  cout << ans[n];
}


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

#define mp make_pair

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef pair<i64,int> pli;
typedef pair<int,i64> pil;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;

template <typename T>
T id(T b) {return b;};
template <class It>
bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool any(It f,It l){return std::any_of(f,l,id<bool>);}

int n;
i64 k;

map<int,i64> m;

int main()
{
  cin >> n >> k;
  int a,b;
  for (int i = 0; i < n; ++i) {
    cin >> a >> b;
    m[a] += b;
  }

  i64 c = 0;
  for (pil p : m) {
    c += p.second;
    if (c >= k) {
      cout << p.first << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 4224
# https://img.atcoder.jp/abc123/editorial.pdf 解法 #1 - 工夫したソートで O(K^2 log K)

def solve(X, Y, Z, K, A, B, C):
    AB = []
    [AB.append(a + b) for a in A for b in B]
    AB.sort(reverse=True)
    AB = AB[:K]

    ABC = []
    [ABC.append(ab + c) for ab in AB for c in C]
    ABC.sort(reverse=True)
    ABC = ABC[:K]

    print("\n".join(map(str, ABC)))

if __name__ == "__main__":
    X, Y, Z, K = list(map(int, input().split()))
    A = sorted(list(map(int, input().split())), reverse=True)
    B = sorted(list(map(int, input().split())), reverse=True)
    C = sorted(list(map(int, input().split())), reverse=True)
    solve(X, Y, Z, K, A, B, C)

Measured memory_bytes: 198492
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
int main() {
	ll x;
	cin>>x;
	ll rem=x%500;
	ll a=x/500;
	ll b=rem/5;
	
	cout<<(a*1000)+(b*5)<<endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
haiten = []
n.times do
  haiten << gets.chomp.to_i
end
sum = haiten.inject(:+)
if (sum%10 != 0)
  puts sum
  exit
end
haiten.sort.each do |h|
  if (h%10 != 0)
    puts sum - h
    exit
  end
end

puts 0

Measured memory_bytes: 1788
//y17-8
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)
int main(){

    int W,H,N;
    cin >> W >> H >> N;

    int m[100000];
    for(int i=0; i<W; i++){
        m[i] = 0;
    }
    for(int i=0; i<N; i++){
        int x,y;
        cin >> x >> y;
        m[x-1] = max(m[x-1], y);
    }
    int tmp = 0;
    for(int i=W-1; i>=0; i--){
        tmp = max(tmp, m[i]);
        m[i] = tmp;
    }

    int ans = INT_MAX;
    for(int i=0; i<W; i++){
        //cout << m[i] << endl;
        ans = min(ans, i+m[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3468
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N, K;
  cin >> N >> K;
  vector<lint> A(N);
  REP(i, N) cin >> A[i];
  lint l = 0;
  lint r = 1e9+1;
  while(r-l > 1) {
    lint m = (l+r) / 2;
    lint cnt = 0;
    REP(i, N) cnt += (A[i] - 1) / m;
    if(cnt <= K) r = m;
    else l = m;
  }
  cout << r << endl;
}

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

int main()
{
    string s1,s2;
    cin >> s1 >> s2;
    reverse(s1.begin(),s1.end());
    if(s1 == s2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int Mod=1e9+7;
int main(){
	int n;
	cin>>n;
	if(n==1){
		cout<<0<<endl;
		return 0;
	}
	long long ans=1;
	for(int i=1;i<=n;i++){
		ans=ans*10%Mod;
	}
	long long minus=1;
	for(int i=1;i<=n;i++){
		minus=minus*9%Mod;
	}
	long long add=1;
	for(int i=1;i<=n;i++){
		add=add*8%Mod;
	}
	cout<<(ans-minus*2%Mod+add+Mod)%Mod;
	return 0;
} 

Measured memory_bytes: 3632
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
 
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; }
 
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int x,y;
  cin>>x>>y;
  
  if(y%2==1) cout<<"No"<<endl;
  else{
    if(y/2-x>=0 && 2*x-y/2>=0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  
  return 0;
}

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

int main() {
  int K, S;
  cin >> K >> S;
  int ctn = 0;
  for (int i = 0; i < K+1; i++) {
    for (int j = 0; j < K+1; j++) {
      if (0 <= S-i-j && S-i-j <= K) {
        ctn++;
      }
    }
  }
  cout << ctn << endl;
}

Measured memory_bytes: 256