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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
//#define ld long double
#define mod 1000000007
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;
typedef long double ld;
bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}




ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b,ll r)
{
    a%=r;
    b%=r;
    return (a+b)%r;
}
ll mulmod(ll a,ll b,ll r)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll submod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    a-=b;
    if(a<0)a+=mod;
    return a%mod;
}
struct CustomCompare
{
    bool operator()(ll a,ll b)
    {
        return a>b;
    }
};
/*
const int mxn = 5*(1e6) +10;
vi spf(mxn);
void sieve()
{
    for(ll i =0;i<mxn;i++)spf[i]  = i;
    for(ll i=2;i<mxn;i+=2)spf[i] = 2;
    for(ll i = 3;i*i<mxn;i++)
    {
        if(spf[i]==i)
        {
            for(ll j = i*i;j<mxn;j+=i)
            {
                if(spf[j]==j)spf[j] = i;
            }
        }
    }
}
*/

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll x; cin>>x;
x = 1-x;
cout<<x<<"\n";
return 0;
}
/*
1
3 1
023l
2 3
*/


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;
typedef queue<ll> qi;
typedef queue<char> qc;
typedef queue<string> qs;
typedef vector<char> vc;
typedef vector<string> vs;
typedef map<char,ll> mpci;
typedef map<ll,ll> mpii;
typedef map<string,ll> mpsi;
typedef set<ll> sei;
typedef set<char> sec;
typedef set<string> ses;
typedef stack<ll> si;
typedef stack<char> sc;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pll> vpll;
typedef vector<pdd> vdd;
typedef unsigned int uint;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vii> vvii;
/*=====================================================================*/
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define sz(a) (int)(a.size())
#define len(a) (int)(a.length())
#define all(s) (s).begin(),(s).end()
#define fi first
#define se second
#define be begin
#define en end
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define forn(i,p,n) for(int i=p;i<n;i++)
#define ford(i,p,n) for(int i=n-1;i>=p;i--)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define zero(a) memset(a,0,sizeof(a))
#define number(a,num) memeset(a,num,sizeof(a))

/*=====================================================================*/

inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
inline void write(long long x) {
  static long long sta[35];
  long long top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[--top] + 48);
  puts("");
}
/*======================================================================*/
bool prime(int n)
{
	if(n==0||n==1)
	  return false;
	for(int i=2;i*i<=n;i++)
	  if(n%i==0)
	    return false;
	return true;
}
/*======================================================================*/
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
pii v[111111];
/*======================================================================*/
int main()
{
  /*
	ios_base::sync_with_stdio(0);
	cin(tie);
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
  */
  /*====================================================================*/
  int n;
  cin>>n;
  rep(i,n)
  {
  	int a;
  	cin>>a;
  	v[i]=pii(a,i);
  }
  sort(v,v+n);
  rep(i,n)
  {
  	cout<<v[i].second+1<<endl;
  }
  return 0;
}


Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {

	static int po=0;
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scan =new Scanner(System.in);
		int n=scan.nextInt();
		int[] arr=new int[n];
		for(int i=0;i<n;i++){
			arr[i]=scan.nextInt();
		}
		po=partition1(arr, 0, n-1);
		
		arrPrint(arr);
	}

	public static int partition2(int[] arr, int low,int high){
		int x=arr[low];
		while(low<high){
			while(low<high&&arr[high]>=x) --high;
			arr[low]=arr[high];
			while(low<high&&arr[low]<=x) ++low;
			arr[high]=arr[low];
			
		}
		arr[low]=x;
		return low;
	}
	public static int partition1(int[] arr, int low,int high){
		int x=arr[high];
		int i=low-1;
		for(int j=low;j<high;j++){
			if(arr[j]<=x){
				i=i+1;
				swap(arr,i,j);
			}
		}
		swap(arr, i+1, high);
		return i+1;
	}
	
	private static void swap(int[] arr, int i,int j) {
		// TODO Auto-generated method stub
		int tmp=arr[i];
		arr[i]=arr[j];
		arr[j]=tmp;
	}
	public static void arrPrint(int[] arr){
		int i=0;
		for(i=0;i<arr.length-1;i++){
			if(i==po){
				System.out.print("["+arr[i]+"] ");
			}
			else System.out.print(arr[i]+" ");
		}
		if(po!=i){
			System.out.println(arr[i]);
		}
		else{
			System.out.println("["+arr[i]+"]");
		}
	}
}



Measured memory_bytes: 67896
#include <bits/stdc++.h>
using namespace std;
int isWhite(char x)
{
    return x=='.';
}
int main()
{
    char mat[102][102];
    int row,col,i,j,dp[102][102];
    for(i=0;i<102;i++)
    {
        for(j=0;j<102;j++)
        {
            dp[i][j] = 69420;
            mat[i][j] = '.';
        }
    }
    dp[0][1] = dp[1][0] = 0;
    scanf("%d%d",&row,&col);
    for(i=1;i<=row;i++)
    {
        getchar();
        for(j=1;j<=col;j++)
        {
            scanf("%c",&mat[i][j]);
        }
    }
    for(i=1;i<=row;i++)
    {
        for(j=1;j<=col;j++)
        {
            if(isWhite(mat[i][j]))
            {
                dp[i][j] = min(dp[i][j-1],dp[i-1][j]);
            }
            else
            {
                dp[i][j] = min((dp[i][j-1]+isWhite(mat[i][j-1])),(dp[i-1][j]+isWhite(mat[i-1][j])));
            }
        }
    }
    printf("%d\n",dp[row][col]);
}


Measured memory_bytes: 256
# -*- coding utf-8 -*-

a,b=map(int,input().split())
x=0
y=0
if a>=b:
    x=x+a
    a=a-1
else:
    x=x+b
    b=b-1
if a>=b:
    y=y+a
else:
    y=y+b

print(x+y)


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

using namespace std;

typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const long long MOD = 1e9 + 7;
const  long long  INF = 5e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

int N, m;
string t[500010], tt[500010];
map<string, int>mp;

int solve(string s) {
	int n = s.size(), it = -1, ans = 0;
	bool fl = 0;
	for (int i = 0;i < n;i++) {
		if (s[i] == '?')it = i, fl = 1;
	}
	if (s[0] == '*') {
		s = s.substr(1, n - 1);
		reverse(s.begin(), s.end());
		it--;
		n--;
		if (fl) {
			for (int i = 0;i < 26;i++) {
				s[n-it-1] = 'a' + i;
				int a = lower_bound(tt, tt + N, s) - tt;
				s += 'z' + 1;
				int b = lower_bound(tt, tt + N, s) - tt;
				s = s.substr(0, n);
				ans += b - a;
			}
		}
		else {
			int a = lower_bound(tt, tt + N, s) - tt;
			s += 'z'+1;
			int b = lower_bound(tt, tt + N, s) - tt;
			ans += b - a;
		}
	}
	else if (s[n - 1] == '*') {
		s = s.substr(0, n - 1);
		if (fl) {
			for (int i = 0;i < 26;i++) {
				s[it] = 'a' + i;
				int a = lower_bound(t, t + N, s) - t;
				s += 'z'+1;
				int b = lower_bound(t, t + N, s) - t;
				s = s.substr(0, n - 1);
				ans += b - a;
			}
		}
		else {
			int a = lower_bound(t, t + N, s) - t;
			s += 'z' + 1;
			int b = lower_bound(t, t + N, s) - t;
			ans += b - a;
		}
	}
	else {
		if (fl) {
			for (int i = 0;i < 26;i++) {
				s[it] = 'a' + i;
				ans += mp[s];
			}
		}
		else {
			ans += mp[s];
		}
	}
	return ans;
}


string s, r;

int main() {
	cin >> N >> m;
	for (int i = 0;i < N;i++) {
		cin >> r;
		mp[r]++;
		t[i] = r;
		reverse(r.begin(), r.end());
		tt[i] = r;
	}
	sort(t, t + N);
	sort(tt, tt + N);
	for (int i = 0;i < m;i++) {
		cin >> s;
		cout << solve(s) << endl;
	}
	return 0;
}




Measured memory_bytes: 89916
#include <bits/stdc++.h>
 
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0) (__VA_ARGS__)
#define rep_0(i, end) for (int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for (int i = (fr); i <= (ba); ++i)
#define overload_rep(arg_0, arg_1, arg_2, name, ...) name
#define all(box) box.begin(), box.end()
 
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

int main() {

  int N, M;
  std::cin >> N >> M;
  std::vector<int> cnt(N);
  std::vector<bool> ac(N);

  rep (i, M) {
    int p;
    std::string S;
    std::cin >> p >> S;
    --p;
    if (S == "AC") {
      ac[p] = true;
    } else {
      if (!ac[p]) {
        ++cnt[p];
      }
    }
  }

  int ok = 0, ng = 0;
  rep (i, N) {
    if (ac[i]) {
      ++ok;
      ng += cnt[i];
    }
  }

  std::cout << ok << ' ' << ng << '\n';
  return 0;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vp vector<pair<int, int>>
#define graph vector< vector<int> >
#define vs vector<string>
#define mn -
#define pls +
#define mod %
#define E =
#define EE ==
#define le <=
#define ge <=
int mx=9999999;
/**  '' "\n" - ^ **/

class Template{
    public:
    void yes()
    {
        cout<<"Yes\n";
    }

    void no()
    {
        cout<<"No\n";
    }
    void YES()
    {
        cout<<"YES\n";
    }

    void NO()
    {
        cout<<"NO\n";
    }

    void Case(int i,int n)
    {
        cout<<"Case:"<<i<<" "<<n<<endl;
    }
    /**  '' "\n" x ^ **/
    /** printf("\n") */
};
bool comp(pair<ll,ll> a,pair<ll,ll> b)
{
    if(a.first<b.first)return true;
    if(a.first>b.first)return false;
    return a.second>b.second;
}
int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    Template root;
    ll n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)sum=sum+i;
    }
    pf(sum);
}


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


int main() {
	int R, G, B, N;
	int count = 0;
	cin >> R >> G >> B >> N;
	for (int i = 0; i <=N/R; i++)
	{
		for (int j = 0; j <= N/G; j++)
		{
			//cout << i * R << "," << j * G << "," << N - i * R - j * G << endl;
			if (((N - i * R - j * G) % B == 0) && (N - i * R - j * G >= 0))
			{
				count++;
				//cout << i * R << "," << j * G << "," << N - i * R - j * G << " is ans"<<endl;
			}
		}
	}
	cout << count;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll freq[100005],mx = INT_MIN;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n; cin>> n;
	for(int i = 0; i < n; ++i){
		ll x; cin >> x;
		freq[x]++;
		freq[x + 1] ++;
		freq[x - 1]++;
		mx= max(mx,max(freq[x],max(freq[x + 1],freq[x - 1])));
	}
	cout << mx << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using ll = long long int;
#define int ll

const int MOD = 1e9 + 7;
const int INF = 1e15 + 373;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> init_vector2(size_t n0, size_t n1, T e = T()) {
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> init_vector3(size_t n0, size_t n1, size_t n2, T e = T()) {
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

template <typename T>
void dump(const vector<T>& v) {
    cout << "[";
    for (T e : v) {
        cout << e << ", ";
    }
    cout << "]" << endl;
}

signed main() {
    int n;
    cin >> n;

    vector2<int> g(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    rep(i, n) {
        if (g[i].size() != 2) {
            continue;
        }
        int a = g[i][0];
        int b = g[i][1];

        g[i].resize(0);
        for (size_t j = 0; j < g[a].size(); j++) {
            if (g[a][j] == i) {
                g[a][j] = b;
                break;
            }
        }
        for (size_t j = 0; j < g[b].size(); j++) {
            if (g[b][j] == i) {
                g[b][j] = a;
                break;
            }
        }
    }

    int ans = 0;
    rep(i, n) {
        if (g[i].size() <= 1) {
            continue;
        }
        int cnt = g[i].size() - 1;
        for (size_t j = 0; j < g[i].size(); j++) {
            if (g[g[i][j]].size() >= 3) {
                cnt--;
            }
        }
        ans += max(cnt, 0LL);
    }

    cout << max(ans, 1LL) << endl;

    return 0;
}


Measured memory_bytes: 6784
#include<iostream>
#include<string>
using namespace std;
template<typename T>
void print(T value)
{
	cout << value << endl;
}

int n;
int result;
int main() 
{
	cin >> n;
	if(n % 2 == 0) 
	{
		result = n;
	}
	else 
	{
		result = n*2;
	}
	print(result);
	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el cout << "\n"
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);
bool visited[1000005];
vector<ll> mp[1000005];
map<ll,ll> pp;
vector<ll> ans;
ll sum;
void dfs(ll s,ll sum)
{
    visited[s]=true;
    ans[s]=sum;
    for (int i=0;i<mp[s].size();i++)
    {
        if (visited[mp[s][i]]==false)
        {
            dfs(mp[s][i],sum+pp[mp[s][i]]);
        }
    }
}
int main()
{
	IOS;
    cout.precision(30);
    ll n,m,a,b,q; cin >> n >> q ; m=n-1;  memset(visited,false,sizeof visited);
    ans.resize(n+1,0);
    for (int i=0;i<m;i++)
    {
        cin >> a >> b;
        mp[a].push_back(b); mp[b].push_back(a);
    }
    for (int i=0;i<q;i++)
    {
        cin >> a >> b;
        pp[a]+=b;
    }
    dfs(1,pp[1]);
    for (int i=1;i<=n;i++) cout << ans[i]<< " " ;
    return 0;
}



Measured memory_bytes: 66796
import math
def main():
    N = int(input())
    ans = N + 1
    for i in range(1, int(math.sqrt(N))+1):
        if N % i == 0:
            ans = min(ans, i-1 + (N // i) - 1)
    return ans


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  float min_sa = 100000;
  float sum,ans,b = 0;
  int n = 0;
  float avg,c,sa = 0;
  cin >> n;
  float a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  avg = sum/n;

  for(int j=0;j<n;++j){
    c = a[j]-avg;
    sa = abs(c);
    if(min_sa > sa){
      min_sa = sa;
      b = j;
    }
  }
  cout << b << endl;
}

Measured memory_bytes: 256
#if __has_include("noamoa_atcoder_lib.h")
#include "noamoa_atcoder_lib.h"
#else
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) (x).begin(),(x).end()
namespace atcoder {
	using namespace std;
	using ll = long long;
	using intv = vector<int>;
	using charv = vector<char>;
	using boolv = vector<bool>;
	using floatv = vector<float>;
	using doublev = vector<double>;
	using stringv = vector<string>;

	constexpr ll MOD  = 1000000007;
    constexpr ll MOD9 = 1000000009;

	template<typename T>
	void sort(vector<T>& v){
		sort(all(v));
	}
	template<typename T>
	void sortInv(vector<T>& v){
		sort(all(v), greater<T>());
	}

	template<typename T>
	T sum(const vector<T>& v){
		T ret = 0;
		for(const auto& e : v) ret += e;
		return ret;
	}

	template<typename T>
	inline vector<T>& operator+=(vector<T>& v, const T& e){
		v.push_back(e);
		return v;
	}

	template<typename T>
	void in(vector<T>& v){
		for(auto& e : v) cin >> e;
	}

	template<typename T>
	istream& operator>>(istream &stream, vector<T>& v){
		for(auto& e : v) stream >> e;
		return stream;
	}

	template<typename T>
	void out(const vector<T>& v){
		for(const auto& e : v) cout << e << ' ';
		cout << endl;
	}

	template<typename T>
	void outln(const vector<T>& v){
		for(const auto& e : v) cout << e << endl;
	}

	void init(){
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}
using namespace atcoder;
#endif

int main(){
	init();

	string S;cin>>S;

	intv a(2019);
	intv t(2019);
	for(int i=0;i<a.size();i++)a[i] =0;

	ll ans=0;

	for(int i=0;i<S.size();i++){
		for(int j=0;j<2019;j++){
			t[j]=a[j];
			a[j]=0;
		}
		for(int j=0;j<2019;j++){
			a[(j*10+S[i]-'0')%2019]+=t[j];
			
		}
		ans+=a[0];
		//if(a[0]>0)cout << i << ", " << a[0]<<endl;
		/*if(i==4){
			for(int j=0;j<2019;j++){
				if(a[j]!=0) cout << j <<" "<<a[j]<<endl;
			}
		}*/
		a[S[i]-'0']++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3684
A, B, C, D, E, F = map(int, input().split())

lst = []

for a in range(0, F, 100*A):
    for b in range(0, F, 100*B):
        x = a + b        
        if x == 0 or x > F:
            continue
        
        for c in range(0, F, C):
            for d in range(0, F, D):
                y = c + d
                if x + y > F or 100*y/(x+y) > 100*E/(100+E):
                    break
                lst.append((100*y/(x+y), x+y, y)) 

d, t, y = max(lst)
print(t, y)

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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp std::make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

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

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

#define fcout(n) std::cout << std::fixed << std::setprecision((n))

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::pair<int,int> PII;

typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::vector<PII> VPII;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

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

    int l, r;
    int sum = 0;
    REP(i, N) {
        std::cin >> l >> r;
        sum += (r-l) + 1;
    }
    std::cout << sum << std::endl;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define repp(i, n) rep(i, n)
#define reppp(i, n) repp(i, n)
#define rrepp(i, n) rrep(i, n)
#define repss(i, n) reps(i, n)
#define repcc(i, n) repc(i, n)
#define repii(i, a, b) repi(i, a, b)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  vi32 v(3);
  v[0] = 1;
  char a, b, c;
  while (cin >> a >> b >> c) swap(v[a - 'A'], v[c - 'A']);
  rep(i, 3) if (v[i]) cout << (char) ('A' + i) << '\n';
}



Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> P;

struct edge {
    int to, cost;
};

typedef vector<vector<edge> > AdjList;

AdjList graph;

const int INF = 10000000;
vector<int> dist;

void dijkstra(int n, int s){
    dist = vector<int>(n,INF);
    dist[s] = 0;
    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P(0,s));

    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(dist[v] < p.first){
            continue;
        }
        for(int i=0; i<graph[v].size(); i++){
            edge e = graph[v][i];
            if(dist[e.to] > dist[v] + e.cost){
                dist[e.to] = dist[v] + e.cost;
                que.push(P(dist[e.to],e.to));
            }
        }
    }
}


int main(void){
    int n, m;
    cin >> n;
    graph = AdjList(2*n);

    for(int i=0;i<n-1;i++){
        int from, to;
        cin >> from >> to;
        from--;
        to--;
        graph[from].push_back((edge){to,1});
        graph[to].push_back((edge){from,1});
    }

    vector<int> distFrom1(n);
    dijkstra(n,0);
    for(int i=0; i<n; i++){
        distFrom1[i] = dist[i];
    }

    vector<int> distFromN(n);

    dijkstra(n,n-1);
    for(int i=0; i<n; i++){
        distFromN[i] = dist[i];
    }

    int cnt1=0, cntN=0;
    for(int i=0; i<n; i++){
        if(distFrom1[i] <= distFromN[i]){
            cnt1++;
        }else{
            cntN++;
        }
    }

    if(cnt1 <= cntN){
        cout << "Snuke" << endl;
    }else{
        cout << "Fennec" << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;


int main() {
    int n; cin >> n;
    vector<ll> l(n, 0);
    rep(i, n) cin >> l[i];
    sort(all(l));

    ll ans = 0;
    rep(i, n) {
        int k = i;

        for (int j=i+1;j<n;++j) {
            while (k < n && l[k] < l[i] + l[j]) k++;
            ans += max(k - (j + 1), 0);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import numpy as np

n, m = list(map(int, input().split()))

ab = [list(map(int, input().split())) for _ in range(m)]
ab.reverse()


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


tree = UnionFind(n)
buf = [n*(n-1)//2]
for i in range(len(ab)-1):
    a, b = ab[i]
    a, b = a-1, b-1
    if tree.same(a, b):
        buf.append(buf[-1])
        continue
    ra = tree.parents[tree.find(a)]
    rb = tree.parents[tree.find(b)]
    buf.append(buf[-1] - ra * rb)
    tree.union(a, b)

buf.reverse()
# ans = []
# roots = [-x for i, x in enumerate(tree.parents) if x < 0]
# roots = np.array(roots)
# ans_tmp = n*(n-1)//2-np.sum(roots*(roots-1))//2
# ans.append(ans_tmp)
# for a, b in reversed(ab):
#     tree.union(a-1, b-1)
#     roots = [-x for i, x in enumerate(tree.parents) if x < 0]
#     roots = np.array(roots)
#     ans_tmp = n*(n-1)//2-np.sum(roots*(roots-1))//2
#     ans.append(ans_tmp)

print('\n'.join(map(str, buf)))


Measured memory_bytes: 50744
#include <stdio.h>

int main(void)
{
	int n,i,m[1000];
	
	 scanf("%d",&n);
	 for(i=0;i<n;i++)
	 scanf("%d",&m[i]);
	 
	 trace(m,n);
    insertionSort(m,n);
	
	return 0;
}
int insertionSort(int A[], int N){
	int i,j,v;
  for(i=1;i<N;i++)
   {
     v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v){
      A[j+1] = A[j];
     j--;
    }
   A[j+1] = v;
   trace(A,N);
}
}
void trace(int A[],int N){
	int i;
	for(i=0;i<N;i++){
		if(i>0)putchar(' ');
		printf("%d",A[i]);
	}
	printf("\n");

}

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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;

    map<int, int> cnt;
    for (int i = 0, a; i < n; ++i) {
        cin >> a;
        ++cnt[a];
    }

    for (auto &it : cnt) {
        if (it.second == 1) continue;
        else if (it.second % 2 == 0) it.second = 2;
        else it.second = 1;
    }

    int n1 = 0, n2 = 0;
    for (auto it : cnt) {
        if (it.second == 1) ++n1;
        else ++n2;
    }

    if (n2 % 2 == 0) cout << n1 + n2 << endl;
    else cout << n1 + n2 - 1 << endl;

    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL <<60;
const long long Mo=1000000007;
     
long long gcn(long long x,long long y){
  if(x%y==0){
    return y;  
  }
  else{
    return gcn(y,x%y);
  }
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(void){
  long long tmp;
  long long n;
  long long i,j,k;
  long long s[2001]={};
  long long res=0;

  cin>>n;
  if(n<3){
    res=0;
    cout<<res<<endl;
    return 0;
  }
  else{
    s[0]=1;
    s[1]=0;
    s[2]=0;
    for(i=3;i<=n;i++){
      for(j=3;j<=i;j++){
        s[i]+=(s[i-j]%Mo);
        s[i]=s[i]%Mo;
      }
      //cout<<i<<" "<<s[i]<<endl;
    }
    res=s[n];
  } 
  
  cout<<res<<endl;
  return 0;
}

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

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

    string s,t;
    cin >> s >> t;
    ll ss = s.size();
    ll tt = t.size();
    ll ans = tt;
    for (ll i = 0; i <= ss-tt; i++){
        ll x = 0;
        for (ll j = 0; j < tt; j++){
            if (s[i+j] != t[j]){
                x++;
            }
        }
        ans = min(x,ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3652
h, w, n = gets.split.map(&:to_i)

sr, sc = gets.split.map(&:to_i)

s = gets.chomp.chars
t = gets.chomp.chars

x = sc
x2 = sc
y = sr
y2 = sr

0.upto(n-1) do |i|
  if s[i] == 'L'
    x -= 1
  end
  if x < 1
    puts "NO"
    exit
  end
  if t[i] == 'R'
    x = [x + 1, w].min
  end

  if s[i] == 'R'
    x2 += 1
  end
  if x2 > w
    puts "NO"
    exit
  end
  if t[i] == 'L'
    x2 = [x2 - 1, 1].max
  end

  if s[i] == 'U'
    y -= 1
  end
  if y < 1
    puts "NO"
    exit
  end
  if t[i] == 'D'
    y = [y + 1, h].min
  end

  if s[i] == 'D'
    y2 += 1
  end
  if y2 > h
    puts "NO"
    exit
  end
  if t[i] == 'U'
    y2 = [y2 - 1, 1].max
  end
end

puts "YES"


Measured memory_bytes: 42620
import java.util.Scanner;
 
class Main{
  static final int INF = (int)1e9+7;
  static int solve(int[] h, int N, int K){
    int[] dp = new int[N];
    dp[0] = 0;
    for(int i= 1; i< N; i++){
      dp[i] = INF;
      for(int j = 1; j <= K; j++)
      	if(i-j >= 0)
      		dp[i] = Math.min(dp[i], dp[i-j] + Math.abs(h[i] - h[i-j]));
    }
    return dp[N-1];
  }
 
  
 
  public static void main(String... args){
 
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] h = new int[N];
    for(int i =0; i< N; i++){
       h[i]= sc.nextInt();
    }
    //_________________________
    int result = solve(h, N, K);
    System.out.println(result);
 
    if(sc != null)
      sc.close();
 
  }  
}

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

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

  char a = s[k-1];

  for(int i=0;i<s.size();i++) {
    if(s[i] == a) cout << a;
    else cout << '*';
  }

  cout << endl;
}

Measured memory_bytes: 256
S=input()
T=input()
flag=False
for i in range(len(S)-len(T)+1):
    dif=0
    same=0
    s=S[i:i+len(T)]#len(T)
    for j in range(len(T)):
        if s[j]!='?':#sが言葉の時
            if s[j]!=T[j]:
                #print("st",s[i],T[i])
                dif+=1
            else:
                same+=1
#                flag=True

        #else:#?のとき
    if dif==0:
        #dst=S.replace(s,T)
        flag=True
        memo=i#複数replace対策
    



if flag==False:
    print("UNRESTORABLE")
else:
    S=list(S)
    for i in range(len(T)):
        S[i+memo]=T[i]
    
    S=''.join(S)    
    S=S.replace('?','a')
    print(S)



Measured memory_bytes: 3064
//pragma GCC optimize("Ofast")
//pragma GCC optimize("unroint-loops")
//pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(int i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( int i = a; i >= b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sz(a) (int) a.size()
#define aint(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
//#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii ;
typedef vector<int>  vi ;
typedef vector<ii> vii ;


const int MAX = 2e5+6;
const ll inf = 5e18;
ll mod=998244353;

int a[MAX];
map<int,int> m;
int main(){
	fastio;
	ll n;
	cin>>n;
	f(i,0,n) cin>>a[i], m[a[i]]++;
	ll sum=0;
	for(auto it:m){
		ll c =  it.second;
		sum+=(c*(c-1))/2;
	}
	f(i,0,n){
		if(m[a[i]]==1){
			cout<<sum<<endl;
		}
		else{
			cout<<sum-m[a[i]]+1<<endl;
		}
	}
}

Measured memory_bytes: 8320
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int a[5],k;
	bool flag=true;
	rep(i,5)cin>>a[i];
	cin>>k;
	rep(i,5){
		for(int j=i+1;j<5;j++){
			if(a[j]-a[i] > k)flag=false;
		}	
	}
	if(flag)cout<<"Yay!"<<endl;
	else cout<<":("<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
char t[100][100];
int main(){
	int h,w;
	int i,j;
	while(1){
	scanf("%d %d",&h,&w);
	if(h==0)return 0;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			scanf(" %c",&t[i][j]);
		}
	}
	int x=0,y=0;
	int c=1;
	while(t[x][y]!='.'){
		char ch=t[x][y];
		switch(ch){
		case '>':y++;break;
		case '<':y--;break;
		case 'v':x++;break;
		case '^':x--;break;
		}
		c++;
		if(c>w*h)break;
	}
	if(t[x][y]=='.')printf("%d %d\n",y,x);
	else printf("LOOP\n");
	}
}

Measured memory_bytes: 1048
f=->a,b{a.size.times.map{|i|a[b[i]]}}
n,*z=`dd`.split.map &:to_i
t=[*0...n]
e=[*0...n]
a=z.shift(n+1)
n.downto(1){|i|a[i]-=a[i-1]}
k=z.shift
z.map{|x|t[x-2],t[x-1]=t[x-1],t[x-2]}
(e=f[e,t]if k%2>0;t=f[t,t];k/=2)while k>0
k=a[0]
n.times{|i|p k;k+=a[e[i]+1]}

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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

    vector<int> L(N);
    rep(i,N) cin >> L[i];

    sort(all(L));
    int tmp = 0;
    rep(i,N-1) tmp += L[i];

    if( L[L.size()-1] < tmp ) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <queue>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
    _typer init = 0;
    char ch = getchar(), k = 0;
    for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
    for ( ; isdigit(ch); ch = getchar())
        init = (init << 3) + (init << 1) + (ch ^ 48);
    return k ? -init : init;
}
const ll N = 100005, INF = 1e9;

priority_queue < int > Q;

struct NODE {
    int day, si;
    inline bool operator < (const NODE &__) const {
        return day > __.day;
    }
} node[N];
int n, m, Ans;

int main() {
    n = read<int>(), m = read<int>();
    rep (i, 1, n) node[i].day = m - read<int>() + 1, node[i].si = read<int>();
    sort(node + 1, node + n + 1);
    int cur = 1;
    dep (i, n, 1) {
        while (node[cur].day >= i && cur <= n)
            Q.push(node[cur].si), ++cur;
        if (!Q.empty()) Ans += Q.top(), Q.pop();
    }

    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 1660
s=input()
n=len(s)-1
ans=0

for bit in range(0, 1<<n):
    st=s
    for i in range(n+1):
        if (bit>>i)%2==0:
            continue
        st=st[:n-i]+'+'+st[n-i:]

    ans+=sum(list(map(int,st.split('+'))))
print(ans)
        


Measured memory_bytes: 9012
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    char c;
    int ttl;
    ttl = 0;
    for(int i = 0; i < 4; i++){
        cin >> c;
        if(c == '-'){
            ttl--;
        }else{
            ttl++;
        }
    }
    cout << ttl << '\n';
    return 0;
}


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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

 
/*CODE START HERE*/
int main() {
  int d,n;
  cin >> d >> n;
  vector <int> hund(100);
  forn(i,99){
    hund.at(i)=i+1;
  }
  hund.at(99) = 101;
  vector<int> keta(3);
  keta.at(0)=1;
  keta.at(1)=100;
  keta.at(2)=10000;
  cout<<hund.at(n-1) * keta.at(d) << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    string s; cin >> s;
    vector<int> a, z;
    rep(i, s.size()) {
        if (s[i] == 'A') a.push_back(i);
        else if (s[i] == 'Z') z.push_back(i);
    }
    cout << *max_element(ALL(z)) - *min_element(ALL(a)) + 1 << endl;
}

Measured memory_bytes: 1428
n=int(input())
h=list(map(int, input().split()))
sum=0
for i in range(max(h)):
    if 0 not in h:
        h=[X-1 if X>0 else 0 for X in h]
        sum+=1
        # print(h,1)
    else:
        count0=[Y for Y, Z in enumerate(h) if Z==0]
        a=count0.copy()
        b=count0.copy()
        del a[0]
        del b[-1]
        c=[x-y for(x,y) in zip(a,b)]
        sum = sum + len(c)-c.count(1)
        if count0[0]>0 and count0[-1]<n-1:
            sum +=2
        elif count0[0]>0 or count0[-1]<n-1:
            sum +=1
        else:
            sum +=0
        h=[i-1 if i>0 else 0 for i in h]
print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int n ;
    cin >> n;
    int ans = 0;
    rep1(i,n+1){
        string s = to_string(i);
        if(s.size()%2==1) ans ++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9 + 5;
constexpr long long INFLL = 1LL << 62;
constexpr double eps = (1e-9);

void warshall_floyd(const int& n, vector<vector<int>>& d) {
  rep(k, n) rep(i, n) rep(j, n) chmin(d[i][j], d[i][k] + d[k][j]);
}

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

  int h, w;
  cin >> h >> w;
  vector<vector<int>> c(10, vector<int>(10));
  rep(i, 10) rep(j, 10) {
    cin >> c[i][j];
  }

  warshall_floyd(10, c);

  ll ans = 0;
  rep(i, h) rep(j, w) {
    int x;
    cin >> x;
    if (x == -1) continue;
    ans += c[x][1];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3648
n, k = map(int, input().split())
p = 0
for i in range(1, n+1):
    sum_ = i
    j = 0
    while True:
        if sum_ >= k:
            break
        sum_ *= 2
        j += 1
    q = 1
    for x in range(j):
        q *= 0.5
    p += q
p /= n
print(p)

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;

class Main {

    int n = 0;
    ArrayList<Integer> m_bounce = new ArrayList<Integer>();
    
    boolean IsReachable() {

	int current = 0;
	for ( int i=0; i<n; ++i ) {
	    if ( current < 10*i ) return false;
	    current = Math.max( current, 10*i + m_bounce.get( i ) );
	    if ( current >= 10*n ) return true;
	}
	return false;
    }
    
    void solve(){

	Scanner sc = new Scanner( System.in );

	n = sc.nextInt();
	for ( int i=0; i<n; ++i ) m_bounce.add( sc.nextInt() );
	    
	if ( !IsReachable() ) {
	    System.out.println( "no" );
	    return;
	}
	
	Collections.reverse( m_bounce );
	if ( !IsReachable() ) System.out.println( "no" );
	else System.out.println( "yes" );
	
    }

    public static void main( String[] a ) {new Main().solve(); }
}



Measured memory_bytes: 111884
#include<stdio.h>
int main()
{
    long long int a,b,s,c;
    while(scanf("%lld %lld",&a,&b)!=EOF){
    s=a+b;
    c=0;
    while(s!=0){
        s=s/10;
        c++;
    }
    printf("%lld\n",c);
        }
        return 0;
}

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

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

        try (Scanner scanner = new Scanner(System.in)){
            int[] input = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            int n = input[0];
            int x = input[1];

            int sum = 0;
            int count = 1;
            for (int i : Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray()) {
                sum += i;
                if (sum > x) break;
                count++;
            }



            System.out.println(count);
        }

    }
}


Measured memory_bytes: 28628