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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

#ifdef CLION

ifstream ifs("/home/kyuridenamida/atcoder-workspace/hitachi2020/D/in_2.txt");
#define cin ifs
#define scanf DONT_USE_SCANF
#endif


long long dp[50];

void solve(long long N, long long T, std::vector<long long> a,
           std::vector<long long> b) {

    deque<pair<long long, long long> > ps;
    for (int i = 0; i < N; i++)
        ps.push_back({a[i], b[i]});
    long long t = 0;
    int ans = 0;

    sort(ps.begin(), ps.end(), [&](pair<long long, long long> a, pair<long long, long long> b) {
        long long A = a.first;
        long long B = a.second;
        long long C = b.first;
        long long D = b.second;
        long long w = C * B + C;
        long long W = A * D + A;
        return w < W;
    });

    vector<long long> items;
    vector<pair<long long, long long>> dpItems;
    for (int i = 0; i < ps.size(); i++) {
        if (ps[i].first == 0) {
            items.push_back(ps[i].second + 1);
        } else {
            dpItems.push_back({ps[i].first, ps[i].second});
        }
    }

    sort(items.begin(), items.end());

    for (int j = 0; j < 50; j++) {
        dp[j] = 2e9;
    }

    dp[0] = 0;


    for (int i = 0; i < dpItems.size(); i++) {
        for (int j = 48; j >= 0; j--) {
            dp[j + 1] = min(dp[j + 1], dp[j] + 1 + dpItems[i].first * (dp[j] + 1) + dpItems[i].second);
        }
    }
    long long maxAns = 0;
    for (int i = 0; i < 49; i++) {
        if (dp[i] <= T) {
            long long r = T - dp[i];
            long long c = i;
            for (int j = 0; j < items.size(); j++) {
                if (r - items[j] >= 0) {
                    r -= items[j];
                    c++;
                }
            }
            maxAns = max(maxAns, c);
        }
    }

    cout << maxAns << endl;


}

int main() {
    long long N;
    cin >> N;
    long long T;
    cin >> T;
    std::vector<long long> a(N);
    std::vector<long long> b(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
    }
    solve(N, T, std::move(a), std::move(b));
    return 0;
}


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

const int MAX_N = 2e5+10;
int N;
int A[MAX_N];
int cnt[MAX_N];

void solve()
{
	for(int i=2;i<=N;++i){
		cnt[A[i]]++;
	}
	for(int i=1;i<=N;++i)cout << cnt[i] << '\n';
}

int main()
{
	cin >> N;
	for(int i=2;i<=N;++i) cin>> A[i];
	solve();
	return 0;
}

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

typedef long long ll;

int main(){
	int N;
	string S;
	cin >> N;
	cin >> S;
	int ans = 0;

	rep(i,N-1){
		if(S[i] != S[i+1])ans++;
	}

	cout << ans+1 << endl;

	return 0;
}


Measured memory_bytes: 512
while True :
    n,x = map(int, input().split())
    if n == 0 and x == 0 : break
    ans = 0
    for i in range(n) :
        for j in range(i) :
            for k in range(j) :
                if i+j+k+3 == x : ans += 1
    print(ans)



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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

string s;

int main()
{
    _FastIO;
    cin >> s;
    if(int(s[0]) > int(s[1])){
        cout << s[0] << s[0] << s[0] << endl;
        return 0;
    }
    if(int(s[0]) == int(s[1]) && int(s[1]) >= int(s[2])){
        cout << s[0] << s[0] << s[0] << endl;
    }
    else{
        char c = char(int(s[0]) + 1);
        cout << c << c << c << endl;
    }
    return 0;
}


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

typedef struct Point {
    int x, y, col;
} Point;

int r, c, n;
vector<Point> ptop, pright, pbottom, pleft;

bool onBorder(int x, int y) {
    return x == 0 || y == 0 || x == r || y == c;
}

void addPoint(int x, int y, int col) {
    Point p;
    p.x = x;
    p.y = y;
    p.col = col;
    if(p.x == 0) {
        ptop.push_back(p);
    } else if(p.y == c) {
        pright.push_back(p);
    } else if(p.x == r) {
        pbottom.push_back(p);
    } else {
        pleft.push_back(p);
    }
}

bool compx(const Point &p1, const Point &p2) {
    return p1.x < p2.x;
}

bool compy(const Point &p1, const Point &p2) {
    return p1.y < p2.y;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> r >> c >> n;
    for(int i = 0; i < n; i++) {
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if(onBorder(x1, y1) && onBorder(x2, y2)) {
            addPoint(x1, y1, i);
            addPoint(x2, y2, i);
        }
    }
    sort(ptop.begin(), ptop.end(), compy);
    sort(pright.begin(), pright.end(), compx);
    sort(pbottom.begin(), pbottom.end(), compy);
    reverse(pbottom.begin(), pbottom.end());
    sort(pleft.begin(), pleft.end(), compx);
    reverse(pleft.begin(), pleft.end());
    vector<Point> pts;
    for(int i = 0; i < 2; i++) {
        pts.insert(pts.end(), ptop.begin(), ptop.end());
        pts.insert(pts.end(), pright.begin(), pright.end());
        pts.insert(pts.end(), pbottom.begin(), pbottom.end());
        pts.insert(pts.end(), pleft.begin(), pleft.end());
    }
    stack<int> st;
    bool seen[111111];
    fill(seen, seen + 111111, false);
    for(int i = 0; i < pts.size(); i++) {
        int col = pts[i].col;
        if(seen[col]) {
            if(st.top() != col) {
                cout << "NO" << endl;
                return 0;
            } else {
                st.pop();
                seen[col] = false;
            }
        } else {
            seen[col] = true;
            st.push(col);
        }
    }
    cout << "YES" << endl;
    return 0;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.length();
  int k = 0, prev = -1;
  for (int i = 0; i < n; i++) {
    if (prev == -1 || s[i] != s[prev]) {
      prev = i;
      k++;
    } else {
      if (i != n - 1) {
        i++;
        k++;
      }
      prev = -1;
    }
  }
  cout << k << '\n';
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N;
    cin >> N;
    VVL G(N);
    rep(i, 0, N-1){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    VL c(N), d(N);
    rep(i, 0, N) cin >> c[i];
    sort(ALL(c), greater<ll>());
    ll ans = 0, ptr = 1;
    queue<ll> que;
    que.push(0);
    d[0] = c[0];
    VB seen(N, false);
    while(!que.empty()){
        auto q = que.front();
        que.pop();
        if(seen[q]) continue;
        seen[q] = true;
        for(auto g : G[q]){
            if(seen[g]) continue;
            d[g] = c[ptr];
            ptr++;
            que.push(g);
            ans += min(d[g], d[q]);
        }
    }
    cout << ans << endl;
    rep(i, 0, N){
        cout << d[i];
        if(i == N-1) cout << endl;
        else cout << " ";
    }
    return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

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

        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        int[] a = new int[n];
        
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            a[i] = sc.nextInt();
        }
        
        int wlmax = 0;
        int whmax = w;
        int hlmax = 0;
        int hhmax = h;
        int sum = 0;
        
        for (int i = 0; i < n; i++) {
            if (a[i] == 1) {
                if (wlmax < x[i]) {
                    wlmax = x[i];
                }
            } else if (a[i] == 2) {
                if (whmax > x[i]) {
                    whmax = x[i];
                }
            } else if (a[i] == 3) {
                if (hlmax < y[i]) {
                    hlmax = y[i];
                }
            } else if (a[i] == 4) {
                if (hhmax > y[i]) {
                    hhmax = y[i];
                }
            } 
        }
        
        w = whmax - wlmax;
        h = hhmax - hlmax;
        if (w <= 0 || h <= 0) {
            sum = 0;
        } else {
           sum = w * h; 
        }
        System.out.println(sum);
    }
}



Measured memory_bytes: 22228
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();

    let ans = n - k + 1;
    return ans.to_string();
}


Measured memory_bytes: 2116
#include<stdio.h>
 
void main(void)
{
 
  int k,a,b,i;
  
  scanf("%d",&k);
  scanf("%d%d",&a,&b);
  
  for(i=a;i<b+1;i++){
    if(i%k==0){
      printf("OK\n");
      return 0;
    }
  }
  printf("NG\n");
  
  return 0;
}

Measured memory_bytes: 1644
import java.io.PrintWriter;
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        long n = sc.nextLong();

        Map<Long, Long> map = primeFactorization(n);

//        debug(map);

        int ans = 0;
        for (Map.Entry<Long, Long> e : map.entrySet()) {
            long m = e.getValue();
            int max = -1;
            for (int i = 1; i <= m; i++) {
                long m2 = m;
                int count = 0;
                for (int j = i; j <= m; j++) {
//                    debug(i, j, m2, count);
                    if (m2 - j >= 0) {
                        m2 = m2 - j;
                        count++;
                    }
                }
                max = Math.max(count, max);
            }
            ans = ans + max;
        }

        System.out.println(ans);

        // out.println("Hello World");
        out.flush();
    }

    Map<Long, Long> primeFactorization(long n) {
        Map<Long, Long> map = new HashMap<>();
        for (long i = 2; i * i <= n; i++) {
            if (n % i != 0) continue;
            long count = 0;
            while (n % i == 0) {
                count++;
                n = n / i;
            }
            map.put(i, count);
        }
        if (n != 1) map.put(n, 1L);
        return map;
    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 35916
#include "bits/stdc++.h"
using namespace std;

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

    int k;
    string s;
    cin >> k >> s;
    if (s.size() <= k)
        cout << s << '\n';
    else
        cout << s.substr(0, k) << "..." << '\n';
    return 0;
}

Measured memory_bytes: 3652
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
typedef long long ll;

int main()
{
    optimiza_io
    string s;
    cin >> s;
    cout << ( s[0] == '7' or s[1] == '7' or s[2] == '7' ? "Yes\n" : "No\n" );
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

ll f(ll b, std::vector<ll>& va)
{
  ll res = 0LL;
  ll N = va.size();
  for (ll i = 0; i < N; i++) {
    res += std::abs(va[i] - (b+i+1));
  }
  return res;
}

bool is_ok(ll b, std::vector<ll>& va)
{
  if (f(b, va) > f(b-1, va)) return true;
  else return false;
}

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

  ll N;
  std::cin >> N;
  std::vector<ll> va(N, 0LL);

  ll ans = 0LL;
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  ll ng = -(std::pow(10, 9) + 1);
  ll ok = +(std::pow(10, 9) + 1);
  while (ok - ng > 1) {
    ll mid = (ng + ok) / 2;
    if (is_ok(mid, va)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  print(f(ok-1, va));
  return 0;
}


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

#define rep(X, Y) for( int (X) = 0; (X) < (Y); ++(X) )
#define rept(X, Y, Z) for( int (X) = (Y); (X) < (Z); ++(X) )

int N, d[101];
long long dp[101][21];

int main(){
	scanf("%d", &N);

	rep( i, N ) scanf("%d", d + i);
	dp[0][d[0]] = 1;

	rept( i, 1, N - 1 ){
		rep( l, 21 ){
			if( l + d[i] <= 20 ) dp[i][l + d[i]] += dp[i - 1][l];
			if( l - d[i] >= 0 ) dp[i][l - d[i]] += dp[i - 1][l];
		}
	}

	std::cout << dp[N - 2][d[N - 1]] << std::endl;

	return 0;
}

Measured memory_bytes: 1224
from itertools import product
n,c = map(int,input().split())
cost = [list(map(int,input().split())) for i in range(c)]
grid = [list(map(int,input().split())) for i in range(n)]
sum0 = []
sum1 = []
sum2 = []
for color in range(c):
  s0,s1,s2 = 0,0,0
  for i in range(n):
    for j in range(n):
      x = grid[i][j]-1
      if (i+j)%3 == 0:
        s0 += cost[x][color]
      elif (i+j)%3 == 1:
        s1 += cost[x][color]
      else:
        s2 += cost[x][color]
  sum0.append((s0,color))
  sum1.append((s1,color))
  sum2.append((s2,color))
ans = 10**18
for a,b,c in product(sum0,sum1,sum2):
  if a[1] != b[1] and b[1] != c[1] and c[1] != a[1]:
    ans = min(ans,a[0]+b[0]+c[0])
print(ans)

Measured memory_bytes: 46300
class UnionFind():
    def __init__(self, N):
        self.par = [i for i in range(N)]
        self.rank = [0 for _ in range(N)]
        self.size = [1 for _ in range(N)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            elif self.rank[x] < self.rank[y]:
                x, y = y, x
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]

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

uf = UnionFind(n)

edge = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
    uf.union(a-1, b-1)
for i in range(k):
    c, d = map(int, input().split())
    edge[c-1].append(d-1)
    edge[d-1].append(c-1)

# 各ノードにおける連結成分の数
cnt = [None] * n
for i in range(n):
    cnt[i] = uf.get_size(i)

# 同じ連結成分かつ関係がある辺の数
cnt_2 = [0] * n
for i in range(n):
    for j in edge[i]:
        if uf.is_same(i, j):
            cnt_2[i] += 1

ans = [None] * n
for i in range(n):
    ans[i] = cnt[i] - cnt_2[i] - 1

print(*ans)

Measured memory_bytes: 118048
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cost;};
//typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)&&islower(c));}
void printvi(vector<int> v){rep(i,0,v.size()){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
void printvil(vector<int> v){rep(i,0,v.size()){cout<<v[i]<<endl;}}
void printvvi(vector<vector<int>> v){
    rep(i,0,v.size()){
        rep(j,0,v[i].size()){
            if(j)cout<<" ";
            cout<<v[i][j];
        }
        cout<<endl;
    }
}
void printvstr(vector<string> v){
    rep(i,0,v.size()){
        cout<<v[i]<<endl;
    }
}

int gcd(int a,int b){
    if(b==0)return a;
    else return gcd(b,a%b);
}

signed main (){
    vector<int> v(10);
    rep(i,0,10)cin>>v[i];
    cout<<accumulate(all(v),0)<<endl;

    
}
/*
*/



Measured memory_bytes: 3104
n, k, *a = map(int, open(0).read().split())

MOD = int(1e9+7)
m = MOD -2
re = 1
s = 2
while m:
        if m&1: re = re*s % MOD
        s = s * s % MOD
        m >>= 1
f = (k+1) * k * re
g = k * (k-1) * re

l = r = 0
for i in range(n):
        for j in range(n):
                if a[i]>a[j]:
                        if i>j: l += 1
                        else: r += 1
print((l*g+r*f) % MOD)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main()
{
	map<string , int> rep;
	rep["SUN"] = 7;
	rep["MON"] = 6;
	rep["TUE"] = 5;
	rep["WED"] = 4;
	rep["THU"] = 3;
	rep["FRI"] = 2;
	rep["SAT"] = 1;
	string s;
	cin >> s;
	cout<<rep[s]<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define SZ(x) ((int)x.size()-1)
#define ms(a,b) memset(a,b,sizeof a)
#define F(i,a,b) for (int i=(a);i<=(b);++i)
#define DF(i,a,b) for (int i=(a);i>=(b);--i)
using namespace std;
inline int read(){
	char ch=getchar(); int w=1,c=0;
	for(;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for(;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
	return w*c;
}
const int M=3e5+10,mod=1e9+7;
char s[M],p[10];
int dp[M][50];
const bool rep[]={0,0,0,1,0,1,1,1};
int trans[50][2],tot;
bool vis[22][1<<21],ok[22][1<<21],clr[22];
bool bf(int len,int sta){
//	cout<<len<<" "<<sta<<"\n";
	if (len==1) return sta;
	if (vis[len][sta]) return ok[len][sta];
	vis[len][sta]=1;
	F(i,0,len-3){
		int o=rep[(sta>>i)&7],cur=(sta&((1<<i)-1))|(o<<i)|((sta>>i+3)<<i+1);
//		cout<<o<<" "<<((sta>>i)&7)<<" ??\n"; 
		if (bf(len-2,cur)) return ok[len][sta]=1;
	}
	return ok[len][sta]=0;
}
bool same(int s1,int l1,int s2,int l2){
	if ((l1^l2)&1) return 0;
	F(i,0,max(l1+10,l2+10)){
		if (!clr[i]){
			clr[i]=1;
			memset(vis[i],0,sizeof(bool)*(1<<i));
		}
	}
	for (int i=!(l1&1);i<=10;i+=2){
		for (int j=0;j<(1<<i);j++){
			if (bf(l1+i,s1|(j<<l1))^bf(l2+i,s2|(j<<l2))) return 0;
		}
	}
	return 1;
}
int val[50],len[50];
void init(){
	ms(clr,0); queue<int> q;
	tot=1; q.push(1);
	while (q.size()){
		int tmp=q.front(),l=len[tmp]+1,x=val[tmp]; q.pop();	
//		cout<<tmp<<" "<<l-1<<" "<<x<<"\n";
		bool flag=0;
		F(i,1,tot){
			if (same(x,l,val[i],len[i])){
				trans[tmp][0]=i;
				flag=1; 
				break; 
			}
		}
		if (!flag) val[++tot]=x,len[tot]=l,trans[tmp][0]=tot,q.push(tot);
		x|=(1<<l-1); flag=0;
		F(i,1,tot){
			if (same(x,l,val[i],len[i])){
				trans[tmp][1]=i;
				flag=1; 
				break;
			}
		}
		if (!flag) val[++tot]=x,len[tot]=l,trans[tmp][1]=tot,q.push(tot);
	}
}
void reduce(int &x){
	x+=(x>>31)&mod;
}
int n;
int main(){
//	int T=read();
//	while (T--){
		scanf("%s",s+1);
		n=strlen(s+1);
//		F(i,0,7) rep[i]=p[i]-'0';
//		cout<<bf(3,0)<<"\n";

		init();
		dp[0][1]=1;
		F(i,0,n-1){
			F(j,1,tot) dp[i+1][j]=0;
			F(j,1,tot){
				if (s[i+1]!='0'){
					reduce(dp[i+1][trans[j][1]]+=dp[i][j]-mod);
				}
				if (s[i+1]!='1'){
					reduce(dp[i+1][trans[j][0]]+=dp[i][j]-mod);
				}
			}
		}
		LL ans=0;
		F(i,1,tot) if (len[i]&1 && bf(len[i],val[i])) ans=(ans+dp[n][i])%mod; 
		cout<<ans<<"\n";
		
//	}
	return 0;
}


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

using namespace std;

int main() {

	long long  a;
	double b;
	long long c;
	cin >> a >> b;

		b *= 100.00001;
		c = (long long)b;

		c = (long long)((long long)a * (long long)c);
		c = c / 100;

		cout << c << endl;

		//long long  a;
		//double b;
		//long long c1,c2,c3;
		//cin >> a >> b;

		//c1 = (long long)b;
		//b *= 10;
		//c2 = ((long long)b) % 10;
		//b *= 10;
		//c3 = ((long long)b) %10;

		//long long a1 = (long long)a * c1;
		//long long a2 = (long long)(a * c2) / 10;
		//long long a3 =(long long)(a * c3) / 100;
		//cout << a1+a2+a3 << endl;

}

Measured memory_bytes: 3712
#include <stdio.h>

int main(){
  int n,a[2][100];
  int ame,ame_max;
  int i,j,down;
  scanf("%d",&n);
  for(i = 0;i < 2;i++){
    for(j = 0;j < n;j++){
      scanf("%d",&a[i][j]);
    }
  }

  ame_max = 0;
  for(i = 0;i < n;i++){
    down = 0;
    ame = 0;
    for(j = 0;j < n;j++){
      ame += a[down][j];
      if(j == i){
        down++;
        ame+= a[down][i];
      }
    }
    if(ame > ame_max){
      ame_max = ame;
    }
  }

  printf("%d\n",ame_max);
  return(0);
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <regex>
#include <vector>
#include <string>
#include <sstream>      // std::ostringstream
using namespace std;
vector<string> split(const string &str, char sep);

//queue
queue<int> qi;
queue<string> qs;
int main(void)
{
  string line = "";
  //改行も含めてfirstlineにブチ込む
  getline(cin, line);
  vector<string> linevec = split(line,' ');
  int rowsize = stoi(linevec[0]);
  int p = stoi(linevec[1]);
  //cout << "rowsize:" << rowsize << endl;
  //cout << "p:" << p << endl;
  for (int i = 0; i < rowsize;i++)
  {
    getline(cin, line);
    vector<string> linevec = split(line,' ');
    qs.push(linevec[0]);
    int process_time = stoi(linevec[1]);
    qi.push(process_time);
  }
  int tmptime = 0;
  while (qi.size() > 0)
  {
    //実行する
    int processing_time = qi.front();
    qi.pop();
    string processing_name = qs.front();
    qs.pop();
    if (processing_time<=p)
    {
      tmptime += processing_time;
      cout <<processing_name<<' '<< tmptime << endl;
    }
    else
    //この実行ではプロセス実行を完了できない
    {
      tmptime += p;
      processing_time -= p;
      qi.push(processing_time);
      qs.push(processing_name);
    }
  }
}
vector<string> split(const string &str, char sep)
{
    std::vector<std::string> v;
    std::stringstream ss(str);
    std::string buffer;
    while( std::getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}


Measured memory_bytes: 5668
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
    int sx,sy,tx,ty;
    int x, y;
    int i;

    scanf("%d %d %d %d",&sx,&sy,&tx,&ty);

    x=tx-sx;
    y=ty-sy;

    //1st move
    for(i=0; i<y; i++)
    {
        printf("U");
    }


    for(i=0; i<x; i++)
    {
        printf("R");
    }

    //2nd move
    for(i=0; i<y; i++)
    {
        printf("D");
    }
    for(i=0; i<x; i++)
    {
        printf("L");
    }

    //3rd move
        for(i=0; i<1; i++)
    {
        printf("L");
    }
    for(i=0; i<y+1; i++)
    {
        printf("U");
    }

    for(i=0; i<x+1; i++)
    {
        printf("R");
    }

    for(i=0; i<1; i++)
    {
        printf("D");
    }

    //4th move
    for(i=0; i<1; i++)
    {
        printf("R");
    }
    for(i=0; i<y+1; i++)
    {
        printf("D");
    }
    for(i=0; i<x+1; i++)
    {
        printf("L");
    }
    for(i=0; i<1; i++)
    {
        printf("U");
    }

    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
    int n; cin >> n;
    vector<int> a(n); rep(i,n) cin >> a[i];
    int now = 0;
    rep(i,n) if(a[i] == now+1) now++;
    if(now == 0) cout << -1 << "\n";
    else cout << n - now << "\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int> > g[100005];
int j[100005];

int main() {
	// your code goes here
    int n,i,j,s[30005],a[5],m,p,ans=0;
    char ss[30005];
    cin >> n >> ss;
    for(i=0;i<n;i++){
        s[i]=ss[i]-'0';
    }
    for(i=0;i<1000;i++){
        m=i;
        bool pb=false;
        a[2]=m%10; m=(m-m%10)/10;
        a[1]=m%10; m=(m-m%10)/10;
        a[0]=m%10;
        p=0;
        for(j=0;j<n;j++){
            if(s[j]==a[p]) p++;
            if(p==3){
                ans++;
                pb=true;
            }
            if(pb) break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2688
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
 

int func(int X){
	int res = 0;
	while(X != 0){
		bitset<20> bit(X);
		int pop_cnt = bit.count();
		X = X % pop_cnt;
		res++;
		// cout << "          X: " << X << " pop_cnt: " << pop_cnt << " res: " << res << endl;
	}
	return res;
}


int main(){
	int N;
	cin >> N;
	string s;
	cin >> s;
	reverse(s.begin(), s.end());

	int pop_cnt = 0;
	for(int i=0; i<N; i++){
		if(s[i] == '1') pop_cnt++;
	}

	vector<int> Xi(N, 0);
	vector<int> ans(N, 0);
	for(int bit=0; bit<2; bit++){//s[i]==0の場合と1の場合で2回ループ
		int pc;
		if(bit == 0) pc = pop_cnt + 1;
		else pc = pop_cnt - 1;
		if(pc <= 0) continue;// 以降0割り(%だけど)が発生するのでcontinueする
		// cout << " pop_cnt: " << pop_cnt << "   pc: " << pc << endl;
		int X = 0;
		int pow2_i = 1 % pc;
		for(int i=0; i<N; i++){
			X += (s[i]-'0') * pow2_i;    X %= pc;
			pow2_i *= 2;                 pow2_i %= pc;
		}
		pow2_i = 1 % pc;
		for(int i=0; i<N; i++){
			if((s[i]-'0') == bit){
				if(bit == 0) Xi[i] = (X + pow2_i) % pc;
				else Xi[i] = (X+pc - pow2_i) % pc;
				ans[i] = 1 + func(Xi[i]);//すでに pop_cntで割った余りを1回計算したので func()に+1
			}
			pow2_i *=2;					pow2_i %= pc;
		}
		
	}
	
	// vector<int> ans(N, 1);// すでに pop_cntで割った余りを1回計算したので 0ではなく1で初期化
	// for(int i=0; i<N; i++){  //しかしこれだと 1を0にしたときに全部の桁が0になった場合も答えが1になってしまうので，上のforループにいれるのが正解 そのためここはコメントアウト
	// 	// cout << " Xi[" << i << "]: " << Xi[i] << endl;
	// 	ans[i] += func(Xi[i]);
	// 	//if(pop_cnt == 0) ans[i] = 0;
	// }

	for(int i=0; i<N; i++){
		cout << ans[N-i-1] << endl;
	}



}


Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+3;


int main(){

    string s;
    cin>>s;

    if(s[s.size()-1]=='s')
        cout<<s<<"es"<<endl;
    else
        cout<<s<<"s"<<endl;

    return 0;
}


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


signed main() {
    int N;
    cin >> N;
    map<int, int> mp;
    rep(i, N) {
        int a;
        cin >> a;
        mp[a]++;
    }

    int res = 0;
    for(auto &p: mp) {
        if(p.se%2) res++;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 6528
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 1987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

int S(ll x)
{
	int c=0;
	while(x>0)
	{
		c+=x%10;
		x/=10;
	}
	return c;
}
Vll v;
void get(ll x,ll y)
{
	while(x<=(ll)1e15 && y*S(x)>=x)
	{
		v.pb(x);
		x+=y;
	}
}
int main(){
	fup(i,1,9,1)v.pb(i);
	for(ll x=19,y=10;x<=(ll)1e15;)
	{
		get(x,y);
		x=(x*10)+9;
		y*=10;
	}
	sort(ALL(v));
	v.resize(unique(ALL(v))-v.begin());
	int k;
	scanf("%d",&k);
	fup(i,0,k-1,1)printf("%lld\n",v[i]);
}

Measured memory_bytes: 256
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

A, B, C, D = LI()

flag = False
for i in range(1000):
    if i % 2 == 0:
        C -= B
    else:
        A -= D

    if A <= 0:
        flag = False
        break
    elif C <= 0:
        flag = True
        break

YesNo(flag)


Measured memory_bytes: 65328
import java.util.*;

public class Main {
    public void main(Scanner sc) {
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	int c = sc.nextInt();
    	long k = sc.nextLong();
    	
    	System.out.println((k % 2 == 0) ? a - b : b - a);
    }

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


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define ll long long
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
#define dbg3(x) cerr<<#x<<"\n"
using namespace std;
#define reg register
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
const int MN=300005;
int a[MN],N;
void No(){puts("No");exit(0);}
void Yes(){puts("Yes");exit(0);}
void chk(int l,int r)
{
	reg int i,_1=0,_2=0;
	for(i=l+1;i<=r-1;i+=2)if(a[i]!=i)No();
	for(i=l;i<=r;i+=2)if(a[i]==i)No();
	for(i=l;i<=r;i+=2)
		if(i<a[i]){if(_1>a[i])No();_1=a[i];}
		else{if(_2>a[i])No();_2=a[i];}
}
main()
{
	N=read();reg int i;
	for(i=1;i<=N;++i) a[i]=read();
	int l=1,r;
	while(a[l]==l&&l<N)++l;
	while(1)
	{
		if(a[l]==l)Yes();
		if(l+2>N)No();r=l+2;
		int Mi=min(a[l],a[r]),Ma=max(a[l],a[r]);
		while((r!=Ma||l!=Mi)&&r<=N)r+=2,Mi=min(Mi,a[r]),Ma=max(Ma,a[r]);
		if(r>N)No();chk(l,r);
		l=r+1;while(a[l]==l&&l<N)++l;
		if(l>N)break;
	}
	Yes();
}

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

int main() {
  int a,b,c,d,ans=0;
  cin>>a>>b>>c>>d;
  if (a>=b) {
    ans+=b;
  }
  else{
    ans+=a;
  }
  if (c>=d){
    ans+=d;
  }
  else{
    ans+=c;
  }
  cout<< ans << endl;
}



Measured memory_bytes: 256
#include <iostream>

#include <vector>

#include <cassert>

#include <algorithm>

#include <functional>

#include <cmath>

#include <iomanip>

#include <limits>
#include <bits/stdc++.h>
#include<queue>
#include<type_traits>
#include<cstdint>
using namespace std;
using ll=long long;
int main(){
   int n,l;
   cin >> n >> l;
   ll pre=1e9;
   ll sum=0;
   ll ok;
   for(int i=1;i<n+1;i++){
       ll x=l+i-1;
       ll y=abs(x);
       sum += x;
       if(pre>y){
           pre=y;
           ok=x;
       }
   }
   cout << sum-ok <<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <iostream>
#include <algorithm>
#include <vector>
#include <bitset>

using namespace std;

bitset<2000> x;
bitset<2000> y[2000];
bitset<2000> z[2000];
int dist[2000];

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

  const int n = a.size();

  for (int i = 0; i < n; i++) {
    x[i] = a[i] == '1';
    for (int j = 0; j < n; j++) {
      y[i][j] = b[(i + j) % n] == '1';
    }
  }
  for (int i = 0; i < n; i++) {
    z[i] = x ^ y[i];
    dist[i] = z[i].count();
  }

  static bitset<2000> u;
  int ans = 1e9;
  for (int l = 0; l <= n; l++) {
    u |= y[l % n];
    bitset<2000> v = u;
    int mn = 1e9;
    for (int r = 0; r <= n * 2; r++) {
      int k = (l - r + n * 3) % n;
      mn = min(mn + 1, dist[k]);
      v |= y[k];
      if ((z[k] & ~v).any()) continue;
      ans = min(ans, mn + l + r);
    }
  }
  u.reset();
  for (int r = 0; r <= n; r++) {
    u |= y[(n - r) % n];
    bitset<2000> v = u;
    int mn = 1e9;
    for (int l = 0; l <= n * 2; l++) {
      int k = (l - r + n * 3) % n;
      mn = min(mn + 1, dist[k]);
      v |= y[k];
      if ((z[k] & ~v).any()) continue;
      ans = min(ans, mn + l + r);
    }
  }

  if (ans == 1e9) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 1408
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()

	for i := 0; i < n; i++ {
		a := nextInt()
		if a%2 == 0 && a%3 != 0 && a%5 != 0 {
			_, _ = fmt.Fprintf(writer, "DENIED")
			return
		}
	}

	_, _ = fmt.Fprintf(writer, "APPROVED")
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
import numpy as np
from collections import defaultdict

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

AB = []
G = defaultdict(list)
for _ in range(m):
    a, b = map(int, input().split())
    AB.append([a, b])
    G[a].append(b)
    G[b].append(a)

ans = 0
for a, b in AB:
    memo = [0]*(n+1)
    memo[a] = 1
    que = [c for c in G[a] if c != b]
    while que:
        c = que.pop()
        memo[c] = 1
        for nc in G[c]:
            if memo[nc] == 0:
                que.append(nc)
    if np.count_nonzero(memo) != n:
        ans += 1
print(ans)

Measured memory_bytes: 12496
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define ll long long int

int main(int argc, const char * argv[]) {
	int N;
	cin >> N;
	if(N==3 || N==5 || N==7){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}


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

int n;

int main() {
  std::cin >> n;
  for (int i = 1; i <= n; i++) {
    int x = i * 1.08;
    if (x == n) {
      std::cout << i << std::endl;
      return 0;
    }
  }
  std::cout << ":(" << std::endl;
}

Measured memory_bytes: 256
import java.math.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int X = sc.nextInt();
    int Y = sc.nextInt();
    sc.close();

    int[] ans = new int[N];
    for (int i = 1; i < N + 1; i++)
      for (int j = i + 1; j < N + 1; j++)
        ans[Integer.min(j - i,
            Math.abs(X - i) + 1 + Math.abs(j - Y))]++;

    for (int i = 1; i < N; i++)
      System.out.println(ans[i]);
  }
}


Measured memory_bytes: 24404
#include<iostream>
#include<vector>
#define _USE_MATH_DEFINES
#include<math.h>
#include<algorithm>
#include<memory>
#include<string>
typedef long long ll;
#define Rep(i,n) for(int i = 0;i < (n);i++)	

int gcd(int a, int b) { if (b == 0)  return a;  else  return gcd(b, a % b);  }
int lcm(int a, int b) { return a * b / gcd(a, b); }
void swap(int& a, int& b) { int temp = a; a = b; b = temp; return; }
int ncr(int n, int r) { int a = 1; Rep(i, r) a = (a * (n - i)) / (i + 1); return a; }
int npr(int n, int r) { int a = 1; Rep(i, r) a *= n - i; return a; }
int mod(int a, int b) { return a % b; }

int main() {
	int s, w;
	std::cin >> s >> w;
	if (s <= w) {
		std::cout << "unsafe" << std::endl;
	}
	else {
		std::cout << "safe" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3596
#![allow(unused_imports)]
#![allow(dead_code)]

mod reader {
    use std;

    macro_rules! read_line {
        () => {{
            let mut input = String::new();
            std::io::stdin().read_line(&mut input).unwrap();
            input
        }};
    }

    pub fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
        read_line!().split_whitespace()
            .map(|e| e.parse().ok().unwrap())
            .collect()
    }
}

#[macro_use]
mod misc {
    #[macro_export]
    macro_rules! bind_from_vec {
        ( $($variable:ident),+ = $vector:expr ) => {
            let mut v = $vector.clone().into_iter();
            $(let $variable = v.next().unwrap();)+
        };
    }
}

use reader::*;
use misc::*;

fn main() {
    bind_from_vec!(a, b, t = read_to_vec::<i32>());

    println!("{}", t / a * b)
}


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

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int[] p = new int[a];
        for (int i = 0; i < a; i++) {
            p[i] = scanner.nextInt();
        }
        int[] q = new int[b];
        for (int i = 0; i < b; i++) {
            q[i] = scanner.nextInt();
        }
        int[] r = new int[c];
        for (int i = 0; i < c; i++) {
            r[i] = scanner.nextInt();
        }
        Arrays.sort(p);
        Arrays.sort(q);
        Arrays.sort(r);
        //забеьем красные по максимуму
        int ci = c - 1;
        int ai = Math.max(0, a - x);
        if (x > a) ci -= (x - a);
        int bi = Math.max(0, b - y);
        if (y > b) ci -= (y - b);
        while (ci >= 0 && (ai < a && p[ai] < r[ci] || bi < b && q[bi] < r[ci])) {
            if (ai < a && bi < b) {
                if (p[ai] < q[bi]) {
                    ai++;
                    ci--;
                } else {
                    bi++;
                    ci--;
                }
            } else if (ai < a) {
                ai++;
                ci--;
            } else {
                bi++;
                ci--;
            }
        }

        long sum = 0;
        for (int i = ai; i < a; i++) {
            sum += p[i];
        }
        for (int i = bi; i < b; i++) {
            sum += q[i];
        }
        for (int i = ci + 1; i < c; i++) {
            sum += r[i];
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 90736
#include <iostream>
#include <vector>
#include <numeric>
#include <string>

using namespace std;
using ll = int64_t;

int main(){
  int N;
  cin >> N;
  vector<ll> march(5);
  for(int i=0;i<N;i++){
	string s;
    cin >> s;
    switch(s[0]){
      case 'M':
        march[0]++;
        break;
      case 'A':
        march[1]++;
        break;
      case 'R':
        march[2]++;
        break;
      case 'C':
        march[3]++;
        break;
      case 'H':
        march[4]++;
        break;
    }
  }
  ll ans = 0;
  ans += march[0] * march[1] * march[2];
  ans += march[0] * march[1] * march[3];
  ans += march[0] * march[1] * march[4];
  ans += march[0] * march[2] * march[3];
  ans += march[0] * march[2] * march[4];
  ans += march[0] * march[3] * march[4];
  ans += march[1] * march[2] * march[3];
  ans += march[1] * march[2] * march[4];
  ans += march[1] * march[3] * march[4];
  ans += march[2] * march[3] * march[4];
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define println(x) cout << x << endl
#define fi first
#define se second
#define Yes println("Yes")
#define No println("No")
#define YES println("YES")
#define NO println("NO")

using pii = pair<int, int>;

struct Range
{
    int l;
    int r;
    Range(int l, int r)
    {
        this->l = l;
        this->r = r;
    }
    bool covers(Range& r1)
    {
        return r > r1.l;
    }
};

bool operator<(const Range& r1, const Range& r2)
{
    return r1.r < r2.r;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<Range> vr;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        Range r = Range(a, b);
        vr.push_back(r);
    }
    sort(all(vr));
    int count = 1;
    Range prev = vr[0];
    rep2(i, 1, m)
    {
        if (prev.covers(vr[i])) continue;
        else
        {
            prev = vr[i];
            count++;
        }
    }
    println(count);
}

Measured memory_bytes: 1400
#include<iostream>

int gcd(int x, int y){
	if (y == 0)return x;
	return gcd(y, x%y);
}

int main(){
	int a, b;
	while (std::cin >> a >> b){
		int tmp = gcd(a, b);
		std::cout << tmp << " " << a / tmp*b << std::endl;
	}
	return 0;
}

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

//#define int long long
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,n+1)
#define repst(i,s,n) reps(i,s,n+1)
#define reprt(i,n,t) for(ll (i)=(n);(i)>=t;--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<n;++i){cout<<x[i]<<(i==n-1?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// Dと同様に操作は "n以上の要素を貪欲に選びそれをn減らし、その他を1増やす" と言い換えられる
// n以上の要素を見つけるたびにa[i]/n回操作をするのを更新されなくなるまで繰り返すだけ
// 4450回もやれば必ず更新が終わるらしい

ll n, a[50], r, t;

signed main() {
	cin >> n;
	rep(i,n) cin >> a[i];
	rep(i,114514) {
		ll pre = r;
		rep(i,n) {
			if (a[i]<n) continue;
			t = a[i]/n;
			r += t;
			a[i] -= t*n;
			rep(j,n) if (i!=j) a[j] += t;
		}
		if (pre==r) break;
	}
	cout << r << ln;
}

Measured memory_bytes: 256