akhauriyash/Code-Regression huggingface dataset:
# 最短経路問題で使われるアルゴリズムの１つ。
# グラフ上の全ての頂点間の最短経路を探す
# 負の閉路（辺の重みの和が負になるような閉路）がない限り、負の辺があっても使える。

# 負の閉路を持つ場合は'NEGATIVE CYCLE'を、そうでない場合には(i,j)成分に
# 頂点iから頂点jへの最短経路の距離を格納するdist_listをprintする関数
def warshall_floyd(v_num, dist_lst):

    # 負の閉路を持つか
    negative_cycle_flag = False

    # 頂点iから頂点jへの経路と、頂点kを経由した場合の経路とを比較して
    # よりコストの合計が小さい方を配列に入れる動的計画法
    for k in range(v_num):
        for i in range(v_num):
            for j in range(v_num):
                # i→k→jがつながっててしかもi→jルートよりもイケてるなら更新
                if dist_lst[i][k] != INF and dist_lst[k][j] != INF:
                    if dist_lst[i][j] > dist_lst[i][k] + dist_lst[k][j]:
                        dist_lst[i][j] = dist_lst[i][k] + dist_lst[k][j]

    for v in range(v_num):
        # dist_lstに負の数が格納されているとは、
        # グラフが負の閉路を持つことを意味する
        if dist_lst[v][v] < 0:
            negative_cycle_flag = True

    if negative_cycle_flag:
        print("NEGATIVE CYCLE")
    else:
        for lst in dist_lst:
            put = ""
            for i in lst:
                if i == INF:
                    put += "INF" + " "
                else:
                    put += str(i) + " "
            print(put.rstrip())

# 頂点の数と辺の数
v_num, e_num = map(int, input().split())

# 配列dist_lst[a][b]には頂点a,b間の辺のコストを入れておき、
# a=bの時は0を、a,b間の辺が存在しないときはINFを入れておく。
INF = 10 ** 20
dist_lst = [[INF] * v_num for _ in range(v_num)]

for _ in range(e_num):
    s, t, dist = map(int, input().split())
    dist_lst[s][t] = dist

for v in range(v_num):
    dist_lst[v][v] = 0

warshall_floyd(v_num, dist_lst)



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

// x^y % m
ll mpow(ll x, ll y, ll m = 998244353) {
  ll ret = 1;
  while (y != 0) {
    if (y & 1) ret = (ret * x) % m;
    x = (x * x) % m;
    y = y >> 1;
  }
  return ret;
};

ll minv(ll a, ll m = 998244353) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

int main() {
  const ll MOD = 998244353;
  ll n, m, k;
  cin >> n >> m >> k;
  if (m == 1) {
    cout << ((k == n - 1) ? 1 : 0) << endl;
    return 0;
  }

  ll ans = 0;
  ll fi = (m * mpow(m - 1, n - 1)) % MOD;
  ans = (ans + fi) % MOD;
  rep2(i, 1, k + 1) {
    fi = (fi * (n - i)) % MOD;
    fi = (fi * minv(i)) % MOD;
    fi = (fi * minv(m - 1)) % MOD;
    ans = (ans + fi) % MOD;
  }

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

Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


int main(void) {
    
    int x = 0;
    scanf("%d", &x);
    
    if (x >= 400 && x <= 599) {
        printf("8\n");
    } else if (x >= 600 && x <= 799) {
        printf("7\n");
    } else if (x >= 800 && x <= 999) {
        printf("6\n");
    } else if (x >= 1000 && x <= 1199) {
        printf("5\n");
    } else if (x >= 1200 && x <= 1399) {
        printf("4\n");
    } else if (x >= 1400 && x <= 1599) {
        printf("3\n");
    } else if (x >= 1600 && x <= 1799) {
        printf("2\n");
    } else if (x >= 1800 && x <= 1999) {
        printf("1\n");
    }
}

Measured memory_bytes: 1648
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#pragma comment(linker, "/STACK:16000000")
using namespace std;

typedef pair <int, int> ii;

const int Maxn = 200005;

int n, k, l;
vector <int> neigh1[Maxn], neigh2[Maxn];
int cur1, col1[Maxn];
int cur2, col2[Maxn];
map <ii, int> M;

void Fill(int v, vector <int> neigh[], int col[], int c)
{
	col[v] = c;
	for (int i = 0; i < neigh[v].size(); i++) {
		int u = neigh[v][i];
		if (!col[u]) Fill(u, neigh, col, c);
	}
}

int main()
{
	scanf("%d %d %d", &n, &k, &l);
	for (int i = 0; i < k; i++) {
		int a, b; scanf("%d %d", &a, &b);
		neigh1[b].push_back(a); neigh1[a].push_back(b);
	}
	for (int i = 0; i < l; i++) {
		int a, b; scanf("%d %d", &a, &b);
		neigh2[b].push_back(a); neigh2[a].push_back(b);
	}
	for (int i = 1; i <= n; i++) if (!col1[i])
		Fill(i, neigh1, col1, ++cur1);
	for (int i = 1; i <= n; i++) if (!col2[i])
		Fill(i, neigh2, col2, ++cur2);
	for (int i = 1; i <= n; i++)
		M[ii(col1[i], col2[i])]++;
	for (int i = 1; i <= n; i++)
		printf("%d%c", M[ii(col1[i], col2[i])], i + 1 <= n? ' ': '\n');
	return 0;
}

Measured memory_bytes: 27904
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 3000 + 5;
const ll INF = (ll) 1e18;
ll memo[MAX][MAX][4];
int grid[MAX][MAX];
int n, m, k;

ll roll(int x, int y, int g) {
    if ((x == (n + 1) and y == m) or (x == n and y == (m + 1))) {
        return 0;
    }

    if (x > n or y > m) {
        return -INF;
    }

    ll &ans = memo[x][y][g];
    if (~ans) {
        return ans;
    }

    ans = max(roll(x + 1, y, 0), roll(x, y + 1, g));

    if (grid[x][y] > 0 && g < 3) {
        ans = max({ans, roll(x + 1, y, 0) + grid[x][y], roll(x, y + 1, g + 1) + grid[x][y]});
    }
    
    return ans;
}

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

    fori (i, 0, k) {
        int r, c, v;
        cin >> r >> c >> v;
        grid[r][c] = v;
    }

    memset(memo, -1, sizeof memo);
    cout << roll(1, 1, 0) << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}



Measured memory_bytes: 321520
#include <iostream>

using namespace std;

int main()
{
	int r, c;
	
	while( cin >> r >> c, (r || c))
	{
		if( r*c % 2 == 0 )
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
//#define MYDEBUG
#include <bits/stdc++.h>

#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(v,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
using std::vector;
using std::cout;
using std::cin;
using std::endl;
using std::max;
using std::min;
using std::swap;
using std::string;
using std::fill;
using std::pair;
using std::sort;
using std::reverse;
using std::pair;
using std::greater;
using std::priority_queue;

template<typename T>
std::ostream& operator<<(std::ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}

const int maxn = 110;
int a[maxn], cnt[10];
int n;

void solve() {
  cin >> n;
  rep(i,0,n)
  {
    int ai;
    cin >> ai;
    if (1 <= ai && ai <= 399) {
      a[i] = 0;
    } else if (400 <= ai && ai <= 799) {
      a[i] = 1;
    } else if (800 <= ai && ai <= 1199) {
      a[i] = 2;
    } else if (1200 <= ai && ai <= 1599) {
      a[i] = 3;
    } else if (1600 <= ai && ai <= 1999) {
      a[i] = 4;
    } else if (2000 <= ai && ai <= 2399) {
      a[i] = 5;
    } else if (2400 <= ai && ai <= 2799) {
      a[i] = 6;
    } else if (2800 <= ai && ai <= 3199) {
      a[i] = 7;
    } else {
      a[i] = 8;
    }
    cnt[a[i]]++;
  }
  int mini = 0, maxi;
  REP(i,0,7)
  {
    if (cnt[i] != 0) {
      mini++;
    }
  }
  if (mini == 0) {
    mini = 1;
    maxi = cnt[8];
  } else {
    maxi = mini + cnt[8];
  }
  cout << mini << " " << maxi;
}

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


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;


public class Main {

    static int mod = (int) 1e9 + 7;
    public static final long pow(long x, long n) {
        long sum = 1;
        while (n > 0) {
            if ((n & 1) == 1) {  //ビットが立っていたら
                sum *= x;        //x^2^k1 * x^2^k2 * x^2^k3 * ・・・
            }
            x *= x;              //((x^2)^2)^2・・・
            n >>= 1;
        }
        return sum;
    }

    public static final long modPow(long a,long n,long p) {
        if (n == 1) return a % p;
        if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
        long t = modPow(a, n / 2, p);
        return (t * t) % p;
    }

    static long fermatComb(long a, long b) {
        if (b > a - b)
            return fermatComb(a, a - b);
        long mul = 1; //分子
        long div = 1; //分母
        for (int i = 0; i < b; i++) {
            mul *= (a - i);
            mul %= mod;
            div *= (i + 1);
            div %= mod;
        }
        long ans = mul * modpow(div, mod - 2) % mod; //フェルマーの小定理を利用して掛け算で計算
        return ans;
    }

    //mod条件下の高速pow
    static long modpow(long a, long p) {
        if (p == 0)
            return 1;
        if (p % 2 == 0) {
            long root = modpow(a, p / 2);
            return root * root % mod;
        } else
            return a * modpow(a, p - 1) % mod;
    }

    static long calc(long a, long b, long p) {
        if (b == 0) {
            return 1;
        } else if (b % 2 == 0) {
            long d = calc(a, b / 2, p);
            return (d * d) % p;
        } else {
            return (a * calc(a, b - 1, p)) % p;
        }
    }

    static int N;
    static List<String> list = new ArrayList<String>();
    static void solve(char c,int n,String temp){
        temp+=c;
        if(n==N){
            System.out.println(temp);
        }else{
            char max ='a';
            char[] tmp = temp.toCharArray();
            for(int i=0;i<tmp.length;i++){
                if(tmp[i]>max){
                    max = tmp[i];
                }
            }
            max = (char)((int)max+1);
            for(char i='a';i<=max;i++){
                solve(i,n+1,temp);
            }



        }

    }

    public static void main(String[] args) {
	// write your code here
        Scanner sc= new Scanner(System.in);
        N=sc.nextInt();
        solve('a',1,"");

    }
}


Measured memory_bytes: 43832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    int n;cin>>n;
    ll tary[n];
    ll aary[n];
    rep(i,n) cin>>tary[i];
    rep(i,n) cin>> aary[i];

    ll kakutei[n];
    rep(i,n) kakutei[i]=0;
    kakutei[0]=tary[0];
    kakutei[n-1]=aary[n-1];
    ll l_min_ary[n];
    rep(i,n) l_min_ary[i] = INF;
    ll r_min_ary[n];
    rep(i,n) r_min_ary[i] = INF;

    rep(i,n)
    {
        if (i==0)
        {
            l_min_ary[0] = tary[i];
            continue;
        }
        
        if (l_min_ary[i-1]!=tary[i])
        {
            kakutei[i] = tary[i];
            l_min_ary[i] = tary[i];
        }
        else
        {
            l_min_ary[i] = tary[i];

        }
    }
    // rREP(i, n-1, 0)
    for (int i=n-1;i>=0;i--)
    {
        if (i==n-1)
        {
            r_min_ary[n-1] = aary[n-1];
            continue;
        }

        if (r_min_ary[i+1] != aary[i])
        {
            kakutei[i] = aary[i];
            r_min_ary[i] = aary[i];
        }
        else
        {
            r_min_ary[i] = r_min_ary[i+1];
            /* code */
        }
        
    }

    ll ans = 1;
    bool flag = true;
    rep(i,n)
    {
        if (kakutei[i]!=0)
        {
            if (r_min_ary[i]>= kakutei[i] && l_min_ary[i] >= kakutei[i])
            {
                continue;
            }
            else
            {
                flag = false;
                break;
            }
            
        }
        else
        {
            ans *= min(l_min_ary[i], r_min_ary[i]);
            ans %= MOD;
        }
    }
    if (n==1 && tary[0]!=aary[0])
    {
        cout << 0 << endl;
    }
    else if (flag)
    {
        cout << ans << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    
}


Measured memory_bytes: 4224
fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(" ").map { it.toInt() }
    var l = Array<Int>(y, {it * 0}).toMutableList()
    for(i in 0 until x){
        val ll = readLine()!!.split(" ").map { it.toInt() }
        for(j in 1 .. ll[0]){
            l[ll[j] - 1] += 1
        }
    }
    println(l.filter{it == x}.count())
}

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

int main() {  
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N - 1);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    for (int i = 0; i < N - 1; i++) cin >> C[i];

    int ans = B[A[0] - 1];
    int tmp = A[0];
    for (int i = 1; i < N; i++) {
        if (A[i] == tmp + 1) ans += B[A[i] - 1] + C[A[i] - 2];
        else ans += B[A[i] - 1];
        tmp = A[i];
    }
    cout << ans << endl;
}

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


int main() {
    ll N;
    ll ans = INFINITY;
    ll total = 0;
    cin >> N;
    vector<ll> A(N);
    ll sum = 0;
    rep(i,N) cin >> A.at(i);
    rep(i,N) total += A.at(i);
    rep(i,N-1) {
        sum += A.at(i);
        ans = min(ans, abs(total - 2 * sum));
    }
    cout << ans << endl;
}


Measured memory_bytes: 4824
d, n = map(int, input().split())

flag = True
tmp = 0
count = 0

while(flag):
    count += 1
    if((100 ** d * count) % (100 ** (d+1)) != 0):
        tmp += 1
        if(tmp == n):
            print(100 ** d * count)
            exit()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

int n,k,l,r,m;
int a[200000];

ll count(int cur, int goal)
{
    if (cur<=goal)
        return 0;
    if (cur%goal)
        return (cur/goal);
    return (cur/goal)-1;
}

bool check(int x)
{
    ll ans=0;
    for (int i=0;i<n;++i)
        ans+=count(a[i],x);
    if (ans<=k)
        return 1;
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k;
    for (int i=0;i<n;++i)
        cin>>a[i];
    l=1;r=1e9;
    while (l<r)
    {
        m=l+(r-l)/2;
        if (check(m))
            r=m;
        else
            l=m+1;
    }
    cout<<l;
    return 0;
}

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

using Int = long long;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	Int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<Int> p(a), q(b);
	priority_queue<Int> r;
	RC(i, a) cin >> p[i];
	RC(i, b) cin >> q[i];
	RC(i, c){
		Int rt;
		cin >> rt;
		r.push(rt);
	}
	sort(p.begin(), p.end(), greater<Int>());
	sort(q.begin(), q.end(), greater<Int>());

	priority_queue<Int, vector<Int>, greater<Int>> queue;
	Int ans = 0;
	RC(i, x){
		ans += p[i];
		queue.push(p[i]);
	}
	RC(i, y){
		ans += q[i];
		queue.push(q[i]);
	}

	while(!r.empty() && queue.top() < r.top()){
		ans += r.top();
		ans -= queue.top();
		queue.pop();
		r.pop();
	}

	cout << ans << endl;
}


Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
int main(){
	set<int> ans;
	int n;
	cin>>n;
	vector<int> mv;
	for(int i=0;i<n;i++){
		int t;
		cin>>t;
		mv.push_back(t);
	}
	for(int i=0;i<(int)mv.size()-2;i++){
		vector<int> tmp;
		tmp.push_back(mv[i]);
		tmp.push_back(mv[i+1]);
		tmp.push_back(mv[i+2]);
		sort(tmp.begin(),tmp.end(),less<int>());
		int fin=tmp[1];
		if(tmp[1]==mv[i+1])
		ans.insert(fin);
	}
	cout<<ans.size()<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int N,A,i;
    cin>>N;
    vector<int>v(N+1);
    for(i=1;i<=N;i++)
    {
        cin>>A;
        v[A]=i;
    }
    for(i=1;i<=N;i++)
    {
        cout<<v[i]<<" ";
    }
    return 0;
}


Measured memory_bytes: 1152
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n-2):
    mn=min(p[i:i+3])
    mx=max(p[i:i+3])
    if mn!=p[i+1] and mx!=p[i+1]:
        cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<cctype>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

#define ll long long
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define MD 1000000007

char sep[3] = " \n";
int i, j, k, l, m, n;
double PI = acos(-1);


int main() {
  double x1, y1, x2, y2, dx, dy;
  cin >> x1 >> y1 >> x2 >> y2;
  dx = x2 - x1, dy = y2 - y1;
  printf("%.5f\n", sqrt(dx*dx+dy*dy));

  return 0;
}
  

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(int &a,int b){
	a = min(a,b);
}
int main(){
	string s,t;
	cin >> s >> t;
	cout << t+s << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import deque

N, U, V = map(int, input().split())
U, V = U-1, V-1
T = [[] for _ in range(N)]
D = [0]*N
for i in range(N-1):
    a, b, = map(int, input().split())
    a, b = a-1, b-1
    T[a].append(b)
    T[b].append(a)
    D[a] += 1
    D[b] += 1

Dist_U = [0]*N
check = [0]*N
Q = deque([(U, 0)])
while Q:
    n, d = Q.popleft()
    check[n] = 1
    Dist_U[n] = d
    for i in T[n]:
        if check[i]:
            continue
        else:
            Q.append((i, d+1))

Dist_V = [0]*N
check = [0]*N
Q = deque([(V, 0)])
while Q:
    n, d = Q.popleft()
    check[n] = 1
    Dist_V[n] = d
    for i in T[n]:
        if check[i]:
            continue
        else:
            Q.append((i, d+1))

ans = 0
for i in range(N):
    if D[i] == 1:
        if Dist_U[i] < Dist_V[i]:
            ans = max(ans, Dist_V[i]-1)

print(ans)


Measured memory_bytes: 30924
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define dame {cout<< "0" <<"\n"; return;}
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<P> ans;
    if(N%2==0){
        reps(i,1,N+1){
            reps(j,i+1,N+1){
                if(i+j==N+1) continue;
                ans.emplace_back(i,j);
            }
        }
    }
    else{
        reps(i,1,N+1){
            reps(j,i+1,N+1){
                if(i+j==N) continue;
                ans.emplace_back(i,j);
            }
        }
    }
    cout<< ans.size()<<"\n";
    for(auto pe: ans){
        cout<< pe.first <<" "<< pe.second<<"\n";
    }
    
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define pb push_back
#define SZ(a) (int) (a.size())
typedef long long ll;

const int M = 1e9 + 7;

typedef vector<vector<ll> > Matrix;
Matrix ones(int n) {
	Matrix r(n,vector<ll>(n));
	fore(i,0,n)r[i][i]=1;
	return r;
}
Matrix operator*(Matrix &a, Matrix &b) {
	int n=SZ(a),m=SZ(b[0]),z=SZ(a[0]);
	Matrix r(n,vector<ll>(m));
	fore(i,0,n)fore(j,0,m)fore(k,0,z)
		r[i][j]+=a[i][k]*b[k][j],r[i][j]%=M;
	return r;
}
Matrix be(Matrix b, ll e) {
	Matrix r=ones(SZ(b));
	while(e){if(e&1LL)r=r*b;b=b*b;e/=2;}
	return r;
}

int main() {
    int n;
    ll k;
    cin >> n >> k;
    Matrix a(n, vector<ll>(n));
    fore(i, 0, n) fore(j, 0, n) cin >> a[i][j];

    Matrix b(n, vector<ll>(1));
    fore(i, 0, n) b[i][0] = 1;

    Matrix r = be(a, k);
    r = r * b;
    ll res = 0;
    fore(i, 0, n) res += r[i][0], res %= M;
    cout << res << endl;
}

Measured memory_bytes: 384
// Problem : C - Step
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


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


#define sc(ar,n) for(int pen=0;pen<n;pen++){ cin>>ar[pen];}
#define pr(ar,n) for(int pen=0;pen<n;pen++){ cout<<ar[pen]<<" ";} cout<<endl;
#define mem(ar,x) memset(ar,x,sizeof(ar))
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define rt return 0;
#define ct continue;
#define pb push_back
#define ll long long int
#define ff first
#define ss second
#define mod 1000000007
#define maxn 1000003
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif



int main(){
	
	fastio;
	ll n,ans=0;
	cin>>n;
	
	ll arr[n];
	sc(arr,n);
	
	for(ll i=1;i<n;i++){
		if(arr[i]<arr[i-1]){
			ans+=(arr[i-1]-arr[i]);
			arr[i] = arr[i-1];
 		}
	}
	cout<<ans;
	
	}


	
	
	
	



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

template<typename T>
void trace(T a[], int n) {
	for (int i = 0; i < n; i++) {
		if (i > 0) printf(" ");
		printf("%c%c", a[i].first, a[i].second);
	}
	printf("\n");
}
template<typename T> 
void MySwap(T &a, T &b) {
	T t = a;
	a = b;
	b = t;
}
template<typename T>
void bubbleSort(T a[], int n) {
	for (int i = n - 1; i > 0; i--) {
		int flag = 1; 
		for (int j = 0; j < i; j++) {
			if (a[j].second > a[j + 1].second) {
				MySwap(a[j], a[j + 1]);
				flag = 0; 
			}
		}
		if (flag) break; //当数组不存在顺序相反的相邻元素提前退出 
	}
	trace(a, n);
}
template<typename T>
void selectionSort(T a[], int n) {
	int minj;
	for (int i = 0; i < n; i++) {
		minj = i;
		for (int j = i; j < n; j++) {
			if (a[j].second < a[minj].second) minj = j;
		}
		if (i != minj) MySwap(a[i], a[minj]);
	}
 	trace(a, n);
} 

int main() {
    int N;
    scanf("%d", &N);
    pair<char, char> a[N], b[N];
    for (int i = 0; i < N; i++) {
    	cin >> a[i].first >> a[i].second;
    	b[i] = a[i];
    }
    bubbleSort(a, N);
    printf("Stable\n");
    selectionSort(b, N);
    int flag = 1;
    for (int i = 0; i < N; i++) {
    	if (a[i].first != b[i].first) {
    		printf("Not stable\n");
    		flag = 0;
    		break;
		}
	}
	if (flag) printf("Stable\n");
    return 0;
}


Measured memory_bytes: 3216
n,a,b=gets.split.map(&:to_i)
s=gets.chomp

count=0
count_b=0

n.times do |i|
    if s[i]=="a" && count<a+b
        count+=1
        puts "Yes"
    elsif s[i]=="b" && count<a+b && count_b<b
        count+=1
        count_b+=1
        puts "Yes"
    else
        puts "No"
    end
end


Measured memory_bytes: 14552
#include <stdio.h>

void trace(int A[], int N) {
	int i;
	for (i = 0; i < N; i++) {
		if (i > 0)printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N) {
	int j, i, v;
	for (i = 1; i < N; i ++) {
		v = A[i];
		j = i - 1;
		while ( j >= 0 && A[j] >v){
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, N);
	}
}

int main() {
	int N, i, j;
	int A[100];

	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%d", &A[i]);

	trace(A, N);
	insertionSort(A, N);

	return 0;
}

Measured memory_bytes: 2752
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  if (ceil((double)a / d) < ceil((double)c / b)) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int n;
	cin >> n;
	int count = 0;
	while(1){
		count ++;
		if(1000*count >= n){
			cout << 1000*count - n << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3632
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1);r(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.in(),r=new Array(e),n=0;n<e;n++)r[n]=t.in();for(var i=new Array(e+1).fill(0),o=1;o<=e;o++)i[r[o-1]]=i[r[o-1]-1]+1;for(var s=0,u=0;u<=e;u++)s=Math.max(s,i[u]);console.log(e-s)}}]);

Measured memory_bytes: 53060
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	int sum=0;
	string s;cin>>s;
	for(int i=0;i<s.size();i++)
	{
		sum+=(int)(s[i]-'0');
		sum%=9;
	}
	
	cout<<(sum ? "No" : "Yes");
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


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

using namespace std;

typedef double D;
typedef long long int LL;

#define st first
#define nd second
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 1e6 + 7;
const int MX = 1e9 + 7;
const LL INF = 1LL * MX * MX;

int add(int x){
	if(x > 3)	return 0;
	return (4 - x) * 100000;
}

int main(){
	int x, y;
	cin >> x >> y;
	
	int s = add(x) + add(y);
	if(x == 1 && y == 1)
		s += 4 * 100000;
	cout << s;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	string S;
	cin >> S;
	int L = S.size();
	cout << S[0] << L - 2 << S[L - 1] << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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

d = 1
while (2**d) < k:
    d += 1
ans = 0
for i in range(1,n+1):
    while (i*(2**(d-1)) >= k) and d > 0:
        d -= 1
    ans += (1/n)*((1/2)**d)

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n, m; cin >> n >> m;
	vector<vector<int>> a(n);
	for (int i = 0; i < m; i++) {
		int p; string s; cin >> p >> s;
		p--;
		if (a[p].size() > 0 && a[p].back() == 0) continue;
		a[p].push_back(s == "WA");
	}
	int solved = 0, penalty = 0;
	for (int i = 0; i < n; i++) {
		if (a[i].size() == 0 || a[i].back() != 0) continue;
		solved++;
		penalty += accumulate(a[i].begin(), a[i].end(), 0);
	}
	cout << solved << " " << penalty << endl;
	return 0;
}


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

using namespace std;

int main()
{
    int X;
    cin >> X;
    long long int m = 1;
    long long int tmp = 1;
    for (auto i=1; i <= X; ++i) {
        for (auto j=2; j <= X; ++j) {
            tmp = pow(i, j);
            if (m < tmp && tmp <= X) {
                m = tmp;
            }
        }
    }
    cout << m << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
        long long int n,k,factor;
        cin>>n>>k;
	if(k>n)
	{
		if(k-n<n)
			cout<<(k-n);
		else
			cout<<n;
	}
	else
	{
		factor=n/k;
		n=n-factor*k;
	        n=min(n,abs(n-k));
		cout<<n;
	}
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=200005;
const int mod=1e9+7;
ll fact[maxn];
ll inv[maxn];
ll h,w,a,b;

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

void _init(){
	fact[0]=fact[1]=1;
	for(int i=2;i<maxn;i++)fact[i]=fact[i-1]*i%mod;
	inv[0]=1;inv[maxn-1]=qpow(fact[maxn-1],mod-2);
	for(int i=maxn-2;i>=1;i--)inv[i]=inv[i+1]*(i+1)%mod;
}

ll C(ll n, ll r){
	return fact[n]*inv[r]%mod*inv[n-r]%mod;
}

int main(){
	_init();
	cin>>h>>w>>a>>b;
	ll ans=0;
	for(int i=b+1;i<=w;i++){
		ans=(ans+(C(h-a+i-2,h-a-1)*C(w+a-i-1,a-1))%mod)%mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;
typedef long long ll;

int main(void)
{
    int n;
    cin >> n;
    int a[26];
    fill(a, a + 26, 100000);

    REP(i, n)
    {
        int t[26];
        fill(t, t + 26, 0);
        string s;
        cin >> s;
        REP(j, s.length())
        {
            t[s[j] - 'a']++;
        }
        REP(j, 26)
        {
            a[j] = min(a[j], t[j]);
        }
    }

    REP(i, 26)
    {
        cout << string(a[i], i + 'a');
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


//二部マッチング（簡易版）
class BipartiteMatching2 {
public:
	//引数：頂点数
	BipartiteMatching2() :V(0) {}
	BipartiteMatching2(int size) :V(size) {
		G.resize(size);
		match.resize(size);
		used.resize(size);
	}
	
	//u,vを結ぶ辺をグラフに追加する
	void add_edge(int u, int v) {
		G[u].push_back(v);
		G[v].push_back(u);
	}

	//二部グラフの最大マッチングを求める
	int max_matching() {
		int res = 0;
		fill(match.begin(), match.end(), -1);
		REP(v, V)if (match[v] < 0) {
			fill(used.begin(), used.end(), false);
			if (dfs(v))res++;
		}
		return res;
	}


private:
	const int V;          //頂点数
	vector<vector<int>> G;//グラフの隣接リスト表現
	vector<int> match;    //マッチングのペア
	vector<bool> used;    //dfsで既に調べたかのフラグ

						  //増加パスをDFSで探す
	bool dfs(int v) {
		used[v] = true;
		REP(i, (int)G[v].size()) {
			int u = G[v][i], w = match[u];
			if (w < 0 || !used[w] && dfs(w)) {
				match[v] = u;
				match[u] = v;
				return true;
			}
		}
		return false;
	}
};
using BM2 = BipartiteMatching2;




//変数
int N;
vector<pair<int, int>> reds, blues;
//サブ関数
//入力
void input()
{
	int a, b;
	cin >> N;
	REP(i, N) {
		cin >> a >> b;
		reds.push_back({ a,b });
	}
	REP(i, N) {
		cin >> a >> b;
		blues.push_back({ a,b });
	}
}


//計算
void calc()
{
	BM2 bm2 = BM2(2 * N);
	REP(i, N)REP(j, N) {
		auto red = reds[i];
		auto blue = blues[j];
		if (red.first < blue.first && red.second < blue.second)
			bm2.add_edge(i, N + j);
	}
	cout << bm2.max_matching() << endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 998244353;
const long long int INF = 1e18;

long long int N,M;
string t;
int main()
{
    cout << fixed << setprecision(18);
    cin>>t;
    IFYes(t[3]==t[2]&&t[4]==t[5]);
}


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

class Main {


    public static int totalCostIncurred(int[] height, int[] memo) {
        return totalCostHelper(0, height, memo);
    }

    private static int totalCostHelper(int i, int[] height, int[] memo) {
        if(i == height.length - 1) {
            return 0;
        }

        if(memo[i] != -1) {
            return memo[i];
        }

        int cost1 = Math.abs(height[i+1]-height[i]) + totalCostHelper(i+1,height, memo);
        int cost2 = i+2 < height.length ? Math.abs(height[i+2]-height[i]) + totalCostHelper(i+2,height, memo): Integer.MAX_VALUE;
        return memo[i] = Math.min(cost1, cost2);
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int numberOfStones = scanner.nextInt();
        int[] height = new int[numberOfStones];
        int[] memo = new int[numberOfStones];
        Arrays.fill(memo, -1);

        for(int i=0; i<height.length; i++)
            height[i] = scanner.nextInt();
        System.out.println(totalCostIncurred(height, memo));
    }
}


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

int main(){
  string S;
  cin >> S;
  S = S + 'E';             //終了記号を付け加える

  int max = 0;          //最大値を格納
  int len = 0;            //現在測定中の長さを格納
  
  for(int i = 0; i < S.size();){
    if(S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C')
      len++;
    else{
      if(max < len)
        max = len;
      len = 0;
    }
    i++;
  }

  cout << max << endl;
  return 0;

}

Measured memory_bytes: 256
fun main(args:Array<String>) {
    Proc(readLine()!!.toInt()).proc()
}

class Proc(val keta:Int) {
    val cnt = createCountDic(keta)
    val primeList = cnt.keys.sorted()
    fun proc() {
        val ans = getAns(0, 75)
        println(ans)
    }
    fun getAns(idx:Int, flag:Int):Int {
        if(flag <= 1) {
            return 1
        }
        if(idx > primeList.lastIndex) {
            return 0
        }
        val element = listOf(1,3,5,15,25,75)
        val key = primeList[idx]
        var ans = 0
        for(i in element) {
            if(cnt[key]!! < i - 1) {
                break
            }
            if(flag % i != 0) {
                continue
            }
            ans += getAns(idx+1, flag / i)
        }
        return ans
    }
    companion object {
        fun createCountDic(num:Int):MutableMap<Int, Int> {
            val count = mutableMapOf<Int, Int>()
            for(i in (2..num)) {
                val ret = primeDevide(i)
                ret.forEach{
                    if(count.containsKey(it.key)) {
                        count[it.key] = count[it.key]!! + it.value
                    } else {
                        count[it.key] = it.value
                    }
                }
            }
            return count
        }
        fun primeDevide(num:Int):MutableMap<Int,Int> {
            var current = num
            val cnt = mutableMapOf<Int,Int>()
            for(i in (2..num)) {
                if(current % i != 0) {
                    continue
                }
                cnt[i] = 0
                while (current % i == 0) {
                    cnt[i] = cnt[i]!! + 1
                    current /= i
                }
                if(current <= 1) {
                    break
                }
            }
            return cnt
        }
    }
}

Measured memory_bytes: 38008
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <set>
#include <string>
#include <bitset>

using namespace std;

#pragma GCC oprimize("Ofast")
#define rep(i,a,b) for(__typeof(b)i=a;i<b;++i)
#define fs first
#define sc second
#define pb emplace_back

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vl2;
typedef pair<ll,ll> pl;

const ll inf = ~((ll)1<<(ll)63);

ll modpow(ll a, ll b, ll m)
{
    ll res = 1;
    while(b)
    {
        if(b%2)
            res = res * a % m;
        a = a * a % m;
        b /= 2;
    }
    return res;
}

string s;
ll m = 1000000007;
ll mem[100010][2];

ll dp(ll at, bool same)
{
    if(at==s.length())return 1;
    if(mem[at][same]!=-1)return mem[at][same];
    ll ans = 0;
    ans = (ans + dp(at+1,s[at]=='0'&&same))%m;
    if(!(same&&s[at]=='0'))ans = (ans + 2*dp(at+1,s[at]=='1'&&same))%m;
    return mem[at][same] = ans;

}

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

	memset(mem,-1,sizeof(mem));

    cin >> s;

    cout << dp(0,true);

	return 0;
}


Measured memory_bytes: 6764
import java.io.*;

class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
                int W, H, x, y, r;

                String line = reader.readLine();
                String[] strAry = line.split(" ");

                W = Integer.parseInt(strAry[0]);
                H = Integer.parseInt(strAry[1]);
                x = Integer.parseInt(strAry[2]);
                y = Integer.parseInt(strAry[3]);
                r = Integer.parseInt(strAry[4]);

                if((x + r) <= W && (y + r) <= H && (x - r) >= 0 && (y - r) >= 0 ){
                    System.out.println("Yes");
                }else{
                    System.out.println("No");
                }

                
        } catch (IOException e) {
            //TODO: handle exception
            System.out.println(e);
        }
    }
}

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

const int MAX_H = 10;

string a[MAX_H];

int main() {
    int h, w;
    cin >> h >> w;

    for (int r = 0; r < h; r++) {
        cin >> a[r];
    }

    for (int r = 0; r < h; r++) {
        for (int c = 0; c < w; c++) {
            if (a[r][c] != '#') continue;

            int cnt = 0;
            if (r - 1 >= 0 && a[r - 1][c] == '#') cnt++;
            if (c - 1 >= 0 && a[r][c - 1] == '#') cnt++;
            if (cnt >= 2) {
                cout << "Impossible" << endl;
                return 0;
            }
            cnt = 0;
            if (r + 1 < h && a[r + 1][c] == '#') cnt++;
            if (c + 1 >= 0 && a[r][c + 1] == '#') cnt++;
            if (cnt >= 2) {
                cout << "Impossible" << endl;
                return 0;
            }
            cnt = 0;
        }

    }

    cout << "Possible" << endl;
    return 0;
}


Measured memory_bytes: 256