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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m; cin>>n>>m;
    vi a(n);
    rep(i,n) cin>>a[i];
    sort(rall(a));
    vll sum(n+1);
    rep(i,n) sum[i+1]=sum[i]+a[i];

    int l=0,r=200020; //l OK r NG
    while(r-l>1){
        int mid=(l+r)/2;
        int idx=n;
        ll cnt=0;
        rep(i,n){
            while(idx>0 && a[i]+a[idx-1]<mid) idx--;
            cnt+=idx;
        }
        if (cnt>=m){
            l = mid;
        }else{
            r = mid;
        }
    }
    int idx=n;
    ll ans=0,cnt=0;
    rep(i,n){
        while(idx>0 && a[i]+a[idx-1]<l) idx--;
        ans+=sum[idx];
        ans+=(ll)a[i]*idx;
        cnt+=idx;
    }
    ans-=(cnt-m)*l;
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 1408
I = input().split()

W = int(I[0])
H = int(I[1])
x = int(I[2])
y = int(I[3])
r = int(I[4])

answer = True

if x - r < 0:
    answer = False
if x + r > W:
    answer = False
if y - r < 0:
    answer = False
if y + r > H:
    answer = False

if answer == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 7728
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    int K,N;
    cin >> K >> N;
    int a[N];
    for(int i=0; i<N; i++) cin >> a[i];
    int d=0;
    for(int i=0; i<N-1; i++){
        if (a[i+1]-a[i]>d) d=a[i+1]-a[i];
    }
    if(K-a[N-1]+a[0]>d) d=K-a[N-1]+a[0];
    cout << K-d;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int a,b;
    while(1)
    {
        scanf("%d %d",&a,&b);
        if(a==0 && b==0)
            break;
        if(a>=b)
            printf("%d %d\n",b,a);
        else if(a<b)
            printf("%d %d\n",a,b);
    }
    return 0;
}



Measured memory_bytes: 2040
#include<stdio.h>
#define MAX 100000

void swap(int *x,int *y){
  int t = *x;
  *x=*y;
  *y=t;
}

int partition(int *A,int p,int r){
  int x = A[r];
  int i = p-1;
  int j;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      swap(&A[i],&A[j]);
    }
  }
  swap(&A[i+1],&A[r]);
  return i+1;
}


int main(){
  int A[MAX],n,i;
  scanf("%d",&n);
  int center;
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  center = partition(A,0,n-1);
  for(i=0;i<n;i++){
    if(i==center){
      printf("[%d] ",A[i]);
      continue;
    }
    if(i!=n-1)printf("%d ",A[i]);
    else printf("%d\n",A[i]);
      }
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  ll x;
  cin >> x;

  ll ans = 0;
  while (x > ans * (ans + 1) / 2) ans++;
  cout << ans << endl;


  
  return 0;
}

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

int main() {
	int A,B,T;
	cin >> A >> B >> T;
  cout << T/A * B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

const int NUM = 62;
ll combi[NUM][NUM];
void calcCombi() {
  combi[0][0] = 1;
  REP(i, NUM-1) {
    combi[i][0] = combi[i][i] = 1;
    REP(j, i)
      combi[i+1][j+1] = combi[i][j] + combi[i][j+1];
  }
}

int main() {
  calcCombi();
  // REP(i,NUM) {
  //   REP(j,NUM) cout << combi[i][j] << " ";
  //   cout << endl;
  // }
  ll n, m;
  while(cin>>n>>m,n||m) {
    ll now = m;
    ll num = 0;
    while(now - combi[n][num] > 0) {
      now -= combi[n][num];
      //cout << now << endl;
      num++;
    }
    //cout << num << endl;
    string ans(n,'0');
    for (int i=0; i<n; ++i) {
      if (num == 0) break;
      //cout << now << " " << num << " " << combi[n-i-1][num] << endl;
      if (now - combi[n-i-1][num] > 0) {
        ans[i] = '1';
        now -= combi[n-i-1][num];
        num--;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
// #ifndef ONLINE_JUDGE
// #include "debug.cpp"
// #endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int n; cin >> n;
  string s1,s2; cin >> s1 >> s2;

  for(int i=0;i<n;i++){
    cout << s1[i] << s2[i];
  }
  

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);

	if(a>=b)
	if(b>=c)
		printf("%d %d %d\n",c,b,a);

	else if(c>=a)
		printf("%d %d %d\n",b,a,c);

		else
			printf("%d %d %d\n",b,c,a);

	else if(c<a)
		printf("%d %d %d\n",c,a,b);

	else if(b>c)
		printf("%d %d %d\n",a,c,b);

	else
		printf("%d %d %d\n",a,b,c);
	return 0;
}

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

int main(){
  uint64_t N;
  cin >> N;
  uint64_t h_sum = 0;
  uint64_t h_old;

  cin >> h_old;

  for( uint64_t i = 0; i < N-1; ++i ){
    uint64_t h;
    cin >> h;
    if( h < h_old ){
      uint64_t diff = h_old - h;
      h_sum += diff;
      h += diff;
    }

    h_old = h;
  }

  cout << h_sum << endl;

}

Measured memory_bytes: 3628
#include<stdio.h>
#include<memory.h>
int n, g[21][21];
int dijkstra(start, goal){
	int c[21], f[21]={0}, i, nearest, t;
	memset(c, 1, sizeof(c));
	c[start] = 0;
	while(1){
		nearest=0;
		for(i=1;i<=n;i++){
			if(!f[i] && (!nearest || c[i]<c[nearest]))
				nearest=i;
		}
		if(!nearest)
			return c[goal];
		f[nearest]=1;
		for(i=1;i<=n;i++){
			t=c[nearest]+g[nearest][i];
			if(t<c[i])
				c[i]=t;
		}
	}
}
int main(){
	int m, x1, x2, y1, y2;
	int i, c12, c21;
	memset(g, 1, sizeof(g));
	scanf("%d%d",&n,&m);
	for(i = 0; i < m; i ++){
		int a,b,c,d;
		scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		g[a][b] = c;
		g[b][a] = d;
	}
	scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);
	c12 = dijkstra(x1, x2);
	c21 = dijkstra(x2, x1);
	printf("%d\n", y1-y2-c12-c21);
	exit(0);
}

Measured memory_bytes: 0
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>

using namespace std;

vector<int> v(10);

int l,r;
int flag;

void dfs(int d){

    if(d==10){
        flag=1;
        return;
    }

    if(flag) return;

    int x = v[d];

    if(x>l){

        int tmp = l;
        l=x;
        dfs(d+1);
        l=tmp;

    }

    if(flag) return;

    if(x>r){

        int tmp = r;
        r=x;
        dfs(d+1);
        r = tmp;

    }

}

int main(){

    int N;

    cin >> N;

    for(int t=0;t<N;++t){

        for(int i=0;i<10;++i)cin >> v[i];

        l = r = flag = 0;

        dfs(0);

        if(flag)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;

    }

    return 0;

}

Measured memory_bytes: 1184
n=int(input())
A=list(map(int,input().split()))
mod = 10**9+7;ans=0
for i in range(60):
  cnt=sum([1 for a in A if a>>i&1]) 
  cnt=cnt*(n-cnt)%mod
  cnt=2**i*cnt%mod
  ans+=cnt
print(ans%mod)

Measured memory_bytes: 42156
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void AGC023A();

#if 1
int main()
{
	AGC023A();
	fflush(stdout);
	return 0;
}
#endif

static void AGC023A()
{
	int N;
	getint(N);

	std::vector<LLONG> an(N, 0);
	for (int i = 0; i < N; i++) {
		getint(an[i]);
	}

	LLONG sum = 0;
	std::map<LLONG, LLONG> summap;
	summap[0] = 1;
	for (int i = 1; i <= N; i++) {
		sum = sum + an[i - 1];
		summap[sum]++;
	}

	LLONG ans = 0;
	for (auto it = summap.begin(); it != summap.end(); it++) {
		ans += (it->second * (it->second - 1LL)) / 2LL;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 14336
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    int ans=0;
    rep(i,3)if(s[i]=='R') ans=1;
    rep(i,2)if(s[i]=='R' && s[i+1]=='R') ans=2;
    if(s=="RRR") ans=3;
    cout<<ans<<endl;
}


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

int main(){
	int H, W, i, j;
	
	while(1){
		cin >> H >> W;
		if (H == 0 && W ==0){
			break;
		}
		for(i = 0; i < H; i++){
			for(j = 0; j < W;j++){
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}
    return 0;
}

Measured memory_bytes: 3088
def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    inlis = set(inlis)
    inlis = list(inlis)
    inlis.sort()

    while len(inlis) > 1:
        tmp = 0
        i = 1
        while tmp < len(inlis):
            #print(i, tmp)
            if inlis[i] % inlis[0] != 0:
                inlis[i] %= inlis[0]
                i += 1
                if i >= len(inlis):
                    break
            else:
                inlis.remove(inlis[i])
            tmp += 1
        inlis = set(inlis)
        inlis = list(inlis)
        inlis.sort()
        #print(inlis, len(inlis))
    print(inlis[0])


if __name__ == "__main__":
    main()

Measured memory_bytes: 101132
#include <iostream>
#include <vector>
using namespace std;
long long const mod = 1000000007;

long long mod_pow(long long a, long long b){
    long long res = 1;
    a %= mod;
    while(b > 0){
        if(b%2 == 1) res = (res * a) % mod;
        a = (a * a) % mod;
        b /= 2;
    }
    return res;
}

long long mod_div(long long a){
    return mod_pow(a, mod-2);
}

long long mod_comb(long long a, long long b){
    if(b < 0 || a < b)return 0;
    if(b > a/2)return mod_comb(a, a-b);
    long long res = 1;
    for(long long i = 0; i < b; i++){
        res = (res * ((a-i)%mod)) % mod;
        res = (res * mod_div(b-i)) % mod;
    }
    return res;
}

int main(void){
    int x, y;
    cin >> x >> y;
    if((x+y)%3 > 0 || x*2-y < 0 || y*2-x < 0){
        cout << 0 << endl;
        return 0;
    }
    int a = (2*x-y)/3;
    int b = (2*y-x)/3;
    cout << mod_comb(a+b, a) << endl;
}


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

int main() {
    int ans;
    vector<int> line(3);
    rep(i, 3) cin >> line.at(i);
    sort(line.begin(), line.end());
    ans = line.at(0) * line.at(1) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] n = sc.nextLine().toCharArray();
        char tmp = n[0];
        int count = 0;
        for(int i = 0;i<n.length;i++){
            if(n.length-1 != i){
                if(n[i] == n[i+1]){
                    count++;
                    if(n[i] == '0'){
                        n[i+1] = '1';
                    }else{
                        n[i+1] = '0';
                    }
                }
            }
        }
        System.out.println(count);
    }
}

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

int main() {
    int a,b;
    cin>>a>>b;
    ((a+b)>(a-b))?((a+b)>(a*b)?cout<<a+b:cout<<a*b):((a-b)>(a*b)?cout<<(a-b):cout<<a*b);
    return 0;
}


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

#define ll long long 
#define pi  pair<int,int>
#define ti  tuple<int,int,int>
#define mt  make_tuple
#define mk  make_pair
#define vi  vector<int>
#define vll vector<ll>
#define fastInOut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pr(a) for(auto x:a) cout<<x<<" ";
#define prmap(m) for(auto x:m) cout<<x.first<<" "<<x.second<<"\n";


ll n,m;
int main() {
    fastInOut
    ll k,x;

    cin>>k;
    string s;
    cin>>s;
    int c=0;
    for(int i=0;i<k;i++){
     if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
         c++;
         i++;
      }
    }
     cout<<c;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            int C = int.Parse(Console.ReadLine());
            int D = int.Parse(Console.ReadLine());
            int ans = 0;
            if (A >= B) { ans += B; }
            else { ans += A; }
            if (C >= D) { ans += D; }
            else { ans += C; }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun May 10 21:39:20 JST 2020
 **/

template <class T> inline bool chmin(T& a, const T& b) {
    if (a <= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmax(T& a, const T& b) {
    if (a >= b) return false;
    a = b;
    return true;
}

void no() {
    std::cout << "No" << std::endl;
    exit(0);
}

using pii = std::pair<Int, Int>;
signed main() {
    Int n;
    std::cin >> n;
    Int total = 0;
    std::vector<std::vector<pii>> ps(2);
    REP(i, n) {
        std::string s;
        std::cin >> s;
        Int mi = 0, acc = 0;
        for (char c : s) {
            acc += c == '(' ? 1 : -1;
            chmin(mi, acc);
        }
        total += acc;
        if (acc >= 0) {
            ps[0].push_back({mi, acc});
        } else {
            ps[1].push_back({mi - acc, -acc});
        }
    }
    if (total != 0) no();
    REP(t, 2) {
        Int cur = 0;
        std::sort(ps[t].rbegin(), ps[t].rend());
        for (auto& p : ps[t]) {
            if (cur + p.first < 0) no();
            cur += p.second;
        }
    }
    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 19344
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var ans = 0;
        if (a >= b) { ans += a; a--; }
        else { ans += b; b--; }
        ans += Max(a, b);
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=sum(p[0:k])+k
s=sum(p[0:k])+k
for i in range(1,n-k+1):
    s+=-p[i-1]+p[i+k-1]
    if ans<s:
        ans=s
print(ans/2)

Measured memory_bytes: 98880
from math import factorial as F
N, M = map(int, input().split())
N, M = min(N, M), max(N, M)
mod = 10**9+7

if M-N > 1:
    print(0)
elif M-N == 1:
    print(F(M)*F(N) % mod)
else:
    print(F(M)**2*2 % mod)


Measured memory_bytes: 5180
N=int(input())
*S,=map(int,input().split())
Q=int(input())
*T,=map(int,input().split())

# N=5
# S=[1,2,3,4,5]
# Q=3
# T=[9]

def bs(key, l):
    low=0
    high=len(l)-1 # 最大値のindexはリストの長さから1を引く
    while low<=high: # lowがhighより低い限りは処理を続ける。
        mid = (low+high)//2
        if l[mid] == key:
            return True
        elif key < l[mid]: 
            high = mid-1 # この時点でmidではないので1つずらすこと
        else:
            low = mid+1  # この時点でmidではないので1つずらすこと
    else:
        return False
cnt=0
for i in T:
    if bs(i, S):
        cnt+=1
print(cnt)


Measured memory_bytes: 16712
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    int n;
    cin >> n;
    lint cnt = 0;
    vector<char> a(n);
    int l = 0;
    int r = n - 1;
    REP(i,n) cin >> a[i];
    while(1){
        while(a[l] != 'W' && l < n)
            l++;
        while(a[r] != 'R' && r >= 0)
            r--;
        if(l >= n || r < 0)
            break;
        if(l >= r)
            break;
        char temp = a[l];
        a[l] = a[r];
        a[r] = temp;
        cnt++;
    }
    println(cnt);
    return 0;
}

Measured memory_bytes: 3600
n = int(input())
an = list(map(int,input().split()))
a = sorted(an, reverse=True)
alice = 0
bob = 0
for i in range(n):
    if i % 2 == 0:
        alice += a[i]
        
    else:
        bob += a[i]
    
print(alice - bob)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int dis[2010];
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		int n, x, y;
		cin >> n >> x >> y;
		for (int i = 1; i < n; i++) {
			for (int j = i + 1; j <= n; j++) {
				if (i <= x && j >= y) dis[x - i + j - y + 1]++;
				else if (i <= x && j <= x) dis[j - i]++;
				else if (i >= y && j >= y) dis[j - i]++;
				else if (i > x && j < y) dis[min(j - i, y - x + 1 - (j - i))]++;
				else if (i > x && j >= y) dis[min(j - i, j - y - x + i + 1)]++;
				else if (i <= x && j < y) dis[min(j - i, y  + 1 - j + x  - i)]++;
			}
		}
		for (int i = 1; i < n; i++) cout << dis[i] << "\n";
	}
	return 0;
}

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

int main(void){
    int N;
    cin >> N;
    int check = 0;

    for(int i = 0; N - (4*i) >= 0; i++){
        for(int j = 0; N - (7*j) >= 0; j++){
            if(4*i + 7*j == N){
                check++;

            }
        }
    }
    if(check >= 1)
        cout << "Yes" << endl;
    else if(check == 0)
        cout << "No" << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';
const ll MOD=1000000007;
using namespace std;

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

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

long long kaijo(ll index, ll conti){
    ll ans=1;
    rep(i, conti){
        ans*=index;
        ans=ans%MOD;
        index--;
    }
    //cout<<modinv(ans, MOD)<<endl;
    return ans%MOD;
}

long long COM(ll n, ll r){
    return kaijo(n, r)*modinv(kaijo(r, r), MOD)%MOD;
}



int main(void){
    ll n, a, b, da=0, db=0;
    cin>>n>>a>>b;
    ll po=modpow(2, n, MOD);
    da=COM(n, a);
    db=COM(n, b);
    //cout<<po<<sp<<da<<sp<<db<<endl;
    cout<<(po-da-db-1+2*MOD)%MOD<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys

def base_convert(n, b):
  if not n: return 0
  res = ''
  while n:
    n, r = divmod(n, b)
    if r < 0: n += 1; r -= b
    res += str(r)
  return int(res[::-1])

n = int(sys.stdin.readline().rstrip())

def main():
    print(base_convert(n, -2))

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3060
import sys


def input(): return sys.stdin.readline().strip()


def main():
    H, W = map(int, input().split())
    s = [['.']*(W+2) for _ in range(H+2)]
    for i in range(H):
        s[i+1][1:-1] = list(input())

    # U L D R
    dx = [0, -1, 0, 1]
    dy = [-1, 0, 1, 0]

    for i in range(1, H+1):
        for j in range(1, W+1):
            if s[i][j] == '.':
                continue

            count = 0
            for x, y in zip(dx, dy):
                if s[i+y][j+x] == '.':
                    count += 1

            if count == 4:
                print('No')
                return

    print('Yes')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
using namespace std;
typedef long long ll;

int main(){
  ll a, b;
  cin >> a >> b;
  
  int ans = 2018;
  //string ans = "Yes";
  //string ans = "No";
  //string ans = "YES";
  //string ans = "NO";
  b = min(b, a + 4038);
  for (ll i = a; i <= b; i++){
    for (ll j = i + 1; j <= b; j++){
      int x = i * j % 2019;
      ans = min(ans, x);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
int main(void){
    int n,in,t=0,qt;
    string s;
    cin>>n>>qt;
    queue<pair<string,int>> q;
    rep(i,n){
        cin>>s>>in;
        q.push({s,in});
    }
    while(!q.empty()){
        pair<string,int> p=q.front();q.pop();
        t+=min(p.sc,qt);
        if(p.sc-qt>0){
            q.push({p.fs,p.sc-qt});
        }
        else{
            cout<<p.fs<<" "<<t<<endl;
        }
    }
}






Measured memory_bytes: 6264
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
using namespace std;
#define REP(i,m,n) for (int i = (int) (m); i < (int) (n); i++)
#define REP1(i,m,n) for (int i = (int) (m); i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
int main(){
    long double L;
    cin>>L;
    printf("%Lf",pow(L/3,3));
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

// debug
template <class T> ostream& operator<<(ostream &s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  string ss; cin >> ss;
  reverse(ALL(ss));
  ss += 'a';
  int n = ss.size();
  vector<int> s(n); REP (i, n) s[i] = ss[i] - 'a';

  vector<int> bef(26, -1);
  vector<int> dp(n + 1, 1e18);
  dp[0] = 0;
  vector<pair<int, char>> recon(n + 1, {-1, -1}); // {i, c}
  REP (i, n) {
    REP (c, 26) {
      if (chmin(dp[i + 1], dp[bef[c] + 1] + 1)) {
        recon[i + 1] = {bef[c], 'a' + c};
      }
    }
    bef[s[i]] = i;
  }
  string ans = "";
  int tmp = n - 1;
  while (tmp >= 0) {
    ans += recon[tmp + 1].se;
    tmp = recon[tmp + 1].fi;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6804
def resolve():
  N = int(input())
  count = 0
  for _ in range(N):
    D = [int(x) for x in input().split(" ")]
    if D[0] == D[1]:
      count += 1
    else:
      count = 0
    if count >= 3:
      break
  print("Yes" if count >= 3 else "No")

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 62364
n, k, l = map(int, input().split())

class UnionFind(object):
    def __init__(self, n):
        self._par = list(range(n))
        self.size = [1] * n
 
    def root(self, v):
        if self._par[v] == v:
            return v
        self._par[v] = self.root(self._par[v])
        return self._par[v]
 
    def unite(self, u, v):
        u, v = self.root(u), self.root(v)
        if u == v:
            return False
        if self.size[u] > self.size[v]:
            u, v = v, u # size[u] <= size[v]
        self.size[v] += self.size[u]
        self._par[u] = v
 
    def is_connected(self, u, v):
        return self.root(u) == self.root(v)


rood = UnionFind(n)
train = UnionFind(n)

for _ in range(k):
    p, q = map(int, input().split())
    rood.unite(p-1, q-1)

for _ in range(l):
    r, s = map(int, input().split())
    train.unite(r-1, s-1)


from collections import Counter
cnt = Counter()
for i in range(n):
    root_r, root_t = rood.root(i), train.root(i)
    cnt[(root_r, root_t)] += 1

ans = []
for i in range(n):
    root_r, root_t = rood.root(i), train.root(i)
    ans.append(cnt[(root_r, root_t)])

print(*ans)

Measured memory_bytes: 58636
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long; using ull = unsigned long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>;
template<typename T, typename U> static void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void chmax(T &x, U y) { if (x < y) x = y; }

signed main() {
    unordered_map<string, int> m;
    int n;
    cin>>n;
    rep(i, n) {
        string s;
        cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;
    return 0;
}

Measured memory_bytes: 3628
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define ll long long 
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;  
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n) {
	for (int i = 0; i < n; ++i)
		cout << arr[i] << ' ';
	cout << endl;
}
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
ll modulo = 1e9 + 7;

ll fpow(ll a, ll n) {
	ll ans = 1;
	while (n) {
		if (n&1) ans = (ans*a)%modulo;
		a = (a*a)%modulo; n = n >> 1;
	}
	return ans;
}

void solve() {
	int arr[] = {
1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k; cin >> k;
cout << arr[k-1] << endl;

}

int main() {
	fast_io();
	int t = 1;
	// cin >> t;
	while (t--) solve();
	return 0;
}

Measured memory_bytes: 256
eval"K,*X,j=#{`tr ' 
' ,`}l=1
x,y,*s=X.map &:abs
d=x+y
x,y=y,x if f=x<y
K%2<d%2&&p(-1)+exit
d!=K&&(l+=[~-d/K,1].max
l+=1&d-K*l
v=K>(t=K*l-d>>1)?0:t-t=K
a=K-t
2.upto(l){s<<(u=f ?-t:a)<<a-t-u
a+=q=[x+v-a,K].min
t-=K-q})
p l,*s.map{_1.*X[j^=1]<=>0.1}+X"

Measured memory_bytes: 29840
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
typedef long long ll;
typedef vector<int> vi;
const ll M = 1e9 + 7;

int main(void){
  int n;
  scanf("%d", &n);
  vi rp(n);
  rep(i, n){
    int p;
    scanf("%d", &p);
    p--; rp[p] = i;
  }

  multiset<ll> ms; ll ans = 0;
  ms.insert(-1); ms.insert(-1);
  ms.insert(n); ms.insert(n);
  rep(i, n){
    ll id = rp[n - 1 - i], l1, l2, r1, r2, x = n - i;
    ms.insert(id);
    auto it = ms.find(id);
    l2 = *(--it), l1 = *(--it);
    it = next(it, 2);
    r1 = *(++it), r2 = *(++it);
    ll v = (l2 - l1) * (r1 - id) + (r2 - r1) * (id - l2);
    ans += v * x;
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 8476
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N,A,B;
  cin>>N>>A>>B;
  cout<<min(A,B)<<" "<<max(A+B-N,0)<<endl;
}


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

struct dir {
    bool row = false;
    bool col = false;
};
int main() {
    int h, w;
    cin >> h >> w;
    char s[h+1][w+1];
    int  value[h+1][w+1];
    for (int i=1; i<h+1; i++) {
        for (int j=1; j<w+1; j++) {
            cin >> s[i][j];
        }
    }

   // if (s[h][w] == '#') {
   //     value[h][w] = 1;
   // } else {
   //     value[h][w] = 0;
   // }

    for (int i=h; i>0; i--) {
        for (int j=w; j>0; j--) {
            if (s[i][j] == '.') {
                if(i==h && j==w) {
                    value[i][j] = 0;
                } else if (i==h) {
                    value[i][j] = value[i][j+1];
                } else if (j==w) {
                    value[i][j] = value[i+1][j];
                } else {
                    value[i][j] = min(value[i][j+1], value[i+1][j]);
                }
            } else { // '#'
                if(i==h && j==w) {
                    value[i][j] = 1;
                } else if (i==h) {
                    if (s[i][j+1] == '.') {
                        value[i][j] = value[i][j+1]+1;
                        continue;
                    } else { 
                        value[i][j] = value[i][j+1];
                    }
                } else if (j==w) {
                    if (s[i+1][j] == '.') {
                        value[i][j] = value[i+1][j]+1;
                        continue;
                    } else {
                        value[i][j] = value[i+1][j];
                    }
                } else {
                    int dvalue, rvalue;
                    // dvalue
                    if (s[i+1][j] == '.') {
                        dvalue = value[i+1][j]+1;
                    } else {
                        dvalue = value[i+1][j];
                    }
                    // rvalue
                    if (s[i][j+1] == '.') {
                        rvalue = value[i][j+1]+1;
                    } else {
                        rvalue = value[i][j+1];
                    }
                    //cout << "dvalue, rvalue: " << dvalue <<", " << rvalue << endl;
                    value[i][j] = min(dvalue, rvalue);
                }
            }

        }
    }
    //for (int i=1; i<h+1; i++){
        //for(int j=1; j<w+1; j++) {
            //cout << value[i][j] << ' ';
        //}
        //cout << endl;
    //}
    cout << value[1][1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int n,a,b, odp;
bool tb[500];
char c;
int main()
{
	scanf("%d", &n);
	for(int i=0; i<n; i++)
	{
		scanf(" %c", &c);
		if(tb[(int)c]==0)
		{
			tb[(int)c]=1;
			a++;
		}
	}
	if(a==3)printf("Three");
	else printf("Four");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  int H, W;
  cin >> H >> W;
  vector<string> s(H);
  for(int i = 0; i < H; i++){
    cin >> s.at(i);
  }
  for(int i = -1; i <= H; i++){
    if(i == -1 || i == H){
      for(int j = 0; j < W+2; j++){
        cout << "#";
      }
      cout << endl;
    }else{
      cout << "#" << s.at(i) << "#";
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long seg_tree[seg_size*4];
long long updates[seg_size*4];
long long seg_find(int now,int n_l,int n_r,int w_l,int w_r){
    seg_tree[now] += updates[now];
    updates[now*2] += updates[now];
    updates[now*2+1] += updates[now];
    updates[now] = 0;
    if(w_l <= n_l&&n_r <= w_r) return seg_tree[now];
    if(n_r <= w_l||w_r <= n_l) return (1LL << 31LL) - 1;
    return min(seg_find(now*2,n_l,(n_l+n_r)/2,w_l,w_r),seg_find(now*2+1,(n_l+n_r)/2,n_r,w_l,w_r));
}
long long seg_add(int now,int n_l,int n_r,int w_l,int w_r,int settings){
    seg_tree[now] += updates[now];
    updates[now*2] += updates[now];
    updates[now*2+1] += updates[now];
    updates[now] = 0;
    if(w_l <= n_l&&n_r <= w_r){
        updates[now] += settings;
        return seg_tree[now];
    }
    if(n_r <= w_l||w_r <= n_l) return (1LL << 31LL) - 1;
    return min(seg_add(now*2,n_l,(n_l+n_r)/2,w_l,w_r,settings),seg_add(now*2+1,(n_l+n_r)/2,n_r,w_l,w_r,settings));
}
int main(){
    int n,query;
    cin >> n >> query;
    REP(i,query){
        int a;
        cin >> a;
        if(a == 0){
            int a,b,c;
            cin >> a >> b >> c;
            seg_add(1,0,seg_size,a,b+1,c);
        }else{
            int b;
            cin >> b;
            cout << seg_find(1,0,seg_size,b,b+1) << endl;
        }
    }
}


Measured memory_bytes: 7844
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};

int main(){
    int N; cin >> N;
    vector<ll> a(N),b(N);
    int in = 0;
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }

    reverse(a.begin(),a.end());
    for (int i = 0; i < N; i++){
        b[in] = a[i];
        if (i+1 < N) b[N-in-1] = a[i+1];
        in++;
        i++;
    }
    for (int i = 0; i < N; i++){
        cout << b[i] << " ";
    }
    cout << endl;
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
struct z{
  ll x,y,d;
  z(ll a,ll b,ll c):x(a),y(b),d(c){};
};

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll h,w;cin>>h>>w;
  vector<string>a(h);
  rep(i,0,h)cin>>a[i];
  auto dp=vec(h,w,INF);
  dp[0][0]=0;
  rep(i,0,h)rep(j,0,w){
    if(i<h-1){
      chmin(dp[i+1][j],dp[i][j]+(a[i][j]=='#'&&a[i+1][j]=='.'));
    }
    if(j<w-1){
      chmin(dp[i][j+1],dp[i][j]+(a[i][j]=='#'&&a[i][j+1]=='.'));
    }
  }
  cout<<dp[h-1][w-1]+(a[h-1][w-1]=='#')<<endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i).first;
		A.at(i).second = i + 1;
	}
	sort(A.begin(), A.end());
	for (int i = 0; i < N; i++) {
		printf("%d ",A.at(i).second);
	}
	cout << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define each(i, c) for (auto& (i) : (c))

using namespace std;
typedef long long int lli;
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }

int main() {
    int n;
    cin >> n;
    int sum = 0;
    for (int t = n; t > 0; t /= 10) {
        int a = t%10;
        sum += a;
    }
    cout << (n%sum == 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N=1e3+5;
const int MOD=1e9+7;
 
int n, a, b, c, d;
int cache[N][N], cache2[N][N];
int fact[N], invfact[N];
 
int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
 
int modinv(int k)
{
	return pow(k, MOD-2, MOD);
}
 
void precompute()
{
	fact[0]=fact[1]=1;
	for(int i=2;i<N;i++)
	{
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
	invfact[N-1]=modinv(fact[N-1]);
	for(int i=N-2;i>=0;i--)
	{
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]%=MOD;
	}
}
 
int nCr(int x, int y)
{
	if(y>x)
		return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=MOD;
	num*=invfact[x-y];
	num%=MOD;
	return num;
}
 
int num(int r, int take)
{
	int &ans=cache2[r][take];
	if(ans!=-1)
		return ans;
	return modinv(pow(fact[r], take, MOD));
}
 
int dp2(int n, int r, int take)
{
	int ans=fact[n] * invfact[n-r*take];
	ans%=MOD;
	int den=num(r, take);
	ans*=den;
	ans%=MOD;
	return ans;
}
 
int dp(int remaining, int freq)
{
	if(remaining==0)
		return 1;
	if(freq==b+1)
		return 0;
	int &ans=cache[remaining][freq];
	if(ans!=-1)
		return ans;
	ans=dp(remaining, freq+1);
	for(int i=c;i<=d;i++)
	{
		int take=i*freq;
		if(take>remaining)
			break;
		int ways=dp2(remaining, freq, i);
		ways*=dp(remaining-take, freq+1);
		ways%=MOD;
		ways*=invfact[i];
		ways%=MOD;
		ans+=ways;
	}
	ans%=MOD;
	return ans;
}
 
int32_t main()
{
	IOS;
	precompute();
	memset(cache, -1, sizeof(cache));
	memset(cache2, -1, sizeof(cache2));
	cin>>n>>a>>b>>c>>d;
	int ans=dp(n, a);
	cout<<ans;
	cerr<<(double)clock()/CLOCKS_PER_SEC;
	return 0;
}

Measured memory_bytes: 16128
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;
typedef  pair<int,int> pa;
int dv[][2]={{0,1},{1,0},{-1,0},{0,-1}};
int mod=1e9+7;
const int N=2e5+100;

int main()
{
   int a,b;
   cin>>a>>b;
   int k=a;
   int ans=1;
   if(b==1) {puts("0");return 0;}
   while(k<b){
      ans++;
      k+=a-1;
   }
   printf("%d\n",ans);
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
        int n;
        cin>>n;
        int ans=0;
        for(int i=1;i<=n;i+=2){
                int cnt=0;
                for(int j=1;j<=i;j++)if(i%j==0)cnt++;
                if(cnt==8)ans++;
        }
        cout<<ans<<endl;

        return 0;
}


Measured memory_bytes: 256