akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

void insertionSort(vector<int> &a, int n)
{

    cout << a[0];
    for (int j = 1; j < n; j++)
    {
        cout << " " << a[j];
    }
    cout << "\n";
    for (int i = 1; i < n; i++)
    {
        int v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v)
        {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        cout << a[0];
        for (int j = 1; j < n; j++)
        {
            cout << " " << a[j];
        }
        cout << "\n";
    }
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &&i : a)
    {
        cin >> i;
    }
    insertionSort(a, n);
}


Measured memory_bytes: 3116
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	long a[]= {scan.nextInt(),scan.nextInt(),scan.nextInt()};
	long ans=0;
	Arrays.sort(a);
	if(a[0]%2==0||a[1]%2==0||a[2]%2==0) {
		ans=0;
	}
	else {
		ans=a[0]*a[1];
	}
	System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  
  if(e-a > k){
  	cout << ":(" << endl;
  }else{
  	cout << "Yay!" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <stack>

using namespace std;

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

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

int main(void){
  LL n, x, k;
  map<int, LL> check;

  cin >> n >> k;
  vector<LL> tel(n, 0);

  rep(i, n) {
    cin >> tel[i];
  }
  
  x = 1;
  repl(i, k) {
    if (i > 0) {
      x = tel[x-1];
    }
    // cout << check.count(x) << endl;
    if (check.count(x)) {
      LL rem = k - check[x];
      LL loop = i - check[x];
      // cout << rem << " " << loop << endl;
      rep(j, rem % loop) {
        x = tel[x-1];
      }
      cout << x << endl;
      return 0;
    }
    check[x] = i;
  }

  x = tel[x-1];
  cout << x << endl;

  return 0;
};

Measured memory_bytes: 14724
/*******************************
Author:Morning_Glory
LANG:C++
Created Time:2019年10月02日 星期三 14时55分48秒
*******************************/
#include <cstdio>
#include <fstream>
using namespace std;
const int maxn = 100005;
const int maxm = 200005;
//{{{cin
struct IO{
	template<typename T>
	IO & operator>>(T&res){
		res=0;
		bool flag=false;
		char ch;
		while((ch=getchar())>'9'||ch<'0')	flag|=ch=='-';
		while(ch>='0'&&ch<='9')	res=(res<<1)+(res<<3)+(ch^'0'),ch=getchar();
		if (flag)	res=~res+1;
		return *this;
	}
}cin;
//}}}
int n,cnt;
int head[maxn],nxt[maxm],to[maxm],w[maxm],col[maxn],dis[maxn];
//{{{add
void add (int u,int v,int val)
{
	nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v,w[cnt]=val;
}
//}}}
//{{{dfs
void dfs (int x,int fa)
{
	if (fa)	col[x]=dis[x]&1;
	else	col[x]=0;
	for (int e=head[x];e;e=nxt[e])
		if (to[e]!=fa)	dis[to[e]]=dis[x]+w[e],dfs(to[e],x);
}
//}}}
int main()
{
	cin>>n;
	for (int i=2;i<=n;++i){
		int u,v,val;
		cin>>u>>v>>val;
		add(u,v,val),add(v,u,val);
	}
	dfs(1,0);
	for (int i=1;i<=n;++i)	printf("%d\n",col[i]);
	return 0;
}

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


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

using namespace std;

int main()
{
	int arr[55],n;
	
	cin >> n;
	
	for(int i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}
	
	int flag = 0, f = 0,p = 0,q = 0;
	
	for(int i = 1; i < n; i++)
	{
		if(arr[i] <= arr[i+1]) continue;
		else
		{
			flag = 1;
			if(f == 0) 
			{
				f = 1;
				p = i;
			}
			else q = i+1;
		}
	}
	if(flag == 0) cout << "YES\n";
	else
	{
		if(q == 0) q = p+1;
		swap(arr[p],arr[q]);
		for(int i = 1; i < n; i++)
		{
			if(arr[i] > arr[i+1])
			{
				cout << "NO\n";
				return 0;
			}
		}
		cout << "YES\n";
	}
	
	return 0;
}


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

int main(void){
    int n,k;
    cin >> n >> k;
    vector<int> height(n);
    for(int i=0;i<n;i++) cin >> height[i];

    ll ans = 1LL<<60;
    for(int i=0;i<1<<n;i++){
        bitset<15> bit(i);
        int num1 = bit.count();
        if(num1!=k) continue;

        vector<int> border(n);
        border[0] = height[0];
        ll cost = 0;
        for(int j=1;j<n;j++){
            if(bit.test(j)){
                if(height[j]<=border[j-1]){
                    border[j] = border[j-1]+1;
                    cost += border[j] - height[j];
                }else{
                    border[j] = height[j];
                }
            }else{
                border[j] = max(border[j-1], height[j]);
            }
        }

        if(ans>cost){
            ans = cost;
            //cout << "bit: " << bit << ", cost: " << cost << endl;
        }

    }

    cout << ans << endl;
}

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

int main() {
 
  int K,X,n;
  cin >>K>>X;
  int a[2*K-2];
  int i;
  a[0] = X-K+1;
  for (int i = 0; i < 2*K-1; i++){
    a[i]=a[0]+i;
     cout << a[i] << endl;
    }
      return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <math.h>
#include <string> 
#include <bits/stdc++.h>
using namespace std;

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    cout << C << " " << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int h, w, a, b;
    cin >> h >> w >> a >> b;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(j < a && i < b){
                cout << 1;
            } else if(j < a && i >= b){
                cout << 0;
            } else if(j >= a && i < b){
                cout << 0;
            } else if(j >= a && i >= b){
                cout << 1;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	Scanner in = new Scanner(System.in);
	int n;
	double[] x, y, z, r;
	double[][] dist;
	double ans;
	boolean[][] visited;
	
	final double INF = 10000;
	
	public void run() {
		while (true) {
			n = in.nextInt();
			if (n == 0) break;
			dist = new double[n][n];
			x = new double[n];
			y = new double[n];
			z = new double[n];
			r = new double[n];
			visited = new boolean[n][n];
			
			for (int i = 0; i < visited.length; i++) {
				Arrays.fill(visited[i], false);				
			}
			
			for (int i = 0; i < x.length; i++) {
				x[i] = in.nextDouble();
				y[i] = in.nextDouble();
				z[i] = in.nextDouble();
				r[i] = in.nextDouble();
			}
			
			for (int i = 0; i < dist.length; i++) {
				for (int j = 0; j < dist[i].length; j++) {
					dist[i][j] = getDistance(i, j);
				}
			}
			
			int cnt = 0;
			ans = 0;
			for (int i = 0; i < n * n; i++) {
				double min = INF;
				int x = 0, y = 0;
				for (int j = 0; j < n; j++) {
					for (int k = 0; k < n; k++) {
						if (visited[j][k]) continue;
						if (min > dist[j][k]) {
							y = j; x = k;
							min = dist[j][k];
						}
					}
				}

				visited[x][y] = true; visited[y][x] = true;
				if (isCircuit(x, y, x)) {
					visited[x][y] = false; visited[y][x] = false;
					dist[y][x] = INF;
					continue;
				} else {
					ans += min; cnt++;
					if (cnt == n - 1) break;
				}
			}
			
			System.out.printf("%.3f\n", ans);
		}
	}
	
	boolean isCircuit(int x, int last, int start) {
		if (last == start) return true;
		
		if (visited[last][x]) {
			for (int i = 0; i < visited[last].length; i++) {
				if (visited[last][i] && i != x && isCircuit(last, i, start)) return true;
			}
		}
		
		return false;
	}
	
	double getDistance(int i, int j) {
		if (i == j) return INF;
		
		double x2 = (x[i] - x[j]) * (x[i] - x[j]);
		double y2 = (y[i] - y[j]) * (y[i] - y[j]);
		double z2 = (z[i] - z[j]) * (z[i] - z[j]);
		
		double distance = Math.sqrt(x2 + y2 + z2) - r[i] - r[j];
		
		return (distance > 0) ? distance : 0;
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

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

int main()
{
    int N;
    cin >> N;
    int L[N],max=0,sum=0;
    for(int i=0;i<N;i++){
        cin >> L[i];
        sum+=L[i];
        if(max < L[i]){
            max = L[i];
        }
    }
    if(sum-max > max) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T>
T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T>
T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T>
bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    map<ll, int, greater<ll>> m;
    REP(i, N) {
        ll A;
        cin >> A;
        m[A]++;
    }
    int cnt = 0;
    ll res[3] = {};
    for (auto &p : m) {
        if (cnt >= 2) {
            break;
        }
        if (p.second >= 4) {
            res[cnt] = p.first;
            res[cnt + 1] = p.first;
            cnt += 2;
        } else if (p.second >= 2) {
            res[cnt] = p.first;
            cnt++;
        }
    }
    cout << res[0] * res[1] << endl;
    return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;


long long int dp[3010][3010];
char s[3010], t[3010];

long long int q(int i, int j, int k) {
    if (dp[i][j] != -1) return dp[i][j];
    else if (i == 0 || j == 0) dp[i][j] = 0;
    else if(s[i-1] == t[j-1]) {
        dp[i][j] = q(i-1, j-1, k) + 1;
    }
    else dp[i][j] = max(q(i-1, j, k), q(i, j-1, k));

    return dp[i][j];
}

void print_lcs(int i, int j){
  if (i == 0 || j == 0) return;
  else if (dp[i][j-1] == dp[i][j]) print_lcs(i, j-1);
  else if (dp[i-1][j] == dp[i][j]) print_lcs(i-1, j);
  else if (dp[i][j] == dp[i-1][j-1]+1) {
    print_lcs(i-1, j-1);
    cout << s[i-1];
  }
  return;
}

int main() {
    int i, j, s_size, t_size;

    s_size = 0;
    t_size = 0;

    cin >> s >> t;

    for (i = 0; i < 3010; i++) {
        if (s[i] != '\0') s_size++;
        if (t[i] != '\0') t_size++;
        if (s[i] == '\0' && t[i] == '\0') break;
    }

    for (i = 0; i <= s_size; i++) {
        for (j = 0; j <= t_size; j++) {
            dp[i][j] = -1;
        }
    }
    int x;
    x = q(s_size, t_size, 0);

    print_lcs(s_size, t_size);
    cout << endl;
}

Measured memory_bytes: 71040
#include <bits/stdc++.h>
using namespace std;
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;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-10;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = complex<double>;
using Data = pair<double, int>;
struct Circle {
    P p;
    double r;
    Circle() = default;
    Circle(P _p, double _r) : p(_p), r(_r) {}
};
struct edge {
    int to;
    double cost;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    int n;
    cin >> n;
    vector<Circle> v(n + 2);
    v[0] = Circle(P(xs, ys), 0);
    v[n + 1] = Circle(P(xt, yt), 0);
    for(int i = 1; i <= n; i++) {
        double x, y, r;
        cin >> x >> y >> r;
        v[i] = Circle(P(x, y), r);
    }
    auto calcCost = [&](Circle c1, Circle c2) {
        return max(abs(c1.p - c2.p) - c1.r - c2.r, 0.0);
    };
    vector<vector<edge>> g(n + 2);
    for(int i = 0; i < n + 2; i++) {
        for(int j = 0; j < n + 2; j++) {
            if(i != j) {
                g[i].emplace_back(edge{j, calcCost(v[i], v[j])});
            }
        }
    }
    vector<double> d(n + 2, LLINF);
    priority_queue<Data, vector<Data>, greater<Data>> que;
    d[0] = 0;
    que.push(Data(0, 0));
    while(que.size()) {
        auto now = que.top();
        que.pop();
        double nd = now.first;
        int nv = now.second;
        if(nd > d[nv] + EPS) {
            continue;
        }
        for(const auto &e : g[nv]) {
            if(d[e.to] > nd + e.cost + EPS) {
                d[e.to] = nd + e.cost;
                que.push(Data(d[e.to], e.to));
            }
        }
    }
    cout << fixed << setprecision(15);
    cout << d[n + 1] << endl;
}

Measured memory_bytes: 22012
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

string s;

int main(){
	cin>>s;
	int t=0;
	for(auto i:s) t+=i-'0';
	cout<<(t%9==0?"Yes":"No")<<endl;
}

Measured memory_bytes: 3720
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	long as[] = new long[n];
      	long md = 1000000007;
      	long sum = 0;
      	long st = 0;
      
      	for(int i = 0;i < n;i++){
          as[i] = sc.nextLong();
          st += as[i];
          st %= md;
        }
      	for(int i = 0;i < n-1;i++){
          st -= as[i];
          if(st < 0) st += md;
          sum += as[i] * st;
          sum %= md;
        }
      
      	System.out.println(sum);
	}
}


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

using namespace std;

int main()
{
    int n;
    int s;
    int damy;
    vector<int> a;

    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> s;
        a.push_back(s);
    }

    for(int j = 1; j < n; j++)
    {
        cout << a[n-j] << " ";
    }
    cout << a[0] << endl;
} 

Measured memory_bytes: 1216
/**                                                     **\
 *    created by:   Divianshu Bansal                     *
 *    e-mail id:    god_coder@icloud.com                 *
*                                                        */

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>


using namespace std;
using namespace __gnu_pbds;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>new_data_set;
#define MOD 1000000007
#define int long long
#define BIG 998244353
#define pf push_front
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589


int power(int x, int y) {
    int r = 1, z = x;
    while (y) {
        if (y & 1)r *= z;
        z *= z; y = y >> 1;
    }
    return r;
}
int powerm(int x, int y, int p) {
    int r = 1;
    while (y) {
        if (y & 1)r = (r * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return r % p;
}
int modinv(int x, int m) {
    return powerm(x, m - 2, m);
}
int logarithm(int a, int b) {
    int x = 0;
    while (a > 1) {
        x++;
        a /= b;
    }
    return x;
}
int max3(int a, int b, int c) {
    return max(a, max(b, c));
}
int min3(int a, int b, int c) {
    return min(a, min(b, c));
}
int32_t main() {
    fast;
    int n;
    cin >> n;
    cout << (n + n * n + n * n * n);
    return 0;
}

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

#define ll                      long long
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define eb                      emplace_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define umap                    unordered_map
#define all(x)                  x.begin(),x.end()
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(int i=0; i<n;++i)
#define fr1(i, n)               for(int i=1; i<=n; ++i)
#define rfr(i, n)			    for(int i=n-1; i>=0; --i)
#define precise(x)              cout<<fixed<<setprecision(x)
#define wh						while
#define mp						make_pair
#define le						length()
#define M						1000000007


void solve()
{
	float ans=6.28318530717958623200;
int r;
cin>>r;
precise(6)<<(float)ans*r<<endl;

}


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

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

using namespace std;
typedef long long ll;

const ll mod = 1e9 + 7;

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> list(N+1,true);
    rep (i,M){
        int tmp;
        cin >> tmp;
        list[tmp] = false;
    }
    vector<ll> dp(N+1);
    dp[0] = 1;
    for (int now = 0; now < N; now++){
        for (int next = now + 1;next <= min(N,now+2); next++){
            if(list[next]){
                dp[next] += dp[now];
                dp[next] %= mod;
            }
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 4252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; 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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll N;
    cin >> N;
    vector<ll> X;
    for (ll i= 0;i<N;i++) {
        ll a;
        cin >> a;
        X.push_back(a);
    }
    vector<ll> A;
    A = X;
    sort(X.begin(),X.end());
    ll left = X.at((N-1)/2);
    ll right = X.at((N+1)/2);
    for (ll i = 0;i<N;i++) {
        if (A.at(i)<right) cout << right << endl;
        else cout << left << endl;
    }

}

Measured memory_bytes: 5488
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();

		System.out.print(s[0]);
		System.out.print(s[1]);
		System.out.print(s[2]);
		System.out.print(s[3]);
		System.out.print(" ");
		System.out.print(s[4]);
		System.out.print(s[5]);
		System.out.print(s[6]);
		System.out.print(s[7]);
		System.out.print(s[8]);
		System.out.print(s[9]);
		System.out.print(s[10]);
		System.out.print(s[11]);


		System.out.println("");
		sc.close();
	}
}


Measured memory_bytes: 10064
#include<bits/stdc++.h>
#define   ll            long long int
#define   endl          "\n"
#define   vi            vector<int>
#define   vll           vector<ll>
#define   pb            push_back
#define   all(p)        p.begin(),p.end()
#define   F             first
#define   S             second
#define   mp            make_pair
#define   MOD           1000000007
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    int t=1;
    while(t--){
       ll c_sum=0,sum=0,x=0,y;
       int n,a;
       cin>>n;
       vi v;

       for(int i=0;i<n;i++){
         cin>>a;
         v.pb(a);
         c_sum+=a;
         c_sum%=MOD;
       }

       for(int i=0;i<v.size();i++){
          c_sum-=v[i];
          if (c_sum < 0) c_sum += MOD;
          sum+=c_sum*v[i];
          sum%=MOD;
       }

       cout<<sum<<endl;
    }


return 0;
}





Measured memory_bytes: 4320
n,w = map(int,input().split())

#d[i][j]:i→jへの距離
d = [[float("inf")]*n for i in range(n)]
for i in range(w):
   x,y,z = map(int,input().split())
   d[x][y] = z 

dp = [[-1] * n for i in range(1<<n)]

#訪れた集合がs、今いる点がvの時０に戻る最短経路
def rec(s,v,dp):
    if dp[s][v] >= 0:
        return dp[s][v]
        
    if s == (1<<n)-1 and v == 0:
        #全ての頂点を訪れた(s = 11...11 and v = 0)
        dp[s][v] = 0
        return 0
    
    res = float("inf")
    for u in range(n):
        if (s>>u&1) == 0:
            #uに訪れていない時(uの箇所が0の時),次はuとすると
#            print("s:",bin(s),"u:",u,"v:",v,"sp:",bin(s|(1<<u)),d[v][u])
            res = min(res,rec(s|(1<<u),u,dp)+d[v][u])
            
    dp[s][v] = res
    return res

rec1=rec(0,0,dp)
if rec1==float("inf"):
    print(-1)
else:
    print(rec1)



Measured memory_bytes: 18784
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        var hw = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        bool judge = true;
        var list = new List<string>();
        list.Add("##" + string.Join("", Enumerable.Repeat('.', hw[1])));
        for (int i = 0; i < hw[0]; i++) list.Add("." + Console.ReadLine() + ".");
        list.Add(string.Join("", Enumerable.Repeat('.', hw[1])) + "##");
        for (int i = 1; i < list.Count() - 1; i++)
        {
            for (int j = 1; j < list[0].Length - 1; j++)
            {
                if (list[i][j] == '#' && (list[i - 1][j] == list[i][j - 1] || list[i + 1][j] == list[i][j + 1])) judge = false;
            }
        }
        Console.WriteLine(judge ? "Possible" : "Impossible");
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

class UnionFind{
  int n;
  vector<int> data;
public:
  UnionFind(int _n):n(_n),data(_n,-1){}
  bool link(int a, int b){ //if new link, then true.
    int ra=find_root(a);
    int rb=find_root(b);
    if(ra!=rb){
      if(data[rb]<data[ra]) swap(ra,rb);
      data[ra]+=data[rb];
      data[rb]=ra;
    }
    return (ra!=rb);
  }
  bool check(int a, int b){ //if same set, then true.
    return (find_root(a)==find_root(b));
  }
  int find_root(int a){
    return ((data[a]<0)?a:(data[a]=find_root(data[a])));
  }
};


int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> v;
  UnionFind uf(N);
  rep(i,M){
    int x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    uf.link(x,y);
  }
  map<int,int> m;
  rep(i,N){
    m[uf.find_root(i)] = 1;
  }

  cout << m.size() << endl;
  
  return 0;
}



Measured memory_bytes: 5376
using System;
using System.Linq;

namespace ABC175
{
    class Program
    {
        static void Main(string[] args)
        {
            c();
        }

        public static void c()
        {
            //1000000000000000
            long[] xkd = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long x = Math.Abs(xkd[0]);
            long k = xkd[1];
            long d = xkd[2];
            /*if(x == 0)
            {
                if(k%2 == 0)
                { Console.WriteLine(0); }
                else
                { Console.WriteLine(d); }
                return;
            }*/
            long ans = 0;
            if (x / d > k)
            {
                ans = x - d * k;
            }
            else
            {
                long a = x / d;
                k -= a;
                x -= a * d;
                if (k % 2 == 1)
                {
                    x = Math.Abs(x - d);
                }
                ans = x;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28164
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); }
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

const int N = 17;
int a[N][N], n;
struct bm {
  int v; bm(int val=0) : v(val) {}
  bool operator[](int i) const { return v & 1 << i; }
  bm set(int i) const { return bm(v | 1 << i); }
  bm invert() const { return bm(v ^ -1); }
};
#define for_submasks(s, m) for (int s=m, l=1<<__builtin_popcount(m); l--; s=(s-1)&m)

ll dp[1 << N];
ll s[1<<N];

ll score(bm mask) {
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      if (mask[i] && mask[j]) {
        ans += a[i][j];
      }
    }
  }
  return ans;
}
void pre() {
  for (int i = 0; i < (1 << n); ++i) {
    s[i] = score(i);
  }
}

int main() { // Emily <3
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> a[i][j];
    }
  }
  pre();
  memset(dp, -INF, sizeof dp);
  dp[0] = 0;
  for (int mask = 0; mask < (1<<n); ++mask) {
    for_submasks(sm, mask) {
      if (sm == mask) continue;
      dp[mask] = max(dp[mask], dp[sm] + s[mask ^ sm]);
    }
  }
  cout << dp[(1 << n)-1] << nl;

  return 0;
}



Measured memory_bytes: 1920
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

template<class Abel> struct UnionFind {
  vector<int> par;
  vector<int> rank;
  vector<Abel> diff_weight;
  
  UnionFind(int n = 1, Abel SUM_UNITY = 0) {
    init(n, SUM_UNITY);
  }
  
  void init(int n = 1, Abel SUM_UNITY = 0) {
    par.resize(n); rank.resize(n); diff_weight.resize(n);
    for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
  }
  
  int root(int x) {
    if (par[x] == x) {
      return x;
    }
    else {
      int r = root(par[x]);
      diff_weight[x] += diff_weight[par[x]];
      return par[x] = r;
    }
  }
  
  Abel weight(int x) {
    root(x);
    return diff_weight[x];
  }
  
  bool issame(int x, int y) {
    return root(x) == root(y);
  }
  
  bool merge(int x, int y, Abel w) {
    w += weight(x); w -= weight(y);
    x = root(x); y = root(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) swap(x, y), w = -w;
    if (rank[x] == rank[y]) ++rank[x];
    par[y] = x;
    diff_weight[y] = w;
    return true;
  }
  
  Abel diff(int x, int y) {
    return weight(y) - weight(x);
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  UnionFind<int> uf(N);
  for (int i = 0; i < M; ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    --l, --r;
    if (uf.issame(l, r)) {
      int diff = uf.diff(l, r);
      if (diff != d) {
        cout << "No" << endl;
        return 0;
      }
    }
    else {
      uf.merge(l, r, d);
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 1408
using System;
     
    namespace C
    {
        class Program
        {
            static int[] ToIntAry(string[]str)
            {
                int len = str.Length;
                int[] intary = new int[len];
                for(int i = 0; i < len;i++)
                {
                    intary[i] = int.Parse(str[i]);
                }
                return intary;
            }
            static void Main(string[] args)
            {
                int[] NM = ToIntAry(Console.ReadLine().Split(' '));
                int n = NM[0], m = NM[1];
                int[] input = ToIntAry(Console.ReadLine().Split(' '));
                int[] Hs = new int[n+1];
                input.CopyTo(Hs,1);
                int[] Score = new int[n+1];
                Score[0] = 1;
                for(int i = 1; i <= n;i++)
                {
                    Score[i] = 0;
                }
                int Count = 0;
                int a,b;
                for(int i = 0;i < m;i++)
                {
                    input = ToIntAry(Console.ReadLine().Split(' '));
                    a = input[0];
                    b = input[1];
                    
                    Score[a] += Convert.ToInt32(Hs[a] <= Hs[b]);
                    Score[b] += Convert.ToInt32(Hs[a] >= Hs[b]);
                }
     
                foreach(int s in Score)
                {
                    if (s == 0)
                    {
                        
                        Count++;
                    }
                }
                Console.WriteLine(Count);
            }
        }
    }

Measured memory_bytes: 48676
let n, h, w = stdin.ReadLine().Split() |> fun x -> int x.[0], int64 x.[1], int64 x.[2]
[for _ in 1..n -> stdin.ReadLine().Split() |> fun x -> int64 x.[0], int64 x.[1]] |> List.map (fun (a, b) -> min (a / h) (b / w)) |> List.sum |> printfn "%d"

Measured memory_bytes: 14172
from copy import deepcopy


def solve(N, abc):
    dp = [[0, 0, 0] for i in range(N+1)]

    for i in range(1, N+1):
        for j in range(3):
            tmp = deepcopy(dp[i-1])
            tmp.pop(j)
            dp[i][j] = max(tmp) + abc[i-1][j]

    return(max(dp[N]))


if __name__ == "__main__":
    N = int(input())
    abc = [list(map(int, input().split())) for _ in range(N)]
    print(solve(N, abc))


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

int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  int p;
  rep(i, x) p += a;
  rep(i, y) p += b;

  ll ans = p;
  rep(i, max(x, y)){
    p += c * 2;
    if (i < x) p -= a;
    if (i < y) p -= b;
    if (ans > p) ans = p;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <queue>
#include <stack>
#define lson rt<<1
#define rson rt<<1|1
using namespace std;
typedef long long ll;
typedef pair<int, int>  P;
typedef pair<int, P>  PP;
const int maxn=2e5+10;

int main()
{
    ll m,n,ans=0;
    cin>>m>>n;
    if(n==1||m==1)
        ans=1;
    else
        ans=(m*n+1)/2;
    cout<<ans;
}



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

void chmin(int& a, int b) {
  if (a > b) a = b;
}
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  vector<int> B(N+1, 0), W(N+2, 0);
  int Bcount = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == '#') Bcount++;
    B[i+1] = Bcount;
  }
  

  
  int Wcount = 0;
  for (int i = N-1; i >= 0; i--) {
    if (S[i] == '.') Wcount++;
    W[i+1] = Wcount;
  } 
  

  int ans = 200000;
  for (int i = 0; i <= N; i++) {
    chmin(ans, B[i]+W[i+1]);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 2180
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define MAXN ((int)1e6+5)
#define MOD ((int)1e9 + 7) 
#define ll long long
#define _ << " " <<
#define TRACE(x) cout << #x << " = " << x << endl;
#define pb push_back
#define MP make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vii vector<pi>
#define all(x) x.begin(), x.end()

int n,W;
ll w[MAXN],c[MAXN];
ll dp[MAXN];
ll valmax;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	clock_t tStart = clock();

	cin >> n >> W;

	for (int i = 0; i < n; ++i)
	{
		cin >> w[i] >> c[i];
		valmax += c[i]; 
	}	
	for (int i = 1; i <= valmax; ++i)
		dp[i] = LLONG_MAX;

	// TRACE(sum);


	for (int i = 0; i < n; ++i)
	{
		for (int j = valmax - c[i]; j >= 0; --j)
		{
			if(dp[j] != LLONG_MAX || !j)
				dp[j + c[i]] = min(dp[j + c[i]] , dp[j] + w[i]);
		}
	}


	// TRACE(W);
	for (int i = valmax; i >= 0; --i)
	{
		if(dp[i] <= W)
		{	
			cout << i << endl;
			break;
		}
	}

	// printf("Time taken: %.6fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
	return 0;
}


Measured memory_bytes: 5120
#include <stdio.h>

int main(void){
	int in;
	
	do{
		scanf("%d",&in);
	}while(in < 10||in > 99);
	if((in % 10) == 9||(in / 10) == 9)
	printf("Yes");
	else
	printf("No");
	
	
	
	return 0;}


Measured memory_bytes: 128
#include <stdio.h>

int main(void) {

  char chara;

  scanf("%c", &chara);

  if((chara >= 'a') && (chara <= 'z')) {
    printf("a \n");
  }

  if((chara >= 'A') && (chara <= 'Z')) {
    printf("A \n");
  }

  return 0;
}


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

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

bool isKaibun(string s)
{
    bool flag = true;
    for (int i = 0; i < s.size() / 2; i++)
    {
        flag &= (s[i] == s[s.size() - i - 1]);
    }
    return flag;
}

int main()
{
    string s;
    cin >> s;
    bool flag0 = isKaibun(s);
    bool flag1 = isKaibun(s.substr(0, s.size() / 2));
    bool flag2 = isKaibun(s.substr(s.size() / 2 + 1, s.size()));
    cout << (flag0 && flag1 && flag2 ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ans,n,m,c;
int a[100][100],b[100];
int main()
{
	cin>>n>>m>>c;
	for (int i=0;i<m;i++)
	  cin>>b[i];
	for (int i=0;i<n;i++)
	  for (int j=0;j<m;j++)
	    cin>>a[i][j];
	for (int i=0;i<n;i++)
	{
	  int r=c;
	  for (int j=0;j<m;j++)
	    r+=a[i][j]*b[j];
	  ans+=(r>0);
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  int i;
  for(i=2;i<=n;i++) cin >> a[i];
  vector<int> b(n+1,0);
  for(i=2;i<=n;i++){
    b[a[i]]++;
  }
  for(i=1;i<=n;i++){
    cout << b[i] << "\n";
  }
  return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long 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 (b<a) {a=b; return 1;} return 0;}

const ll INF = ll(1e18) + 1;

int n;
ll k;
vll a;

bool func(ll x) {
    ll tot = 0;
    rep(i, n) {
        if (a[i] < 0) {
            int ng = -1, ok = n;
            while (ok - ng > 1) {
                int mid = (ok + ng) / 2;
                if (a[i] * a[mid] < x) ok = mid;
                else ng = mid;
            }
            tot += n - ok;
        } else {
            int ok = -1, ng = n;
            while (ng - ok > 1) {
                int mid = (ok + ng) / 2;
                if (a[i] * a[mid] < x) ok = mid;
                else ng = mid;
            }
            tot += ng;
        }
        if (a[i] * a[i] < x) tot--; 
    }
    tot /= 2;
    return tot < k;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n >> k;
    a.resize(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    ll ok = -INF, ng = INF;
    while (ng - ok > 1) {
        ll mid = (ok + ng) / 2;
        if (func(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << endl;
}

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

using namespace std;
const int N=1e5+100;
const int mod=1e9+7;
typedef long long ll;
ll dp[20][N];
int main()
{
   int n;cin>>n;
   int ans=0;
   int minn=n+1;
   int x;
   for(int i=1;i<=n;i++){
     scanf("%d",&x);
     if(minn>=x) ans++,minn=x;
   }
   cout<<ans;
    return 0;
}


Measured memory_bytes: 256
/*
 * ARC084C.cpp
 *
 *  Created on: Jun 1, 2018
 *      Author: 13743
 */
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

int a[100000];
int b[100000];
int c[100000];

lng bb[100001];

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

	int N;
	cin >> N;
	REP(i, N) cin >> a[i];
	REP(i, N) cin >> b[i];
	REP(i, N) cin >> c[i];

	sort(b, b+N);
	sort(c, c+N);
	REP(i, N) {
		bb[i] = N - (upper_bound(c, c+N, b[i]) - c);
	}
	//bb[N] = 0;
	FORD(i, N-1, 0) {
		bb[i] += bb[i+1];
	}

	lng ans = 0;
	REP(i, N) {
		ans += bb[upper_bound(b, b+N, a[i]) - b];
	}

	cout << ans << endl;
}






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

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

  unsigned long power = 1;

  rep(i, N) {
    power = (   ((unsigned long)(i + 1) * power) % (unsigned long)(pow(10, 9) + 7)    );
  }

  cout << power << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string N;
    cin >> N;

    //小さい位から考える
    reverse(ALL(N));
    //最も大きい位に余裕を持たせる
    N += '0';

    int l = N.size();
    vvi dp(l+1, vi(2, 1e10));
    dp[0][0] = 0;

    rep(i, l) {
        rep(j, 2) {
            int D = N[i]-'0' + j; //支払う場合の枚数(繰り上がっている場合は、１枚増える)

            //D枚を支払う場合（繰り上がりはなくなる）
            if(D < 10) dp[i+1][0] = min(dp[i+1][0], dp[i][j]+D);

            //D枚を支払わず、おつりを貰う場合（繰り上がりが発生/維持される）
            if(D > 0) dp[i+1][1] = min(dp[i+1][1], dp[i][j]+(10-D));
        }
    }

    cout << dp[l][0] << endl;
    
    return 0;
}

Measured memory_bytes: 55940
#include "bits/stdc++.h"

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int main()
{
	int n;
	cin >> n;
	VI a(n);
	IN(n, a);

	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			ans += a[i] * a[j];
		}
	}
	cout << ans << endl;
}

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

int main()
{
  ll a; cin >> a;
  ll b; cin >> b;
  ll c; cin >> c;
  ll k; cin >> k;

  if (k <= a) cout << k << endl;
  else if (k <= a+b) cout << a << endl;
  else cout << a-(k-a-b) << endl;

  return 0;
}


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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e16;
const int N = 3e3 + 5;

LL a[ N ];
LL dp[ N ][ N ];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif // LOCAL
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];

  for (int i = 1; i <= n; i++) {
    for (int j = i; j >= 1; j--) {
      if (i == j) {
        dp[i][j] = a[i];
      }
      else {
        dp[i][j] = max(a[i] - dp[i - 1][j], a[j] - dp[i][j + 1]);
      }
    }
  }
  cout << dp[n][1] << endl;
  return 0;
}


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

// D - String Formation
int main() {
    string S;
    cin >> S;
    list<char> result;
    for (int i = 0; i < S.size(); i++) {
        result.push_back(S[i]);
    }

    int Q;
    cin >> Q;

    bool isReverse = false;
    bool isFrontAdd = false;
    int T, F;
    char C;
    for (int i = 0; i < Q; i++) {
        cin >> T;
        if (T == 1) {
            isReverse = !isReverse;
        } else {
            cin >> F;
            cin >> C;
            if (F == 1) {
                isFrontAdd = !isReverse;
            } else {
                isFrontAdd = isReverse;
            }
            if (isFrontAdd) {
                result.push_front(C);
            } else {
                result.push_back(C);
            }
        }
    }

    while (!result.empty()) {
        if (isReverse) {
            cout << result.back();
            result.pop_back();
        } else {
            cout << result.front();
            result.pop_front();
        }
    }
}


Measured memory_bytes: 13064
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  int n,d,x,ans=0;
  int a[100]={};

  cin >>n;
  cin>>d>>x;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  ans+=n;
  for(int i=0;i<n;i++){
    for(int j=1;j<100;j++){
      if(j*a[i]+1<=d){
        ans++;
      }else{
        break;
      }
    }
  }
  ans+=x;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ull unsigned long long
#define db double
#define vi vector<ll>
#define vvi vector<vector<int> >
#define vvii vector<vector<pii> >
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl "\n"
#define pii pair<ll,ll>
#define piii pair<ll,pair<ll,ll> >
#define mem(a,b) memset(a , b , sizeof a ) ; 
#define pb push_back
#define pf push_front
#define F first 
#define S second 
#define mp make_pair
#define all(v) v.begin(),v.end()

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}



#define deb1(a) cout<<#a<<"=*"<<a<<endl;
#define deb2(a) cout<<#a<<"=@"<<a<<endl;
#define deb3(a) cout<<#a<<"=#"<<a<<endl;
#define deb4(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;
#define deb5(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


ll mod=1000000007;
ll vis[212345]={0};
vvi v(212345);
ll d[212345]={0};


ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}





int main()
{
speed
ll n,d;
cin>>n>>d;
ll x[n],y[n];
rep(i,0,n) cin>>x[i]>>y[i];
ll c=0;
rep(i,0,n)
{
	ll k=x[i]*x[i]+y[i]*y[i];
	if(k<=d*d) c++;
}
cout<<c<<endl;
}



Measured memory_bytes: 11380