akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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 <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int h, w;
	bool ans = true;
	bool cnt = false;
	cin >> h >> w;
	vector<string> s(h);
	cin >> s;
	rep(i, h) {
		rep(j, w) {
			if (s[i][j] == '.') continue;
			cnt = false;
			for (int ni = max(0, i - 1); ni < min(h, i + 2); ni++) {
				for (int nj = max(0, j - 1); nj < min(w, j + 2); nj++) {
					if ((ni == i) xor (nj == j)) {
						if (s[ni][nj] == '#') {
							cnt = true;
						}
					}
				}
			}
			ans = ans and cnt;
		}
	}
	cout << solve(ans) << endl;
}

Measured memory_bytes: 3580
#include<stdio.h>

int main(void)
{
    int L, R, d, count=0, i;

    scanf("%d %d %d", &L, &R, &d);

    for(i=1; i<=R; i++) {
        if (L <= i*d && i*d <= R) {
            count++;
        }
    }

    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int A[MAX_N], B[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	rep(i, 0, N) cin >> B[i];
	ll ans = 0;
	rep(k, 0, 29) {
		vector<int> vec;
		rep(i, 0, N) vec.pb(B[i] & ((1 << k) - 1));
		sort(all(vec));
		ll res = 0;
		rep(i, 0, N) {
			int a = (1 << k) - (A[i] & ((1 << k) - 1));
			if((A[i] ^ B[i]) & (1 << k)) {
				res += lower_bound(all(vec), a) - vec.begin();
			}
			else res += N - (lower_bound(all(vec), a) - vec.begin());
			// debug(k, i, A[i], vec, a, res);
		}
		if(res % 2) ans |= (1 << k);
	}
	cout << ans << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

vector<ll> v;

ll ret;
ll n,m,k;

void last(priority_queue<ll> que,ll remain){
  ll cnt = 0;
  while(!que.empty()){
    if(que.top()>0 && remain>0){
      que.pop();
      remain--;
    }else break;
  }
  ll q = que.size();
  for(ll i=0;i<q;i++){
    cnt-=que.top();
    que.pop();
  }
  //cout << cnt << endl;
  ret = max(ret,cnt);
  return;
}

void right(priority_queue<ll> que, ll remain,ll left){
  for(ll j=0;j<=min(n,remain);j++){//右からj個掘る
    if(j>0 && left+j<=n)que.push(-v[n-j]);
    //if(!que.empty())cout << que.top() << endl;
    last(que,remain-j);
  }
  //cout << endl;
}

int main(){
  cin >> n >> k;
  ll i,j;
  v.resize(n);
  for(i=0;i<n;i++)cin >> v[i];
  ll sum = 0;
  priority_queue<ll> que;
  for(i=0;i<=min(k,n);i++){//左からi個掘る
    if(i>0)que.push(-v[i-1]);
    right(que,k-i,i);
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int MAX = 200005;
static const int INF = 1e9+5;
int n, a[MAX], ans[MAX], dp[MAX];
vector<int> G[MAX];

void dfs(int x, int p) {
    int pos = lower_bound(dp, dp+n, a[x]) - dp;
    int res = dp[pos];
    dp[pos] = a[x];
    ans[x] = lower_bound(dp, dp+n, INF) - dp;
    for (int y: G[x]) {
        if (y != p) dfs(y, x);
    }
    dp[pos] = res;
}

int main() {
    int u, v;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n-1; i++) {
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    for (int i = 0; i < n; i++) {
        dp[i] = INF;
    }
    dfs(0, -1);
    for (int i = 0; i < n; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 31224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
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; }


int main(){
    int N;
    cin >> N;
    ll ans = 0;
    vector<int> L(N);
    rep(i, N) cin >> L.at(i);
    for(int i = 0; i < N-2; i++){
        for(int j = i+1; j < N-1; j++){
            for(int k = j+1; k < N; k++){
                priority_queue<int> que;
                que.push(L[i]);
                que.push(L[j]);
                que.push(L[k]);
                int a = que.top();
                que.pop();
                int b = que.top();
                que.pop();
                int c = que.top();
                que.pop();
                if(a == b || b == c || a == c) continue;
                if(a < b+c) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <vector>
using std::cin;
using std::cout;
using std::vector;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int &pi : p) cin >> pi;

    std::sort(p.begin(), p.end());
    int ans = 0;
    for (int i = 0; i < k; ++i) {
        ans += p.at(i);
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;

int main() {
	int m = 3, x, n;
	map < int, pii > mp;
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < m; j++) {
			cin >> x;
			mp[x] = make_pair (i, j);
		}
	}
	vector < int > rows (m), cols(m), diag(2);
	cin >> n;
	while (n--) {
		cin >> x;
		if (mp.find (x) == mp.end()) continue;
		pii p = mp[x];
		rows[p.first]++;
		cols[p.second]++;
		if (p.first == p.second) diag[0]++;
		if (p.first + p.second == m - 1) diag[1]++;
	}
	for (int row : rows) {
		if (row >= m) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	for (int col : cols) {
		if (col >= m) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	for (int d: diag) {
		if (d >= m) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;	
}


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

#define rep(i,n) for (int i=0; i < (n); ++i)
using ll = long long ;
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;

int dp[110000] ;

int main() {

    int n ;
    cin >> n ;
    int h[n+1];
    rep(i,n) cin >> h[i] ;
    dp[0] = 0 ;

    for(int i=1;i<n;i++){
        if(i==1)dp[i-1] + abs(h[i]-h[i-1]) ;
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]),
                    dp[i-2] + abs(h[i]-h[i-2])) ;
    }
    cout << dp[n-1] << endl ;
    return 0 ;
}

Measured memory_bytes: 4316
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n, m = sc.nextInt()

  Range(0, m).map(_ => (sc.nextInt, sc.nextInt))
    .sorted
    .foldLeft(Array[Int](Range(0, n).map(_ => 0):_*)) {
      case (ar, (a, b)) =>
        ar(a - 1) = ar(a - 1) + 1
        ar(b - 1) = ar(b - 1) + 1
        ar
    }
    .foreach(println(_))
}


Measured memory_bytes: 25920
import java.util.ArrayList;
	import java.util.Arrays;
	import java.util.Collections;
	import java.util.Comparator;
	import java.util.HashMap;
	import java.util.HashSet;
	import java.util.List;
	import java.util.Map;
	import java.util.Map.Entry;
	import java.util.PriorityQueue;
	import java.util.Queue;
	import java.util.Scanner;
	import java.util.Set;

	public class Main{

		public static void main(String[] args) {

			Scanner scanner = new Scanner(System.in);
			String[] t = scanner.nextLine().split(" ");
			int n = Integer.parseInt(t[0]);
			int m = Integer.parseInt(t[1]);
			HashSet<Integer> set = new HashSet<>();

			for(int i = 0; i < m;i++) {
				set.add(scanner.nextInt() - 1);
			}

			long mod = 1000000007;

			long[] dp = new long[n];

			for(int i = 0; i < n; i++) {

				if(!set.contains(i)) {
					if(i == 0) {
						dp[0] = 1;
					}else if(i == 1) {
						dp[i] = dp[0] + 1;
					}else{

					dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
					}
				}

			}


			System.out.println(dp[n - 1]);
		}
	}

Measured memory_bytes: 62644
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
vi adj[N];int n;int a[N];
int ans[N];
multiset<int>s;
void dfs(int u,int par)
{
    s.insert(a[u]);
    auto it=s.lower_bound(a[u]);
    it++;
    int p=-1;
    if(it!=s.end())
    {
        p=*(it);
        s.erase(it);
    }
    ans[u]=s.size();
    for(auto child : adj[u])
    {
        if(child!=par)
            dfs(child,u);
    }
    if(p!=-1)
    {
        s.insert(p);
    }
    s.erase(s.find(a[u]));
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   cin>>n;
   rep(i,1,n+1)
   {
       cin>>a[i];
   }
   rep(i,0,n-1)
   {
       int u,v;
       cin>>u>>v;
       adj[u].pb(v);
       adj[v].pb(u);
   }
   dfs(1,0);
   for(int i=1;i<=n;i++)
    cout<<ans[i]<<endl;
}



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

int main(){
  int x;
  cin >> x;
  if(400 <= x && x < 600){
    cout << 8 << endl;
  }else if(600 <= x && x < 800){
    cout << 7 << endl;
  }else if(800 <= x && x < 1000){
    cout << 6 << endl;
  }else if(1000 <= x && x < 1200){
    cout << 5 << endl;
  }else if(1200 <= x && x < 1400){
    cout << 4 << endl;
  }else if(1400 <= x && x < 1600){
    cout << 3 << endl;
  }else if(1600 <= x && x < 1800){
    cout << 2 << endl;
  }else if(1800 <= x && x < 2000){
    cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3668
/*
 author : @itzmv
 */
#include<bits/stdc++.h>
using namespace std;

#define ll int64_t
#define llu uint64_t
#define lli long long int
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define inf (ll)(1e9)

int main()
{
    int n;
    cin >> n;
    map < string, int > mp;
    for(int i = 0; i < n; i++)
    {
        string x;
        cin >> x;
        mp[x]++;
    }
    cout <<"AC x " << mp["AC"] << "\n";
    cout <<"WA x " << mp["WA"] << "\n";
    cout <<"TLE x " << mp["TLE"] << "\n";
    cout <<"RE x " << mp["RE"] << "\n";
    return 0;
}


Measured memory_bytes: 3564
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;

ll nCr(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
ll sumdigit(ll n) {
	ll dig = 0, sum = 0;
	while (n) {
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	return sum;
}



int main() {
	int a, b, c;
	std::cin >> a >> b >> c;
	if (c >= a && c <= b) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	return 0;
}

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

#define MAX 110000

int N, M;
pair<pair<int,int>, string> CD[MAX];
string O[MAX];

int main(){
	// set<int> s;
	  cin>>N;

	  for(int i = 0; i < N; i++){
		cin>>CD[i].second>>CD[i].first.first;
		CD[i].first.second = i;
		// s.insert(CD[i].first.first);
	  }

	  sort(CD, CD + N);
	  
	  cin>>M;

	  for(int i = 0, j  = 0; i < M; i++){
			cin>>O[i];
			for(; j < N; j++){
				if(O[i] == CD[j].second) break;
			}
			
			if(j == N){
				cout<<"No"<<endl;
				return 0;
			}
			j++;
			
			for(; j < N; j++){
				if(CD[j].first.first != CD[j-1].first.first){
					break;
				}
			}
			
	  }
	  // cout<<N<<" "<<s.size()<<" "<<M<<endl;
	  cout<<"Yes"<<endl;
	  
  return 0;
}


Measured memory_bytes: 21372
object Main {
  def main(args: Array[String]): Unit = {
    val Seq(a, b) = io.StdIn.readLine().split(" ").map(_.toInt).toSeq

    if (a >= b) println(a + math.max(a - 1, b))
    else println(b + math.max(a, b - 1))
  }
}


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

int main() {
  string S[3];
  cin >> S[0] >> S[1] >> S[2];

  char next = 'a';
  while (S[next - 'a'].size() > 0) {
    int tmp = next - 'a';
    next = S[tmp][0];
    S[tmp] = S[tmp].substr(1);
  }

  if (next == 'a') cout << "A" << endl;
  else if (next == 'b') cout << "B" << endl;
  else cout << "C" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
 
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define beg begin
#define dbg(x) cout << #x << " = " << x << endl;
 
template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}
 
template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i;
    }
    return str;
}
 
template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}
 
template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    solve();
    return 0;
}

const double eps = 1e-6;
const int MAXN = 1e5 + 10;
const double INF = 1e18 + 10;
int n;
vec<vec<int>> cycl;
int xs, ys, xf, yf;
vec<pair<double, int>> g[MAXN];

double get_dist(vec<int> &a, vec<int> &b) {
    int x1 = a[0], y1 = a[1], r1 = a[2];
    int x2 = b[0], y2 = b[1], r2 = b[2];
    if ((r1 + r2) * (r1 + r2) >= (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) {
        return (double)0.;
    }
    else {
        return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) - (r1 + r2);
    }
}

void solve() {
    cin >> xs >> ys >> xf >> yf;
    cin >> n;
    cycl.resize(n + 2, vec<int>(3));
    for (int i = 0; i < n; ++i) {
        cin >> cycl[i];
    }
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            double wt = get_dist(cycl[i], cycl[j]);
            assert(wt >= 0);
            g[i].pb({wt, j});
            g[j].pb({wt, i});
        }
    }
    cycl[n] = {xs, ys, 0};
    cycl[n + 1] = {xf, yf, 0};
    for (int i = 0; i <= n + 1; ++i) {
        if (i == n) continue;
        vec<int> tmp = {xs, ys, 0};
        double wt = get_dist(tmp, cycl[i]);
        assert(wt >= 0);
        g[n].pb({wt, i});
        g[i].pb({wt, n});
    }
    for (int i = 0; i <= n; ++i) {
        vec<int> tmp = {xf, yf, 0};
        double wt = get_dist(tmp, cycl[i]);
        assert(wt >= 0);
        g[n + 1].pb({wt, i});
        g[i].pb({wt, n + 1});
    }

    vec<double> dist(MAXN, INF);
    dist[n] = (double)0.;
    priority_queue<pair<double, int>> se;
    se.push({(double)0., n});
    while (!se.empty()) {
        auto it = se.top();
        se.pop();
        if (dist[it.y] < it.x) continue;
        for (auto nxt : g[it.y]) {
            if (dist[nxt.y] - (dist[it.y] + nxt.x) > eps) {
                dist[nxt.y] = dist[it.y] + nxt.x;
                pii tmp = {-dist[nxt.y], nxt.y};
                se.emplace(tmp);
            }
        }
    }

    cout << dist[n + 1] << endl;
}

Measured memory_bytes: 48008
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <bitset>
#include <iterator>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <random>
#include <numeric>
#include <set>
#include <cassert>
#include <cmath>
#include <cinttypes>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}
template<class T> T read_val() { throw 1; }
template<> int read_val() { int tmp; scanf("%" PRId32, &tmp); return tmp; }
template<> long long read_val() { long long tmp; scanf("%" PRId64, &tmp); return tmp; }
auto read_int = read_val<int>; auto read_long = read_val<long long>;
template<class T> void scanf_vec(vector<T>& vec) { for (int i = 0; i < vec.size(); i++) vec[i] = read_val<T>(); }

#define MOD 1000000007
#define inf 2000000000
#define FWT_SIZE 2000000
#define pii pair<int,int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define sort_all(x) sort(all(x))
#define make_unique(x) (x).erase(unique(all(x)), (x).end())

vector<int> step(vector<int> vec)
{
	vector<int> ans;
	for (int i = 0; i + 1 < vec.size(); i++)
	{
		ans.push_back(abs(vec[i] - vec[i + 1]));
	}
	return ans;
}

int solve(vector<int> vec)
{
	int n = vec.size() - 1;
	vector<int> ans;
	ans.push_back(0);
	for (int j = 30; j >= 0; j--)
	{
		if ((1<<j) & n)
		{
			vector<int> newans;
			for (int jj : ans)
			{
				newans.push_back(jj);
				newans.push_back(jj + (1 << j) );
			}
			ans = newans;
		}
	}
	int resp = 0;
	for (int x : ans)
	{
		if (x < vec.size())
			resp ^= vec[x];
	}
	return resp;
}

int main() {

#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	string str;
	cin >> str;
	n = str.size();
	vector<int> vec;
	bool any2 = false, any1 = false;
	for (char c : str)
	{
		vec.push_back(c - '0');
	}

	vector<int> orig_vec = vec;
	vec = step(vec);
	for (int c : vec)
	{
		if (c == 2) any2 = true;
		if (c == 1) any1 = true;
	}

	if (any1)
	{
		for (int& x : vec)
		{
			if (x == 2)x = 0;
		}
		cout << solve(vec);
	}
	else
	{
		cout << solve(vec);
	}

	return 0;
	cout << "\n";
	vec = orig_vec;
	while (vec.size() > 1)
	{
		vec = step(vec);

		cout << vec << "\n";

	}



	return 0;
}

Measured memory_bytes: 20756
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  long long n;
  cin >> n;
  long long k=100;
  long long ans=0;
  while(k<n){
    ans++;
    k=k+k/100;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
/**
 * Author : Deep Raval
 * There are no two words in the English language more harmful than "good job".
 * 1729 0_0
**/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <bitset>
#include <iomanip>
#include <assert.h>
#include <numeric>
using namespace std;
using ll = long long;
#define endl '\n'
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) 
{
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define FAST_IO ios::sync_with_stdio(0); std::cin.tie(0);
#define bp(x) __builtin_popcount(x)
#define zf(x) __builtin_clz(x)
#define zl(x) __builtin_ctz(x)
#define par(x) __bultin_parity(x)
#define all(x) (x).begin(), (x).end()
/* **************************************************************************************** */

void test_case()
{
	FAST_IO
    ll a;
    cin >> a;
    cout << a + (a * a) + (a * a * a) << endl;
	return ;
}
int main()
{
	FAST_IO
        test_case();
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    int N;
    cin >> N;
    vector<int>A(N);
    REP(i, N)cin >> A[i];

    vector<int> s = A;
    sort(ALL(s));
    int mode = s[N / 2];
    int iMode = N / 2;
    REP(i, N) {
        if (A[i] >= mode) {
            cout << s[iMode - 1] << endl;

        }
        else {
            cout << mode << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3712
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

lint ma;

void search(lint left,lint right,lint* A,lint* F,lint N){
    while(right-left>1){
        lint mid=left+(right-left)/2;
        lint K=ma;
        bool able=true;
        rep(i,N){
            lint minus=max(0LL,(A[i]-mid+F[i]-1LL)/F[i]);
            K-=minus;
            if(K<0) able=false;
        }
        if(able) right=mid;
        else left=mid;
    }
    cout << right << endl;
}
 
int main(void){
    lint N,K;
    cin >> N >> K;
    ma=K;
    lint A[N],F[N];
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> F[i];
    sort(A,A+N,greater<lint>());
    lint A2[N];
    sort(F,F+N);
    rep(i,N) A2[i]=A[i]*F[i];
    search(-1,1e13,A2,F,N);
}

Measured memory_bytes: 4992
#include<stdio.h>
int main(void)
{
	int n;
	int i;
	int x,y,h,w,s;
	int sum;
	
	scanf("%d",&n);
	while(n!=0){
		sum=0;
		for(i=0;i<n;i++){
			scanf("%d %d %d %d",&x,&y,&h,&w);
			s=x+y+h;
			if(s<=60 && w<=2){
				sum+=600;
			}
			else if(s<=80 && w<=5){
				sum+=800;
			}
			else if(s<=100 && w<=10){
				sum+=1000;
			}
			else if(s<=120 && w<=15){
				sum+=1200;
			}
			else if(s<=140 && w<=20){
				sum+=1400;
			}
			else if(s<=160 && w<=25){
				sum+=1600;
			}
		}
		printf("%d\n",sum);
		scanf("%d",&n);
	}
	return 0;
}

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

int main(){
  int n,k; cin>>n>>k;
  if(n>=k){
    cout<<0<<endl;
    return 0;
  }
  vector<int> num(k),dif(k-1);
  for(int i=0;i<k;i++){
    cin>>num[i];
  }
  sort(num.begin(),num.end());
  for(int i=0;i<k-1;i++){
    dif[i]=num[i+1]-num[i];
  }
  sort(dif.begin(),dif.end());
  long long ans=0;
  for(int i=0;i<k-n;i++){
    ans+=dif[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    int n,m,a,b,ans=0;
    scanf("%d %d",&n,&m);
    int h[n],x[n];
    for(int i=0; i<n; i++){
        scanf("%d",&h[i]);
        x[i]=0;
    }
    for(int i=0; i<m; i++){
        scanf("%d %d",&a,&b);
        if(h[a-1]<h[b-1])
            x[a-1]=1;
        else if(h[a-1]>h[b-1])
            x[b-1]=1;
        else{
            x[a-1]=1;
            x[b-1]=1;
        }
    }
    for(int i=0; i<n; i++){
        if(x[i]==0)
            ans++;
    }
    printf("%d",ans);
}


Measured memory_bytes: 2508
import java.util.Scanner

val sc = Scanner(System.`in`)

fun main(args:Array<String>){
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val K = sc.nextInt()
    var arr:IntArray = intArrayOf(a,b,c)
   arr.sort()
    for(i in 0 .. K-1){
     arr[2] *= 2
    }
    println(arr[0]+arr[1]+arr[2])
}

Measured memory_bytes: 35916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> field(H);
    rep(i, H){
        cin >> field[i];
    }

    int ans;
    ans = 0;
    rep(hi, H){
        rep(wi, W){
            if(field[hi][wi] == '#') continue;

            queue<i_i> q;
            vector<vector<int>> d(H, vector<int>(W, -1));
            vector<int> hmove = {0,0,1,-1};
            vector<int> wmove = {1,-1,0,0};

            q.push({hi, wi});
            d[hi][wi] = 0;

            while(q.size() > 0){
                int ch, cw;
                ch = q.front().first;
                cw = q.front().second;
                q.pop();
                rep(i, 4){
                    int nh, nw;
                    nh = ch + hmove[i];
                    nw = cw + wmove[i];
                    if(nh >= 0 && nw >= 0 && nh < H && nw < W && field[nh][nw] == '.' && d[nh][nw] == -1){
                        q.push({nh, nw});
                        d[nh][nw] = d[ch][cw] + 1;
                        ans = max(d[nh][nw], ans);
                    }
                }
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}


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

int main(void) {
	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	return 0;
}

Measured memory_bytes: 764
#include"iostream"
#include"cmath"
#include"vector"

using namespace std;

int main(void){
  int N;
  cin>>N;
  vector<int>dp(N+1,N);
  dp[0]=0;
  for(int i=0;i<N;i++){
    for(int j=1;j+i<=N;j*=6){
      dp[i+j]=min(dp[i]+1,dp[i+j]);
    }
    for(int j=1;j+i<=N;j*=9){
      dp[i+j]=min(dp[i]+1,dp[i+j]);
    }
  }
  cout<<dp[N]<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vvi vector<vi>
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
// #define int long long
using namespace std;
using ll = long long;

int main() {
  string s,t;
  cin >> s;
  cin >> t;
  int ans = 0;
  rep(i,s.size()){
    if(s[i] != t[i]){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3820
def comb(n, k):
    return factorial(n) // (factorial(k) * factorial(n-k))
  
if __name__ == '__main__':
    from collections import Counter
    from math import factorial

    N,A,B = [int(i) for i in input().split()]
    V = [int(i) for i in input().split()]

    V.sort(reverse = True)
    max_list = [V[0:A]]
    max = sum(V[0:A]) / A

    for i in range(A+1,B+1):
        a = sum(V[0:i]) / i
        if max <= a:
            max_list.append(V[0:i])
            max = a
    print("{:.6f}".format(max))

    ans = 0
    for x in max_list:
        ans_sub = 1
        try:
            x = Counter(x).most_common()
        except TypeError:
            ans += ans_sub
            continue
        for i in range(len(x)):
            ans_sub *= comb(V.count(x[i][0]),x[i][1])
        ans += ans_sub
    print(int(ans))


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

typedef long long ll;

ll N, M;
const ll MAX_N = 12;
ll Dp[1 << MAX_N];
const ll INF = 1ll << 60;

int main() {
  cin >> N >> M;
  for (ll s = 0; s < (1 << N); ++s) {
    Dp[s] = INF;
  }
  Dp[0] = 0;
  for (ll i = 0; i < M; ++i) {
    ll a, b;
    cin >> a >> b;
    ll x = 0;
    for (ll j = 0; j < b; ++j) {
      ll c;
      cin >> c;
      --c;
      x |= (1 << c);
    }
    for (ll s = 0; s < (1 << N); ++s) {
      Dp[s | x] = min(Dp[s] + a, Dp[s | x]);
    }
  }
  ll res = Dp[(1 << N) - 1];
  cout << (res == INF ? -1 : res) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;cin>>n;
	int arr[n],sum=0;
	for(int i=0;i<n;i++){
		cin>>arr[i];sum+=arr[i];
	}
	int q,temp1,temp2;cin>>q;
	for(int i=0;i<q;i++){
		cin>>temp1>>temp2;
		int ans = sum + (temp2 - arr[temp1-1]);
		cout<<ans<<endl;
	}
	
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<time.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INI(n) scanf("%d",&n)
#define INL(n) scanf("%lld",&n)
#define INF 10000000000
#define mod 1000000007
#define X 100000
#define N 20
#define M 46
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
void Iswap(int *a,int *b){
  int t=*a;
  *a=*b;
  *b=t;
}
void Fswap(double *a,double *b){
  double t=*a;
  *a=*b;
  *b=t;
}
void Lswap(ll *a,ll *b){
  ll t=*a;
  *a=*b;
  *b=t;
}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void nCrReady(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (ll i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(ll n,ll k){return fac[n]*(finv[k]*finv[n-k]%mod)%mod;}
ll modpow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}
int a[200001];
int main(void){
  int n;
  INI(n);
  int x;
  FOR(i,n-1){
    INI(x);
    a[x-1]++;
  }
  FOR(i,n)PRN(a[i]);
  return 0;
}

Measured memory_bytes: 2456
w, h ,n = gets.chomp.split.map(&:to_i)
x1, x2, y1, y2 = 0, w, 0, h

n.times do
    x, y, a = gets.chomp.split.map(&:to_i)
    
    case a
    when 1 then
        x1 = x if x1 < x
    when 2 then
        x2 = x if x2 > x
    when 3 then
        y1 = y if y1 < y
    when 4 then
        y2 = y if y2 > y
    end
end

puts x1 < x2 && y1 < y2 ? (x2 - x1) * (y2 - y1) : 0

Measured memory_bytes: 1788
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    # 全部 A にした時に、差が3の約数なら良さそう
    S=[1 if(s=='A') else 2 for s in input()]
    T=[1 if(s=='A') else 2 for s in input()]

    # cumsum
    m=len(S)
    n=len(T)
    CS=[0]*(m+1)
    for i in range(m):
        CS[i+1]=CS[i]+S[i]

    CT=[0]*(n+1)
    for i in range(n):
        CT[i+1]=CT[i]+T[i]

    # output
    for _ in range(int(input())):
        a,b,c,d=map(int,input().split())
        a-=1; c-=1
        k=abs((CS[b]-CS[a])-(CT[d]-CT[c]))
        print("YES" if(k%3==0) else "NO")
resolve()

Measured memory_bytes: 60912
#include <iostream>

using namespace std;

class Solver {
    public:
        int h;
        int num[10][5];
        int solve() {
            bool has_changed = true;
            int score = 0;
            while (has_changed) {
                has_changed = false;
                for (int y = 0; y < h; ++y) {
                    for (int x = 0; x < 5; ++x) {
                        if (num[y][x] == 0) {
                            continue;
                        }
                        for (int x2 = x + 1; x2 <= 5; ++x2) {
                            if (x2 != 5 && num[y][x2] == num[y][x]) {
                                continue;
                            }
                            if (x2 - x > 2) {
                                has_changed = true;
                                for (int x3 = x; x3 < x2; ++x3) {
                                    score += num[y][x3];
                                    num[y][x3] = 0;
                                }
                            }
                            break;
                        }
                    }
                }
                for (int x = 0; x < 5; ++x) {
                    for (int y = h - 1; y >= 0; --y) {
                        if (num[y][x] > 0) {
                            continue;
                        }
                        for (int y2 = y; y2 >= 0; --y2) {
                            if (num[y2][x] > 0) {
                                num[y][x] = num[y2][x];
                                num[y2][x] = 0;
                                break;
                            }
                        }
                    }
                }
            }
            return score;
        }
};

int main() {
    Solver s;
    while (true) {
        cin >> s.h;
        if (s.h == 0) {
            return 0;
        }
        for (int y = 0; y < s.h; ++y) {
            for (int x = 0; x < 5; ++x) {
                cin >> s.num[y][x];
            }
        }
        cout << s.solve() << endl;
    }
}

Measured memory_bytes: 1160
// https://atcoder.jp/contests/abc128/tasks/abc128_c

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 10;
const int M_MAX = 10;
const int MOD = 2;

int N, M;
int f[M_MAX];
int p[M_MAX];

void solve() {
  int S = 1 << N;
  int ans = 0;
  REP(i, S) {
    bool all = true;
    REP(j, M) {
      if ((__builtin_popcount(i & f[j]) ^ p[j]) & 1) {
        all = false;
        break;
      }
    }
    if (all) ans++;
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &N, &M);
  REP(i, M) {
    f[i] = 0;
    int k;
    scanf("%d", &k);
    REP(j, k) {
      int s;
      scanf("%d", &s);
      f[i] |= 1 << (s - 1);
    }
  }
  REP(i, M) scanf("%d", p + i);
}

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


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int i,j;
  int n,r;
  int p,c;
  int h[50],tmp[50];


  while(1){
      scanf("%d %d",&n,&r);
      if(!n && !r){break;}

      for(i=0;i<n;i++)h[i] = n-i;
 
      for(i=0;i<r;i++){
	scanf("%d %d",&p,&c);
	p--;
	for(j=0;j<c;j++)tmp[j] = h[j+p];

	for(j=p-1;j>=0;j--)h[j+c] = h[j];

	for(j=0;j<c;j++)h[j] = tmp[j];
      }

      printf("%d\n",h[0]);
    }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(){

  int n,rate,over=0,result=0,a[8]={0},i;

  cin>>n;

  for(i=0;i<n;i++){

    cin>>rate;

    if(rate < 400) a[0]++;
    else if(rate < 800) a[1]++;
    else if(rate < 1200) a[2]++;
    else if(rate < 1600) a[3]++;
    else if(rate < 2000) a[4]++;
    else if(rate < 2400) a[5]++;
    else if(rate < 2800) a[6]++;
    else if(rate < 3200) a[7]++;
    else over++;
    
  }

  for(i=0;i<8;i++) if(a[i]>0) result++;

  if(result==0) cout<<"1 ";
  else cout<<result<<" ";

  result += over;

  cout<<result<<endl;

  return 0;

}

Measured memory_bytes: 256
/*input
6
AC
TLE
AC
AC
WA
TLE
*/
#include <bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define rd() abs((int)rng())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int maxn = 2e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	int t;
	cin >> t;
	map<string, int>mp;
	while (t--) {
		string s;
		cin >> s;
		++mp[s];
	}

	for (string s : {"AC", "WA", "TLE", "RE"}) {
		cout << s << " x " << mp[s] << "\n"; 
	}
	return 0;
}

Measured memory_bytes: 3628
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    a = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    print(a + a**2 + a**3)


if __name__ == '__main__':
    solve()


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    ll N, K;
    cin >> N >> K;
    ll A = 0;
    ll B = 0;
    REP(i, N){
        if((i+1)%K==0){
            A++;
        }
        if((i+1)%K==(K/2)){
            B++;
        }
    }
    if (K%2==1){
        cout << A*A*A << endl;
    }else{
        cout << A*A*A + B*B*B << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
a=[]
for i in range(M):
    n,m=map(int,(input().split()))
    a.append([n,m,i])
ans=['0']*M
a.sort()
j=0
for i in range(M):
    if j!=a[i][0]:
        j=a[i][0]
        c=1
    ans[a[i][2]]=str(a[i][0]).zfill(6)+str(c).zfill(6)
    c+=1
for i in range(M):
    print(ans[i])

Measured memory_bytes: 31304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll modd=1e9+7;
//unordered_map<int,int> mapp;
ll n,a,b,ans;
int read() {
	char ch = getchar();
	int x = 0, f = 1;
	while (ch < '0' || ch > '9') f = (ch == '-' ? -1 : 1), ch = getchar();
	while (ch >= '0' && ch <= '9') x = x*10 + ch - 48, ch = getchar();
	return x * f;
}
ll qpow(ll a,ll b){
	ll base=a,ans=1;
	while(b){
		if(b&1) ans*=base,ans%=modd;
	    base*=base,base%=modd,b>>=1; 
	}
	return ans;
}
ll mul(ll st,ll ed){
	ll ans=1;
	for(ll i=st;i<=ed;i++)
	ans*=i,ans%=modd;
	return ans;
}
int main() {
	cin>>n>>a>>b;
	ans=qpow(2,n)-1;
	if(a<=n) ans-=mul(n-a+1,n)*qpow(mul(1,a),modd-2)%modd,ans=(ans+modd)%modd;
	if(b<=n) ans-=mul(n-b+1,n)*qpow(mul(1,b),modd-2)%modd,ans=(ans+modd)%modd;
	cout<<ans; 
	return 0;
}

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

S = input()[::-1]

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for i in S:
    num += int(i) * d
    num %= 2019
    d *= 10
    d %= 2019
    counts[num] += 1

ans = 0
for i in counts:
    ans += i * (i - 1) // 2

print(ans)

Measured memory_bytes: 9240
def getHoursToMeet(distance, v1, v2)
  return distance.to_f / (v1.to_f + v2.to_f)
end

def getSum(l)
  sum = 0
  10.times{|i|
    sum += l[i].to_i
  }
  return sum
end

def getStationNoToMeet(l, v1, v2)
  distanceToMeet = v1.to_f * getHoursToMeet(getSum(l), v1, v2)
  10.times{|i|
    distanceToMeet -= l[i].to_f
    return i + 1 if distanceToMeet <= 0
  }
end

while input = gets
    input = input.chomp.split(",")
    puts getStationNoToMeet(input, input[10], input[11])
end

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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	int N;
	cin >> N;
	vector<P> X(N);
	rep(i,N){
		int x;
		cin >> x;
		X[i]=P(x,i);
	}
	sort(X.begin(),X.end());
	vector<int> B(N);
	rep(i,N/2){
		int n=X[i].second;
		B[n]=X[N/2].first;
	}
	rep(i,N/2){
		int n=X[N/2+i].second;
		B[n]=X[N/2-1].first;
	}
	rep(i,N) cout << B[i] << endl;

	return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n, k, r, s, p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;

  int ans = 0;
  rep(i,k) {
    string tt;
    int it = i;
    while (it < n) {
      tt += t[it];
      it += k;
    }

    // suc = (直前の文字の連続している数)%2
    bool suc = false; 
    // suc && tt[j-1]==tt[j]  -> +point, suc = false;  "rpp"+'p'
    // suc && tt[j-1]!=tt[j]  -> +point, suc = false;  "rpp"+'s'
    // !suc && tt[j-1]==tt[j] -> +0,     suc = true;   "rrp"+'p' "prrr"+'r' "prp"+'p'
    // !suc && tt[j-1]!=tt[j] -> +point, suc = false;  "rrp"+'s' "rrr"+'s' "prp"+'s'

    rep(j,tt.size()) {
      char c = tt[j];
      if (suc) suc = false;
      else {
        if (j && tt[j-1] == tt[j]) {
          suc = true;
          continue;
        }
      }
      if (c == 'r') ans += p;
      if (c == 's') ans += r;
      if (c == 'p') ans += s;
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#define  ll long long
using namespace std;

int n;
ll solve(ll *dp[] , int w[] , ll p[] , int weight, int i)
{
	ll a,b;
	a = b = 0;
	
	
	if(dp[weight][i] > 0)
	return dp[weight][i];
	
	if(i == 0)
	{
		if(weight >= w[0])
		{
			dp[weight][i] = p[0];
		}
		else
		{
			dp[weight][i] = 0;
		}
		return dp[weight][i];
	}
	
	if(weight >= w[i])
	a = p[i] + solve(dp , w , p , weight - w[i] , i - 1);
	
	b = solve(dp , w , p , weight , i - 1);
	
	dp[weight][i] = max(a , b);
	return dp[weight][i];
}

main()
{
	int weight,i,j;
	cin>>n>>weight;
	int w[n];
	ll p[n];
	
	ll *dp[weight+1];
	for(i=0;i<=weight;i++)
	{
		dp[i] = new ll[n+1];
		for(j=0;j<=n;j++)
		{
			dp[i][j] = 0;
		}
		
	}
	for(i=0;i<n;i++)
	{
		cin>>w[i]>>p[i];
	}
	
	cout<<solve(dp,w,p,weight,n-1);
	
}

Measured memory_bytes: 80768