akhauriyash/Code-Regression huggingface dataset:
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define int ll
ll po(ll a, ll x, ll m) { if (x == 0) {return 1;} ll ans = 1; ll k = 1;  while (k <= x) {if (x & k) {ans = ((ans * a) % m);} k <<= 1; a *= a; a %= m; } return ans; }
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
int n, w;
int dp[101][N];
int a[N][2];
int rec(int pos, int weight) {
  if (weight > w || pos > n)
    return INT_MIN;
  if (pos == n)
    return 0;
  int &ans  = dp[pos][weight];
  if (ans != -1)
    return ans ;
  ans  = max(rec(pos + 1, weight), a[pos][1] + rec(pos + 1, weight + a[pos][0]));
  return ans ;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ms(dp, -1);
  cin >> n >> w;
  forr(i, n) {
    forr(j, 2)
    cin >> a[i][j];
  }
  int ans  =  rec(0, 0);
  cout << ans << "\n";
  return 0;
}

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

#define inf 1e18

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define tc ll t;cin >> t;while(t--)

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n ,w;
	cin >> n >> w;
	vector < pair <ll ,ll > > item(n+1);
	for1(i,n){
		cin >> item[i].ff >> item[i].ss;
	}
	ll dp[n+1][w+1];
	for0(i,w+1){
		dp[0][i] = 0;
		// cout << i << " ";
	}
	// cout << endl;
	for0(i,n+1){
		dp[i][0] = 0 ;
	}
	for1(i,n){
		for1(j,w){
			if(j < item[i].ff){
				dp[i][j] = dp[i-1][j];
			}
			else{
				dp[i][j] = max(dp[i-1][j-item[i].ff] + item[i].ss ,dp[i-1][j]);
			}
		}
	}

	// for1(i,n){
	// 	cout << i << " ";
	// 	for1(j,w){
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	cout << dp[n][w] << endl;
	return 0;
}


Measured memory_bytes: 79232
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n, m, r;
    cin >> n >> m >> r;
    int d[220][220];
    rep(i,220){
        rep(j,220){
            d[i][j] = 1e9;
        }
    }
    rep(i, 220) d[i][i] = 0;
    vector<int> p(r);
    rep(i, r){
        cin >> p[i];
        p[i]--;
    }
    rep(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        d[a][b] = c;
        d[b][a] = c;
    }

    rep(via, n){
        rep(i, n){
            rep(j, n){
                d[i][j] = min(d[i][j], d[i][via] + d[via][j]);
            }
        }
    }   
    sort(all(p));
    int ans = 1e9;
    do{
        int sum = 0;
        rep(i, r - 1){
            sum += d[p[i]][p[i + 1]];
        }
        ans = min(ans, sum);
    } while(next_permutation(all(p)));
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node{int p,l,r;};

Node T[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  cout<<"node "<<u<<": ";
  cout<<"parent = "<< T[u].p << ", ";
  cout<<"depth = "<<D[u]<<", ";

  if(T[u].p==NIL) cout<<"root, ";
  else if(T[u].l==NIL) cout<<"leaf, ";
  else cout<<"internal node, ";
  cout<<"[";
  for(i=0,c=T[u].l ; c!=NIL; i++,c=T[c].r){
    if(i) cout<<", ";
    cout<<c;
  }
  cout<<"]"<<endl;
}

int rec(int u,int p){
  D[u]=p;
  if(T[u].r != NIL) rec(T[u].r, p);
  if(T[u].l != NIL) rec(T[u].l, p+1);
}

int main(){
  int i,j,d,v,c,l,r;
  cin >>n;
  for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;
  for(i=0;i<n;i++){
    cin>>v>>d;
    for(j=0;j<d;j++){
      cin>>c;
      if(j==0)T[v].l=c;
      else T[l].r=c;
      l=c;
      T[c].p=v;
    }
  } 
  for(i=0;i<n;i++){
    if(T[i].p==NIL)r=i;
  }
  rec(r,0);
  for(i=0;i<n;i++) print(i);
  return 0;
}

Measured memory_bytes: 7776
s = gets.chomp.split("")
alphabets = ("a".."z").to_a
# まだ含まれていない文字がある場合（25文字以下の場合）、1番小さいアルファベットを末尾に足す
if addition = alphabets.find { |a| !s.include?(a) }
  s << addition
  puts s.join
# 後ろから見て降順が終わっている箇所 top を探す
# （abcdefghijklmnopqrstuvwzyx であれば zyx 以降が理論値のため）
else
  top = nil
  previous_ord = 0
  s.reverse.each_with_index do |c, i|
    if c.ord > previous_ord
      previous_ord = c.ord
    else
      top = i
      break
    end
  end
# top - 1 を top - 1 より大きい且つ top 以降で 1 番小さいアルファベットと差し替え、以降は空
  if top
    former = s[0...s.size - top]
    latter = s[s.size - top..-1].sort
    former[-1] = latter.find { |c| c.ord > former.last.ord }
    puts former.join
  else
    puts -1
  end
end


Measured memory_bytes: 1788
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.15f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto s = RD!string;
	long l = 0, r = s.length-1;
	long ans;
	while (r-l > 0)
	{
		if (s[l] == s[r])
		{
			++l; --r;
		}
		else if (s[l] == 'x')
		{
			++ans;
			++l;
		}
		else if (s[r] == 'x')
		{
			++ans;
			--r;
		}
		else
		{
			ans = -1;
			break;
		}
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

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

int main(){
  int N , X , D=0 , ans=1;
  cin >> N >> X;
  
  for(int i=0;i<N;i++){
    int L;
    cin >> L;
    D+=L;
    
    if(D>X) break;
    else ans++;
  }
  
  cout << ans << endl;
  return 0;
}


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

int main(){
    string w;
    cin >> w;

    sort(w.begin(), w.end());

    int count=1;
    char target=w[0];
    for(int i=1; i<w.size(); i++){
        char tmp = w[i];
        if(tmp == target){
            count += 1;
        }else{
            if(count%2 == 1){break;}
            target = tmp;
            count =1;
        }
    }

    if(count%2 == 1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e7+5;
const ll p=1e9+7;

ll read()
{
	ll s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(ll x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(ll x,char c='\n')
{
	write(x);
	putchar(c);
}
ll fact[N],inv[N];
ll power(ll a,ll b)
{
	ll ans=1;
	while (b)
	{
		if (b&1) ans=ans*a%p;
		a=a*a%p;
		b/=2;
	}
	return ans;
}
ll C(ll n,ll m)
{
	if (m>n) return 0;
	return fact[n]*inv[m]%p*inv[n-m]%p;
}

int main()
{
	fact[0]=1;
	ll n=read(),k=read();
	for (ll i=1;i<=n;i++) fact[i]=fact[i-1]*i%p;
	inv[n]=power(fact[n],p-2);
	for (ll i=n-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%p;
	for (ll i=1;i<=k;i++) print(C(k-1,i-1)*C(n-k+1,i)%p);

	return 0;
}

Measured memory_bytes: 2304
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define Pv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define Pt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    ll sum = 0;
    ll count = 0;
    rep(i,s.length()){
        if(s[i] == 'W'){
            sum += i;
            count++;
        }
    }

    for(ll i = 0;i < count;i++){
        sum -= i;
    }
    P(sum);
}

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


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

using namespace std;

#define fto(i, s, e) for(int i = s; i <= e; ++i)
#define fto1(i, s, e) for(int i = s; i < e; ++i)
#define fdto(i, s, e) for(int i = s; i >= e; --i)
#define fit(var, it) for(__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define frit(var, it) for(__typeof(var.rbegin()) it = var.rbegin(); it != var.rend(); ++it)

#define newl '\n'
#define debugt cerr << 0.001*clock() << newl
#define debug1(x, i) cout << #x << '[' << i << "] = " << x[i] << newl
#define debug(v, l, r) fto(_i, l, r) debug1(v, _i)
#define debug2(x, i, j) cout << #x << '[' << i << "][" << j << "] = " << x[i][j] << newl
#define debug3(x, i, j, k) cout << #x << '[' << i << "][" << j << "][" << k << "] = " << x[i][j][k] << newl

#define ll long long
#define ii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define glen(v) int((v).size())

template<typename T1, typename T2> ostream& operator<< (ostream &os, pair<T1, T2> const &v) {
	return os << '(' << v.ff << ", " << v.ss << ')';
}

#define eps 1e-15
#define oo 1000000007
#define OO 1000000000000000003LL
#define maxn 100003

int n, m, cnt;
int topo[maxn], f[maxn];
bool visited[maxn];
vector<int> a[maxn];

void dfs(int u) {
	visited[u] = 1;
	fto1 (i, 0, glen(a[u])) {
		int v = a[u][i];
		if (!visited[v]) dfs(v);
	}
	topo[--cnt] = u;
}

int main() {
	#ifndef ONLINE_JUDGE
		//freopen("main.inp", "r", stdin);
		//freopen("main.out", "w", stdout);
	#endif
	//ios_base::sync_with_stdio(0); cin.tie(0);

	scanf("%d%d", &n, &m);
	cnt = n+1;

	int u, v;
	fto (i, 1, m) {
		scanf("%d%d", &u, &v);
		a[u].pb(v);
	}

	fto (i, 1, n) if (!visited[i]) dfs(i);

	fto (i, 1, n) visited[i] = 0;

	fto (i, 1, n) {
		int u = topo[i];
		visited[u] = 1;
		fto1 (i, 0, glen(a[u])) {
			int v = a[u][i];
			if (!visited[v]) f[v] = max(f[v], f[u] + 1);
		}
	}

	printf("%d\n", *max_element(f + 1, f + 1 + n));

	return 0;
}


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

namespace Atcoder
{

    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            double ans = 0;
            for (int i = 1; i <= N; i++)
            {
                double obj = Math.Pow(i,2);
                if(obj<=N){
                    ans = obj;
                }else{
                    break;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
DBG = !true
BIG = 99999999999
a,b,q = gets.split.map{|z| z.to_i}
s = []
t = []
for i in 0...a
  s << gets.to_i
end
for i in 0...b
  t << gets.to_i
end

for i in 0...q
  x = gets.to_i
  mn = BIG

  p = s.bsearch_index{|z| z>=x}
  p = a-1 if p.nil?
  puts "-- x #{x} p #{p}" if DBG
  if s[p] == x && false
    q = t.bsearch_index{|z| z>=x}
    q = b-1 if q.nil?
    mn = (t[q]-x).abs
    mn = (t[q-1]-x).abs if q>0 && (t[q-1]-x).abs < mn
  else
    q = t.bsearch_index{|z| z>=s[p]}
    q = b-1 if q.nil?
    mid = (s[p]-x).abs
    v = mid + (t[q]-s[p]).abs
    puts "1. q #{q} mid #{mid} v #{v} " if DBG
    mn = v if v < mn
    if q>0
      v = mid + (t[q-1]-s[p]).abs
      puts "2. q #{q} mid #{mid} v #{v} " if DBG
      mn = v if v < mn
    end

    if p>0
      q = t.bsearch_index{|z| z>=s[p-1]}
      q = b-1 if q.nil?
      mid = (s[p-1]-x).abs
      v = mid + (t[q]-s[p-1]).abs
      puts "3. q #{q} mid #{mid} v #{v} " if DBG
      mn = v if v < mn
      if q>0
        v = mid + (t[q-1]-s[p-1]).abs
        puts "4. q #{q} mid #{mid} v #{v} " if DBG
        mn = v if v < mn
      end
    end

  end

   # # #

  q = t.bsearch_index{|z| z>=x}
  q = b-1 if q.nil?
  puts "== x #{x} q #{q}" if DBG
  if t[q] == x && false
    q = t.bsearch_index{|z| z>=x}
    q = b-1 if q.nil?
    mn = (t[q]-x).abs
    mn = (t[q-1]-x).abs if q>0 && (t[q-1]-x).abs < mn
  else
    p = s.bsearch_index{|z| z>=t[q]}
    p = a-1 if p.nil?
    mid = (t[q]-x).abs
    v = mid + (t[q]-s[p]).abs
    puts "1. p #{p} mid #{mid} v #{v} " if DBG
    mn = v if v < mn
    if p>0
      v = mid + (t[q]-s[p-1]).abs
      puts "2. p #{p} mid #{mid} v #{v} " if DBG
      mn = v if v < mn
    end

    if q>0
      p = s.bsearch_index{|z| z>=t[q-1]}
      p = a-1 if p.nil?
      mid = (t[q-1]-x).abs
      v = mid + (t[q-1]-s[p]).abs
      puts "3. p #{p} mid #{mid} v #{v} " if DBG
      mn = v if v < mn
      if p>0
        v = mid + (t[q-1]-s[p-1]).abs
        puts "4. p #{p} mid #{mid} v #{v} " if DBG
        mn = v if v < mn
      end
    end

  end


  puts "#{mn}"
end


Measured memory_bytes: 4600
#include<stdio.h>
int t;
int ans = 0;
void dfs(unsigned n,bool k3,bool k5,bool k7){
	if(n>t)return; 
	if(k3&&k5&&k7){
		ans++;	
	}
	dfs(n*10+3,true,k5,k7);
	dfs(n*10+5,k3,true,k7);
	dfs(n*10+7,k3,k5,true);
}

int main(){
	scanf("%d", &t);
	dfs(0,false,false,false);
	
//	dfs(3,true,false,false);
//	dfs(5,false,true,false);
//	dfs(7,false,false,true);
	
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n){
		int b;cin >> b;
		a.at(b)++;
	}
	bool ok = true;
	for(int i = n - 1; i >= 0; i -= 2){
		if(i == 0 && a.at(i) != 1) ok = false;
		if(i > 0 && a.at(i) != 2) ok = false;
	}
	if(ok){
		ll ans = 1;
		rep(i,n / 2){
			ans *= 2;
			ans %= mod;
		}
		cout << ans << endl;
	}
	else cout << 0 << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
typedef long long ll;
using namespace std;

int main(void){
  static ll i,n,m,a[100000];
  static pair <ll,ll> s[100000];
  cin>>n>>m;
  for(i=0;i<n;i++)cin>>a[i];
  for(i=0;i<m;i++)cin>>s[i].second>>s[i].first;

  sort(a,a+n);
  sort(s,s+m);
  ll j=m-1;
  i=0;

  while(j>=0&&i<n){
    if(a[i]<s[j].first){
      a[i]=s[j].first;
      s[j].second--;
    }
    else break;
    if(s[j].second==0){
      j--;
    }
    i++;
  }

  ll ans=0;
  for(i=0;i<n;i++){
    ans+=a[i];
  }
  cout<<ans<<endl;
  
	return 0;
}


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

int main() {
  
  char a,b;
  cin >> a >> b;
  
  if(a == 'H') cout << b << endl;
  else {
    if(b == 'H') cout << "D" << endl;
    else cout << "H" << endl;
  }
  
}


Measured memory_bytes: 256
X = input()
N = len(X)

right = 1
cnt = 0

for left in range(N - 1):
    if X[left] == 'S':
        right = max(right, left + 1)
        while right < N and X[right] != 'T':
            right += 1
        if right >= N:
            break
        if X[right] == 'T':
            # print(left, right)
            right += 1
            cnt += 1
print(N - cnt * 2)

Measured memory_bytes: 40928
function Main(s) {
  var s = s.split("\n");
  var n = s[0]*1, t = s[1];
  var backet = new Array(n).fill(0);
  var wCnt = 0, eCnt = 0;
  for (var i = 0; i < n; i++) {
    backet[i] += wCnt;
    if (t[i] === "W") wCnt++;
    backet[n - 1 - i] += eCnt;
    if (t[n - 1 - i] === "E") eCnt++;
  }
  var min = Infinity;
  for(var i of backet) min = Math.min(min, i);
  console.log(min);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 15156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int main(){
  string S; cin>>S;
  if(S[2]==S[3]&&S[4]==S[5]) cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int n;
  set<int64_t> s;
  for (int i = 0; i < N; i++){
    cin >> n;
    s.insert(n);
    if (s.size() != i + 1){
      cout << "NO" << endl;
      break;
    }
    if (i == N - 1){
      cout << "YES" << endl;
    }
  }
}


Measured memory_bytes: 9600
#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<tuple<int, int> > v = {};
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		v.push_back(make_tuple(a, b));
	}
	sort(v.begin(), v.end(),
			[](tuple<int, int> s, tuple<int, int> t) -> bool {
				return get<1>(s) < get<1>(t);
			});
	set<int> s;
	int ans = 0;
	for(int i = 0; i < m; i++) {
		bool f = false;
		for(auto x: s) {
			if(get<0>(v[i]) <= x && x < get<1>(v[i])) {
				f = true;
				break;
			}
		}
		if (!f) {
			s.insert(get<1>(v[i]) - 1);
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>

int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);

  if(a <= b&b <= c){
    printf("%d %d %d\n",a, b, c);
  }else if (a<= c&c <= b){
    printf("%d %d %d\n",a, c, b);
  }else if (b <= a&a <= c){
    printf("%d %d %d\n",b, a, c);
  }else if(b <= c&c <= a){
    printf("%d %d %d\n",b, c, a);
  }else if(c <= b&b <= a){
    printf("%d %d %d\n",c, b, a);
  }else if(c <= a&a <= b){
    printf("%d %d %d\n",c, a, b);
  }

  return 0; 
}

Measured memory_bytes: 596
import math

TAXRATE8 = 0.08
TAXRATE10 = 0.1

tax8, tax10 = map(int, input().split())

amount8_min = math.ceil(tax8 / TAXRATE8)
amount8_max = math.floor((tax8+1) / TAXRATE8)
if ((tax8+1) / TAXRATE8).is_integer():
  amount8_max -= 1


amount10_min = math.ceil(tax10 / TAXRATE10)
amount10_max = math.floor((tax10+1) / TAXRATE10)
if ((tax10+1) / TAXRATE10).is_integer():
  amount10_max -= 1

ans_set = set(range(amount8_min, amount8_max)) & set(range(amount10_min, amount10_max))

if ans_set == set({}):
  print(-1)
else:
  print(min(ans_set))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define P pair<long,long>
#define all(a) a.begin(),a.end()
using namespace std;

signed main(){
    int n,k; cin>>n>>k;
    int a=0,b=0;
    rep(i,n){
        if((i+1)%k==0) a++;
        else if(k%2==0 and (i+1)%k==k/2) b++;
    }
    cout<<a*a*a+b*b*b<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;
multiset<int> a;
int main(){
  int n,k;cin>>n>>k;
  for(int i = 0; n > i; i++){
    int z;cin>>z;
    a.insert(z);
  }
  vector<int> b;
  for(auto i = a.begin(); a.end() != i;){
    b.push_back(a.count(*i));
    while(*i == *++i){
      if(i==a.end())break;
    }
    
  }
  sort(b.begin(),b.end());
  int ret = 0;
  for(int i = 0; b.size()-i > k; i++){
    ret += b[i];
  }
  cout << ret << endl;
}

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

int main(void){
  long long a,b,c;
  long long ans=0;
  
  cin >> a >> b >> c;
  if (a==b&&b==c&&a%2==0) cout << -1 << endl;
  else {
    while (a%2==0&&b%2==0&&c%2==0){
      int t,u,v;
      t = b/2+c/2;
      u = c/2+a/2;
      v = a/2+b/2;
      a=t; b=u; c=v;
      ans++;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for(ll i=0;i<(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n,q;cin>>n>>q;
    priority_queue<ll>a[1010];
    while(q--){
        int c;cin>>c;
        if(c==0){
            ll t,x;cin>>t>>x;
            a[t].push(x);
        }
        else if(c==1){
            ll t;cin>>t;
            if(a[t].size())
            cout<<a[t].top()<<endl;;
        }
        else{
            ll t;cin>>t;
            if(a[t].size())
            a[t].pop();
        }
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------













































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

typedef long long ll;
typedef pair <int , int> pii;

const int N = 2e5+10 , mod = 1e9+7;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int a;
   cin >> a;
   cout << a + a * a + a * a * a;
   return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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; }

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}

int main(){
    for(int i = 1; i < 6; i++){
        int x;
        cin >> x;
        if(x == 0){
            cout << i << endl;
            return 0;
        }
    }
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

struct edge{
    int from,to,cost;
};

void solve(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> d(n,vector<int>(n,inf));
    vector<edge> es;
    rep(i,0,n) d[i][i]=0;
    rep(i,0,m){
        int a,b,c;
        cin >> a >> b >> c;
        --a;
        --b;
        d[a][b]=d[b][a]=c;
        es.push_back({a,b,c});
    }
    rep(k,0,n){
        rep(i,0,n){
            rep(j,0,n){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    int ans=m;
    for(edge &e:es){
        if(d[e.from][e.to]==e.cost) --ans;
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T>
struct BIT{
    int n;
    vector<T> d;
    BIT(int n = 0):n(n), d(n+1){}
    void add(int i, T x = 1){
        for(i++; i <= n; i += i&-i){
            d[i] += x;
        }
    }
    T sum(int i){
        T x = 0;
        for(i++; i; i -= i&-i){
            x += d[i];
        }
        return x;
    }
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, d, a;
    cin >> n >> d >> a;
    vector<P> p(n);
    rep(i,n) cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end());
    BIT<ll> bit(n+1);
    ll ans = 0;
    rep(i,n){
        ll x = p[i].first;
        ll h = p[i].second;
        h -= bit.sum(i);
        if(h <= 0) continue;
        ll num = (h+a-1)/a;
        ans += num;
        ll damage = num*a;
        bit.add(i, damage);
        int rx = min(x+d*2, 1001001001LL);
        int j = upper_bound(p.begin(), p.end(), P(rx+1, -1)) - p.begin();
        bit.add(j, -damage);
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    string s;
    int x, y;
    cin >> s >> x >> y;
    s += 'T';

    vec<vec<bool>> X(2, vec<bool>(8001, 0)), Y(2, vec<bool>(8001, 0));
    X[0][0] = 1;
    Y[0][0] = 1;

    bool forx  = true;
    bool first = true;
    int now    = 0;
    for (auto e : s) {
        if (e == 'F') {
            ++now;
        } else {
            if (first) {
                x -= now;
                first = false;
            } else if (now > 0) {
                vec<vec<bool>> &a = (forx ? X : Y);
                rep(i, 8001) {
                    if (!a[0][i]) continue;
                    a[1][abs(i - now)] = true;
                    a[1][abs(i + now)] = true;
                }
                a[0] = a[1];
                a[1] = vec<bool>(8001, 0);
            }
            forx = !forx;
            now  = 0;
        }
    }

    bool ans = (X[0][abs(x)] && Y[0][abs(y)]);
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

bool flag[55][55];
long long int H[55][55];

int main(){
	int w, d, n;
	cin >> w >> d >> n;
	for(int i = 0; i < n; i++){
		int x, y, z;
		cin >> x >> y >> z;
		H[y][x] = z;
		flag[y][x] = true;
	}
	long long int ans = 0;
	for(int i = 1; i <= d; i++){
		for(int j = 1; j <= w; j++){
			if(flag[i][j]){
				for(int k = 1; k <= d; k++){
					for(int l = 1; l <= w; l++){
						if(flag[k][l] && abs(H[i][j] - H[k][l]) > abs(i - k) + abs(j - l)){
							cout << "No" << endl;
							return 0;
						}
					}
				}
			}else{
				H[i][j] = -INF;
				for(int k = 1; k <= d; k++){
					for(int l = 1; l <= w; l++){
						if(flag[k][l]){
							H[i][j] = max(H[i][j], H[k][l] - abs(i - k) - abs(j - l));
						}
					}
				}
			}
			ans += H[i][j];
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;

int main(){
  char s[101],p[101],c;

  scanf("%s\n",s);
  scanf("%s\n",p);

  for(unsigned long int i=0;i<strlen(s);i++){
    if(strncmp(s,p,strlen(p))==0){
      puts("Yes");
      return 0;
    }
    c=s[strlen(s)-1];
    memmove(s+1,s,strlen(s)-1);
    s[0]=c;
  }
  puts("No");

}


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

typedef enum {
  JUDGE_GREATER = 0,
  JUDGE_EQUAL   = 1,
  JUDGE_LESS    = 2,
  JUDGE_ALL     = 3,
} E_JUDGE;

E_JUDGE greater(std::string a, std::string b) {
  if (a.size() > b.size()) {
    return JUDGE_GREATER;;
  }
  if (a.size() == b.size()) {
    std::string::iterator ita = a.begin();
    std::string::iterator itb = b.begin();
    for (; ita != a.end() && ita!= b.end(); ita++, itb++) {
      if (*ita == *itb) {
	continue;
      }
      if (*ita > *itb) {
	return JUDGE_GREATER;
      }
      if (*ita < *itb) {
	return JUDGE_LESS;
      }
    }
    return JUDGE_EQUAL;
  }
  return JUDGE_LESS;
}

int main(int argc, char* argv[])
{
  std::string A, B;
  std::cin >> A >> B;

  E_JUDGE judge = greater(A, B);
  if (judge == JUDGE_GREATER) {
    std::cout << "GREATER" << std::endl;
  }
  if (judge == JUDGE_EQUAL) {
    std::cout << "EQUAL" << std::endl;
  }
  if (judge == JUDGE_LESS) {
    std::cout << "LESS" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<sstream>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;


int main()
{
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0;i < s.length()/2;i++){
		if(s[i] != s[s.length() - 1 - i])
			ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;

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

int main() {
  ll A, B;
  cin >> A >> B;
  ll ans = (A * B) / gcd(A, B);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
S=int(input())
x1=0
y1=0
x2=10**9
y2=1
x3=10**9-S%(10**9)
y3=S//(10**9)+1
if S!=10**18:
  print(x1,y1,x2,y2,x3,y3)
else:
  y3=10**9
  x3=0
  print(x1,y1,x2,y2,x3,y3)

Measured memory_bytes: 3060
#include<stdio.h>
int a,b,c,k,s,cnt;
int main() {
	scanf("%d %d",&k,&s);
	for(int i=0;i<=k;i++)
		for(int j=0;j<=k;j++){
			int m=s-i-j;
			if(m>=0&&m<=k) cnt++;
		}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
long long n,a,b;
cin >> a >> b;
long long i = min(1000000000,(int)(b / a));
for(i; i > 0;i--){
if(b % i == 0)if(b / i >= a){cout << i <<endl;return 0;}
}
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;
const ll MAX = 26;
const ll OFFSET = 1e6;

ll C[30];
ll S[400][30];
ll Last[30];

ll calc(ll t, ll d, ll score) {
    score += S[d][t];
    //Last[t] = d;
    REP(i, MAX) {
        if (i == d)
            continue;
        score -= C[i] * (d - Last[i]);
    }
    return score;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll D;
    cin >> D;
    REP(i, MAX) {
        cin >> C[i];
    }
    REP(i, D) {
        REP(j, MAX) {
            cin >> S[i][j];
        }
    }
    memset(Last, -1, sizeof(Last));
    ll score = 0;
    vector<ll> ans;
    REP(i, D) {
        pll mx = pll(-INF, 0);
        REP(j, 26) {
            ll s = calc(j, i, score);
            if (s > mx.first)
                mx = pll(s, j);
        }
        score = mx.first;
        Last[mx.second] = i;
        ans.push_back(mx.second);
    }


    REP(i, ans.size()) {
        cout << ans[i] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3752
#include<iostream>
#include<cstdio>
using namespace std;
long long n,sum,a[13]; //记得开long long
long long dfs(long long x,long long sum,long long sum1)
{
    if(x==1)
        return 2*sum+sum1+a[x]+sum1*10+a[x];
    return dfs(x-1,sum,sum1*10+a[x])+dfs(x-1,sum+sum1,a[x]); //分两种情况dfs
}
int main()
{
    cin>>n;
    while(n!=0)
        sum++,a[sum]=n%10,n/=10;
    cout<<dfs(sum,0,0)/2;
    return 0;
}

Measured memory_bytes: 256
n,l = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

index = 0
for i in range(n-1):
    if a[i]+a[i+1] >= l:
        index = i+1

if index==0:
    print("Impossible")
else:
    print("Possible")
    for i in range(1,index):
        print(i)
    for i in range(n-1,index,-1):
        print(i)
    print(index)

Measured memory_bytes: 14052
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			System.out.println(IntStream.range(1, n).reduce(scanner.nextInt(), (a, b) -> gcd(a, scanner.nextInt())));
		}
	}

	/**
	 * 最大公約数を計算
	 * 
	 * @param x
	 * @param y
	 * @return 最大公約数
	 */
	private static int gcd(int x, int y) {
		if (x < y) {
			return gcd(y, x);
		}
		int tmp = 0;
		while (0 != (tmp = x % y)) {
			x = y;
			y = tmp;
		}
		return y;
	}
}


Measured memory_bytes: 58996
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t a,b,c;
    cin >> a >> b >> c;
    // 2より小さいのがあればならす
    // 1の差が１つなら　+1, 2つなら+2;
    int64_t max_ = max(a,max(b,c));
    int64_t res = 0;
    if(a!=max_) {
        res += (max_-a)/2;
        a += ((max_-a)/2)*2;
    }
    if(b!=max_) {
        res += (max_-b)/2;
        b += ((max_-b)/2)*2;
    }
    if(c!=max_) {
        res += (max_-c)/2;
        c += ((max_-c)/2)*2;
    }
    if(b>a) swap(a,b);
    if(c>a) swap(a,c);
    if(c>b) swap(b,c);
    if(a == b && b == c) cout << res << endl;
    if(a>b && b==c) cout << res + 1 << endl;
    if(a==b && b>c) cout << res + 2 << endl;
}


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

#define rep(i,a,b) for(long long i = a; i < b; i++)
#define dump(a) for(auto x : a) cout << x << " "; cout << "\n"
#define print(a) cout << a << "\n"
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr << #x << ": " << x << ", " << #y << ": " << y << "\n"
#define debug3(x,y,z) std::cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << "\n"

typedef long long ll;
using vi   = vector<int>;
using vll  = vector<long long>;
using vs   = vector<string>;
using vvi  = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using vvs  = vector<vector<string>>;


int main() {
  ll n,d;cin >>n >>d;
  ll total = 0;
  rep(i,0,n) {
    ll x,y;cin>>x>>y;
	ll p2 = x * x;
    ll q2 = y * y;
    if(sqrt(p2 + q2) <= d) {
      total++;
    }
  }
  print(total);
  
  
  return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n, k;
  cin >> n >> k;
  ll ans = k;
  for(int i = 0; i < n - 1; i++){
    ans *= (k - 1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, 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;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int n, bool visited[nmax]) {
	bool all_visited = true;
	rep(i, n) {
		if (!visited[i])all_visited = false;
	}
	if (all_visited)return 1;
	int ret = 0;
	rep(i, n) {
		if (!graph[v][i])continue;
		if (visited[i])continue;
		visited[i] = true;
		ret += dfs(i, n, visited);
		visited[i] = false;
	}
	return ret;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, t; cin >> n >> t;
	int ans = t;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n - 1) {
		ans += min(t, a[i + 1] - a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
A = int(input())
B = int(input())
C = int(input())
X = int(input())
t = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500 + j*100 + k*50 == X:
                t += 1
print(t)


Measured memory_bytes: 39664
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
const int inf = 0x3f3f3f3f;
typedef long long ll;
#define ull unsigned long long
const int maxn = 1e5+10;
const ll mod=1e9+7;
#define MAXN 40100
ll gcd(ll T, ll b) { return b == 0 ? T : gcd(b, T % b); }
ll lcm(ll T, ll b) { return T / gcd(T, b) * b; }
ll mul(ll a,ll b, ll c) {
    ll ans = 0;
    while(b) {
        if(b&1) {
            ans= (ans+a)%c;
            b--;
        }
        b>>=1;
        a=(a+a)%c;
    }
    return ans;
}
 
ll powmod(ll a,ll b,ll c) {
    ll ans = 1;
    while(b) {
        if(b&1) {
            ans = mul(ans,a,c);
            b--;
        }
        b>>=1;
        a=mul(a,a,c);
    }
    return ans ;
}
 
ll exgcd(ll a,ll b,ll &x,ll &y) {
    if(b==0)
    {
        x=1;y=0;
        return a; 
    }
    ll r=exgcd(b,a%b,x,y);
    ll temp=y;
    y=x-(a/b)*y;
    x=temp;
    return r;
}

int main() {
    ull a,ans;
    char s[6];
    cin>>a>>s;
    ans=(s[0]-'0')*100 + (s[2]-'0')*10 + (s[3]-'0'); 
    cout<<a*ans/100<<endl;
    return 0;

}


Measured memory_bytes: 3644
n=int(input())
c=list(map(int,input().split()))
c.sort(reverse=1)
m=10**9+7
d=(2**(n-2))%m
ans=0
k=2
for x in c:
  x=int(x%m)
  ans+=(x*k*d)%m
  k+=1
ans=(int(ans)%m*d*4)%m

print(int(ans))

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

int main() {
    int k; cin >> k;

    ll sum = 0;
    for (int a = 1; a <=k;a++) {
        for (int b = 1; b<=k; b++) {
            for (int c = 1; c<= k; c++) {
                sum+= __gcd(__gcd(a, b), c);
            }
        }
    }
    cout << sum << endl;

}

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

int main()
{
  int n;
  cin >> n;
  n %= 10;

  if (n == 3) {
    cout << "bon" << endl;
  } else if (n == 0 || n == 1 || n == 6 || n == 8) {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }

  return 0;
}


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

int main() {
    int N; cin >> N;
    for (int i=1; i<10; ++i) {
        if ((N/i)*i==N && N/i < 10) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys 
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, A = map(int, readline().split())
X = list(map(int,readline().split()))
Y = [x-A for x in X]
dp = {0:1}

for y in Y:
    tmp = list(dp.items())
    for k,v in tmp:
        dp[k+y] = dp.get(k+y,0) + v
print(dp[0]-1) 

Measured memory_bytes: 27392
n=int(input())
A=list(map(int,input().split()))
right=0
s=0
ans=0
for left in range(n):
    while right<=n-1 and (s+A[right])==(s^A[right]):
        s+=A[right]
        right+=1
    ans+=right-left
    s-=A[left]
print(ans)

Measured memory_bytes: 24840
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

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

#ifdef __BORLANDC__
	typedef __int64 ll;
#else
	typedef long long ll;
#endif


int main(){
	
	ll k = 1;
	int n;
	cin>>n;
	reps(i,1,n+1){
		k*=i;
	}
	cout<<k<<endl;
}

Measured memory_bytes: 1156
a,b,c,d = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)
turn = True
while(a > 0 and c > 0):
    if turn == True:
        c = c - b
        turn = False
    else:
        a = a - d
        turn = True
if a <= 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9188
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace dwango_5_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            double[] input = ReadLine().Split().Select(Double.Parse).ToArray();
            double ave = input.Sum()/(double)n;

            for (int i = 0; i < n; i++){
                input[i] = Abs(input[i]-ave);
            }

            double min = int.MaxValue;
            int cnt=0;
            for (int i = 0; i < n; i++){
                if(input[i]<min){
                    cnt = i;
                    min = input[i];
                }
            }

            WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 13396
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	int N;
	int i,count=1;
	scanf("%d\n", &N);
	char S[N+1][11];

	for (i = 0; i < N; i++) {
		scanf("%s\n", S[i]);
		//printf("%s\n", S[i]);
	}
	
	//qsort(S, N, sizeof(*S), strcmp);
	qsort(S, N, sizeof(S[0]), strcmp);

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

Measured memory_bytes: 5744
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define ll long long int
const int INF=0x3f3f3f3f;
int main()
{
	ll n,a,b;
	scanf("%lld %lld %lld",&n,&a,&b);
	ll t;
	t=min(a,(n%(a+b)));
	printf("%lld\n",(n/(a+b))*a+t);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

typedef long long ll;

ll a, b, c, sol;

int main(){
cin >> a >> b >> c;
sol += b;
sol += min(c, b);
c = max(0LL, c - b);
sol += min(c, a);
c = max(c - a, 0LL);
if(c > 0){
	sol++;
}
cout << sol << endl;

return 0;
}



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

#include <stdio.h>
#include <iostream>
#include <stddef.h>
 
using namespace std;
typedef long long ll;

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

  int n; cin >> n;
  int arr[n + 1];

  for (int i = 1; i <= n; ++i) cin >> arr[i];

  bool visited[n + 1];
  memset(visited, false, sizeof(visited));

  int buttons_pressed = 0;
  queue<int> q({1});

  while (!q.empty()) {
    int x = q.front(); q.pop();

    if (x == 2) {
      cout << buttons_pressed << "\n";
      return 0;
    }

    if (!visited[x]) {
      visited[x] = true;
      buttons_pressed++;
      q.push(arr[x]);
    }
  }

  cout << -1 << "\n";
}


Measured memory_bytes: 4144