akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> S(N);
    rep(i, N) {
        int a;
        cin >> a;
        S[i] = mp(a, i);
    }

    sort(all(S));
    rep(i, N) {
        cout << S[i].second + 1 << (i == N - 1 ? '\n' : ' ');
    }
}

Measured memory_bytes: 1664
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)

N = 0


def dfs(S, M):
    if len(S) == N:
        print(S)
        return
    for c in range(ord('a'), M + 1):
        dfs(S + chr(c), max(M, c + 1))


def solve():
    global N
    N = Scanner.int()
    dfs('', ord('a'))


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 83028
#include <stdio.h>
int c[26];

int main(void) {
    char ch;
    while( scanf( "%c", &ch ) != EOF ) {
        if( 'a' <= ch && ch <= 'z' ){
            c[ ch - 'a' ]++;
        } else if( 'A' <= ch && ch <= 'Z' ) {
            c[ ch - 'A' ]++;
        }
    }
    for( int i = 0; i < 26; i++ ){
        printf( "%c : %d\n", 'a' + i, c[i] );
    }
    return 0;
}


Measured memory_bytes: 2604
#include <bits/stdc++.h>
#include<string>
using namespace std;
int main(){
   int n,cnt=0;
   cin >> n;
   int c[10][10];
   for(int i=0;i<=9;i++){
       for(int j=0;j<=9;j++){
           c[i][j]=0;
       }
   }
   for(int i=1;i<=n;i++){
       string s = to_string(i);
       int a = s.at(0)-'0';
       int b = s.at(s.size()-1)-'0';
       c[a][b]++;
   }
   for(int i=0;i<=9;i++){
       for(int j=0;j<=9;j++){
           cnt+=c[i][j]*c[j][i];
       }
   }
   cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

//
int main(void) {
    ll N;cin >> N;
    vector<ll> a(5);
    for(ll i=0;i<5;i++){
        cin >> a.at(i);
    }
    vector<ll>::iterator minIter = min_element(all(a));
    size_t minIndex = distance(a.begin(), minIter);
    ll min = a.at(minIndex);
    if(N<=min){
        cout << 5 << endl;
    }
    else{
        cout << (N+min-1)/min+4 << endl;
    }
    return 0;
}

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

using ll = long long;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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 MOD = 1000000007;
const int INF = 1000000001;
constexpr double EPS = 1e-10;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}

void solve() {
    double a, b, x;
    cin >> a >> b >> x;
    if (a * a * b / 2 < x) {
        cout << atan2((2 * b) - ((2 * x) / (a * a)), a) * 180 / M_PI<< EOL;
    } else {
        cout << atan2(b, (2 * x) / (a * b)) * 180 / M_PI << EOL;
    }
}



Measured memory_bytes: 256
mod=10**9+7

S=input()

dp=[]
for i in range(len(S)):
  dp.append([0]*13)
#print(dp)

if S[-1]=="?":
  for j in range(10):
    dp[-1][j]=1
else:
  sj=int(S[-1])
  dp[-1][sj]=1
  
pow_mod=1
for i in range(1,len(S)):
  pow_mod*=10
  pow_mod%=13
  if S[-i-1]=="?":
    for k in range(13):
      for j in range(10):
        dp[-i-1][(k+j*pow_mod)%13]+=dp[-i][k]
        dp[-i-1][(k+j*pow_mod)%13]%=mod
  else:
    sj=int(S[-i-1])
    for k in range(13):
      dp[-i-1][(k+sj*pow_mod)%13]+=dp[-i][k]
      dp[-i-1][(k+sj*pow_mod)%13]%=mod
    
#print(dp)
print(dp[0][5]%mod)


Measured memory_bytes: 64416
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import fractions
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def fact(n):
    val = 1
    for i in range(2,n+1):
        val *= i
    return val

def comb(a,b):
    return fact(a) // (fact(a-b)*fact(b))


def solve():
    n,k = map(int,input().split())
    for i in range(1,k+1):
        if i <= n-k+1:
            print(comb(k-1,i-1)*comb(n-k+1,i) % (10**9 +7))
        else:
            print(0)
        
    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
        def dump(*args):
            names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
            print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
    except:
        def dump(*args):
            pass

    solve()

# vim: set foldmethod=marker:}}}


Measured memory_bytes: 107608
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for (int i=(n)-1;i>=0;i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define REPS(i,f,n) for (int i=(f)-1;i>=(n);i--)
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};

#define NIL -1
//?????????????????????????????????
struct node{
	int p, l, r;
};

node T[101010];
int n, D[101010];

void print_ans(int u){
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].p);
	printf("depth = %d, ", D[u]);

	if (T[u].p == NIL) printf("root, ");
	else if(T[u].l == NIL) printf("leaf, ");
	else printf("internal node, ");

	printf("[");
	for (int i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){
		if (i != 0) printf(", ");
		printf("%d", c);
	}
	printf("]");
	printf("\n");
}

//?????°??¢??°????????¨????????±???????±??????? 
int deep(int u, int p){//u???????????????????????§ p???????????±???
	D[u] = p;
	//?¨?????????¨???????????????????????±??????????????§?±?????????????????????°??¢??°
	if (T[u].r != NIL) deep(T[u].r, p);//????????????????????¨????????°???????????????????????¨????????±???????¨????
	if (T[u].l != NIL) deep(T[u].l, p + 1);//?????????????????????????????±???+1????¨????
	return 0;
}

int main(void){
	int root;
	int child_id; //???????????????id???????????????
	int tmp;
	cin >> n;
	rep(i, n) T[i].p = T[i].l = T[i].r = NIL; //?????????

	/* ??¨?§??????????????????? */
	rep(i, n){
		int id, k;//id??????????????????k?¬???°(????????°)
		scanf("%d %d", &id, &k);
		rep(j, k){
			scanf("%d", &tmp);//??????????????????
			if (j == 0) T[id].l = tmp;//??????????????????????????????
			else T[child_id].r = tmp;//??????????????????????????????
			child_id = tmp;//?¬????????????????id?????´??°??????
			T[tmp].p = id;//??????????????????		 
		}
	}

	//??????????????¢???
	//????????????n???
	rep(i, n){
		if (T[i].p == NIL) root = i;
	}

	deep(root, 0); //(?????????????????????root, ??±???)

	rep(i, n) print_ans(i);
	
	return 0;
 }

Measured memory_bytes: 7876
#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


class BIT {
	std::vector<int> bit;
public:
	BIT(int size) :bit(size + 1, 0) {}
	void add(int i, int x) {//i番目にx加える
		i++;//BIT添え字は1～ｎだから
		while (i<(int)bit.size()) {
			bit[i] += x;
			i += i&-i;
		}
	}
	int sum(int a)const {//[0,a]の和
		a++;
		int res = 0;
		while (0<a) {
			res += bit[a];
			a -= a&-a;
		}
		return res;
	}
	int sum(int a, int b)const {//[a,b]の合計
		return sum(b) - sum(a - 1);
	}
};


int popcount32(unsigned int x) {
#if defined(_MSC_VER)
	return __popcnt(x);
#else
	return __builtin_popcount(x);
#endif
}

class BIT_01 {
	BIT bit;
	std::vector<unsigned int> b;
public:
	BIT_01(int size) :bit((size+31)/32 + 1), b((size + 31) / 32) {}
	void on(unsigned int i) {
		if (b[i / 32] >> i % 32 & 1)return;
		b[i / 32] |= 1 << i % 32;
		bit.add(i / 32 + 1, 1);
	}
	void off(unsigned int i) {
		if (!(b[i / 32] >> i % 32 & 1))return;
		b[i / 32] &= ~(1 << i % 32);
		bit.add(i / 32 + 1, -1);
	}
	int rank(unsigned int i)const { //[0,i)
		return bit.sum(i / 32) + popcount32(b[i / 32] & ((1 << i % 32) - 1));
	}
};





int ans[100000];


vector<pair<int,int>> query[100000];
vector<int> child[100000];
BIT_01 bit(100000);



int N;
int x[100000];
int L, Q;

void dfs(int u) {
	for (auto p : query[u]) {
		ans[p.second] = bit.rank(p.first) + 1;
	}

	bit.on(u);
	for (int v : child[u]) {
		dfs(v);
	}
	bit.off(u);
}


int main() {
	scanf("%d", &N);
	rep(i, N)scanf("%d", x + i);
	scanf("%d%d", &L, &Q);
	rep(i, Q) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--; b--;
		if (a > b)swap(a, b);
		query[a].emplace_back(b, i);
	}
	rep(i,N-1) {
		if (query[i].empty() && child[i].empty())continue;
		int nxt = upper_bound(x, x + N, x[i] + L) - 1 - x;
		child[nxt].push_back(i);
	}
	dfs(N - 1);
	rep(i, Q)printf("%d\n", ans[i]);

	return 0;
}

Measured memory_bytes: 19200
#include <stdio.h>

int main(){
	int l,r,n;
	while(~scanf("%d %d %d",&l,&r,&n)){
		int i,k=0;
		for(i=l;i<=r;i++){
			if(i % n == 0){
				k+=1;
			}
		}
		printf("%d",k);
	}
	return 0;
} 

Measured memory_bytes: 1732
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n,ans=0; cin >> n;
	int d[100005];
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d, d + n, greater<int>());
	cout << d[n / 2 - 1] - d[n / 2] << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<map>
#include<cmath>
#include<stdlib.h>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>

using namespace std;

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

const int MX = 100005;

int N;
int D[MX];

int main()
{
	scanf("%d", &N);
	int ans = 0, cnt = 0, a;
	for(int i = 1; i <= N; i++){
		scanf("%d", &a);
		if( a == i ) cnt++;
		else ans += (cnt+1) / 2, cnt = 0;
	}ans += (cnt+1) / 2;
	printf("%d\n", ans);
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> c(n-1), s(n-1), f(n-1);
    for(int i=0;i<n-1;i++){
        cin >> c[i] >> s[i] >> f[i];
    }
    for(int i=0;i<n;i++){
        int ans = 0;
        for(int j=i;j<n-1;j++){
            if(ans <= s[j]){
                ans = s[j]+c[j];
            }else{
                int k = (ans-s[j]+f[j]-1)/f[j];
                ans += s[j]+k*f[j]-ans+c[j];
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] numberInfo = new int[100000 +1];
		long total = 0;
		for(int i =0;i < n;i++) {
			int tmp = sc.nextInt();
			numberInfo[tmp]++;
			total+= tmp;

		}
		int q = sc.nextInt();
		for(int i = 0; i < q; i++) {
			int b = sc.nextInt();
			int c = sc.nextInt();
			total += (c -b) * numberInfo[b];
			System.out.println(total);
			numberInfo[c] += numberInfo[b];
			numberInfo[b] = 0;
		}
	}
}

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

using namespace std;

int main() {
   int h,w;
   cin >> h >> w;
   string s[50];
   for(int i=0;i<h;i++){
       cin >> s[i];
   }
   int white=0;
   int cost[50][50];
   for(int i=0;i<h;i++){
       for(int j=0;j<w;j++){
           cost[i][j]=3000;//big enough
           if(s[i][j]=='.')white++;
       }
   }
   //bfs
   int dy[4]={-1,1,0,0};
   int dx[4]={0,0,-1,1};
   queue<pair<int ,int > > que;
   cost[0][0]=1;
   que.push(make_pair(0,0));
   while(!que.empty()){
       int y=que.front().first;
       int x=que.front().second;
       que.pop();
       for(int i=0;i<4;i++){
           if(y+dy[i]<0||y+dy[i]>=h||x+dx[i]<0||x+dx[i]>=w)continue;
           if(s[y+dy[i]][x+dx[i]]=='#')continue;
           if(cost[y+dy[i]][x+dx[i]]>cost[y][x]+1){
               cost[y+dy[i]][x+dx[i]]=cost[y][x]+1;
               que.push(make_pair(y+dy[i],x+dx[i]));
           }
       }
   }
   if(cost[h-1][w-1]==3000)cout << -1 << endl;
   else {
       cout << white-cost[h-1][w-1]<< endl;
   }
    return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
  int i;
  char S[111];
  ll K;
  cin >> K >> S;
  ll N =0;
  while(S[N]) N++;
  if(N <= K)
    cout << S << endl;
  else{
    for(i=0;i<=K-1;i++)
      cout << S[i];
    cout << "...";
    }
}

Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		sc.close();

		Collections.sort(list, Collections.reverseOrder());
		int ans = list.get(0) - list.get(list.size() - 1);
		System.out.println(ans);
	}

}

Measured memory_bytes: 20564
#include <iostream>
using namespace std;
int main(void){
    
    int x1 , x2;
    cin >> x1 >> x2;
    
    if(x1 < x2) cout<< x2 - x1<< endl;
    else
    cout<< x1 - x2<< endl;
    return 0;
}



Measured memory_bytes: 3088
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		//int N = int.Parse(Console.ReadLine());
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        long K = long.Parse(input[1]);
 
		// N個の数値の入力
        string[] nums = Console.ReadLine().Split(' '); 
 
		// 文字列の入力
		//string s = Console.ReadLine();
 
        // Kを2進数表記にする
        string strK = Convert.ToString(K, 2);
        // K（2進数）と同じ桁のint[]を用意
        int[] xor = new int[strK.Length];
        for (int i = 0; i < strK.Length; i++)
        {
            xor[i] = 0;
        }
        // N個の数値を2進数にし、i桁目に1がある数を数える
        for (int i = 0; i < N; i++)
        {
            string strAi = Convert.ToString(long.Parse(nums[i]), 2);
            for (int j = strAi.Length - 1, k=strK.Length -1; j>=0 && k>=0; j--, k--)
            {
                if (strAi[j] == '1')
                {
                    xor[k] += 1;
                }
            }
        }
        bool smallerFlg = false; // Kより小さいことを担保するフラグ
        string strX = "";
        // N個全てに対してチェックした後、f(x)最大値を取るときのxを求める
        for (int i = 0; i < xor.Length; i++)
        {
            if (xor[i] <= N / 2)
            {
                if (strK[i] == '1' || smallerFlg)
                {
                    strX =  strX + "1";
                }
                else
                {
                    strX = strX + "0";
                }
            }
            else
            {
                if (strK[i] == '1')
                    smallerFlg = true;
                strX = strX + "0";
            }
        }
        // f(x)の算出
        long ret = 0;
        long X = Convert.ToInt64(strX, 2);
        for (int i = 0; i < N; i++)
        {
            //int a = Convert.ToInt32(int.Parse(nums[i]) ^ X);
            //Console.WriteLine(nums[i] + "^" + X + "=" + a);
            ret += long.Parse(nums[i]) ^ X;
        }
            //出力
        Console.WriteLine(ret + "");
	    }
}

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

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

    string ans;
  	bool judge = false;
    for ( int i = 0 ; i <= n/4 ; i++ ){
        for ( int j = 0 ; j <= n/7 ; j++ ){
            if ( 4 * i + 7 * j == n ){
                judge = true;
            }
        }
    }
  	if(judge) ans = "Yes";
  	else ans = "No";
  
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<fstream>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<complex>
#include<cstring>
#include<string>
#include<algorithm>
#include<assert.h>
#include<vector>
#include<stack>
#include <utility>
#include<set>
#include<bitset>
#include<queue>
#include<map>
#include<valarray>
#include<numeric>
#include<map>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).end()),((v).begin())
#define clr(v,idx) memset(v,idx,sizeof(v))
#define rep(i,x) for(int i=0;i<(int)x;i++)
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll,ll>
//const int dx[] = {1,-1,0,0,1,-1,1,-1};
//const int dy[] = {0,0,1,-1,1,-1,-1,1};
//const int dxhorse[] = {-2,-2,-1,-1,1,1,2,2};
//const int dyhorse[] = {1,-1,2,-2,2,-2,1,-1};
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}

int main()
{
	int n; cin >> n;
	set<int>s;
	int d;
	while (n--) cin >> d, s.insert(d);
	cout << s.size();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n, t;
    cin >> n >> t;
    vector<P> v;
    rep(i,n){
        P p;
        cin >> p.first >> p.second;
        v.push_back(p);
    }
    sort(v.begin(), v.end());
    int ans = 0;

    int dp[t] = {};
    rep(i,n){
        rep(j,t)ans = max(ans, dp[j] + v[i].second);
        drep(j,t){
            if(v[i].first > j)break;
            if(v[i].first == j)dp[j] = max(dp[j], v[i].second);
            else dp[j] = max(dp[j], dp[j-v[i].first] + v[i].second);
        }
    }

    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * コンソールテスト用Main クラス
 *
 * @author RisaTozawa
 */
public class Main {

	/* コンストラクタ */
	Main() {
	//何もしない
	}

	/**
	 * 提出
	 *
	 */

	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a = 0;
		int b = 0;

		/* ２つの整数 a, b を読み込んで、a と b の大小関係を出力するプログラム */
		a = scanner.nextInt();
		b = scanner.nextInt();

		/* a より b の方が大きい */
		if (a < b) {
			System.out.println("a < b");
		/* a より b の方が小さい */
		} else if (a > b) {
			System.out.println("a > b");
		/* a と b が等しい */
		} else {
			System.out.println("a == b");
		}
	}
}



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

int main() {
  int a, b;
  cin >> a >> b;
  cout << max(0, a - 2 * b) << endl;
  return 0;
}

Measured memory_bytes: 256
// Aizu 2103: Battle Town
// 2017.9.20 bal4u@uu

#include <stdio.h>

char map[22][22]; int h, w;
char s[102];
char tbl[128];
int mv[4][2] = { {-1,0},{0,1},{1,0},{0,-1} };
char dir[4] = { '^', '>', 'v', '<' };

int main()
{
	int cno, t, n, r, c, tr, tc, d, k;
	char *p;

	tbl['^'] = 1, tbl['>'] = 2, tbl['v'] = 3, tbl['<'] = 4;
	tbl['U'] = 1, tbl['R'] = 2, tbl['D'] = 3, tbl['L'] = 4;
	scanf("%d", &t); cno = 0; while (t-- > 0) {
		scanf("%d%d", &h, &w);
		for (r = 0; r < h; r++) {
			scanf("%s", map[r]);
			for (c = 0; c < w; c++) if ((k = tbl[map[r][c]]) > 0) tr = r, tc = c, d = k-1;
		}
		scanf("%d", &n);
		scanf("%s", s); p = s;
		while (*p) {
			if (*p != 'S') {
				d = tbl[*p]-1; r = tr + mv[d][0], c = tc + mv[d][1]; map[tr][tc] = '.';
				if (r >= 0 && r < h && c >= 0 && c < w && map[r][c] == '.') tr = r, tc = c;
				map[tr][tc] = dir[d];
			} else {
				r = tr, c = tc; while (1) {
					r += mv[d][0], c += mv[d][1];
					if (r < 0 || r >= h || c < 0 || c >= w) break;
					if (map[r][c] == '*') { map[r][c] = '.'; break; }
					else if (map[r][c] == '#') break;
				}
			}
			p++;
		}
		if (cno++) putchar('\n');
		for (r = 0; r < h; r++) puts(map[r]);
	}
	return 0;
}

Measured memory_bytes: 1748
require 'pp'

def gets_HW_int
  h, w, n= gets.split.map(&:to_i)
  board = n.times.map { gets.split.map(&:to_i) }
  return h, w, n, board
end
W, H, N, xya_list = gets_HW_int

a1 = xya_list.select{|x, y, a| a == 1}
a2 = xya_list.select{|x, y, a| a == 2}
a3 = xya_list.select{|x, y, a| a == 3}
a4 = xya_list.select{|x, y, a| a == 4}

a1_x = a1.empty? ? 0 : a1.transpose[0].max
a2_x = a2.empty? ? W : a2.transpose[0].min
a3_y = a3.empty? ? 0 : a3.transpose[1].max
a4_y = a4.empty? ? H : a4.transpose[1].min

puts [a2_x - a1_x, 0].max * [a4_y - a3_y, 0].max


Measured memory_bytes: 2172
S = list(str(input()))

op_cnt = len(S) - 1
cons = 0
for i in range(2 ** op_cnt):
    op = [""] * op_cnt 
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"
    Ans = []
    for k in range(len(S)-1):
        Ans.append(S[k])
        Ans.append(op[k])
    Ans.append(S[-1])
    formula = ''.join(Ans)
    cons += eval(formula)

print(cons)


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

signed main() {
    int N;
    cin >> N;
    vector<int> B(N - 1);
    for (int& x : B) cin >> x;

    int ans = 0;
    for (auto it = B.begin(); it != B.end(); it++) {
        auto t = next(it, 1);
        if (t == B.end()) {
            t = it;
        }
        ans += min(*it, *t);
    }
    ans += B.front();
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
import bisect
from collections import defaultdict
import math

def judge(start, end, S):
    for i in range(start, end):
        s = S[i:i+2]
        if tuple(s) == ("#", "#"):
            return False
    return True

def main():
    N, A, B, C, D = map(int, input().split())
    S = list(input().strip())

    is_ok = judge(A-1, C-1, S)
    if not is_ok:
        print("No")
        return
    is_ok = judge(B-1, D-1, S)
    if not is_ok:
        print("No")
        return

    if C > D:
        for i in range(B-1, D):
            if S[i] != "#" and S[i-1] != "#" and S[i+1] != "#":
                print("Yes")
                return
        print("No")
    else:
        print("Yes")

if __name__ == '__main__':
    main()


Measured memory_bytes: 5172
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

f c a n = t1 + t2 + t3
  where
    t3 = min c $ min a n
    t2 = min ((c-t3)`div`2) (a-t3)
    t1 = (c-2*t2-t3) `div` 3

main = do
    n <- getInt
    replicateM n getInts >>= mapM_ (print . apply3 f)
    


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

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

const int prime_max = 1000000;
int NP,prime[100000],divp[prime_max];
map<int,int> M;

void cprime() {
	if(NP) return;
	for(int i=2;i<prime_max;i++) if(divp[i]==0) {
		//M[i]=NP;
		prime[NP++]=i;
		for(ll j=1LL*i*i;j>=i&&j<prime_max;j+=i) if(divp[j]==0) divp[j]=i;
	}
}

int S[1010100];

int Q,L,R;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cprime();
	for(i=1;i<=100000;i++) {
		S[i]=S[i-1];
		if(divp[i]==0 && i>=3 && (i%2==1) && divp[(i+1)/2]==0) S[i]++;
	}
	
	cin>>Q;
	FOR(i,Q) {
		cin>>L>>R;
		cout<<S[R]-S[L-1]<<endl;
	}
	
	
	
}


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


Measured memory_bytes: 7168
fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt()
    val d: List<Int> = sc.asSequence().take(n).map(String::toInt).toList()


    val ret = (0..k).map { left ->
        val la = d.take(left)
        (0..Math.min(k - left, n - left)).map { right ->
            val a: List<Int> = d.takeLast(right).plus(la).sorted().toList()
            val minus: Int = a.take(k - left - right).takeWhile { it < 0 }.sum()
            a.sum() - minus
        }.max() ?: 0
    }.max() ?: 0

    println(ret)
}


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


int main(){
  int k,s;
  cin >> k >> s;
  int i,j,x,y,z;
  int ans=0;
  for(i=0;i<=k;++i){
    for(j=0;j<=k;++j){
      x=i;
      y=j;
      z=s-x-y;
      if(z<=k && z>=0){
        ans++;
      }else{
        continue;
      }
    }
  }
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PB push_back

int main()
{
    ll N;
    cin >> N;
    map<ll, ll> value_count;
    map<ll, ll> ans;
    vector<ll> A(N);
    rep(i, N){
        cin >> A.at(i);
        if(value_count.count(A.at(i))){
            value_count[A.at(i)]++;
        }
        else{
            value_count[A.at(i)]=1;
            ans[A.at(i)]=0;
        }
    }
    ll all_conbination=0;
    for(auto i=value_count.begin(); i!=value_count.end(); i++){
        all_conbination+=i->S*(i->S-1)/2;
    }
    for(int i=0; i<N; i++){
        cout << all_conbination-value_count[A.at(i)]+1 << endl;
    }

}

Measured memory_bytes: 19072
#include<cstdio>
#include<algorithm>
int a[101],n,vis[101],mx,mn;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",a+i);
	std::sort(a+1,a+n+1);
	mx=a[n];
	for(int i=0;i<=mx;++i){
		bool find=0;
		for(int j=1;j<=n;++j)if(!vis[j]&&a[j]==mx-i/2){find=1;vis[j]=1;break;}
		if(!find){puts("Impossible");return 0;}
	}
	for(int i=1;i<=n;++i)if(!vis[i]&&a[i]<=(mx+1)/2){puts("Impossible");return 0;}
	puts("Possible");
	return 0;
}

Measured memory_bytes: 128
S = input()
max = 0
for i in range(len(S)):
    if(S[i] not in ['A', 'T', 'C', 'G']):
        continue
    for n in range(i, len(S)):
        if(S[n] in ['A', 'T', 'C', 'G']):
            if(max < n - i + 1):
                max = n - i + 1
        else:
            break
print(max)

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main()
{
    int n, l;
    cin >> n >> l;
    vector<int> taste(n + 1);
    int eat = 100000;
    for (int i = 1; i <= n; i++)
    {
        taste[i] = l + i - 1;
        if(abs(eat) > abs(taste[i])){
            eat = taste[i];
        }
    }

    int all = 0;
    for (int i = 1; i <= n; i++)
    {
        all += taste[i];
    }
    cout << all - eat << endl;
    
}


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

int main() {
	int n, m, ans = 0, count;
	bool f;
	cin >> n >> m;
	vector<int> k(m), p(m);
	vector<vector<int>> s(m, vector<int>(n));
	for (int i = 0; i < m; ++i) {
		cin >> k[i];
		s[i].resize(k[i]);
		for (int j = 0; j < k[i]; ++j) cin >> s[i][j];
	}
	for (int i = 0; i < m; ++i) cin >> p[i];

	for (int i = 0; i < (1 << n); ++i) {
		f = true;
		for (int j = 0; j < m && f; ++j) {
			count = 0;
			for (int l = 0; l < k[j] && f; ++l) {
				if (i & (1 << s[j][l] - 1)) count++;
			}
			if (count % 2 != p[j]) f = false;
		}
		if (f) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define Pi pair<int,int>
#define Pl pair<ll,ll>
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

vector<vector<Pi>> X(100000);
vector<int> W(100000, MOD);

int dest, dist;

bool search(int x, int y) {
	int ss = X[x].size();
	int f, s;
	for (int i = 0;i < ss;i++) {
		f = X[x][i].first;
		s = X[x][i].second;
		if (f == y) continue;
		if (W[f] == MOD) {
			W[f] = W[x] + s;
			if (search(f, x))
				return true;
		}
		else if (W[f] != W[x] + s)
			return true; //失敗
	}
	return false;
}

int main() {
	int N, M;
	cin >> N >> M;
	int L, R, D;
	for (int i = 0;i < M;i++) {
		cin >> L >> R >> D;
		L--;R--;
		X[L].push_back({ R,D });
		X[R].push_back({ L,-D });
	}
	for (int i = 0;i < N;i++) {
		if (W[i] == MOD) {
			if (search(i, MOD)) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 12928
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
//const int mod = 1e9 + 7;
const int mod = 998244353;

using mint = modint998244353;

struct S{
    mint val,digit;
};

using F = int;

S op(S l, S r) {return S{l.val + r.val, l.digit + r.digit};};

S mapping(F l, S r) {return S{(l == inf ? r.val : r.digit * l), r.digit};};

F composition(F l, F r) {return l == inf ? r : l;}

S e() {return S{0,0};};

F id() {return inf;};

int main(){
    int n,q; cin >> n >> q;
    vector<S> a(n);
    rep(i,n) a[i] = S{mint(10).pow(n-i-1), mint(10).pow(n-i-1)};
    lazy_segtree<S,op,e,F,mapping,composition,id> seg(a);
    while(q--){
        int l,r,d; cin >> l >> r >> d; l--;
        seg.apply(l,r,d);
        cout << seg.all_prod().val.val() << "\n";
    }
}

Measured memory_bytes: 9872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    vl A(N);
    rep(i, N) cin >> A[i];

    if(A[0]!=0){
        cout << -1 << endl;
        return 0;
    }

    ll zi = 0;
    rep(i, N) if (A[i] == 0) zi = i;

    ll pre = 0, ans = 0;
    repr(i, N){
        if(i<zi){
            zi--;
            while (A[zi] != 0) zi--;
        }
        if(A[i] > i - zi or pre - A[i] > 1){
            cout << -1 << endl;
            return 0;
        }
        if (A[i] != pre - 1) ans += A[i];
        pre = A[i];
    }

    cout << ans << endl;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e2 + 5;

int g[MAXN][MAXN];

void solve(){
	int n, m;
	cin >> n;
	REPN(i, 1, n) {
		REPN(j, i + 1, n) {
			g[i][j] = g[j][i] = 1;
		}
	}
	m = n * (n - 1) / 2;
	if (n & 1) {
		REPN(i, 1, n / 2) {
			g[i][n - i] = g[n - i][i] = 0;
			m--;
		}
	} else {
		REPN(i, 1, n / 2) {
			g[i][n + 1 - i] = g[n + 1 - i][i] = 0;
			m--;
		}
	}
	printf("%d\n", m);
	REPN(i, 1, n) {
		REPN(j, i + 1, n) {
			if (g[i][j]) {
				printf("%d %d\n", i, j);
			}
		}
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;

int N, L;

int main() {
	cin >> N >> L;
	vector<int> apple;
	for (int i = 1; i <= N; i++)
		apple.push_back(L + i - 1);
	int abs_min = 999999;
	int i_min;
	for (int i = 0; i < N; i++) 
		if (abs(apple[i]) < abs_min) {
			abs_min = abs(apple[i]);
			i_min = i;
		}
	int ans = 0;
	for (int i = 0; i < N; i++)
		ans += apple[i];
	ans -= apple[i_min];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
ll s;
const ll N=1e9;
int main(){
    cin>>s;
    ll a,b,c,d;
    d=N-1,a=min(s/d,N);b=-1,c=s-a*d;
    ll x1=0,x2=a,x3=c,y2=0,y1=1,y3=1+d;
    cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;
    return 0;
}


Measured memory_bytes: 256
# def gcd(a_gcd, b_gcd):
#     while b_gcd != 0:
#         a_gcd, b_gcd = b_gcd, a_gcd % b_gcd
#     return a_gcd
#
#
# def lcm(a_lcm, b_lcm):
#     return a_lcm * b // gcd(a_lcm, b_lcm)
#
#
# def max_sum(N_max_sum, a_max_sum):
#     dp = [0] * (N_max_sum + 1)
#     for i in range(N_max_sum):
#         dp[i + 1] = max(dp[i], dp[i] + a_max_sum[i])
#     return dp[N]
#
#
# def knapsack(N_knapsack, W, weight, value):
#     inf = float("inf")
#     dp = [[-inf for _ in range(W+1)] for j in range(N_knapsack + 1)]
#     for i in range(W+1):
#         dp[0][i] = 0
#
#     for i in range(N_knapsack):
#         for w in range(W+1):
#             if weight[i] <= w:
#                 dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
#             else:
#                 dp[i+1][w] = dp[i][w]
#     return dp[N_knapsack][W]


import math

# n = int(input())
N, K = map(int, input().split())

sum = [0 for _ in range(math.ceil(math.log(K, 2)) + 1)]


for i in range(N, 0, -1):
    for j in range(len(sum)):
        if K <= i * pow(2, j):
            sum[j] += 1
            break

ans = 0

for i in range(len(sum)):
    # print(pow(2, i))
    # print(sum[i])
    ans += sum[i] / (pow(2, i) * N)

print(ans)

















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

int main() {
  string s;
  cin >> s;
  
  int l = s.size();
  for(int i = 0; i < 26; i++){
    char now = 'a' + i;
    bool ok = true;
    for(int j = 0; j < l; j++) if(now == s.at(j)) ok = false;
    if(ok){
      cout << s << now << endl;
      return 0;
    }
  }
  
  vector<char> ans(1, s.at(l-1));
  for(int i = l-1; i > 0; i--){
    if(s.at(i) < s.at(i-1)) ans.push_back(s.at(i-1));
    else{
      for(int j = 0; j < i-1; j++) cout << s.at(j);
      sort(ans.begin(), ans.end());
      char c;
      for(auto a : ans){
        if(a > s.at(i-1)){
          c = a;
          break;
        }
      }
      cout << c << endl;
      return 0;
    }
  }
  
  cout << -1 << endl;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define V vector
#define pb push_back
#define mp make_pair
#define endl "\n"
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define MOD 1000000007  //1e9+7

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
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...);
}

const int N=1000000;
int p[N+1]={0};

void PrimeSieve()
{
    p[0]=0;
    p[1]=0;
    p[2]=1;
    for(int i=3;i<=N;i+=2)
    {
        p[i]=1;
    }
    for(int i=3;i*i<=N;i+=2)
    {
        if(p[i])
        {
            for(int j=i*i;j<=N;j=j+2*i)
            {
                p[j]=0;
            }
        }
    }
    return;
}

void solve()
{
	int a; cin>>a;
	for(int i=a;i<=N;i++){
		if(p[i]){
			cout<<i<<endl;
			return;
		}
	}
}
	
int32_t main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //int t; cin>>t;
    //while(t--)
    PrimeSieve();
    solve();
    return 0;
}

Measured memory_bytes: 8064
//NAME-DEEPESH BHATT
//Institute-IIT Dhanbad
//MOTTO-THINK FIRST,CODE LATER

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1E9+7  ;
/*#define endl '\n'*/
#define pb push_back
#define mp make_pair

//Check for signed int overflow
// use __builtin_popcount(num) to calculate no.of setbits in num
//s.lower_bound() works in O(logn) whereas lower_bound(s.begin(),s.end(),x) works in O(n)

//Euclid's Algo
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
//Extended Euclid's Algo
ll gcd_ex(ll a,ll b,ll&x,ll&y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll g=gcd_ex(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}
//Multiplicative Modulo Inv
ll multi_mod_inv(ll a,ll m){
    ll x,y;
    ll g=gcd_ex(a,m,x,y);
    if(g!=1){
        return -1;
    }
    x=(x%m+m)%m;
    return x;
}
//Mod division
ll mod_div(ll a,ll b,ll m){
    //(a/b)mod m?
    if(multi_mod_inv(b,m)!=-1){
        return (a%m*multi_mod_inv(b,m)%m)%m;
    }
    else{
        return -1;
    }
}
//lcm
ll lcm(ll a ,ll b)
{
    return a/gcd(a,b)*b;
}
//Binary Exponentiation
ll power(ll a,ll n){
    if (n == 0)
        return 1;
    ll p = power(a, n / 2);
    p = (p * p)%MOD;
    if (n % 2)
        return (p * a)%MOD;
    else
        return p%MOD;
}
//Euler Totient Function
ll phi[1000001]={0};
void euler_totient(ll n){
    for(ll i=0;i<=n;i++){
        phi[i]=i;
    }
    phi[1]=1;
    for(ll i=2;i<=n;i++){
        if(i==phi[i]){
            phi[i]=i-1;//For a prime number phi(p)=p-1
            for(ll j=2*i;j<=n;j+=i){
                phi[j]=phi[j]*(i-1)/i;
            }
        }
    }
}
int32_t main()
{
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    ios_base::sync_with_stdio(false);    //for fast I/O operation
    cin.tie(nullptr);
    ll t=1;
    /*cin>>t;*/
    while(t--){
        string s;
        cin>>s;
        ll n=s.length();
        if(s[n-1]!='s'){
            s+='s';
        }
        else{
            s+="es";
        }
        cout<<s<<endl;
    }
    return 0;
}

Measured memory_bytes: 3624