akhauriyash/Code-Regression huggingface dataset:
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-02-04 16:22:43
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#define i64 long long
#include<vector>
const int N=400010,mod=1000000007;
int n,a[N],b[N],x[N],y[N],v[N],m,_n,n_;
i64 ans,f[N],s[N];
std::vector<int> e[N];
i64 query(int p)
{
	i64 ans=0;
	while(p){ ans=(ans+s[p])%mod; p-=p&(-p); }
	return ans;
}
void modify(int p,i64 v)
{
	while(p<=m){ s[p]=(s[p]+v)%mod; p+=p&(-p); }
}
int main()
{
	n=read(); n_=read();
	fr(i,1,n) a[i]=read();
	fr(i,1,n_) b[i]=read();
	fr(i,1,n)
	{
		if(a[i]<=b[1]||a[i]>=b[n_]) continue;
		int nex=*std::upper_bound(b+1,b+n_+1,a[i]),pre=*(std::upper_bound(b+1,b+n_+1,a[i])-1);
//		printf("%d %d %d\n",a[i],nex,pre);
		if(a[i]==nex||a[i]==pre) continue;
//		printf("%d\n",i);
		_n++; x[_n]=a[i]-pre; y[_n]=nex-a[i];
	}
	n=_n;
	fr(i,1,n){ v[++m]=x[i]; v[++m]=y[i]; }
	std::sort(v+1,v+m+1); m=std::unique(v+1,v+m+1)-v-1;
	fr(i,1,n){ x[i]=std::lower_bound(v+1,v+m+1,x[i])-v; y[i]=std::lower_bound(v+1,v+m+1,y[i])-v; }
	fr(i,1,n) e[x[i]].push_back(y[i]);
//	fr(i,1,m) fr(j,0,e[i].size()-1) printf("%d %d\n",i,e[i][j]);
	fr(i,1,m) if(e[i].size()) std::sort(e[i].begin(),e[i].end());
//	printf("%d\n",m);
	fr(i,1,m)
	{
		fr(j,0,e[i].size()-1) if(!j||e[i][j]!=e[i][j-1]) ans=(ans+(f[j]=query(e[i][j]-1)+1))%mod;
		fr(j,0,e[i].size()-1) if(!j||e[i][j]!=e[i][j-1]) modify(e[i][j],f[j]);
	}
	printf("%lld\n",ans==mod-1?0:ans+1);
	return 0;
}

Measured memory_bytes: 25856
import scala.io.StdIn
object Main extends App {
  val x = StdIn.readLine.toInt
  val r = math.sqrt(x).toInt
  val res = if( r == 1) Seq(x) else
    (2 to r).map { i =>
      val e = for {
        j <- (2 to r)
        e = math.pow(i,j).toInt if(e <= x)
      } yield e
      e.max
    }
  val ans = res.max
  println(ans)
}

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

import sys
from bisect import bisect_left

n = int(sys.stdin.readline().strip())
l = list(map(int,sys.stdin.readline().strip().split()))
    
l.sort()
c = 0
n1 = n - 1
for i in range(n-2):
    li = l[i]
    for j in range(i+1,n1):
        k = bisect_left(l,l[j]+li,lo=j)
        c += k-j-1
#
print(c)


Measured memory_bytes: 43868
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cstring>

#define int long long
//typedef long long ll;
#define rep(i, n) for(int i=0; i<(n); i++)

using namespace std;

int N;
string s;
bool exist;
char ans[100010];

bool check1()
{
    if (ans[1] == 'S') {
        if (s[1] == 'o') {
            if (ans[N] == ans[2]) return true;
        } else {
            if (ans[N] != ans[2]) return true;
        }
    } else {
        if (s[1] == 'o') {
            if (ans[N] != ans[2]) return true;
        } else {
            if (ans[N] == ans[2]) return true;
        }
    }
    
    return false;
}

bool check()
{
    for (int i=2; i<=N-1; i++) {
        if (ans[i] == 'S') {
            if (s[i] == 'o') {
                ans[i+1] = ans[i-1];
            } else {
                ans[i+1] = ans[i-1] == 'S' ? 'W' : 'S';
            }
        } else {
            if (s[i] == 'o') {
                ans[i+1] = ans[i-1] == 'S' ? 'W' : 'S';
            } else {
                ans[i+1] = ans[i-1];
            }
        }
    }

    if (ans[N] == 'S') {
        if (s[N] == 'o') {
            if (ans[N-1] == ans[1]) return check1();
        } else {
            if (ans[N-1] != ans[1]) return check1();
        }
    } else {
        if (s[N] == 'o') {
            if (ans[N-1] != ans[1]) return check1();
        } else {
            if (ans[N-1] == ans[1]) return check1();
        }
    }

    return false;
}

signed main()
{
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    cin >> N;
    cin >> s;

    s = "?" + s;

    ans[1] = 'S';
    ans[2] = 'S';
    if (check()) {
        for (int i=1; i<=N; i++) {
            cout << ans[i];
        }
        cout << endl;
        return 0;
    }

    ans[1] = 'S';
    ans[2] = 'W';
    if (check()) {
        for (int i=1; i<=N; i++) {
            cout << ans[i];
        }
        cout << endl;
        return 0;
    }

    ans[1] = 'W';
    ans[2] = 'S';
    if (check()) {
        for (int i=1; i<=N; i++) {
            cout << ans[i];
        }
        cout << endl;
        return 0;
    }

    ans[1] = 'W';
    ans[2] = 'W';
    if (check()) {
        for (int i=1; i<=N; i++) {
            cout << ans[i];
        }
        cout << endl;
        return 0;
    }

    cout << -1 << endl;
}


Measured memory_bytes: 636
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) (x.begin(),x.end())
using namespace std;

int main(){
ll A,B;
cin>>A>>B;

ll tmp,tmp1,tmp2;
tmp = A+B;
tmp1 = A-B;
tmp2 = A*B;
ll ans =tmp;

if(tmp1>ans)
ans = tmp1;
if(tmp2>ans)
ans =tmp2;


cout<<ans<<endl;
return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define LL long long
#define RG register

using namespace std;
template<class T> inline void read(T &x) {
	x = 0; RG char c = getchar(); bool f = 0;
	while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') c = getchar(), f = 1;
	while (c >= '0' && c <= '9') x = x*10+c-48, c = getchar();
	x = f ? -x : x;
	return ;
}
template<class T> inline void write(T x) {
	if (!x) {putchar(48);return ;}
	if (x < 0) x = -x, putchar('-');
	int len = -1, z[20]; while (x > 0) z[++len] = x%10, x /= 10;
	for (RG int i = len; i >= 0; i--) putchar(z[i]+48);return ;
}
const int N = 200010;
struct Edge {
	int u, v, w;
	bool operator < (const Edge &z) const {
		return w < z.w;
	}
}e[N << 1];
int n, q, c, w[N], fa[N];
int find(int x) {
	return x == fa[x] ? x : fa[x] = find(fa[x]);
}
 main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	read(n), read(q);
	int tot = 0;
	memset(w, 127, sizeof(w));
	for (int i = 1, x, y, z; i <= q; i++) {
		read(x), read(y), read(z);
		e[++tot] = (Edge) {x, y, z};
		w[x] = min(w[x], z + 1); w[y] = min(w[y], z + 2);
	}
	for (int i = 0; i < n; i++) w[i] = min(w[i], w[(i - 1 + n) % n] + 2);
	for (int i = 0; i < n; i++) w[i] = min(w[i], w[(i - 1 + n) % n] + 2);
	for (int i = 0; i < n; i++) e[++tot] = (Edge) {i, (i + 1) % n, w[i]};
	sort(e + 1, e + 1 + tot);
	for (int i = 0; i < n; i++) fa[i] = i;
	int ans = 0;
	for (int i = 1; i <= tot; i++) {
		int u = find(e[i].u), v = find(e[i].v);
		if (u == v) continue;
		ans += e[i].w;
		fa[v] = u;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
string hitachi = "";
for (int i = 1; i <= 5; i++) {
hitachi += "hi";
if (hitachi == s) {
cout << "Yes" << endl;
return 0;
 }
 }
 cout << "No" << endl;
 return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N = input().strip()
    tmp = 0
    for i in range(len(N)):
        tmp += int(N[i])
    # print(tmp)
    if int(N) % tmp == 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;

#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define Rep(i, a, b) for (int (i) = (a) - 1; (i) < (b); (i)++)
#define REP(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define Sort(a, len, cmp) sort(a + 1, a + len + 1, cmp)
#define ass(a, sum) memset(a, sum, sizeof(a))

#define ls ((rt) << 1)
#define rs ((rt) << 1 | 1)
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
#define ENDL cout << endl
#define SZ(x) ((int)x.size())

typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef pair <ll, ll> pll ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
typedef map <ll, ll> mll ;

const int N = 100010 ;
const double eps = 1e-8 ;
const int iinf = INT_MAX ;
const ll linf = 2e18 ;
const double dinf = 1e30 ;
const int MOD = 1000000007 ;

inline int read(){
    int X = 0, w = 0 ;
	char ch = 0 ;
    while (!isdigit(ch)) { w |= ch == '-' ; ch = getchar() ; }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar() ;
    return w ? - X : X ;
}

void write(int x){
     if (x < 0) putchar('-'), x = - x ;
     if (x > 9) write(x / 10) ;
     putchar(x % 10 + '0') ;
}

void print(int x) {
	cout << x << endl ;
	exit(0) ;
}

void PRINT(string x) {
	cout << x << endl ;
	exit(0) ;
}

void douout(double x){
	 printf("%lf\n", x + 0.0000000001) ;
}

int n ;
int a[N] ;
string s ;

void get(int x) {
	printf("%d\n", x) ; fflush(stdout) ;
	cin >> s ;
	if (s[0] == 'M') a[x] = 1 ;
	if (s[0] == 'F') a[x] = 2 ;
	if (s[0] == 'V') a[x] = -1, exit(0) ;
}

signed main(){
	cin >> n ;
	int l = 0, r = n - 1 ;
	get(l) ; get(r) ;
	while (l + 1 < r) {
		int mid = (l + r) >> 1 ;
		get(mid) ;
		if ((r - mid - 1) & 1) {
			if (a[mid] == a[r]) r = mid ;
			else l = mid ;
		}
		else {
			if (a[mid] != a[r]) r = mid ;
			else l = mid ;
		}
	}
}

/*
写代码时请注意：
	1.是否要开Long Long？数组边界处理好了么？
	2.实数精度有没有处理？
	3.特殊情况处理好了么？
	4.做一些总比不做好。
思考提醒：
	1.最大值和最小值问题可不可以用二分答案？
	2.有没有贪心策略？否则能不能dp？
*/


Measured memory_bytes: 852
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cctype>
using namespace std;

string str;
int pos;
int tree[32];
int ha[10];
int type[32];
int maxp;
int cnt;


int getDigit() {
  int s = pos;
  int length = 0;
  while(pos < str.length() && isdigit(str[pos])) { pos++; length++; }
  return atoi((str.substr(s, length)).c_str());
}

void exp(int p) {
  for(int i = 0; i < 2; ++i) {
    int child = p*2 + (i+1);
    maxp = max(maxp, child);
    if(str[pos] == '(') {
      tree[child] = 0;
      pos++; exp(child); pos++;
    } else {
      tree[child] = getDigit();
    }
    if(i == 0) pos++;
  }
}

void conv() {
  fill(tree, tree+32, -1);
  if(str[0] != '(') {
    maxp = 1;
    pos = 0;
    tree[0] = getDigit();
  } else {
    maxp = 0;
    tree[0] = 0;
    pos = 1; exp(0);
    maxp++;
  }
}

int rec2(int p) {
  if(tree[p] != 0) {
    return ha[tree[p]-1];
  } else {
    int a[2];
    for(int i = 0; i < 2; ++i) {
      int child = p*2 + (i+1);
      a[i] = rec2(child);
    }
    if(type[p] == 0) {
      return a[0] & a[1];
    } else if(type[p] == 1) {
      return a[0] | a[1];
    } else if(type[p] == 2) {
      return a[0] ^ a[1];
    }
  }
}

void rec(int p) {
  if(p == maxp) {
    if(rec2(0) == (1<<4)-1) cnt++;
    return;
  }
  if(tree[p] != 0) {
    rec(p+1);
  } else {
    for(int i = 0; i < 3; ++i) {
      type[p] = i;
      rec(p+1);
    }
  }
}

void solve() {
  conv();
  cnt = 0;

  rec(0);
  cout << cnt << endl;
}

main() {
  while(1) {
    getline(cin, str);
    if(str == "END") break;
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i) {
      ha[i] = 0;
      for(int j = 0; j < 4; ++j) {
	int a;
	cin >> a;
	ha[i] |= a << j;
      }
    }
    solve();
    getchar();
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int n, k;
    cin >> n >> k;
    bool cnt[n];
    rep(i,n) cnt[i] = 0;
    rep(i,k) {
        int m;
        cin >> m;
        rep(j,m) {
            int d;
            cin >> d;
            d--;
            cnt[d] = true;
        }
    }
    int ans = 0;
    rep(i,n) {
        if (!cnt[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
#define N 100010
using namespace std;

ll n, m, q, ans, a[N];

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9'){
		if (ch == '-') w *= -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9'){
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * w;
}

inline void work(){
	n = read(), m = read(), q = read();
	REP(i, 1, n) a[i] = m;
	while (q--){
		ll x = read();
		a[x]++;
		ans++;
	}
	REP(i, 1, n){
		if (a[i] - ans > 0) puts("Yes");
		else puts("No");
	}
}

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

Measured memory_bytes: 1408
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn f(b: i64, n: i64) -> i64 {
    if n < b {
        n
    } else {
        f(b, (n as f64 / b as f64).floor() as i64) + (n % b)
    }
}

fn solve(n: i64, s: i64) -> Option<i64> {
    if n == s {
        return Some(n + 1);
    }
    let sqrt_n = (n as f64).sqrt() as i64;
    let mut result = Vec::new();

    for i in 2..sqrt_n + 1 {
        if f(i, n) == s {
            result.push(i);
        }
    }

    for i in (1..sqrt_n + 1).rev() {
        if (n - s + i) % i != 0 {
            continue;
        }

        let b = (n - s + i) / i;
        if b <= 1 {
            continue;
        }
        if f(b, n) == s {
            result.push(b);
        }
    }
    result.sort();
    result.get(0).map(|x| *x)
}

fn main() {
    input!(n: i64, s: i64);
    match solve(n, s) {
        Some(res) => println!("{}", res),
        None => println!("{}", -1),
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

double EPS=1e-10;
double add(double a,double b){
  if(abs(a+b)<EPS*(abs(a)+abs(b))) return 0;
  return a+b;
}
struct P{
  double x,y;
  P() {}
  P(double x,double y):x(x),y(y){
  }
  P operator +(P p){
    return P(add(x,p.x),add(y,p.y));
  }
  P operator -(P p){
    return P(add(x,-p.x),add(y,-p.y));
  }
  P operator *(double d){
    return P(x*d,y*d);
  }
  double dot(P p){
    return add(x*p.x,y*p.y);
  }
  double det(P p){
    return add(x*p.y,-y*p.x);
  }
};
bool cmp_x(const P& p,const P& q){
  if(p.x!=q.x) return p.x<q.x;
  return p.y<q.y;
}
bool on_seg(P p1,P p2,P q){
  return (p1-q).det(p2-q)==0 and (p1-q).dot(p2-q)<=0;
}
vector<P> ps(100100);
vector<P> convex_hull(int n){
  sort(all(ps),cmp_x);
  int k=0;
  vector<P> qs(n*2);
  rep(i,n){
    while(k>1 and ((qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1]))<=0) k--;
    qs[k++]=ps[i];
  }
  int t=k;
  rep(i,n-1){
    while(k>t and ((qs[k-1]-qs[k-2]).det(ps[n-2-i]-qs[k-1]))<=0) k--;
    qs[k++]=ps[n-2-i];
  }
  qs.resize(k-1);
  return qs;
}

int main(){
  int N;
  cin>>N;
  VI X(N),Y(N);
  rep(i,N) cin>>X[i]>>Y[i];
  rep(i,N) ps[i]=P(X[i],Y[i]);
  ps.resize(N);
  sort(all(ps),cmp_x);
  vector<P> qs=convex_hull(N);
  map<PII,int> M;
  rep(i,N) M[mp(X[i],Y[i])]=i;
  vector<double> ans(N);
  int Q=qs.size();
  rep(i,Q){
    int prv=(i-1+Q)%Q;
    int nxt=(i+1)%Q;
    P C=qs[i]-qs[prv];
    P D=qs[nxt]-qs[i];
    C=P(C.y,-C.x);
    D=P(D.y,-D.x);
    double tmp=C.dot(D)/sqrt(C.dot(C)*D.dot(D));
    ans[M[mp(qs[i].x,qs[i].y)]]=acos(tmp)/(double)2/acos(-1);
  }
  cout<<setprecision(10);
  rep(i,N) cout<<ans[i]<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int n,a,z=0;
	cin>>n;
	for(int i=1;i<=n;i++)
    {
        cin>>a;
        if(i%2&&a%2)
            z++;
    }
    cout<<z<<endl;
	return 0;
}


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

int main(){
    ll a,b;
    cin >> a >> b;
    if((a<0&&0<b)||a==0||b==0)cout << "Zero" << endl;
    else if((a%2!=b%2&&b<0)||a>0) cout << "Positive" << endl;
    else cout << "Negative" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  char s = '#';
  vector<string> vec(H);
  for(int i=0;i<H;i++) {
    cin >> vec.at(i);
  }
  for(int i=0;i<W+2;i++) {
    cout << s;
  }
  cout << endl;
  for(int i=0;i<H;i++) {
    cout << s << vec.at(i) << s << endl;
  }
  for(int i=0;i<W+2;i++) {
    cout << s;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for(int i = (int)(n); i>=0; --i)
struct fast_ios { fast_ios(){cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast_ios_;

int main()
{
    string S, T;
    cin >> S >> T;

    int cnt=0;
    rep(i, S.length())
    {
        if(S.at(i) != T.at(i))
        {
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

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

const int LOOP = 1000; //?????????[???v????????????
const double EPS = 1e-6; //?????????????????????p(???C??????????????????????????)
int L;
int N; //?????????[?????????P???[???L????????

//?????????[?????????P???[???L?????????u???????????????????????n???????????A???S?????????????????????????v???Z????????????
double Evaluate(int r[12]) {
	double val = r[0] + r[N-1];
	for (int i = 0; i < N - 1; i++)
	{
		int a = abs(r[i] - r[i+1]), c = r[i] + r[i+1];
		val += sqrt(c*c - a*a);
	}
	return val;
}

//???????????????????[???v?????????????n???????????A?????????????????????????????J????????????????????????????
//(???J??????????????????????true)
bool Changes(int cnt) {
	return cnt < rand()%LOOP;
}

//?????????????????????@??????????????????????????
//???????????×????????????????????????????????????????????????????????????
//int r[12] : ?????????[?????????P???[???L??????0????????????N-1???????????????????t?????????A???z???????????u???????????????????????????i???[????????????
double Solve(int r[12]) {
	double score = Evaluate(r); //??????????????????????r[]???????????????????????i???[????????????????????
	double mi = score; //?????????????????????????????????????????????????????l?????????i???[????????????????????
	for (int cnt = 0; cnt < LOOP; cnt++)
	{
		//===============================================
		swap(r[rand()%N],r[rand()%N]);
		for(int i = 0 ;i < N ; i++){
			score = Evaluate(r);
		}
		if(score < mi){
			mi = score;
		}
		else {
			if(Changes(cnt)){
				if(mi > score){
					mi = score;
				}
			}
			else {
				swap(r[rand()%N],r[rand()%N]);
			}
		}
		
		//===============================================
	}
	return mi; //???????????l??????????????
}

//???????????`?????????????????????????????????|????????????????????????????????????????????????
int main() {
	srand(time(NULL));
	while (cin >> L)
	{
		N = 0;
		int r[12];
		string S;
		getline(cin, S);
		stringstream SS(S);
		while (!SS.eof()) SS >> r[N++];

		double ans;
		if (N == 1) ans = r[0]*2;
		else ans = Solve(r);

		if (L - ans + EPS > 0) puts("OK");
		else puts("NA");
	}
	return 0;
}

Measured memory_bytes: 3188
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

int main()
{
	int a, b;

	scanf("%d %d", &a, &b);

	printf("%d\n", (a + b - 1) / b);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll  vis[200009],lvl[200009];
    vector<ll>vi[200009];
int main()
{
   ll m,n,a,b,i,j,k;
   cin>>n>>m;
   queue<ll>q;
   for(i = 0 ;i<m ;i++)
   {
       cin>>a>>b;
       vi[a].push_back(b);
       vi[b].push_back(a);
   }
   vis[1]=1;
   lvl[1]=0;
   q.push(1);
   while(!q.empty())
   {
       k=q.front();
       q.pop();
       for(i = 0 ;i<vi[k].size() ;i++)
       {
           if(vis[vi[k][i]]==0)
           {
               q.push(vi[k][i]);
               vis[vi[k][i]]=1;
               lvl[vi[k][i]]=lvl[k]+1;
           }
       }
   }
   //cout<<lvl[n]<<endl;
   if(lvl[n]==2 || lvl[n]==1)
    cout<<"POSSIBLE"<<endl;
   else
    cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 16744
import sys


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


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


class UnionFind:
    # 初期化
    def __init__(self, n_nodes):
        self.n_nodes = n_nodes
        # 親要素のノード番号を格納する.初めは全て親ノード.
        # self.parent[x] == x の時，そのノードは根.
        self.parent = [i for i in range(n_nodes)]
        # 木の高さを格納する．
        self.rank = [1] * n_nodes
        # 自分と同じグループの要素数を格納．親要素を参照するようにする
        self.size = [1] * n_nodes

    # 検索. 根を返す.
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            # 一度調べた値は，根に繋ぎ直す.
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    # 併合.
    # 木の高さが低くなるように.
    # 親要素の書き換えは少ない方がいい
    def unite(self, x, y):
        # 根を探す．
        x = self.find(x)
        y = self.find(y)
        # 根が同じ場合はそのまま
        if x == y:
            return
        # 木の高さを比較し，低い方を高い方の根に貼る.
        if self.rank[x] > self.rank[y]:
            self.parent[y] = x
            self.size[x] += self.size[y]
        else:
            self.parent[x] = y
            self.size[y] += self.size[x]
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    # 同じ集合に属するか判定
    def check(self, x, y):
        return self.find(x) == self.find(y)

    # 同一グループに所属する要素数を返す
    def get_size(self, x):
        return self.size[self.find(x)]

    # 親要素のリストを返す
    def get_parent_list(self):
        return [i for i in range(self.n_nodes) if self.find(i) == i]

    # グループの数を返す
    def get_n_groups(self):
        return len(self.get_parent_list())

    # 同じグループに所属する要素の集合を返す
    def get_members(self, x):
        parent = self.find(x)
        return [i for i in range(self.n_nodes) if self.find(i) == parent]

    # 全ての根に対する，グループのメンバーを返す．
    def get_members_dict(self):
        return {par: self.get_members(par) for par in self.get_parent_list()}


def main():
    N, M = map(int, input().split())
    P = list(map(int, input().split()))
    UF = UnionFind(N)
    for _ in range(M):
        x, y = map(int, input().split())
        UF.unite(x - 1, y - 1)

    cnt = 0
    for i in range(N):
        a = P[i] - 1
        if UF.check(i, a):
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20488
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int m,k;
    cin>>m>>k;
    int val=(1LL<<m)-1;
    if(k>val)
    {
        cout<<"-1"<<endl;
        return 0;
    }
    if(k==0)
    {
        f(i,0,val)
        {
            cout<<i<<" ";
            if(i==val)cout<<i;
            else cout<<i<<" ";
        }
        cout<<endl;
        return 0;
    }
    if(m==1)
    {
        cout<<"-1"<<endl;
        return 0;
    }
    f(i,0,val)
    {
        if(i!=k)cout<<i<<" ";
    }
    cout<<k;
    rf(i,val,0)
    {
        if(i!=k)cout<<" "<<i;
    }
    cout<<" "<<k<<endl;
    return 0;

}



































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

from itertools import combinations_with_replacement
def main():
    N, M, Q = map(int, input().split())
    Abcd = [list(map(int,input().split())) for i in range(Q)]
    L = list(combinations_with_replacement(range(1,M+1), N))
    ret = 0

    for l in L:
        pt = 0
        for abcd in Abcd:
            if l[abcd[1]-1] - l[abcd[0]-1] == abcd[2]:
                pt += abcd[3]
        ret = max(ret, pt)
    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 21488
#include<bits/stdc++.h>
using namespace std;
bool ban[10];
bool check(int val) {
	while(val != 0) {
		if(ban[val%10])
			return false;
		val /= 10;
	}
	return true;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin >> n >> k;
	for(int i=0,val;i<k;i++) {
		cin >> val;
		ban[val] = true;
	}
	for(int ans=n;;ans++) {
		if(check(ans)) {
			cout << ans << endl;
			return 0;
		} 
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

ll B=0, W = 0;
vvl G = vv(401*401, 0, 0, ll);
vll c(401*401, 0), num(401*401, 0);
void dfs(ll now, ll from){
  if(c[now]==1) return;
  c[now] = 1;

  if(num[now]==1) B++;
  else W++;

  for(int i=0;i<G[now].size();i++){
    if(G[now][i] == from ) continue;
    dfs(G[now][i], now);
  }
}
int main(int argc, char const *argv[]) {
  ll h, w;std::cin >> h >> w;
  vector<string> s(h);re(i, h) std::cin >> s[i];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='#') num[i*401+j] = 1;
      if(i!=0&&(s[i][j]!=s[i-1][j]))  G[i*401+j].push_back((i-1)*401+j);
      if(i!=h-1&&(s[i][j]!=s[i+1][j]))G[i*401+j].push_back((i+1)*401+j);
      if(j!=0&&(s[i][j]!=s[i][j-1]))  G[i*401+j].push_back(i*401+(j-1));
      if(j!=w-1&&(s[i][j]!=s[i][j+1]))G[i*401+j].push_back(i*401+(j+1));
    }
  }
  ll ans = 0;
  re(i, h) {
    re(j, w) {
      B = 0, W = 0;
      if(c[i*401+j]==0){
        dfs(i*401+j, -1);
        ans += B * W;
        //std::cout << i << " " << j << " " << B << " " << W << '\n';
      }
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 21888
a = int(input())
b = int(input())
c = int(input())
x = int(input())

n = 0
for i in range(a + 1):
	for j in range(b + 1):
		k = (x - 500 * i - 100 * j) // 50
		if 0 <= k <= c:
			n += 1

print(n)

Measured memory_bytes: 3060
#include <stdio.h>
int main() {

  int A[100],minj,i,j,x,N,count=0,flag;

  scanf("%d",&N);
  for(i = 0; i < N; i++) {
    scanf("%d",&A[i]);
  }

  for(i = 0; i < N; i++) {
    minj = i;
    flag = 0;
    for(j = i; j < N; j++) {
      if(A[j] < A[minj]) {
    minj = j;
    flag = 1;

      }
    }
    if(flag == 1) {
      x = A[i];
      A[i] = A[minj];
      A[minj] = x;
      count++; 
    }
  }

  for(i = 0; i < N; i++) {
    printf("%d",A[i]);
    if(N-1 != i) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2144
import java.util.*;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException{
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a<b)
            System.out.println("a < b");
        if(a>b)
            System.out.println("a > b");
        if(a==b)
            System.out.println("a == b");

    }
}

Measured memory_bytes: 26184
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

int H;

int parent(int i) { return i / 2; }

int left(int i) { return 2 * i; }

int right(int i) { return 2 * i + 1; }

void maxHeapify(vector<ll> &A, int i) {
    int l = left(i);
    int r = right(i);
    int largest;
    if (l <= H and A[l] > A[i]) {
        largest = l;
    } else {
        largest = i;
    }
    if (r <= H && A[r] > A[largest]) {
        largest = r;
    }
    if (largest != i) {
        swap(A[i], A[largest]);
        maxHeapify(A, largest);
    }
}

void buildMaxHeap(vector<ll> &A) {
    for (int i = H / 2; i >= 1; i--) {
        maxHeapify(A, i);
    }
}

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

    cin >> H;
    vector<ll> A(3 * H, -INF);
    for (int i = 1; i <= H; i++) {
        cin >> A[i];
    }

    buildMaxHeap(A);

    for (int i = 1; i <= H; i++) {
        cout << " " << A[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 14352
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String str1 = sc.nextLine();
		String str2 = sc.nextLine();
		String ans = "No";
		for(int i = 0; i < str1.length(); i++) {
			if(str1.equals(str2)) {
				ans = "Yes";
				break;
			} else {
				char c[] = new char[str1.length()];
				char temp = ' ';
				for(int j = 0; j < str1.length(); j++) {
					if(j == 0) {
						temp = str1.charAt(j);
					}else {
						c[j - 1] = str1.charAt(j);
					}
				}
				c[str1.length() - 1] = temp;
				
				str1 = String.valueOf(c);
			}
		}
		System.out.println(ans);
	}
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#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 REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
const  LL mod=1000000007;
vector<int>v;
int main()
{
    LL n;
    cin>>n;
   LL a[n+1];
   LL b[n];
   LL s=0;
   for(int i=0;i<n+1;i++)cin>>a[i];
   for(int i=0;i<n;i++)cin>>b[i];
   LL c=0;
   for(int i=0;i<n;i++)
   {
       LL x=min(c,a[i]);
       s+=x;
       a[i]-=x;
       x=min(b[i],a[i]);
       s+=x;
       c=max(0LL,b[i]-x);
//       cout<<s<<" "<<c<<endl;
   }
////   cout<<s<<" "<<c<<endl;
   s+=min(c,a[n]);
   cout<<s;

}


Measured memory_bytes: 5144
if __name__ == "__main__":
    s = input()
    ans = 0
    red = 0
    blue = 0
    for ss in reversed(s):
        if ss == '0':
            red += 1
            if blue > 0:
                red -= 1
                blue -= 1
                ans += 2
        else:
            blue += 1
            if red > 0:
                red -= 1
                blue -= 1
                ans += 2

    print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long INF = 1LL<<60;

void YN(bool x){
  if(x) cout<<"Yes";
  else cout<<"No";
  return;
}

int main() {
  int N,H,K; cin>>N>>H>>K;
  bool finish=false;
  for(int i=0;i<=N;i++) for(int j=0;j<=H;j++) if(i*H+j*N-2*i*j==K) finish=true;
  YN(finish);   
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
     ll n;
     cin>>n;
     ll a[n];
     for(ll i=0;i<n;i++)
     {
         cin>>a[i];
     }
     ll mx=a[0];
     ll cnt=0;
     for(ll i=1;i<n;i++)
     {
         if(mx>a[i])
         {
             cnt+=mx-a[i];
         }
         mx=max(mx, a[i]);
     }
     cout<<cnt;



    return 0;
}

Measured memory_bytes: 5148
#include <cstdio>
#include <algorithm>

const int MN = 100005;

int N, M, A[MN];

int main() {
	scanf("%d%d", &N, &M);
	int C = 0;
	for (int i = 1; i <= M; ++i) scanf("%d", &A[i]), C += A[i] & 1;
	if (C > 2) return puts("Impossible"), 0;
	int p1 = 0, p2 = 0;
	for (int i = 1; i <= M; ++i)
		if (A[i] & 1) (p1 ? p2 : p1) = i;
	if (p1 && !p2) std::swap(A[1], A[p1]);
	if (p2) std::swap(A[1], A[p1]), std::swap(A[p2], A[M]);
	for (int i = 1; i <= M; ++i) printf("%d%c", A[i], " \n"[i == M]);
	if (N == 1) return puts("1\n1"), 0;
	if (M == 1) return printf("2\n1 %d\n", N - 1), 0;
	--A[1], ++A[M];
	printf("%d\n", M - !A[1]);
	for (int i = A[1] ? 1 : 2; i <= M; ++i) printf("%d%c", A[i], " \n"[i == M]);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,l,i;
    cin>>n;
    l=2*n+1;
    char s1[n],s2[n],s3[l];
    cin>>s1>>s2;
    k=0;
    for(i=0; i<n; i++)
    {
        s3[k]=s1[i];
//         cout<<s3[k];
        k++;
        s3[k]=s2[i];
//        cout<<s3[k];
        k++;

    }
    s3[k]='\0';
    cout<<s3<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int n;
int x[3000],y[3000];
bool f[5001][5001];
int i,j;
int a,b,p,q,r,s;
int m;

int max(int c,int d){
	if(c>=d)return c;
	else return d;
}

int main(){
	while(1){
		scanf("%d",&n);
		if(n==0)return 0;
		m=0;
		for(i=0;i<=5001;i++)for(j=0;j<=5001;j++)f[i][j]=false;
		for(i=0;i<n;i++){
			scanf("%d %d",&x[i],&y[i]);
			f[x[i]][y[i]]=true;
		}
		for(i=0;i<n-1;i++)for(j=i+1;j<n;j++){
			a=x[i]-x[j];
			b=y[i]-y[j];
			if((x[i]+b>=0&&y[i]-a>=0&&x[j]+b>=0&&y[j]-a>=0&&x[i]+b<=5000&&y[i]-a<=5000&&x[j]+b<=5000&&y[j]-a<=5000&&f[x[i]+b][y[i]-a]&&f[x[j]+b][y[j]-a])||(x[i]-b>=0&&y[i]+a>=0&&x[j]-b>=0&&y[j]+a>=0&&x[i]-b<=5000&&y[i]+a<=5000&&x[j]-b<=5000&&y[j]+a<=5000&&f[x[i]-b][y[i]+a]&&f[x[j]-b][y[j]+a]))m=max(m,a*a+b*b);
		}
		printf("%d\n",m);
	}
}

Measured memory_bytes: 25472
n,m,q = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(m)]
p = [list(map(int, input().split()))+ [i] for i in range(q)]
class BIT:
    def __init__(self, node_size):
        self._node = node_size+1
        self.bit = [0]*self._node

    def add(self, index, add_val):
        while index < self._node:
            self.bit[index] += add_val
            index += index & -index

    def sum(self, index):
        res = 0
        while index > 0:
            res += self.bit[index]
            index -= index & -index
        return res
l.extend(p)
l = sorted(l,key= lambda x:x[1])
ka = BIT(n)
ans = []
for i in l:
  if len(i) == 2:
    ka.add(i[0], 1)
  else:
    ans.append([i[2],ka.sum(i[1]) - ka.sum(i[0]-1)])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i][1])

Measured memory_bytes: 73404
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    w, h, x, y = map(int, readline().split())
    ans = '{:.10f}'.format(w*h/2) 
    print(ans, end=' ')
    if (2*x == w) and (2*y == h):
        print(1)
    else:
        print(0)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] A = new long[N + 1];
    for (int i = 1; i <= N; i++) {
      A[i] = sc.nextLong();
    }
    long[] S = new long[N + 1];
    S[0] = 0L;
    for (int i = 1; i <= N; i++) {
      S[i] = S[i - 1] + A[i];
    }
    Arrays.sort(S);
    long ans = 0L;
    long before = S[0];
    long count = 1L;
    for (int i = 1; i <= N; i++) {
      if (before == S[i]) {
        count++;
      } else {
        ans += count * (count - 1) / 2;
        before = S[i];
        count = 1L;
      }
    }
    ans += count * (count - 1) / 2;
    System.out.println(ans);
  }
}

Measured memory_bytes: 89016
#include<iostream>
#include<vector>
#define MAX_M 100001
using namespace std;
typedef long long ll;
signed main(){
  ll m,a,b,max_pq,ps,num;
  ll pr[MAX_M];
  fill(pr,pr+MAX_M,1);
  vector<ll> p_list;
  for(ll i=2;i<MAX_M;i++){
    if(pr[i]==1){
      for(ll j=2*i;j<MAX_M;j+=i){
        pr[j]=0;
      }
      p_list.push_back(i);
    }
  }
  ps=p_list.size();
  cin >> m >> a >> b;
  while(m!=0){
    max_pq=0;
    pair<int,int> pq;
    for(ll i=0;i<ps;i++){
      for(ll j=i;j<ps;j++){
        num = p_list[i]*p_list[j];
        if(num>m) break;
        if(a*p_list[j]<=b*p_list[i]){
          if(num>=max_pq){
            max_pq=num;
            pq=make_pair(p_list[i],p_list[j]);
          }
        }
      }
    }
    cout << pq.first<<" "<<pq.second<<endl;
    cin >> m >> a >> b;
  }
}



Measured memory_bytes: 4036
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
  static InputReader in;
  static PrintWriter out;
  
  static class Solution {
    void solve() throws IOException {
      int a = in.nextInt();
      int b = in.nextInt();
      if (a < b) {
        out.println("a < b");
      } else if (a == b) {
        out.println("a == b");
      } else {
        out.println("a > b");
      }
    }
  }

  public static void main(String[] args) throws IOException {
//    ??????
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;
    
    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }
   
    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }
    
    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken()); 
    }
    
    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }
    
    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }
    
  }
  
}

Measured memory_bytes: 24292
public class Main {


  private static void solve() {
    int n = ni();
    int k = ni();
    int[] a = na(n);
    
    boolean[][] dp = new boolean[k + 1][2];

    boolean ret = false;
    for (int i = 1; i <= k; i ++) {
      for (int t = 0; t < 2; t ++) {
        for (int j = 0; j < n; j ++) {
          if (i >= a[j]) {
            if (!dp[i - a[j]][t^1]) {
              dp[i][t] = true;
              break;
            }
          }
        }
      }
      if (i == k && dp[i][0]) {
        ret = true;
      }
    }
    
    System.out.println(ret ? "First" : "Second");
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

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

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  
  int ans;
  
  if(n < k) ans = n * x;
  else ans = k * x + (n - k) * y;
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
ans = sum(A)

if ans % 10 == 0:
    for a in A:
        if (ans - a) % 10 != 0:
            print(ans - a)
            break
    else:
        print(ans % 10)
else:
    print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;
const ll inf = 1001001001;
const ll mod = 1000000007;

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    ll ans = b/x - a/x;
    if(a%x == 0)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#include <numeric>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Graph;

const double PI = 3.14159265358979323846;
const int mod = 1000000007;


int main(int argc, char *args[]) {
	int k, n; cin >> k >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int max_dist = -1;
	rep(i,n) {
		if (i == n - 1) {
			max_dist = max(max_dist, a[0] + k - a[i]);
			continue;
		}
		max_dist = max(max_dist, a[i + 1] - a[i]);
	}
	int ans = k - max_dist;
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
#define PI 3.1415926535897932384626433
#define MOD 1000000007

int main(){
    int n, l;
    cin >> n >> l;
    int a, b;
    a = l;
    b = l + n - 1;

    int eat = 0;
    if (b <= 0){
        eat = b;
    }else if(a >= 0){
        eat = a;
    }

    cout << (b - a + 1) * (a + b) / 2 - eat << endl;
    return 0;
}


Measured memory_bytes: 256