akhauriyash/Code-Regression huggingface dataset:
//  Suraj Saste

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi pair<ll,ll>
#define in insert
#define fe first
#define se second
#define ms(x,i) memset(x,i,sizeof(x))
#define prec(x) cout<<std::setprecision(x)
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll fpow(ll n, ll k, ll p=mod) {ll r=1; n=n%p; while(k>0){ if(k&1){ r=(r*n)%p; } k=k>>1; n=(n*n)%p; } return r;}
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;}

vector<ll> dp[3003];
string s,t,ans="";

void lcs(ll i,ll j)
{
	if(dp[i][j]==0||i<0||j<0)return;
	while(dp[i][j]==dp[i-1][j])i--;
    while(dp[i][j]==dp[i][j-1])j--;
	if(dp[i][j]!=dp[i-1][j]&&dp[i][j]!=dp[i][j-1])
    {
    	ans+=s[i-1];
    	lcs(i-1,j-1);
    }
}	

int main()
{
	fast;
	cin>>s>>t;
	for(ll i=0;i<=s.size();i++)
	{
		for(ll j=0;j<=t.size();j++)
		{
			dp[i].pb(0);
		}
	}
    for(ll i=0;i<s.size();i++)
	{
		for(ll j=0;j<t.size();j++)
		{
			if(s[i]==t[j])
			{
				dp[i+1][j+1]=dp[i][j]+1;
			}
			else
			{
				dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
			}
		}
	}
	lcs(s.size(),t.size());
	reverse(ans.begin(),ans.end());
	cout<<ans;
	return 0;
}


Measured memory_bytes: 82816
#include<stdio.h>
struct Node
{
  int p;
  int l;
  int r;
};

struct Node T[100000];

void preorder(int id)
{
  printf(" %d",id);
  if(T[id].l!=-1) 
    {
      preorder(T[id].l);
    }
  if(T[id].r!=-1)
    {
      preorder(T[id].r);
    }
}

void inorder(int id)
{
  if(T[id].l!=-1)
    {
      inorder(T[id].l);
    }
  printf(" %d",id);
  if(T[id].r!=-1)
    {
      inorder(T[id].r);
    }
}

void postorder(int id)
{
  if(T[id].l!=-1)
    {
      postorder(T[id].l);
    }
  if(T[id].r!=-1)
    {
      postorder(T[id].r);
    }
  printf(" %d",id);
}

main()
{
  int n,i,id;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    {
      T[i].p=T[i].l=T[i].r=-1;
    }
  
  for(i=0;i<n;i++)
    {
      scanf("%d",&id);
      scanf("%d %d",&T[id].l,&T[id].r);
      T[T[id].l].p=id;
      T[T[id].r].p=id;
    }
  printf("Preorder\n");
  for(i=0;i<n;i++)
    {
      if(T[i].p==-1)
	{
	  preorder(i);
	  printf("\n");
	  break;
	}
    }
  
  printf("Inorder\n");
  inorder(i);
  printf("\n");
  
  printf("Postorder\n");
  postorder(i);
  printf("\n");
  return 0;
}

Measured memory_bytes: 616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int n = sc.nextInt();

		Node_BT[] nodes = new Node_BT[n];
		for(int i=0; i<n; i++) {
			nodes[i] = new Node_BT();
		}

		for(int i=0; i<n; i++) {
			int id = sc.nextInt();
			int left = sc.nextInt();
			int right = sc.nextInt();
			nodes[id].id = id;
			nodes[id].left = left;
			nodes[id].right = right;

			if(left != -1) {
				nodes[left].parent = id;
			}
			if(right != -1) {
				nodes[right].parent = id;
			}
		}

		for(int i=0; i<n; i++) {
			if(nodes[i].parent == -1) {
				System.out.println("Preorder");
				nodes[i].preOrder(nodes);
				System.out.println();
				System.out.println("Inorder");
				nodes[i].inOrder(nodes);
				System.out.println();
				System.out.println("Postorder");
				nodes[i].postOrder(nodes);
				System.out.println();
				break;
			}
		}

	}

	static class Node_BT {
		int id;
		int left;
		int right;
		int parent = -1;

		void preOrder(Node_BT[] nodes) {
			System.out.print(" " + id);
			if(left != -1) {
				nodes[left].preOrder(nodes);
			}
			if(right != -1) {
				nodes[right].preOrder(nodes);
			}
		}

		void inOrder(Node_BT[] nodes) {
			if(left != -1) {
				nodes[left].inOrder(nodes);
			}
			System.out.print(" " + id);
			if(right != -1) {
				nodes[right].inOrder(nodes);
			}
		}

		void postOrder(Node_BT[] nodes) {
			if(left != -1) {
				nodes[left].postOrder(nodes);
			}
			if(right != -1) {
				nodes[right].postOrder(nodes);
			}
			System.out.print(" " + id);
		}
	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 24468
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
ll seg[1000009];
ll m[1000009];
pll p[200009];
vll lq[200009];
vll rq[200009];
ll update(ll v,ll vl,ll vr,ll l,ll r,ll add)
{
	if(l>r)
		return (seg[v]+m[v]);
	if(vl==l&&vr==r)
		seg[v]+=add;
	else
	{
		ll mid=(vl+vr)/2;
		m[v]=max(update(2*v,vl,mid,l,min(mid,r),add),update((2*v)+1,mid+1,vr,max(l,mid+1),r,add));
	}
	return seg[v]+m[v];
}
ll get(ll v,ll vl,ll vr,ll l,ll r)
{
	if(l>r)
		return -inf;
	if(vl==l&&vr==r)
		return seg[v]+m[v];
	ll mid=(vl+vr)/2;
	return seg[v]+(max(get(2*v,vl,mid,l,min(mid,r)),get((2*v)+1,mid+1,vr,max(l,mid+1),r)));
}
int main()
{
	FAST
	#ifdef ayk_16
	    time_taken_start
		freopen("input.txt","rt",stdin);
		freopen("output.txt","wt",stdout);
	#endif
	ll n,mq;
	cin>>n>>mq;
	ll x,y,z;
	for(ll i=0;i<mq;i++)
	{
		cin>>x>>y>>z;
		lq[x].pb(i);
		rq[y].pb(i);
		p[i].ff=x;
		p[i].ss=z;
	}
	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		for(auto z:lq[i])
		{
			pll j=p[z];
			update(1,0,n,0,j.ff-1,j.ss);
		}
		x=get(1,0,n,0,i-1);
		ans=max(ans,x);
		update(1,0,n,i,i,x);
		for(auto z:rq[i])
		{
			pll j=p[z];
			update(1,0,n,0,j.ff-1,-j.ss);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 35328
#include <bits/stdc++.h>
  
using namespace std;
  
#define MAX 1010
  
struct Point{
    double x,y;
    Point(){}
    Point(double x,double y) : x(x),y(y) {}
};
  
int N,X,Y;
vector<int> G[MAX];
  
double getDist(Point &a,Point &b){
    return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
  
void init(){
    for(int i = 0 ; i < MAX ; i++){
	G[i].clear();
    }  
}
  
void solve(){
    int d[MAX] = {0};
    queue<int> Q; Q.push(0);
    bool can = true;
   
    while(!Q.empty()){
	int v = Q.front(); Q.pop();
	for(int i = 0 ; i < (int)G[v].size() ; i++){
	    int to = G[v][i];
	    if(d[to] == 0){
		d[to] = d[v] + 1;
		if(v > 0 && X > Y) can = false;
		Q.push(to);
	    }
	}
    }
   
    if(can){
	cout << *max_element(d+1,d+N+1)*X << endl;
    }else{
	cout << "You're always welcome!" << endl;
    }
}
  
int main(){
    int Tc;
    cin >> Tc;
    while(Tc--){
	init();
	Point sp;
	vector<Point> p;
	cin >> N >> X >> Y;
	cin >> sp.x >> sp.y;
	p.resize(N);
	for(int i = 0 ; i < N ; i++){
	    cin >> p[i].x >> p[i].y;
	    if(getDist(sp,p[i]) <= 10){
		G[0].push_back(i+1);
	    }
	}
	for(int i = 0 ; i < N ; i++){
	    for(int j = 0 ; j < N ; j++){
		if(i == j) continue;
		if(getDist(p[i],p[j]) <= 50){
		    G[i+1].push_back(j+1);
		}
	    }
	}
	solve();
    }
    return 0;
}

Measured memory_bytes: 7096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

string s;
int n, k;

int main()
{
    cin >> n >> s >> k;
    for (int i = 0; i < n; i++)
    {
        if (s[i] != s[k - 1])
            s[i] = '*';
    }
    cout << s << endl;
}

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

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    if(n==1&&m==0){
        cout<<"0"<<endl;
        return 0;
    }
    string ans(n,'a');
    for (int i = 0; i < m; ++i) {
        int s,c;
        cin>>s>>c;
        if(c==0&&s!=n){
            cout<<"-1"<<endl;
            return 0;
        }
        --s;
        if(ans[s]=='a')ans[s]='0'+c;
        else if(ans[s]!='0'+c){
            cout<<"-1"<<endl;
            return 0;
        }
    }
    for (int i = 0; i < n; ++i) {
        if(ans[i]=='a'){
            if(i==0)ans[i]='1';
            else ans[i]='0';
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    int n, s;
    cin >> n >> s;
    vector<int> v(n+1), w(n+1);
    for(int i = 1; i <= n; i++){
        cin >> v[i] >> w[i];
    }

    ll dp[10010];
    for(int j = 0; j <= s; j++){
        dp[j] = 0;
    }

    for(int j = 0; j <= s; j++){
        for(int i = 1; i <= n; i++){
            if(j-w[i] >= 0){
                dp[j] = max(dp[j], dp[j-w[i]]+v[i]);
            }
        }
    }

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


Measured memory_bytes: 3160
N=int(input())
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table
print(sum(num_divisors_table(N-1)))

Measured memory_bytes: 16780
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        long a = sc.nextInt();
        long v = sc.nextInt();
        long b = sc.nextInt();
        long w = sc.nextInt();
        long t = sc.nextInt();

        if(w >= v){
            System.out.println("NO");
            return;
        }
        if(Math.abs(a - b) <= Math.abs(v - w) * t){
            System.out.println("YES");
            return;
        }


        System.out.println("NO");

    }

}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s; cin >> s;
	
	ll k; cin >> k;

	vvl dp(k+1,vl(2));
	dp[0][0] = 1;

	for (char c: s) {
		ll x = c-'0';
		vvl ndp(k+1,vl(2));
		FOR(i,0,k+1) FOR(lt,0,2) {
			FOR(d,0,10) {
				if (!lt && d > x) break;
				ll ni = i + (d > 0);
				ll nlt = lt || (d < x);
				if (ni > k) continue;
				ndp[ni][nlt] += dp[i][lt];
			}
		}
		dp = ndp;
	}

	ll res = 0;
	FOR(lt,0,2) res += dp[k][lt];
	cout << res << endl;
}



Measured memory_bytes: 256
/*
* @Author: Kabid
* @Date:   2020-04-26 18:01:07
* @Last Modified by:   Kabid
* @Last Modified time: 2020-05-02 18:13:24
*/
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<set>
#include<map>
#include<algorithm>
#define ll long long
#define  in(x) scanf("%d",&x);
#define out(x) printf("%d",x);
#define  ins(x)  scanf("%s",x);
#define outs(x) printf("%s",x);
#define lin puts("");
#define _ putchar(' ');
using namespace std;

int t;       //test cases
int i = 1, j=0;	 //iterators
int n=0, k, p; //variables
int w;
int a, b, c, d;
string s;
set<string>st;
int main() {
	cin>>k>>a>>b;
	for(i=a;i<=b;i++){
		if(i%k==0){
			j=1;
			puts("OK");
			break;
		}
	}
	if(j==0){
		puts("NG");
	}
	j=0;

	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;


int main(){
    char a = 'a';
    char z = 'z';
    char n;
    cin >> n;
    int x;
    x = (int) n;
    if(a <= (int)x && (int)z >= x){
        cout << "a" << endl;
    } else {
        cout << "A" << endl;
    }
    
}

Measured memory_bytes: 3628
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>	
#include <utility>
using namespace std;

int main(){
    long n,m;
    vector<pair<long,long>> a;
    scanf("%ld %ld",&n,&m);
    a.reserve(n);
    for (int i=0;i<n;i++){
        long tmp1,tmp2;
        scanf("%ld %ld",&tmp1,&tmp2);
        a.push_back(pair<long, long>(tmp1,tmp2));
    }
    sort(a.begin(),a.end(),[](pair<long,long> x, pair<long,long> y) -> long {return ( x.first < y.first );});
    int i = 0;
    long total = 0;
    while (m > 0){
        long buy_each = min(a[i].second,m);
        total += a[i].first*buy_each;
        m -= buy_each;
        i++;
    }
    printf("%ld\n",total);
}

Measured memory_bytes: 1792
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let v: Vec<&str> = s.split_whitespace().collect();
    let (n, m) = (v[0].parse::<usize>().unwrap(), v[1].parse::<usize>().unwrap());

    let mut lamps = Vec::new();
    for _i in 0..m {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let s = buf.split_whitespace().skip(1).map(|i| i.parse::<usize>().unwrap() - 1).collect::<Vec<usize>>();
        lamps.push(s);
    }

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let p = buf.split_whitespace().map(|i| i.parse::<usize>().unwrap()).collect::<Vec<usize>>();

    let mut ans = 0;
    'a: for bit in 0..(1 << n) {
        // スイッチのON/OFFの情報
        let mut swc = vec![false; n];
        for sft in 0..n {
            if (bit >> sft) & 1 == 1 {
                swc[sft] = true;
            }
        }

        for (i, ls) in lamps.iter().enumerate() {
            if !ls.iter().filter(|&l| swc[*l]).count() % 2 == p[i] {
                continue 'a;
            }
        }
        ans += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
def main():
    # 入力
    n = int(input())
    s = input()

    set1 = set()
    set2 = set()
    set3 = set()
    for x in s:
        for x2 in set2:
            _x2 = x2+x
            set3.add(_x2)
        for x1 in set1:
            _x1 = x1+x
            set2.add(_x1)
        set1.add(x)

    print(len(set3))


main()


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#define dump(a) cout << (a) << endl;
typedef long long ll;
ll mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    double t, a;
    cin >> t >> a;
    vector<double> h(n);
    for (int i = 0; i < n; i++ ) cin >> h[i];
    int x = 0;
    double mi = fabs( a-(t-h[0]*0.006));
    for( int i = 0; i < n; i++ ) {
        if( mi > fabs( a-(t-h[i]*0.006))) {
            mi = fabs( a-(t-h[i]*0.006));
            x = i;
        }
    }
    dump(x+1);
    return 0;  
}

Measured memory_bytes: 256
import Control.Monad
import Data.List
import Data.Ord

main = do
  [n, m] <- map read . words <$> getLine
  cards <- map read . words <$> getLine
  reads <- replicateM m $ map read . words <$> getLine
  let cs = sort cards
  let xs = sort' $ concat $ sortOn Down (map reverse reads)
  print $ foldl' (+) 0 (func xs cs)

sort' :: [Int] -> [Int]
sort' [] = []
sort' (b:a:xs) = replicate a b ++ sort' xs

func :: [Int] -> [Int] -> [Int]
func xs = zipWith max (xs ++ repeat 0)


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

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

using namespace std;

typedef long long ll;

int main(){
  int T;
  cin >> T;
  while( T-- ){
    ll src,dst;
    cin >> src >> dst;
    int use = 0;
    if( src & 1LL ) ++use, ++src;
    if( dst & 1LL ) ++use, --dst;
    bool found = false;
    while( src != dst ){
      if( src == 0 ) {
        found = true;
        cout << use+__builtin_popcount(dst-src) << endl;
        break;
      }
      for(int shift=31;shift>=0;shift--){
        ll coef = (1LL<<shift);
        if( llabs(src) >= coef && src % coef == 0LL ) {
          bool used = false;
          if( src+coef <= dst ){
            ++use;
            src += coef;
            break;
          }
        }
      }
    }
    if( !found ) cout << use << endl;
  }
  return 0;
}

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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

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

	ll a, b, c, d;
  	cin >> a >> b >> c >> d;
  	cout << max(max(a * c, a * d), max(b * c, b * d)) << '\n';

    return 0;
}


Measured memory_bytes: 3664
n = gets.to_i

a = []

n.times{|i|
    a[i] = gets.chomp
}

ary = []

n.times{|i|
    break if ary.length > 1000000
    x = a.shift
    case x
    when "deleteFirst" then
        ary.shift
    when "deleteLast" then
        ary.pop
    else
        cmd = x.split[0]
        i = x.split[1].to_i
        case cmd
        when "insert" then
            ary.unshift(i)
        when "delete" then
            if (index = ary.index(i)) != nil then
                ary.delete_at(index)
            end
        end
    end
}

puts ary.join(" ")


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

using namespace std;

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

struct SegmentTree {
private:
    int n;
    vector<int> node;
public:
    SegmentTree(vector<int> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2*n-1,0);
        for (int i = 0;i < sz;++i) node[i+n-1] = v[i];
        for (int i = n-2;i >= 0;--i) node[i] = max(node[2*i+1],node[2*i+2]);
    }
    void update(int x,int val) {
        x += (n-1);
        node[x] = val;
        while (x > 0) {
            x = (x-1)/2;
            node[x] = max(node[2*x+1],node[2*x+2]);
        }
    }
 
    int getmax(int a,int b,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return 0;
        if (a <= l && r <= b) return node[k];
        int vl = getmax(a,b,2*k+1,l,(l+r)/2);
        int vr = getmax(a,b,2*k+2,(l+r)/2,r);
        return max(vl,vr);
    }
 
    int find(int a,int b,int x,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l || node[k] <= x) return b;
        if (k >= n-1) return k-n+1;
        int vl = find(a,b,x,2*k+1,l,(l+r)/2);
        if (vl != b) return vl;
        return find(a,b,x,2*k+2,(l+r)/2,r);
    }
};

int main() {
    int n,q;
    cin >> n >> q;
    vector<int> a(n);

    // for (int i = 0;i < n;++i) cin >> a[i];
    for (int i = 0;i < n;++i) scanf("%d",&a[i]);
    SegmentTree seg(a);
    for (int i = 0;i < q;++i) {
        int t,x,v;
        // cin >> t >> x >> v;
        scanf("%d%d%d",&t,&x,&v);
        if (t == 1) seg.update(x-1,v);
        else if (t == 2) cout << seg.getmax(x-1,v) << newl;
        else cout << seg.find(x-1,n,v-1)+1 << newl;
    }
}

Measured memory_bytes: 7032
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		out.println(""+in.next().charAt(0)+in.next().charAt(0)+in.next().charAt(0));
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 9684
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n)	 for(int i = 0; i < (n); i++)
#define all(a)		 begin(a), end(a)

typedef long long int		   ll;
typedef long long unsigned int llu;

void solve(ll A, ll B) {
	if(A % 3 == 0 or B % 3 == 0 or(A + B) % 3 == 0) printf("Possible");
	else printf("Impossible");
}

int main() {
	ll A;
	ll B;
	scanf("%lld", &A);
	scanf("%lld", &B);
	solve(A, B);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
long long mod=1000000007;
int M=8050000;
long long fact[8100000];
long long inv[8100000];
long long factinv[8100000];
long long dp[2100][2100];
long long C(int a,int b){
	return fact[a]*factinv[a-b]%mod*factinv[b]%mod;
}
int N;
int K;
long long calc(int a,int b){
	if(dp[a][b]!=-1)return dp[a][b];
	if(a==0&&b==0)return 1;
	long long ret=0;
	if(a){
		ret+=calc(a-1,b);
	}
	if(a<b){
		ret=(ret+calc(a,b-1)*C((K-1)*b+a-1,K-2))%mod;
	}
	return dp[a][b]=ret;
}
int main(){
	inv[1]=fact[0]=factinv[0]=1;
	for(int i=2;i<M;i++)inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	for(int i=1;i<M;i++)fact[i]=fact[i-1]*i%mod;
	for(int i=1;i<M;i++)factinv[i]=factinv[i-1]*inv[i]%mod;
	int a,b;scanf("%d%d",&a,&b);
	N=a;
	K=b;
	if(K==1){
		printf("1\n");
		return 0;
	}
	for(int i=0;i<=a;i++)for(int j=0;j<=a;j++)
		dp[i][j]=-1;
	printf("%lld\n",calc(a,a)*fact[a]%mod);
}

Measured memory_bytes: 221824
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007LL
using namespace std;

int main(void){
    map<string, string> m;
    m["Sunny"] = "Cloudy";
    m["Cloudy"] = "Rainy";
    m["Rainy"] = "Sunny";
    string S;
    cin >> S;
    cout << m[S] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
    int a,b;
    cin >> a >> b;

    if (a<= b)
    {
        cout <<a << endl;
    }else
    {
        cout << a-1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long 

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int ans = 0;
    if(K % 2 == 0) {
        int a = (N + K / 2) / K;
        int b = N / K;
        cout << a * a * a + b * b * b  << endl;
    } else {
        cout << (N / K) * (N / K) * (N / K) << endl;
    }

    return 0;
}

Measured memory_bytes: 3668
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE GADTs                #-}
{-# LANGUAGE OverloadedStrings    #-}
{-# LANGUAGE RankNTypes           #-}
{-# LANGUAGE ScopedTypeVariables  #-}
{-# LANGUAGE Strict               #-}
{-# LANGUAGE TypeApplications     #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Data.ByteString.Char8 (ByteString, putStrLn)
import qualified Data.ByteString.Char8 as BS
import           Prelude               hiding (getLine, print, putStrLn, readLn,
                                        unwords, words)

import           Control.Monad         (replicateM)
import           Data.List             (sort)
import           Data.List.Extra       (nubOrd)
import           Data.Maybe            (isJust)
import           Prelude               (print)

class (Read a, Show a) =>
      CPString a
  where
  cpRead :: String -> a
  cpShow :: a -> ByteString
  cpRead = read
  cpShow = BS.pack . show

instance CPString ByteString where
  cpRead = BS.pack
  cpShow = id

instance CPString String where
  cpRead = id
  cpShow = BS.pack

instance CPString Char where
  cpRead [a] = a
  cpShow = BS.pack . pure

instance CPString Int

instance CPString Integer

instance CPString Float

instance CPString Double

instance CPString Rational

instance CPString a => CPString [a]

readLine :: CPString a => IO [a]
readLine = fmap (cpRead . BS.unpack) . BS.words <$> BS.getLine

printLn :: CPString a => a -> IO ()
printLn = putStrLn . cpShow

main :: IO ()
main = do
  [k] <- readLine @Int
  printLn $ solve k

solve :: Int -> Int
solve k = sum [gcd3 a b c | a <- [1 .. k], b <- [1 .. k], c <- [1 .. k]]

gcd3 :: Int -> Int -> Int -> Int
gcd3 a b c = gcd (gcd a b) c


Measured memory_bytes: 4168
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int sum[2001][2001];
ll f(int x1,int y1,int x2,int y2){
    return sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1];
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,k;cin>>n>>k;
    int sum[n+1];
    sum[0]=0;
    int p[n];
    rep(i,0,n){
        cin>>p[i];
        sum[i+1]=sum[i]+p[i];
    }
    int ans=0;
    rep(i,0,n-k+1){
        ans=max(ans,sum[i+k]-sum[i]);
    }
    double anss=ans/2.0+k/2.0;
    cout<<fixed<<setprecision(12)<<anss<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
//library begin
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int log(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
int mypow(int a,int b){
    if(b==0)return 1;
    if(b==1)return a;
    int t=mypow(a,b/2);
    if(b%2==0)return t*t;
    return t*t*a;
}
//library end
int n,k;
int p[400000];
double d[400000];
double sum=0;
double ans=0;
signed main(){
    cin>>n>>k;
    rep(i,n){
        cin>>p[i];
        d[i]=0.5000000*(1+p[i]);
    }
    rep(i,k)sum+=d[i];
    ans=sum;
    for(int i=k;i<n;i++){
        sum=sum+d[i]-d[i-k];
        if(sum>ans)ans=sum;
    }
    printf("%.7lf",ans);
    cout<<endl;
    return 0;
}


Measured memory_bytes: 5888
/**
 *      purpose : ABC 133 C
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64_t INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int64 l, r; cin >> l >> r;
  int64 mod = 2019;

  if (r - l + 1 >= 2019) {
    print(0); return 0;
  }

  int64 ans = INF64;

  for (int64 i = l; i <= r; ++i) {
    for (int64 j = l; j <= r; ++j) {
      if (i == j) continue;
      chmin(ans, (i * j) % mod);
    }
  }
  print(ans);

  return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
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; }

string S;

int main()
{
    cin >> S;

    string S1;
    S1.push_back(S[0]);
    S1.push_back(S[1]);
    string S2;
    S2.push_back(S[2]);
    S2.push_back(S[3]);


    if (S1 == "00" && S2 == "00")
    {
        cout << "NA" << "\n";
        return 0;
    }

    int a = atoi(S1.c_str());
    int b = atoi(S2.c_str());

    if (0 < a && a <= 12 && 0 < b && b <= 12)
    {
        cout << "AMBIGUOUS" << "\n";
        return 0;
    }

    if (S2 == "00" && 1 <= a && a <= 12)
    {
        cout << "MMYY" << "\n";
        return 0;
    }

    if (S1 == "00" && 1 <= b && b <= 12)
    {
        cout << "YYMM" << "\n";
        return 0;
    }
    
    if (1 <= b && b <= 12)
    {
        cout << "YYMM" << "\n";
        return 0;
    }

    if (1 <= a && a <= 12)
    {
        cout << "MMYY" << "\n";
        return 0;
    }
    
    cout << "NA" << "\n";

    return 0;
}


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

using namespace std;
using int64 = long long int;

constexpr int MaxAB = 100000 + 10;
int64 P[2][MaxAB];
int L[2];

pair<int, int> LeftRight(int64 position, int type)
{
    if (L[type] == 1)
    {
        return make_pair(0, 0);
    }

    auto where = upper_bound(P[type], P[type] + L[type], position);
    if (where > P[type] + L[type])
    {
        where--;
    }

    int index = static_cast<int>(where - P[type]);
    if (index == 0)
        return make_pair(0, 1);
    else if (index == L[type])
        return make_pair(L[type] - 2, L[type] - 1);
    else
        return make_pair(index - 1, index);
}

int64 Query(int64 position)
{
    auto shrine = LeftRight(position, 0);
    auto temple = LeftRight(position, 1);
    array<int64, 4> dests = { P[0][shrine.first], P[0][shrine.second], -P[1][temple.first], -P[1][temple.second] };
    sort(dests.begin(), dests.end());

    int64 answer = 1LL << 50;

    do
    {
        int64 current = position;
        int64 cost = 0;
        bool positive = false, negative = false;
        for (auto next : dests)
        {
            cost += abs(current - abs(next));
            current = abs(next);
            if (next > 0)
                positive = true;
            else
                negative = true;

            if (positive && negative)
                break;
        }
        answer = min(answer, cost);
    } while (next_permutation(dests.begin(), dests.end()));

    return answer;
}

int main()
{
    int a, b, q;
    cin >> a >> b >> q;
    L[0] = a;
    L[1] = b;
    int index = 0;

    for (int i = 0; i < a; i++)
    {
        cin >> P[0][i];
    }

    for (int i = 0; i < b; i++)
    {
        cin >> P[1][i];
    }

    for (int i = 0; i < q; i++)
    {
        int64 x;
        cin >> x;
        cout << Query(x) << endl;
    }
}

Measured memory_bytes: 2816
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int K = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if (Check(K, A, B) == true) {
			System.out.println("OK");
		} else {
			System.out.println("NG");
		}
	}
	
	public static boolean Check(int k, int a, int b) {
		boolean result = false;
		
		for (int i = a; i <= b; i++) {
			if (i % k == 0) {
				result = true;
				break;
			}
		}
		
		return result;
	}
}


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

typedef long long ll;
typedef long double ld;

int main(){
    ll a,b;
    cin >> a >> b;
    ll c(1),i(0);
    while(c<b){
        c--;
        c += a;
        i++;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

// [?????????L][?????????R][?????????L][?????????R]??§?????????(??????:1,??????:-1)
int match(int l1, int r1, int l2, int r2) {
	if(l1 == 5 && r1 == 5) return -1;

	int res;
	if(l1 != 5) {
		if(l2 != 5) {
			res = -match(min(l2 + l1, 5), r2, l1, r1);
			if(res == 1) return 1;
		}
		if(r2 != 5) {
			res = -match(l2, min(r2 + l1, 5), l1, r1);
			if(res == 1) return 1;
		}
	}
	if(r1 != 5) {
		if(l2 != 5) {
			res = -match(min(l2 + r1, 5), r2, l1, r1);
			if(res == 1) return 1;
		}
		if(r2 != 5) {
			res = -match(l2, min(r2 + r1, 5), l1, r1);
			if(res == 1) return 1;
		}
	}
	return -1;
}

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

	int l1, r1, l2, r2;
	cin >> l1 >> r1 >> l2 >> r2;
	if(match(l1, r1, l2, r2) == 1) {
		cout << "ISONO" << endl;
	}
	else {
		cout << "NAKAJIMA" << endl;
	}
}

Measured memory_bytes: 1188
#include<iostream>

using namespace std;

int main() {
  string s;
  cin >> s;
  if (s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi") {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

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

	long long sum=0;

	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=k;j++)
		{
			for(int p=1;p<=k;p++)
			{
				int x=__gcd(i,j);
				int y=__gcd(x,p);

				sum=sum+y;
			}
		}
	}	
	cout<<sum<<endl;

	return 0;
}

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

#define int long long

int a, b, c, x, y, ans;

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> a >> b >> c >> x >> y;
	
	int tmp = min(x, y);
	ans += min(2 * tmp * c, tmp * (a + b));
	x -= tmp;
	y -= tmp;
	cout << ans + min(x * a, 2 * x * c) + min(y * b, 2 * y * c) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define Num 1000000007
// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{

    int n;
    cin>>n;
    stack < int > ans;
    while(n){
        ans.push(abs(n)%2);
        n-=ans.top();
        n=n/(-2);
    }
    if(ans.size()==0) cout<<0<<endl;
    else{
        while(!ans.empty()){
            cout<<ans.top();
            ans.pop();
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
	int nn;
	cin >> nn;
	vector<int> aa(nn);
	
	rep(i,nn) cin >> aa[i];
	
	vector<int> res(nn);
	
	int tmp1,tmp2=0;
	for(int i=1;i<nn;i++){
		tmp1=aa[i-1]^aa[i];
		res[i] = res[i-1]^tmp1;
		
		tmp2 ^= res[i];
		
	}
	
	//rep(i,nn) printf("%d ",res[i]);
	
	
	tmp1 = aa[0]^tmp2;
	
	//cout << tmp1 << endl;
	rep(i,nn){
		res[i] ^= tmp1;
		printf("%d ",res[i]);
	}
	
	
	return 0;
}

Measured memory_bytes: 4824
// 入力マクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::min;
fn main() {
    input! {
        n: usize,
        x: usize1,
        y: usize1
    }

    let mut dp = vec![0; n-1];

    for start in 0..n-1 {
        let mut count = 0;
        for goal in start+1..n {
            let shortest = min(goal - start, ((x as i32 - start as i32).abs() + (y as i32 - goal as i32).abs() + 1) as usize);
            dp[shortest - 1] += 1;
        }
    }

    for ans in dp {
        println!("{}", ans);
    }
}


Measured memory_bytes: 4352
#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;
    vector<ll> A(N + 2, 0);
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }
    ll orig = 0;
    for (int i = 0; i <= N; i++) {
        orig += abs(A[i] - A[i + 1]);
    }
    vector<ll> adv(N + 2);
    for (int i = 1; i <= N; i++) {
        adv[i] = abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1]) - abs(A[i - 1] - A[i + 1]);
    }
    for (int i = 1; i <= N; i++) {
        cout << orig - adv[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 2816
require 'pp'

n, m, q = gets.split.map(&:to_i)
x = Array.new(q)
memo = {}
q.times do |i|
    a = gets.split.map(&:to_i)
    x[i] = a
end

path = [[[1], 1]]
cand = []
while path.empty?.!
    t = path.pop
    if t[1] >= n
        cand << t[0]
    else
        t[0][-1].upto(m) do |i|
            path.push([t[0] + [i], t[1] + 1])
        end
    end
end

#pp cand

max = 0
cand.each do |ca|
    sum = 0
    x.each do |q|
        if ca[q[1]-1] - ca[q[0]-1] == q[2] 
            sum += q[3]
        end
    end

    if max < sum
        max = sum
    end
end

puts max


Measured memory_bytes: 22660
#include<bits/stdc++.h>
#include<cstring>
//#define Mfc_Tanzim
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ff first
#define ss second
#define all(v) (v.begin(), v.end())
#define pi acos(-1.0)
#define FastRead ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define bug(a) cerr << #a << " : " << a << endl
using namespace std;

ll posx[] = {1,-1, 0, 0};
ll posy[] = {0, 0, 1,-1};

int main()
{
    FastRead

#ifdef Mfc_Tanzim
    freopen("input.txt","r", stdin);
    // freopen("output.txt","w", stdout);
#endif // Mfc_Tanzim

    ll n = 5;
    //cin >> n;
    vector<ll>v(5);

    for(auto &i: v)
        cin >> i;

    for(ll i=0; i<n; i++)
    {
        if(v[i]==0)
        {
            cout << i+1 << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define MAXN 200005
#define mo 994711
//#define ivorysi
using namespace std;
typedef unsigned long long int64;
typedef long double db;
typedef unsigned int u32;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 + c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {putchar('-');x = -x;}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
int N;
int64 a[505][505];
bool nonprime[50005];
int prime[50005],tot;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
map<int64,pii > mmm;
int64 gcd(int64 a,int64 b) {
    return b == 0 ? a : gcd(b,a % b);
}
int64 Calc(int x,int y) {
    int64 res = 1;
    for(int k = 0 ; k <= 3 ; ++k) {
	int tx = x + dx[k],ty = y + dy[k];
	if(tx < 1 || tx > N || ty < 1 || ty > N) continue;
	res = res / gcd(res,a[tx][ty]) * a[tx][ty];
    }
    return res + 1;
}
void Solve() {
    read(N);
    if(N == 2) {
	puts("4 7");
	puts("23 10");
	return;
    }
    for(int i = 2 ; i <= 50000 ; ++i) {
	if(!nonprime[i]) {
	    prime[++tot] = i; 
	}
	for(int j = 1 ; j <= tot ; ++j) {
	    if(prime[j] > 50000 / i) break;
	    nonprime[i * prime[j]] = 1;
	    if(i % prime[j] == 0) break;
	}
    }
    int st = 1;
    for(int s = 2 ; s <= N + N ; s += 2) {
	for(int i = 1 ; i <= N ; ++i) {
	    int j = s - i;
	    if(j < 1 || j > N) continue;
	    a[i][j] = prime[st];
	}
	++st;
    }
    int k = N & 1 ? 1 - N : 2 - N;
    for(int s = k ; s <= N ; s += 2) {
	for(int i = 1 ; i <= N ; ++i) {
	    int j = i - s;
	    if(j < 1 || j > N) continue;
	    a[i][j] = a[i][j] * prime[st];
	}
	++st;
    } 
    for(int s = 3 ; s <= N + N ; s += 2) {
	for(int i = 1 ; i <= N ; ++i) {
	    int j = s - i;
	    if(j < 1 || j > N) continue;
	    if(i == 409 && j == 101) {
		puts("QAQ");
	    }
	    a[i][j] = Calc(i,j);
	    
	}
    }
    for(int i = 1 ; i <= N ; ++i) {
	for(int j = 1 ; j <= N ; ++j) {
	    out(a[i][j]);
	    j == N ? 0 : space;
	}
	enter;
    }
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, a, b;
	cin>>n>>a>>b;
	vector<ll> h(n);
	for(auto &x : h){
		cin>>x;
	}
	a -= b;
	ll lo = 0, hi = 1e9;
	while(lo < hi){
		ll mi = lo + (hi - lo)/2;
		ll cnt = 0;
		for(int i = 0; i < n; i++){
			if(h[i] <= b*mi)continue;
			ll tmp = h[i] - b*mi;
			cnt += (tmp + a - 1)/a;
		}
		if(cnt <= mi)hi = mi;
		else lo = mi + 1;
	}
	cout<<lo<<'\n';

	return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

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


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

using namespace std;

int N, M, a[200009], nxt[200009], ap[200009], p[200009], stk[200009];
long long K;

void printStartingFrom (int pos)
{
    for (int i=1; i<=N; i++)
        ap[a[i]] = 0;
    int nr = 0;
    for (int i=pos; i<=N; i++)
    {
        if (ap[a[i]])
        {
            while (nr > 0 && stk[nr] != a[i])
                ap[stk[nr]] = 0, nr --;
            ap[stk[nr]] = 0, nr --;
        }
        else ap[a[i]] = 1, stk[++nr] = a[i];
    }
    for (int i=1; i<=nr; i++)
        printf ("%d%c", stk[i], " \n"[i == nr]);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %lld", &N, &K);
for (int i=1; i<=N; i++)
    scanf ("%d", &a[i]);
for (int i=N; i>=1; i--)
{
    if (ap[a[i]] != 0) nxt[i] = ap[a[i]];
    else nxt[i] = -1;
    ap[a[i]] = i;
}///now ap is first occurrence
p[N + 1] = 1;
for (int i=N; i>=1; i--)
{
    if (nxt[i] == -1) p[i] = ap[a[i]] + 1;
    else p[i] = p[nxt[i] + 1];
}
/*for (int i=1; i<=N + 1; i++)
    printf ("%d ", p[i]);
printf ("\n");*/
if (K <= 2 * N)
{
    int i = 1;
    K --;
    while (K --)
        i = p[i];
    printStartingFrom (i);
    return 0;
}
for (int i=1; i<=N; i++)
    ap[a[i]] = 0;
ap[1] = 1;
int rec, x, y;
for (int i = p[1], j = 2;; i = p[i], j ++)
    if (ap[i] != 0)
    {
        ///reached i as ap[i]th and as jth
        rec = i, x = ap[i], y = j;
        break;
    }
int steps = (K - x) % (y - x);
while (steps --)
    rec = p[rec];
printStartingFrom (rec);
return 0;
}


Measured memory_bytes: 5376
# coding: utf-8

n,m,q = list(map(int,input().split()))
M = [ list(map(int,input().split())) for i in range(m) ]
Q = [ list(map(int,input().split())) for i in range(q) ]

LR = [[0]*(n+1) for _ in range(n+1)]

for m in M:
    LR[m[0]-1][m[1]] += 1 

for l in range(n,-1,-1):
    for r in range(0,n,1):
        LR[l-1][r+1] = LR[l-1][r+1] + LR[l-1][r] + LR[l][r+1] - LR[l][r]

for q in Q:
    print(LR[q[0]-1][q[1]])

Measured memory_bytes: 73224