akhauriyash/Code-Regression huggingface dataset:
(let* ((n (read))
    (a (make-array (list n)))
    (ans "Yes")
    (cTime 0))
    (dotimes (i n)
        (setf (aref a i) (list (read) (read)))
    )
    (setf a (sort a #'< :key #'second))
    (loop for i below n do
        (progn
            (incf cTime (car (aref a i)))
            (if (not (<= cTime (second (aref a i))))
                (progn
                    (setq ans "No")
                    (return)
                )
            )
        )
    )
    (princ ans)
)

Measured memory_bytes: 83808
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <fstream>
#include <numeric>


using namespace std;

#define max(a,b) a > b ? a : b
#define min(a,b) a < b ? a : b

int N, M;
vector<int> H, H2, A, B;

int main() {

    cin >> N >> M;

    H.resize(N);
    H2.resize(N);
    A.resize(M);
    B.resize(M);

    for (int i = 0; i < N; i++) {
        cin >> H[i];
        H2[i] = 1;
    }
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];

        if (H[A[i] - 1] > H[B[i] - 1]) {
            H2[B[i] - 1] = 0;
        }
        else if (H[A[i] - 1] < H[B[i] - 1]){
            H2[A[i] - 1] = 0;
        }else {
            H2[A[i] - 1] = 0;
            H2[B[i] - 1] = 0;
        }
    }

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (H2[i] > 0) cnt++;
    }

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


Measured memory_bytes: 4780
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<list>
#include<math.h>
using namespace std;

#define ll long long
#define vecint vector<int>
#define listint list<int>

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

#define INF 1000000007;

int main(){
  int sx,sy,tx,ty;
  int ans;
  cin>>sx>>sy>>tx>>ty;
  rep(i,ty-sy){
    cout << 'U';
  }
  rep(i,tx-sx){
    cout << 'R';
  }
  rep(i,ty-sy){
    cout << 'D';
  }
  rep(i,tx-sx+1){
    cout << 'L';
  }
  rep(i,ty-sy+1){
    cout << 'U';
  }
  rep(i,tx-sx+1){
    cout << 'R';
  }
  cout << 'D';
  cout << 'R';
  rep(i,ty-sy+1){
    cout << 'D';
  }
  rep(i,tx-sx+1){
    cout << 'L';
  }
  cout << 'U';
  cout << endl;


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<vector>

int const MAXN = 1e5;
int const MAXM = 2e5;
typedef std::pair<int, int> P;

int N, M;
P b[MAXN+1];
std::map<P, int> LR;
std::set<int> ix;
std::vector<int> G[MAXN+1];
std::set<int> ans;
bool used[MAXN+1];

bool dfs(int i, int p) {
  used[i] = true;
  bool res = ix.find(i) != ix.end();
  for(auto c: G[i]) if(!used[c]) {
    res ^= dfs(c, i);
  }
  if(p >= 0 && res) {
    int l = std::min(i, p), r = std::max(i, p);
    ans.insert(LR[std::make_pair(l, r)]);
  }
  return res;
}

int main() {
  std::cin >> N >> M;
  for(int i = 0; i < N; ++i) std::cin >> b[i].first >> b[i].second;
  std::sort(b, b+N); b[N] = std::make_pair(1e9+1, 0);
  if(b[0].second) ix.insert(0);
  for(int i = 0; i < N-1; ++i) if(b[i].second != b[i+1].second) ix.insert(i+1);
  if(ix.size()%2 == 1) ix.insert(N);
  
  for(int i = 0; i < M; ++i) {
    int L, R; std::cin >> L >> R;
    L = std::partition_point(b, b+N+1, [&](auto& x){ return x.first < L; }) - b;
    R = std::partition_point(b, b+N+1, [&](auto& x){ return x.first <= R; }) - b;
    if(L >= R) continue;
    LR[std::make_pair(L, R)] = i+1;
  }
  for(auto e: LR) {
    G[e.first.first].push_back(e.first.second);
    G[e.first.second].push_back(e.first.first);
  }
  std::fill_n(used, N+1, false);
  for(int i = 0; i <= N; ++i) if(!used[i] && dfs(i, -1)) {
    std::cout << "-1" << std::endl;
    return 0;
  }
  std::cout << ans.size() << std::endl;
  int i = 0;
  for(auto c: ans) {
    std::cout << c;
    if(++i < ans.size()) std::cout << " ";
    else std::cout << std::endl;
  }
  return 0;
}



Measured memory_bytes: 30848
n,m = map(int,input().split())
l = [int(input()) for _ in[0]*m]
l=set(l)
dp=[0]*(n+1)#0〜n段目までのn+1通り。
#1段目までは手動。
dp[0]=1
dp[1]=0 if 1 in l else 1
MOD =10**9+7
#dp 貰うタイプ
for i in range(2,n+1):
  if i not in l:#床が壊れてなければ
    dp[i] = (dp[i-1] + dp[i-2])%MOD
print(dp[n])

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

#define nl '\n'

using namespace std;

typedef long long ll;

void solve() {
  int N;
  cin >> N;

  unordered_map<string, int> cnt;
  while (N--) {
    string status;
    cin >> status;
    cnt[status]++;
  }

  cout << "AC"
       << " x " << cnt["AC"] << nl;
  cout << "WA"
       << " x " << cnt["WA"] << nl;
  cout << "TLE"
       << " x " << cnt["TLE"] << nl;
  cout << "RE"
       << " x " << cnt["RE"] << nl;
}

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

  // int t;
  // cin >> t;
  // while (t--) {
  solve();
  cout << nl;
  // }

  return 0;
}

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

int main(){
    int n; cin>>n;
    while(n){
        if(n % 10 == 9){
            cout<<"Yes\n";
            return 0;
        }
        n /= 10;
    }
    cout<<"No\n";
    return 0;
}

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

int main(){
	int N;
	string S;
	cin >> N >> S;
	long long r = 0, g = 0, b = 0;
	for(int i=0;i<N;i++){
		if(S[i] == 'R')r++;
		if(S[i] == 'G')g++;
		if(S[i] == 'B')b++;
	}
	long long ans = r * g * b;
	for(int i=0;i<N;i++){
		for(int j=1;i + 2 * j<N;j++){
			if(S[i] != S[i + j] && S[i + j] != S[i + j * 2] 
				&& S[i] != S[i + 2 * j])ans--;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a /g* b ;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
int  GetDigit(T num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){
        }

        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size;i++){
                makeSet(i);
            }
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x,int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x,int y){
            link(findSet(x), findSet(y));
        }
        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x]==rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};



int main()
{
    int N;
    cin>>N;
    ll T[N];
    ll ans=1;
    REP(i,0,N){
        cin>>T[i];
        ans=lcm(ans,T[i]);
    }
    cout<<ans<<endl;
    

}

Measured memory_bytes: 256
//#pragma GCC optimize("O3", "no-stack-protector")
//#pragma GCC target("sse4", "avx", "popcnt", "lzcnt", "sse3", "sse4.1", "sse4.2", "sse2", "tune=native")
//#pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using old = long double;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> dp(k + 1);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i <= k; ++i) {
        if (i < a[0]) {
            dp[i] = 0;
            continue;
        }
        int kek = 1;
        for (int j : a) {
            if (j <= i) {
                kek = min(kek, dp[i - j]);
            }
        }
        dp[i] = 1 - kek;
    }
    if (dp[k]) {
        cout << "First";
    } else {
        cout << "Second";
    }
    return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 21:35:36 2020

@author: nanasakiwataru
"""

S = input()
if S == 'ABC':
    ans = 'ARC'
elif S == 'ARC':
    ans = 'ABC'
print(ans)

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
#define MAX_N 100000

vll d(MAX_N, LLINF);


struct segTree{
  ll N;
  vll dat;
  void init(ll n){
    N = 1;
    while(N < n)
      N *= 2;

    dat = vll(2*N, LLINF);
  }

  void update(ll k, ll a){
    k += N-1; //leaf
    dat[k] = a;
    while(k > 0){
      k = (k-1)/2;
      dat[k] = min(dat[k*2+1], dat[k*2+2]);
    }
  }

  ll query(ll a, ll b){
    if(a > b)
      return query(b,a,0,0,N);
    else
      return query(a,b,0,0,N);
  }

  ll query(ll a, ll b, ll k, ll l, ll r){
    if(b <= l || r <= a)
      return LLINF;

    if(a <= l && r <= b)
      return dat[k];
    else{
      ll m = (l+r)/2;
      ll vl = query(a, b, k*2+1, l, m);
      ll vr = query(a, b, k*2+2, m, r);
      return min(vl, vr);
    }
  }

  ll at(ll a){
    return dat[a+N-1];
  }
};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n,m;
  cin >> n >> m;
  vector<pair<pll, ll>> lrc(m);
  REP(i, m){
    cin >> lrc[i].FI.FI >> lrc[i].FI.SE >> lrc[i].SE;
    lrc[i].FI.FI--;
    lrc[i].FI.SE--;
  }
  sort(lrc.begin(), lrc.end());

  segTree seg;
  seg.init(n);
  seg.update(0, 0);
  REP(i, m){
    ll l = lrc[i].FI.FI;
    ll r = lrc[i].FI.SE;
    ll c = lrc[i].SE;

    ll k = seg.query(l, r+1);
    seg.update(r, min(k+c, seg.at(r)));
  }

  ll ans = seg.at(n-1);
  if(ans == LLINF)
    cout << -1 << endl;
  else
    cout << ans << endl;

}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void Main(){
    int N; cin >> N;
    VI A(N); REP(i,N) cin >> A[i];

    auto c = [&](P a, P b){
        int v1 = min(a.first, a.second), v2 = min(b.first, b.second);
        return v1<v2;
    };

    SORT(A); REVERSE(A);
    ll ans = A[0];
    priority_queue<P,vector<P>,decltype(c)> q(c);
    q.emplace(A[0],A[1]); q.emplace(A[1],A[0]);
    REP(i,N-2){
        auto p = q.top(); q.pop();
        ans += min(p.first, p.second);
        q.emplace(p.first,A[i+2]);
        q.emplace(p.second,A[i+2]);
    }

    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 6068
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int sum = a+b+c;
        int max = 0;
        int[] arr = {a,b,c};
        for(int i=0; i<3; i++) {
            max = Math.max(max, arr[i]);
        }

        int cnt = 0;
        for(int i=0; i<max+1; i++) {
            if(max*3 == sum || (max+1)*3 == sum) {
                break;
            }
            sum += 2;
            cnt++;
        }
        System.out.println(cnt);
    }
}


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

using namespace std;

using ll = long long;

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

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

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll cnt = 0;
    for (int i = 0; i < n; ++i) {
        ll na = distance(a.begin(), lower_bound(a.begin(), a.end(), b[i]));
        ll nc = n - distance(c.begin(), upper_bound(c.begin(), c.end(), b[i]));
        cnt += na * nc;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1408
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static Scanner sc = new Scanner(System.in);
	public void run() throws Exception {
		//
		final int N;
		final int K;
		final int[] a;
		Scanner scan = new Scanner(System.in);
			N = scan.nextInt();
			K = scan.nextInt();
			a = new int[N];
			for (int i = 0; i < N; i++) {
				a[i] = scan.nextInt();
			}
			Arrays.sort(a);
		int anw=0;
		for(int i=N-K;i<N;i++){
			anw +=a[i];
		}

		System.out.println(anw);
	}
    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    int findSumOfDigits(int n) {
    	  int sum = 0;
    	  while (n > 0) { // n が 0 になるまで
    	    sum += n % 10;
    	    n /= 10;
    	  }
    	  return sum;
    	}
}

Measured memory_bytes: 35852
// Ref : https://book.mynavi.jp/ec/products/detail/id=35408

#include <iostream>
#include <cmath>
#include <string>
#include <map>
#include <queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle {
	int f[N2]; // 9マスの状態
	int space; // 遷移の起点となるスペース位置
	string path; // スペースの移動方向を文字（dir[4]）の組み合わせで記録

	// mapによる二分探索木を使うための要素の大小関係の定義
	bool operator < (const Puzzle &p) const {
		for (int i = 0; i < N2; i++) {
			if (f[i] == p.f[i]) continue;
			return f[i] < p.f[i];
		}
		return false;
	}
};

// スペースと隣り合う位置への座標移動
static const int dx[4] = { -1, 0, 1, 0 };
static const int dy[4] = {  0,-1, 0, 1 };
static const char dir[4] = { 'u', 'l', 'd', 'r' };

bool isTarget(Puzzle p) {
	for (int i = 0; i < N2; i++)
		if (p.f[i] != (i + 1)) return false;
	return true;
}

string bfs(Puzzle s) {
	queue<Puzzle> Q;
	map<Puzzle, bool> V;
	Puzzle u, v;
	s.path = "";
	Q.push(s);
	V[s] = true;

	while (!Q.empty()) {
		u = Q.front(); Q.pop();
		if (isTarget(u)) return u.path;
		int sx = u.space / N; // スペースのx座標に変換
		int sy = u.space % N; // スペースのy座標に変換
		for (int r = 0; r < 4; r++) {
			int tx = sx + dx[r]; // 交換対象のx座標
			int ty = sy + dy[r]; // 交換対象のx座標
			if (tx < 0 || ty < 0 || tx >= N || ty >= N) continue; // マス外の無効座標
			v = u;
			swap(v.f[u.space], v.f[tx * N + ty]); // スペースと交換対象を交換
			v.space = tx * N + ty; // スペースの位置を更新
			if ( !V[v] ) { // 交換後の状態が存在しなければ自動的にfalseで要素が新規作成される
				V[v] = true;
				v.path += dir[r]; 
				Q.push(v);
			}
		}
	}
	return "unsolvable";
}

int main() {
	Puzzle in;

	for (int i = 0; i < N2; i++) {
		cin >> in.f[i];
		if (in.f[i] == 0) {
			in.f[i] = N2; // スペースは0からN2に形式変更
			in.space = i;
		}
	}
	string ans = bfs(in);
	cout << ans.size() << endl; // 移動方向の記録の文字数からスペースの交換回数を取得

	return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int r, g;
  std::cin >> r >> g;
  print(2 * g - r);
}


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

int main(){
  set<int> s;
  int h,w,k; cin>>h>>w>>k;
  for(int i=0;i<=h;i++){
    for(int j=0;j<=w;j++){
      int x=i*w+j*h-2*i*j;
      s.insert(x);
    }
  }
  auto itr=s.find(k);
  if(itr==s.end()){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
}

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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

  ll a = il();

  cout << a + a*a + a*a*a << endl;


  
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<pair<double,double>> town(n);
  vector<int> town_num(n);
  for(int i = 0; i < n; ++i){
    town_num[i] = i;
    cin >> town[i].first >> town[i].second;
  }
  int divisor = 0;
  double sum = 0;
  double per_sum = 0;
  do {
    divisor++; 
    for(int i = 0; i < n - 1; ++i){
      per_sum = 0;
      per_sum += pow((town[town_num[i]].first - town[town_num[i + 1]].first), 2);
      per_sum += pow((town[town_num[i]].second - town[town_num[i + 1]].second), 2);
      sum += sqrt(per_sum);
    }
  } while(next_permutation(town_num.begin(), town_num.end()));
  printf("%.10f\n", sum / divisor);
}

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

int main(){
    int N;
    string S;

    cin >> N;
    cin >> S;

    if((N % 2 == 0) && (S.substr(0, N / 2) == S.substr(N / 2, N / 2))){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

i64 nHr(i64 n, i64 k) {
  return COM(n + k - 1, k);
}

int main() {
  COMinit();
  i64 N, K;
  cin >> N >> K;

  i64 B = K;
  i64 A = N - K;

  for(int i = 1;i <= K;i++) {
    i64 blue = nHr(i, B - i);
    i64 red = nHr(i + 1, A - (i - 1));
    cout << blue * red % MOD << endl;
  }
}


Measured memory_bytes: 12160
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
    FOR(i,2,p) {
      if (p%i==0) return false;
    }
  return true;
}

int main(){
  int a,b,c,x,y,r;
  cin >> a >> b >> c >> x >> y;
  r=0;
  if (a+b>2*c) {
    int mi = min(x,y);
    r+=mi*c*2;
    x-=mi;
    y-=mi;
  }
  if (a>c*2) {
    r+=x*c*2;
  } else {
    r+=x*a;
  }
  if (b>c*2) {
    r+=y*c*2;
  } else {
    r+=y*b;
  }
  cout << r;
  return 0;
}

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

int main(){
    long long int n,k,c=0;
    cin>>n>>k;
    vector<long long int>a(10000000);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end(),std::greater<>());
    for(int i=k;i<n;i++){
        c+=a[i];
    }
    cout<<c<<endl;
   return 0;
}

Measured memory_bytes: 78336
#include <vector>
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    long long int n,m;
    cin >> n >> m;
    if(n>=3&&m>=3){
        cout << (n-2)*(m-2);
    }else if(n==2||m==2){
        cout << 0;
    }else if(n==1&&m>=3){
        cout << m-2;
    }else if(n>=3&&m==1){
        cout << n-2;
    }else if(n==1&&m==1){
        cout << 1;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  double l;
  cin>>l;
  long double y=l/3;
  cout<<setprecision(9)<<y*y*y<<'\n';
  return(0);
}


Measured memory_bytes: 256
def main():
    H, W, A, B = map(int, input().split())

    lines = [[0 for _ in range(W)] for _ in range(H)]

    for y in range(H):
        for x in range(W):
            if x < A and y < B:
                lines[y][x] = 1
            if x >= A and y >= B:
                lines[y][x] = 1

    for line in lines:
        print("".join(map(str, line)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 12916
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>

using namespace std;

unsigned long long int a = 0, b = 0, c =1, d = 0, e = 0, n = 0,x=0,y=0,z=0, maxy = 0, mini = 9999, counter = 0, sur = 0,kuso=0,kuso2=0,ans=0;
std::vector<unsigned long long int> vec{}, vecsec{};
unsigned long long int iremono[101][101];
std::vector<std::string>str{};
std::vector<std::string>str2{};
bool okada = false;
int arraykun[2300] = {}, nyan[1001] = {}, koji[50][50];
std::string output, output2, input,nyahhoi;
char kakunou[101][101] = {};
int kakunou2[50][50] = {};
int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {
	
		c = i % j;
		i = j;
		if (c != 0) {
		
			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int main()
{
	cin >> a >> b;
	for (int i = 0; i < a; i++) {
		for (int j = 0; j < b; j++) {
			cin >> kakunou[i][j];
		}
	}

	for (int j = 0; j < b; j++) {
		okada = false;
		for (int i = 0;i < a - 1; i++) {

			if (kakunou[i][j] == '.' &&kakunou[i+1][j] == '.') {

			}
			else {
				okada = true;
			}
			if (okada == false && i == a - 2) {
				for (int k = 0; k < a; k++)
					iremono[k][j] = 1;
			}
		}
	}

	for (int i = 0; i < a; i++) {
		okada = false;
		for (int j = 0; j < b-1; j++) {
		
			if (kakunou[i][j] =='.' &&kakunou[i][j + 1]=='.') {
			}
			else {
				okada = true;
			}
			if (okada==false&&j == b - 2) {
				for (int k = 0; k < b;k++) {
					iremono[i][k] = 2;
				}
			}
		}
	}
	okada = false;
	for (int i = 0; i < a; i++) {
		for (int j = 0; j < b; j++) {
			if (iremono[i][j] ==2) {
				okada = true;
			}
			if (iremono[i][j] == 0) {
				cout << kakunou[i][j];
			}
		}
		if (!okada) {
			cout << endl;
		}
		else {
			okada = false;
		}
	}


}






Measured memory_bytes: 384
<?php
 
$a=trim(fgets(STDIN));
 $b=explode(" ",trim(fgets(STDIN)));
 if(in_array(0,$b)){
     echo 0;
     exit;
 }
 $total=1;
 for($i=0;$i<$a;$i++){
     $total*=$b[$i];
 }
$d=pow(10,18);
 if($total>$d){
     echo "-1";
   exit;
  }
echo $total;

Measured memory_bytes: 25740
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin >> n;
    vector<ll> a(3 * n);
    priority_queue<ll, vector<ll>, greater<ll>> left;
    priority_queue<ll> right;
    ll lsum = 0, rsum = 0;
    rep(i, 3 * n) {
        cin >> a[i];
        if (i < n) {
            left.push(a[i]);
            lsum += a[i];
        }
        if (i >= 2 * n) {
            right.push(a[i]);
            rsum += a[i];
        }
    }

    vector<ll> l(3 * n);
    l[n - 1] = lsum;
    for (int i = n; i < 2 * n; i++) {
        left.push(a[i]);
        lsum += a[i];
        lsum -= left.top();
        left.pop();
        l[i] = lsum;
    }

    vector<ll> r(3 * n);
    r[2 * n] = rsum;
    for (int i = 2 * n - 1; i > n - 1; i--) {
        right.push(a[i]);
        rsum += a[i];
        rsum -= right.top();
        right.pop();
        r[i] = rsum;
    }

    // rep(i, 3 * n) cout << l[i] << " \n"[i == 3 * n - 1];
    // rep(i, 3 * n) cout << r[i] << " \n"[i == 3 * n - 1];

    ll ans = -LINF;
    for (int i = n - 1; i < 2 * n; i++) {
        chmax(ans, l[i] - r[i + 1]);
    }
    cout << ans << endl;
}


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

int main(void) {
	int n, d;
	cin >> n >> d;
	int ans = 0;
	ans = n / (d * 2 + 1);
	if (n%(d*2 + 1) != 0) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int a[100];
int b[10000];
signed main() {
	int n = read(), m = 0;
	for (int i = 2; i <= n; i++) {
		for (int j = 2; j < i; j++) {
			if (i % j == 0) goto loop;
		}
		for (int j = 2; j <= n; j++) {
			int k = j;
			while (k % i == 0) {
				a[m]++;
				k /= i;
			}
		}
		m++;
	loop:;
	}
	for (int i = 0; i < m; i++) {
		b[a[i]]++;
	}
	for (int i = 1000; i >= 0; i--) {
		b[i] += b[i + 1];
	}
	int ans = b[4] * (b[4] - 1) / 2 * (b[2] - 2) + (b[2] - 1) * b[24] + b[14] * (b[4] - 1) + b[74];
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int prime[100010];
bool is_prime[1000010];
void sieve(int n){
    // n以下の素数を求める
    int p = 0;
    for(int i=0;i<=n;i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <=n ; i++){
        if(is_prime[i]){
            prime[p++]=i;
            for(int j=2*i;j <=n;j+=i) is_prime[j] = false;
        }
    }
}
int main(){
    cout << fixed << setprecision(10);
    sieve(100000);
    int q;
    cin >> q;
    vector<int> ans(100010,0);
    rep(i,100001){
        if(i%2!=0){
            if(is_prime[i] && is_prime[(i+1)/2]){
                ans[i] = ans[i-1] +1;
            }else ans[i] = ans[i-1];
        }else if(i!=0) ans[i] = ans[i-1];
    }
    rep(i,q){
        int l,r;
        cin >> l >> r;
        cout << ans[r] - ans[l-1] << endl;
    }
    return 0;
}

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

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

int main(){
	//freopen("c.in","r",stdin);
	int x;
	cin >> x;
	long long l = 1, r = (int)1e9;
	while(l<r) {
		 long long m = l + (r-l)/2;
		 long long sum = m*(m+1)/2;
		if(sum>=x) r = m;
		else l = m+1;
	}
	cout << l << endl;
	return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N, t;
	ldbl ans = 0.0;
	ldbl x, h;

	cin >> N >> t;
	for(int i = 0; i < N; i++){
		cin >> x >> h;
		ans = max(ans, h*1.0/x);
	}

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

	return 0;
}


Measured memory_bytes: 3284
import itertools
h, w, k = map(int, input().split())
ans = 0
s = [input() for _ in range(h)]
for hi in itertools.product([0, 1], repeat=h):
	for wi in itertools.product([0, 1], repeat=w):
		cnt = 0
		for i, j in itertools.product(range(h), range(w)):
			if hi[i] and wi[j]:
				if s[i][j] == "#":
					cnt += 1
		if cnt == k:
			ans += 1
print(ans)


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  int n;
  cin >> n;
  int ar[n + 5];
  for (int i = 0; i < n; i++){
    cin >> ar[i];
  }
  ld sum = 0;
  for (int i = 0; i < n; i++){
    sum += (1.0 / (ld)ar[i]);
  }
  cout << fixed << setprecision(10);
  cout << 1.0 / sum << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <random>
#include <ctime>
#define ll long long
#define mod 1000000007
#define maxn 20000000
using namespace std;
//ifstream cin("input.txt"); ofstream cout("output.txt");
//ifstream cin("search.in"); ofstream cout("search.out");
ll step(ll a, ll n) {
	if (n == 0) return 1;
	else if (n % 2 == 0) return step(a*a, n / 2);
	else return a*step(a, n - 1);
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	int cx = 0, cy = 0, ct = 0;
	for (int i = 0; i < n; i++) {
		int t, nx, ny;
		cin >> t >> nx >> ny;
		int dist = abs(cx - nx) + abs(cy - ny);
		if (t - ct >= dist && (t - ct - dist) % 2 == 0){
			ct = t;
			cx = nx;
			cy = ny;
			continue;
		}
		else {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int N = sc.nextInt();
		TreeSet<Pair> set = new TreeSet<>();
		for (int i = 0; i < N; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			set.add(new Pair(a, b));
		}
		int ans = H;
		int canFrom = 1;
		while (!set.isEmpty() && set.first().s == 1) {
			ans = Math.min(ans, set.pollFirst().f - 1);
		}
		for (int j = 2; j <= W; j++) {
			canFrom++;
			Pair tmp = new Pair(canFrom, j);
			while (set.contains(tmp)) {
				canFrom++;
				tmp.f++;
			}
			SortedSet<Pair> next = set.tailSet(tmp);
			if (!next.isEmpty() && next.first().s == j) {
				ans = Math.min(ans, next.first().f - 1);
			}
		}
		out.println(ans);
		
		out.flush();
	}
	
	static class Pair implements Comparable<Pair> {
		int f, s;
		
		public Pair(int f, int s) {
			this.f = f;
			this.s = s;
		}
		
		@Override
		public int compareTo(Pair o) {
			int cmp = Integer.compare(s, o.s);
			if (cmp != 0) return cmp;
			return Integer.compare(f, o.f);
		}
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 71456
k = int(input())

def lunlun(a):
    res = []
    for i in a:
        j = int(i[-1])
        if j == 0:
            res += [i + '0', i +'1']
        elif j == 9:
            res += [i + '8', i +'9']
        else:
            res += [i + str(j-1),  i + str(j), i + str(j+1)]
    return res


res = []
a = list(map(str, range(1, 10)))
while len(res) < k:
    if not res:
        tmp = a
    else:
        tmp = lunlun(tmp)
    res.extend(tmp)

print(res[k-1])

Measured memory_bytes: 18448
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <queue>
#include <map>
#include <stack>
#define ll long long
using namespace std;



int main(){
  //cout<<123<<endl;
  int n,x,y;cin>>n>>x>>y;
  cout<<min(x,y)<<" "<<max(x+y-n,0)<<endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<algorithm>

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

using namespace std;

const double INF=1e77;
const double EPS=1e-8;
const double PI=acos(-1);

template<class T>
struct point{
	T x,y;
	point operator+(const point &a)const{ return (point){x+a.x,y+a.y}; }
	point operator-(const point &a)const{ return (point){x-a.x,y-a.y}; }
};

template<class T>
point<T> operator*(T c,const point<T> &a){
	return (point<T>){c*a.x,c*a.y};
}

point<double> rot(const point<double> &a,double theta){
	return (point<double>){a.x*cos(theta)-a.y*sin(theta),a.x*sin(theta)+a.y*cos(theta)};
}

template<class T>
struct segment{
	point<T> a,b;
};

struct star{
	point<double> c;
	double a,r;
	point<double> p[5];
};

template<class T>
T dot(const point<T> &a,const point<T> &b){ return a.x*b.x+a.y*b.y; }

template<class T>
T cross(const point<T> &a,const point<T> &b){ return a.x*b.y-a.y*b.x; }

enum{CCW=1,CW=-1,ON=0};
int ccw(const point<double> &a,const point<double> &b,const point<double> &c){
	double rdir=cross(b-a,c-a);
	if(rdir> EPS) return CCW;
	if(rdir<-EPS) return CW;
	return ON;
}

bool intersect(const segment<double> &S1,const segment<double> &S2){
	if(max(S1.a.x,S1.b.x)+EPS<min(S2.a.x,S2.b.x)
	|| max(S1.a.y,S1.b.y)+EPS<min(S2.a.y,S2.b.y)
	|| max(S2.a.x,S2.b.x)+EPS<min(S1.a.x,S1.b.x)
	|| max(S2.a.y,S2.b.y)+EPS<min(S1.a.y,S1.b.y)) return false;
	return ccw(S1.a,S1.b,S2.a)*ccw(S1.a,S1.b,S2.b)<=0
		&& ccw(S2.a,S2.b,S1.a)*ccw(S2.a,S2.b,S1.b)<=0;
}

template<class T>
T dist2(const point<T> &a,const point<T> &b){
	return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}

template<class T>
double dist2(const segment<T> &S,const point<T> &p){
	if(dot(S.b-S.a,p-S.a)<=0) return dist2(p,S.a);
	if(dot(S.a-S.b,p-S.b)<=0) return dist2(p,S.b);
	return (double)cross(S.b-S.a,p-S.a)*cross(S.b-S.a,p-S.a)/dist2(S.a,S.b);
}

template<class T>
double dist(const segment<T> &S1,const segment<T> &S2){
	if(intersect(S1,S2)) return 0;
	return sqrt(min(min(dist2(S1,S2.a),dist2(S1,S2.b)),
					min(dist2(S2,S1.a),dist2(S2,S1.b))));
}

int main(){
	for(int n,m,l;scanf("%d%d%d",&n,&m,&l),n||m||l;){
		m--;
		l--;

		star S[100];
		rep(i,n){
			scanf("%lf%lf%lf%lf",&S[i].c.x,&S[i].c.y,&S[i].a,&S[i].r);
		}

		rep(i,n){
			S[i].p[0]=(point<double>){0,S[i].r};
			S[i].p[0]=rot(S[i].p[0],S[i].a/180*PI);
			for(int j=1;j<5;j++){
				S[i].p[j]=rot(S[i].p[j-1],2*PI/5);
			}
			rep(j,5) S[i].p[j]=S[i].p[j]+S[i].c;
		}

		int f1[5]={0,2,4,1,3};
		int f2[5]={2,4,1,3,0};

		double d[100][100];
		rep(i,n) rep(j,n) {
			d[i][j]=INF;
			rep(a,5) rep(b,5) d[i][j]=min(d[i][j],dist((segment<double>){S[i].p[f1[a]],S[i].p[f2[a]]},(segment<double>){S[j].p[f1[b]],S[j].p[f2[b]]}));
		}

		rep(k,n) rep(i,n) rep(j,n) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);

		printf("%.15f\n",d[m][l]);
	}

	return 0;
}

Measured memory_bytes: 912
// Java program For handling Input/Output 
import java.io.*; 
import java.util.*;
import java.math.*;
//import java.awt.*;

public class Main 
{ 
    FastReader sc;
    //actual logic
    void solve() throws IOException{
        int n = sc.ni();
        int k = sc.ni();
        int h[] = new int[n];
        long sum = 0;
        for(int i = 0;i < n;i++)
        {
            h[i] = sc.ni();
            sum += h[i];
        }

        if(k >= n)
            System.out.println(0);
        else
        {
            Arrays.sort(h);
            for(int i = 0;i < k;i++)
            {
                sum -= h[n-1-i];
            }
            System.out.println(sum);
        }

    }   

    //constructor
    Main()
    {
        try{  
            sc = new FastReader();
        }catch(Exception e){
            System.out.println(e);
        }
    }


    //main metohd
    public static void main(String[] args) throws IOException
    { 
     new Main().solve();
 }
    //Utility methods

 static class FastReader{
    BufferedReader br;
    StringTokenizer st;
    FastReader(){
        br = new BufferedReader(new InputStreamReader(System.in));
        try{
            st = new StringTokenizer(br.readLine());
        }catch(Exception e){
            System.out.println(e);
        }
    }

    FastReader(String s){
        try{
            br = new BufferedReader(new FileReader(s));
            st = new StringTokenizer(br.readLine());
        }catch(Exception e){
            System.out.println(e);
        }
    }

    String ns(){
        if(!st.hasMoreTokens())
        {
            try{
                st = new StringTokenizer(br.readLine());
            }catch(Exception e){
                System.out.println(e);
            }    
        }
        return st.nextToken();

    }

    int ni(){
        return Integer.parseInt(ns());
    }

    long nl(){
        return Long.parseLong(ns());
    }

    double nd(){
        return Double.parseDouble(ns());
    }
}
}


Measured memory_bytes: 56728