akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
using namespace std;
typedef pair<int, int>p;
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
vector<long long> divisor(long long n) {
	vector< long long> ret;
	for (long long i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return (ret);
}
struct LazySegmentTree {
private:
	int n;
	vector<int> node, lazy;
	vector<bool> lazyFlag;

public:
	LazySegmentTree(vector<int> v) {
		int sz = (int)v.size();
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1);
		lazy.resize(2 * n - 1, INT_MAX);
		lazyFlag.resize(2 * n - 1, false);

		for (int i = 0; i<sz; i++) node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
	}

	void lazyEvaluate(int k, int l, int r) {
		if (lazyFlag[k]) {
			node[k] = lazy[k];
			if (r - l > 1) {
				lazy[k * 2 + 1] = lazy[k * 2 + 2] = lazy[k];
				lazyFlag[k * 2 + 1] = lazyFlag[k * 2 + 2] = true;
			}
			lazyFlag[k] = false;
		}
	}

	void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k] = x;
			lazyFlag[k] = true;
			lazyEvaluate(k, l, r);
		}
		else {
			update(a, b, x, 2 * k + 1, l, (l + r) / 2);
			update(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = min(node[2 * k + 1], node[2 * k + 2]);
		}
	}

	int find(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return INT_MAX;
		if (a <= l && r <= b) return node[k];
		int vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
		int vr = find(a, b, 2 * k + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};
long long mod = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(16);
	int n, m;
	cin >> n >> m;
	int s[2004];
	int t[2004];
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> t[i];
	}
	long long dp[2003] = { 0 };
	long long dp2[2003] = { 0 };
	long long sum = 0;
	for (int j = m - 1; j >= 0; j--) {
		sum = 0;
		for (int i = n - 1; i >= 0; i--) {
			if (s[i] == t[j]) {
				dp2[i] = sum+1;
				dp2[i] %= mod;
			}
			else {
				dp2[i] = 0;
			}
			sum += dp[i];
			sum %= mod;
		}

		for (int i = 0; i < n; i++) {
			dp[i] += dp2[i];
			dp[i] %= mod;
		}
	}
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		ans += dp[i];
		ans %= mod;
	}
	cout <<ans+1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

template <typename T>
class SegmentTree
{
private:
  using Fn = function<T(T, T)>;
  int N;
  vector<T> dat;
  T unit;
  Fn func;

public:
  SegmentTree() {}
  SegmentTree(int n_, Fn func_, T unit_) : func(func_), unit(unit_)
  {
    N = 1;
    while (N < n_)
      N *= 2;
    dat.assign(2 * N - 1, unit);
  }

  void init(int n_, Fn func_, T unit_)
  {
    func = func_, unit = unit_;
    N = 1;
    while (N < n_)
      N *= 2;
    dat.assign(2 * N - 1, unit);
  }

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

  T query(int a, int b, int k = 0, int l = 0, int r = -1)
  {
    if (r < 0)
      r = N;
    if (r <= a || b <= l)
      return unit;
    if (a <= l && r <= b)
      return dat[k];
    else
    {
      T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
      T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
      return func(vl, vr);
    }
  }
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n;
  cin >> n;
  pii p[200010];
  rep(i, n)
  {
    int h;
    cin >> h;
    p[i] = MP(h, i);
  }
  ll a[200010];
  rep(i, n) cin >> a[i];
  sort(p, p + n);
  auto my_max = [](ll a, ll b) { return max(a, b); };
  SegmentTree<ll> sg(n, my_max, 0);
  rep(j, n)
  {
    int i = p[j].second;
    sg.update(i, sg.query(0, i) + a[i]);
  }
  cout << sg.query(0, n) << endl;
  return 0;
}


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

#define inf 2000000000
#define INF 1e18

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vl;
typedef vector<ii> vii;

#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define togglebit(n,i) ((n)^(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define lb lower_bound
#define ub upper_bound
#define sz(x) (ll)x.size()
#define all(x) begin(x), end(x)
#define f0r(i, a) for (ll i=0; i<a; i++)
#define FOR(i, a) for (ll i=1; i<=a; i++)
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front

ll a[105];

int main()
{
    ll n,m,t,i,j,x,y,b,d,w;
    cin>>n>>d;
   //w=d*d;
    ll cnt=0;
    while(n--){
    cin>>x>>y;
    ll p=x*x;
    ll q=y*y;
    if(sqrt(p+q)<=d)
    cnt++;
    }
    cout<<cnt<<endl;

}    


Measured memory_bytes: 3688
#include<stdio.h>
int main(void)
{
  long long a;
  double b;
  scanf("%lld %lf",&a,&b);
  int c=b*100+0.5;
  // printf("%d\n",c);
  // printf("%lld\n",(a*c/100));
  printf("%lld\n",(long long)(a*c/100));
  return 0;
}


Measured memory_bytes: 1752
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// スペース区切りの整数の入力
		int b = sc.nextInt();
      int[] hairetu=new int[b];
        for(int i=0;i<hairetu.length;i++){
          int c=sc.nextInt();
          hairetu[i]=c;
        }
      int count=0;
      int champ=hairetu[0];
      for(int k=0;k<hairetu.length;k++){
        if(champ>=hairetu[k]){
          champ=hairetu[k];
          count++;
        }
      }
      System.out.println(count);
	}
}

Measured memory_bytes: 87352
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007

// void dfs(int x, int y, vector<vector<int>>& grid, vector<vector<int>>& ans,int& n, int& m)
// {
// 	ans[x][y]++;
// 	ans[x][y]%=M;

// 	if(x+1 < n && grid[x+1][y]==1)
// 		dfs(x+1,y,grid,ans,n,m);
// 	if(y+1 < m && grid[x][y+1]==1)
// 		dfs(x,y+1,grid,ans,n,m);
// }

int main()
{

	// #ifndef ONLINE_JUDGE
	// 		freopen("input", "r", stdin);
	// 		freopen("output","w",stdout);
	// #endif

	int n,m;	cin>>n>>m;
	// vector<vector<int>> v(n,vector<int>(m,0)), ans(n,vector<int>(m,0));
	int v[n][m], ans[n][m];

	memset(v,0,sizeof(v));
	memset(ans,0,sizeof(ans));

	for(int i=0;i<n;++i)
		for(int j=0;j<m;++j)
		{
			char c;	cin>>c;
			if(c=='.')	v[i][j]=1;
		}

	ans[0][0]=1;
	

	for(int i=0;i<n;++i)
		for(int j=0;j<m;++j)
			if(v[i][j]==1 && (j!=0 || i!=0))
				ans[i][j] = ((i-1>=0?ans[i-1][j]:0) + (j-1>=0?ans[i][j-1]:0))%M;

	cout<<ans[n-1][m-1]<<endl;

}

Measured memory_bytes: 11368
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
using namespace std;

int main(){
  string x;
  int p;
  cin >> x >> p;

  vector<string> v;
  for (int i=0; i<x.length(); i++) {
    for (int j=1; j<=p; j++) {
      v.push_back(x.substr(i, j));
    }
  }

  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  cout << v[p-1] << endl;
}


Measured memory_bytes: 1160
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc095_a.cpp
 * time   : Thu Apr 30 18:30:54 2020
 * quest  : A - Something on It
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  cout << 700 + (s[0] == 'o' ? 100 : 0) + (s[1] == 'o' ? 100 : 0) + (s[2] == 'o' ? 100 : 0) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

vec eratosthenes(ll n) {
    vector<bool> sieve(n+1, true);
    vector<ll> table;
    sieve[0] = sieve[1] = false;
    for (ll i = 2; i <= n; i++) {
        if (sieve[i]) {
            table.push_back(i);
            for (ll j = 2; i * j <= n; j++) {
                sieve[i * j] = false;
            }
        }
    }

    return table;
}

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

    ll N;
    cin >> N;
    vec A(N);
    ll check = 0;
    Rep (i, N) {
        cin >> A[i];
        check = gcd(check, A[i]);
    }

    if (check != 1) {
        cout << "not coprime\n";
        return 0;
    }

    auto primes = eratosthenes(1300);
    ll primenum = primes.size();
    // cout << primenum << "\n";
    set<ll> used;

    Rep (i, N) {
        Rep (j, primenum) {
            if (A[i] % primes[j] == 0) {
                if (used.find(primes[j]) != used.end()) {
                    cout << "setwise coprime\n";
                    return 0;
                } else {
                    used.insert(primes[j]);
                    while (A[i] % primes[j] == 0) {
                        A[i] /= primes[j];
                    }
                }
            }
        }

        if (A[i] > 1) {
            if (used.find(A[i]) != used.end()) {
                cout << "setwise coprime\n";
                return 0;
            } else {
                used.insert(A[i]);
            }
        }
    }

    cout << "pairwise coprime\n";
}

Measured memory_bytes: 11112
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#include <time.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
 
using namespace std;

class UF
{
private:
    int         num;
    vector<int> par;
    vector<int> siz;
public:
    //vector<int> val;
public:
    UF(int n): num(n) {
        par.resize(n);
        siz.resize(n);
        //val.resize(n);
        int i;
        for(i=0; i<n; i++) {
            par[i]=i; siz[i]=1;
            //val[i]=0;
        }
    }
	
    int find(int x) {
        if(x==par[x]) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(siz[x]<siz[y]) {
            par[x]=y;
            siz[y]=siz[x]+siz[y];
            //val[y]=val[x]+val[y];
        }
        else {
            par[y]=x;
            siz[x]=siz[x]+siz[y];
            //val[x]=val[x]+val[y];
        }
    }

    bool same(int x, int y) {
        return find(x)==find(y);
    }

    int size(int x) {
        return siz[find(x)];
    }

    int ngroup() {
    //int ngroup( int& ans ) {
        int count=0;
        int i;
        for(i=0; i<num; i++) {
            if(par[i]==i) {
                count++;
                //ans += (val[i]? siz[i]: siz[i]-1);
            }
        }
        return count;
    }
};

int main(int argc, char* argv[])
{
    int n,Q;
    scanf("%d%d", &n, &Q);
    UF uf(n);
    int i;
    for(i=0; i<Q; i++) {
        int flag,x,y;
        scanf("%d%d%d", &flag, &x, &y); 
        if(flag==0) {
            uf.unite(x,y);
        }
        else {
            if(uf.same(x,y)) printf("1\n");
            else printf("0\n");
        }
    }

    return 0;
}



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

int main() {
    // input
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    // solve & output
    if (A + B  > C + D) cout << "Left" << endl;
    else if (A + B < C + D) cout << "Right" << endl;
    else cout << "Balanced" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<limits.h>
#include<float.h>

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(){
	int n, k;
	int *h, *h_tmp;
	int min = INT_MAX;
	scanf("%d%d\n", &n, &k);
	h = (int*)malloc(sizeof(int) * n);
	h_tmp = h;
	for(int i=0 ; i<n; i++){
		scanf("%d", h_tmp++);
	}
	qsort(h, n, sizeof(int), asc);
	for(int i=0; i<n - (k - 1); i++){
		int tmp = h[i + k - 1] - h[i];
		if(tmp < min) min = tmp;
	}
	free(h);
	printf("%d", min);
	return 0;
}

Measured memory_bytes: 892
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    A, B, C, K = map(int, input().split())
    
    if A >= K:
        print(K)
    elif A + B >= K:
        print(A)
    else:
        print(A - (K - A - B))


if __name__ == '__main__':
    main()

Measured memory_bytes: 77524
#include<stdio.h>

int main (void)

{
	int n;
	int i;
	int kane = 100000;
	int max = 0.0;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		max = (kane * 1.05);
		if (max % 1000 != 0){
			kane = (((max/1000) + 1) * 1000);
		}
		else if(max % 1000 == 0){
			kane = max;
		}
	}
	
	printf("%d\n", kane);
	
	return(0);
}

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

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

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

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::cmp::max;

fn main() {
    let nw: Vec<usize> = read_vec();
    let n = nw[0];
    let maxw = nw[1] as usize;
    let vw: Vec<Vec<u32>> = read_vec2(n);
    let mut dp: Vec<u32> = vec![0; maxw + 1];

    for i in 0..n {
        let v = vw[i][0];
        let w = vw[i][1] as usize;
        for j in 0..maxw + 1 {
            if j >= w {
                dp[j] = max(dp[j - w] + v, dp[j]);
            }
        }
    }

    println!("{}", dp[maxw]);
}



Measured memory_bytes: 5036
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=1e2+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
  }


string s;
int k,dp[N][N][2];
vi nax;



int cal(int pos,int cnt,int f) {
	  if(pos==sz(nax)) {
		    if(cnt==k) return 1;
		    else return 0;
		  }
	  
	  if(dp[pos][cnt][f]!=-1) return dp[pos][cnt][f];
	  
	  int yan=(f?9:nax[pos]);
	  int ans=0;
	  for(int i=0;i<=yan;i++) {
		     int ct=cnt;
		     int cf=f;
		     if(i<nax[pos]) cf=1;
		     if(i!=0) ct++;
		     ans+=cal(pos+1,ct,cf);
		  }	   
		  
		  return dp[pos][cnt][f]=ans;
}

void solve() {
   cin>>s;
   cin>>k;
   
   memset(dp,-1,sizeof(dp));
   
   rep(i,0,sz(s)) {
	      int yo=s[i]-'0';
	      nax.pb(yo);
	   }
   
   int res=0;
   res+=cal(0,0,0);
   cout<<res<<endl;     
               
}

    
int32_t main() {
	cool;
	int t=1;	

	//cin>>t;
	while(t--)
	  solve();

  return 0;	   
}


Measured memory_bytes: 3756
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  ll n;
  cin >> n;
  
  repo(i,40000) {
    if(i*i>n) {
    cout << (i-1)*(i-1);
    return 0;
    }
  }

  
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(scan.nextInt());
		}
		
		Collections.sort(list);
		
		System.out.println(list.get(list.size() - 1) - list.get(0));
	}
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);


int main()
{
    int i = 0, j = 0, cs = 0, in;
    ll n, m; cin>>n>>m;
    ll cnt = 0;
    for(i = 0; i < m; i++){
        int in; cin>>in; cnt += in;
    }
    if(cnt > n) cout << -1 << endl;
    else cout << n - cnt << endl;
    return 0;
}


Measured memory_bytes: 3624
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long[] x = new long[](2);
    x[0] = lread();
    x[1] = lread();
    x.sort();
    if (x == [1, 2])
        writeln(3);
    if (x == [1, 3])
        writeln(2);
    if (x == [2, 3])
        writeln(1);
}


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

int main() {
 
  int N;
  cin >> N;
  
  //10でNを割って商と余りを使ってf(N)を判定していくよ。
  int t, c, C;
    t = N, c = 0;
  for (int i = 0; ; i++){
  
    c = t % 10;
    t = t / 10;
    C = C + c;
    
    if (t == 0) {
     // cout << t << " " << C << endl;
      if (N % C == 0){
        cout << "Yes" << endl;
      }
      else {
        cout << "No" << endl;
      }
    break;
    }
        
  } 
  
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a < b) swap(a, b);
  cout << string(a, '0' + b) << endl;
  return 0;
}

Measured memory_bytes: 256
################################################################
##............................................................##
##........................######..............................##
##.........................#######............................##
##........................#######.............................##
##.......................#####..####..........................##
##.....................#####......#####.......................##
##....................#####.........#####.....................##
##..................#############....######...................##
##................#####....########....######.................##
##..............#####........####........#######..............##
##............#####................######..#########..........##
##..........#####............##############.#############.....##
##........####.....##############...#######...###############.##
##.....##............##########....######.......################
##..........................#####..#####......................##
##..........................####..#####.......................##
##..........................####.#####........................##
##..........................####.#####........................##
##.........................#####..............................##
##..........................###...............................##
##............................................................##
##............................................................##
##..................#########.................................##
##..............##############................................##
##...........############.....................................##
##....................####....................................##
##.....................########..................##...........##
##................##############...........############.......##
##.........################...#####...#####...##########......##
##..#######################....#######.........########.......##
##....########.....###########..######.........#######........##
##........#......#####.#######...######.......#######.........##
##.............######..####.......####################........##
##...........#####.....###........###################.........##
##........###..........###.........##.........................##
##....................####....................................##
##....................####....................................##
##.....................###....................................##
################################################################

from collections import Counter as C

n = int(input())
a = list(map(int,input().split()))

acc = [0]
for i in a:
    acc.append(i + acc[-1])

res = 0
for k,v in C(acc).most_common():
    res += v * (v - 1) // 2
print(res)


Measured memory_bytes: 48636
#include <bits/stdc++.h>
using namespace std;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    ll ans=0;
    vector<ll>a(n),b(n);
    rep(i,n)cin>>a[n-1-i]>>b[n-1-i];
    
    rep(i,n){
      a[i]+=ans;
      ll t=b[i]-(a[i]%b[i]);
      if(t!=b[i]){
        a[i]+=t;
        ans+=t;
      }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
    std::fill((T *)array, (T *)(array + N), val);
}

int main()
{
    int n, m, q;
    cin >> n >> m >> q;
    int a[55], b[55], c[55], d[55];
    repi(i, q, 0)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    vector<int> vec(n+m,1);
    repi(i, m, 0)
    {
        vec[i] = 0;;
    }
    int ans = 0;
    do
    {
        int zero_cnt = 0;
        vector<int> A;
        repi(i, n + m, 0)
        {
            if (vec[i] == 0)
                zero_cnt++;
            else{
                A.push_back(zero_cnt);
                if(zero_cnt == 0){
                    A.clear();
                    break;
                }
            }
        }
        if(A.size() != n)continue;
        int s = 0;
        repi(i, q, 0)
        {
            if (A[b[i] - 1] - A[a[i] - 1] == c[i])
                s += d[i];
        }
        ans = max(ans, s);
    } while (next_permutation(vec.begin(), vec.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = k; i < n; i++) {
        if(a[i] > a[i - k]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 4788
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int n,k,s;cin>>n>>k>>s;
    if(k==n){
        for(int i=0;i<n;i++){
            if(i==n-1)cout<<s<<endl;
            else cout<<s<<" ";
        }return 0;
    }
    if(s==1){
        for(int i=0;i<k;i++){
            cout<<1<<" ";
        }
        for(int i=k;i<n;i++){
            cout<<10;
            if(i==n-1)cout<<endl;
            else cout<<" ";
        }return 0;
    }
    int age=(s+1)/2;
    int sage=s/2;
    for(int i=0;i<=k;i++){
        if(i%2==0)cout<<age;
        else cout<<sage;
        if(i==n-1)cout<<endl;
        else cout<<" ";
    }
    for(int i=0;i<n-(k+1);i++){
        if(s==1000000000)cout<<999999999;
        else cout<<1000000000;
        if(i==n-(k+1)-1)cout<<endl;
        else cout<<" ";
    }
}


Measured memory_bytes: 3592
N = int(input())
A = list(map(int, input().split()))
m1 = int(sum(A) / N)
# 切り捨て
m2 = int(sum(A) / N) + 1
# (ほぼ)切り上げ
print(min(sum([(a - m1) ** 2 for a in A]), sum([(a - m2) ** 2 for a in A])))


Measured memory_bytes: 2940
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import accumulate

h,w,d = li()
a = [list(li()) for _ in range(h)]

num2point = [(-1,-1)]*(h*w)
for r, ai in enumerate(a):
    for c, aij in enumerate(ai):
        num2point[aij-1] = (r, c)
    

dist = [[] for _ in range(d)]
for i in range(h*w):
    if i // d == 0:
        dist[i%d].append(0)
        
    else:
        dist[i%d].append(abs(num2point[i][0]-num2point[i-d][0]) + abs(num2point[i][1]-num2point[i-d][1]))
        
dist_cum = [list(accumulate(dist_row)) for dist_row in dist]


q = ni()
for _ in range(q):
    l,r = li_()
    print(dist_cum[l%d][r//d] - dist_cum[l%d][l//d])

Measured memory_bytes: 41276
#include<cstdio>
#include<cstdlib>
#include<cstring>

using namespace std;

struct Node {
    int key;
    Node *next, *prev;
};

Node *nil;

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->prev = nil;
    nil->next = nil;
}

Node* listSearch(int key){
    Node* cur = nil->next;
    while(cur != nil && cur->key != key){
        cur = cur->next;
    }
    return cur;
}

void printList(){
    Node* cur = nil->next;
    int isFirst = 0;
    while(1){
        if(cur == nil) break;
        if(isFirst++ > 0)   printf(" ");
        printf("%d" , cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void insert(int key){
    Node* x = (Node *)malloc(sizeof(Node));
    x->key = key;
    
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

void deleteNode(Node* del){
    if(del == nil) return;
    del->prev->next = del->next;
    del->next->prev = del->prev;
    free(del);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

int main(){
    char op[20];
    int key, n, i;

    scanf("%d", &n);
    init();
    for(i = 0; i < n; i++){
        scanf("%s%d" , op , &key);
        if(op[0] == 'i'){
            insert(key);
        }else if(op[0] == 'd'){
            if(strlen(op) > 6){
                if(op[6] == 'F'){
                    deleteFirst();
                }else if(op[6] == 'L'){
                    deleteLast();
                }
            }else{
                deleteKey(key);
            }
        }
    }

    printList();

    return 0;
}


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

int main(void){
	string s;cin >> s;

	for(int i=0;i<s.size()-1;i++){
		if(s[i] == s[i+1]){
			cout << i+1 << " " << i+2 << endl;return 0;
		}
		if(i < s.size()-2 && s[i] == s[i+2]){
			cout << i+1 << " " << i+3 << endl;return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
const int MAXSIZE = 10000+2;
int C[MAXSIZE];
void Counting_sort(int A[], int B[], int k,int n) {
	for (int i = 0; i <= k; i++) {
		C[i] = 0;
	}
	for (int j = 0; j < n; j++) {
		C[A[j]]++;
	}
	for (int i = 1; i <= k; i++) {
		C[i] = C[i] + C[i - 1];
	}
	for (int j = n - 1; j >= 0; j--) {
		B[C[A[j]]] = A[j];
		C[A[j]]--;
	}
}
int main() {
	int n = 0;
	scanf("%d", &n);
	int*A, *B;
	A = (int*)malloc(sizeof(int)*n + 2);
	B = (int*)malloc(sizeof(int)*n + 2);
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	Counting_sort(A, B, MAXSIZE, n);
	for (int i = 1; i <= n; i++) {
		if (i > 1)printf(" ");
		printf("%d", B[i]);
	}
	printf("\n");
	return 0;

}

Measured memory_bytes: 18360
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int main(){
    int a,b,c,d,e,k;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);
    if (abs(a-b)<=k&&abs(a-c)<=k&&abs(a-d)<=k&&abs(a-e)<=k&&abs(b-c)<=k&&abs(b-d)<=k&&abs(b-e)<=k&&abs(c-d)<=k&&abs(c-e)<=k&&abs(d-e)<=k) {
        printf("Yay!\n");
    }else{
        printf(":(\n");
    }
    return 0;
}


Measured memory_bytes: 128
H,W = map(int,input().split())
A = [input() for _ in range(H)]

for i in range(H+W-1):
  if i < W:
    x = i
    y = 0
  else:
    x = W-1
    y = i-x
  cnt = 0
  while(x >= 0 and y < H):
    if A[y][x] == '#':
      cnt += 1
    #print(x,y,cnt)
    if cnt > 1:
      print('Impossible')
      exit()
    x -= 1
    y += 1
print('Possible')

Measured memory_bytes: 38544
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    
	    String s=sc.nextLine();
	    char[] c=s.toCharArray();
	    
	    int len=s.length();
	    int ans10=0;
	    int ans01=0;
	    
	    for(int i=0;i<len;i++) {
	    	if(i%2==0) {
	    		if(c[i]=='0') {
	    			ans10++;
	    		}else if(c[i]=='1') {
	    			ans01++;
	    		}
	    	}else if(i%2==1){
	    		if(c[i]=='0') {
	    			ans01++;
	    		}else if(c[i]=='1') {
	    			ans10++;
	    		}
	    	}
	    

	    }
	    
	    int ans=ans10<ans01?ans10:ans01;
	    System.out.println(ans);
	    
	}

}


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

"""
Sは全部0と仮定して良い，最後に2^N倍
Cはソートしておく，後ろから使う．

iは0indexとする
各C[i]ごとに見るか，そうしたら，それが何番目かによって寄与が決まる
i桁目なので左にi桁あるけど，これは通り数にしか関与しない
右側にN-i-1(=aとする)桁分ある．a桁のうちj桁1があるとして，寄与がj*C[i]

通り数：
右：a個からj個えらぶ=aCj
左：0でも1でも置ける=2^i

変更時のD：j+1

i,jの2つのΣで考えると，j側は結局Σ((j+1) * aCj)
j=0~aでΣ(j+1 * aCj) = (a+2) * pow(2,a-1) = (N-i+2) * pow(2,a-1)

"""

def main():
    mod=10**9+7
    N=I()
    C=LI()
    C.sort()
    ans=0
    
    def calc(ii):
        a = N-ii-1
        if a==0:
            temp_j=1
        else:
            temp_j = (a+2) * pow(2,a-1,mod)
        temp = C[ii]*pow(2,ii,mod)*temp_j
        return temp%mod
    
    for i in range(N):
        ans=(ans+calc(i))%mod
        
    ans=(ans*pow(2,N,mod))%mod
        
    print(ans)

  

main()


Measured memory_bytes: 103896
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, M = map(int, input().split())
    sc = [tuple(map(int, input().split())) for _ in range(M)]
    ans = [-1] * N
    for i in range(N):
        for s, c in sc:
            if s == i + 1:
                if ans[i] == -1:
                    ans[i] = c
                else:
                    if ans[i] == c:
                        continue
                    else:
                        print(-1)
                        exit()
                
        if ans[i] == -1:
            if i == 0 and N > 1:
                ans[i] = 1
            else:
                ans[i] = 0
    ans_v = int(''.join(map(str, ans)))
    if len(str(ans_v)) == N:
        print(ans_v)
    else:
        print(-1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    long k = scan.nextLong();
    HashMap<Integer,Long> a = new HashMap<Integer,Long>();
    HashSet<Integer> d = new HashSet<Integer>();
    for (int i=0;i<n;i++){
        int b = scan.nextInt();
        long c = scan.nextLong();
        d.add(b);
        if (a.get(b) == null){
          a.put(b,c);
        }
        else{
          long g = a.get(b);
          a.put(b,g+c);
        }
    }

    ArrayList<Integer> e = new ArrayList<Integer>(d);
    Collections.sort(e);

    long sum = 0;
    int count = 0;
    int g = 0;
    while (sum < k){
      g = e.get(count);
      long much = a.get(g);
      sum += much;
      count += 1;
    }

    System.out.print(g);


  }

}


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

const int N = 1e5 + 10;

int a[N];
int n;

bool check(int id){
	long long sum = a[id];
	for (int i = 1; i <= n; i++){
		if (i == id) continue;
		if (sum * 2 < a[i]) return false;
		sum += a[i];
	}
	return true;
}

int main(){
	int l, r, mid;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) scanf("%d",&a[i]);
	sort(a + 1, a + n + 1);
	l = 0; r = n + 1;
	while (r - l > 1){
		mid = (l + r) >> 1;
		if (check(mid)) r = mid;
		else l = mid;
	}
	printf("%d\n", n - r + 1);
	return 0;
}

Measured memory_bytes: 768
n, m = map(int, input().split())
bn = [1] * n
red = [True] + [False] * (n-1)

for _ in range(m):
    x, y = map(int, input().split())
    x -= 1; y -= 1
    bn[x] -= 1
    bn[y] += 1
    if red[x]: red[y] = True
    if bn[x] == 0: red[x] = False

print(sum(red))


Measured memory_bytes: 5364
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int a[maxn],b[maxn],c[maxn];
set<int>s;
set<int>ss;
map<int,int>x;
map<int,int>y;
bool cmp(int xx,int yy)
{
    return x[xx]>x[yy];
}
bool cmp2(int xx,int yy)
{
    return y[xx]>y[yy];
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);
    if(n==2)
    {
        if(a[0]==a[1])
            printf("1\n");
        else
            printf("0\n");
        return 0;
    }
    for(int i=0; i<n; i+=2)
        s.insert(a[i]),x[a[i]]++;
    for(int i=1; i<n; i+=2)
        ss.insert(a[i]),y[a[i]]++;
    if(s.size()==1&&ss.size()==1&&a[0]==a[1])
        printf("%d\n",n/2);
    else
    {
        int m=s.size(),k=0;
        for(set<int>::iterator it=s.begin(); it!=s.end(); it++)
            b[k++]=*it;
        int mm=ss.size();
        k=0;
        for(set<int>::iterator it=ss.begin(); it!=ss.end(); it++)
            c[k++]=*it;
        sort(b,b+m,cmp);
        sort(c,c+mm,cmp2);
        if(m==1)
        {
            if(c[0]==a[0])
            {
                int sum=0;
                for(int i=0; i<mm; i++)
                    if(i!=1)
                        sum+=y[c[i]];
                printf("%d\n",sum);
            }
            else
            {
                int sum=0;
                for(int i=1; i<mm; i++)
                    sum+=y[c[i]];
                printf("%d\n",sum);
            }
        }
        else if(mm==1)
        {
            if(b[0]==a[1])
            {
                int sum=0;
                for(int i=0; i<m; i++)
                    if(i!=1)
                        sum+=x[b[i]];
                printf("%d\n",sum);
            }
            else
            {
                int sum=0;
                for(int i=1; i<m; i++)
                    sum+=x[b[i]];
                printf("%d\n",sum);
            }
        }
        else
        {
            if(b[0]!=c[0])
            {
                int sum=0;
                for(int i=1; i<m; i++)
                    sum+=x[b[i]];
                for(int i=1; i<mm; i++)
                    sum+=y[c[i]];
                printf("%d\n",sum);
            }
            else
            {
                int ans=1e6,sum=0;
                for(int i=1; i<m; i++)
                    sum+=x[b[i]];
                for(int i=0; i<mm; i++)
                    if(i!=1)
                        sum+=y[c[i]];
                ans=min(ans,sum);
                sum=0;
                for(int i=0; i<m; i++)
                    if(i!=1)
                        sum+=x[b[i]];
                for(int i=1; i<mm; i++)
                    sum+=y[c[i]];
                ans=min(ans,sum);
                printf("%d\n",ans);
            }
        }
    }

}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
int main(){
    string ans;
    int x,y,w,h,r;
    cin >> w >> h >> x >> y >> r;
    if(r<=x&&x<=w-r&&r<=y&&y<=h-r){
        ans="Yes";
    }else{
        ans="No";
    }
    cout << ans << endl;
}


Measured memory_bytes: 3196
#include <stdio.h>
int main(){
	int S, s, m, h,sub;
	scanf("%d", &S);
	h = S / 3600;
	sub = S % 3600 ;
	m = sub / 60;
	s = sub % 60;
	printf("%d:%d:%d\n", h, m, s);
		return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<ll,ll>;
const ll INF = 1e18+7;

ll n;
ll a, b, c, d;

struct edge {
  ll to, cost;
  edge(ll to, ll cost) : to(to), cost(cost){}
};

ll dijkstra() {
  priority_queue<P, vector<P>, greater<P> > que;
  map<ll, ll> mem;
  mem[n] = 0;
  que.emplace(0, n);

  while (true) {
    P p = que.top(); que.pop();
    if (p.second == 1) {
      return p.first;
    }
    ll v = p.second;
    if (mem[v] < p.first) continue;

    vector<edge> g;
    switch (v % 2) {
      case 0: g.emplace_back(v/2, v/2 <= a/d ? v/2*d : a); break;
      case 1:
        g.emplace_back(v/2, v-v/2 <= (a+d)/d ? (v-v/2)*d : a+d);
        g.emplace_back(v/2+1, v-v/2-1 <= (a+d)/d ? (v-v/2-1)*d : a+d);
        break;
    }
    switch (v % 3) {
      case 0: g.emplace_back(v/3, v-v/3 <= b/d ? (v-v/3)*d : b); break;
      case 1:
        g.emplace_back(v/3, v-v/3 <= (b+d)/d ? (v-v/3)*d : b+d);
        g.emplace_back(v/3+1, v-v/3-1 <= (b+2*d)/d ? (v-v/3-1)*d : b+2*d);
        break;
      case 2:
        g.emplace_back(v/3, v-v/3 <= (b+2*d)/d ? (v-v/3)*d : b+2*d);
        g.emplace_back(v/3+1, v-v/3-1 <= (b+d)/d ? (v-v/3-1)*d : b+d);
        break;
    }
    switch (v % 5) {
      case 0: g.emplace_back(v/5, v-v/5 <= c/d ? (v-v/5)*d : c); break;
      case 1:
        g.emplace_back(v/5, v-v/5 <= (c+d)/d ? (v-v/5)*d : c+d);
        g.emplace_back(v/5+1, v-v/5-1 <= (c+2*d)/d ? (v-v/5-1)*d : c+2*d);
        break;
      case 2:
        g.emplace_back(v/5, v-v/5 <= (c+2*d)/d ? (v-v/5)*d : c+2*d);
        g.emplace_back(v/5+1, v-v/5-1 <= (c+3*d)/d ? (v-v/5-1)*d : c+3*d);
        break;
      case 3:
        g.emplace_back(v/5, v-v/5 <= (c+3*d)/d ? (v-v/5)*d : c+3*d);
        g.emplace_back(v/5+1, v-v/5-1 <= (c+2*d)/d ? (v-v/5-1)*d : c+2*d);
        break;
      case 4:
        g.emplace_back(v/5, v-v/5 <= (c+2*d)/d ? (v-v/5)*d : c+2*d);
        g.emplace_back(v/5+1, v-v/5-1 <= (c+d)/d ? (v-v/5-1)*d : c+d);
        break;
    }

    for (edge e : g) {
      if (e.to != n && mem[e.to] == 0) mem[e.to] = INF;
      if (mem[e.to] > mem[v] + e.cost) {
        mem[e.to] = mem[v] + e.cost;
        que.emplace(mem[e.to], e.to);
      }
    }
  }
}

int main() {
  int t;
  cin >> t;
  vector<ll> ans(t);
  rep(t0,t) {
    cin >> n >> a >> b >> c >> d;

    ans[t0] = dijkstra() + d;
  }

  rep(t0,t) {
    cout << ans[t0] << endl;
  }
}


Measured memory_bytes: 4188
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<pair<int, pair<int, int>>> hp(n+1, {0, {0, 0}});
  REP(i, n) {
    cin >> hp[i].second.first >> hp[i].second.second;
    hp[i].first = hp[i].second.first + hp[i].second.second;
  }
  sort(ALL(hp));
  // dp[i][j] = i 人まで見る．j 人積んだときの座布団の枚数の最小値
  vector<vector<long long>> dp(n+1, vector<long long>(n+1, LINF));
  dp[0][0] = 0;
  REP(i, n) REP(j, i+1) {
    dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
    if (dp[i][j] <= hp[i+1].second.first) dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + hp[i+1].second.second);
  }
  int ans = 0;
  REP(i, n+1) if (dp[n][i] != LINF) ans = i;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 198016
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

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

  string S;
  cin >> S;

  vector<int> A(0);
  if (S[0] == '0') A.pb(0);

  char now = S[0];
  int cnt = 0;
  repp(i, 1, S.size() - 1) {
    cnt++;
    if (now != S[i]) {
      A.pb(cnt);
      now = S[i];
      cnt = 0;
    }
  }
  A.pb(++cnt);
  if (S[S.size() - 1] == '0') A.pb(0);
  // rep(i, A.size()) { cout << A[i] << endl; }

  if (A.size() < 2 * K + 1) {
    int ans = 0;
    rep(i, A.size()) { ans += A[i]; }
    cout << ans << endl;
    return 0;
  }

  int ans = 0;
  int temp = 0;
  int r;
  for (r = 0; r <= 2 * K; r++) {
    temp += A[r];
  }
  r--;
  int l = 0;
  r += 2;
  l += 2;
  ans = temp;
  while (r < A.size()) {
    temp = temp - A[l - 1] - A[l - 2] + A[r] + A[r - 1];
    chmax(ans, temp);
    r += 2;
    l += 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1020
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
#include<set>
#include<iomanip>
#include<bitset>

using namespace std;

/************************************************/

int main(void) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int count = 0;
	for (int i = 0; i <= 100; i++) {
		if (a <= i && i <= b && c <= i && i <= d) {
			count++;
		}
	}
	if (count > 0) {
		cout << count - 1;
	}
	else {
		cout << count;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = in.nextInt();
            }

            double sumInverse = 0;
            for (int i = 0; i < N; i++) {
                sumInverse += 1.0 / A[i];
            }
            System.out.println(1.0 / sumInverse);
        }
    }
}


Measured memory_bytes: 27272