akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

int main(void)
{
    int i, n, a;
    double f, g, h, j;
    int x[1000], y[1000];

    scanf("%d", &n);

    for (i = 0; i < n; i++){
        scanf("%d", &x[i]);
    }

    for (i = 0; i < n; i++){
        scanf("%d", &y[i]);
    }

    //p = 1のとき
    f = 0;
    for (i = 0; i < n; i++){
        a = 0;
        a = x[i] - y[i];
        if (a < 0){
            a = a * (-1);
        }

        f += a;
    }

    printf("%lf\n", f);

    //p = 2のとき
    g = 0;
    for (i = 0; i < n; i++){
        g += pow(x[i] - y[i], 2.0);
    }

    printf("%lf\n", pow(g, 1.0 / 2.0));

    //p = 3のとき
    h = 0;
    for (i = 0; i < n; i++){
        a = 0;
        a = pow(x[i] - y[i], 3.0);
        if (a < 0){
            a = a * (-1);
        }

        h += a;
    }

    printf("%lf\n", pow(h, 1.0 / 3.0));

    //p = ∞のとき
    j = 0;
    for (i = 0; i < n; i++){
        if(fabs(x[i] - y [i]) > j){
            j = fabs(x[i] - y [i]); 
            //printf("%lf\n", j);
        }
    }

    printf("%lf\n", j);

    return (0);
}



Measured memory_bytes: 2100
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

string S, T;

signed main(){
    cin >> S >> T;
    cout << T << S << endl;
}

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

int get_pos(char c) {
    if(c == '1' || c == '4' || c == '7') {
        return 0;
    } else if(c == '2' || c == '8') {
        return 1;
    } else {
        return 2;
    }
}

int main() {
    string s;
    while(cin >> s, s != "#") {
        vector<vector<int>> dp(2, vector<int>(s.size()+1, 1e9)); // 0:left, 1:right
        vector<vector<int>> pos(2, vector<int>(s.size()+1, 0)); // 0:1 4 7, 1:2 8, 2:3 6 9
        for(int i=0; i<s.size(); ++i) {
            if(i == 0) {
                dp[1][0] = dp[0][0] = 0;
                pos[1][0] = pos[0][0] = get_pos(s[i]);
            } else {
                int next_pos = get_pos(s[i]);
                // next step left
                if(pos[1][i-1] >= next_pos) {
                    dp[0][i] = dp[1][i-1];
                    pos[0][i] = next_pos;
                } else {
                    dp[0][i] = dp[0][i-1] + 1;
                    pos[0][i] = next_pos;
                }
                // right
                if(pos[0][i-1] <= next_pos) {
                    dp[1][i] = dp[0][i-1];
                    pos[1][i] = next_pos;
                } else {
                    dp[1][i] = dp[1][i-1]+1;
                    pos[1][i] = next_pos;
                }
            }
        }
        cout << min(dp[0][s.size()-1], dp[1][s.size()-1]) << endl;
    }
}


Measured memory_bytes: 4864
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanln(&n)
	a := make([]int, n+1)
	ans := make([]int, n+1)
	for i := 1; i < n+1; i++ {
		fmt.Scan(&a[i])
	}
	for i := n; i > 0; i-- {
		temp := 0
		for j := 2 * i; j < n+1; j += i {
			temp += ans[j]
		}
		temp %= 2
		ans[i] = (2 + a[i] - temp) % 2
	}
	m := 0
	for i := 1; i < n+1; i++ {
		if ans[i] > 0 {
			m++
		}
	}
	fmt.Println(m)
	if m > 0 {
		for i := 1; i < n+1; i++ {
			if ans[i] > 0 {
				fmt.Print(i)
				if m > 1 {
					fmt.Print(" ")
				}
				m--
			}
		}
		fmt.Println()
	}
}


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

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

    int n;
    cin >> n;
    map<int, int> a;

    REP(i, n) {
        int tmp;
        cin >> tmp;
        a[tmp]++;
        a[tmp - 1]++;
        a[tmp + 1]++;
    }

    int maxi = 0;
    for(auto i : a)
        maxi = max(maxi, i.second);

    cout << maxi << '\n';
    return 0;
}


Measured memory_bytes: 4736
# -*- coding: utf-8 -*-

S = str(input())

N = len(S)

#条件１
T = S[:(N-1)//2]
t = T[::-1]

#条件2
U = S[(N+3)//2-1:]
u = U[::-1]

#反転した文字
s = S[::-1]

#必要なかった！！！
ans = 'No'

if S != s:
    ans = 'No'

else:
    if T == t and U == u:
        ans = 'Yes'

print(ans)

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

#define ll long long
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if (a == 1) a = 14;
    if (b == 1) b = 14;
    if (a == b) cout << "Draw" << endl;
    if (a > b) cout << "Alice" << endl;
    if (b > a) cout << "Bob" << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 *   author:  prakhar17252
 *   created: 19.07.2019 14:10:14
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
#define int ll

#define pb emplace_back
#define push emplace
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define len(a) (int) a.size()
#define reset(a, val) memset(a, val, sizeof(a))
#define endl '\n'
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }

#ifdef PRAKHAR
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;

const ll mod = (int) 1e9 + 7;
const ll inf = (ll) 2e18;
const ll ninf = (ll) -2e18;

ll power(ll x, ll y, ll mod = inf) {
    if (y == 0) return 1LL;
    if (y % 2) return ((x % mod) * power(x, y - 1, mod)) % mod;
    return power((x * x) % mod, y / 2, mod);
}

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

    time_t t1, t2;
    t1 = clock();

    #ifdef PRAKHAR
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("error.txt", "w", stderr);
    #endif

    int n, x;
    cin >> n >> x;
    vector<int> vals = {x};
    for (int i = 0; i < n; i++) {
        int X; cin >> X;
        vals.emplace_back(X);
    }

    sort(vals.begin(), vals.end());
    int g = 0;
    for (int i = 0; i < n; i++) {
        g = __gcd(g, (vals[i+1] - vals[i]));
    }

    cout << g << '\n';


    t2 = clock();
    #ifdef PRAKHAR
        cerr << endl << "time taken: " << (ld) (t2 - t1) / CLOCKS_PER_SEC << endl;
    #endif // ONLINE_JUDGE

    return 0;
}

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

int main(void) {
    int H, W;
    
    while(true) {
        cin >> H >> W;
        if(H == 0 && W == 0)   break;
        
        for(int w = 0; w < W; ++w) {
            cout << "#";
        }
        cout << endl;
        for(int h = 0; h < H - 2; ++h) {
            cout << "#";
            for(int w = 0; w < W - 2; ++w) {
                cout << ".";
            }
            cout << "#" << endl;
        }
        for(int w = 0; w < W; ++w) {
            cout << "#";
        }
        cout << endl;
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define maxn (int)1e5+1000
typedef long long ll;

int main()
{
    int a[3];
    for(int i = 0;i < 3;i ++)
        cin >> a[i];
    swap(a[0],a[1]);
    swap(a[0],a[2]);
    for(int i = 0;i < 3;i ++)
        printf("%d%c",a[i], i == 2?'\n':' ');
}


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int a = in(), b = in();
  cout << ((a + b + 1) / 2) << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import itertools
from collections import Counter

N, M = map(int, input().split())

def primes(n):
    primfac = []
    d = 2
    while d*d <= n:
        while (n % d) == 0:
            primfac.append(d)  # supposing you want multiple factors repeated
            n //= d
        d += 1
    if n > 1:
       primfac.append(n)
    return primfac


mod = M % N
div = M // N
if mod == 0:
    print(M//N)
    exit()

f = primes(M)

# 素数の場合などは１
if len(f) == 1:
    print(1)
    exit()

cnt = Counter(f)
ans_list = []

tmp_list = []
for k,v in cnt.items():
  tmp_list.append([i for i in range(v+1)])

# print(cnt)
# print(list(itertools.product(*tmp_list)))
for p in itertools.product(*tmp_list):
    tmp = 1
    for k,i in zip(cnt.keys(),p):
        tmp = tmp * (k ** i)

    if tmp > N:
        ans_list.append(M//tmp)

if len(ans_list) == 0:
    print(1)
else:
    print(max(ans_list))


Measured memory_bytes: 3444
#include <iostream>

using namespace std;

int A[1000000], n;

int binarySearch ( int key )
{
    int left = 0;
    int right = n;
    while ( left < right )
    {
        int mid = ( left + right ) / 2;
        if ( A[mid] == key ) return 1;
        else if ( key < A[mid] ) right = mid;
        else left = mid + 1;
    }
    return 0;
}

int main()
{
    int q, k, sum(0);
    cin >> n;
    for ( int i = 0; i < n; i++ )
        cin >> A[i];
    cin >> q;
    for ( int i = 0; i < q; i++ )
    {
        cin >> k;
        if ( binarySearch ( k ) ) sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3464
#include <bits/stdc++.h> 
using namespace std; 
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
int main()
{
	string cal;
	cin>>cal;
	if(cal=="Sunny")cout<<"Cloudy";
	else if(cal=="Cloudy")cout<<"Rainy";
	else cout<<"Sunny";
  return 0;
}
//code the AC sol !
// BS/queue/map


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N, K;
  std::cin >> N >> K;
  string S;
  std::cin >> S;
  std::vector<int> num;
  int tmp = 0, start;
  if(S[0] == '0') num.push_back(0);
  range(i, N){
    if(i == 0){
      tmp = S[0]-'0';
      start = tmp;
      if(tmp == 1)num.push_back(1);
      else num.push_back(-1);
    }else if(tmp==S[i] - '0'){
      if(tmp == 1)num[num.size()-1]+=1;
      else num[num.size()-1]-=1;
    }else{
      if(S[i]-'0' == 1){
        num.push_back(1);
        tmp = 1;
      }else{
        num.push_back(-1);
        tmp = 0;
      }
    }
  }
  if(S[N-1] == '0') num.push_back(0);

  int count = 0, ans = 0;
  range(i, num.size()-1){
    if(num[i] < 0){
      count += 1;
      ans += -1 * num[i];
      if(count == K){
        ans += num[i+1];
        break;
      }
    }else{
      ans += num[i];
    }
  }
  int reg = ans;
  if(count < K){
    std::cout << N  << '\n';
    return 0;
  }
  for(int i=0;2*(i+K)+1<num.size();i++){
    reg -= num[2*i];
    reg -= -1 * num[2*i+1];
    reg += -1 * num[2*i+1+2*K];
    reg += num[2*i+1+2*K+1];
    ans = max(ans, reg);
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1020
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
typedef long long ll;
#define mp make_pair
int n;
int a[105];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int ans=0;
	for(int i=1;i<n-1;i++){
		if(min(a[i+1],a[i-1])<a[i]&&max(a[i-1],a[i+1])>a[i]){
			ans++;
		}
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int h,w,i,j;
    scanf("%d %d",&h,&w);
    while(h!=0&&w!=0){
    	for(i=0;i<h;i++){
    		for(j=0;j<w;j++){
    			if(i!=0&&i!=h-1&&j!=0&&j!=w-1){
    				printf(".");
    			}else{
    				printf("#");
    			}
    		
    		}
    		printf("\n");
    	}
    	printf("\n");
    	scanf("%d %d",&h,&w);
    }
    return 0;
}



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

bool pal(string s)
{
	string t(s.rbegin(),s.rend());
	return s==t;
}
int main()
{
	//code
	string s;
	cin>>s;
	int n=s.length();
	if(pal(s) && pal(s.substr(0,(n-1)/2)) && pal(s.substr((n+1)/2)))
		cout<<"Yes";
	else
		cout<<"No";
 	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    int dp[n];
    for(int i=0;i<n;i++)
    {
        dp[i]=INT_MAX;
    }
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
        dp[0]=0;
        for(int i=1;i<n;i++)
        {
            int temp=INT_MAX;
            for(int j=1;j<=k;j++)
            {
                if((i-j)>=0)
                    temp=min(temp,dp[i-j]+abs(arr[i]-arr[i-j]));
                else
                    break;
            }
            dp[i]=temp;
        }
        cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main{
 void run() {
  Scanner sc = new Scanner(System.in);
  for(;sc.hasNext();){
   int a = sc.nextInt();
   int b = sc.nextInt();
   System.out.println( gcd(a, b) + " " + lcm(a, b) );
  }
 }
 int gcd(int a, int b){
  if(b==0) return a;
  return gcd(b, a%b);
 }
 int lcm(int a, int b){
  return a/gcd(a, b)*b;
 }
 public static void main(String[] args){
  new Main().run();
 }
}

Measured memory_bytes: 12000
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A;
  tools::read(A, N);
  std::cout << (std::all_of(A.begin(), A.end(), [](const i64& A_i) { return A_i % 2 == 1 || A_i % 3 == 0 || A_i % 5 == 0; }) ? "APPROVED" : "DENIED") << std::endl;
  return 0;
}

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

template<typename T>
class BIT
{
//bit[x]
//manage range of bit[x] is (x & -x)
//
public:
	static const int n = 10000;
	T bit[n] = {};
	void add(int a, T w)
	{
		for (int x = a; x <= n; x += x & -x)
		{
			bit[x] += w;
		}
	}
	T sum(int a)
	{
		T ret = 0;
		for (int x = a; x > 0; x -= x & -x)
		{
			ret += bit[x];
		}
		return ret;
	}
};

long long int wa(long long int a)
{
	return (a*(a+1))/2;
}

int main()
{
	long long int n, k;
	cin >> n >> k;
	int A[2001], B[2001];
	for (int i = 0; i < n; ++i)
	{
		cin >> B[i];
		A[i] = 2000 - B[i] + 1;
	}
	long long int tentou[2001];
	long long int migi[2001];
	long long int ti = wa(k) % 1000000007;
	long long int to = wa(k - 1) % 1000000007;
	BIT<long long int> BT;
	BIT<long long int> saisho;
	for (int i = 0; i < n; ++i)
	{
		tentou[i] = BT.sum(A[i] - 1);
		BT.add(A[i], 1);
	}
	for (int i = n - 1; i >= 0; --i)
	{
		migi[i] = saisho.sum(A[i] - 1);
		saisho.add(A[i], 1);
	}
	long long int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		ans += ((ti * tentou[i])%1000000007 + (to * migi[i])% 1000000007)% 1000000007 ;
	}
	cout << ans % 1000000007 << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;



int main(){
    int n;cin >> n;
    if(n%2==0){
        cout << n*(n-1)/2-n/2 << endl;
        int t = n+1;
        for (int i = 1; i <= n; i++) {
            for (int j = i+1; j <= n; j++) {
                if(i+j==t) continue;
                cout << i << " " << j << endl;
            }
        }
    }
    else{
        cout << n*(n-1)/2-n/2 << endl;
        int t = n;
        for (int i = 1; i <=n; i++) {
            for (int j = i+1; j <=n; j++) {
                if(i+j==t) continue;
                cout << i << " " << j << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

int main(){
  int N; cin >> N; int cnt[10][10] = {};
  rep(i, N){
    int k = i+1;
    int a = k%10;
    while(k>=10){
      k/=10;
    }
    cnt[a][k]++;
  }
  int ans = 0;
  rep(i, 10){
    rep(j, 10){
      ans+=cnt[i][j]*cnt[j][i];
    }
  }
  cout << ans << endl;
}  

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int K, X;
  cin >> K >> X;
  int min = X-(K-1);
  int max = X+(K-1);
  if(min<-1000000)
    min = -1000000;
  if(max>100000)
    max = 1000000;
  for(int i=min; i<=max; i++)
    cout << i << " ";
  cout << endl;
  return 0;
}

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

int main()
{
    int n;
    scanf("%d", &n);
    int main[n],left[n+1],right[n+2];
    for(int i=0; i<n; i++)
        scanf("%d", &main[i]);
    left[0]=0,right[n+1]=0;
    for(int i=1; i<=n; i++)
    {
        left[i]=__gcd(left[i-1],main[i-1]);
        right[n+1-i]=__gcd(right[n+2-i],main[n-i]);
    }

    int ans=1;
    for(int i=1; i<=n; i++)
        ans=max(__gcd(left[i-1],right[i+1]),ans);
    //ans=max(ans,right[1]);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 5008
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;

int main() {
        int l;
        scanf("%d", &l);
        string s, t;
        cin >> s >> t;
        if (s + t > t + s) swap(s, t);
        int p = 1 << 30, q = 1 << 30;
        for (int left = l; left >= 0; left --) {
                int right = l - left;
                if (left % (int)s.size() == 0 && right % (int)t.size() == 0) {
                        p = left, q = right;
                        break;
                }
        }
        int lcnt = p / (int)s.size(); 
        int rcnt = q / (int)t.size();
        while (lcnt --) cout << s;
        while (rcnt --) cout << t;
        cout << endl;
        return 0;
}



Measured memory_bytes: 1544
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if ((A + B) > (C + D))
  {
    cout << "Left" << endl;
  }
  else if ((A + B) == (C + D))
  {
    cout << "Balanced" << endl;
  }
  else if ((A + B) < (C + D))
  {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
        public  static void main(String[] args){

                int r=calc();
                System.out.println(r);
        }
        static int calc(){
                Scanner sc = new Scanner(System.in);
                int A=sc.nextInt();
                int B=sc.nextInt();
                int rp;
                int rm;
                int rb;
                int r;
                rp = A+B;
                rm = A-B;
                rb = A*B;
                if(rp >= rm && rp >= rb){
                        r = rp;
                }else if(rm >= rp && rm >= rb){
                        r = rm;
                }else{
                        r = rb;
                }
                return r;
        }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n)  for(int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define ld long double
#define ull unsigned long long int


void solve()
{
	//freopen("input.txt","r",stdin);

	string s;

	int T;
	cin>>T;
	int a=0,w=0,t=0,r=0;
	while(T--)
	{
		cin>>s;
		if(s[0]=='A') a++;
		else if(s[0]=='W') w++;
		else if(s[0]=='T') t++;
		else 
			r++;
	}

	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<w<<endl;
	cout<<"TLE x "<<t<<endl;
	cout<<"RE x "<<r<<endl;
}


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

solve();

	return 0;
}

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

int n, a[200001], s;

int main(void) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i=0; i<n; ++i) {
        cin >> a[i];
        s^=a[i];
    }
    for (int i=0; i<n; ++i) {
        if (i>0)
            cout << " ";
        int t=a[i]^s;
        cout << t;
    }
    cout << '\n';
}


Measured memory_bytes: 4412
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i += 2) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline
 
N,K = map(int,input().split())
H = [int(x) for x in input().split()]
 
def main(N,K,H):
    dp = [0]*N
    for i in range(1,N):
        L = [dp[j]+abs(H[i]-H[j]) for j in range(max(0,i-K),i)]
        dp[i] = min(L)
    print(dp[-1])
main(N,K,H)

Measured memory_bytes: 14104
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ZYCSwing
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt(), a = in.nextInt(), b = in.nextInt();

            out.println(Math.min(n * a, b));
        }

    }
}



Measured memory_bytes: 22740
r, d, x = map(int, input().split())

def calu_weight(r, d, x):
    return r*x-d

w_l = []

for i in range(0,10):
    if i == 0:
        #初期値使用(xはinput)
        w_l.append(calu_weight(r,d,x))
        print(calu_weight(r,d,x))
    else:
        w_l.append(calu_weight(r,d,w_l[i-1]))
        print(calu_weight(r,d,w_l[i-1]))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>

int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for(int i = 0; i < n; ++i){
        std::cin >> a.at(i);
    }

    int min = *std::min_element(a.begin(), a.end());    
    int max = *std::max_element(a.begin(), a.end());    
    std::vector<int> ans;
    int sum = 0;
    for(int i = min; i <= max; ++i){
        for(int j = 0; j < n; ++j){
            sum += std::pow(i - a.at(j), 2);         
        }
        ans.push_back(sum);
        sum = 0;
    }

    std::cout << *std::min_element(ans.begin(), ans.end()) << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define AC(x,t) accumulate(ALL(x),t)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int N;
int f( int n )
{
    int cnt{};
    while( true )
    {
        if( n <= 0 ){ break; }
        if( n % 2 == 0 || n == 1 )
        {
            cnt++;
        }
        n = n / 2;
    }
    return cnt;
}
int main()
{
    cin >> N;
    int res{}, ans{};
    REP2( i, 1, N + 1 )
    {
        int tmp = f( i );
        if( res < tmp )
        {
            res = tmp;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int x,y;
    int answer=0;
    scanf("%d %d",&x,&y);
    
    if(x==2||y==2){
        printf("No");
    }

    else if(x==4||x==6||x==9||x==11)
    {
        if(y==4||y==6||y==9||y==11){
            printf("Yes");
        }
        else
        {
            printf("No");
        }
        
        
    }

    else 
    {
        if(y==4||y==6||y==9||y==11){
            printf("No");
        }
        else
        {
            printf("Yes");
        }
        
        
    }

    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int a[N],n,b[N],tmp,ans,cur,uni[N],sz[N],vis[N];
map<int,int> mp;
typedef pair<int,int> pii;
vector<int> vec;
template <typename tp>
void outputarr(tp *a,tp *b) {
  while (a != b)
    cerr << *a << ' ', ++ a;
  cerr << endl;
}
int getfa(int pos) {
  return pos == uni[pos] ? pos : uni[pos] = getfa(uni[pos]);
}
int main() {
  scanf("%d",&n);
  for (int i = 1 ; i <= n ; ++ i)
    scanf("%d",&a[i]), tmp ^= a[i];
  a[0] = tmp;
  for (int i = 1 ; i <= n ; ++ i)
    scanf("%d",&b[i]);
  for (int i = 0 ; i <= n ; ++ i)
    ++ mp[a[i]];
  for (int i = 1 ; i <= n ; ++ i) {
    if (!mp.count(b[i]))
      return puts("-1"), 0;
    if (mp[b[i]] == 0) return puts("-1"), 0;
    mp[b[i]]--;
  }
  for (int i = 0 ; i <= n ; ++ i)
    if (mp[a[i]]) b[0] = a[i];
  for (int i = 0 ; i <= n ; ++ i)
    vec.push_back(a[i]);
  sort(vec.begin(),vec.end());
  vec.erase(unique(vec.begin(),vec.end()),vec.end());
  for (int i = 0 ; i <= n ; ++ i)
    a[i] = lower_bound(vec.begin(),vec.end(),a[i]) - vec.begin() + 1, \
      b[i] = lower_bound(vec.begin(),vec.end(),b[i]) - vec.begin() + 1;
  for (int i = 0 ; i <= n ; ++ i)
    uni[a[i]] = a[i];
  for (int i = 0 ; i <= n ; ++ i) {
    int x = getfa(a[i]), y = getfa(b[i]);
    if (x != y)
      uni[x] = y;
  }
  for (int i = 0 ; i <= n ; ++ i) {
    if (a[i] == b[i]) continue;
    ++ ans;
    ++ sz[getfa(a[i])];
  }
  for (int i = 0 ; i <= n ; ++ i) {
    if (a[i] == b[i]) continue;
    if (a[i] == getfa(a[i]) && !vis[a[i]]) {
      ++ ans;
      vis[a[i]] = 1;
    }
  }
  if (a[0] != b[0]) ans --;
  if (sz[getfa(a[0])] > 1) ans --;
  printf("%d\n",ans);
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  if (s.at(0) != s.at(1) || s.at(1) != s.at(2)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

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

const int MAX = 1e5 + 5;

#define dbg(a) cout << "-> " << __LINE__ << ": " << #a << " = " << a << endl

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long a, b, v, w, t;
	cin >> a >> v >> b >> w >> t;
	b -= a;
	b = abs(b);
  a = 0;
	if (a + v * t >= b + t * w) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}
	return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

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

signed main(){
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  int ch, cw, dh, dw;
  cin >> ch >> cw >> dh >> dw;
  ch--, cw--, dh--, dw--;
  rep(i, h) cin >> s[i];
  vector<vector<int>> dist(h, vector<int>(w, inf));
  deque<pair<int, int>> deq;
  dist[ch][cw] = 0;
  deq.emplace_front(ch, cw);
  while(!deq.empty()){
    int i = deq.front().first, j = deq.front().second;
    deq.pop_front();
    int d = dist[i][j];
    rep(v,4){
      int ni = i + dx[v], nj = j + dy[v];
      if(ni < 0||ni >= h||nj < 0||nj >= w)
        continue;
      if(dist[ni][nj] <= d)
        continue;
      if(s[ni][nj] == '#')
        continue;
      dist[ni][nj] = d;
      deq.emplace_front(ni, nj);
    }
    FOR(vi,-2,3){
      FOR(vj,-2,3){
        int ni = i + vi, nj = j + vj;
        if(ni < 0||ni >= h||nj < 0||nj >= w)
          continue;
        if(dist[ni][nj] <= d + 1)
          continue;
        if(s[ni][nj] == '#')
          continue;
        dist[ni][nj] = d + 1;
        deq.emplace_back(ni, nj);
      }
    }
  }
  if(dist[dh][dw] != inf) cout << dist[dh][dw] << endl;
  else
    cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 8624
def solve():
	n = int(input())
	s = input().strip()
	left = 0
	right = n-1
	total = 0
	while left < right:
		while left < right and s[left] == 'R':
			left+=1
		while left < right and s[right] == 'W':
			right-=1
		if left == right:
			break
		total+=1
		left+=1
		right-=1
	return total



print(solve())

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int main(void) {
	while (1) {
		int n;
		int count = 0;
		bool left = false;
		bool right = false;
		bool first = false;

		cin >> n;
		if (n == 0) {
			break;
		}
		vector<string>f(n + 1);
		FOR(i, 1, n) {
			cin >> f[i];
		}
		FOR(i, 1, n) {
			if (f[i] == "lu") {
				left = true;
			}
			else if (f[i] == "ld") {
				left = false;
			}
			else if (f[i] == "ru") {
				right = true;
			}
			else if (f[i] == "rd") {
				right = false;
			}
			if (first == false) {
				if (left == true && right == true) {
					count++;
					first = true;
				}
			}
			else {
				if (left == false && right == false) {
					count++;
					first = false;
				}
			}
		}
		cout << count << endl;
	}
}


Measured memory_bytes: 3108
using System;

class Program
{
    static void Main(string[] args)
    {
        Console.Write(IrohaLovesStrings_ABCEdition());
    }

    private static string IrohaLovesStrings_ABCEdition()
    {
        //文字列の個数を得る
        string[] line = Console.ReadLine().Split(' ');
        int N = int.Parse(line[0]);

        string[] words = new string[N];

        for (int i = 0; i < N; i++)
        {
            words[i] = Console.ReadLine();
        }

        Array.Sort(words);

        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        foreach (var str in words)
        {
            sb.Append(str);
        }

        return sb.ToString();
    }
}


Measured memory_bytes: 13408
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
#include <ctype.h> // isdigit
#include <cassert>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(u) begin(u),end(u)
#define PB push_back
#define LE(n,m) ((n) < (m) + EPS * (abs(n) + abs(m)))
#define GE(n,m) ((n) + EPS * (abs(n) + abs(m)) > (m))
#define LT(n,m) ((n) + EPS * (abs(n) + abs(m)) < (m))
#define GT(n,m) ((n) > (m) + EPS * (abs(n) + abs(m)))
#define EQ(n,m) (abs((n)-(m)) < EPS * (abs(n) + abs(m)))

typedef long long int ll;
const int INF = (1<<30) - 1;
const double EPS = 1e-9;
const int MOD = 1000000007;

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(16);
    //cout.setf(ios::fixed);
    
    int N, W, D;
    cin >> N >> W >> D;
    int L = 2 * (W + D);
    //end, start
    vector<pair<int, int>> lines;
    
    for(int i=0; i<N; i++){
        int x, y; string f;
        cin >> x >> y >> f;
        int nx, ny;
        if(f == "S"){
            nx = x;
            ny = y;
        }
        if(f == "E"){
            nx = y + W;
            ny = W - x;
        }
        if(f == "N"){
            nx = 2*W + D - x;
            ny = D - y;
        }
        if(f == "W"){
            nx = -y;
            ny = x;
        }
        lines.emplace_back(nx + ny, nx - ny);
    }
    sort(lines.begin(), lines.end());
    
    int ans = INF;
    for(int s=0; s<N; s++){ //????????°???????§??????¨?????????
        int tans = 0;
        int p = lines[0].first;
        for(int i=0; i<N; i++){
            while(i<N && lines[i%N].second <= p) i++;
            p = lines[i--%N].first;
            tans++;
        }
        ans = min(ans, tans);
        
        lines[0].first += L;
        lines[0].second += L;
        sort(lines.begin(), lines.end());
    }
    cout << ans << endl;
    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  vector<string> ss(n);
  for (ll i = 0; i < n; ++i) {
    cin >> ss[i];
  }

  ll ba = 0;
  ll b = 0;
  ll a = 0;
  for (ll i = 0; i < n; ++i) {
    if (ss[i][0] == 'B' && ss[i][ss[i].size()-1] == 'A') ++ba;
    else if (ss[i][0] == 'B') ++b;
    else if (ss[i][ss[i].size()-1] == 'A') ++a;
  }

  ll ans = 0;
  for (ll i = 0; i < ss.size(); ++i) {
    for (ll j = 0; j < ss[i].size()-1; ++j) {
      if (ss[i][j] == 'A' && ss[i][j+1] == 'B') ++ans;
    }
  }
  if (ba == 0) ans += min(b, a);
  else if (b+a > 0) ans += ba + min(b, a);
  else ans += ba-1;

  cout << ans << endl;

  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    int total=0;
    for(int i=0;i<n;i++){
        cin >> s.at(i) >> t.at(i);
        total+=t.at(i);
    }
    string x;
    cin >> x;
    int com=0;
    for(int i=0;i<n;i++){
        com+=t.at(i);
        if(x==s.at(i)){
            break;
        }
    }
    cout << total-com << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a, b,t;

	cin >> a >> b;
	if (a > b)
	{
		t = a;
		a = b;
		b = t;
	}
	if (a + b > 16)
		printf(":(");
	else
		if(b>8)
			printf(":(");
		else
			if(b==8&&a>8)
				printf(":(");
			else
				printf("Yay!");


	return 0;
}

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

using namespace std;
static const int MAX = 2000;

int main() {
    int n;
    cin >> n;
    vector<int> L(n);
    for (int i = 0; i < n; ++i) cin >> L[i];
    sort(L.begin(), L.end(), greater<int>());

    int sum = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n - 1; ++j) {
            int x = L[i];
            int y = L[j];
            for (int k = j + 1; L[k] > x - y && k < n; ++k) sum++;
        }
    }
    
    cout << sum;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h" 
using namespace std; 
#define MAXN 1000001 
int spf[MAXN]; 
#define ll long long int
/*Taken from gfg*/
void sieve() 
{ 
	spf[1] = 1; 
	for (int i=2; i<MAXN; i++) 
		spf[i] = i; 
 
	for (int i=4; i<MAXN; i+=2) 
		spf[i] = 2; 

	for (int i=3; i*i<MAXN; i++) 
	{ 
		 
		if (spf[i] == i) 
		{ 
			 
			for (int j=i*i; j<MAXN; j+=i) 
 
				if (spf[j]==j) 
					spf[j] = i; 
		} 
	} 
} 

set<int> getFactorization(int x) 
{ 
	set<int> ret; 
	while (x != 1) 
	{ 
		ret.insert(spf[x]); 
		x = x / spf[x]; 
	} 
	return ret; 
} 


int main() 
{ 
	 
	sieve(); 
	// calling getFactorization function 
	int n;
	cin>>n;
	ll *factors = new ll[1000001]();
	ll ans = 0;
	//vector<int> p = getFactorization(16);
	
	for(int i=1;i<n;i++){
		ll temp = 1;
		set <int> p = getFactorization(n-i);
		set<int>::iterator it;
		for(it = p.begin();it!=p.end();it++){
			
			ll num = n-i;
			ll cnt = 0;
			while(num%(*it)==0){
				num/=(*it);
				cnt++;
			}
			//cout<<cnt<<"\n";
			temp=(cnt+1)*temp;
			//cout<<temp<<"\n";
		}
		//cout<<"\n";
		//cout<<temp<<"\n";	
		ans+=temp;
	}
	cout<<ans<<"\n";
		
	return 0; 
} 


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;

	cin >>n >>k;
	
	double p=1;
	vector<double> su ={1};
	rep(i, 1000010) su.push_back(su.back()*2);
	//rep(i, 10)  printf(" %f, ",su[i]); puts("");
	double ans = 0;
	rep2(i, 1, n+1){
		double z = 1.0 * k / i;
		int ps = lower_bound(all(su), z) - su.begin();
		ans += 1.0 / n  / pow(2.0, ps);
		//dbg(i, ps, z, pow(2.0, ps));
	}
	
	printf("%.15f\n", ans);
	return 0;
}


Measured memory_bytes: 10348
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long int64;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second

signed main(){
    long long A[5];
    long long N;
    cin >> N;
    REP(i, 5) cin >> A[i];
    long long minx = A[0];
    REP(i, 5) minx = min(minx, A[i]);
    long long ans = 4;
    if(N%minx) ans += N/minx + 1;
    else ans += N/minx;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, m, k = map(int,input().split())

for i in range(min(n,m)+1):
    for j in range(max(n,m)+1):
        tmp = max(n,m)*i + min(n,m)*j - 2*i*j
        if tmp == k:
            print('Yes')
            exit()
                
print('No')

Measured memory_bytes: 64712
#include <bits/stdc++.h>
using namespace std;
map<int,int> mp;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,x,y;
	cin>>n>>x>>y;
	for(int i=1;i<n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(j<x||i>y){
				mp[j-i]++;
				continue;
			}
			if(j>=x&&j<y){
				if((y-j+abs(x-i)+1)<(j-i))
				{
					mp[y-j+abs(x-i)+1]++;
				}
				else{
					mp[j-i]++;
				}
				continue;
			}
			if(i<x){
				mp[j-y+x-i+1]++;
			}
			else{
				if(j-y+i-x+1<j-i)
				{
					mp[j-y+i-x+1]++;
				}
				else{
					mp[j-i]++;
				}
			}
		}
	}
	for(int i=1;i<n;i++)
	{
		cout<<mp[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;


//ある一日でコンテストタイプtiを開催した場合の得点
int calc_point(vector<vector<int>>sds, vector<int>cs, int i, vector<int>lds, int ti){
    int cnt = 0;
    cnt += sds[i][ti];
    lds[ti] =i+1;

    for (int j=0; j<26; j++)cnt -= cs[j]*(i+1-lds[j]);
    
    return cnt;
}


int main() {
    int D;
    cin >> D;
    vector<int>cs(26);
    vector<vector<int>>sds(D, vector<int>(26));
    for (int i=0; i<26; i++)cin >> cs[i];

    for (int i=0; i<D; i++){
        for (int j=0; j<26; j++){
            cin >> sds[i][j];
        }
    }
    //貪欲法
    int stf = 0;
    vector<int>lds(26);
    for (int i=0; i<D; i++){
        int last_ti, last_score;
        last_ti = last_score = -INF;
        for (int j=0;j<26; j++){
            int score = calc_point(sds, cs, i, lds, j);
            if (score >last_score){
                last_score = score;
                last_ti = j;
            }
        }
        //last_tiは0-indexed
        lds[last_ti] = i+1;
        stf += last_score;
        
        //cout << stf << endl;
        cout << last_ti+1 << endl;
        //cout << "i: " << i << endl;
    
    }
    

}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
 
using namespace std;
 
bool dp[5010];
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	sort(a.begin(), a.end());

	int L = -1, R = N;
	while (R - L > 1) {
		int M = (R + L) / 2;
		for (int i = 1; i < K; i++) dp[i] = false;
		dp[0] = true;
		for (int i = 0; i < N; i++) {
			if (i == M) continue;
			for (int j = K - 1; j >= a[i]; j--) {
				dp[j] |= dp[j - a[i]]; 
			}
		}
		bool flag = false;
		for (int i = max(K - a[M], 0); i < K; i++) {
			flag |= dp[i];
		}
		if (flag) R = M;
		else L = M;
	}
	cout << R << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num,init) vector<ll> name((num),(init));
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define mat(name,fnum,snum,init); vector<vector<ll>> name((fnum),vector<ll>((snum),(init)));
#define debugP int debug_point; cin>>debug_point;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){

    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
    ll n;
    cin>>n;
    vec(a,n,0);
    a=getv<ll>(n);
    int cnt=0;
    int cnt1=0;
    rep(i,n){
        if(a[i]%4==0){
            cnt++;
        }else if(a[i]%2==0){
            cnt1++;
        }
    }
    if(cnt>=n/2){
        opY;
    }else if(cnt1>=2&&cnt>=(n-cnt1+1)/2){
        opY;
    }else opN;
    return 0;
}

Measured memory_bytes: 2168