akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n,m,i,j,t,k,s,f[105][105];
char str[105][105];

/*void dfs(int x,int y,bool flg,int cnt)
{
	if (str[x][y]=='.'&&flg) flg=0;
	else if (str[x][y]=='#'&& !flg) ++cnt,flg=1;
	if (x==n&&y==m) {s=min(s,cnt);return;}
	if (x<n) dfs(x+1,y,flg,cnt);
	if (y<m) dfs(x,y+1,flg,cnt);
}*/

int main()
{
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;++i)
	{
		scanf("%s",str[i]+1);
	}
	s=1e9;
	//dfs(1,1,0,0);
	for (i=1;i<=n;++i)
	 for (j=1;j<=m;++j)
	{
		if (i==1&&j==1) f[i][j]=(str[1][1]=='#');
		else
		{
			f[i][j]=1e9;
			if (i>1) f[i][j]=min(f[i][j],f[i-1][j]+(str[i][j]=='#'&&str[i-1][j]=='.'));
			if (j>1) f[i][j]=min(f[i][j],f[i][j-1]+(str[i][j]=='#'&&str[i][j-1]=='.'));
		}
	}
	printf("%d\n",f[n][m]);
	return 0;
}

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

int main()
{
	long long n, sum=0, neg=0, mini=1e9;
	cin  >> n;
	long long a[n+1];
	for(int i=0; i<n; i++){
		cin >> a[i];
		sum += abs(a[i]);
		if(a[i]<0) neg++;
		if(abs(a[i])<mini) mini = abs(a[i]);
	}

	if(neg %2 == 0)	cout << sum;
	else cout << sum - 2*mini;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int n;
    std::cin>>n;
    std::vector<int> a(n);
    for(auto i = a.begin();i != a.end();i++){
        std::cin>>*i;
    }

    std::sort(a.begin(), a.end(), std::greater<>());
    for(int i = 1;i < a.size();i += 2){
        a[i] = -a[i];
    }
    std::cout<<std::accumulate(a.begin(), a.end(), 0)
        <<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int r, g, b;
    std::cin >> r >> g >> b;
    if ((r*100 + g*10 + b) % 4 == 0) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO"  << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int a = Integer.parseInt(s.substring(0, 2));
        int b = Integer.parseInt(s.substring(2, 4));
        if (0 < a && a < 13) {
            if (0 < b && b < 13) {
                System.out.println("AMBIGUOUS");
            } else {
                System.out.println("MMYY");
            }
        } else {
            if (0 < b && b < 13) {
                System.out.println("YYMM");
            } else {
                System.out.println("NA");
            }
        }
    }
}

Measured memory_bytes: 21844
cards = ["S 1","S 2","S 3","S 4","S 5","S 6","S 7","S 8","S 9","S 10","S 11","S 12","S 13",
"H 1","H 2","H 3","H 4","H 5","H 6","H 7","H 8","H 9","H 10","H 11","H 12","H 13",
"C 1","C 2","C 3","C 4","C 5","C 6","C 7","C 8","C 9","C 10","C 11","C 12","C 13",
"D 1","D 2","D 3","D 4","D 5","D 6","D 7","D 8","D 9","D 10","D 11","D 12","D 13",]

loopnum = gets.to_i
(1..loopnum).each do |num|
    cards.delete(gets.chomp.to_s)
end
puts cards

Measured memory_bytes: 8692
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int dp[50];
    dp[0]=1;
    dp[1]=1;
    for(int i=2;i<=n;i++)dp[i]=dp[i-1]+dp[i-2];
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 3164
#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);
    //cout << fixed << setprecision(15);

	string S; cin >> S;
	int N = S.size();
	bool flag = true;
	rep(i,(N+1)/2) {
		if(S[i] != S[N-1-i]) No
	}
	rep(i,(N-1)/2) {
		if(S[i] != S[(N-1)/2 - 1 - i]) No
	}
	repk(i,(N+1)/2,N) {
		if(S[i] != S[N-1-i]) No

	}
    Yes
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
n = INT()

ans = 0
# a = [INT() for i in range(n)]
a = []
for i in range(n):
    a.append(INT())
l = []
# print(a)

b = sorted(a, reverse=True)
# print(a)
m1 = b[0]
m2 = b[1]
for i in range(n):
    if a[i] != m1:
        print(m1)
    else:
        print(m2)
     




# # for i in range(n):
#     l = []
#     for j in range(n):
#         if i != j:
#             l.append(a[j])
#     print(max(l))
#         # print(l)
#         # print(max(l))

#     # print(a[0:i], a[i:n])
#     # print(ans)
# 


Measured memory_bytes: 16180
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
    int n, ans = 0;
    cin>> n;
    string s;
    cin>> s;
    set<int> r, w;
    rep(i, 0, n){
        if(s[i] == 'R')
            r.insert(i);
        else
            w.insert(i);
    }
    if(r.size() == 0  or  w.size() == 0)
        return cout<< 0, 0;
    while(true){
        int rr = *(r.rbegin());
        int ww = *(w.begin());
        if(rr < ww)
            break;
        ans++;
        r.erase(rr);
        w.erase(ww);
        r.insert(ww);
        w.insert(rr);
    }
    cout<< ans<< "\n";
    return 0;
}
//Counting problems: Sometimes easier to find complement of the answer
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


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

using namespace std;
int main (){
    string s;
    int n;
    cin >> n;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        s[i]+=n;
        if(s[i]>'Z') s[i]-=26;
    }
    cout << s <<"\n";

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const int limit = 30000;

int n, nn, i, even, odd, sumi;
vector<int> sol;

int main()
{
    //freopen("test.in","r",stdin);

    scanf("%d", &n);
    even = 2;
    odd = 3;

    nn = n;
    sumi += even;
    sol.pb(even); even += 2; n--;

    if (nn % 2 == 1) {
        sumi += even;
        sol.pb(even); even += 2; n--;

        sumi += even;
        sol.pb(even); even += 2; n--;
    }



    while (odd + 6 <= limit && n >= 2) {
        sol.pb(odd);
        sol.pb(odd + 6);
        odd += 12;
        n -= 2;
    }

    while (n > 0) {
        sol.pb(even);
        sumi += even;
        even += 2;
        n--;
    }

    for (i = sol.size() - 1; sol[i] % 2 == 1; i--);

    while (sumi % 3 != 0) {
        sol[i] += 2;
        sumi += 2;
    }

    if (nn == 3) sol = {2, 5, 63};
    if (nn == 4) sol = {2, 5, 20, 63};

    for (auto e : sol) cout << e << ' ';


    return 0;
}


Measured memory_bytes: 512
//******* It's LEVI_17 ***************

#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ff first
#define ss second
#define MP make_pair
#define mset(x,a) memset(x,a,sizeof(x))
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define sqr(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define f(i, n) for (int i = 0; i < n; i++)
#define f1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define vvll vector<vector<ll>>  
#define vll vector<ll> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define cases ll t;cin >> t;while(t--)
#define rr return 0
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define deb(a)			std::cerr<<#a<<"="<<(a)<<"\n"
#define deb2(a,b)		std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define deb3(a,b,c)		std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
const int MOD = 1000 * 1000 * 1000 + 7;

//syntax for priority queue
// max queue -> priority_queue<ll>
// min queue -> priority_queue<ll,vector<ll>,greater<ll>>

//##############################################################################################

ll getRes(ll arr[],ll brr[],ll crr[], ll n)
{
    ll dp[n + 1][3];
    dp[0][0] = 0; dp[0][1] = 0; dp[0][2] = 0;
    for (ll i = 1; i <= n; i++)
    {
        dp[i][0] = arr[i - 1] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = brr[i - 1] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = crr[i - 1] + max(dp[i - 1][0], dp[i - 1][1]);
    }

    return max(dp[n][0], max(dp[n][1], dp[n][2]));

}

void solve()
{
    ll n;
    cin >> n;
    ll arr[n], brr[n], crr[n];
    f(i, n)
        cin >> arr[i] >> brr[i] >> crr[i];
   
    ll res = getRes(arr,brr,crr, n);
    cout << res << "\n";
}

//###############################################################################################

int main()
{
    fast;
    ll t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    rr;
}


//Watashi wa tsuyoku modotte kimasu

Measured memory_bytes: 8324
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
#define PI 3.141592653589793

int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double mdo, hdo;
  mdo = 6 * m;
  hdo = 30 * h + 0.5 * (double)m;
  double kakudo = abs(hdo - mdo);
  kakudo = min(kakudo, 360 - kakudo);
  kakudo = kakudo * PI / 180.0;
  // cout << kakudo << " => " << hdo << ", " << mdo << endl;
  double ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(kakudo));
  printf("%.10f\n", ans);

  return 0;
}

Measured memory_bytes: 4192
#include <iostream>
using namespace std;
using ld = long double;

int main() {
	int n;
	cin >> n;
	
	int a[n] {};
	
	for (int i = 1; i < n; i++) {
		int x;
		cin >> x;
		x--;
		a[x]++;
	}
	
	for (int i = 0; i < n; i++)
		cout << a[i] << '\n';
}

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


int main(void)
{
	int N;
	cin >> N;
	int ans = 100;

	for (int A = 1; A < N; A++) {
		int a = A;
		int b = N - a;

		int sum = 0;
		for (int i = 0; i <= 5; i++) {
			sum += (a%10 + b%10);
			a /= 10;
			b /= 10;
		}
		ans = std::min(ans, sum);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;




int main(void) {
    
    int n;
    cin>>n;
    vll v(n);
    rep(i,n)cin>>v[i];
    vll a(1,0);
    rep(i,n){
        ll div=a[a.size()-1]/2;
        a.pb((v[i]-div)*2);
    }
    vll b(1,a[a.size()-1]/2);
    rep(i,n){
        ll div=b[b.size()-1]/2;
        b.pb((v[i]-div)*2);
    }
    
    rep(i,n){
        if(i!=n-1)cout<<b[i]<<" ";
        else cout<<b[i];
    }
    cout<<endl;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<pi> vpi;

#define debugone(x) cout << #x << " " << x << endl;
#define debugtwo(x) cout << #x << "-------------" << endl;for(auto &it: x) cout << it << " ";cout << endl;
#define debugthree(x, i, j) cout << #x << "------------" << endl;cout << "from " << i << " to " << j << endl;for(int k=i; k<=j; k++) cout << x[k] << " ";cout << endl;

const int mod = (int)1e9 + 7;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int a, p;
	cin >> a >> p;
	cout << (3 * a + p)/2 << endl;
}

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

int main() {
	
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  
  int cnt = 0;
  int k = 0;
  rep(i, n){
    if(s[i] == 'a'){
      if(cnt < a+b){
		cnt++;
        cout << "Yes" << endl;
      }
      else{
		cout << "No" << endl;
      }
    }
    else if(s[i] == 'b'){
      if(k < b && cnt < a+b){
		cnt++;
        k++;
        cout << "Yes" << endl;
      }
      else{
		cout << "No" << endl;
      }
    }
    else{
	  cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;

const int MAX = 86400;
const double EPS = 1e-8;
int cons[MAX];
int N,L;


void init(){
  fill(cons,cons+MAX,0);
}

void input(){
  for(int i = 0; i < N; i++){
    int s,g,c;
    cin >> s >> g >> c;
    for(int j = s; j < g; j++) cons[j] = c;
  }
}

double search(double tank, double pump){

  for(int i = 0; i < MAX; i++){
    tank-=cons[i];
    tank = min(tank+pump,(double)L);
    if(tank < 0 || tank == 0 && cons[i] > 0) return -1;
  }
  return tank;
}

bool isOK(double* res){

  for(int i = 0; i < 3; i++)
    if(res[i] < 0) return false;
     
  if(res[1] > res[2]) return false;
  
  return true;
}


void solve(){

  double res[3];
  double l = 0, r = 100000000;

  while(r-l >= EPS){
    double c = (l+r)/2.0;
    res[0] = L;

    for(int i = 0; i < 2; i++)
      res[i+1] = search(res[i],c);
    
    if(isOK(res)) r = c;
    else l = c;
  }

  printf("%.6f\n",r);
}

int main(){
  while(cin >> N >> L && N+L){
    init();
    input();
    solve();
  }
  return 0;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }

ll mod;
ll keta[19], cnt[19];

typedef vector<ll> vec;
typedef vector<vec> mat;

mat mul(mat& a, mat& b) {
  mat c(a.size(), vec(b[0].size(), 0));
  rep(i, a.size()) {
    rep(k, b.size()) {
      rep(j, b[0].size()) {
        c[i][j] += a[i][k] * b[k][j];
        c[i][j] %= mod;
      }
    }
  }
  return c;
}

mat pow(mat a, ll n) {
  mat b(a.size(), vec(a.size(), 0));
  rep(i, a.size()) b[i][i] = 1;
  while (n > 0) {
    if (n & 1) b = mul(b, a);
    a = mul(a, a);
    n >>= 1;
  }
  return b;
}


int main() {
  ll l, a, b;
  cin >> l >> a >> b >> mod;

  keta[0] = 1;
  rep(i, 18) keta[i + 1] = keta[i] * 10;
  rep(i, 19) keta[i]--;
  rep(i, 19) {
    if (keta[i] - a < 0) continue;
    cnt[i] = min(l, (keta[i] - a) / b + 1);
  }
  repr(i, 18) cnt[i + 1] -= cnt[i];
  mat A = {{1, b % mod, a % mod}, {0, 1, 1}, {0, 0, 1}};
  mat ans = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
  rep(i, 18) {
    A[0][0] = A[0][0] * 10 % mod;
    mat res = pow(A, cnt[i + 1]);
    ans = mul(res, ans);
  }
  cout << ans[0][2] << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("goodluckin.txt","r",stdin);
    freopen("goodluckout.txt","w",stdout);
    #endif
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k<=a){
      cout << k;
      return 0;
    }
    if(k<=(a+b)){
      cout << a;
      return 0;
    }
    k = k-(a+b);
    a = a-(min(k,c));
    cout << a;
}


Measured memory_bytes: 3616
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
struct Combination{
private:
    ll N;
    vector<ll> fac, facinv;

public:
    Combination(ll n){
        N = n;
        fac.push_back(1); fac.push_back(1);
        rep(i,2,N+1) fac.push_back(fac[i-1] * i % MOD);
        rep(i,0,N+1) facinv.push_back(power(fac[i], MOD-2));
    }
    ll power(ll x, ll n){
        if(n == 0) return 1LL;
        ll res = power(x * x % MOD, n/2);
        if(n % 2 == 1) res = res * x % MOD;
        return res;
    }
    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
    }
    ll npk(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[n-k] % MOD;
    }
    ll get(ll x){return fac[x];};
    ll getinv(ll x){return facinv[x];};
};
    vector<ll> factor(ll M){ //素因数分解
        vector<ll> dd;
        if(M == 1){
            dd.push_back(1);
            return dd;
        }
        for(ll i = 2; i*i <= M; i++){
            while(M % i == 0){
                dd.push_back(i);
                M /= i;
            }
        }
        if(M != 1) dd.push_back(M);
        sort(dd.begin(), dd.end());
        return dd;
    }
ll val[2000010] = {};

void solve(){
    ll K;
    cin >> K;
    string S;
    cin >> S;
    ll N = S.size();
    Combination cb(2000010);
    rep(i,N,N+K+1){
        val[i] = cb.nck(i,N-1) * cb.power(25, i-(N-1)) % MOD;
    }
    // printa(val, N+K+1);
    ll ans = 1;
    rep(i,N,N+K){
        ans = ans * 26 + val[i];
        ans %= MOD;
    }
    print(ans);
}

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

Measured memory_bytes: 44468
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
    int n;
    cin>>n;
    vector<ll> l(n);
    map<ll,ll> mp;
    for(int i=0;i<n;i++) {
        cin>>l[i];
        mp[l[i]]++;
    }
    sort(l.begin(),l.end());
    l.resize(unique(l.begin(),l.end())-l.begin());
    // for(auto it : l) cout<<it<<" ";
    // cout<<endl;
    n=l.size();
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(l[i]+l[j]>l[k]) 
                {
                    //cout<<i<<" "<<j<<" "<<k<<endl;
                    ans+=mp[l[i]]*mp[l[j]]*mp[l[k]];
                }
            }

        }
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 3632
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

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

void solve(){
	int n = rint;
	
	P[] ps;
	foreach(i; 0 .. n) ps ~= P(rreal, rreal);
	
	real sum = 0.0;
	foreach(p; ps) foreach(q; ps){
		P d = P(p.x - q.x, p.y - q.y);
		sum += sqrt(d.x * d.x + d.y * d.y);
	}
	
	real ans = sum / n;
	
	writefln("%10.10f", ans);
	
}

struct P{
	real x, y;
}

/*
全部でN!×(N-1)個の通路。
通路の種類はN(N-1)/2種類ですべて同回数使われるから
平均は Sum * 2 / N(N-1) それが(N-1)個
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, a; set<int> p[200005];
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n; bool ok=1;
for (int i=0; i<n; i++) {cin >> a; p[a].insert(i);}
int cur=0; a=0;
for (int i=1; i<=n and ok; i++){
	set<int>::iterator it=p[i].lower_bound(cur); 
	if (it==p[i].end()) ok=0;
	else{cur = *it; a++;}
}
if (a==0) cout << "-1";
else cout << (n-a);
return 0;
}


Measured memory_bytes: 19072
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0029
{
    public class Program

    {
        public static void Main(string[] args)
        {
            string[] words = RStAr();
            Dictionary<string, int> res = new Dictionary<string, int>();
            for (int i = 0 ; i < words.Length ; i++)
            {
                if (!res.ContainsKey(words[i])) res.Add(words[i], 0);
                res[words[i]]++;
            }

            Console.WriteLine("{0} {1}"
                ,res.Where(x => x.Value == res.Max(y => y.Value)).First().Key
                ,res.Where(x => x.Key.Length == res.Max(y => y.Key.Length)).First().Key);
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 16408
a = Array.new
for i in 1..3
  a << gets.chomp.split.map(&:to_i)
end
n = gets.to_i
b = Array.new(3) {Array.new 3}
for i in 0..n-1
  bi = gets.to_i
  a.each_with_index do |r, ind|
    j = r.find_index bi
    b[ind][j] = 0 if !j.nil?
  end
end
ans = 'No'
ans = 'Yes' if b[0][0] && b[1][0] && b[2][0]
ans = 'Yes' if b[0][1] && b[1][1] && b[2][1]
ans = 'Yes' if b[0][2] && b[1][2] && b[2][2]
ans = 'Yes' if b[0][0] && b[0][1] && b[0][2]
ans = 'Yes' if b[1][0] && b[1][1] && b[1][2]
ans = 'Yes' if b[2][0] && b[2][1] && b[2][2]
ans = 'Yes' if b[0][0] && b[1][1] && b[2][2]
ans = 'Yes' if b[0][2] && b[1][1] && b[2][0]
puts ans


Measured memory_bytes: 1788
import java.util.Scanner;

class Main {
  public static void main(String[] args){
  Scanner scan = new Scanner(System.in);
  String s = scan.nextLine();
  String t = scan.nextLine();
  if(t.substring(0,t.length()-1).equals(s)){
    System.out.println("Yes");
  } else {
    System.out.println("No");
  }
  
  
  }


}

Measured memory_bytes: 26956
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
vector<vector<int>> g;

void dfs(int v, int p, vector<int> &dist) {
    for(auto nv: g[v]) {
        if(nv == p) continue;
        if(dist[nv] == inf) {
            dist[nv] = dist[v] + 1;
            dfs(nv, v, dist);
        }
    }
}

void solve() {
	cin >> n;
    g.assign(n, vector<int>());
    rep(i, n - 1) {
        int a, b; cin >> a >> b; --a; --b;
        g[a].pb(b);
        g[b].pb(a);
    }
    vector<int> d1(n, inf);
    d1[0] = 0;
    dfs(0, -1, d1);
    int mx = 0, res = 0;
    rep(i, n) {
        if(res < d1[i]) {
            mx = i;
            res = d1[i];
        }
    }
    vector<int> d2(n, inf);
    d2[mx] = 0;
    dfs(mx, -1, d2);
    int ans = 0;
    rep(i, n) {
        chmax(ans, d2[i]);
    }
    ++ans;
    if(ans % 3 == 2) {
        cout << "Second" << endl;
    } else {
        cout << "First" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

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

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

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

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

    int k = 0;
    int l = 0;
    ll max = 0;
    REP(i, N)
    {
        if (S[i] == '0')
        {
            if (i == 0 || S[i - 1] == '1')
            {
                k++;
            }
        }
        while (k > K)
        {
            l++;
            if (l >= N)
                break;
            if (S[l] == '1' && S[l - 1] == '0')
                --k;
        }
        max = std::max(max, i - l + 1);
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

ll n;
vi ans;

void rec(ll p){
    if(p<=n){
        auto s=to_string(p);
        if(s.find('3')!=-1 and s.find('5')!=-1 and s.find('7')!=-1)
            ans.push_back(p);
        rec(p*10+3);
        rec(p*10+5);
        rec(p*10+7);
    }
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	cin>>n;
	rec(0);
	cout<<ans.size();
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int d;
    cin >> d;

    switch (d){
        case 25:
            p("Christmas");
            break;
        case 24:
            p("Christmas Eve");
            break;
        case 23:
            p("Christmas Eve Eve");
            break;
        case 22:
            p("Christmas Eve Eve Eve");
            break;
    }
}


Measured memory_bytes: 256
#include<stdio.h> 
#include<iostream> 
#include<algorithm> 
#include<cstring> 
#define ll unsigned long long 
using namespace std; 
ll N,Cnt[2],P,x,Ans,t,C[105][105]; 
int main() 
{ 
    ll i,j,t=0; 
     
    scanf("%lld%lld",&N,&P); 
    for(i=1;i<=N;i++)scanf("%lld",&x),Cnt[x&1]++; 
     
    Ans=1LL<<Cnt[0]; 
     
    for(i=0;i<=Cnt[1];i++)C[i][0]=1; 
    for(i=1;i<=Cnt[1];i++) 
    for(j=1;j<=i;j++)C[i][j]=C[i-1][j-1]+C[i-1][j]; 
     
    if(P&1) 
    { 
        for(i=1;i<=Cnt[1];i+=2) 
        t+=C[Cnt[1]][i]; 
    } 
    else 
    { 
        for(i=0;i<=Cnt[1];i+=2) 
        t+=C[Cnt[1]][i]; 
    } 
     
    printf("%lld",Ans*t); 
}

Measured memory_bytes: 256
def myAnswer(N:int,A:list) -> int:
   counter = 0
   for a in A:
      if(a % 2==0):
         counter +=1

   return 3**N-2**counter






def modelAnswer():
   tmp=1
def main():
   N = int(input())
   A = list(map(int,input().split()))
   print(myAnswer(N,A[:]))
if __name__ == '__main__':
   main()

Measured memory_bytes: 3060
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int a = sc.nextInt();
			int[] arr = new int[a];
			for (int i = 0; i < a; i++) {
				arr[i] = sc.nextInt();
			}

			System.out.println(Arrays.stream(arr).min().getAsInt() + " " + Arrays.stream(arr).max().getAsInt() + " "
					+ Arrays.stream(arr).mapToLong(r -> r).sum());
		}
	}
}


Measured memory_bytes: 46144
#include<bits/stdc++.h>
using namespace std;
int n,D;
int main(){
	scanf("%d%d",&n,&D);
	D=D*2+1;
	if(n%D==0)printf("%d\n",n/D);
	else printf("%d\n",n/D+1);
	return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
ans = 1000
if len(s) == len(t):
  cnt = 0
  for j in range(len(t)):
    if s[j] != t[j]:
      cnt += 1
  ans = cnt
for i in range(len(s)-len(t)):
  cnt = 0
  for j in range(len(t)):
    if s[i+j] != t[j]:
      cnt += 1
  ans = min(ans,cnt)
print(ans)

Measured memory_bytes: 9076
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):  # リストに重複した要素があるか判定（要素にリストがある場合）
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# s = input()
# n = len(s)
# m = int(s)


# def check(l):
#     x = int("".join(list(map(str, l))))
#     return m >= x and (3 in l) and (5 in l) and (7 in l)


# def solve(l):
#     if len(l) == n:
#         if check(l):
#             # print(int("".join(list(map(str, l)))))
#             return 1
#         else:
#             return 0
#     a = solve(l+[3])
#     b = solve(l+[5])
#     c = solve(l+[7])
#     d = 0
#     if len(l) == 0 or l[-1] == 0:
#         d = solve(l+[0])
#     return a+b+c+d


# print(solve([]))

#n = readints()[0]
#
#ans = 0
#
# for i in range(n+1):
#    s = list(str(i))
#    a = s.count("3")
#    b = s.count("5")
#    c = s.count("7")
#    if a != 0 and b != 0 and c != 0 and a+b+c == len(s):
#        ans += 1
# print(ans)

s = input()

if (s[0] == 'A' and s[1] == 'A' and s[2] == 'A'):
    print("No")
    exit()
if (s[0] == 'B' and s[1] == 'B' and s[2] == 'B'):
    print("No")
    exit()

print("Yes")


Measured memory_bytes: 3956
#coding:utf-8

a, b = map(str, input().split())

if (a == 'H' and b == 'H') or (a == 'D' and b == 'D') :
  print('H')
elif (a == 'H' and b == 'D') or (a == 'D' and b == 'H'):
  print('D')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L



int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long long ans = 0;
    for (int i = 0; i < n-1; i++) {
        for (int j = i + 1; j < n; j++) {
            ans += a[i] * a[j];
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3628
import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    var (_, k) = readIntegerList()
    val s = readLine()!!
    val runLength = runLengthEncode(s)
    var unHappy = 0
    for (i in 1..runLength.lastIndex) {
        if (runLength[i].value == 'L' && runLength[i - 1].value == 'R') {
            unHappy += 2
        }
    }

    var edge = 0
    if (runLength.first().value == 'L') {
        edge++
    }

    if (runLength.last().value == 'R') {
        edge++
    }

    while (k > 0 && unHappy > 0) {
        unHappy -= 2
        k--
    }

    if (k >= 1) {
        edge = 1
    }

    println(s.length - unHappy - edge)
}


data class RunLength<T>(val value: T, val length: Int)

/** O(s.length) */
fun runLengthEncode(s: CharSequence): List<RunLength<Char>> {
    if (s.isEmpty()) return emptyList()

    val runLengthList = mutableListOf<RunLength<Char>>()
    var currentChar = s.first()
    var length = 1
    for (c in s.substring(1)) {
        if (c == currentChar) {
            length++
        } else {
            runLengthList += RunLength(currentChar, length)
            currentChar = c
            length = 1
        }
    }
    runLengthList += RunLength(currentChar, length)

    return runLengthList
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 42440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,x,y;
	cin>>n>>x>>y;
	x--;y--;
	ll ans[2010]={};
	for(ll i=0;i<n;i++){
		ll cnt[n]={};
		for(ll j=0;j<n;j++){
			cnt[j]=-1;
		}
		cnt[i]=0;
		queue<ll>q;
		q.push(i);
		while(q.size()!=0){
			ll now=q.front();
			q.pop();
			if(now!=0&&cnt[now-1]==-1){
				ll j=now-1;
				cnt[j]=cnt[now]+1;
				ans[cnt[j]]++;
				q.push(j);
			}
			if(now!=n-1&&cnt[now+1]==-1){
				ll j=now+1;
				cnt[j]=cnt[now]+1;
				ans[cnt[j]]++;
				q.push(j);
			}
			if(now==x&&cnt[y]==-1){
				ll j=y;
				cnt[j]=cnt[now]+1;
				ans[cnt[j]]++;
				q.push(j);
			}
			if(now==y&&cnt[x]==-1){
				ll j=x;
				cnt[j]=cnt[now]+1;
				ans[cnt[j]]++;
				q.push(j);
			}					
		}
	}
	for(ll i=1;i<n;i++){
		cout << ans[i]/2<<endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;

  int xvec=c-a,yvec=d-b;
  printf("%d %d %d %d",c-yvec,d+xvec,a-yvec,b+xvec);
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  string s; cin>>s;
  int len = s.size();
  int a=len,z=0;
  for (int i=0; i<len; i++) {
    if (s[i]=='A') a=min(a,i);
    if (s[i]=='Z') z=max(z,i);
  }
  cout << z-a+1 << endl;
}

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


Measured memory_bytes: 640
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
int g[101][101]={0},n,vis[101]={0};
int t=0,d[101],f[101];
/*
void dfs(int u){
	d[u]=++t;
	vis[u]=1;
	for(int v=1;v<=n;v++) if (!vis[v]&&g[u][v]==1) dfs(v);
	f[u]=++t;
}*/
stack<int>S;
void dfs2(int i){
	S.push(i); 
	vis[i]=1;
	d[i]=++t;
	while(!S.empty()){
		int u=S.top(),w=-1;
		for (int i=1;i<=n;i++) if (!vis[i]&&g[u][i]==1){w=i;break;}
		if (w!=-1){
			vis[w]=1;
			d[w]=++t;
			S.push(w);
		}
		else{
			f[u]=++t;
			S.pop();
		}
	}
} 
main(){
	int u,v,deg;
	scanf("%d",&n);
	for (int i=0;i<n;i++){
		scanf("%d%d",&u,&deg);
		for (int j=0;j<deg;j++){
			scanf("%d",&v);
			g[u][v]=1;
		}
	}
	for (int i=1;i<=n;i++) if (!vis[i]) dfs2(i);
	for (int i=1;i<=n;i++) printf("%d %d %d\n",i,d[i],f[i]);
}
/*
4
1 1 2
2 1 4
3 0
4 1 3

6
1 2 2 4
2 1 5
3 2 5 6
4 0
5 1 4
6 1 6
*/


Measured memory_bytes: 3252
import collections
s = collections.deque(list(input()))
q = int(input())
cnt = 0
for i in range(q):
    fc = input().split()
    if fc[0] == '1':
        cnt += 1
    else:
        if cnt == 1:
            fc[1] = '1' if fc[1] == '2' else '2'
        if fc[1] == '1':
            s.appendleft(fc[2])
        else:
            s.append(fc[2])
    cnt %= 2
s = list(s)
if cnt == 1:
    s.reverse()
print(*s, sep='')


Measured memory_bytes: 13412
var lines=[];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', function (line) {
  lines.push(line);
});
reader.on('close', function () {
    const vals = lines[0].split(' ');
    const X = vals[0],N = vals[1];
    const ps = lines[1].split(' ');

    if(ps.includes(X)){
        var val1 = Number(X)-1;
        var val2 = Number(X)+1;
        while(ps.includes(val1.toString()) && ps.includes(val2.toString())){
                val1--;
                val2++;
        }

        if(ps.includes(val1.toString()))
            console.log(val2);
        else if(ps.includes(val2.toString))
            console.log(val1);
        else{
            const result = Math.abs(val1 - X) <= Math.abs(val2-X) ? val1 : val2;
            console.log(result);
        }
        return;
    }

    console.log(X);
});

Measured memory_bytes: 30084
import sys

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

s=[]

i_b,j_b=0,0
for i in range(h):
    for j in range(w):
        if m[i][j] =="#":
            if i<i_b or j<j_b:
                print("Impossible")
                sys.exit()
            else:
                i_b,j_b=i,j
print("Possible")

Measured memory_bytes: 38384
#include<iostream>

using namespace std;

int l[100];

int main() {
  int n, x;
  cin >> n >> x;
  int d = 0;
  for (int i = 0; i < n; i++) {
    cin >> l[i];
    d += l[i];
    if (d > x) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << n + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h,w,q,ans=0xfffffff;
string s[15];
int main()
{
	cin>>h>>w>>q;
	for(int i=0;i<h;++i)
	 cin>>s[i];
	for(int a=0;a<(1<<(h-1));++a)
	{
		vector<int> b;
		for(int i=0;i<h-1;++i)
		 if(a&(1<<i)) b.push_back(i+1);
		b.push_back(h);
		int cur=__builtin_popcount(a),k=b.size();
		vector<int>cnt(k);
		for(int j=0;j<w;++j)
		{
			int t=0;
			vector<int> add(k);
			for(int i=0;i<h;++i)
			{
				if(i==b[t]) ++t;
				add[t]+=s[i][j]-'0';
			}
			for(int i=0;i<k;++i)
			 cnt[i]+=add[i];
			bool f=1;
			for(int i=0;i<k;++i)
			 if(cnt[i]>q) f=0;
			if(f) continue;
			++cur;
			for(int i=0;i<k;++i)
			 cnt[i]=add[i];
			f=1;
			for(int i=0;i<k;++i)
			 if(cnt[i]>q) f=0;
			if(!f) cur=0xfffffff;
		}
		ans=min(ans,cur);
	}
	cout<<ans;
	return 0;
}

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

int main() {
  int n;
  cin >>n ;
  
  vector<int>p(n,0);
  for(int i=0; i<n; i++){
    cin >>p[i];
  }
  
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  int max =p[0];
  
  int sum=0;
  for(int i=0; i<n; i++){
    sum+=p[i];
  }
  
  cout <<sum-max/2 <<endl;
}





Measured memory_bytes: 256
fn solve(n: usize) -> usize {
    if n < 10 {
        n
    } else if n < 100 {
        9
    } else if n < 1000 {
        9 + n - 100 + 1
    } else if n < 10000 {
        909
    } else if n < 100000 {
        909 + n - 10000 + 1
    } else {
        90909
    }
}

fn solve_test() {
    assert_eq!(solve(11), 9);
    assert_eq!(solve(139), 46);
    assert_eq!(solve(100000), 90909);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let n = parse_line!(usize);
    println!("{}", solve(n));
}


Measured memory_bytes: 4352
n = int(input())
a = list(map(int,input().split()))
box = [0]*n
for i in range(n,0,-1):
  k = a[i-1]
  c = 0
  for j in range(1,n//i+1):
    c += box[i*j-1]
  if c%2 != k:
    box[i-1] = 1
ans = []
w = 0
for m in range(n):
  if box[m] == 1:
    w += 1
    ans.append(str(m+1))
print(w)
print(' '.join(ans))

Measured memory_bytes: 17212