akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

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


int main(){
  ll l,r;
  cin>>l>>r;
  vector<bool> P(100000,true);
  P[0]=P[1]=false;
  for(ll i=2;i*i<100000;i++){
    if(P[i]){
      for(ll t=2;i*t<100000;t++){
	P[i*t]=false;
      }
    }
  }
  vector<ll> count(r-l+1,0);
  vector<ll> N(r-l+1,0);
  for(int i=0;i<N.size();i++){N[i]=i+l;}
  for(ll i=2;i<100000;i++){
    if(P[i]){
      ll s=l/i+(l%i==0?0:1);
      for(;s*i<=r;s++){
	while(N[s*i-l]%i==0){
	  count[s*i-l]++;
	  N[s*i-l]/=i;
	}
      }
    }
  }
  for(int i=0;i<N.size();i++){
    if(N[i]!=1){count[i]++;}
  }
  ll ans=0;
  for(int i=0;i<count.size();i++){
    if(P[count[i]]){ans++;}
  }
  cout<<ans<<endl;
  


  return 0;
}



Measured memory_bytes: 18416
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    vector<int>vv;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        if(!(arr[i] & 1))vv.push_back(arr[i]);
    }
    for(int i=0;i<vv.size();i++)
    {
        if(vv[i]%3==0 or vv[i]%5==0)continue;
        
        else
        {
            cout<<"DENIED";
            return 0;
        }
    }
    cout<<"APPROVED";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,i,j,num=0,ans=0;
  cin>>n;
  vector<ll> a(n);
  for(i=0;i<n;i++){
	cin>>a[i];
  }
  sort(a.begin(),a.end());
  for(i=0;i<n;i++){
	if(a[i]>0){
      num=i;
      break;
    }
    num=n;
  }
  if(num>1){
    if(i%2==1){
  	 for(i=0;i<num-1;i++){
		 a[i]=-a[i];
     }
    }else{
      for(i=0;i<num;i++){
		 a[i]=-a[i];
      }
    }
  }	
  for(i=0;i<n;i++){
    ans+=a[i];
  }
  if(num%2==1 && num!=n){
  ans+=max(2*(-a[num]-a[num-1]),(ll)0);
  }
  cout<<ans<<endl;
}
  

  

Measured memory_bytes: 1152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException{
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader bf = new BufferedReader(is);
		int x = Integer.parseInt(bf.readLine());
		double db = Math.pow(x, 3);
		System.out.println((int)db);
	}
}

Measured memory_bytes: 24244
n = int(input())
S = [0 for x in range(13)]
H = [0 for x in range(13)]
C = [0 for x in range(13)]
D = [0 for x in range(13)]


def printLost(k,K):
  for x in range(13):
    if K[x] == 0:
      print("{} {}".format(k,x+1))


for i in range(n):
  k,l = input().split()
  if k == "S":
    S[int(l) -1] = 1
  if k == "H":
    H[int(l) -1] = 1
  if k == "C":
    C[int(l) -1] = 1
  if k == "D":
    D[int(l) -1] = 1

printLost('S',S)
printLost('H',H)
printLost('C',C)
printLost('D',D)





Measured memory_bytes: 5600
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    int N, M;
    cin >> N >> M;
    map<int, int> preorder;
    map<int, pair<int, int>> order;
    vector<vector<int>> G(N, vector<int>());
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        preorder[b] = i + 1;
        G[a].push_back(b);
    }

    rep(i, N) { sort(all(G[i])); }

    rep(i, N) {
        if (G[i].size() == 0)
            continue;
        rep(j, G[i].size()) { order[preorder[G[i][j]]] = {i + 1, j + 1}; }
    }

    for (auto o : order) {
        printf("%06d", o.second.first);
        printf("%06d", o.second.second);
        printf("\n");
    }
}

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

int main() {
	int n, m; cin >> n >> m;
	int a[200005], b[200005];
	int d[100005], ans[100005];
	G g(n+1);
	queue<pii> q;
	for(int i=0;i<m;i++){
		cin >> a[i] >> b[i];
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
	}
	for(int i=1;i<=n;i++){
		d[i] = -1;
		ans[i] = -1;
	}
	q.push({1,0});
	while(!q.empty()){
		int c = q.front().first;
		d[c] = q.front().second;
		q.pop();
		for(auto x: g[c]){
			if(d[x]!=-1) continue;
			else{
				ans[x] = c;
				d[x] = d[c]+1;
				q.push(make_pair(x, d[x]));
			}
		}
	}
	for(int i=1;i<=n;i++){
		if(d[i]==-1){
			//cout << i << endl;
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	for(int i=2;i<=n;i++){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 12404
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e5+4;
int n,m,cur;
char ss[N];
int main() {
	scanf("%d%d",&n,&m);
	scanf("%s",ss+1);
	for (register int i=1;i<=n;++i) {
		if (ss[i]=='L'&&ss[i-1]=='L'&&i-1) ++cur;
		else if (ss[i]=='R'&&ss[i+1]=='R'&&i<n) ++cur;
	}
	printf("%d\n",min(n-1,cur+(m<<1)));
	return 0;
}

Measured memory_bytes: 384
/*Points to be noted :
1)Don't be afraid to fail.
2)Never give up easily,keep trying.
3)Don't care about other ppl's progress.
4)Spend much time on each problem & keep trying. I WILL DO IT!💯*/

// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//


#include<bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define int long long int
#define ld long double
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define r0 return 0;
#define tc int t;cin>>t;while(t--)
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define md 998244353
#define inf 1000000000000000 //1e15
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd(a,b)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}
int factorial(int n)
{
    int fact=1;
    for(int i=2;i<=n;i++)
    fact=fact*i;
    
    return fact;
}
int ncr(int n,int r)
{
    return factorial(n)/(factorial(r)*factorial(n-r));
}
void c_p_c()
{
    crap;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
signed main()
{
   // c_p_c();
    int a;
    long double b;
    cin>>a>>b;
    long double ans=a*b;
    cout<<long(ans)<<endl;
}


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

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

using namespace std;
typedef int Weight;
const Weight INF = 1000000000;
struct Edge{
  int src, dest; Weight weight;
  bool operator < (const Edge &rhs) const {return weight > rhs.weight;}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int calc(const Matrix &g, const vector<int> &v) {
  int m=v.size();
  if (m <= 1) return 0;
  int sum = 0;
  REP(i,m) {
    int mn = INF;
    REP(j,m) {
      if (i==j) continue;
      mn = min(mn, g[v[i]][v[j]]);
    }
    sum += mn;
  }
  return sum;
}

int func(const Matrix &g, const vector<int> &v) {
  int n=g.size();
  int mxs = calc(g, v);
  REP(i,n){
    if (!v.empty() && i >= v.back()) break;
    bool ok = true;
    REP(j,v.size()) {
      if(g[i][v[j]] == 0) ok = false;
    }
    if (ok) {
      auto cp = v;
      cp.push_back(i);
      mxs = max(mxs, func(g, cp));
    }
  }
  return mxs;
}


int main() {
  int n,m;
  cin>>n>>m;
  Matrix g(n, Array(n, 0));
  REP(i,m){
    int u,v,f;
    cin>>u>>v>>f;
    --u;--v;
    g[u][v] = g[v][u] = f;
  }
  vector<int> v;
  cout << func(g, v) << endl;
  return 0;
}

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

struct node {
	struct node *parent;
	struct node *child[2];
	int key;
};

void Insert(struct node **root, struct node *p){
	struct node *y = NULL;
	struct node *x = *root;
	while(x!=NULL){
		y = x;
		if(p->key<x->key){
			x = x->child[0];
		}else{
			x = x->child[1];
		}
	}
	p->parent = y;

	if(y==NULL){
		*root = p;
	}else if(p->key<y->key){
		y->child[0] = p;
	}else{
		y->child[1] = p;
	}

}
/*
void calcDepth(int num){
	int i;
	for(i=0;i<2;i++){
		if(tree[num].child[i] == -1){
			continue;
		}
		tree[tree[num].child[i]].depth = tree[num].depth + 1;
		calcDepth(tree[num].child[i]);
	}
	return;
}
*/

/*
int calcHeight(int num){
	int i;
	int temp;
	int h = -1;
	if(num==-1){
		return -1;
	}
	for(i=0;i<2;i++){
		temp = calcHeight(tree[num].child[i]);
		h = (h>temp?h:temp);
	}
	tree[num].height = h + 1;
	return tree[num].height;
}
*/

void Preorder(struct node *p){
	printf(" %d",p->key);
	if(p->child[0]==NULL){
		if(p->child[1]==NULL){
			return;
		}else{
			Preorder(p->child[1]);
		}
		return;
	}
	Preorder(p->child[0]);
	if(p->child[1]==NULL){
		return;
	}
	Preorder(p->child[1]);
	return;
}

void Inorder(struct node *p){
	if(p->child[0]==NULL&&p->child[1]==NULL){
		printf(" %d",p->key);
		return;
	}else if(p->child[0]==NULL&&p->child[1]!=NULL){
		printf(" %d",p->key);
		Inorder(p->child[1]);
	}else if(p->child[0]!=NULL&&p->child[1]==NULL){
		Inorder(p->child[0]);
		printf(" %d",p->key);
	}else{
		Inorder(p->child[0]);
		printf(" %d",p->key);
		Inorder(p->child[1]);
	}
	return;
}
/*
void Postorder(struct node *p){
	if(p->child[0]==NULL&&p->child[1]==NULL){
		printf(" %d",p->key);
		return;
	}else if(p->child[0]==NULL&&p->child[1]!=NULL){
		Postorder(p->child[1]);
	}else if(p->child[0]!=NULL&&p->child[1]==NULL){
		Postorder(p->child[0]);
	}else{
		Postorder(p->child[0]);
		Postorder(p->child[1]);
		printf(" %d",p->key);
	}
}
*/

int main(){
	int n;
	struct node *root = NULL;
	struct node *temp;
	int i,j;
	char order[32];
	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%s",order);
		if(strcmp(order,"insert")==0){
			temp = (struct node *)malloc(sizeof(struct node));
			scanf("%d",&temp->key);
			temp->parent = NULL;
			temp->child[0] = NULL;
			temp->child[1] = NULL;
			Insert(&root,temp);
		}else if(strcmp(order,"print")==0){
			Inorder(root);
			printf("\n");
			Preorder(root);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 24036
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
int yaku(int a) {
int cnt = 0;
for (int i = 1; i <= a;i++) {
    if (a%i == 0) cnt++;
}
return cnt;

}

int main() {
int N;
cin >> N;
int ans = 0;
for (int i = 1;i <= N;i +=2) {
    if (yaku(i) == 8) ans++;
}
cout << ans << endl;

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ll a[11];
    ll r, d;
    cin>>r>>d>>a[0];
    for(ll i = 1;i< 11;i++){
        a[i] = a[i-1] * r - d;
        cout<<a[i]<<endl;
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define INF 100000

int main(){
	string S, T;
	cin>>S>>T;
	int count = 0;
	int ans = INF;
	for (int i = 0; i < S.length()-T.length()+1; ++i)
	{
		count = 0;
		for (int j = 0; j < T.length(); ++j)
		{
			if(T[j]!=S[i+j])
				count++;
		}
		ans = min(ans, count);	
	}
	cout<<ans;

	return 0;
}

Measured memory_bytes: 3596
#include <cstdio>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define MIN(x, y) x < y ? x : y
using namespace std;
const int MAXN = 300005;

int n, e[MAXN], ans=1<<30;
char s[MAXN];

int main() {
    scanf("%d", &n), scanf("%s", s);
    REP(i,n) e[i+1] = e[i] + (s[i] == 'E');
    REP(i,n) ans = MIN(ans, i - e[i] + e[n] - e[i+1]);
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long double;
using P = pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

ll dist(P a, P b)
{
    return sqrt(pow(a.first - b.first, 2) + pow(a.second - b.second, 2));
}

int main()
{

    int n;
    cin >> n;
    vector<P> t(n);
    rep(i, n) cin >> t[i].first >> t[i].second;
    int factorial = 1;
    rep(i, n)
    {
        factorial *= (i + 1);
    }

    sort(t.begin(), t.end());
    ll ans = 0;
    do
    {
        P a = t[0];
        ll now = 0;
        for (int i = 1; i < n; ++i)
        {
            now += dist(a, t[i]);
            a = t[i];
        }
        ans += now;
    } while (next_permutation(t.begin(), t.end()));

    cout.precision(12);
    cout << (ans / factorial) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
const int INFTY = (1 << 21); // 2097152
// const ll INFTY = (1LL << 60);
const ll MD = 1000000007LL;
// fprintf(stderr, "%d %lld \n", x, xll);


int N, T;
int A[100000];

int main() {
	cin >> N >> T;
	rep(i, N) cin >> A[i];

	int mn;
	map<int, int> M;
	rep(i, N){
		if(i == 0){
			mn = A[i];
		}
		else{
			int y = A[i] - mn;
			if(y > 0){
				if(M.find(y) == M.end()) M[y] = 0;
				M[y]++;
			}
			mn = min(mn, A[i]);
		}
	}

	int mx = 0;
	for(auto &it: M){
		if(mx == 0) mx = it.first;
		else mx = max(mx, it.first);
	}
	cout << M[mx] << endl;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, A[101010];
//---------------------------------------------------------------------------------------------------
#define yes "Yes"
#define no "No"
string solve() {
	map<int, int> cnt;
	rep(i, 0, N) cnt[A[i]]++;

	if (3 < cnt.size()) return no;

	vector<int> ans;
	vector<pair<int, int>> v;
	fore(p, cnt) v.push_back(p);
	if (cnt.size() == 1) {
		rep(i, 0, N) ans.push_back(A[0]);
	}
	else if (cnt.size() == 2) {
		if (v[0].second < v[1].second) {
			while (0 < v[0].second and 1 < v[1].second) {
				ans.push_back(v[0].first);
				v[0].second--;
				ans.push_back(v[1].first);
				v[1].second--;
				ans.push_back(v[1].first);
				v[1].second--;
			}
			if (v[0].second != 0 or v[1].second != 0) return no;
		}
		else {
			while (1 < v[0].second and 0 < v[1].second) {
				ans.push_back(v[0].first);
				v[0].second--;
				ans.push_back(v[0].first);
				v[0].second--;
				ans.push_back(v[1].first);
				v[1].second--;
			}
			if (v[0].second != 0 or v[1].second != 0) return no;
		}
	}
	else {
		if (v[0].second == v[1].second and v[1].second == v[2].second) {
			rep(i, 0, v[0].second) {
				ans.push_back(v[0].first);
				ans.push_back(v[1].first);
				ans.push_back(v[2].first);
			}
		}
		else return no;
	}

	int ng = 0;
	rep(i, 0, N) {
		int bak = (i - 1 + N) % N;
		int nxt = (i + 1) % N;

		int x = ans[bak] ^ ans[nxt];
		if (x != ans[i]) ng = 1;
	}

	if (ng) return no;
	return yes;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	cout << solve() << endl;
}







Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

int firstDigit(int n) 
{ 
    while (n >= 10)  
        n /= 10; 
      
    return n; 
} 

int main(){
	int n;
	cin >> n;
	map<pair<int,int>, int> c;
	for(int i = 1 ; i <= n ; i++){
		int first_digit = firstDigit(i);
		int last_digit = i % 10 ;
		pair<int, int> p = make_pair(first_digit, last_digit);
		c[p]++;
	}
	int ans = 0;
	for(int i = 1 ; i <= n ; i++){
		int first_digit = firstDigit(i);
		int last_digit = i % 10 ;
		ans += c[{last_digit, first_digit}];
	}
	cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
	ll N;
	cin >> N;

	char* S = new char[N + 1];
	cin >> S;

	char* p = S;
	char* q = S + N - 1;
//	cout << *p << " " << *q << endl;
	ll count = 0;
	while (p < q) {
		while (*p == 'R' && p < q) p++;
		while (*q == 'W' && p < q) q--;
		if (p < q) {
			*p = 'R';
			*q = 'W';
			count++;
		}
	}


	cout << count << endl;
	return(0);
}


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

int main(){
    int k,x,min,max; cin >> k >> x;
    max = x+k-1;
    min = x-k+1;
    for(int i=min; min<=max; ++min){
        cout << min << endl;
    }
}

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

long A, B, C, D;

int main(void) {

    cin >> A >> B >> C >> D;

    while (A > 0 && C > 0) {
        A -= D;
        C -= B;
    }

    if (C <= 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }


    return 0;

}

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

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

    ll n,k,x,y; cin >> n >> k >> x >> y;

    if(n>=k){
        cout << x*k+y*(n-k);
    }
    else{
        cout << x*n;
    }


    return 0;
}

Measured memory_bytes: 256
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
 
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
 
// typedef  long long int ll;
typedef long double   ld;

#define    int                      long long int 
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>
#define    ppl                      pair <long long int , pll>              //pair of ll and pair ll 
#define    sp(x)                    setprecision(x)

ld p[3003],ans=0,dp[3003][3003]; 

int32_t main()
{
    speed upp
    int n;
    cin>>n;
    f(i,1,n)
        cin>>p[i];
    dp[0][0]=1.00;
    f(i,1,n)
    {
        f(j,0,n)
        {
            dp[i][j]+=dp[i-1][j]*(1-p[i]);
            dp[i][j+1]+=dp[i-1][j]*p[i];
        }
    }
    f(i,n/2 +1,n)
        ans+=dp[n][i];
    cout<<fixed<<sp(10)<<ans;
}

Measured memory_bytes: 141056
#include<stdio.h>
int main(void){
    int mun[5],a,i,j,set;
    for(i=0;i<5;i++){
        scanf("%d",&mun[i]);
    }
    for(i=0;i<3;i++){
        for(j=i+1;j<3;j++){
            if(mun[i]>mun[j]){
                a=mun[i];
                mun[i]=mun[j];
                mun[j]=a;
            }
        }
    }
    if(mun[3]<mun[4]){
        set=mun[3]+mun[0]-50;
    }
    else{
        set=mun[4]+mun[0]-50;
    }
    printf("%d\n",set);
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N;
  cin >> N;
  string S;
  cin >> S;

  ll ans = 0;
  for (ll i = 0; i < N - 2; i++)
  {
    if (S.substr(i, 3) == "ABC")
      ans++;
  }
  cout << ans << endl;
}

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

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll kosuu = a + b;
    ll amari = n % kosuu;
    ll waru = n / kosuu;

    ll ans = waru * a;
    if (amari >= a) {
        ans += a;
    }
    else {
        ans += amari;
    }

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


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n;
	scanf("%d", &n);
	vector<LL> as(n + 1);
	vector<pll> ps(n + 1);
	for(int i = 1; i <= n; ++i){
		scanf("%lld", &as[i]);
		ps[i] = pll(as[i], i);
	}
	sort(ALL(ps));

	vector<int> ms(1);
	for(int i = 1; i <= n; ++i){
		if(as[i] > as[ms.back()]){
			ms.push_back(i);
		}
	}

	vector<LL> ans(n + 1);
	int k = n;
	LL cnt = 0;
	for(int i = ms.size() - 2; i >= 0; --i){
		LL sum = cnt * (as[ms[i + 1]] - as[ms[i]]);
		while(ps[k].second != ms[i]){
			sum += ps[k].first - as[ms[i]];
			--k;
			++cnt;
		}
		ans[ms[i + 1]] = sum;
	}

	for(int i = 1; i <= n; ++i){
		printf("%lld\n", ans[i]);
	}
}



}
int main() try{
//	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 4728
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#define int long long
using namespace std;
void file(){
    freopen("read.in","r",stdin);
    freopen("write.out","w",stdout);
}
const int N=500010;
inline int read(){
    int sym=0,res=0;char ch=0;
    while (!isdigit(ch))sym|=(ch=='-'),ch=getchar();
    while (isdigit(ch)) res=(res<<3)+(res<<1)+(ch^48),ch=getchar();
    return sym?-res:res;
}
int n,m;
signed main(){
    n=read();
    if (n==1){
        printf("0");return 0;
    }
    if (n==2){
        printf("1");return 0;
    }
    if (n==3){
        printf("2");return 0;
    }
    for (int i=ceil(sqrt(n));i>=1;i--){
        if (n%i==0){
            printf("%lld",i+n/i-2);return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
H = list(map(int,input().split()))
ans = [1]*N
for i in range(M):
    Ai,Bi = map(int,input().split())  
    Ai -=1
    Bi -=1
    if H[Ai] == H[Bi]:
        ans[Ai]=0
        ans[Bi]=0
    elif H[Ai] > H[Bi]:
        ans[Bi]=0
    elif H[Bi] > H[Ai]:
        ans[Ai]=0
print(sum(ans))


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

int main(){
  ll a,b,n;
  cin >> a >> b >> n;
  int ans=0;
  ll c=min(b,n);
  if(c==b)ans = (a*(c-1))/b;
  else{ans= (a*c)/b;}
  cout << ans << endl;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++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 irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e12;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k;
  cin>>n>>k;
  vector<vll> s(n);
  rep(i,n){
    ll t,d; cin>>t>>d; --t;
    s[t].push_back(d);
  }
  for(auto &v: s){
    sort(v.begin(), v.end(), greater<ll>());
    if(v.empty()) v.push_back(-LINF);
  }
  // 配列の最大値が大きい順にソート
  sort(s.begin(), s.end(), [&](vector<ll> a, vector<ll> b){ return a[0] > b[0];});
  
  // k種類選ぶ
  ll now = 0;
  priority_queue<ll> que;
  rep(i,k){
    now += s[i][0];
    for(int j=1; j<s[i].size(); j++) que.push(s[i][j]);
  }
  for(int i=k; i<n; ++i) rep(j, s[i].size()) que.push(s[i][j]);
  
  ll ans = now + k*k;
  for(ll x = k-1; x >= 1; --x){
    ll v=s[x][0];
    ll w=que.top();
    if(v<w){
      que.pop();
      now+=w;
      que.push(v);
      now-=v;
    }
    ans = max(ans, now + x*x);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 8696
import math

def main():
    N = int(input())
    # x = math.floor(N / 1.08)
    # if x * 1.08 == N:
    #     print(x)
    # else:
    #     print(':(')

    # # if x == y:
    # #     print()

    for i in range(1, N+100):
        cost = math.floor(i * 1.08)
        if cost == N:
            print(i)
            exit()
    print(':(')


if __name__ == "__main__":
    main()

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
ll x;
cin>>x;

for(ll i=-1000;i!=1000;i++){
ll A=pow(i,5);
for(ll j=-1000;j!=1000;j++){
if(A-x==pow(j,5)){
cout<<i<<" "<<j<<endl;
return 0;

}

}
}


  return 0;
}


Measured memory_bytes: 4028
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;import java.util.Objects;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int count = Integer.valueOf(reader.readLine());

        boolean[][] compatible = new boolean[count][count];

        for (int i = 0; i < count; ++i) {
            String[] parts = reader.readLine().split(" ");
            for (int j = 0; j < count; ++j) {
                if (Integer.valueOf(parts[j]) == 1) {
                    compatible[i][j] = true;
                }
            }
        }
        long modulo = 1_000_000_007;

        int combinationCount = 1 << count;
        long[] counts = new long[combinationCount];
        counts[0] = 1;

        Map<Integer, List<Integer>> seq = new HashMap<>();
        for (int len = 0; len <= count; ++len) {
            Map<Integer, List<Integer>> newSeq = new HashMap<>();

            for (int ones = 0; ones <= len; ++ones) {
                ArrayList<Integer> list = new ArrayList<>();
                if (ones == 0) {
                    list.add(0);
                } else {
                    if (ones < len) {
                        for (int s : seq.get(ones)) {
                            list.add(s << 1);
                        }
                    }

                    for (int s : seq.get(ones - 1)) {
                        list.add((s << 1) | 1);
                    }
                }


                newSeq.put(ones, list);
            }

            seq = newSeq;
        }

        for (int i = 0; i < count; ++i) {
            for (int j = 0; j < count; ++j) {
                if (compatible[i][j]) {
                    for (int s : seq.get(i)) {
                        if ((s & (1 << j)) == 0) {
                            int newS = s | (1 << j);
                            counts[newS] += counts[s];
                            counts[newS] %= modulo;
                        }
                    }
                }
            }
        }

        System.out.println(counts[combinationCount - 1]);
    }
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int solve(){
  int n,m;
  cin>>n>>m;
  vector<pll> a(m);
  cin>>a;
  for(auto& ai:a)ai.first--;
  auto chk = [&](int x){
    string s = to_string(x);
    if(s.size()!=n)return false;
    for(auto const& ai:a){
      if(s[ai.first]!=(ai.second+'0'))return false;
    }
    return true;
  };
  for(int ans=0;ans<=1000;++ans){
    if(chk(ans)){
      return ans;
    }
  }
  return -1;
}

int main(){

  cout<<(solve())<<endl;
  return 0;

  int n,m;
  cin>>n>>m;
  vector<pll> a(m);
  cin>>a;

  map<ll,set<ll>> mp;
  for(auto x:a){
    if(mp[x.first].empty()){
      mp[x.first].emplace(x.second);
    }
    else{
      if(mp[x.first].find(x.second)==mp[x.first].end()){
        cout<< -1 <<endl;
        return 0;
      }
    }
  }

  string s;
  rep(i,n)s+='0';
  s[0]=1;
  rep(i,m){
    s[a[i].first-1]=('0'+a[i].second);
  }
  if(s[0]=='0'){
    cout<< -1 <<endl;
    return 0;
  }
  cout<<(s)<<endl;

}

Measured memory_bytes: 256
#include<cstdio>
int N;
bool mp[610][610][2];
int main(){
	scanf("%d",&N);
	for(int t=0;t<2;t++){
		int D;scanf("%d",&D);
		int d=0;
		while(D%4==0)D/=4,d++;
		//printf("d=%d D=%d\n",d,D);
		if(D%4==2){
			for(int x=0;x<N*2;x++)
				for(int y=0;y<N*2;y++)if((x>>d)&1)mp[x][y][t]=1;
		}
		else{
			for(int x=0;x<N*2;x++)
				for(int y=0;y<N*2;y++)if((x>>d)+(y>>d)&1)mp[x][y][t]=1;//,printf("mark %d %d\n",x,y);
		}
	}
	int tot=0;
	for(int i=0;i<N*2&&tot<N*N;i++)
		for(int j=0;j<N*2&&tot<N*N;j++)
			if(!mp[i][j][0]&&!mp[i][j][1])tot++,printf("%d %d\n",i,j); 
}

Measured memory_bytes: 1536
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

int main() {
    int n,m,x ;
    cin >> n >> m >> x ;
    int a[m] ;
    for(int i=0;i<m;i++)cin >> a[i] ;

    int b[n] ;
    for(int i=0;i<n;i++){
      b[i] = 0 ;
    } 
    for(int i=0;i<m;i++) b[a[i]] = 1  ;
  
     int former = 0 ;
     int latter = 0 ;

    for(int i=0;i<n;i++){
        if(i<x){
         former+=b[i] ;
        }else{
         latter+=b[i] ;
        }
    }
    int ans =  min(former,latter) ;
  cout << ans << endl ;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int count[4][3][10];
	int j,i,n,b,f,r,v;
	for(j=0;j<4;j++){
		for(i=0;i<3;i++){
			for(n=0;n<10;n++){
				count[j][i][n]=0;
			}
		}
	}
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
			count[b-1][f-1][r-1]+=v;
	}
	for(j=0;j<4;j++){
		for(i=0;i<3;i++){
			for(n=0;n<10;n++){
				printf(" %d",count[j][i][n]);
			}
			printf("\n");
		}
		if(j<3)printf("####################\n");
	}
return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B;
    cin >> A >> B;
    if (A > B) {
        cout << -1 << endl;
        return 0;
    }
    int x1 = B * 10;
    int x2 = A * 13; // A * 100 / 8
    if (x1 == x2) {
        cout << x1 << endl;
        return 0;
    }
    for (int i = x1; i <= x2; i++) {
        if ((int)(i * 0.08) == A && (int)(i * 0.1) == B) {
            cout <<  i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y){
  int u,v,r;
  u=min(x,y);
  v=max(x,y);
  r=v%u;
  while(r>0){
    v=u;
    u=r;
    r=v%u;
  }
  return u;
}
int main(){
  int n,i,ans;
  cin>>n;
  vector<int> a(n);
  for(i=0;i<n;i++) cin>>a.at(i);
  ans=a.at(0);
  for(i=1;i<n;i++) ans=gcd(ans,a.at(i));
  cout<<ans<<endl;
}

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


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    long long max = -1;
    int     index = 0;
    long long sum = 0;
    scanf("%lld",&K);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    std::vector<long long> A_distance(N);
    scanf("%lld",&A[0]);
    for(int i = 1 ; i < N ; i++){
        scanf("%lld",&A[i]);
        A_distance[i-1] = A[i] - A[i-1];
        if(A_distance[i-1] > max){
            max = A_distance[i-1];
            index = i-1;
        }
        sum += A_distance[i-1];
    }
    A_distance[N-1] = (K-A[N-1]) + A[0];
    if(A_distance[N-1] > max){
        max = A_distance[N-1];
        index = N-1;
    }
    sum += A_distance[N-1];
    
    cout << sum-A_distance[index] << endl;
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  ll x;
  cin >> x;
  ll i = x / 11;
  ll j = (x % 11 + 5) / 6;
  ll ans = 2 * i + j;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double

////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////
string s;int n,m[1100000],dp[1100000][2];
signed main(){
  cin>>s;n = s.length();
  rep(i,n){
    m[i] = (int)(s[i]-'0');
  }
  dp[0][0] = 0;
  dp[0][1] = 1;
  repd(i,1,n+1){
    dp[i][0] = min(dp[i-1][0]+m[i-1], dp[i-1][1]+(10-m[i-1]));
    dp[i][1] = min(dp[i-1][0]+m[i-1]+1, dp[i-1][1]+(10-m[i-1]-1));
  }
  cout << dp[n][0] << endl;
}




Measured memory_bytes: 26372
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector <double> x(N);
	vector <double> y(N);
	for (int ii = 0; ii < N; ++ii){
		cin >> x[ii] >> y[ii];
	}

	vector <int> v;
	for (int ii = 0; ii < N; ++ii){
		v.push_back(ii);
	}

	vector <double> dist;
	do {
		double tmp = 0.0;
		for (int ii = 0; ii < N-1; ++ii){
			tmp += sqrt( (x[v[ii+1]]-x[v[ii]])*(x[v[ii+1]]-x[v[ii]]) + (y[v[ii+1]]-y[v[ii]])*(y[v[ii+1]]-y[v[ii]]) );
		}
		dist.push_back(tmp);
	} while(next_permutation(v.begin(), v.end()));

	double ans = 0.0;
	for (int ii = 0; ii < dist.size(); ++ii){
		ans += dist[ii];
	}

	cout << fixed << setprecision(10) << ans / (double)dist.size() << "\n";


	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main(){
  vector<ull> vc;
  while(1){
    ull x, y;
    cin >> x >> y;
    if ( x == 0 && y == 0 ) break;
    vc.push_back(x); vc.push_back(y);
  }

  for (size_t i = 0; i < vc.size()/2; i ++){
    if (vc[2 * i] > vc[2 * i + 1]){
      ull tmp;
      tmp = vc[2 * i];
      vc[2 * i] = vc[2 * i + 1];
      vc[2 * i + 1] = tmp;
    }
    cout << vc[2 * i] << " " << vc[2 * i + 1] << "\n";
  }
}



Measured memory_bytes: 3120
#pragma once

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ll mod = 1000000007;


struct UnionFind {
public:
	vector <ll> par; // 
	vector <ll> siz; // 

	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}

	ll root(ll x) {
		while (par[x] != x) {
			x = par[x] = par[par[x]];
		}
		return x;
	}

	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool issame(ll x, ll y) {
		return root(x) == root(y);
	}

	ll size(ll x) {
		return siz[root(x)];
	}
};

int main(void)
{
	ll n, m;
	cin >> n >> m;
	vector<t3> vs(m);
	UnionFind uf(n);
	rep(i, m) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		uf.merge(a, b);
	}
	unordered_set<ll> s;
	rep(i, n) {
		s.insert(uf.root(i));
	}
	cout << s.size() << endl;
	return 0;
}


Measured memory_bytes: 8228
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll H,W;cin>>H>>W;
    ll N;cin>>N;
    vector<ll> a(N);
    REP(i,N)cin>>a[i];
    
    ll m[H][W];

    ll idx=0;ll c=0;
    WREP(i,H,j,W){
        m[i][j]=c+1;
        idx++;
        if(idx>=a[c]){c++;idx=0;}
    }

    REP(i,H){
        if(i%2==0){
            REP(j,W){
                cout<<m[i][j]<<(j==W-1?"\n":" ");
            }
        }else{
            RREP(j,W){
                cout<<m[i][j]<<(j==0?"\n":" ");
            }
        }
    }
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	void	 solve() {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		for(long h = 1; h <= 3500; h++) {
			for(long w = 1; w <= 3500; w++) {
				long u = n * h * w;
				long d = 4 * h * w - n * h - n * w;
				if(d != 0 && u % d == 0 && u / d > 0) {
					System.out.println(h + " " + w + " " + (u/d));
					return;
				}
			}
		}
	}
	public static void main(String[] args) throws Exception{
		new Main().solve();
	}
}


Measured memory_bytes: 23892
# -*- coding: utf-8 -*-
a = map(int, raw_input().split())
b = a[0]
c = []
while b <= a[1]:
    one = str(b)
    two = str(one[4])+str(one[3])+str(one[2])+str(one[1])+str(one[0])
    if one == two:
        c.append(one)
    b += 1
print len(c)

Measured memory_bytes: 2568
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;

int main()
{
    int H, N;
    cin >> H >> N;
    int sum = 0, a;
    for(int i=0;i<N;++i){
        cin >> a;
        sum += a;
    }
    if(sum >= H) cout << "Yes";
    else cout << "No";
    cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LENGHTH 100010
typedef struct p{

  char pname[100];
  int runtime;

}process;

process runprocess[LENGHTH];

void enqueue(process, int );
process dequeue();

int head = 0;
int tail = 0;


int main(){

  int sumprocess,rtime,sumruntime = 0;
  int i,j;
  process data;

  scanf("%d%d",&sumprocess,&rtime);

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

    scanf("%s%d",runprocess[i].pname,&runprocess[i].runtime);

  }

  head = 0;
  tail = sumprocess; /*????????°??????*/

  while(head != tail){

    data = dequeue();

    // data.runtime = data.runtime - rtime;                                                                                                                                                                                                                                                                                                                          

    if(data.runtime - rtime > 0){

      enqueue(data,data.runtime - rtime);


      sumruntime = sumruntime + rtime;

    }

    else{

      sumruntime = sumruntime + data.runtime;

      printf("%s %d\n",data.pname,sumruntime);

    }

  }

  return 0;

}


void enqueue(process data, int stime){

  strcpy(runprocess[tail].pname,data.pname);
  runprocess[tail].runtime = stime;

  tail = tail + 1;

  if(tail >= LENGHTH){

    tail = 0;

  }

}

process dequeue(){

  int phead;

  phead = head;

  head = head + 1;

  if(head >= LENGHTH){

    head = 0;

  }

  return runprocess[phead];

}

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

int main() {

  vector <int> sta,ima,mae,ima2;
  int ls[101][101];
  int n;
  
  while(1) {
    
    cin >> n;
    if(n == 0) break;
    sta.resize((1<<n)+1);

    for(int i=1;i<=1<<n;i++) sta[i] = 1000000000;
    
    for(int i=0;i<n;i++)
      for(int j=0;j<n+1;j++)
	cin >> ls[i][j];
    
    int t,c,one;
    ima.resize(n);
    ima2.resize(n);
    sta[0] = 0;
    
    for(int i=1;i<=(1<<n)-1;i++) {
      
      for(int j=0;j<n;j++)ima[j] = ima2[j] = 0;
      c = n-1;
      t = i;
      one = 0;
      while(t != 0) {
	if(t%2  == 1) one++;
	ima[c] = t%2;
	ima2[c] = ima[c];
	t /= 2;
	c--;
      }
      //      for(int j=0;j<n;j++) cout << ima[j];   cout << endl;
      
      for(int j=0;j<n;j++)
	if(ima[j] == 1){
	  ima[j] = 0;
	  t = 0;
	  c = 1;
	  for(int k=n-1;k>=0;k--) t += ima[k]*c, c*=2; //2 to 10 
	  // cout << "t = " <<t << endl; 
	  int minls = ls[j][0];
	  for(int k=1;k<=n;k++) 
	    if(ima[k-1] == 1) 
	      minls = min(minls,ls[j][k]);
	  //cout <<" minls = " <<minls<< endl;
	  ima[j] = 1;  
	  sta[i] = min(sta[i] ,sta[t]+minls);
	}
      
      // cout <<sta[i] << endl;	    
      
      
    }

    cout << sta[(1<<n)-1] << endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 1268