akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

    vector<int> ret(n);
    int now = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            now++;
            if (s[i + 1] == 'L') {
                ret[i] += (now + 1) / 2;
                ret[i + 1] += now / 2;
                now = 0;
            }
        }
    }
    now = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'L') {
            now++;
            if (s[i - 1] == 'R') {
                ret[i] += (now + 1) / 2;
                ret[i - 1] += now / 2;
                now = 0;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        if (i > 0)cout << " ";
        cout << ret[i];
    }
    cout << endl;
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}

int a[1005][1005];

int main2() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;

  CLR(a, 0);

  REP(i, H) {
    REP(j, W) {
      if ((i < B) ^ (j < A))
        a[i][j] = 0;
      else
        a[i][j] = 1;
    }
  }


  REP(i, H) {
    REP(j, W) cout << a[i][j];
    cout << endl;
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<int> P(N);
	for (auto& e: P) scanf("%d", &e);
	int min{1 << 30}, ans{};
	for (int i{}; i < N; i++)
	{
		if (P[i] <= min)
			ans++;
		min = std::min(min, P[i]);
	}
	printf("%d\n", ans);

	return 0;
}

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

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)

int n,k;
int card[16];
int check[16];
set<string> ss;

string tos(int a){
	char str[100];
	int i=0;
	while( a>0 ){
		str[i++] = a%10 + '0';
		a /= 10;
	}
	str[i] = 0;
	string s = string(str);
	return string(s.rbegin(), s.rend());
}
void solve(int cnt, string str){
	//printf("%d , %s\n",cnt,str.c_str());
	if( cnt==0 ){
		ss.insert(str);
		return;
	}
	for(int i=0; i<n; i++)if( !check[i] ){
		check[i] = 1;
		solve(cnt-1, str + tos(card[i]));
		check[i] = 0;
	}
	return;
}
int main(){
	while(scanf("%d%d",&n,&k),n|k){
		ss.clear();
		rep(i,n)scanf("%d",&card[i]);
		solve(k,"");
		cout << ss.size() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(){
    string a;
    short r[6][2]={{1,2},{-1,3},{1,-1},{4,5},{5,2},{2,1}};
    while(cin>>a,a!="#"){
        int now=0;
        for(int i = 0; i < a.size(); i++){
            now = r[now][a[i]-'0'];
            if(now == -1)break;
        }
        cout << (now == 5?"Yes":"No") << endl;
    }
    return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a;
    cin >> n;
    a = n %10 + (n/10)%10 + (n/100)%10 +(n/1000)%10 + n/10000;
    if(a==1) cout << 10 << endl;
    else cout << a << endl;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll h, a;
    cin >> h >> a;
    ll ans = (h + a - 1) / a;
    cout << ans << endl;
    return 0;
}



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

long long gcd(long long a,long long b)
{
  return b?gcd(b,a%b):a;
}

int main()
{
  int n;
  static long long B,A[100000];
  scanf("%d%lld",&n,&B);
  for(int i=0;i<n;i++){
    scanf("%lld",A+i);
  }
  long long G=A[0],M=A[0];
  for(int i=1;i<n;i++){
    G=gcd(G,A[i]);
    M=max(M,A[i]);
  }
  puts(B<=M&&B%G==0?"POSSIBLE":"IMPOSSIBLE");
  return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
constexpr long long LINF = 1000100010001000100LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main() { 
    ll n, a, b; cin >> n >> a >> b;
    if((b-a)%2==0) cout << (b-a)/2 << ln;
    else{
        ll res = LINF * 4;
        //左に寄せる
        ll cnt = min(a-1, b-1), x = a , y = b;
        x -= cnt , y -= cnt;
        x==1?y--:x--; cnt++;
        cnt += abs((y-x)/2);
        chmin(res, cnt);
        //右に寄せる
        cnt = min(n-a, n-b);
            a += cnt, b += cnt;
            a==n?b++:a++; cnt++;
        cnt += (abs(b-a)/2);
        chmin(res, cnt);
        cout << res << ln;
    }
}

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

using DD = double;
const DD INF = 1LL<<60;      // to be set appropriately
const DD EPS = 1e-10;        // to be set appropriately
const DD PI = acosl(-1.0);
DD torad(int deg) {return (DD)(deg) * PI / 180;}
DD todeg(DD ang) {return ang * 180 / PI;}

/* Point */
struct Point {
    DD x, y;
    Point(DD x = 0.0, DD y = 0.0) : x(x), y(y) {}
    friend ostream& operator << (ostream &s, const Point &p) {return s << '(' << p.x << ", " << p.y << ')';}
};
inline Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);}
inline Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);}
inline Point operator * (const Point &p, DD a) {return Point(p.x * a, p.y * a);}
inline Point operator * (DD a, const Point &p) {return Point(a * p.x, a * p.y);}
inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);}
inline Point operator / (const Point &p, DD a) {return Point(p.x / a, p.y / a);}
inline Point conj(const Point &p) {return Point(p.x, -p.y);}
inline Point rot(const Point &p, DD ang) {return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);}
inline Point rot90(const Point &p) {return Point(-p.y, p.x);}
inline DD cross(const Point &p, const Point &q) {return p.x * q.y - p.y * q.x;}
inline DD dot(const Point &p, const Point &q) {return p.x * q.x + p.y * q.y;}
inline DD norm(const Point &p) {return dot(p, p);}
inline DD abs(const Point &p) {return sqrt(dot(p, p));}
inline DD amp(const Point &p) {DD res = atan2(p.y, p.x); if (res < 0) res += PI*2; return res;}
inline bool eq(const Point &p, const Point &q) {return abs(p - q) < EPS;}
inline bool operator < (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x < q.x : p.y < q.y);}
inline bool operator > (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x > q.x : p.y > q.y);}
inline Point operator / (const Point &p, const Point &q) {return p * conj(q) / norm(q);}


const int ITER = 100;

int N;
vector<Point> v;

DD f(DD x, DD y) {
    DD res = 0;
    for (int i = 0; i < N; ++i) res = max(res, abs(v[i] - Point(x, y)));
    return res;
}

DD g(DD x) {
    DD left = -1000, right = 1000;
    for (int _ = 0; _ < ITER; ++_) {
        DD m1 = (left * 2 + right) / 3;
        DD m2 = (left + right * 2) / 3;
        if (f(x, m1) > f(x, m2)) left = m1;
        else right = m2;
    }
    return f(x, left);
}

DD solve() {
    DD left = -1000, right = 1000;
    for (int _ = 0; _ < ITER; ++_) {
        DD m1 = (left * 2 + right) / 3;
        DD m2 = (left + right * 2) / 3;
        if (g(m1) > g(m2)) left = m1;
        else right = m2;
    }
    return g(left);
}

int main() {
    cin >> N;
    v.resize(N);
    for (int i = 0; i < N; ++i) cin >> v[i].x >> v[i].y;
    cout << fixed << setprecision(10) << solve() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;

int main()
{
	int a, b, C;
	double PI = acos(-1);

	cin >> a >> b >> C;

	double radC = C * PI / 180;
	double c = sqrt(a*a + b*b - 2 * a*b*cos(radC));

	double L = a + b + c;

	double S = a * b * sin(radC) / 2;

	double h = b * sin(radC);

	printf("%lf\n%lf\n%lf\n", S, L, h);

	return 0;
}

Measured memory_bytes: 3412
n = int(input())
A = list(map(int, input().split()))
c = [0] * 10001
output = [0] * n

for num in A:
    c[num] += 1

for i in range(0, max(A)):
    c[i + 1] += c[i]

for j in range(-1, -n-1, -1):
    output[c[A[j]] - 1] = A[j]
    c[A[j]] -= 1

print(*output)



Measured memory_bytes: 224504
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int W = sc.nextInt();
		int[] w = new int[N];
		long[] v = new long[N];
		for(int i=0; i<N; i++){
			w[i] = sc.nextInt();
			v[i] = sc.nextLong();
		}
		long[][] dp = new long[N+1][W+1];
		for(int i=1; i<N+1; i++){
			for(int j=1; j<W+1; j++){
				if(j < w[i-1]){
					dp[i][j] = dp[i-1][j];
				}
				else{
					dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1]);
				}
			}
		}
		System.out.println(dp[N][W]);
	}
}

Measured memory_bytes: 128980
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <iomanip>
using namespace std;
int main(void){
    int n,m;
    cin >> n >> m;
    vector<vector<int> > v1(n+1),v2(n+1);
    int p[m],y[m];
    for(int i=0;i<m;i++){
        cin >> p[i] >> y[i];
        v1[p[i]].push_back(y[i]);
    }
    for(int i=1;i<n+1;i++){
        sort(v1[i].begin(),v1[i].end());
    }
    cout.setf(ios::fixed);
    for(int i=0;i<m;i++){
        vector<int>::iterator itr = lower_bound(v1[p[i]].begin(), v1[p[i]].end(), y[i]);;
        cout << setw(6) <<setfill('0')<< p[i] <<setw(6)<< itr-v1[p[i]].begin()+1 << endl;
    }
}


Measured memory_bytes: 10112
import java.util.*;

public class Main {
  private static final int MOD = 1_000_000_007;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    char[][] d = new char[2][N];
    for (int i = 0; i < 2; i++) {
      String s = sc.next();
      for (int j = 0; j < N; j++) {
        d[i][j] = s.charAt(j);
      }
    }

    int j = d[0][0] == d[1][0] ? 1 : 2;
    long ans = d[0][0] == d[1][0] ? 3 : 6;
    while (j < N) {
      if (d[0][j] == d[1][j]) {
        ans *= d[0][j-1] == d[1][j-1] ? 2 : 1;
        j++;
      } else {
        ans *= d[0][j-1] == d[1][j-1] ? 2 : 3;
        j += 2;
      }
      ans %= MOD;
    }
    System.out.println(ans);
  }
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, K;
    cin >> N >> K;
    ll ans = 0;
    rep(i, 100) {
        if (N >= pow(K, i)) {
            ans = max(ans, i);
        } else {
            break;
        }
    }
    cout << ans + 1 << '\n';
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,r,ans=10000000000;
string s,S,t;
int main() {
ios_base::sync_with_stdio(false);
  cin >> s;
REP(i,s.size()-2){
ans=min(ans,llabs(753-(((LL)s[i]-48)*100+((LL)s[i+1]-48)*10+((LL)s[i+2]-48))));
}
cout <<ans<<endl;
}

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

int main() {
  int N;
  scanf("%d",&N);
  int C[N-1], S[N-1], F[N-1];
  for (int i=0; i<N-1; i++) {
    scanf("%d %d %d",&C[i],&S[i],&F[i]);
  }
  for (int i=0; i<N; i++) {
    int x=0;
    for (int j=i; j<N-1; j++) {
      if (x<S[j]) {
        x=S[j];
        x+=C[j];
      } else if (x%F[j]==0) {
        x+=C[j];
      } else {
        x=x+F[j]-x%F[j];
        x+=C[j];
      }
    }
    printf("%d\n",x);
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
int n,i,j;
  float nn;
  scanf("%f",&nn);
  n=(int)nn;
float x[n],y[n],d[n][n],sum;
  sum=0;
  for(i=0;i<n;++i){
  scanf("%f %f",&x[i],&y[i]);
  }
  for(i=1;i<n;++i){
   for(j=0;j<i;++j){
   d[i][j]=sqrtf((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
   sum=sum+d[i][j]/nn*2;
   }
  }
  printf("%.6f",sum);  
return 0;
}

Measured memory_bytes: 2200
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int T, A, B;

bool palindrome(int n){
	string s = to_string(n);
	for(int i = 0; i < s.length() / 2; i++)
		if(s[i] != s[s.length() - 1 - i]) return false;
	return true;
}

int main(void){
	//IO("test.in", "test.out");
	scanf("%d%d", &A, &B);
	for(int i = A; i <= B; i++)
		if(palindrome(i)) T++;
	printf("%d\n", T);
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

S = input()
K = int(input())

for i in range(K):
	if S[i] == '1':
		continue
	else:
		print(S[i])
		sys.exit()

print(S[K-1])


Measured memory_bytes: 10712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main(){
    int k, n; cin>>k>>n;
    vector<int> a(n);
    vector<int> b(n);
    int sum=0;
    cin>>a[0];
    for(int i=1; i<n; i++){
        cin>>a[i];
        b[i]=a[i] - a[i-1];
        sum+=b[i];
    }
    b[0] = k-a[n-1] + a[0];
    sum += b[0];
    int ans=sum - *max_element(b.begin(), b.end());
    cout<<ans<<endl;
}

Measured memory_bytes: 4860
n=int(input())
w=[input() for s in range(n)]
k=[w[0]]
D=0
for i in range(1,n):
 if w[i] in k or w[i-1][-1]!=w[i][0]:
  D+=1
 else:
  k.append(w[i])

if D>0:
 print("No")
else:
 print("Yes")

Measured memory_bytes: 3064
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     cin>>n;
     int ara[200005]={0};
     for(i=0;i<n;i++){
        cin>>x;
        sum+=x;
        ara[x]++;
     }
     cin>>p;
     while(p--){
        cin>>l>>r;
       sum=sum-(ara[l]*l);
       sum+=ara[l]*r;
       ara[r]=ara[l]+ara[r];
       ara[l]=0;
       cout<<sum<<endl;
     }

     return EXIT_SUCCESS;
}


Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
 
/*????????????????????????*/
struct edge {int to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<edge> VE;
//static const int INF = 2147483647;
//static const int INF = 1000000000;
//static const int INf = 9223372000000000000;
static const long long INF = 9223372000000000000/2;
static const int NIL = -1;
static const int MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
/* t y p o ??£ ??? ??\ ??£ ??? ??? ??\ ??? ??? */
#define itn int
#define scnaf scanf
#define reutnr return
#define scamf scanf
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define int ll

const int NMAX = 100;

int n,m;
int d[NMAX+10][NMAX+10];

void intialize(){
    for(int i=0;i<NMAX;i++){
        for(int j=0;j<NMAX;j++) d[i][j] = INF;
    }
    for(int i=0;i<NMAX;i++) d[i][i] = 0;
}

void WF(){
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++) if(d[i][k] != INF && d[k][j] != INF) d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
        }
    }
}

void output(){
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(d[i][j]==INF) printf("INF");
            else printf("%d",d[i][j]);
            if(j!=n-1) printf(" ");
        }
        printf("\n");
    }
}

void input(){
    for(int i=0;i<m;i++){
        int tmp1,tmp2,tmp3;
        scanf("%lld %lld %lld",&tmp1,&tmp2,&tmp3);
        //tmp1--; tmp2--;
        d[tmp1][tmp2] /*= d[tmp2][tmp1] */= tmp3;
    }
}

void solve(){
    for(int i=0;i<n;i++){
        if(d[i][i]<0){
            printf("NEGATIVE CYCLE\n");
            return;
        }
    }
    
    output();

    return;
}

signed main(){
    scanf("%lld %lld",&n,&m);

    intialize();

    input();

    WF();

    solve();

    return 0;
}

Measured memory_bytes: 3308
import math
import sys
def rem(i,j):
    return (i*j)%2019
l, r = map(int, input().split())
cnt=2018
if (r - l >= 2019):
    print(0)
    sys.exit()
else:
    for i in range(l, r+1):
        for j in range(i + 1, r+1):
            cnt = min(rem(i, j), cnt)
if (r - l == 1):
    cnt=min(cnt,r*l%2019)
print(cnt)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N;
        cin >> N;
        int S = 1 + N;
        if (N % 2 == 1) S = N;
        vector<pair<int, int> > ans;
        for (int i = 1; i <= N; ++i) {
            int musi = S - i;
            for (int j = i + 1; j <= N; ++j) {
                if (j != musi) ans.emplace_back(i, j);
            }
        }

        cout << ans.size() << endl;
        for (auto e : ans) {
            cout << e.first << " " << e.second << endl;
        }

        //test
//        vector<int> sum(N + 1);
//        for (auto e : ans) {
//            sum[e.first] += sum[e.second];
//            sum[e.second] += sum[e.first];
//        }
//
//        for (int i = 0; i < N; ++i) {
//            if (sum[i] != sum[i + 1]) {
//                exit(-1);
//                cerr << "err" << endl;
//            }
//        }


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

    int root(int x)
    {
        if (par[x] < 0)
            return x;
        else
            return par[x] = root(par[x]);
    }

    bool issame(int x, int y)
    {
        return root(x) == root(y);
    }

    bool merge(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (par[x] > par[y])
            swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x)
    {
        return -par[root(x)];
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k, l;
    cin >> n >> k >> l;
    UnionFind way(n), train(n);
    for (int i = 0; i < k; i++)
    {
        int p, q;
        cin >> p >> q;
        p--;
        q--;
        way.merge(p, q);
    }
    for (int i = 0; i < l; i++)
    {
        int r, s;
        cin >> r >> s;
        r--;
        s--;
        train.merge(r, s);
    }
    vector<pair<int, int>> cnt(n);
    map<pair<int, int>, int> mp;
    for (int i = 0; i < n; i++)
    {
        cnt[i] = make_pair(way.root(i), train.root(i));
        mp[cnt[i]]++;
    }
    for (int i = 0; i < n; i++)
    {
        cout << mp[cnt[i]] << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 15104
#include <iostream>
using namespace std;
int main(){
    while(true){
        int x,y,xa;
        cin >>x>>y;
        if( x==0&&y==0){break;}
        if(x>y){
            xa = x;
            x = y;
            y = xa;}
        cout << x << " " << y << endl;
    }    
}


Measured memory_bytes: 2964
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		
		var x = Console.ReadLine().Split().Select(a => int.Parse(a)).ToArray();
		int ans = 0;
		for(int i=0;i!=5;i++){
			if(x[i]==0){
				ans = i+1;
			}
		}
		
		Console.WriteLine(ans);
		
		
	}
}

Measured memory_bytes: 28300
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

/*
//tenka1 2017
int main(void) {
	ll N;
	cin >> N;
	bool isEnd = false;
	rep(h, 1, 3501) {
		rep(n, 1, 3501) {
			ll child = h * n * N;
			ll parent = 4 * h * n - N*(h + n);
			if (parent > 0 && child % parent == 0) {
				ll w = child / parent;
				if (4 * h * n * w == N * (h * n + n * w + h * w)) {
					cout << h << " " << n << " " << w  << endl;
					isEnd = true;
					break;
				}
			}

		}
		if (isEnd)break;
	}
}
*/
/*
//ABC98 D

int main(void) {
	ll n;
	cin >> n;
    vector<ll> a = vector<ll>(n);	
	rep(i, 0, n)cin >> a[i];
	ll l = 0, r = 0;
	ll xorSum = 0;
	ll sum = 0;
	ll ans = 0;
	while (r < n) {
		ll xorSumNew = xorSum ^ a[r];
		ll sumNew = sum + a[r];
		if (xorSumNew == sumNew) {
			ans += r - l + 1;
			r++;
			xorSum = xorSumNew;
			sum = sumNew;
		}
		else {
			xorSum ^= a[l];
			sum -= a[l];
			l++;
		}
	}
	cout << ans << endl;
}
*/

//ABC 96 D

int main(void) {
	ll n;
	cin >> n;
	vector<ll> p = vector<ll>(55556,0);
	rep(i, 2, 55556) {
		if (p[i] < 0)continue;
		else {
			for (ll j = i * 2; j < 55556; j += i) {
				p[j] = -1;
			}
		}
	}
	ll count = 1;
	for (ll j = 5; j + 2 < 55556; j += 10) {
		if (p[j + 2] == 0) {
			if (count < n) {
				cout << j + 2 << " " << endl;
				count++;
			}
			else {
				cout << j + 2 << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#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=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n;
	cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	vector<ll> c(n);
	for (ll i = 0;i < n;i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	vector<vector<ll>> dp(n,vector<ll>(3,-1));
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	for (ll i = 1; i < n;i++){
		dp[i][0] = max(dp[i - 1][1] +a[i],dp[i-1][2]+a[i]);
		dp[i][1] = max(dp[i - 1][0] +b[i],dp[i-1][2]+b[i]);
		dp[i][2] = max(dp[i - 1][0] +c[i],dp[i-1][1]+c[i]);
	}
	cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) <<endl;
	return 0;
}

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

// input
int C[3][3];


void input() {
    rep(i, 3) rep(j, 3) cin >> C[i][j];
}


bool judge() {
    rep(i, 3) rep(j, 3) {
        int a, b, c;
        a = C[0][i] - C[0][j];
        b = C[1][i] - C[1][j];
        c = C[2][i] - C[2][j];
        if (a != b or b != c) return false;
        a = C[i][0] - C[j][0];
        b = C[i][1] - C[j][1];
        c = C[i][2] - C[j][2];
        if (a != b or b != c) return false;
    }
    return true;
}


int main() {
    input();
    string ans;
    if (judge()) ans = "Yes";
    else ans = "No";
    cout << ans << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long


signed main()
{
    FAST;
    
    int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
    int temp1=0,temp2=0,temp3=0,temp4=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,anss=0,start=0,end=0,r=0,q=0,total=0;
    int maxx=-1,minn=1e10,curr=0,ansss=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,z=0,d=0,val=0;
    
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
    
    
}

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

using namespace std;

#define pb push_back
#define mp make_pair

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

const ll INF= ll (1e18);
const int MOD= 1e9+7;
const int N=200000+10;

ll arr[N],arr1[N];

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

    ll n;
    cin>>n;

    for(int i=1;i<=n;i++)
        cin>>arr[i];

    sort(arr+1,arr+n+1);

    for(int i=1;i<=n;i++)
    {
        arr1[i]=arr[i];
    }

    for(int i=2;i<=n;i++)
        arr[i]+=arr[i-1];

    int ans=1;
    for(int i=n-1;i>0;i--)
    {
        if(arr[i]*2>=arr1[i+1])
            ans++;
        else
            break;
    }
    cout<<ans;


    return 0;
}





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

int main(void){
  int N, M;
  cin >> N;
  map<string,int> mp{};
  string s;
  for(int i = 0; i < N; i++){
    cin >> s;
    mp[s]++;
  }
  cin >> M;
  string t;
  for(int i = 0; i < M; i++){
    cin >> t;
    mp[t]--;
  }
  int max = 0;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr){
    string key = itr->first;
    int value = itr->second;
    // cout << key << ":" << value << endl;
    if(max <= value){
      max = value;
    }
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#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<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    string s;
    cin>>s;
    int ssz=s.size();
    int biun=-1;
    int triun=-1;
    rep(i,ssz-1){
        if(s[i+1]==s[i]){
            biun=i;
            break;
        }
    }
    rep(i,ssz-2){
        if(s[i+2]==s[i]){
            triun=i;
            break;
        }
    }
    if(biun!=-1)cout<<biun+1<<" "<<biun+2<<endl;
    else if(triun!=-1)cout<<triun+1<<" "<<triun+3<<endl;
    else cout<<-1<<" "<<-1<<endl;
}


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

#define ll long long
using namespace std;

int main() {
    ll n;
    cin >> n;
    ll N = 0;
    ll p = 0;
    for (ll i = 1; i <= n; i++)
    {
        ll x;
        cin >> x;
        if ( x % 2 == 0) p++;
            else N++;
    }
    if (N % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  std::string s;
  cin>>s;
  int count=0;

  std::vector<int> result(s.size());
  for(int i=0;i<s.size();i++){

      if(s[i]=='R'){
        count++;

      }else{
        result[i]+=count/2;
        result[i-1]+=ceil((double)count/2);
        count=0;

      }

  }
  count=0;
  for(int i=s.size()-1;i>=0;i--){
    if(s[i]=='L'){
      count++;

    }else{
      result[i]+=count/2;
      result[i+1]+=ceil((double)count/2);
      count=0;

    }
  }
  for(int i=0;i<s.size()-1;i++){
    cout<<result[i]<<" ";
  }
  cout<<result.back()<<endl;

  return 0;
}


Measured memory_bytes: 1104
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int n,sum = 0;
    string s;
    cin >> n;
    s = to_string(n);
    for(int i = 0;i < s.size();i++)
    {
        sum += s[i] - '0';
    }
    if(n % sum == 0){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<math.h>
#include<iomanip>
#include<cstdio>
	using namespace std;
	int main()
	{
		int N, x, y,sum;
		cin >> N;
		sum = 800 * N;
		y = N / 15;
		sum -= 200*y;
		cout << sum;
	}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    string S;
    cin >> S;
    for (ll i = 0; i < 3; i++) {
        cout << S[i];
    }
    cout << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <string>
#include <stack>
// #include <numeric>
 
using namespace std;
 
#define f(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define vvi vector<vector<int> >
#define ss second
#define ff first
#define ll long long
#define lld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pq priority_queue< int >
#define pqll priority_queue< ll >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define INF 1000000000
#define NINF -1000000000
#define endl '\n'

void solve(){
    ll n;
    cin >> n;
    if (n%2){
        cout << 0 << endl;
    }
    else{
        ll temp1 = 10;
        ll count1 = 0;
        while((ll)n/(ll)temp1 != 0){
            count1 += (ll)n/(ll)temp1 ;
            temp1 *= 5;
        }
        cout << count1 << endl;
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);

    int t = 1;
    // cin >> t;
    
    while(t--){    
        solve();
    }
}

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

int main() {
  int n,x,sum = 0;
  cin >> n >> x;
  rep(i,n){
    int a;
    cin >> a;
    if(sum+a > x){
      cout << i+1 << endl;
      return 0;
    }
    sum += a;
  }
  cout << n+1 << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Word
import qualified Data.ByteString.Char8 as BS
import Data.Array.Unboxed
import Data.Array.ST

-- Input: s t
-- Output: arr
--   arr ! (i,j) == length of lcs of (drop i s, drop j t)
lcsTable2 :: BS.ByteString -> BS.ByteString -> UArray (Int,Int) Word16
lcsTable2 s t = runSTUArray $ do
  let !m = BS.length s
      !n = BS.length t
  arr <- newArray ((0,0),(m,n)) 0
  forM_ [m-1,m-2..0] $ \ !i -> do
    let !x = BS.index s i
    forM_ [n-1,n-2..0] $ \ !j -> do
      let !y = BS.index t j
      l <- if x == y
           then do l2 <- readArray arr (i+1, j+1)
                   return (l2 + 1)
           else do l0 <- readArray arr (i+1, j)
                   l1 <- readArray arr (i, j+1)
                   return (max l0 l1)
      writeArray arr (i,j) l
  return arr

main = do
  s <- BS.getLine
  t <- BS.getLine
  -- BS.length s <= 3000, BS.length t <= 3000, BS.all isAsciiLower s, BS.all isAsciiLower t
  let !table = lcsTable2 s t
      !m = BS.length s
      !n = BS.length t
  let recon !i !j | i >= m || j >= n = Nothing
                  | x == y = let !i' = i+1 ; !j' = j+1
                             in Just (x, (i', j'))
                  | table ! (i+1,j) >= table ! (i,j+1) = recon (i+1) j
                  | otherwise = recon i (j+1)
        where x = BS.index s i
              y = BS.index t j
      (result, _) = BS.unfoldrN (fromIntegral $ table ! (0,0)) (\(!i,!j) -> recon i j) (0,0)
  BS.putStrLn result


Measured memory_bytes: 19580
<?php
fscanf(STDIN, "%s %s", $s, $t);
fscanf(STDIN, "%d %d", $a, $b);
fscanf(STDIN, "%s", $u);
if($u === $s){
    $a = $a - 1;
}else{
    $b = $b -1;
}
echo $a.' '.$b;

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

int main() {
	
	int n;
	cin >> n;
	vector<int> a(n + 2);
	a[0] = a[n + 1] = 0;
	int sum = 0;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	for(int i = 1; i <= n + 1; i++){
		sum += abs(a[i] - a[i - 1]);
	}
	for(int i = 1; i <= n; i++){
		int ans = sum;
		ans -= abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]);
		ans += abs(a[i + 1] - a[i - 1]);
		cout << ans << endl;
	}
	
	return 0;
}

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

int N;
int x[10], y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> x[i] >> y[i];
    double sum = 0.0;
    vector<int> v(N);
    for(int i = 0; i < N; i++) v[i] = i + 1;
    do {
        for(int i = 0; i < N - 1; i++) sum += dist(v[i], v[i+1]);
    } while(next_permutation(v.begin(), v.end()));
    int Factorial = 1;
    for(int i = 2; i <= N; i++) Factorial *= i;
    cout << fixed << setprecision(10) << sum / Factorial << endl;
    return;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, p, m = INF, ctr = 0;
   cin >> n;
   FOR(i, 0, n)
   {
      cin >> p;
      if (p <= m)
         ctr++;
      m = min(m, p);
   }
   cout << ctr << endl;
   return 0;
}


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

const int N = 1e5 + 10;

int n, k, a[N], b[N];

int main() {
	scanf("%d%d", &n, &k);
	for(int i = 1 ; i <= n ; ++ i) {
		scanf("%d", &a[i]);
		if(a[i] == 0) {
			-- k;
			a[i] = 1e9;
		}
	}
	sort(a + 1, a + 1 + n);
	if(a[n] == int(1e9)) -- n;
	if(k == 0) {
		puts("0");
		return 0;
	}
	int ans = abs(a[1]) + a[n] - a[1];
	if(0 < a[1]) {
		ans = a[k];
	} else if(a[n] < 0) {
		ans = 0 - a[n - k + 1];
	}
	for(int i = 1 ; i <= n ; ++ i) {
		if(a[i] <= 0 && 0 <= a[i + 1]) {
			if(i - k + 1 >= 1) {
				ans = min(ans, 0 - a[i - k + 1]);
			}
			if(i + k <= n) {
				ans = min(ans, a[i + k]);
			}
			for(int j = 1 ; j <= k ; ++ j) {
				int l = i - (k - j) + 1, r = i + j;
				if(1 <= l && r <= n) {
					ans = min(ans, a[r] + (a[r] - a[l]));
				}
			}
			for(int j = 1 ; j <= k ; ++ j) {
				int l = i - j + 1, r = i + (k - j);
				if(1 <= l && r <= n) {
					ans = min(ans, 0 - a[l] + (a[r] - a[l]));
				}
			}
			break;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 640
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
#define ff first
#define ss second
#define deb(x) cout<<#x<<" "<<x<<"\n"
#define Clear(x) memset(x,0,sizeof(x))
#define all(x) (x).begin(),(x).end()

void checkpoint1()
{
	/******think more code less******/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

bool comp(pair< ll,ll > &a,pair< ll,ll > &b)
{
	if(a.ff!=b.ff)
		return a.ff<b.ff;
	else
	{
		if(a.ss>b.ss)
			return b.ss<a.ss;
		else if(a.ss<b.ss)
			return a.ss<b.ss;
	}
	return a.ff>b.ff;
}

ll powe(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b&1)
		{
			res*=a;
			res%=mod;
		}
		a*=a;
		a%=mod;
		b>>=1;
	}
	return res;
}

int main()
{
	checkpoint1();
	ll n;
	cin>>n;	
	ll dp[n+1];
	Clear(dp);
	dp[0]=1;
	for(ll i=3;i<=n;i++)
	{
		for(ll j=3;j<=i;j++)
		{
			if(i-j<0)
				break;
			dp[i]+=dp[i-j];
			dp[i]%=mod;
		}	
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
long long now=10;
int main()
{
	long long n,sum;
	long long ans=0;
	cin>>n;
	if(n%2==0)
	{
		for(now=10;now<=n;now*=5)
		{
			sum=n/now;
			ans+=sum;
		}
	}
	cout<<ans;
	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int length = s.size();
    int a = 0;
    int b = 0;
    for (int i = 0; i < length; i++)
    {
        char c = i % 2 == 0 ? '0' : '1';
        if (s[i] != c)
        {
            a++;
        }
    }
    for (int i = 0; i < length; i++)
    {
        char c = i % 2 != 0 ? '0' : '1';
        if (s[i] != c)
        {
            b++;
        }
    }
    cout << min(a, b) << "\n";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vll vector<long long int>
#define vi  vector<int>
#define vpi vector<pair<int,int>>
#define prec fixed<<setprecision(12)
#define set(x) __builtin_popcount(x)
#define ffs(x) __builtin_ffs(x)
#define clz(x) __builtin_clz(x)
#define inf 1000000007
#define linf 1000000000000000007
#define a(v) v.begin(),v.end()
void fast(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    cout.tie(NULL);
}


int main(){
	fast;
    int n;
    cin >> n;
    cout << prec << 2*(3.141)*n;
    
}


Measured memory_bytes: 3784
#include <vector>
#include <cstdio>

int main(){
    std::vector<long long> package;
    int n;
    int k;
    std::scanf("%d", &n);
    std::scanf("%d", &k);

    for(int i = 0; i < n; ++i){
        long long v;
        std::scanf("%lld", &v);
        package.push_back(v);
    }

    long long left = 0;
    long long right = 100000 * 10000;
    long long mid = 0;
    while(right - left > 1){
        mid = (left + right) / 2;
        int i = 0;
        for(int j = 0; j < k; ++j){
            long long s = 0;
            while(s + package[i] <= mid && i < n){
                s += package[i];
                ++i;
            }
            if(i == n) break;
        }
        if(i >= n) right = mid;
        else left = mid;
    }

    std::printf("%lld\n", right);
    return 0;
}



Measured memory_bytes: 3400
#include <stdio.h>
#include <string.h>
#define NUM 100

int main(void)
{
  int len;
  char s[NUM];

  scanf("%s",s);
  len = strlen(s);

  for(int i = 0;i < len;i++){
    printf("x");
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 128
fun main(args: Array<String>) = println(run {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val h = readLine()!!.split(" ").map { it.toInt() }
    val ab = (1..m).map { readLine()!!.split(" ").map { it.toInt() } }

    val g = Array(n) { mutableListOf<Int>() }
    ab.forEach {
        val (a,b) = it
        g[a-1].add(b-1)
        g[b-1].add(a-1)
    }

    g.mapIndexed { i, v ->
        v.all { h[i] > h[it] }
    }.count { it }

})

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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    int n;
    cin >> n;

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

    vector<LL> w(v);
    sort(w.begin(), w.end());
    
    LL median;
    if (n & 1) {
        median = w[n/2];
    }else{
        median = (w[n/2-1] + w[n/2]) / 2;
    }

    LL ans=0;
    for (int i = 0; i < n; i++) {
        ans += abs(v[i] - median);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328
using System.Text;
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            if (n == 0 && m == 0) break;
            var r = new string[n, 3];
            for (int i = 0; i < n; i++)
            {
                line = Console.ReadLine().Trim().Split(' ');
                for (int j = 0; j < 3; j++) r[i, j] = line[j];
            }
            getAns(r, n, m);
        }
    }
    static bool check(string r, string t)
    {
        for (int i = 0; i < 8; i++)
            if (r[i] != '?' && r[i] != t[i]) return false;
        return true;
    }
    static void getAns(string[,] r, int n, int m)
    {
        var count = 0;
        var sb = new StringBuilder();
        for (int i = 0; i < m; i++)
        {
            var s = Console.ReadLine().Trim();
            string[] line = s.Split(' ');
            var t1 = line[0];
            var t2 = line[1];
            var ok = false;
            for (int j = 0; j < n; j++)
                if (r[j, 0] == "permit")
                {
                    if (check(r[j, 1], t1) && check(r[j, 2], t2)) ok = true;
                }
                else
                {
                    if (check(r[j, 1], t1) && check(r[j, 2], t2)) ok = false;
                }
            if (ok) { count++; sb.Append(s + "\n"); }
        }
        Console.WriteLine(count);
        Console.Write(sb);
    }
}


Measured memory_bytes: 18228
//#include<bits/stdc++.h>	// 全てのヘッダーファイルをinclude
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<utility>	// wrap,pair
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR (i,n) for(int i=n;i>0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
const int MOD{ int(1e9 + 7) };	// int 1000000007
const int inf{ int(1e9) };	// inf = 1000000000 // 1e9 はdouble型
using namespace std;
typedef long long ll;

// 最大公約数（ユークリッドの互除法）
int GCD(int x, int y) {
	if (x > y) {
		swap(x, y);
	}
	int r = y % x;
	while (r != 0) {
		y = x;
		x = r;
		r = y % x;
	}
	return x;
}

// 最小公倍数
int LCM(int x, int y) {
	ll gcd = GCD(x, y);
	return x * y / gcd;
}

// 素数判定(素数ならtrue,合成数ならfalse)
bool IsPrime(int num) {
	if (num < 2) return false; // 0,1
	else if (num == 2) return true;	// 2
	else if (num % 2 == 0) return false; // 偶数

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false; // 割り切れたら素数ではない
	}
	return true; // 全部通ったら素数
}

// pairをsecond基準で昇順sort
// sort(vector_name.begin(),vector_name.end(),compare_by_b);
bool compare_by_b(pair<int, int>a, pair<int, int>b) {
	if (a.second != b.second) return a.second < b.second;
	else return a.first < b.first;
}

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

int main(void) {

	int n, q;
	string s;
	cin >> n >> q >> s;
	vector<int>l(n), r(n), a(n);
	REP(i, q) cin >> l[i] >> r[i];
	
	a[0] = 0;
	for (int i = 1; i < n; i++) {
		if (s[i - 1] == 'A' && s[i] == 'C') a[i] = a[i - 1] + 1;
		else a[i] = a[i - 1];
	}

	REP(i, q) {
		cout << a[r[i] - 1] - a[l[i] - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 2176