akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	int D, N;
	cin >> D >> N;

	int ans = 0;
	int counter = 0;
	for (int n = 1; n <= 1010000; n++)
	{
		int count = 0;
		int tmp = n;
		while (tmp%100 == 0) {
			tmp /= 100;
			count++;
		}

		if (count == D) {
			counter++;
		}

		if (counter == N) {
			ans = n;
			break;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)

using ll = long long;
using namespace std;

constexpr int INF = 2147483647; // 2 * 1e9
constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b) cout << c << "\n";
	else if(a == c) cout << b << "\n";
	else cout << a << "\n";
	return 0;
}


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

int main(void){
    
    int x, y;
    cin >> x >> y;
    if(y%2 == 0){
        int n;
        for(n = 0; n <= x; n++){
            if(y == 4*x -2*n){
                cout << "Yes" << endl;
                break;
            }
        }
        if(n > x) cout << "No" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

using namespace std;
template<typename T> void in(T &x) { x = 0; bool neg = false; register T c = getchar(); if (c == '-')neg = true, c = getchar(); while ((c < 48) || (c > 57))c = getchar(); for (; c < 48 || c > 57; c = getchar()); for (; c > 47 && c < 58; c = getchar())x = (x << 3) + (x << 1) + (c & 15); if (neg) x *= -1; }
template<typename T> void out(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); }
template<typename T> void outln(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); putchar('\n'); }
#define len(_x) (sizeof((_x)) / sizeof(_x)[0])
#define fastIO ios_base::sync_with_stdio(false); cin.tie(false);
#define ll long long
#define itr(_c) for(auto i=_c.begin();i!=_c.end();i++)
#define itrr(_c)for(auto i=_c.begin();i!=_c.end();i++)
#define f1(_x)for (int i = 0; i < _x; ++i)
#define fr(_x)for (int i = _x; i >0; i--)
#define f2(_x,_y)for (int i = _x; i < _y; ++i)
#define fileIO 	freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi; typedef vector<string> vs; typedef vector<bool> vb; vector<long long>vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;

template<typename T>
T gcd(T __m, T __n)
{
	while (__n != 0)
	{
		T __t = __m % __n;
		__m = __n;
		__n = __t;
	}
	return __m;
}
vi v,vv;
int main() {
	int n, a, b; cin >> n >> a >> b;
	std::cout << (n == 1 ? (a == b ? 1 : 0) : (a>b? 0:(ll)(n-2)*(b-a)+1 ));



	
	
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <cstring>

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using PP = pair<ll, pair<ll,ll>>;
#define rep(i,n) for (ll i = 0; i < (n); ++i)

ll n, sum, m = -10000000009;
//              01234567890
ll f[100][10], p[100][11];
ll o[10];
ll c[100];

int main() {
    cin >> n;
    rep(i,n) rep(j,10) cin >> f[i][j];
    rep(i,n) rep(j,11) cin >> p[i][j];

    for (ll i = 1; i < 1024; ++i){
        rep(j,10) o[j] = (i>>j)&1;

        rep(j,n) c[j] = 0;
        sum = 0;

        rep(j,10){
            rep(k,n){
                if (o[j] == 1 && f[k][j] == 1) c[k]++;
            }
        }

        rep(j,n){
            sum += p[j][c[j]];
        }

        if (m < sum) m = sum;
    }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main{
	
	static int MOD = 1000000007;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		if((2*x - y) % 3 != 0 &&(2 * y - x) % 3 != 0) {
			System.out.println(0);
			return ;
		}
		
		int l =( 2 * x - y)/3;
		int k =( 2 * y - x)/3;
		
		long []fac = new long [l + k + 1];
		long []finv = new long [l + k + 1];
		long []inv = new long [l + k + 1];
		
		    fac[0] = fac[1] = 1;
		    finv[0] = finv[1] = 1;
		    inv[1] = 1;
		    for (int i = 2; i <= l+ k; i++){
		        fac[i] = fac[i - 1] * i % MOD;
		        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		        finv[i] = finv[i - 1] * inv[i] % MOD;
		    }
		        
		    long ans = COM(l+k , k , fac , finv);
		    
		    
		    System.out.println(ans);
	}
  
	 static long COM(int n, int k , long []fac, long []finv){
	    if (n < k) return 0;
	    if (n < 0 || k < 0) return 0;
	    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}

}


Measured memory_bytes: 46548
N, M = gets.split(" ").map(&:to_i)
A = N.times.map{ gets[0...N].chars.map{|c| c == "#" ? 1 : 0} }
B = M.times.map{ gets[0...M].chars.map{|c| c == "#" ? 1 : 0} }

def f()
  g = lambda{|x, y|
    #p [x, y]
    (0...M).each{|by|
      (0...M).each{|bx|
        return false if A[y+by][x+bx] != B[by][bx]
      }
    }
    true
  }

  (0..N-M).each{|y|
    (0..N-M).each{|x|
      return true if g.(x, y)
    }
  }
  false
end

puts f() ? "Yes" : "No"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;

int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	for (int i=n; i>=0; i--)
	{
		bool flag = true;
		for (int j=0; j<i; j++)
			if (t[j] != s[n-i+j])
				flag = false;
		if (flag)
		{
			cout << 2 * n - i << "\n";
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 384
import Data.Functor
import Control.Applicative
import Control.Monad
import qualified Data.IntSet as IS
import Data.List
import qualified Data.ByteString.Char8 as C
import Data.Maybe

main = sol <$> (C.getLine *> get) >>= print

get = fmap fst . mapMaybe C.readInt . C.lines <$> C.getContents

sol = IS.size . foldl' lis IS.empty

lis s a = case IS.lookupGE a s of
    Just x
        | a < x         -> IS.insert a $ IS.delete x s
        | otherwise     -> s
    Nothing             -> IS.insert a s

Measured memory_bytes: 14292
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
int main(){
  //drkenの解答を参考に
  
  string s;
  cin>>s;
  ll n=s.length();
  ll ans=0;
  for(int bit=0;bit<((1<<n-1));bit++){
    ll tmp=0;
    for(int i=0;i<n-1;i++){
      tmp*=10;
      tmp+=s[i]-'0';
      if(bit & (1<<i))ans+=tmp,tmp=0;
    }
    tmp*=10;
    tmp+=s.back()-'0';
    ans+=tmp;
  }
  cout<<ans<<endl;
  
    
    
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
using namespace std;
const int N=1e6+10;
const int M=1e9+7;

int f[N];
string s;
int n;
int main(){Accel
	cin>>n;
	cin>>s;
	s=" "+s;
	int c=0;
	FOR(i,1,n){
		f[i]+=c;
		if(s[i]=='W')c++;
	}
	c=0;
	for(int i=n;i;i--){
		f[i]+=c;
		if(s[i]=='E')c++;
	}
	int t=f[1];
	FOR(i,2,n)
		t=min(t,f[i]);
	cout<<t<<endl;
	
}

Measured memory_bytes: 1900
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int r, d;
    vector<int> x(11);
    cin>>r>>d>>x[0];
    for(int i;i<10;i++){
        x[i+1]=r*x[i]-d;
        cout<<x[i+1]<<endl;
    }
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (a, b) = (v[0], v[1]);
    let ans;
    if a >= 13 {
        ans = b;
    } else if a <= 5 {
        ans = 0;
    } else {
        ans = b / 2;
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

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

		int n = sc.nextInt();
		int q = sc.nextInt();

		SqrtDecompositionRSQRUQ sq = new SqrtDecompositionRSQRUQ(n);
		for(int i = 0; i < q; i++){
			int type = sc.nextInt();

			if(type == 0){
				int s = sc.nextInt();
				int t = sc.nextInt();
				int x = sc.nextInt();

				sq.update(s, t + 1, x);
			}
			else {
				int s = sc.nextInt();
				int t = sc.nextInt();

				System.out.println(sq.getSum(s, t + 1));
			}

		}
	}

}

class SqrtDecompositionRSQRUQ {
	int N, K;
	long[] data;
	long[] bucketSum;
	long[] bucketLazyUpdate;
	static final int sqrtN = 512;
	static final int NIL = Integer.MIN_VALUE;

	public SqrtDecompositionRSQRUQ(int n) {
		N = n;
		K = (N + sqrtN - 1) / sqrtN;
		data = new long[K * sqrtN];
		bucketLazyUpdate = new long[K];
		Arrays.fill(bucketLazyUpdate, NIL);
		bucketSum = new long[K];
	}

	// [s, t)
	void update(int s, int t, int x) {
		for (int k = 0; k < K; ++k) {
			int l = k * sqrtN, r = (k + 1) * sqrtN;
			if (r <= s || t <= l)
				continue;
			if (s <= l && r <= t) {
				bucketLazyUpdate[k] = x;
				bucketSum[k] = x*sqrtN;
			} else {
				if(bucketLazyUpdate[k] != NIL){
					for(int i = l; i < r; i++){
						data[i] = bucketLazyUpdate[k];

					}
					bucketLazyUpdate[k] = NIL;
				}
				for (int i = Math.max(s, l); i < Math.min(t, r); ++i) {
					data[i] = x;
				}
				bucketSum[k] = 0;
				for(int i = l; i < r; i++){
					bucketSum[k] += data[i];
				}
			}
//			System.out.println("from "+l+" to "+r+ " bucketSum "+bucketSum[k] );
		}
	}

	//[s,t)
	long getSum(int s, int t) {
		long result = 0;
		for (int k = 0; k < K; ++k) {
			int l = k * sqrtN, r = (k + 1) * sqrtN;
			if (r <= s || t <= l)
				continue;
			if (s <= l && r <= t) {
				result += bucketSum[k];
//				System.out.println("bucket Add " + result);
			}
			else {
				for (int i = Math.max(s, l); i < Math.min(t, r); ++i) {
					if(bucketLazyUpdate[k] != NIL){
						result += bucketLazyUpdate[k];
					}
					else {
						result += data[i];
					}
				}
//				System.out.println("direct Add " + result);
			}
		}

		return result;
	}

	long get(int s) {
		int k = s / sqrtN;
		if(bucketLazyUpdate[k] != NIL){
			return bucketLazyUpdate[k];
		}
		else {
			return data[s];
		}
	}
}


Measured memory_bytes: 111764
#include<bits/stdc++.h>
#define E 0.000000001
using namespace std;
int main(){
  int n;
  double xa,ya,ra,xb,yb,rb;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>xa>>ya>>ra>>xb>>yb>>rb;
    double s=sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb)),r=ra+rb;
    if(s>r)cout<<"0"<<endl;
    else if(s+rb<ra) cout<<"2"<<endl;
    else if(s+ra<rb) cout<<"-2"<<endl;
    else cout<<"1"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>

using namespace std;


int main()
{
	string str,str2[200000],strmemo="";
	long long int n, m=0;
	cin >> n;
	if (n / 100 >= 1 && n / 100 <= 12 && n % 100 >= 1 && n % 100 <= 12) {
		cout << "AMBIGUOUS";
	}
	else if (n / 100 >= 1 && n / 100 <= 12) {
		cout << "MMYY";
	}
	else if (n % 100 >= 1 && n % 100 <= 12) {
		cout << "YYMM";
	}
	else {
		cout << "NA";
	}
	cout <<str ;
	
}


Measured memory_bytes: 1792
#include <iostream>

int main()
{
	int n;
	std::cin >> n;
	
	const char *s = nullptr;
	switch (n % 10) {
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		s = "hon";
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		s = "pon";
		break;
	case 3:
		s = "bon";
		break;
	}
	std::cout << s << std::endl;
	
	return 0;
}


Measured memory_bytes: 3044
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b){
        int tmp=a;
        a=b;
        b=tmp;
    }
    if(a>c){
        int tmp=a;
        a=c;
        c=tmp;
    }
    if(b>c){
        int tmp=b;
        b=c;
        c=tmp;
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N;
 cin >> N;
 int M = 3 * N;
 vector<long long> a(M);
 for(int i = 0; i < M ;i++){
   cin >> a.at(i);
 }
 sort(a.begin(),a.end());
 long long  sum = 0;
 for(int i = N; i < M; i+=2){
   sum+= a.at(i);
 }
 cout << sum <<endl;
}

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

int main() {

  int N;
  cin >> N;

  vector<pair<int,int>> p(N-1);
  vector<vector<int>> e(N,vector<int>(0));
  for(int i = 0;i < N-1;i++) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    p.at(i).first = a; p.at(i).second = b;
    e[a].push_back(b);
    e[b].push_back(a);
  }

  int K = 0;
  map<pair<int,int>,int> mp;
  vector<bool> check(N,false);
  vector<int> pn(N,0);
  queue<int> Q;
  Q.push(0);
  check[0] = true;
  while(!Q.empty()) {
    int q = Q.front(); Q.pop();
    if(K < e[q].size()) K = e[q].size();
    int num = 1;
    for(int v:e[q]) {
      if(check[v]) continue;
      if(pn[q] == num) num++;
      pn[v] = mp[make_pair(q,v)] = mp[make_pair(v,q)] = num++;
      check[v] = true;
      Q.push(v);
    }
  }

  cout << K << endl;
  for(int i = 0;i < N-1;i++) {
    int a = p.at(i).first,b = p.at(i).second;
    cout << mp[make_pair(a,b)] << endl;
  }



  
}


Measured memory_bytes: 19712
#include<stdio.h>
int main()
{
    int N, M, X, C=0, Cn=0;
    scanf("%d%d%d", &N, &M, &X);
    int A=0;
    for(int i=1; i<=M; i++){
            scanf("%d", &A);
            for(int j=1; j<=X; j++){
                    if(j-A==1){
                               Cn++;
                               }
                    }
            for(int k=N; k>X; k--){
                    if(k-A==1){
                               C++;
                               }
                    }
            }
    if(Cn<C){
             printf("%d\n", Cn);
             }
    else{
         printf("%d", C);
         }
    return 0;
}


Measured memory_bytes: 128
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename T> ll min(ll a, const T&& b) { return a < b ? a : b; }
template<typename T> ll min(const T&& a, ll b) { return a < b ? a : b; }
template<typename T> ll max(ll a, const T&& b) { return a > b ? a : b; }
template<typename T> ll max(const T&& a, ll b) { return a > b ? a : b; }
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

class Bit {
  ll n;
  vector<ll> v;
public:
  Bit(ll sz) : n((sz+1)*2), v((sz+1)*2, 0) {}
  // v[pos] += val
  void add(ll pos, ll val) {
    ++pos;
    while (pos < n) {
      v[pos] += val;
      pos += pos & -pos;
    }
  }
  // [l, r)
  ll find(ll l, ll r) {
    return find(r) - find(l);
  }
  // [0, pos)
  ll find(ll pos) {
    ll res = 0;
    while (pos >= 1) {
      res += v[pos];
      if (pos == 0) break;
      pos -= pos & -pos;
    }
    return res;
  }
};

void solve() {
  ll n, m; cin >> n >> m; ++m;
  map<ll, vector<P>> ev;
  rep(i, n) {
    ll l, r; cin >> l >> r; ++r;
    ev[r-l].eb(l, r);
  }
  ll sum = n;
  Bit bit(m);
  vector<ll> ans(m-1);
  rep(i, 1, m) {
    ll a = sum;
    for (ll j = 0; j < m; j += i) {
      a += bit.find(j+1);
    }
    ans[i-1] = a;
    each(p, ev[i]) {
      bit.add(p.first, 1);
      bit.add(p.second, -1);
      --sum;
    }
  }
  each(a, ans) cout << a << endl;
}


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

int main(){
  int N,M;
  int sum = 0;
  cin >> N;
  M = N;
  while(N > 0){
    sum += N % 10;
    N /= 10;
  }
  if(M % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())

if n % 2 == 0:
    nn = n
    print(n*(n-2)//2)
else:
    nn = n-1
    print(nn*(nn-2)//2+nn)



for i in range(1,nn//2):
    for j in range(i+1,nn//2 + 1):
        print(i,j)
        print(i,nn+1-j)
        print(nn+1-i,j)
        print(nn+1-i,nn+1-j)

if n % 2 == 1:
    for i in range(1,n):
        print(i,n)

Measured memory_bytes: 3620
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int c=sc.nextInt();
		char[] s=sc.next().toCharArray();
		St[] front=new St[n+2];
		St[] back=new St[n+2];
		back[0]=new St(0,-200000);
		int idx=0;
		for(int i=1; i<=n; i++){
			back[i]=back[i-1];
			if(idx<i && s[i-1]=='o'){
				back[i]=new St(back[i].sum+1,i);
				idx=i+c;
			}
		}
		if(back[n].sum<k){
			return;
		}
		front[n+1]=new St(0,400000);
		idx=n+1;
		for(int i=n; i>=1; i--){
			front[i]=front[i+1];
			if(idx>i && s[i-1]=='o'){
				front[i]=new St(front[i].sum+1,i);
				idx=i-c;
			}
		}
		for(int i=1; i<=n; i++){
			if(s[i-1]=='o'){
				int sum=front[i+1].sum+back[i-1].sum;
				if(front[i+1].recent-back[i-1].recent<=c){
					sum--;
				}
				if(sum<k){
					System.out.println(i);
				}
			}
		}
	}
	static class St{
		int sum,recent;
		St(int sum,int recent){
			this.sum=sum;
			this.recent=recent;
		}
	}
}


Measured memory_bytes: 64936
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N=int(input())
A=list(map(int,input().split()))

SUM=[0]*(N+1)
for i in range(N-1,-1,-1):
    SUM[i]=SUM[i+1]

    if (N-i)%2==1:
        SUM[i]+=A[i]

#print(SUM)

ADICT=dict()

def calc(i,select):
    if ADICT.get((i,select))!=None:
        return ADICT.get((i,select))
    rest=N-i

    if rest==0 or select==0:
        ADICT[(i,select)]=0
        return 0

    if rest%2==1 and rest//2+1==select:
        ADICT[(i,select)]=SUM[i]
        return SUM[i]
    
    elif rest%2==0 and rest//2==select:
        ADICT[(i,select)]=max(calc(i+1,select),A[i]+calc(i+2,select-1))
        return ADICT[(i,select)]

    elif rest%2==1 and rest//2==select:
        ADICT[(i,select)]=max(calc(i+1,select),A[i]+calc(i+2,select-1))
        return ADICT[(i,select)]

print(calc(0,N//2))

    


Measured memory_bytes: 156532
n = int(input())
h = list(map(int, input().split()))

dp = [1000000000] * n
dp[0] = 0

for i in range(1, n):
  dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
  if (i > 1):
    dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[n - 1])



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


Measured memory_bytes: 128
import sys
input = sys.stdin.readline

N,K = (int(x) for x in input().rstrip('\n').split())
vs = [int(x) for x in input().rstrip('\n').split()]
g = [vs[0],vs[-1]]
rest = K
for k in [K-1,K]:
  for b in range(K//2):
    t = k-b
    if t>N:
      t=N
    for i in range(t+1):
      v = []
      if i <t:
        v.extend(vs[:i])
        v.extend(vs[-(t-i):])
        for _ in range(b):
          if min(v)<0:
            v.remove(min(v))
          else:
            break
      else:
        v.extend(vs[:t])
        for _ in range(b):
          if min(v)<0:
          	v.remove(min(v))
      g.append(sum(v))
if max(g)<0:
  print(0)
else:
  print(max(g))

Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <sstream>
#include <complex>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using iii = pair<int, ii>;
using viii = vector<iii>;

using ll = long long int;
using vc = vector<char>;
using vb = vector<bool>;
using ib = pair<int, bool>;
using vib = vector<ib>;

#define MOD 1000 * 1000 * 1000 + 7
#define INF 1000 * 1000 * 1000
#define EMPTY -10
#define mp(a, b) make_pair(a,b)

bool resuelveCaso() {
	int n;
	cin >> n;
	if (!cin) return false;
	int k;
	cin >> k;

	ll sol;
	
	if (k % 2 == 0) {
		ll n1 = n / k;
		ll n2 = n1;
	if (n % k >= k / 2) ++n2;
		sol = n1 * n1 * n1 + n2*n2*n2; 
	}
	else {
		ll n1 = n / k;
		sol = n1 * n1 * n1;
	}

	cout << sol << '\n';

	return true;
}

int main() {
	while (resuelveCaso()) {}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k,tmp,cnt=0;
    cin >> n >> k;
    map<int,int> a;
    set<int> v;
    vector<int> tmpa;
    for(int i=0;i<n;i++){
        cin >> tmp;
        a[tmp]++;
        v.insert(tmp);
    }
    for(auto itr = a.begin();itr != a.end(); itr++)
        tmpa.push_back(itr->second);
    sort(tmpa.begin(),tmpa.end());
    k = (int)v.size()-k;
//    cout << k << endl;
    if(k<0){
        cout << 0 << endl;
        return 0;
    }
    for(int i=0;i<k;i++)
        cnt+=tmpa.at(i);
    cout << cnt << endl;
}


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] hwd = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int h = hwd[0];
			int w = hwd[1];
			int d = hwd[2];

			Point[] a = new Point[h * w];
			for (int i = 0; i < h; i++) {
				int[] aa = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				for (int j = 0; j < w; j++) {
					a[aa[j] - 1] = new Point { Y = i + 1, X = j + 1 };
				}

			}

			int[] p = new int[h * w];
			for (int i = 0; i < h * w; i++) {
				if (i / d == 0) {
					p[i] = 0;
				} else {
					var dst = a[i];
					var src = a[i - d];
					p[i] = Math.Abs(src.X - dst.X) + Math.Abs(src.Y - dst.Y)
						+ p[i - d];
				}
			}

			int q = int.Parse(Console.ReadLine());
			for (int i = 0; i < q; i++) {
				int[] lr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				Console.WriteLine(p[lr[1] - 1] - p[lr[0] - 1]); 
			}
		}
	}

	public struct Point
	{
		public int X;
		public int Y;
	}
}


Measured memory_bytes: 17076
#include<stdio.h>
int main()
{
    int x,a,b,t,n,c,i;
    scanf("%d",&x);
    if(x>=500)
    {
        a=x/500;
        x=x%500;
        b=a*1000;
        x=x/5;;
        c=x*5;
        t=c+b;
        printf("%d",t);
    }
    else
    {
        a=x/5;
        b=a*5;
        printf("%d\n",b);
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <cmath>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
#include <functional>
#include <stack>
#include <map>
#include <utility>
#define REP(i,n) for(int i=0;i<n;++i)
using namespace std;

int main() {
  int n;
  cin >> n;
  int a = n % 1000;
  if (a == 0) {
    cout << 0 << endl;
  } else {
    cout << 1000 - a << endl;
  }
}


Measured memory_bytes: 3608
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq
a,b=list(map(int,input().split()))
b_i=a
a_i=1
for i in range(b,0,-1):
    if i%2==1:
        print(b_i-i,b_i)
        b_i-=1

    else:
        print(a_i,a_i+i)
        a_i+=1



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

using lint = long long int;

int main() {
    lint N, A, B;
    cin >> N >> A >> B;

    lint M = N % (A + B);

    lint x = N / (A + B);
    lint y = min(A, M);
    cout << x * A + y << endl;
}

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

using namespace std;

vector<long long> burger_size;
vector<long long> patty;

long long solve(long long level, long long eaten){

    //printf("%lld %lld %lld %lld \n", level, eaten, burger_size[level], patty[level]);

    if(eaten == 0){
        return 0;
    }

    if(eaten == burger_size[level])
        return patty[level];

    if(eaten  < burger_size[level] / 2 + 1){

        return solve(level - 1, eaten - 1);

    } else if(eaten == burger_size[level] / 2 + 1){

        return 1 + patty[level - 1];

    } else if(eaten > burger_size[level] / 2 + 1){

        return 1 + patty[level - 1] + solve(level - 1, eaten - 2 - burger_size[level - 1]);

    }
}

int main(){
    long long n, x;
    scanf("%lld %lld", &n, &x);

    burger_size.push_back(1);

    for(int i = 1; i <= n; i++){
        burger_size.push_back(burger_size[i - 1] * 2ll + 3);
    }

    patty.push_back(1);

    for(int i = 1; i <= n; i++){
        patty.push_back(patty[i - 1] * 2ll + 1);
    }

    //printf("%lld", burger_size[n]);
    long long ans = solve(n, x);
    printf("%lld", ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
#include<list>
#include <stdio.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0;i < (n); ++i)
#pragma GCC optimize("Ofast")



int main() {
	vector<vector<int>>a(3, vector<int>(3));
	rep(i, 3) {
		rep(j, 3)cin >> a[i][j];
	}
	int n;
	cin >> n;
	vector<int>b(n);
	rep(i, n)cin >> b[i];
	vector<vector<bool>>chack(3, vector<bool>(3,false));
	rep(i, n) {
		rep(j, 3) {
			rep(k, 3) {
				if (b[i] == a[j][k]) {
					chack[j][k] = true;
				}
			}
		}
	}
	rep(i, 3) {
		if (chack[i][0] ==true && chack[i][1] ==true&& chack[i][2] == true) {
			cout << "Yes" << endl;
			return 0;
		}
		if (chack[0][i] ==true&& chack[1][i] ==true&& chack[2][i] == true) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	if (chack[0][0] ==true&& chack[1][1] ==true&& chack[2][2]==true) {
		cout << "Yes" << endl;
		return 0;
	}
	if (chack[0][2] ==true&& chack[1][1] ==true&& chack[2][0] == true) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3648
n = int(input())
nums = [int(i) for i in input().split(" ")]

count = 0

def merge(nums, left, mid, right):
    i = 0
    j = 0
    nums_l = nums[left:mid]
    nums_r = nums[mid:right]
    nums_l.append(10 ** 9 + 1)
    nums_r.append(10 ** 9 + 1)
    for x in range(0, right - left):
        global count
        count = count + 1
        if nums_l[i] <= nums_r[j]:
            nums[left + x] = nums_l[i]
            i = i + 1
        else:
            nums[left + x] = nums_r[j]
            j = j + 1

def merge_sort(nums, left, right):
    if left + 1 < right:
        mid = int((left + right) / 2)
        merge_sort(nums, left, mid)
        merge_sort(nums, mid, right)
        merge(nums, left, mid, right)

merge_sort(nums, 0, n)
result = ""
for i in nums:
    result += str(i) + " "
print(result.rstrip())
print(count)


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

#define o(output) cout << output << endl

using namespace std;

string s,t,u;
int a,b,c,d;
char A,B;
priority_queue<int,vector<int>,greater<int> >small;
int l[14]={0,13,1,2,3,4,5,6,7,8,9,10,11,12};

int main(){
  cin>>a>>b;
  if(l[a]>l[b])o("Alice");
  else if(l[a]==l[b])o("Draw");
  else o("Bob");
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        if(t<0 || 86400<t){
            System.exit(-1);
        }
        System.out.println(t/3600+":"+(t%3600)/60+":"+(t%3600)%60);
    }
}

Measured memory_bytes: 26324
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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 (b<a) { a=b; return 1; } return 0; }
 
ll MOD = 1000000007;
ll INF =1<<30;



int main(){
   ll a,v;
   cin >> a>>v;
   ll b,w,t;
   cin >> b>>w;
   cin >>t;
   if(a<=b){ 
       if(a+v*t>=b+w*t){
       cout <<"YES" <<endl;
       return 0;}}
   else if(b<a){
       if(a-v*t<=b-w*t) {cout << "YES" <<endl;return 0;}
   }
   cout << "NO" <<endl;
}

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

int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  int ans=0;
  for (int i=0; i<N; i++) {
    int minj=i;
    for (int j=i; j<N; j++) {
      if (A[j]<A[minj]) {
        minj=j;
      }
    }
    int v=A[i];
    A[i]=A[minj];
    A[minj]=v;
    if (i!=minj) {
      ans++;
    }
  }
  for (int i=0; i<N; i++) {
    cout << (i==0?"":" ") << A[i] << flush;
  }
  printf("\n");
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 3220
#include<iostream>

using namespace std;

int main() {
	char c;

	//入力
	cin >> c;

	//母音か判定
	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> v[10];
vector<int> p;
int main()
{
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            int x;
            cin >> x;
            v[i].push_back(x - 1);
        }
    }
    for (int i = 0; i < m; i++)
    {
        int x;
        cin >> x;
        p.push_back(x);
    }
    int ans = 0;
    for (int i = 0; i < (1 << n); i++)
    {
        int f = 1;
        for (int j = 0; j < m; j++)
        {
            int cnt = 0;
            for (int k = 0; k < v[j].size(); k++)
            {
                if (int(i & (1 << v[j][k])) != 0)
                    cnt++;
            }
            if (cnt % 2 != p[j])
            {
                f = 0;
            }
        }
        ans += f;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define FTEST int testcase;fin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define plii pair<ll,pii>
#define no {cout<<"no"<<endl;return;}
#define yes {cout<<"yes"<<endl;}
#define rep(i,N) for(int i=0;i<N;i++)
const int maxn=1e6;
const int mod=998244353;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void solve(){

    int n;cin>>n;
    int arr[n],brr[n];
    bool ok=false;
    for(int i=0;i<n;i++) cin>>arr[i]>>brr[i];
    for(int i=0;i+2<n;i++){
        if(arr[i]==brr[i] && arr[i+1]==brr[i+1] && arr[i+2]==brr[i+2]) ok=true;
    }
    if(ok) cout<<"Yes";
    else cout<<"No";
    return;
}

int main(){
    IO
    solve();

    return(0);
}



Measured memory_bytes: 3640
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

const ll MOD = 1000000007;
//const ll MOD = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        return mint(*this) /= a;
    }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int n;
    cin >> n;

    if(n < 2) {
        print(0);
        return 0;
    }

    print(mint(10).pow(n) - mint(9).pow(n) * 2 + mint(8).pow(n));
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	string s;
	int K;
	cin >> s >> K;

	set<string> ss;
	for(int i = 0; i < s.size(); i++){
		for(int j = 1; j <= 5 && j + i <= s.size(); j++){
			string t = s.substr(i, j);
			ss.insert(t);
			if(ss.size() > K){
				auto it = ss.end();
				--it;
				ss.erase(it);
			}
		}
	}
	auto it = ss.end();
	--it;
	cout << *it << endl;
}


Measured memory_bytes: 256
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(s[int(input())-1])

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

int main() {
  string S;
  cin>>S;
  long long N=S.size()+1;
  vector<long long>A(N);
  for(long long i=0;i<N;i++) A[i]=0;
  if(N==2) cout<<1<<endl;
  else{
  if(S[0]=='<'){
    long long nogi;
    long long con=1;
    for(long long i=0;i<N-1;i+=nogi){
      nogi=1;
      if(i==N-2){
        if(S[i]=='<'){
          A[i]=1;
        }
      }
      else{
      for(int j=i+1;j<N-1;j++){
        if(S[i]==S[j]){
          nogi++;
          if(j==N-2){
            nogi*=con;
            con*=-1;
            A[i]=nogi;
            nogi=abs(nogi);
            break;
          }
        }
        else{
          nogi*=con;
          con*=-1;
          A[i]=nogi;
          nogi=abs(nogi);
          break;
        }
      }
      }
    }
    long long renka;
    long long ans=0;
   for(long long k=0;k<N;k++){
     if(A[k]>0){
       ans+=A[k]*(A[k]+1)/2;
       renka=A[k];
     }
     else if(A[k]<0){
       long long n=abs(A[k]);
       ans+=n*(n-1)/2;
       if(n-renka>0) ans+=n-renka;
     }
   }
   cout<<ans<<endl;
  }
  else{
    long long nogi;
    long long con=-1;
    for(int i=0;i<N-1;i+=nogi){
      nogi=1;
      if(i==N-2){
        if(S[i]=='<'){
          A[i]=1;
        }
      }
      else{
      for(long long j=i+1;j<N-1;j++){
        if(S[i]==S[j]){
          nogi++;
          if(j==N-2){
            nogi*=con;
            con*=-1;
            A[i]=nogi;
            nogi=abs(nogi);
            break;
          }
        }
        else{
          nogi*=con;
          con*=-1;
          A[i]=nogi;
          nogi=abs(nogi);
          break;
        }
      }
      }
    }
    long long renka;
    long long ans=0;
    long long nibu=abs(A[0]);
    ans+=nibu*(nibu+1)/2;
   for(long long k=1;k<N;k++){
     if(A[k]>0){
       ans+=A[k]*(A[k]+1)/2;
       renka=A[k];
     }
     else if(A[k]<0){
       long long n=abs(A[k]);
       ans+=n*(n-1)/2;
       if(n-renka>0) ans+=n-renka;
     }
   }
   cout<<ans<<endl;
  }
  }
}


Measured memory_bytes: 4740
#include <iostream>

using namespace std;

int n, a; char c;

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

	while (true)
	{
		cin >> c;

		if (c == '=') { break; }

		cin >> a;

		switch (c)
		{
			case '+': n += a; break;
			case '-': n -= a; break;
			case '*': n *= a; break;
			case '/': n /= a; break;
		}
	}

	cout << n << endl;

	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <random>
#include <ctime>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pll pair<ll,ll>
#define ld double
#define pld pair<ld,ld>
#define pii pair<int,int>
#define sqr(a) ((a)*(a))
#define all(v) v.begin(),v.end()

using namespace std;
//using namespace __gnu_pbds;

ll MOD = 998244353;
const ll INF = 1e18;
const ld E = 1e-18;
const ld PI=acos(-1);
mt19937_64 rnd(time(0));
ll p1 = 31, p2 = 37, p3 = 7, p4 = rnd() % 100 + 1, md1 = MOD, md2 = 998244353, md3 = 998244357, md4 = rnd() % 1000000000;

//using ord_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

ll n, m, k;


ll binpow(ll h, ll r, ll md = MOD)
{
    ll l = 1;
    while (r)
    {
        if (r & 1) l *= h, l%=md;
        h *= h;
        h %= md;
        r /= 2;
    }
    return l;
}

ll gcd(ll x, ll y)
{
    if (x < y) swap(x, y);
    while (x && y)
    {
        x %= y;
        swap(x, y);
    }
    return x + y;
}

void solve()
{
    cin >> n >> m;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen("capitals.in","r",stdin);
    //freopen("capitals.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    cout << (n>=30?"Yes\n":"No\n");
    return 0;
}

/*
a-b=k
a+b=m
a=(m+k)/2;
b=(m-k)/2;
*/


Measured memory_bytes: 3608
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  vll ipai(n);
  vll jmaj(n);
  map<ll, ll> jmajmp;
  rep(i, n) {
    ll a;
    cin >> a;
    ipai[i] = i + a;
    jmaj[i] = i - a;
    jmajmp[jmaj[i]]++;
  }
  ll ans = 0;
  rep(i, n) {
    jmajmp[jmaj[i]]--;
    ans += jmajmp[ipai[i]];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 29036
import java.util.*;
public class Main{
    
    static final int MOD = (int)1e9+7;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        UnionFind uf = new UnionFind(n);
        
        ArrayList<Integer>[] g = new ArrayList[n];
        for(int i=0; i<n; i++){
            g[i] = new ArrayList<>();
        }
        for(int i=0; i<m; i++){
            int a = Integer.parseInt(sc.next())-1;
            int b = Integer.parseInt(sc.next())-1;
            g[a].add(b);
            g[b].add(a);
            uf.unite(a, b);
        }
        
        int max = 0;
        for(int i=0; i<n; i++){
            max = Math.max(max, uf.size(i));
        }
        
        System.out.println(max);
    }
}

class UnionFind{
    int n;
    int[] par;
    int[] size;
    
    public UnionFind(int n){
        this.n = n;
        par = new int[n];
        for(int i=0; i<n; i++){
            par[i] = i;
        }
        size = new int[n];
        Arrays.fill(size, 1);
    }
    
    public int find(int x){
        if(par[x] == x){
            return x;
        }else{
            par[x] = find(par[x]);
            return par[x];
        }
    }
    
    public boolean unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x==y) return false;
        
        if(size[x]<size[y]){
            int tmp = x;
            x = y;
            y = tmp;
        }
        size[x] += size[y];
        par[y] = x;
        return true;
    }
    
    public boolean same(int x, int y){
        return find(x)==find(y);
    }
    
    public int size(int x){
        return size[find(x)];
    }
    
    public int groupCount(){
        Set<Integer> s = new HashSet<>();
        for(int i=0; i<n; i++){
            s.add(this.find(i));
        }
        return s.size();
    }
}



Measured memory_bytes: 85068
#include <bits/stdc++.h>
using namespace std;
#define ALL(c) (c).begin(),(c).end()

void solve(long long N, long long x, vector<long long> a){
	sort(ALL(a));
	int res = 0;
	for(int i = 0; i < N; ++i) {
		if(a[i] <= x) {
			++res;
			x -= a[i];
		}
	}
	if(x != 0 && res == N) {
		res = max(0, res - 1);
	}
	cout << res << endl;
}

int main(){	
	long long x;
	long long N;
	scanf("%lld",&N);
	vector<long long> a(N-1+1);
	scanf("%lld",&x);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, x, a);
	return 0;
}



Measured memory_bytes: 256
let bin_search x (a : int array) n =
  let rec doit l r =
    if l >= r then false
    else
      let m = (l + r) / 2 in
      if x = a.(m) then true
      else if x < a.(m) then doit l m
      else doit (m + 1) r in
  doit 0 n

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let read_seq () = read_line () |> split_on_char ' ' |> List.map int_of_string in
  let n = read_int () in
  let s = read_seq () |> Array.of_list in
  let _ = read_int () in
  let t = read_seq () in
  List.fold_left (fun acc e -> acc + (if bin_search e s n then 1 else 0)) 0 t
  |> Printf.printf "%d\n"

Measured memory_bytes: 17000
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

int main()
{
    ll a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a <= k)
    {
        cout << "Yay!";
    }
    else
    {
        cout << ":(";
    }
}


Measured memory_bytes: 256