akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int N,M,X;
int C[20],A[20][20],D[20];
int min_S=-1;
void f(int p,int S){
  int c=1;
  for(int i=1;i<=M;i++){
    if(D[i]<X) c=0;
  }
  if(c==1){
    if(min_S<0 || S<min_S){
      min_S=S;
      return;
    }
  }
  for(int i=p+1;i<=N;i++){
    for(int j=1;j<=M;j++){
      D[j]+=A[i][j];
    }
    f(i,S+C[i]);
    for(int j=1;j<=N;j++){
      D[j]-=A[i][j];
    }
  }
  return;
}
int main(){
  scanf("%d %d %d",&N,&M,&X);
  for(int i=1;i<=N;i++){
    scanf("%d",C+i);
    D[i]=0;
    for(int j=1;j<=M;j++){
      scanf("%d",&A[i][j]);
    }
  }
  f(0,0);
  printf("%d\n",min_S);
}

Measured memory_bytes: 1692
n = int(input())
s = str(input())

def z_algorithm(s):
    n = len(s)
    Z = [0]*n
    Z[0] = n
    i = 1
    j = 0
    while i < n:
        while i+j < n and s[j] == s[i+j]:
            j += 1
        Z[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k < n and k+Z[k] < j:
            Z[i+k] = Z[k]
            k += 1
        i += k
        j -= k
    return Z

s = list(s)
s.reverse()
import copy
ans = 0
for i in range(n):
    if i != 0:
        s.pop()
    t = copy.copy(s)
    t.reverse()
    t = ''.join(t)
    Z = z_algorithm(t)
    for i, z in enumerate(Z):
        ans = max(ans, min(i, z))
print(ans)


Measured memory_bytes: 53036
import java.io.*;
import java.util.*;

public class Main {
    void run() {
        int N = readInt();
        int M = readInt();
        int[][] A = new int[N][M];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < M; j++) {
                A[i][j] = readInt();
            }
        }
        int[] b = new int[M];
        for (int i = 0; i < M; i++) {
            b[i] = readInt();
        }
        for (int i = 0; i < N; i++) {
            int ans = 0;
            for (int j = 0; j < M; j++) {
                ans += A[i][j] * b[j];
            }
            sysout.println(ans);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }

    // flush automatically iff you call `println` or `printf` or `format`.
    PrintWriter sysout = new PrintWriter(System.out, true);

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer buffer = null;

    String readLine() {
        buffer = null;
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    String read() {
        if (buffer == null || !buffer.hasMoreTokens()) {
            buffer = new StringTokenizer(readLine());
        }
        return buffer.nextToken();
    }

    int readInt() {
        return Integer.parseInt(read());
    }

    long readLong() {
        return Long.parseLong(read());
    }

    double readDouble() {
        return Double.parseDouble(read());
    }
}

Measured memory_bytes: 22396
# -*- coding: utf-8 -*-
"""
AtCoder B
"""

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = int(input()) for _ in range(N) # 1 row N column

# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']

def main():
    R, G, B, N = list(map(int,input().split()))
    tmp=0
    rb=0
    while rb*R<=N:
        ball=rb*R
        gb=0
        while gb<N-rb*R+1:
            ball_g=gb*G
            gball=ball_g+ball
            if N>=gball and (N-gball)%(B)==0:
                tmp+=1
            gb+=1
        rb+=1

    print(tmp)
    
if __name__ == "__main__":
    main()

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

int main(){
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  if (abs(a - c) <= d) {
    puts("Yes");
  } else if (abs(a - b) <= d && abs(b - c) <= d) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double dp[305][305][305];
double dish(int a,int b,int c,int n){
	if(a<0 or b<0 or c<0)
		return 0;
	if(a==0 and b==0 and c==0)
		dp[a][b][c]=0;
	if(dp[a][b][c]==-1){
		dp[a][b][c]=(a*dish(a-1,b+1,c,n)+b*dish(a,b-1,c+1,n)+c*dish(a,b,c-1,n)+n)/(a+b+c);
	}
	return dp[a][b][c];
}
int main(){
	int n;
	cin >> n;
	std::fill_n(&dp[0][0][0],305*305*305,-1.0);
	int a=0,b=0,c=0;
	for(int i=0;i<n;i++){
		int x;
		cin >> x;
		if(x==3)
			a++;
		else if(x==2)
			b++;
		else
			c++;
	}
	cout << setprecision(50) << dish(a,b,c,n) << endl;
}

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

import collections


Point = collections.namedtuple("Point", "x y idx")


def manhattan_dist(p1, p2):
    return abs(p1.x - p2.x) + abs(p1.y - p2.y)


def find_res_point(st, ps):
    def key(p):
        return (manhattan_dist(st, p), p.idx)
    return min(ps, key=key)


def solve(sts, ps):
    return (find_res_point(st, ps) for st in sts)


def main():
    n, m = (int(x) for x in input().split())
    sts = []
    for i in range(n):
        a, b = (int(x) for x in input().split())
        sts.append(Point(a, b, i + 1))
    ps = []
    for j in range(m):
        c, d = (int(x) for x in input().split())
        ps.append(Point(c, d, j + 1))
    for p in solve(sts, ps):
        print(p.idx)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3436
/**
 * Created by hiramekun at 08:21 on 2019-11-24.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll h, w, k;
    cin >> h >> w >> k;

    vector<string> s(h);
    vector<bool> hasS_tate(h), hasS_yoko(w);
    rep(i, h) cin >> s[i];

    vector<vector<ll>> ans(h, vector<ll>(w));
    vector<ll> s_idx;
    rep(i, k) s_idx.emplace_back(i + 1);

    auto dfs = [&](auto &&f, ll l, ll r, ll u, ll d, ll num) {
        if (l < 0 || w < r || u < 0 || h < d) return;
        if (r <= l || d <= u) return;
        ll prev_i = -1, prev_j = -1;
        for (ll i = u; i < d; ++i) {
            for (ll j = l; j < r; ++j) {
                if (s[i][j] != '#') continue;
                if (prev_i == -1) {
                    prev_i = i, prev_j = j;
                    continue;
                }

                ll next = s_idx.back();
                s_idx.pop_back();
                if (i != prev_i) { // 縦に分ける
                    f(f, l, r, u, i, num);
                    f(f, l, r, i, d, next);
                    return;
                }
                if (j != prev_j) { // 横に分ける
                    f(f, l, j, u, d, num);
                    f(f, j, r, u, d, next);
                    return;
                }
            }
        }
        for (ll i = u; i < d; ++i) {
            for (ll j = l; j < r; ++j) {
                ans[i][j] = num;
            }
        }
    };
    ll num = s_idx.back();
    s_idx.pop_back();
    dfs(dfs, 0, w, 0, h, num);
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 2420
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOZ
{
	class MainClass
	{
		static void Main(string[] args)
		{
			var input_arr = Console.ReadLine().Split(' ');
			double r = double.Parse(input_arr[0]);
			double area = Math.PI * Math.Pow(r, 2);
			double circumference = 2 * Math.PI * r;
			Console.WriteLine($"{area:F6} {circumference:F6}");
		}
	}
}



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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;


int main(){
	
	vector<int> v(4);
	REP(i,4)cin >> v[i];
	sort(ALL(v));
	if(v[0] == 1 && v[1] == 4 && v[2] == 7 && v[3] == 9){
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
from sys import stdin


def sp(G,R,V):
    d = {}
    INF = float('inf')
    for i in range(V):
        d[i] = INF
    d[R] = 0
    q = deque([(R)])
    while q:
        u = q.popleft()
        for v in G[u].keys():
            if d[v] > d[u] + G[u][v]:
                d[v] = d[u] + G[u][v]
                q.append(v)
    return d


V, E, R = [int(x) for x in stdin.readline().split(' ')]
G = defaultdict(dict)
for case in range(E):
    s, t, w = [int(x) for x in stdin.readline().split(' ')]
    G[s][t] = w
d = sp(G, R, V)
for k in range(V):
        if d[k] == float('inf'):
            print("INF")
        else:
            print(d[k])

Measured memory_bytes: 98988
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int A = nextInt();

        for(int i=1; i<10; i++){
            if(A%i == 0) {
                if(A/i < 10) {
                    println("Yes");
                    return;
                }
            }
        }

        println("No");
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 23380
#include <iostream>
#include <string>

int main()
{
    int N;
    std::string str;
    std::cin >> N >> str;

    size_t pos = 0, cnt = 0;
    while (true) {
        pos = str.find("ABC", pos);
        if (pos == std::string::npos) {
            break;
        }
        pos++;
        cnt++;
    }
    std::cout << cnt << std::endl;
}


Measured memory_bytes: 256
program main
  implicit none
  integer i, H, W, K, j, ans, l, m, s, v
  integer,allocatable :: G(:,:), G0(:,:)
  character(6) c
  read(*, *)H, W, K
  allocate(G(H,W))
  allocate(G0(H,W))
  do i = 1,H
    read(*, *) c
    do j = 1,W
      if (c(j:j) == '.') then
        G0(i,j) = 0
      else if (c(j:j) == '#') then
        G0(i,j) = 1
      end if
    end do
  end do

  ans = 0

  do i = 0,2**(H + W)-1
    s = i
    G = G0
    v = H + W -1
    do j = 1,H
      if (s >= 2**v) then
        do l = 1,W
          G(j,l) = 0
        end do
        s = s-2**v
      end if
      v = v-1
    end do
    do j = 1, W
      if (s >= 2**v) then
        do l = 1,H
          G(l,j) = 0
        end do
        s = s-2**v
      end if
      v = v-1
    end do
    m = sum(G)
    !write(*, *) G
    if (m == K) then
      ans = ans + 1
    end if
  end do
  !read(*, *) (L(i), i = 1,N)

  write(*, *) ans
end program main


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

int main(){
  int e,a,b,W;
cin>>a;
  e=0;
vector<int>L(2*a);
for(int i=0;i<2*a;i++){
  cin>>L[i];
}
  sort(L.begin(),L.end());
  for(int j=0;j<a;j++){
    e+=L[2*j];
  }

   cout<<e<<endl;
    }


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


int main() {

    int n, k;
    cin >> n >> k;
    ll t1 = n / k;
    ll t2 = t1 + (n % k >= k / 2);
    if(k%2)
        cout << t1 * t1 * t1;
    else
        cout << t1 * t1 * t1 + t2 * t2 * t2;

    return 0;
}


Measured memory_bytes: 3620
'use strict';

const input = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const NM = input[0].split(' ').map(Number);
const N = NM[0];
const M = NM[1];
const As = input.slice(1, N + 1);
const Bs = input.slice(N + 1, N + M + 1);

for (let ax = 0; ax < N - M + 1; ax++) {
    for (let ay = 0; ay < N - M + 1; ay++) {
        let flag = true;
        for (let bx = 0; bx < M; bx++) {
            for (let by = 0; by < M; by++) {
                if (As[ax + bx][ay + by] !== Bs[bx][by]) {
                    flag = false;
                    break;
                }
            }
            if (!flag) break;
        }

        if (flag) {
            console.log('Yes');
            process.exit(0);
        }
    }
}
console.log('No');

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

class UnionFind {
public:
  vector<int> par, rank;
  UnionFind(int sz) : par(sz, -1), rank(sz, 0){}
  int find(int x){
    if(par[x]<0) return x;
    else return par[x] = find(par[x]);
  }
  void unite(int x, int y){
    x=find(x); y=find(y);
    if(x==y) return;
    if(rank[x] < rank[y]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
    if(rank[x]==rank[y]) rank[x]++;
  }
  inline bool same(int x, int y){ return find(x) == find(y); }
  inline int size(int x){ return -par[find(x)]; }
  inline bool isroot(int x) const { return par[x] < 0; }
};

vector<pair<int,int>> g[100005]; // <to ,idx>

int main(){
  int n,m;
  cin>>n>>m;
  vector<long> w(n);
  rep(i,n) cin>>w[i];
  vector<pair<int,int>> e(m);
  vector<long> ew(m);
  rep(i,m) {
    int a,b;
    cin>>a>>b;
    a--;b--;
    e[i] = {a,b};
    cin>>ew[i];
    g[a].pb({b, i});
    g[b].pb({a, i});
  }

  if(m==0){
    cout << 0 << endl;
    return 0;
  }

  vector<bool> candidate(m, false);
  vector<long> sz(n,0);
  vector<int> ord(m);
  rep(i,m) ord[i] = i;
  sort(all(ord), [&](auto &l, auto &r){
    return ew[l] < ew[r];
  });

  UnionFind uf(n);
  rep(i,n) sz[i] = w[i];

  for(int i : ord){
    int a = e[i].first, b = e[i].second;dbg(i,a,b,sz);
    if(!uf.same(a,b)) {
      long nv = sz[uf.find(a)] + sz[uf.find(b)];
      uf.unite(a,b);
      sz[uf.find(a)] = nv;
    }

    if(sz[uf.find(a)] >= ew[i]) candidate[i] = true;
  }
  dbg(candidate);

  vector<bool> use(m, false);
  reverse(all(ord));
  for(int i : ord) if(candidate[i] && !use[i]){dbg(i);
    use[i] = true;
    queue<int> q;
    q.push(e[i].first);
    q.push(e[i].second);
    while(!q.empty()){
      int v = q.front(); q.pop();dbg(v);
      for(auto to : g[v]) if(ew[to.second] <= ew[i] && !use[to.second]){
        use[to.second] = true;
        q.push(to.first);
      }
    }
  }
  dbg(use);

  int ans = 0;
  rep(i,m) if(!use[i]) ans++;
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 10624
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <boost/math/common_factor.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
#define REP(i, N) for(int i=0; i<(N); i++)
using namespace std;

int main() {
	int N;

	cin >> N;

  vector<int> A(N);
    for (auto& i : A)
      cin >> i;

      bool tootta = true;
      for (int k = 0; k < N-1; k++)
        if (A[k] >A[k+1])
          tootta = false;
      if (tootta) {
        cout << "YES" << endl;
        return 0;
      }

  REP(i, N)
    for (int j = i + 1; j < N; j++) {
      bool tootta = true;
      swap(A[i], A[j]);
      for (int k = 0; k < N-1; k++)
        if (A[k] >A[k+1])
          tootta = false;
      if (tootta) {
        cout << "YES" << endl;
        return 0;
      }
      swap(A[i], A[j]);
    }
	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int ans = 1;
    for (int i = 0; i < n; ++i) {
        int a = ans * 2;
        int b = ans + k;
        ans = (a < b) ? a : b;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(all(a));
    vector<ll> s(n+1,0);
    rep(i,n) s[i+1]=s[i]+a[i];
    int ans=1;
    bool ok[n];
    rep(i,n) ok[i]=false;
    ok[n-1]=true;
    for(int i=n-1;i>=1;i--){
        if(ok[i] && s[i]*2>=a[i]){
            ans++;
            ok[i-1]=true;
        }
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef unsigned long long ll;
const int maxn = 40005;
const int mod = 1000000007;

int n,m,sqrtn;


void upd(ll&ret,ll val){
  ret+=val;
  if(ret>=mod)ret-=mod;
}

ll f1[maxn],f2[maxn];
ll add1[maxn],add2[maxn];
void solve() {
  memset(add1,0,sizeof(add1));
  memset(add2,0,sizeof(add2));
  for(int i=1;i<=sqrtn;i++){
    upd(add1[1],f1[i]);
    upd(add2[i],f1[i]);
  }
  for(int i=1;i<=sqrtn;i++){
    upd(add1[1],f2[i]);
    upd(add1[i+1], (mod-f2[i])%mod);
  }
  ll cur = 0;
  for(int i=1;i<=sqrtn;i++){
    upd(cur,add1[i]);
    f1[i]=cur;
  }
  cur = 0;
  for(int i=1;i<=sqrtn;i++){
    ll r = n/i;
    ll l = max(sqrtn,n/(i+1));
    if(r>sqrtn&&r>l) {
      upd(cur, add2[i]);
      f2[i] = cur*(r-l)%mod;
    } else break;
  }
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  cin>>n>>m;
  sqrtn = (int)sqrt(n);
  for(int i=1;i<=sqrtn;i++)f1[i]=1;
  for(int i=1;;i++){
    int r = n/i;
    if(r<=sqrtn)break;
    int l = n/(i+1);
    l=max(sqrtn, l);
    f2[i]=r-l;
  }
  for(int i=1;i<m;i++)solve();
  ll ret = 0;
  for(int i=1;i<=sqrtn;i++)ret=(ret+f1[i])%mod;
  for(int i=1;i<=sqrtn;i++)ret=(ret+f2[i])%mod;
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 1408
N = int(input())
T, A = map(float, input().split())
H = list(map(int, input().split()))
ans_N = 100000000

for i in range(N):
    # print(abs(T - H[i] * 0.006 - A))
    if ans_N > abs(T - H[i] * 0.006 - A):
        ans_N = abs(T - H[i] * 0.006 - A)
        ans = i+1

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M;
    cin >> N >> M;
    if (N == M)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
from itertools import combinations

H,W,K = map(int, input().split())

grid = np.zeros([H,W],dtype=int)
for i in range(H):
  row = input().replace('.', '0').replace('#', '1')
  for j in range(W):
  	grid[i,j]=int(row[j])

grid2 = grid.copy()
count = 0
for i in range(-1, H):
  for j in range(-1, W):
    if i != -1 and j != -1:
      for p in combinations(range(H), i+1):
      	for q in combinations(range(W), j+1):
          grid2[p, :] = 0
          grid2[:, q] = 0
          if grid2.sum() == K: 
            count += 1
            #print(p, q)
          grid2 = grid.copy()
    
    elif i == -1 and j != -1:
      for q in combinations(range(W), j+1):
        grid2[:, q] = 0
        if grid2.sum() == K: 
          count += 1
          #print(q)
        grid2 = grid.copy()
    
    elif i != -1 and j == -1:
      for p in combinations(range(H), i+1):
        grid2[p, :] = 0
        if grid2.sum() == K:
          count += 1
          #print(p)
        grid2 = grid.copy()
    
    else:
      if grid2.sum() == K:
        count += 1
        #print(-1)
      grid2 = grid.copy()
          
print(count)

Measured memory_bytes: 27248
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BPowerSocket {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int A, B;
        in>>A>>B;
        out<<(B-1+A-2)/(A-1)<<'\n';
    }
};


int main() {
	BPowerSocket solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

int main()
{
    int H, W;
    cin >> H >> W;
    for (int i = 0; i <= W + 1; i++)
    {
        cout << "#";
    }
    cout << endl;

    for (int i = 0; i < H; i++)
    {
        string str;
        cin >> str;
        cout << "#" << str << "#" << endl;
    }
    for (int i = 0; i <= W + 1; i++)
    {
        cout << "#";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define endl '\n'
#define mem(a,b) memset(a,b,sizeof(a))
#define IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int maxn=1e5+5;
int n,a,b,c;
string s[maxn];
vector<char> vec;
int flag;
void dfs(int x,int a,int b,int c){
	if(flag) return ;
	if(x==n+1&&a>=0&&b>=0&&c>=0){
		flag=1;
		puts("Yes");
		for(int i=0;i<n;i++) cout<<vec[i]<<endl;
		return ;
	}
	if(s[x][0]=='A'&&s[x][1]=='B'){
		if(a+1>=0&&b-1>=0&&c>=0){
			vec.push_back('A');
			dfs(x+1,a+1,b-1,c);
			vec.pop_back();
		}
		if(a-1>=0&&b+1>=0&&c>=0){
			vec.push_back('B');
			dfs(x+1,a-1,b+1,c);
			vec.pop_back();			
		}
	}
	else if(s[x][0]=='A'&&s[x][1]=='C'){
		if(a+1>=0&&b>=0&&c-1>=0){
			vec.push_back('A');
			dfs(x+1,a+1,b,c-1);
			vec.pop_back();
		}
		if(a-1>=0&&b>=0&&c+1>=0){
			vec.push_back('C');
			dfs(x+1,a-1,b,c+1);
			vec.pop_back();			
		}		
	}
	else if(s[x][0]=='B'&&s[x][1]=='C'){
		if(a>=0&&b-1>=0&&c+1>=0){
			vec.push_back('C');
			dfs(x+1,a,b-1,c+1);
			vec.pop_back();
		}
		if(a>=0&&b+1>=0&&c-1>=0){
			vec.push_back('B');
			dfs(x+1,a,b+1,c-1);
			vec.pop_back();			
		}		
	}
}
int main(){
	cin>>n>>a>>b>>c;flag=0;
	for(int i=1;i<=n;i++) cin>>s[i];
	dfs(1,a,b,c);
	if(!flag) puts("No");
}


Measured memory_bytes: 14572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll INF = LLONG_MAX/3;
const int N = 100000;

struct edge{
    int to;
    ll cost;
};

vector<edge> G[N];
ll x[N];

void dfs(int v){
    for(const auto &e:G[v]){
        if(x[e.to]==INF){
            x[e.to] = x[v]+e.cost;
            dfs(e.to);
        }
    }
}

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

    vector<int> l(m),r(m),d(m);
    rep(i,m){
        cin >>l[i] >>r[i] >>d[i];
        --l[i];
        --r[i];

        G[l[i]].pb({r[i],d[i]});
        G[r[i]].pb({l[i],-d[i]});
    }

    fill(x,x+N,INF);
    rep(i,n){
        if(x[i]==INF){
            x[i] = 0;
            dfs(i);
        }
    }

    string ans = "Yes";
    rep(i,m){
        if(x[r[i]] - x[l[i]] !=  d[i]) ans = "No";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 18816
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int i = n / 111;
        if (n % 111 != 0) {
            i += 1;
        }

        System.out.println(i * 111);
    }
}


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

int main(){
	
	int k=0,u=0,p=0,c=0,i;
	string kupc;
	
	cin >> kupc;
	for(i=0;i<kupc.size();i++){
		if(kupc[i]=='K') k++;
		if(kupc[i]=='U') u++;
		if(kupc[i]=='P') p++;
		if(kupc[i]=='C') c++;
	}
	
	cout << min(k,min(u,min(p,c))) << endl;
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define mp make_pair
using namespace std;
const int MX = 1007;
const int LIM = 2e5+3;
const int MLOG = 25;
int arr[LIM+3];
int main(){
    
    int a,b;cin >> a >> b;
    int mx = a*b;
    mx = max(mx,a+b);
    mx = max(mx,a-b);
    cout << mx << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


#line 1 "lib/modint.hpp"



#include <iostream>

// Modint
struct Mint {
    static const long long mod = (long long)1e9 + 7;
    long long val;

    Mint() { val = 0; }
    Mint(long long a) { val = a; verify_value(); }

    void verify_value() {
        if (val >= mod) val %= mod;
        if (val < 0) val %= mod, val += mod;
    }

    Mint pow(long long p) const {
        Mint cur = Mint(val), ret = 1;
        while (p > 0) {
            if (p & 1) ret *= cur;
            cur *= cur;
            p >>= 1LL;
        }
        return ret;
    }
    Mint inv() const {
        if (val == 0)
            std::cerr << "WARNING: inv() is called with 0." << std::endl;
        return pow(mod - 2);
    }

    Mint operator+() const { return *this; }
    Mint operator-() const { return Mint(mod - val); }

    Mint operator+=(const Mint &a) {
        val += a.val;
        if (val >= mod) val -= mod;
        return Mint(val);
    }
    Mint operator*=(const Mint &a) {
        val *= a.val;
        if (val >= mod) val %= mod;
        return Mint(val);
    }
    Mint operator-=(const Mint &a) { return *this += -a; }
    Mint operator/=(const Mint &a) { return *this *= a.inv(); }

    Mint operator++() { return *this += Mint(1); }
    Mint operator--() { return *this -= Mint(1); }
    Mint operator++(int) {
        Mint ret = *this;
        ++(*this);
        return ret;
    }
    Mint operator--(int) {
        Mint ret = *this;
        --(*this);
        return ret;
    }

    operator long long() const { return val; }
};

Mint operator+(const Mint &a, const Mint &b) {
    long long ret = a.val + b.val;
    if (ret >= Mint::mod) ret -= Mint::mod;
    return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
    long long ret = a.val * b.val;
    if (ret >= Mint::mod) ret %= Mint::mod;
    return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

std::ostream &operator<<(std::ostream &out, const Mint &a) { return out << a.val; }
std::istream &operator>>(std::istream &in, Mint &a) {
    in >> a.val;
    a.verify_value();
    return in;
}

Mint pow(Mint a, long long b) {
    return a.pow(b);
}


int main() {
    int n; std::cin >> n;
    std::string s; std::cin >> s;
    std::vector<Mint> cnt(30);
    for (char c : s) cnt[c - 'a']++;
    Mint ans = 1;
    for (int i = 0; i <= 26; i++) {
        ans *= cnt[i] + Mint(1);
    }
    std::cout << ans - Mint(1) << std::endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int read() {
	int x = 0,f = 0;char ch = getchar();
	while(!isdigit(ch)) {if(ch=='-')f=1;ch=getchar();}
	while(isdigit(ch)) {x = x * 10 + ch - '0';ch = getchar();}
	return f?-x:x;
}
const int N = 2e5+1000;
struct Node{LL x,y;}a[N];
int n,X[N],Y[N];
int main()
{
	n = read();
	for(int i = 1;i <= n;i++) {
		int x = read();
		int y = read();
		X[i] = x+y;Y[i] = x-y;
	}
	sort(X+1,X+1+n);sort(Y+1,Y+1+n);
	cout << max(X[n]-X[1],Y[n]-Y[1]) << endl;
	return 0;
}



Measured memory_bytes: 5188
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,K = inpl()

if N%K == 0:
	print(0)
else:
	print(1)

Measured memory_bytes: 4456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;
    int MOD = 1000000007;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        solve();
    }

    void solve() {
        System.out.println(fillFactorial(n, MOD)[n]);
    }

    long[] fillFactorial(int max, int mod) {
        long[] facts = new long[max + 1];
        facts[0] = 1;
        for (int i = 1; i < facts.length; i++) {
            facts[i] = facts[i - 1] * i % mod;
        }
        return facts;
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21076
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
long A[200001];
long DP[5*200001];
void Calc(){
	int N = rei();
	for(int i=1;i<=N;i++){
		A[i] = rel();
	}
	for(int i=0;i<5*N+5;i++){
		DP[i] = 10000000000000000;
	}
	DP[0] = 0;
	for(int i=1;i<=N;i++){
		DP[i*5] = DP[i*5-5] + A[i];
		DP[i*5+4] = min({DP[i*5-5],DP[i*5-5+1],DP[i*5-5+2],DP[i*5-5+3],DP[i*5-5+4]}) + A[i];
		if(A[i] != 0){
			DP[i*5+1] = min(DP[i*5-5],DP[i*5-5+1]) + A[i] % 2;
			DP[i*5+3] = min({DP[i*5-5],DP[i*5-5+1],DP[i*5-5+2],DP[i*5-5+3]}) + A[i] % 2;
		}
		else{
			DP[i*5+1] = min(DP[i*5-5],DP[i*5-5+1]) + 2;
			DP[i*5+3] = min({DP[i*5-5],DP[i*5-5+1],DP[i*5-5+2],DP[i*5-5+3]}) + 2;
		}
		DP[i*5+2] = min({DP[i*5-5],DP[i*5-5+1],DP[i*5-5+2]}) + (A[i] + 1) % 2;
	}
	cout << min({DP[N*5],DP[N*5+1],DP[N*5+2],DP[N*5+3],DP[N*5+4]}) << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[200010];
ll kai[200010];
ll m;
ll beki(ll n,ll k){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=m;
    }
    now*=now;
    now%=m;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n){
  return beki(n,mod-2);
}
void nckinit(ll n){
  kai[0]=1;
  kai[1]=1;
  for(int i=2;i<=n;i++){
    kai[i]=kai[i-1]*i;
    kai[i]%=mod;
  }
  gya[n]=gyaku(kai[n]);
  for(int i=n-1;i>=1;i--){
    gya[i]=gya[i+1]*(i+1);
    gya[i]%=mod;
  }
  gya[0]=1;
}    
ll nck(ll n,ll k){
  if(k<0)return 0;
  if(k==0||n==k)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=mod;
  ret*=gya[k];
  ret%=mod;
  return ret;
}
ll npk(ll n,ll k){
  if(k<0)return 0;
  if(k==0)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=mod;
  return ret;
}
random_device rnd;
mt19937 mt(rnd());
uniform_real_distribution<double> ra(1,6);
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  ll a[n],b[n];
  multiset<ll> st1,st2;
  vector<pll> v;
  rep(i,0,n){
    cin>>a[i]>>b[i];
    if(a[i]>b[i])swap(a[i],b[i]);
    st1.insert(a[i]);
    st2.insert(b[i]);
    v.push_back({a[i],i});
    v.push_back({b[i],i});
  }
  sort(v.begin(),v.end());
  bool used[n];
  fill(used,used+n,false);
  used[v.back().second]=true;
  ll ans=inf;
  ll c=0;
  rep(i,0,v.size()-1){
    if(c==0){
      auto itr=st1.end();itr--;
    auto itr2=st2.end();itr2--;
    ans=min(ans,(*itr-*st1.begin())*(*itr2-*st2.begin()));
    }
    ll now=v[i].first,num=v[i].second;
    if(used[num]){
      c=1;
      continue;
    }
    c=0;
    used[num]=true;
    ll na=a[num];
    ll nb=b[num];
    auto itr=st1.lower_bound(na);
    auto itr2=st2.lower_bound(nb);
    st1.erase(itr);
    st2.erase(itr2);
    st1.insert(nb);
    st2.insert(na);
  }
  cout<<ans<<endl;
}
  
  

Measured memory_bytes: 30440
#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 PickingGoods | diff PickingGoods.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address PickingGoods.cpp && ./a.out

/*

 8/15/2020

 6:17-6:45 AC

 https://twitter.com/hanseilimak/status/1294753121864790017
 https://atcoder.jp/contests/abc175/editorial/54

 */

const int MAX_N=3000+1;
LL V[MAX_N][MAX_N];
int N,M,K;

//const LL Inf=1e18;
LL dp[MAX_N][MAX_N][4];
void solve() {
  dp[0][0][0]=0;
  REP(i,N)REP(j,M)REPE(k,3) {
    if(dp[i][j][k]>0) dump(i,j,k,dp[i][j][k]);
    // right
    SMAX(dp[i][j+1][k],dp[i][j][k]);
    if(k<3) SMAX(dp[i][j+1][k+1],dp[i][j][k]+V[i][j]);

    // down
    SMAX(dp[i+1][j][0],dp[i][j][k]);
    if(k<3) SMAX(dp[i+1][j][0],dp[i][j][k]+V[i][j]);
  }
  LL res=0;
  REPE(k,3) {
    LL a=dp[N-1][M-1][k];
    dump(k,a);
    if(k<3) a+=V[N-1][M-1];
    SMAX(res,a);
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N>>M>>K;
  REP(i,K) {
    int r,c; LL v; cin>>r>>c>>v;
    --r,--c;
    V[r][c]=v;
  }
  solve();

  return 0;
}


Measured memory_bytes: 355256
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int h,w;cin>>h>>w;
    VS s(h);
    REP(i,h){
        cin>>s[i];
    }

    VVI dist(h);
    REP(i,h){
        dist[i].resize(w,-1);
    }

    queue<PII> q;

    REP(i,h){
        REP(j,w){
            if(s[i][j] == '.'){
                continue;
            }
            q.push(MP(i,j));
            dist[i][j] = 0;
        }
    }

    VI dx = {-1,1,0,0};
    VI dy = {0,0,-1,1};

    while(!q.empty()){
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        //cerr<<x<<" "<<y<<" "<<dist[x][y]<<endl;;

        REP(i,4){
            int nx = x+dx[i];
            int ny = y+dy[i];
            if(nx<0 || nx>=h || ny<0 || ny>=w){
                //cerr<<"range "<<nx<<" "<<ny<<endl;
                continue;
            }
            if(dist[nx][ny] != -1){
                //cerr<<"dist "<<nx<<" "<<ny<<" "<<dist[nx][ny]<<endl;
                continue;
            }
            dist[nx][ny] = dist[x][y]+1;
            q.push(MP(nx,ny));
        }
    }



    int result = 0;

    REP(i,h){
        REP(j,w){
            result = max(result, dist[i][j]);
        }
    }
    cout<<result<<endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 13456
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <unordered_set>
#include <functional>
 
using namespace std;

int main() {
    long long a,b,c;
    cin>>a>>b>>c;
    //if (2*sqrt(a*b)<c-a-b)
    if (c-a-b>0&&4*a*b<(c-a-b)*(c-a-b))
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    long mod = 998244353;
    long[] frac, inv;
    public static void main(String[] args){
        Main main = new Main();
//        String ans = main.solve()<0?"No":"Yes";
//        System.out.println(main.solve());
        main.solve();
    }
    long solve(){
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;i++) a[i] = sc.nextInt();
        int[] cnt = new int[n+10];
        for(int num:a) cnt[num]++;
        long total = 0;
        for(int num:cnt){
//            if(num<=1) continue;
            total += ((long)num)*(num-1)/2;
        }
        for(int i=0;i<n;i++){
            int cur = cnt[a[i]];
            long temp = total - cur+1;
            out.println(temp);
        }
        out.flush();
        return 1;

    }
}


Measured memory_bytes: 89856
def main():
    profit, loss = -1e+10, -1e+10
    price, high, low, before = 0, 0, 1e+10, 1e+10
    win = False
    for _ in range(int(input())):
        price = int(input())
        if low > price:
            profit = max(profit, high - low)
            loss = max(loss, price - before)
            high, low, before = price, price, price
        else:
            high = max(high, price)
            before = price
            win = True
    print(max(profit, high - low) if win else loss)


if __name__ == "__main__":
    main()



Measured memory_bytes: 5632
#include<cstdio>

using namespace std;

int a[200];
bool dp[200000];

int main()
{
  int n=0,k=0;scanf("%d%d",&n,&k);
  for(int i=1;i<=n;i++)scanf("%d",&a[i]);
  dp[0]=false;
  for(int i=1;i<=k;i++)
  {
    for(int j=1;j<=n&&a[j]<=i;j++)
    {
      if(!dp[i-a[j]]){dp[i]=true;break;}
    }
  }
  if(dp[k])printf("First");else printf("Second");
  return 0;
}

Measured memory_bytes: 256