akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve()
{	
	int n;
	cin >> n;
	int a[n + 1], b[n + 1], c[n + 1];
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
	}
	int sum = 0;
	for(int i = 1; i <= n; ++i){
		cin >> b[i];
	}
	for(int i = 1; i <= n - 1; ++i){
		cin >> c[i];
	}
	for(int i = 1; i <= n; ++i){
		sum += b[a[i]];
		if(i + 1 <= n && a[i + 1] == a[i] + 1){
			sum += c[a[i]];
		}
	}
	cout << sum;

}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>

using namespace std;

constexpr static int MAXN = 1e6;
int n, L;
int64_t t[MAXN], v[MAXN];

int main() {
    scanf("%d%d", &n, &L);
    for (int i = 0; i < n; i++)
        scanf("%lld%lld", &t[i], &v[i]);

    // maintain the cumulative best f(v) = tvsum (convex, piecewise-linear)
    // m contains (slope, len) where slope is decreasing
    deque <pair <double, int64_t>> m; // (slope, len)
    // v[0] == L
    m.push_back({t[0], v[0]});
    double tvsum = 1.0 * t[0] * v[0];
    printf("%.10lf\n", tvsum / L);
    for (int i = 1; i < n; i++) {
        // cut down from L to L - v[i]
        int64_t del = v[i];
        while (true) {
            int64_t len = m.back().second;
            if (len <= del) {
                del -= len;
                tvsum -= m.back().first * len;
                m.pop_back();
                if (del == 0)
                    break;
            }
            else {
                tvsum -= m.back().first * del;
                m.back().second -= del;
                break;
            }
        }

        // add v[i] block
        tvsum += 1.0 * t[i] * v[i];
        m.push_front({t[i], v[i]});
        printf("%.10lf\n", tvsum / L);

        // convexify
        while (m.size() > 1 && m[0].first < m[1].first) {
            double tv = m[0].first * m[0].second + m[1].first * m[1].second;
            int64_t len = m[0].second + m[1].second;
            m.pop_front();
            m.pop_front();
            m.push_front({tv / len, len});
        }
    }
}


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

using ll = long long;
using ull = unsigned long long;
constexpr ll mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;

using namespace std;
vector<int> fac(int n){
    vector<int> ret(n+1,1);
    for(int i=2;i<=n;++i){
        for(int j=i;j<=n;j+=i)ret[j]++;
    }
    return ret;
}
int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    ll sum = 0;
    vector<int> pre = fac(n);
    for(int i=1;i<=n;++i){
        sum += 1ll*i * pre[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 42268
#include <bits/stdc++.h>
using namespace std;
long long n,m,cnt = 0;
long long dis[200010];
struct edge {
	long long u,v,len;
}e[500010];
long long fa[200010];
bool cmp(edge x,edge y){
	return x.len<y.len;
}
long long get(long long x){
	if (fa[x]==x){
		return x;
	}
	return fa[x]=get(fa[x]);
}
int main () {
	scanf("%lld%lld",&n,&m);
	for (register int i = 0; i <= n; i++){
		fa[i] = i;
		dis[i] = 1e18;
	}
	for (register int i = 1; i <= m; i++){
		long long a,b,c;
		scanf("%lld%lld%lld",&a,&b,&c);
		e[++cnt].u = a;
		e[cnt].v = b;
		e[cnt].len = c;
		dis[a] = min(dis[a],c+1);
		dis[b] = min(dis[b],c+2);
	}
	for (register int i = 0; i <= n; i++){
		dis[i] = min(dis[i],dis[(i-1+n)%n]+2);
	}
	for (register int i = 0; i <= n; i++){
		dis[i] = min(dis[i],dis[(i-1+n)%n]+2);
	}
	for (register int i = 0; i < n; i++){
		e[++cnt].u = i;
		e[cnt].v = (i+1)%n;
		e[cnt].len = dis[i];
	}
	sort(e+1,e+cnt+1,cmp);
	long long ans = 0,ccnt = 0;
	for (register int i = 1; i <= cnt; i++){
		int fx = get(e[i].u);
		int fy = get(e[i].v);
		//cout << fx << " " << fy << " " << e[i].len << endl;
		if (fx!=fy){
			fa[fx] = fy;
			ans += e[i].len;
			ccnt++;
		}
		if (ccnt==n-1){
			break;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 15360
#ifdef __GNUC__
#include <bits/stdc++.h>
#endif // __GNUC__

int main() {
    std::cin.tie(nullptr); std::ios::sync_with_stdio(false);
    uint64_t N;
    std::cin >> N;
    int ans = log10(N) + 1;
    for (uint64_t A = 1ull; A * A <= N; ++A) {
        if (N % A)continue;
        int big = std::max(log10(A), log10(N / A))+1;
        ans = std::min(ans, big);
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
def main():
    from collections import Counter
    s = input()

    l = [0]
    t = 1
    for i, x in enumerate(s[::-1]):
        t = t * 10 % 2019
        y = (l[-1] + int(x) * t) % 2019
        l.append(y)

    c = Counter(l)
    ans = sum([v * (v - 1) // 2 for v in c.values()])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 16784
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1, 1, -1};
int dy[] = {1, 0, -1, 0, 1, 1};
#define INF 1000000000000
#define MAX 200001
#define MOD 1000000007
ll fac[MAX], finv[MAX], inv[MAX];
const int MX = 1000005;

int main(){
    int n,k;cin>>n>>k;
    ll ans=INF;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int bit=0;bit<(1<<n);bit++){
        ll cost = 0;
        vector<ll> b(n);
        for(int i=0;i<n;i++) b[i] = a[i];
        for(int j=0;j<n;j++){
            if(bit>>j&1){
                ll max_height = 0;
                for(int k=0;k<j;k++){
                    max_height = max(max_height,b[k]);
                }
                if(max_height < b[j]) continue;
                else{
                    cost += max_height - b[j] + 1;
                    b[j] = max_height + 1;
                }
            }
        }
        int count = 1;
        ll max_height = b[0];
        for(int i=1;i<n;i++){
            if(max_height < b[i]){
                count++;
                max_height = b[i];
            }
        }
        if(count >= k) ans = min(ans, cost);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int r = sc.nextInt();
   int g = sc.nextInt();
   int b = sc.nextInt();
   
   System.out.println((100*r + 10*g + b)%4 == 0 ? "YES":"NO");
   
 }
}

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

long long int N;
string S[1000000];

int AC;
int WA;
int TLE;
int RE;
int main(){
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> S[i];
        if(S[i] == "AC")  AC++;
        if(S[i] == "WA")  WA++;
        if(S[i] == "TLE") TLE++;
        if(S[i] == "RE")  RE++;
    }

    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
}

Measured memory_bytes: 34884
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>


using ll = long long;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);

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

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
int d[210];
bool flag = true;
bool fl = true;
struct edge { int to, cost; };
std::vector<edge>v[100];
bool used[210];

int main() {
	std::string s;
	std::cin >> s;
	int n = 0, S = 0, w = 0, e = 0;
	for (int i = 0;i < s.size();i++) {
		if (s[i] == 'N')n++;
		if (s[i] == 'S')S++;
		if (s[i] == 'W')w++;
		if (s[i] == 'E')e++;
	}
	if (n == 0 && S != 0)flag = false;
	if (S == 0 && n != 0)flag = false;
	if (w == 0 && e != 0)flag = false;
	if (e == 0 && w != 0)flag = false;
	if (flag) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
}

Measured memory_bytes: 256
S=input()
ans=0
a=len(S)/2
if len(S)%2==0:
	S1=S[:int(len(S)/2)]
	S2=S[int(len(S)/2):]
else:
	S1=S[:int(len(S)/2)]
	S2=S[int(len(S)/2)+1:]
S3 = S2[::-1]
for i,j in zip(S1,S3):
	if i!=j:
		ans+=1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(void) {
	int n; cin >> n;
	int sum = 0, a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}

	cout << sum - n << endl;

	return 0;
}

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

using namespace std;

int main() {
  long long a, b;
  cin >> a >> b;

  long long g = __gcd(a, b);

  long long ans = 1LL;
  for (long long i = 2; i*i <= g; ++i) {
    if (g % i == 0) ++ans;
    while (g % i == 0) {
      g /= i;
    }
  }

  if (g > 1) ++ans;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#define N 200005
#define LL long long
#define PAIR pair<int,int>
using namespace std;
int n,lw,f[N],g[N],a[N]; PAIR w[N]; LL ans; vector<int> G[N];
void dfs(int t,int fa)
{
	int i; g[t]=a[t];
	for(i=0;i<G[t].size();i++)
		if(G[t][i]!=fa){
			dfs(G[t][i],t);
			f[t]=max(f[t],f[G[t][i]]+1);
			g[t]+=g[G[t][i]];
		  }
}
void DFS(int t,int fa)
{
	int i,sp=0,sq=0,p,q,r,s;
	w[lw=1]=PAIR(0,a[t]);
	for(i=0;i<G[t].size();i++)
		w[++lw]=PAIR(f[G[t][i]]+1,g[G[t][i]]);
	sort(w+1,w+lw+1),p=0;
	for(i=1;i<lw;i++)
		if(p+=w[i].second){
			if(i==lw-1){
				if(w[i+1].first>w[i].first) ans++;
				if(w[i+1].first>w[i].first+1) ans++;
			  }
			else ans+=w[i+1].first-w[i].first;
		  }
	for(i=0;i<G[t].size();i++)
		if(f[G[t][i]]>f[sp]) sq=sp,sp=G[t][i];
		else if(f[G[t][i]]>f[sq]) sq=G[t][i];
	for(i=0;i<G[t].size();i++)
		if(G[t][i]!=fa){
			p=f[t],q=g[t],r=f[G[t][i]],s=g[G[t][i]];
			f[t]=(sp==G[t][i] ? f[sq]+1 : f[t]);
			f[G[t][i]]=max(f[G[t][i]],f[t]+1);
			g[t]-=g[G[t][i]],g[G[t][i]]+=g[t];
			DFS(G[t][i],t);
			f[t]=p,g[t]=q,f[G[t][i]]=r,g[G[t][i]]=s;
		  }
}
int main()
{
	int i,x,y; f[0]=-1;
	scanf("%d",&n);
	for(i=1;i<n;i++){
		scanf("%d %d\n",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	  }
	x=0,y=0;
	for(i=1;i<=n;i++) a[i]=getchar()-'0';
	dfs(1,0);
	DFS(1,0);
	cout<<ans+1;
	return 0;
}


Measured memory_bytes: 29568
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

int main() {
    int m,n;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int e=0;
    rep(i,n) e+=a[i];
    int u=e/(4*m);
    if (e%(4*m)==0) u--;
    int t=0;
    rep(i,n){
        if (a[i]>u) t++;
    }
    if (t>=m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    string s;
    cin>>s;
    if (s=="SUN")
    printf("7\n");
    else if (s=="MON")
    printf("6\n");
    else if (s=="TUE")
    printf("5\n");
    else if (s=="WED")
    printf("4\n");
    else if (s=="THU")
    printf("3\n");
    else if (s=="FRI")
    printf("2\n");
    else
    printf("1\n");
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int n, s=0, b=-100, c=0, d=999999999;
  cin >> n;
  int a[n];
  rep(i,0,n){
    cin >> a[i];
    s+=a[i];
  }
  
  while(b<=100){
    rep(i,0,n){
      c+=pow(b-a[i] ,2);
    }
    d=min(c, d);
    c=0;
    b++;
  }
  
  co(d);
  
  return 0;
}


Measured memory_bytes: 256
#97a
a,b,c,d=map(int,input().split())

if a<=b<=c or c<=b<=a:
    if abs(a-b)<=d and abs(c-b)<=d:
        print('Yes')

    else:
        print('No')
else:
    if abs(a-c)<=d:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3064
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
using namespace std;
template <typename lx> inline void read(lx &x){
	x = 0;int f = 1;char c = getchar();
	for(;c < '0' || '9' < c; c = getchar()) if(c == '-') f = -1;
	for(;'0' <= c && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	x *= f;return;
}
template <typename lx> inline void print(lx x){
	if(x < 0) putchar('-'),x = -x;
	if(x > 9) print(x / 10);
	putchar(x % 10 + 48);
	return;
}
#define rg register
#define ll long long
#define r_2(a,b) read(a),read(b)
#define r_3(a,b,c) read(a),read(b),read(c)
#define print_n(a) print(a),puts("")
#define print_(a) print(a),putchar(' ')
const int inf = 2147483647;
ll a,b,c;
int main()
{
	r_2(a,b);
	c = a + b;
	if(c & 1) puts("IMPOSSIBLE");
	else print(c >> 1);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main(){
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    const double alpha=2.0*M_PI*(h/12.0+m/(12.0*60.0)-m/60.0);
    cout<<setprecision(15)<<sqrt(a*a+b*b-2.0*a*b*cos(alpha));
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

struct UnionFind {
  vector<int> parent;
  vector<int> num_node;

  UnionFind(int N) : parent(N), num_node(N, 1) {
    for (int i = 0; i < N; i++) {
      parent[i] = i;
    }
  }

  // 根を求める
  int root(int x) {
    if (parent[x] == x) {
      return x;
    }

    // 経路圧縮
    parent[x] = root(parent[x]);
    return parent[x];
  }

  // 同一判定
  bool is_same(int x, int y) {
    return this->root(x) == this->root(y);
  }

  // 併合
  void unite(int x, int y) {
    x = this->root(x);
    y = this->root(y);

    // すでに一緒ならなにもしない
    if (x == y) {
      return;
    }
    parent[x] = y;
    num_node[y] += num_node[x];
  }

  int size(int x) {
    return num_node[root(x)];
  }
};

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

  ll n, m;
  cin >> n >> m;

  vector<P> b(m);
  rep(i, m) {
    cin >> b[i].first >> b[i].second;
    b[i].first--;
    b[i].second--;
  }

  vll ans(m);

  UnionFind uf(n);
  for (int i = m - 1; i >= 0; i--) {
    // 既に別の橋で繋がってる場合
    if (uf.is_same(b[i].first, b[i].second)) {
      ans[i] = 0;
    } else {
      int num_x = uf.size(b[i].first);
      int num_y = uf.size(b[i].second);
      ans[i] = num_x * num_y;

      uf.unite(b[i].first, b[i].second);
    }
  }

  REP(i, m) {
    ans[i] += ans[i - 1];
  }

  rep(i, m) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 4480
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;


void solve(long long N, std::vector<std::string> S){
}

int main(){
    long long N;
    scanf("%lld",&N);
	set<string> S;
    for(int i = 0 ; i < N ; i++){
		string s;
        std::cin >> s;
		S.insert(s);
    }
	cout << S.size() << endl;
    return 0;
}


Measured memory_bytes: 15796
#include<stdio.h>
#include<algorithm>
using namespace std;
int cmp(int a,int b)
{
	return a>b;
}
int main(void)
{
	int a[50],n,k,s=0;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n,cmp);
	for(int i=0;i<k;i++)
		s+=a[i];
	printf("%d",s);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,m;
  while(cin >> n >> m , n + m){
    int yasai[1000] = {0};

    for(int i = 1 ; i <= n ; i++){
      cin >> yasai[i];
    }

    sort(yasai,yasai+(n+1),greater<int>());

    for(int i = n ; i >0 ; i--){
      yasai[i] = yasai[i-1];
    }
    int sum = 0;
    for(int i = 1 ; i <= n ; i++){
      if(i%m != 0)sum+=yasai[i];
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 1180
words = lambda t : list(map(t, input().split()))
r,g,b,n = words(int)

ans = 0
for i in range(n // r + 1):
    for j in range((n-(i*r)) // g + 1):
        #print(i, j)
        if (n - (i*r) - (j*g)) % b == 0:
            ans += 1

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>

#define EACH(i,a) for(auto(i)=(a).begin(),_END=(a).end();i!=_END;++i)

std::string S;

std::vector<int> cnt;

int main(void){
    std::cin >> S;

    cnt.resize((int)('z'-'a'+1), 0);
    bool f = true;
    EACH(it,S){
        if(++cnt[*it-'a'] >= 2){
            f = false;
            break;
        }
    }
    std::cout << (f ? "yes" : "no") << std::endl;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

#define MAX_V 110
#define INF 1<<29

struct MaxFlow {
  struct edge { int to, cap, rev; };

  vector<edge> G[MAX_V];
  int level[MAX_V];
  int iter[MAX_V];
  
  MaxFlow() {}

  void add_edge(int from, int to, int cap) {
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size()});
  }

  void bfs(int source) {
    memset(level, -1, sizeof(level));
    queue<int> que;
    que.push(source);
    level[source] = 0;
    while (!que.empty()) {
      int v = que.front(); que.pop();
      for (int i = 0; i < (int)G[v].size(); i++) {
	edge &e = G[v][i];
	if (e.cap > 0 && level[e.to] < 0) {
	  level[e.to] = level[v] + 1;
	  que.push(e.to);
	}
      }
    }
  }

  int dfs(int v, int sink, int flow) {
    if (v == sink) return flow;
    for (int &i = iter[v]; i < (int)G[v].size(); i++) {
      edge &e = G[v][i];
      if (e.cap > 0 && level[v] < level[e.to]) {
	int d = dfs(e.to, sink, min(e.cap, flow));
	if (d > 0) {
	  e.cap -= d;
	  G[e.to][e.rev].cap += d;
	  return d;
	}
      }
    }
    return 0;
  }

  int dinic(int source, int sink) {
    int flow = 0;
    while (true) {
      bfs(source);
      if (level[sink] < 0) return flow;
      memset(iter, 0, sizeof(iter));
      int f;
      while ((f = dfs(source, sink, INF)) > 0) {
	flow += f;
      }
    }
  }
};


int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int V, E;
  cin >> V >> E;
  MaxFlow mf;
  REP(i, E) {
    int u, v, c;
    cin >> u >> v >> c;
    mf.add_edge(u, v, c);
  }
  cout << mf.dinic(0, V-1) << endl;  
  return 0;
}

Measured memory_bytes: 3248
import java.util.*;

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

        String[] points = point.split(" ");
        int n = Integer.parseInt(points[0]);
        int d = Integer.parseInt(points[1]);

        double d2 = d * 2.0 + 1;

        //きりあげ
        double kiriage = Math.ceil(n / d2);

        System.out.println((int)kiriage);
    }
}

Measured memory_bytes: 21972
#include<stdio.h>
int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    char s[100000];
    scanf("%s",&s);
    char previous=s[0];
    int happy=0;
    int inverse=0;
    for (int i = 1; i < n; i++)
    {
        if(previous==s[i])
        {
            happy++;
        }else if(k>0&&inverse==0){
            happy++;
            k--;
            inverse=1;
        }else if(inverse==1){
            happy++;
            inverse=0;
        }
        
        previous=s[i];
    }
    printf("%d",happy);
    return 0;
        
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define int long long

using namespace std;

const int N = 300111;
int a, b;
int n, m;
signed main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("diameter.in", "r", stdin);
    //freopen("diameter.out", "w", stdout);
    cin >> n >> m >> a >> b;
    int x = m / 2 + m % 2;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            if (j <= a && i <= b){
                cout << 1;
            }
            else
            if (j > a && i > b){
                cout << 1;
            }
            else {
                cout << 0;
            }
        }
        cout << endl;
    }



    return 0;
}


Measured memory_bytes: 1280
import java.util.*;

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

        if(a>b && a>c){
            ans = a*10+b+c;
        }else if(b>c){
            ans = b*10+c+a;
        }else{
            ans = c*10+a+b;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
#include <cstdio>
	#include <iostream>
	#include <string.h>
	#include <cstring>
	#include <cmath>
	#include <math.h>
	#include <algorithm>
	#include <iomanip>
	#include <map>
	#include <set>
	#include <vector>
	#include <sstream>
	#include <queue>	
	#include <bitset>
	using namespace std;	
	#define FOR(i,f_limit) for(long long int i=0;i<f_limit;i++)
	#define FR(i,s_limit,f_limit) for(long long int i=s_limit;i<f_limit;i++)
	typedef long long int llong;
	
	llong s[3001],ss[3001];
	int main()
	{
		// freopen("input.txt","r",stdin);
		// freopen("output.txt","w",stdout);
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		
		llong n,m,mini;
		cin>>n>>m;
		llong x[n],y[n],x1[m],y1[m];
		FOR(i,n)
		{
			cin>>x[i]>>y[i];
		}
		FOR(i,m)
		{
			cin>>x1[i]>>y1[i];
		}
		llong d,pos;
		FOR(i,n)
		{
			mini=999999999;
			FOR(j,m)
			{
				d=abs(x[i]-x1[j])+abs(y[i]-y1[j]);
				if(d<mini) 
				{
					mini=d;
					pos=j;
				}
				else if(d==mini)
				{
					mini=d;
					pos=min(pos,j);
				}
			}
			cout<<pos+1<<endl;
		}
		return 0;
	}


Measured memory_bytes: 256
N = input()

ans = 0
for n in N:
    ans += int(n)

for i in range(len(N)):
    tmp = 0
    for j in range(i):
        tmp += int(N[j])

    tmp += int(N[i])-1

    if i < len(N):
        for _ in range(i+1, len(N)):
            tmp += 9

    if tmp > ans:
        ans = tmp

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;
ll i;



int main(){
    ll N;
    cin>>N;
    V p(N);
    rep(i,N)cin>>p.at(i);
    ll cnt=0;
    rep(i,N)if(p.at(i)!=i+1)cnt++;
    if(cnt<=2)cout<<"YES";
    else cout<<"NO";
    cout<<endl;
}


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

int main(){
  string s;
  cin >> s;
  rep(i, s.length()){
    rep(j, s.length()-i) {
      string target = s.substr(0, i) + s.substr(i+j, s.length()-1);
      if (target == "keyence") {
        cout << "YES" << endl;
        exit(0);
      }
    }
  }
  cout << "NO" <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
ll n;
ll count(ll a,ll b){
	if(n<a) {
		return 0;
	}
	return (n-a)/b +(a!=0);
}
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	cin>>n;
	ll k; cin>>k;
	ll ans=0;
	for(int i=0; i<k; i++) {
		ll j=(k-i)%k;
		ll d=(k-i)%k;
		if((2*j)%k==0) {
			ans+=1ll*count(j,k)*1ll*count(d,k)*1ll*count(i,k);
		}
	}


	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    ll A,B,C,D,N;
    ll ans=0;
    ll X[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    string S;
    bool F;
int main(){
    cin>>A;


    cout<<X[A-1]<<endl;

    return 0;
}


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

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  
  int town[n];
  rep(i,n) cin >> town[i];
  
  int dist[n-1];
  rep(i,n-1) dist[i] = town[i+1] - town[i];
  
  int can_walk = b / a; //歩ける最大値
  int cont_dist = 0; //連続で歩く距離
  long long ans = 0;
  rep(i,n-1){
    if(dist[i] <= can_walk) 
      ans = ans + dist[i] * a;
    else
      ans = ans + b;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"

#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define fod(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map<int,int>
#define mii map<int,int>
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define pqMin priority_queue<int,vector<int>,greater<int>>
#define pqMax priority_queue<int>
#define pqpii priority_queue<pii>
#define all(v) v.begin(),v.end()
#define sortall(v) sort(all(v))
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define w(t) int t; cin>>t; while (t--)
#define out(x, y) cout << x << " " << y << endl
#define print(x) cout << x << endl
#define ps(x,y) fixed<<setprecision(y)<<x
#define pprint cout<<"Case #"<<tt<<": ";
const int mod = 1e9+7;
const int N = 2e5;
const int inf = 1e18;

int add(int a,int b){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
bool compare (int x, int y) { return x > y;}

struct Compare {
    bool operator () (pii A, pii B) {
        return A.first > B.first;
    }
};
 struct tri{
   int x,y,z;
 };
 struct cmp{
bool operator ()(tri a,tri b){
    if(a.x==b.x)
        return a.y>b.y;
    return a.x<b.x;

}};
bool comp(pii a,pii b){
    if(a.first>b.first) return true;
    else if(a.first==b.first) return a.second<b.second;
    else return false;

}
int binarySearch(vector<int>nums, int lo, int hi, int target) {
        while (lo < hi) {
            int mid = (lo + hi)/2;
            if (nums[mid] <= target) {
                lo = mid + 1;
            } else {
                hi = mid;
            }
        }
        return lo;
    }
void solve() {

    int t = 1;
    //cin >> t;
   while(t--){
      int x;
      cin>>x;
      if(x>=400&&x<=599)
        cout<<"8";
      else if(x>=600&&x<=799)
        cout<<"7";
        else if(x>=800&&x<=999)
        cout<<"6";
        else if(x>=1000&&x<=1199)
        cout<<"5";
        else if(x>=1200&&x<=1399)
        cout<<"4";
        else if(x>=1400&&x<=1599)
        cout<<"3";
        else if(x>=1600&&x<=1799)
        cout<<"2";
        else if(x>=1800&&x<=1999)
        cout<<"1";
    }
}

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

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

    solve();

    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>

int main(){


int n;
scanf("%d",&n);
int arr[100] = {0};
int count = 0;
for(int i=0;i<n;i++){
	scanf("%d",&arr[i]);
}
for(int i=0;i<n;i++){
	for(int j=n-1;j>=i+1;j--){
		if(arr[j]<arr[j-1]){
			int temp = arr[j-1];
			arr[j-1] = arr[j];
			arr[j] = temp;
			count++;
		}
	}
}
for(int i=0;i<n;i++){
	if(i==n-1)
	printf("%d\n",arr[i]);
	else 
	printf("%d ",arr[i] );
}
printf("%d\n",count);



	return 0;
}


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

typedef long long ll;

int main(){
  string s;
  cin>>s;
  if(s=="keyence"){
    cout<<"YES"<<endl;
    return 0;
  }
  for(int i=0;i<s.size();i++){
    for(int j=i;j<s.size();j++){
      string t="";
      for(int k=0;k<s.size();k++){
	if(k<i||k>j)t.push_back(s[k]);
      }
      if(t=="keyence"){
	cout<<"YES"<<endl;  
	return 0;
      }
    }
  }
  cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn=new Scanner(System.in);
	int A = stdIn.nextInt();
	int B = stdIn.nextInt();
      if(A*B%2==0){
        System.out.println("No");
      }else{
        System.out.println("Yes");
      }
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
void solve(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    string s;
    cin >> s;
    vector<ll> basis;
    for(int i = n - 1; i >= 0; i--){
        if(s[i] == '0'){
            ll t = a[i];
            for(auto x : basis)t = min(t, t ^ x);
            if(t)basis.push_back(t);
        }else{
            ll t = a[i];
            for(auto x : basis)t = min(t, t ^ x);
            if(t){
                cout << 1 << "\n";
                return;
            }
        }
    }
    cout << 0 << "\n";
    return;
}
int main(){
    int t;
    cin >> t;
    while(t--)solve();
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using Int = long long;

int main(){
    Int n, h;
    cin >> n >> h;
    vector<Int> a(n), b(n);
    for(Int i=0;i<n;i++) cin >> a[i] >> b[i];
    Int x = *max_element(a.begin(), a.end());
    
    using P = pair<Int, Int>;
    vector<P> v(n);
    for(Int i=0;i<n;i++) v[i] = P(b[i], a[i]);
    //降順ソート
    sort(v.rbegin(), v.rend());
    
    Int sum = 0;
    for(Int i=0;i<n;i++){
        sum += max(v[i].first, x);
        if(sum >= h){
            cout << i+1 << endl;
            return 0;
        }
    }
    
    Int s=0, c=0;
    for(Int i=0;i<n;i++) if(b[i] > x) s += b[i], c++;
    Int ans = c + ((h-s)+x-1)/x;
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<stdio.h>



int main(void)
{
	long int n,k;
	long int a[100000];
	long int i,j;
	long int base;
	int min;
	long int tail_len;
	long int top_len;
	long int count = 0;

	scanf("%ld %ld",&n,&k);

	min = 1;

	for(i = 0 ; i< n;i++){
		scanf("%ld",&a[i]);
		if(a[i] == min){
			base = i;
		}
	}
	tail_len = n-1  - base;
	top_len = base;
//	if ( int(tail_len/(k-1)>1)){
		count += int(tail_len/(k-1));
//		printf("tail : %d\n",int(tail_len/(k-1)));
//	}

//	if( int(top_len/(k-1) > 1)){
		count += int(top_len/(k-1));
//		printf("top : %d\n",int(top_len/(k-1)));
//	}
	if(tail_len%(k-1) + top_len%(k-1) == 0){
		count += 0;
	}
	else if(tail_len%(k-1) + top_len%(k-1) < k){
		count += 1;
	}

	else{
		count += 2;
	}
//	printf("%d\n",tail_len%k + top_len%k);
	printf("%ld\n",count);
/*	if ((n-1)%k > 0){
		printf("%ld\n",int((n-1)/k)+1);
	}
	else{
		printf("%ld\n",int((n-1)/k));
	}
	*/
	return 0;

}



Measured memory_bytes: 896
s = str(input())

o = ['R','U','D']
e = ['L','U','D']
flag = 0
for idx ,i in enumerate(s):
  if (idx+1)%2 == 0 and not i in e:
    print('No')
    flag = 1
    break
  if (idx+1)%2 != 0 and not i in o:
    print('No')
    flag = 1
    break
if flag == 0:
  print('Yes')

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		int count = 0;
		//		String[] atgc = {"A", "T", "G", "C"};

		for (int i = 0; i < s.length(); i++) {
			int tmpCount = 0;
			while (s.substring(i, i + 1).equals("A") || s.substring(i, i + 1).equals("T") ||
					s.substring(i, i + 1).equals("G") || s.substring(i, i + 1).equals("C")) {
				tmpCount++;
				if (i == s.length() - 1) {
					break;
				}
				i++;

			}
			if (tmpCount > count) {
				count = tmpCount;

			}
		}

		System.out.print(count);
		sc.close();
	}
}

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

int main()
{
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i <= r; i++) {
        if (i % d == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
// AtCoder Beginner Contest 116 - Problem A: Right Triangle (https://atcoder.jp/contests/abc116/tasks/abc116_a)
#include <bits/stdc++.h>

using namespace std;

void solve(int B, int H)
{
    auto ans = (B * H)/2;

    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);

    int B, H, X;
    cin >> B >> H >> X;

    solve(B, H);

    return 0;
}


Measured memory_bytes: 256
x,n = map(int,input().split())
s = list(map(int,input().split()))
if s==[]:
    print(x)
    exit()    
s.sort()
sa = 10**9
for i in range(102):
    if i in s:
        continue
    if sa > abs(x-i):
        sa = abs(x-i)
        ans = i
print(ans)        


Measured memory_bytes: 9120
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int main(){
    ll N,A,B;
    cin>>A>>B>>N;
    cout<<floor(A*min((B-1),N)/B)<<endl;
    return 0;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define ll long long
#define Vi vector<vector<int>>
#define Vl vector<vector<ll>>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vp vector<pair<int,int>>
#define mod 1000000007
using namespace std;
int lower(vl &temple,ll start_point){
	int temp_index=lower_bound(temple.begin(),temple.end(),start_point)-temple.begin();
	int temp_lower=temp_index;
	if(temp_index==0 && temple[temp_index]!=start_point){
		temp_lower=-1;
	}else if(temple[temp_index]!=start_point){
		temp_lower=temp_index-1;
	}
	return temp_lower;
}
int uper(vl &temple,ll start_point){
	int temp_index=upper_bound(temple.begin(),temple.end(),start_point)-temple.begin();
	int temp_lower=temp_index;
	if(temp_index==temple.size()){
		temp_lower=-1;
	}
	return temp_lower;
}
int main(){
	int A,B,Q;
	cin>>A>>B>>Q;
	vl srine(A);
	vl temple(B);
	for(int i=0;i<A;i++)
		cin>>srine[i];
	for(int i=0;i<B;i++)
		cin>>temple[i];
	while(Q--){
		ll start_point;
		cin>>start_point;
		ll temp_lower=lower(temple,start_point)!=-1?temple[lower(temple,start_point)]:-1;
		ll srine_lower=lower(srine,start_point)!=-1?srine[lower(srine,start_point)]:-1;
		ll temp_uper=uper(temple,start_point)!=-1?temple[uper(temple,start_point)]:-1;
		ll srine_uper=uper(srine,start_point)!=-1?srine[uper(srine,start_point)]:-1;
		ll res=LLONG_MAX;
		// cout<<"temp:"<<temp_lower<<" "<<temp_uper<<endl;
		// cout<<"srine:"<<srine_lower<<" "<<srine_uper<<endl;
		if(temp_lower!=-1 && srine_lower!=-1){
			res=min(res,start_point-min(temp_lower,srine_lower));
		}
		if(temp_uper!=-1 && srine_uper!=-1){
			res=min(res,max(temp_uper,srine_uper)-start_point);
		}
		if(temp_lower!=-1 && srine_uper!=-1){
			res=min(res,min(start_point-temp_lower,srine_uper-start_point)+srine_uper-temp_lower);
		}
		if(srine_lower!=-1 && temp_uper!=-1){
			res=min(res,min(start_point-srine_lower,temp_uper-start_point)+temp_uper-srine_lower);
		}
		cout<<res<<endl;
	}
	return 0;
}

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

#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

using ll = long long;

inline void Main() {
  // code
  int H, N;
  ll A = 0;
  cin >> H >> N;
  rep(i, N) {
    int a;
    cin >> a;
    A += a;
  }

  if (H - A <= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 1e5 + 5;



int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    using ll = long long;
    ll n; cin >> n;

    ll ans = 0;
    ans = n / 500 * 1000;
    n %= 500;
    ans += n / 5 * 5;
    cout << ans << endl;

    return 0;
%>

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

int main() {
	int N;
	set<long long> A;
	cin >> N;

	bool valid = true;
	for (int i = 0; i < N; i++) {
		long long a;
		cin >> a;
		if (A.find(a) == A.end()) {
			A.insert(a);
		}
		else {
			valid = false;
			break;
		}
	}

	if (valid) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 9600
# -*- coding:utf-8 -*-
import sys
N = int(input())
s = []
for tmp in range(N):
    s.append(int(input()))
s.sort()
total = sum(s)
if total%10 != 0:
    print(total)
else:
    for tmp in s:
        total -= tmp
        if total%10 != 0:
            print(total)
            sys.exit()
        else:
            total += tmp
    print(0)

Measured memory_bytes: 3064
round = int(input(""))
for i in range (0,round):
    arr = []
    temp = input("")
    a,b,c = temp.split(" ")
    arr.append(int(a))
    arr.append(int(b))
    arr.append(int(c))
    arr.sort()
    if(pow(arr[0],2)+pow(arr[1],2)==pow(arr[2],2)):
        print("YES")
    else:
        print("NO")



Measured memory_bytes: 5596
n = input().rstrip()
m = int(input())

dp = [[[0 for _ in range(2)] for _ in range(4)] for _ in range(101)]
dp[0][0][0] = 1

for i in range(len(n)):
    for j in range(4):
        for k in range(2):
            nd = ord(n[i]) - ord('0')
            for d in range(10):
                ni = i + 1
                nj = j
                nk = k
                if d != 0:
                    nj += 1
                if nj > m:
                    continue
                if k == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
                dp[ni][nj][nk] += dp[i][j][k]
            
print(dp[len(n)][m][0] + dp[len(n)][m][1])


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
typedef pair<int, int> P;
int a[114514];

signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	int mx = 0, m=-1;
	rep(i, n - 1) {
		if (m < min(a[i], a[n - 1] - a[i])){
			mx = a[i];
			m = min(a[i], a[n - 1] - a[i]);
		}
	}
	cout << a[n - 1] << ' ' << mx << endl;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        List<Restaurant> list = new ArrayList<>();
        for (int i=1; i<=N; i++) {
            list.add(new Restaurant(i, scanner.next(), scanner.nextInt()));
        }

        list.sort((o1, o2) -> {
            int compareResult = o1.city.compareTo(o2.city);
            if (compareResult == 0) {
                return o2.score - o1.score;
            }
            return compareResult;
        });

        list.forEach(System.out::println);
    }
    static class Restaurant {
        int index;
        String city;
        int score;
        public Restaurant(int index, String left, int right) {
            this.index = index;
            this.city = left;
            this.score = right;
        }

        @Override
        public String toString() {
            return String.valueOf(index);
        }
    }
}

Measured memory_bytes: 26836
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register int i=(a);i<=(b);i++)
#define For(i,a,b) for (register int i=(a);i>=(b);i--)
#define mem(i,j) memset(i,j,sizeof(i))
#define GO(u) for (register int j=f[u];j!=-1;j=nxt[j])
#define fi first
#define se second
#define pii pair<int,int>
#define MP make_pair
#define pb push_back
using namespace std;
typedef long long ll;
const int N=2020;
int n,a[N],vis[N],cnt=0,ans[N],du[N];
int mp[N][N];
vector<int> G[N];
priority_queue <pii> q;
inline int read()
{
	int x=0,f=1;
	char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return f*x;
}
inline void write(int x)
{
	if (x<0) putchar('-'),x=-x;
	if (x>9) write(x/10);
	putchar(x%10+'0');
	return;
}
inline int GCD(int x,int y)
{
	if (!y) return x;
	if (x<y) return GCD(y,x);
	return GCD(y,x%y);
}
inline void dfs(int u)
{
	vis[u]=1;
	FOR(v,1,n) if (u!=v&&mp[u][v])
	{
		if (vis[v]) continue;
		G[u].pb(v);
		du[v]++;
		dfs(v);
	}
	return;
}
int main()
{
	n=read();
	FOR(i,1,n) a[i]=read();
	sort(a+1,a+n+1);
	FOR(i,1,n) FOR(j,1,n) if (i!=j) if (GCD(a[i],a[j])>1) mp[i][j]=1;
	FOR(i,1,n) if (!vis[i])
	{
		dfs(i);
		q.push(MP(a[i],i));
	}
	while (q.size())
	{
		pii tmp=q.top();
		q.pop();
		ans[++ans[0]]=tmp.fi;
		FOR(i,0,(int)G[tmp.se].size()-1)
		{
			int v=G[tmp.se][i];
			du[v]--;
			if (!du[v]) q.push(MP(a[v],v));
		}
	}
	FOR(i,1,n) write(ans[i]),putchar(' ');
	return 0;
}

Measured memory_bytes: 16256