akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-8
#define succ(x) (1LL<<(x))
#define lowbit(x) (x&(-x))
#define sqr(x) ((x)*(x))
#define mid (x+y>>1)
#define NM 400005
#define nm 1000005
#define N 1000005
#define M(x,y) x=max(x,y)
const double pi=acos(-1);
const int inf=1e9+7;
using namespace std;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}



struct edge{int t,v;edge*next;}e[nm],*h[NM],*o=e;
void add(int x,int y,int v){o->v=v;o->t=y;o->next=h[x];h[x]=o++;}
int n,m,cnt,tot,c[NM],b[NM],f[NM],d[NM];
bool v[NM];
int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
struct TT{
    int x,y,v;
    bool operator<(const TT&o){return v<o.v;}
}a[nm];
queue<int>q;
void spfa(){
    inc(i,2,cnt)d[i]=inf;q.push(1);mem(v);v[1]++;
    while(!q.empty()){
    int t=q.front();q.pop();v[t]=false;
    link(t)if(d[j->t]>d[t]+j->v){
        d[j->t]=d[t]+j->v;
        if(!v[j->t])v[j->t]++,q.push(j->t);
    }
    }
}

int main(){
    //freopen("data.in","r",stdin);
    n=read();m=read();
    mem(e);mem(h);o=e;
    inc(i,1,m){a[i].x=read();a[i].y=read();a[i].v=read();}
    sort(a+1,a+1+m);cnt=n;
    inc(i,1,m){
        int t=i;while(a[i].v==a[t].v&&t<=m)t++;t--;
        tot=0;
        inc(j,i,t){c[++tot]=a[j].x;c[++tot]=a[j].y;}
        sort(c+1,c+1+tot);
        tot=unique(c+1,c+1+tot)-c-1;
        inc(j,1,tot)f[c[j]]=c[j],b[c[j]]=0,v[c[j]]=false;
        inc(j,i,t){
        int x=find(a[j].x),y=find(a[j].y);
        if(x==y)continue;
        f[x]=y;
        }
        inc(j,1,tot){
        int x=find(c[j]);
        if(v[c[j]])continue;
        v[c[j]]++;
        if(!b[x])b[x]=++cnt;
        add(c[j],b[x],1);add(b[x],c[j],0);
        //printf("%d %d %d\n",c[j],b[x],1);
        //printf("%d %d %d\n",b[x],c[j],0);
        }
        i=t;
    }
    spfa();
    if(d[n]==inf)printf("-1\n");else printf("%d\n",d[n]);
    return 0;
}


Measured memory_bytes: 31744
from collections import*
import sys
sys.setrecursionlimit(10**8)
input=sys.stdin.readline  #危険！基本オフにしろ！

def main():
    n,q=map(int,input().split())
    d=defaultdict(list)
    cost=[0]*(n+10)
    
    TF=[1]+[0]*(n-1)
    for i in range(n-1):
        a,b=map(int,input().split())
        d[a].append(b)
        d[b].append(a)
    for i in range(q):
        a,b=map(int,input().split())
        cost[a]+=b
    
    def dfs(cost,point):
        if len(d[point])==0:
            return 0
        for i in d[point]:
            if TF[i-1]:
                continue
            TF[i-1]=1
            cost[i]+=cost[point]
            dfs(cost,i)
            TF[i-1]=0

    dfs(cost,1)
    print(*cost[1:n+1])
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 282448
#include<stdio.h>
int main()
{
	int n;
	int a[200];
	while(~scanf("%d",&n))
	{
		int sum=0;
		for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
		for(int i=0;i<n-1;i++)
		for(int j=i+1;j<n;j++)
		{
			sum+=a[i]*a[j];
		}
		printf("%d\n",sum);
		
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
  string s; cin >> s;

  ll k; cin >> k;

  for(int i=0; i<s.length() && i < k; i++){
    if(s[i] != '1'){
      cout << s[i] << endl;
      return 0;
    }
  }

  cout << 1 << endl;
  
  return 0;

}


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

template<typename T, typename F> string to_string(pair<T, F> p);
string to_string(string s) {
  return '"' + s + '"';
}
string to_string(char c) {
  return (string) "'" + c + "'";
}
string to_string(const char* p) {
  return to_string((string) p);
}
string to_string(bool B) {
  return (B ? "true" : "false");
}
string to_string(vector<bool> v) {
  string res = "{";
  for (int i = 0; i < (int) v.size(); ++i) {
    if ((int) res.size() > 1) res += ", ";
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template<size_t T> string to_string(bitset<T> bs) {
  return bs.to_string();
}
template<typename T> string to_string(T v) {
  string res = "{";
  for (auto& el : v) {
    if ((int) res.size() > 1) res += ", ";
    res += to_string(el);
  }
  res += "}";
  return res;
}
void debug_out() {
  cerr << endl;
}
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" , debug_out(__VA_ARGS__)
#else 
#define debug(...) (void) 37
#endif

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int r, c, k;
  cin >> r >> c >> k;
  vector<vector<int>> grid(r, vector<int>(c));
  while (k--) {
    int x, y, val;
    cin >> x >> y >> val;
    --x; --y;    
    grid[x][y] = val;
  }
  vector<vector<vector<long long>>> dp(r, vector<vector<long long>>(c, vector<long long>(4)));
  auto get = [&](int x, int y, int v) {
    if (x < 0 || x >= r || y < 0 || y >= c) return 0ll;
    return dp[x][y][v]; 
  };
  for (int i = r - 1; i >= 0; --i) {
    for (int j = c - 1; j >= 0; --j) {
      for (int left = 1; left < 4; ++left) {
        dp[i][j][left] = max({get(i, j + 1, left - 1) + grid[i][j], get(i, j + 1, left), get(i +1, j, 3) + grid[i][j]});  
      }
      dp[i][j][0] = max(get(i + 1, j, 3), get(i, j + 1, 0));
      debug(i, j, dp[i][j]);
    }
  }
  cout << dp[0][0][3] << '\n';
}

Measured memory_bytes: 671644
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

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

int A, B;

int main() {

	scanf("%d%d", &A, &B);

	if (A <= 5) printf("0\n");
	else if (A <= 12) printf("%d\n", B / 2);
	else printf("%d\n", B);

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;

const int maxn = 305;
vector<int> l[maxn][5];
int n, m;

int dp[2][3][maxn][maxn];

const int mod = 1e9 + 7;
void add(int &a, int b){
    a += b;
    if(a >= mod)
        a -= mod;
}

int main(){
    cin >> n >> m;
    for(int i = 1;i <= m;i++){
        int L, R, x;
        scanf("%d%d%d", &L, &R, &x);
        l[R][x].push_back(L);
    }
    dp[0][0][0][0] = 1;
    for(int i = 1;i <= n;i++){
        int cur = (i & 1);
        int pre = cur ^ 1;
        memset(dp[i & 1], 0, sizeof(dp[i & 1]));
        for(int j = 0;j < 3;j++){
            for(int k = 0;k < i;k++){
                for(int k1 = 0;k1 < i;k1++){
                    if(dp[pre][j][k][k1] == 0)
                        continue;
                    int from = dp[pre][j][k][k1];
                    add(dp[cur][j][k][k1], from);
                    if(j == 0){
                        add(dp[cur][1][k1][i - 1], from);
                        add(dp[cur][2][i - 1][k], from);
                    }else if(j == 1){
                        add(dp[cur][2][k1][i - 1], from);
                        add(dp[cur][0][i - 1][k], from);
                    }else if(j == 2){
                        add(dp[cur][0][k1][i - 1], from);
                        add(dp[cur][1][i - 1][k], from);
                    }
                } 
            }
        }
        for(auto v : l[i][1]){
            for(int j = 0;j < 3;j++){
                for(int k = 0;k < i;k++){
                    for(int k1 = 0;k1 < i;k1++){
                        if((k >= v) or (k1 >= v))
                            dp[cur][j][k][k1] = 0; 
                    }
                }
            }
        }
        for(auto v : l[i][2]){
            for(int j = 0;j < 3;j++){
                for(int k = 0;k < i;k++){
                    for(int k1 = 0;k1 < i;k1++){
                        if((k >= v) and (k1 >= v))
                            dp[cur][j][k][k1] = 0; 
                        if((k < v) and (k1 < v))
                            dp[cur][j][k][k1] = 0;       
                    }
                }
            }
        }
        for(auto v : l[i][3]){
            for(int j = 0;j < 3;j++){
                for(int k = 0;k < i;k++){
                    for(int k1 = 0;k1 < i;k1++){
                        if((k < v) or (k1 < v))
                               dp[cur][j][k][k1] = 0; 
                    }
                }
            }
        }
    }
    int ans = 0;
    for(int j = 0;j < 3;j++){
        for(int k = 0;k < n;k++){
            for(int k1 = 0;k1 < n;k1++){
                add(ans, dp[n & 1][j][k][k1]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int n, k, x;

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> x;
    int ans = 1;
    n -= k;
    ans += n / (k - 1);
    n %= (k - 1);
    if (n) ans++;
    cout << ans << endl;
    return 0;
}


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

int main() {
  ll x;
  cin >> x;
  ll count=0,sum=0;
  while(sum<x){
    count++;
    sum+=count;
  }
  cout << count << endl;
}

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

//const int MOD = (int)1e9+7;
const long long MOD = 998244353;

int main(){
	int N;
	cin >> N;
	vector<int> V(N);
	vector<int> C(N);
	for(int i=0;i<N;i++)	cin >> V.at(i);
	for(int i=0;i<N;i++)	cin >> C.at(i);

	int ans=0;
	for(int i=0;i<N;i++){
		if(C.at(i)<V.at(i))	ans+=V.at(i)-C.at(i);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a[100010],ans=0,sumnow=0;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        sumnow+=a[i];
        if(a[i]==0){
            ans+=sumnow/2;
            sumnow=0;
        }
    }
    ans+=sumnow/2;
    cout<<ans<<endl;
    return 0;
}

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

vector<int> gr[100001];
int res = 0, dp[100001];

int solve(int src) {
    if(dp[src] != -1) return dp[src];

    bool leaf = 1;
    int bestChild = 0;
    for(int child: gr[src]) {
      leaf = 0;
      bestChild = max(bestChild, solve(child));
    }
    return dp[src] = leaf ? 0 : 1+bestChild;
}

int main() {
    int N, M; cin>>N>>M;
    for(int i=0; i<M; i++) {
        int x, y; cin>>x>>y;
        gr[x].push_back(y);
    }

    int res = 0;
    memset(dp, -1, sizeof dp);
    for(int i=1;i<=N;i++) res = max(res, solve(i));
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 11348
ary=$stdin.readlines
od=Array.new
ev=Array.new
n = ary[0].to_i
array=ary[1].split.map!(&:to_i)
p=0
while p<n
  od.push(array[p]) if p%2==0
  ev.push(array[p]) if p%2==1
  p+=1
end

  sd_n_ns_od = od.group_by{|i| i}.sort_by{|k,v| v.size}
  sd_n_ns_ev = ev.group_by{|i| i}.sort_by{|k,v| v.size}



if sd_n_ns_od.size == 1 && sd_n_ns_ev.size == 1
  if sd_n_ns_od.last.first == sd_n_ns_ev.last.first
    answer = n/2
  else
    answer= 0
  end
else
most_n_od = sd_n_ns_od.last.first
most_n_ev = sd_n_ns_ev.reject{|k,v| k == most_n_od}.last.first
answer1=0
answer1+=od.reject{|i| i==most_n_od}.size
answer1+=ev.reject{|i| i==most_n_ev}.size

most_n_ev = sd_n_ns_ev.last.first
most_n_od = sd_n_ns_od.reject{|k,v| k== most_n_ev}.last.first
answer2=0
answer2+=ev.reject{|i| i==most_n_ev}.size
answer2+=od.reject{|i| i==most_n_od}.size

 answer = (answer1 <= answer2)?  (answer1):(answer2)

 if  sd_n_ns_od.size == 1
   answer=answer1
 end

 if  sd_n_ns_ev.size == 1
   answer=answer2
 end
 end
=begin
 if  sd_n_ns_od.size > 1  && sd_n_ns_ev.size > 1
     if sd_n_ns_od.last.last.size == sd_n_ns_od[-2].last.size || sd_n_ns_ev.last.last.size == sd_n_ns_ev[-2].last.size
       answer=0
     answer+=od.reject{|i| i == sd_n_ns_od.last.first}.size
     answer+=ev.reject{|i| i == sd_n_ns_ev.last.first}.size
    end
   end
=end
puts answer


Measured memory_bytes: 25620
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val a, b, c = sc.next()

  def solve(a: String, b: String, c: String, turn: Char): String = {
    turn match {
      case 'a' =>
        if (a.isEmpty) {
          "A"
        } else {
          solve(a.tail, b, c, a.head)
        }
      case 'b' =>
        if (b.isEmpty) {
          "B"
        } else {
          solve(a, b.tail, c, b.head)
        }
      case 'c' =>
        if (c.isEmpty) {
          "C"
        } else {
          solve(a, b, c.tail, c.head)
        }
    }
  }

  println(solve(a, b, c, 'a'))
}


Measured memory_bytes: 55384
#![allow(non_snake_case, unused_imports)]

// Input
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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        T: [i64; N],
        M: usize,
        PX: [(usize,i64); M]
    }
    let mut total = 0;
    for i in 0..N{
        total += T[i];
    }
    for i in 0..M{
        println!("{}", total - T[PX[i].0-1] + PX[i].1);
    }
}

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

int main(void){
    string moji;
    int c;
    
    for(int i = 0;; i++){
        getline(cin, moji);
        if(moji == "0") break;
        c = 0;
        
        for(int j = 0; j < moji.size(); j++){
            c += moji[j] - '0';
        }
        
        cout << c << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn solve() {
    input!(
        a: [usize; 5],
        k: usize,
    );

    println!("{}", if a[4] - a[0] > k {":("} else {"Yay!"});
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
n = int(input())
a = input().split()
a = [int(m) for m in a]
q = []
k = 0
kco = 0
#+-
for i in range(n):
    if i == 0:
        if a[i] > 0:
            q.append(a[i])
        else:
            q.append(1)
            kco += 1 - a[i]
        k += q[i]
    else:
        k += a[i]
        if i % 2 != 0:
            if k < 0:
                q.append(a[i])
            else:
                q.append(a[i]-k-1)
                kco += k + 1
            k += q[i] - a[i]
        if i % 2 == 0:
            if k > 0:
                q.append(a[i])
            else:
                q.append(a[i]-k+1)
                kco += -k + 1
            k += q[i] - a[i]
xco = kco
q = []
k = 0
kco = 0
#-+
for i in range(n):
    if i == 0:
        if a[i] < 0:
            q.append(a[i])
        else:
            q.append(-1)
            kco += a[i] + 1
        k += q[i]
    else:
        k += a[i]
        if i % 2 == 0:
            if k < 0:
                q.append(a[i])
            else:
                q.append(a[i]-k-1)
                kco += k + 1
            k += q[i] - a[i]
        if i % 2 != 0:
            if k > 0:
                q.append(a[i])
            else:
                q.append(a[i]-k+1)
                kco += -k + 1
            k += q[i] - a[i]
yco = kco
print(min(xco, yco))

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

int main(){


  int x;
  cin>>x;
  int h = x / 3600;
  int m = (x /60) % 60;
  int s = x % 60;
  cout<<h<<":"<<m<<":"<<s<<endl;


return 0;
}



Measured memory_bytes: 3084
import java.text.DecimalFormat;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        final long X = sc.nextLong(), Y = sc.nextLong();
        long ans = 0;

        for (long i = X; i <= Y; i *= 2) {
            ans++;
        }

        out.println(ans);

        out.flush();
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

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


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
	int count[26],rcount[26],n,cmax=0,data;
	char c[26];
	string str;
	c[0]='a';
	for(int i=1;i<26;i++){//判定入力
		c[i]=c[i-1]+1;
	}
	cin>>n;
	cin>>str;
	std::vector<int> result(n);
	for(int i=1;i<n;i++){
		for(int j=0;j<26;j++){//初期化
			count[j]=0;
			rcount[j]=0;
		}
		for(int j=0;j<i;j++){
			for(int k=0;k<26;k++){
				if(str[j]==c[k]){
					count[k]=1;
					break;
				}
			}
		}
		for(int j=n-1;j>=i;j--){
			for(int k=0;k<26;k++){
				if(str[j]==c[k]  && count[k]==1){
					rcount[k]=1;
					break;
				}
			}
		}
		for(int j=0;j<26;j++){
			if(rcount[j]==1){
				result[i]+=1;
			}
		}
	}
	sort(result.begin(),result.end());
	cout<<result[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int n;
    string s;
    long long ans = 0;
    long long co[5] = {};
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> s;
        if(s[0] == 'M') co[0]++;
        else if(s[0] == 'A') co[1]++;
        else if(s[0] == 'R') co[2]++;
        else if(s[0] == 'C') co[3]++;
        else if(s[0] == 'H') co[4]++;
    }

    for(int i = 0; i < 5; i++){
        for(int j = i+1; j < 5; j++){
            for(int k = j+1; k < 5; k++){
                ans += co[i] * co[j] * co[k];
            }
        }
    }

    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;

char str[55][55];

int dx[8] = { 1,1,0,-1,-1,-1, 0, 1 };
int dy[8] = { 0,1,1, 1, 0,-1,-1,-1 };
void solve()
{
    int h, w;
    scanf("%d%d", &h, &w);
    int i, j;
    for (i = 0; i < h; i++) {
        scanf("%s", str[i]);
    }
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            if (str[i][j] != '.') continue;
            int k;
            int cnt = 0;
            for (k = 0; k < 8; k++) {               
                int i2 = i + dx[k], j2 = j + dy[k];
                if (i2 < 0 || i2 >= h || j2 < 0 || j2 >= w) continue;
                 
                if (str[i2][j2] == '#') cnt++;
            }
            str[i][j] = '0' + cnt;
        }
    }
    for (i = 0; i < h; i++) {
        printf("%s\n", str[i]);
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    int res = 0;

    rep(i, n) {
        if (s[i] == '+') res++;
        else res--;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n,t,a,h;
    scanf("%d%d%d",&n,&t,&a);
    int ans,i;
    vector<double> dif(n);
    for(i=0;i<n;i++){
        scanf("%d",&h);
        dif[i]=abs(t-h*0.006-a);
    }
    printf("%d\n",1+min_element(dif.begin(),dif.end())-dif.begin());
    return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int main() {
	int N;
	map<ll, int> T;
	ll ret = 0;

	cin >> N;
	T[0] = 1;
	ll s = 0;

	rep(i, N) {
		int x;
		cin >> x;
		s += x;
		ret += T[s];
		++T[s];
	}

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 12800
N = int( input())
A = list( map( int, input().split()))
K = max(A)
L = min(A)
if K == L:
    if K == N-1 or 2*K <= N:
        print('Yes')
    else:
        print('No')
elif abs(K-L) == 1:
    x = K*N - sum(A)
    if 2*K - x <= N and x < K:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 13964
#include <stdlib.h>
#include <stdio.h>

int main()
{
	int k,t,i;
	scanf("%d %d",&k,&t);
	int s[t];
	for (i = 0;i<t;i++) scanf("%d",&s[i]);

	if (t == 1) printf("%d\n",k-1);
	else {
		int b = s[0];
		int index = 0;
		for (i = 0;i<t;i++) 
			if (s[i] > b){
				index = i;
				b = s[i];
			}
		for (i = 0;i<t;i++){
			if (i != index){
				b -= s[i];
			}
		}
		if (b <= 0) printf("0\n");
		else printf("%d\n",b-1);
	}
	return 0;
}


Measured memory_bytes: 128
n, m, x, y = map(int, input().split())
listX = list(map(int, input().split()))
listY = list(map(int, input().split()))
maxX = max(listX)
minY = min(listY)

flag =0
if maxX < minY:
    for number in range(x+1, y+1):
        if maxX < number and minY > number-1:
            print("No War")
            flag=1
            break
    if flag ==0:
        print("War")
else:
    print("War")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,ans;
string s[N];
map<string,int>mp;
int main(){
	scanf("%d",&n);
	for (register int i=1; i<=n; ++i) cin>>s[i];
	sort(s+1,s+n+1);
	for (register int i=1; i<=n; ++i) mp[s[i]]++;
	for (register int i=1; i<=n; ++i) ans=max(ans,mp[s[i]]);
	for (register int i=1; i<=n; ++i)
	if (mp[s[i]]==ans) 
	{
		cout<<s[i]<<endl;
		mp[s[i]]--;	
	}
return 0;	
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n;
    cin>>n;
    ll a[n],ans=0,i,j,k;
    forn(i,n) cin>>a[i];
    for(i=0;i<n-2;i++){
        for(j=i+1;j<n-1;j++){
            for(k=j+1;k<n;k++){
                ll x=max({a[i],a[j],a[k]}),y=min({a[i],a[j],a[k]});
                if(x<y+(a[i]+a[j]+a[k])-(y+x) and a[i]!=a[j] and a[j]!=a[k] and a[k]!=a[i]) ans++;
            }
        }
    }
    cout<<ans el;
}

main()
{
//      fastio();
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll A[101010];
vector<int> V;
ll ret[101010];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	map<ll,ll> M;
	FOR(i,N) cin>>A[i], M[A[i]]++;
	V.push_back(0);
	for(i=1;i<N;i++) if(A[V.back()]<A[i]) V.push_back(i);
	for(i=V.size()-2;i>=0;i--) {
		while(M.rbegin()->first>A[V[i]]) {
			auto r=*M.rbegin();
			M.erase(r.first);
			ret[V[i+1]] += (r.first-A[V[i]])*1LL*r.second;
			M[A[V[i]]]+=r.second;
		}
	}
	FORR(r,M) ret[0] += r.first*r.second;
	
	
	FOR(i,N) cout<<ret[i]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 9468
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
void solve(){
	string s;
	vector<pair<char,int>> v;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(v.empty()||v.back().first!=s[i])v.push_back({s[i],1});
		else v.back().second++;
	}
	int mx=0;
	for(auto x:v){
		if(x.first=='R'){
			mx=max(mx,x.second);
		}
	}
	cout<<mx<<"\n";
}
int main(){
	FASTIO
	solve();
	return 0;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

template <typename T>
class SegmentTree
{
public:
    SegmentTree(const int n, const T &unit) : _unit(unit)
    {
        _n = 1 << __lg(2 * n - 1);
        _data.resize(2 * _n, unit);
    }

    SegmentTree(const vector<T> &v, const T &unit) : _unit(unit)
    {
        int n = v.size();
        _n = 1 << __lg(2 * n - 1);
        _data.resize(2 * _n, unit);

        // 最下段に要素をセット
        for (int i = 0; i < n; i++) this->set(i, v[i]);
        // セグメント木を構築
        this->build();
    }

    // k 番目の要素を最下段にセット
    void set(int k, const T &x) { _data[k + _n] = x; }

    // セグメント木を構築
    void build(void)
    {
        for (int i = _n - 1; i > 0; i--) _data[i] = f(_data[2 * i], _data[2 * i + 1]);
    }

    // k番目の値をxに更新する
    void update(int k, const T &x)
    {
        k += _n; // 葉の節点に変換
        _data[k] = x;
        while (k >>= 1) _data[k] = f(_data[2 * k], _data[2 * k + 1]);
    }

    // 区間[a, b)に対してクエリ処理した結果を返す
    T query(int a, int b)
    {
        T left = _unit, right = _unit;
        a += _n, b += _n; // 葉の節点に変換
        for (; a < b; a >>= 1, b >>= 1) {
            if (a & 1) left  = f(left, _data[a++]);
            if (b & 1) right = f(_data[--b], right);
        }
        return f(left, right);
    }

    const T &operator[](size_t k) const { return _data[k + _n]; }
    T &operator[](size_t k) { return _data[k + _n]; }

private:
    int _n;          // 要素数
    vector<T> _data; // データを格納する配列
    T _unit;        // 単位元

    // クエリ処理用の関数
    T f(const T &a, const T &b) { return max(a, b); }
};

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

    int h, w, m; cin >> h >> w >> m;

    vector<vector<int>> v(h);
    SegmentTree<int> seg(w, 0);
    for (int i = 0; i < m; i++) {
        int y, x; cin >> y >> x;
        y--, x--;
        v[y].emplace_back(x);
        seg[x]++;
    }
    seg.build();

    int ans = 0;
    for (int i = 0; i < h; i++) {
        int res = v[i].size();
        for (auto x: v[i]) seg.update(x, seg[x] - 1);
        res += seg.query(0, w);
        ans = max(ans, res);
        for (auto x: v[i]) seg.update(x, seg[x] + 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 23780
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  int N; cin >> N;
  set<string> se;
  rep(i,N){
    string s; cin >> s;
    se.insert(s);
  }
  cout << SZ(se) << endl;
  return 0;
}


Measured memory_bytes: 19140
import collections

n = []

while True:
   try:
       N = input()
   
   except:
       break
   
   N = N.lower() 
    
   N.replace('', ' ')
   
   N = list(N)
   
   n.extend(N)
   
c = collections.Counter(n)

for i in range(97, 97+26):
        print("%s : %d" % (chr(i),c[chr(i)]) )


Measured memory_bytes: 5960
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, A: int, B: int, C: int, D: int, S: str):
    if C < D:
        flag_d = False
        for i in range(A+1, D-1):
            if S[i:i+2] == '##':
                flag_d = True
                break

        if flag_d:
            print(NO)
        else:
            print(YES)


    elif D < C:
        flag_d = False
        for i in range(A+1, C-1):
            if S[i:i+2] == '##':
                flag_d = True
                break

        flag_c = False
        for i in range(B-2, D-2):
            if S[i:i+3] == '...':
                flag_c = True
                break

        if flag_d:
            print(NO)
        else:
            if flag_c:
                print(YES)
            elif S[D-2] != '#' and S[D] != '#':
                print(YES)
            else:
                print(NO)


    else:
        raise NotImplementedError





    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include  <cstdio>
#include <algorithm>
#include  <cstdio>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
using namespace std;
#define maxn 110
int main()
{
 int N ,M;
 cin >> N >>M;
 if(M%N == 0)
    cout << M/N<<endl;
 else
 {
    int i;
    int ans = 0;
    for(i = 1;i<=M/N;i++)
    {
        if(M%i == 0 && M/i >= N)
        ans = i;
    }
    cout << ans <<endl;
 }

return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

int n;
int skew[200];

void proc() {
	scanf("%d", &n);
	for (int i = 0; i < n * 2; ++i) {
		scanf("%d", &skew[i]);
	}
	sort(skew, skew + n * 2);

	int ans = 0;
	for (int i = 0; i < n * 2; i += 2) {
		ans += skew[i];
	}
	printf("%d", ans);
}

int main() {
	//freopen("input.txt", "r", stdin);
	proc();
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int, int>;
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n; cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];

  bool zero = false;
  int negative = 0;
  rep(i,n) {
    if (a[i] == 0) {
      zero = true;
      break;
    }
    if (a[i] < 0) {
      ++negative;
    }
  }

  ll ans = 0;
  if (zero || negative%2 == 0) {
    rep(i,n) ans += abs(a[i]);
  }
  else {
    int minimum = 1e9+1;
    rep(i,n) {
      ans += abs(a[i]);
      minimum = min(minimum, abs(a[i]));
    }
    ans -= minimum * 2;
  }
  cout << ans << endl;
  return 0;
}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,k;
cin>>n>>k;
vector<int>p(n);
rep(i,n)cin>>p[i];
sort(p.begin(),p.end());
int ans=0;
rep(i,k){
    ans+=p[i];
}
cout<<ans<<endl;
return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> ans(n);
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int dist = min(j - i, abs(x - i) + 1 + abs(j - y));
            ans[dist]++;
        }
    }
    for (int i = 1; i < n; i++) printf("%d\n", ans[i]);
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint H;
  cin>>H;
  lint h=H;
  lint n=1;
  lint ans=0;
  while(h>0){
    ans+=n;
    h/=2;
    n*=2;
  }
  cout<<ans<<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;
using ll = long long;
using P = pair<int, int>;


int main() {
    int n;
    cin >> n;
    int keta = n % 10;
    if(keta == 3){
        cout << "bon" << endl;
    }
    else if(keta == 0 || keta == 1 || keta == 6 || keta == 8){
        cout << "pon" << endl;
    }
    else{
        cout << "hon" << endl;
    }


    return 0;
}

Measured memory_bytes: 3636
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**8) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

cnt = [0]*4
for _ in range(3):
    a,b = li_()
    cnt[a] += 1
    cnt[b] += 1
    
if max(cnt) == 2:
    print('YES')
else:
    print('NO')

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

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

    vector<int> a(n),b(n-1);
    for(int i=0; i<n-1; i++){
        cin>>b[i];
    }

    int sum=0;
    a[n-1]=b[n-2];

    for(int i=n-2; i>0; i--){
        if(b[i-1]>b[i]){
            a[i]=b[i];
        }else{
            a[i]=b[i-1];
        }
    }

    a[0]=b[0];

    for(int i=0; i<n; i++){
        sum+=a[i];
    }

    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,ans=0,b[100005]={};
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        b[a-1]++;
        b[a]++;
        b[a+1]++;
    }
    for(int i=0;i<=100000;i++){
        if(ans<b[i])
            ans=b[i];
    }   
    cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 3944
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  string s; cin >> s;
  bool f=0;
  rep(i,3){
    if(s[i]=='7') f=1;
  }
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int main() {
	int a, b,c;
	cin >> a >> b>>c;
	PRI(max(c + b - a,0));
	return 0;
}


Measured memory_bytes: 3604
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int main() {
  int flag;
  double a, b, x, pi = acos(-1), l, r, mid, th;
  cin >> a >> b >> x;
  if (a * a * b <= 2.0 * x) {
    flag = 0;
    l = 0.0;
    r = atan(b / a) * 360.0 / 2 / pi;
  } else {
    l = atan(b / a) * 360.0 / 2 / pi;
    r = 90.0;
    flag = 1;
  }
  for (int i = 0; i < 50; i++) {
    mid = (l + r) / 2.0;
    th = (90 - mid) / 180 * pi;
    if (flag == 0 && x + a * a * a / tan(th) / 2.0 >= a * a * b) {
      r = mid;
    } else if (flag == 0) {
      l = mid;
    } else if (flag == 1 && b * b * tan(th) * a / 2.0 >= x) {
      l = mid;
    } else {
      r = mid;
    }
  }
  cout << fixed << setprecision(7) << (l + r) / 2.0 << endl;
}

Measured memory_bytes: 640
// AOJ 0223
#include <iostream>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

#define x first
#define y second
#define mp make_pair

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

typedef pair <int, int> Point;
typedef pair <Point, Point> kotori;
int x, y;

ostream &operator<<(ostream &os, const Point &a) { os << "(" << a.x << ", " << a.y << ")"; return os; }

bool is_region(Point p)
{
	return (0 <= p.x && p.x < x && 0 <= p.y && p.y < y);
}

int main()
{
	while (cin >> x >> y, x || y){
		Point s1, s2;
		bool otonoki[64][64];
		cin >> s1.x >> s1.y;
		cin >> s2.x >> s2.y;
		s1.x--; s1.y--;
		s2.x--; s2.y--;
		for (int i = 0; i < y; i++){
			for (int j = 0; j < x; j++){
				cin >> otonoki[i][j];
			}
		}

		// cout << "in" << endl;

		map <kotori, bool> vst;
		queue <pair <kotori, int> > q;
		q.push(mp(mp(s1, s2), 0));
		bool f = false;
		while (!q.empty()){
			Point honoka = q.front().first.first, umi = q.front().first.second;
			int steps = q.front().second;
			q.pop();
			if (honoka == umi){
				cout << steps << endl;
				f = true;
				break;
			}
			if (vst[mp(honoka, umi)]) continue;
			vst[mp(honoka, umi)] = true;
			// cout << steps << " : " << honoka << " " << umi << endl;
			for (int i = 0; i < 4; i++){
				Point nh = honoka, nu = umi;
				nh.x += dx[i], nh.y += dy[i];
				nu.x -= dx[i], nu.y -= dy[i];

				// cout << nh << " " << nu << endl;
				// if (!is_region(nh) && !is_region(nu)) continue;
				if (vst[mp(nh, nu)]) continue;
				
				if (!is_region(nh)) nh.x -= dx[i], nh.y -= dy[i];
				if (!is_region(nu)) nu.x += dx[i], nu.y += dy[i];
				if (otonoki[nh.y][nh.x]) nh.x -= dx[i], nh.y -= dy[i];
				if (otonoki[nu.y][nu.x]) nu.x += dx[i], nu.y += dy[i];
				q.push(mp(mp(nh, nu), steps + 1));
			}
		}
		if (!f) cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 27464