akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for(int i=(a);i<(b);++i)
#define foreach(i, n) for (__typeof(n.begin()) i = n.begin(); i != n.end(); ++i)
#define sqr(x) ((x)*(x))
#define clr(a, b) memset(a, b, sizeof(a))
#define SZ(a) ((int)a.size())
#define inf 0x3f3f3f3f
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
const double eps = 1e-8;
int dcmp(double x) { if (x < -eps) return -1; else return x > eps;}
#define se(x) cout<<#x<<" = "<<x<<endl


const int N = 200010;
const int M = 200010 * 2;

int n, m;
char s[N];

struct graph {
    int e, head[N];
    int ev[M], nxt[M];
	int vis[N];
	int del[N];
	int a[N];
	int b[N];

    void init() { e = 0; clr(head, -1); } 
    void addedge(int u, int v) {
        ev[e] = v; nxt[e] = head[u]; head[u] = e++;
    }

	void dfs(int u) {
		// printf("%d\n", u);
        vis[u] = 1;
        for (int i = head[u]; ~i; i = nxt[i]) { 
            int v = ev[i];
            if (!vis[v]) dfs(v);
			if (!del[v]) {
				if (s[v-1] == 'A') {
					a[u] = 1;
				} else {
					b[u] = 1;
				}
			}
			// printf("%d %d %d A%d B%d\n", u, v, del[v], a[u], b[u]);
        } 
		// printf("%d A%d B%d\n", u, a[u], b[u]);
		if (a[u] == 0 || b[u] == 0) {
			del[u] = 1;
		}
	}

	void handle(queue<int> &q1, queue<int> &q2, int mk) {
		while (!q1.empty()) {
			int u = q1.front(); q1.pop();
			// printf("%d\n", u);
        	for (int i = head[u]; ~i; i = nxt[i]) { 
            	int v = ev[i];
				if (del[v]) continue;
				if (s[v-1] == 'A') {
					a[u] = mk;
				} else {
					b[u] = mk;
				}
			}
			if (a[u] < mk || b[u] < mk) {
				// printf("-- %d,\n", u);
				del[u] = 1;
        		for (int i = head[u]; ~i; i = nxt[i]) { 
            		int v = ev[i];
					if (del[v]) continue;
					q2.push(v);
				}
			}
		}
		// printf("[%d]\n", mk);
	}

	bool solve() {
		clr(vis, 0);
		clr(del, 0);
		clr(a, 0);
		clr(b, 0);
		int mk = 1;
		queue<int> q1, q2;
		forab (u, 1, n + 1) {
			q1.push(u);
		}
		while (true) {
			if (!q1.empty()) {
				handle(q1, q2, mk++);
			}
			if (!q2.empty()) {
				handle(q2, q1, mk++);
			}
			if (q1.empty()) {
				break;
			}
		}
		forab (i, 1, n + 1) {
			if (!del[i]) {
				return true;
			}
		}
		return false;
	}

};


int main(int argc, char *argv[]) {
	graph g;
	while (scanf("%d%d", &n, &m) != EOF) {
		scanf("%s", s);
		g.init();
		forn (i, m) {
			int a, b;
			scanf("%d%d", &a, &b);
			g.addedge(a, b);
			g.addedge(b, a);
		}
		bool ret = g.solve();
		if (ret) {
			puts("Yes");
		} else {
			puts("No");
		}
		// printf("%d\n", ret);
		// break;
	}
	return 0;
}

Measured memory_bytes: 8192
#include<stdio.h>
int main()
{
   long long int n,s=0,a,b,i,m;
    scanf("%lld",&n);
    scanf("%lld",&a);
    m=a;
    for(i=1;i<n;i++)
    {
        scanf("%lld",&b);
        if(b>m)m=b;
         else if(b<m)
           s=m-b+s;
    }
    printf("%lld\n",s);
}


Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int N; str S;cin>>N>>S;
    int cnt = 1; char pr = S[0];
    for(int i=1; i<N;i++){
      if(pr != S[i]){
        cnt++; pr = S[i];
      }
    }

    cout<<cnt<<endl;
    return 0;
}


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

using namespace std;

int main(){
  int N,R;

  cin >> N >> R;
  int ans = 0;
  if(N >= 10) {ans = R;}
  else {ans = R + 100 * (10 - N); }

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

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())

    x = 0
    cur = 0
    while cur < n:
        x += 1
        cur += x

    if cur == n:
        print("Yes")
        k = x + 1
        res = [[0] * x for _ in range(x + 1)]

        for i in range(1, x + 1):
            l = i * (i - 1) // 2 + 1
            for j in range(i):
                res[j][i - 1] = j + l
            for j in range(i):
                res[i][j] = j + l
        print(k)
        for row in res:
            print(k - 1, *row)
    else:
        print("No")


if __name__ == '__main__':
    main()


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

int main(void)
{
    while (true)
    {
        int a, b;
        cin >> a >> b;
        if (a == 0 && b == 0)
            break;
        else if (a < b)
            cout << a << " " << b << endl;
        else
            cout << b << " " << a << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;

int N,X;
int L[110],ans;
signed main(){
    cin>>N>>X;
    rep(i,N)cin>>L[i];

    int now=0;
    rep(i,N+1){
        if(now<=X)ans++;
        now+=L[i];
    }
    cout<<ans<<endl;


 
}

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

int main(){
	int n;
	scanf("%d", &n);
	vector<pair<int, int> > a;
	for(int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		a.push_back(make_pair(x, i + 1));
	}
	sort(a.begin(), a.end());
	for(int i = 0; i < n - 1; i++)
		printf("%d ", a[i].second);
	printf("%d\n", a[n-1].second);
}


Measured memory_bytes: 1780
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int32 i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int32 i = (b) - 1; i >= (a); --i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define ALL(x) (x).begin(),(x).end()
#define C(x) cout << #x << " : " << x << endl
#define scanf scanf_s

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;



int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int32 n;
	cin >> n;
	int32 f[100][10];
	rep(i, 0, n) {
		rep(j, 0, 10) {
			cin >> f[i][j];
		}
	}
	int32 p[100][11];
	rep(i, 0, n) {
		rep(j, 0, 11) {
			cin >> p[i][j];
		}
	}
	uint32 i;
	int64 ans = -1e18;
	int64 cur;
	for (i = 1;i < 1024;++i) {
		cur = 0;
		int32 temp = 0;
		rep(j, 0, n) {
			rep(k, 0, 10) {
				if (bitget(i, k) && f[j][k]) {
					++temp;
				}
			}
			cur += p[j][temp];
			temp = 0;
		}
		ans = max(ans, cur);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 105
using namespace std;
int ans;
int cnt[N][N];
#define mmax(x,y) (x=max(x,y),ans=max(ans,y))
#define get(x1,y1,x2,y2) (cnt[x2][y2]-cnt[x2][y1-1]-cnt[x1-1][y2]+cnt[x1-1][y1-1])
char s[N][N];
int n,m,Ex,Ey;
int dp[2][N][N][N];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++){
			cnt[i][j]=cnt[i-1][j]+cnt[i][j-1]-cnt[i-1][j-1]+(s[i][j]=='o');
			if(s[i][j]=='E') Ex=i,Ey=j;
		}
	int now=0;
	for (int i=0;i<=Ex-1;i++){
		memset(dp[now^1],0,sizeof(dp[0]));
		for (int j=0;j<=n-Ex;j++)
			for (int k=0;k<=Ey-1;k++)
				for (int L=0;L<=m-Ey;L++){
					int v=dp[now][j][k][L];
					int xl=max(Ex-i,j+1),yl=max(Ey-k,L+1),xr=min(Ex+j,n-i),yr=min(Ey+L,m-k);
					if (Ex-i-1>j) mmax(dp[now^1][j][k][L],v+get(Ex-i-1,yl,Ex-i-1,yr));
					if (Ex+j<n-i) mmax(dp[now][j+1][k][L],v+get(Ex+j+1,yl,Ex+j+1,yr));
					if (Ey-k-1>L) mmax(dp[now][j][k+1][L],v+get(xl,Ey-k-1,xr,Ey-k-1));
					if (Ey+L<m-k) mmax(dp[now][j][k][L+1],v+get(xl,Ey+L+1,xr,Ey+L+1));
				}
		now^=1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 9344
($N,$M)=glob<>;
for(@_=<>){
	/ /;
	push@{$`},$'
}
for$p(1..$N){
	$%=0;
	$$p{$_}=++$%for sort{$a-$b}@$p
}
for(@_){
	/ /;
	printf"%06d%06d\n",$`,${$`}{$'}
}


Measured memory_bytes: 106624
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll A, B;
    scanf("%lld %lld", &A, &B);
    printf("%lld\n", (A+B)%24);
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var N, a int
	fmt.Scan(&N)
	m := map[int]int{}
	for i := 0; i < N; i++ {
		fmt.Scan(&a)
		if _, ok := m[a]; ok {
			fmt.Println("NO")
			return
		}
		m[a]++
	}
	fmt.Println("YES")
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 1000000000;
typedef pair<int, int> P;
const int MAX_N = 200000;
const int MAX_L = 100000000;
const int MAX_SQRT_B = 10000;
typedef int64_t ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll N, A, B;

int main() {
	cin >> N >> A >> B;
	if (A % 2 != B % 2) {
		cout << min(A - 1, N - B) + 1 + (B - A - 1) / 2 << endl;
		
	}
	else {
		cout << (B - A) / 2 << endl;
	}
}

Measured memory_bytes: 3576
from functools import lru_cache
N = int(input())
K = int(input())

@lru_cache(None)
def f(N, K):
    if K == 0: return 1
    if N < 10:
        if K == 1: return N
        return 0
    q, r = divmod(N, 10)
    ret = 0
    ret += f(q, K)
    ret += f(q, K-1) * r
    ret += f(q-1, K-1) * (9-r)
    return ret

print(f(N, K))  


Measured memory_bytes: 38384
#include<iostream>
#include<stack>
void search(int,int,int);
using namespace std;
int w,h;
int map[100][100];
int icemax=0;
int main(void)
{
	
	int a,i,j,b,x,y;
	cin>>w>>h;
	while(w!=0||h!=0){
	for(i=0;i<w;i++){
		for(j=0;j<h;j++){
			cin>>map[i][j];
		}
	}
	for(i=0;i<w;i++){
		for(j=0;j<h;j++){
			if(map[i][j]==1){
			search(i,j,1);
			}
		}
	}
	cout<<icemax+1<<endl;
	icemax=0;
	cin>>w>>h;
	}
}
void search(int y,int x,int c)
{
	int gx[4]={1,0,-1,0},gy[4]={0,1,0,-1},i,p;
	map[y][x]=0;
	for(i=0;i<4;i++){
		if(gx[i]+x<0||gx[i]+x>=w||gy[i]+y>=h||gy[i]+y<0) continue;
		if(map[gy[i]+y][gx[i]+x]==0) continue;
		search(gy[i]+y,gx[i]+x,c+1);
		if(icemax<c) icemax=c;
	}
	map[y][x]=1;
}
//tp://www27.atpages.jp/tasuku/pro/2_algo.pdf

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

int main() {
	// your code goes here
        long long int  x=0;
        cin>>x;
       long long int p=100;
       int c=0;
       while(p<x) 
      { 
          p+=p/100;
        c++;
      }
     cout<<c;
	return 0;
}


Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

	private void run() {
		Scanner sc = new Scanner(System.in);

		for (;;) {
			long n = sc.nextLong();
			int k = sc.nextInt();
			if (n + k == 0)
				break;
			long num = 1;
			long g2 = 0;

			{
				long n2 = n;
				long dig = 10;

				for (int i = 1;; i++) {
					// System.out.println(dig*i +" "+n2+ " " + i);
					if (n2 < dig * i) {
						num = n2 / i;
						g2 = (n2) % i;
						break;
					}
					n2 += dig;
					dig *= 10;
				}
			}
			long nums = num;
			long gs = g2;

			{
				long n2 = n + k ;
				long dig = 10;

				for (int i = 1;; i++) {
					// System.out.println(dig*i +" "+n2+ " " + i);
					if (n2 < dig * i) {
						num = n2 / i;
						g2 = (n2) % i;

						break;
					}
					n2 += dig;
					dig *= 10;
				}
			}
//			 System.out.println(nums + " " + gs + " " + num + " " + g2);
			 if(nums==num){
					System.out.print((nums + "").substring((int) gs, (int) g2));
				 
			 }else{
			System.out.print((nums + "").substring((int) gs));
			for (int i = (int) nums+1 ; i < num; i++) {
				System.out.print(i);
			}
			System.out.print(("" + num).substring(0, (int) g2));
			 }
			System.out.println();
		}
		sc.close();
	}

	public static void main(String args[]) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

struct Query {
  int a,b,c,d;
};
int n,m,q, ans=0;
vector<Query> query;


void dfs(vector<int> now) {
  if (now.size()==n) {
    int point=0;
    for (const auto& e: query) {
      if (now[e.b]-now[e.a]==e.c) point+=e.d;
    }
    ans=max(ans,point);
    return;
  }
  // 広義単調増加列より末尾以上の要素は追加可能
  for (int i = now.back(); i <= m; ++i)
  {
    vector<int> nxt=now;
    nxt.push_back(i);
    dfs(nxt);
  }
}

int main()
{
  cin>>n>>m>>q;
  query.resize(q);
  for(auto&& e: query) 
  {
    cin>>e.a>>e.b>>e.c>>e.d;
    e.a--;
    e.b--;
  }
  for (int i = 1; i <= m; ++i)
  {
    vector<int> start{i};
    dfs(start);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/
vi to[100100];
int n,m;



signed main(){
  cin>>n>>m;
  vi h(n);
  rep(i,n) cin>>h[i];
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    to[a].pb(b);
    to[b].pb(a);
  } 

  int ans=0; 
  rep(i,n){
    
    bool top=1;
    for(auto v:to[i]){
      if(h[v]>=h[i]) top=0;
    }
    if(top) ans++;
  }

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

Measured memory_bytes: 9860
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int A = Integer.parseInt(st.nextToken());
        int B = Integer.parseInt(st.nextToken());
        if ((A+B)%2==1) {
            System.out.println("IMPOSSIBLE");
        } else {
            System.out.println((A+B)/2);
        }
    }
}


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

int N;
vector<vector<pair<int, int>>> P;

int kthbit(int A, int K) { return (A >> K) & 1; }

bool possible(int n){
    vector<int> isHonest(N, -1);
    for(int i=0; i<N; i++){
        isHonest[i] = kthbit(n, i);
    }

    for(int i=0; i<N; i++){
        if(isHonest[i] == 0) continue;

        for(auto p : P[i]){
            if(isHonest[p.first] != p.second){
                return false;
            }
        }
    }
    return true;
}

int cntBit(int n){
    if(n < 2) return n;
    else return n%2 + cntBit(n/2);
}

int main(){
    cin >> N;
    P.resize(N);
    for(int i=0; i<N; i++){
        int A;  cin >> A;
        P[i].reserve(A);
        for(int a=0; a<A; a++){
            int x, y;  cin >> x >> y;
            x--;
            P[i].push_back({x, y});
        }
    }

    int ans = 0;
    for(int i=0; i<(1<<N); i++){
        if(possible(i)){
            ans = max(ans, cntBit(i));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N, D, A;
    cin >> N >> D >> A;
    vector<pair<ll, ll>> monsters(N);
    Rep (i, N) {
        ll X, H;
        cin >> X >> H;
        monsters[i] = {X, H};
    }

    sort(monsters.begin(), monsters.end());

    map<ll, ll> bomb;
    ll cnt = 0;
    Rep (i, N) {
        if (i > 0) {
            auto itr = bomb.lower_bound(monsters[i-1].first - D);
            while ((*itr).first < monsters[i].first - D && itr != bomb.end()) {
                cnt -= (*itr).second;
                itr++;
            }
        }     

        monsters[i].second -= A*cnt;

        if (monsters[i].second <= 0) continue;

        ll exp = monsters[i].first + D;
        bomb[exp] = max((ll)0, (monsters[i].second + A - 1) / A);
        cnt += bomb[exp];
    }

    ll ans = 0;
    for (auto e : bomb) {
        ans += e.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15872
N, A, B = map(int, input().split())
# if (B - A) % 2 == 1:
#     ans = min(B-1, N-A)
# else:
#     # 中間地点で会うのがベスト
#     ans = abs(B-A)//2
#
# print(ans)
a = A
b = B
if (B - A) % 2 == 0:
    # 中間地点で会うのがベスト
    ans = abs(B-A)//2
    print(ans)
    exit()
else:
    a = A
    b = B
    ans = 10**20
    # 左側で偶奇を揃える場合
    left = A-1  # 左に行くまでの試合回数
    tmp = left
    a -= left  # Aは1に
    b -= left
    # 1回試合をして偶奇を揃える
    b -= 1
    tmp += 1
    # 中間地点で会う
    tmp += abs(b-a)//2
    ans = min(ans, tmp)

    # 右側で偶奇を揃える場合
    a = A
    b = B
    right = N-b  # 右に行くまでの回数
    tmp = right
    b = N
    a += tmp  # 試合回数文
    # 1回試合をする
    tmp += 1
    a += 1
    tmp += abs(b-a)//2
    ans = min(tmp, ans)
    print(ans)
    exit()


Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>

using namespace std;
using P = pair<int, int>;

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

	vector<int>sum(N + 1);
	sum[0] = 0;
	for (int i = 0; i < N; ++i) sum[i + 1] = (sum[i] + A[i]) % M;

	map<int, int> m;
	long long ans = 0;
	for (int i = 0; i < N + 1;++i) {
		ans += m[sum[i]];
		m[sum[i]]++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3968
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#"4
2 1 4 3"# => r#"2"#,

r#"3
2 3 1"# => r#"0"#,

r#"5
5 5 5 5 1"# => r#"1"#,
}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        n: usize,
        a: [usize; n],
    }
    let mut ans = 0.0;

    for i in 0..n {
        if i == a[a[i] - 1] - 1 {
            ans += 0.5;
        }
    }

    (ans as usize).to_string()
}

Measured memory_bytes: 6396
// Copyright lzt
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef std::pair<long long, long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i, j, k)  for (register int i = (int)(j); i <= (int)(k); i++)
#define rrep(i, j, k) for (register int i = (int)(j); i >= (int)(k); i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

inline ll read() {
  ll x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}

const int maxn = 200200;
int n;
ll f[maxn], c;
int h[maxn];

double calc(int x) {
  return f[x] + h[x] * 1.0 * h[x];
}
double slop(int x, int y) {
  return (calc(x) - calc(y)) * 1.0 / (h[x] - h[y]) / 2;
}

int q[maxn], l, r;

void work() {
  n = read(); c = read();
  rep(i, 1, n) h[i] = read();
  l = r = 1; q[1] = 1;
  rep(i, 2, n) {
    while (r > l && slop(q[l], q[l + 1]) <= h[i]) l++;
    int nw = q[l]; f[i] = f[nw] + (h[i] - h[nw]) * 1ll * (h[i] - h[nw]) + c;
    while (r > l && slop(q[r], i) < slop(q[r - 1], q[r])) r--;
    q[++r] = i;
  }
  printf("%lld\n", f[n]);
}

int main() {
  #ifdef LZT
    freopen("in", "r", stdin);
  #endif

  work();

  #ifdef LZT
    Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
  #endif
}


Measured memory_bytes: 3328
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;
using static System.Console;

namespace program {
  class Program {
    static string Alp = "abcdefghijklmnopqrstuvwxyz";
    static void Main()
    {
      WriteLine(new Func<string[],string>((string[] s)=>$"{s[1]}{s[0]}")(ScanStrArray()));
    }
  }
  
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
    static public string RegaxReplace(this string arg1, string pattern, string replacement)
    {
      return Regex.Replace(arg1, pattern, replacement);
    }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
 
//LIFE IS NOT A PROBLEM TO BE SOLVED
 
#define rep(i, a, b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back
 
using namespace std;
 
const int mod = 1000000007;
const int INF = 0x3f3f3f3f;
const long long int LINF = 1LL<<56;

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


int N, W;
ll dp[100010];

int main(){
	
	rep(i, 1, 100001) dp[i] = LINF;
	
	cin >> N >> W; 
	
	int w, v;
	rep(i, 0, N){
		cin >> w >> v;
		for(int j = 100000; j>=v; j--){
			if(dp[j-v]<LINF){
				dp[j] = min(dp[j], dp[j-v]+w);
			}
		}
	}
	
	for(int i=100000; i>=0; i--){
		if(dp[i]<=W){
			cout << i << '\n';
			return 0;
		}
	}
	
		
	
	

	
	return 0;
}

Measured memory_bytes: 1024
from collections import*
h,w,m=map(int,input().split())
d=defaultdict(int)
a=[0]*h
b=[0]*w
for _ in range(m):
  x,y=map(int,input().split())
  x-=1
  y-=1
  a[x]+=1
  b[y]+=1
  d[(x,y)]+=1

ma=max(a)
mb=max(b)

ind_x=[i for i,j in enumerate(a) if j==ma]
ind_y=[i for i,j in enumerate(b) if j==mb]


for x in ind_x:
  for y in ind_y:
    if d[(x,y)]==0:
      print(ma+mb)
      exit()
print(ma+mb-1)


Measured memory_bytes: 202960
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;


//2のn乗を求めるよ！！！
int ni(int n) {
	if (n == 0)return 1;
	int x = ni(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
}

//フィボナッチ数列のx番目を求めるよ！
int f(int x, vector<int> s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	s[x] = f(x - 1, s) + f(x - 2, s);
	return s[x];
}

//aとｂの最大公約数を求めるよ！
llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}



// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//m進数のn桁を全列挙やで
void dfs(int m, int n) {

	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			cout << now << endl;
		}
		else {
			for (int i = m - 1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}

int main() {
	int n;
	cin >> n;
	hei(string) s(n+1);
	rep(i, 0, n) {
		int a;
		cin >> a;
		if (i + 1 == a)s[i] = "x";
		else s[i] = "o";
	}
	int ans = 0;
	rep(i, 0, n) {
		if (s[i] == "x" && i == n - 1)s[i] = "o", ans++;
		if (s[i] == "x") {
		    s[i]="o";
			s[i + 1] = "o";
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5760
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define REP(i, start, end) for (ll i = start, i##Len = (end); i < i##Len; ++i)
#define REPR(i, start, end) for (ll i = start, i##Len = (end); i > i##Len; --i)
using ll = long long;
using namespace std;

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

    ll n;
    cin >> n;
    ll ans = 0;
    REP(i, 1, n + 1)
    {
        ll cnt = n / i;
        ans += cnt * (cnt + 1) / 2 * i;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		
		String ans = "";
		for(int i = 0;i < s.length();++i) {
			switch(s.charAt(i)) {
			case '0':
			case '1':
				ans = ans + s.charAt(i);
				break;
			case 'B':
				if(ans.length() > 0)
					ans = ans.substring(0, ans.length()-1);
				break;
			}
		}
		System.out.println(ans);
	}
}


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

int main(){
	int n;
	while(cin >> n, n){
		int num, ans = 0;
		for(int i = 0;i < 9;i++){
			cin >> num;
			ans += num;
		}
		cout << n-ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2976
#include <iostream>

int main(){
    using namespace std;

    int n;
    cin >> n;
    int past = 2100100100;
    int res = -1100100100;
    for(int i = 0; i < n; i++){
        int cur;
        cin >> cur;
        res = (res < cur-past) ? cur-past:res;
        past = (past > cur) ? cur:past;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3092
using System;

namespace _0137
{
    class Program
    {
        static void Main(string[] args)
        {
            int j = int.Parse(Console.ReadLine());
            for (int i = 1; i <= j; i++)
            {
                int n = int.Parse(Console.ReadLine());
                Console.WriteLine("Case " + i + ":");
                for (int k = 0; k < 10; k++)
                {
                    n = (n * n) % 1000000 / 100;
                    Console.WriteLine(n);
                }
            }
        }
    }
}

Measured memory_bytes: 9156
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()
	h := make([][]int, n)

	for i := 0; i < n; i++ {
		h[i] = make([]int, 3)
		for j := 0; j < 3; j++ {
			h[i][j] = readInt()
		}
	}
	dp := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		dp[i] = make([]int, 3)
	}

	for i := 0; i < n; i++ {
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if k == j {
					continue
				}
				dp[i+1][k] = max(dp[i+1][k], dp[i][j]+h[i][k])
			}
		}
	}
	fmt.Println(maxIntSlice(dp[n]))
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func maxIntSlice(list []int) int {
	max := 0
	for _, v := range list {
		if v > max {
			max = v
		}
	}
	return max
}


Measured memory_bytes: 12032
#include <iostream>
#include <vector>
#include <map>
using namespace std;

typedef long long ll;

const ll MOD = (1e+9) + 7;

vector<pair<ll, ll> > p;
ll fac[200000], finv[200000], inv[200000];

void initComb()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for(int i = 2; i < 200000; 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;
  }
}

ll comb(int n, int k)
{
  if(n < k or n < 0 or k < 0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main()
{
  initComb();

  int n, m;
  cin >> n >> m;

  int x = m;
  for(ll i = 2; i*i <= m; i++){
    if(x % i != 0) continue;
    int cnt = 0;
    while(x % i == 0){
      x /= i;
      cnt++; 
    }
    p.push_back(make_pair(i, cnt));
  }
  if(x != 1) p.push_back(make_pair(x, 1));

  ll ans = 1;
  for(auto u : p){
    int k = u.second;
    ans = (ans * comb(n+k-1, n-1)) % MOD;
  }
   
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int n,k,i;
  ll a[100005];
  
  cin >> n >> k;
  for (i=0;i<n;i++) cin >> a[i];
  
  sort(a,a+n);
  
  ll fac[100005],inv[100005],finv[100005],ans=0;
  const ll mod=1e9+7;
  
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (i=2;i<=n;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;
  }
  
  for (i=0;i<n;i++){
    if (i>=k-1) ans=(ans+fac[i]*finv[k-1]%mod*finv[i-k+1]%mod*a[i]%mod)%mod;
    if (i+k-1<n) ans=(ans+mod-fac[n-i-1]*finv[k-1]%mod*finv[n-i-k]%mod*a[i]%mod)%mod;
  }
  
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

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

const int MAXN = 1e6 + 10;
const int MM = 1e9 + 7;

int n, m;
int a[MAXN];

string s, t;
set<string> st;

int main(){
    cin >> n;
    string t = "====";
    for (int i = 1; i <= n; i++){
        cin >> s;
        if (st.find(s) != st.end()){
            puts("No");
            return 0;
        }
        st.insert(s);
        if (i > 1 && s[0] != t[t.length() - 1]){
            puts("No");
            return 0;
        }
        t = s;
    }   
    puts("Yes");
    return 0;
}


Measured memory_bytes: 256
C = str(input())

#alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
alphabet = list('abcdefghijklmnopqrstuvwxyz')

id = alphabet.index(C)

print(alphabet[id+1])

Measured memory_bytes: 2940
import collections
n = int(input())
deq = collections.deque()
ls = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","a"]
if n == 1:
    print("a")
else:
    n -= 1
    while n > 0:
        deq.appendleft(n%26)
        n //= 26
    ans = ""
    #print(deq)
    for i in range(len(deq)-2,0,-1):
        if deq[i] <= 0:
            deq[i-1] -= 1
            deq[i] += 26
    #print(deq)
    for i in range(len(deq)):
        if i != len(deq)-1:
            if deq[i] != 0:
                ans += ls[deq[i]-1]
        else:
            ans += ls[deq[i]]
    print(ans)


Measured memory_bytes: 9476
<?php
fscanf(STDIN, "%d %d", $N, $Y);
 
$answer = "-1 -1 -1";
 
$k10max = floor($Y / 10000);
for ($k10 = 0; $k10 <= $k10max; $k10++) {
    $k1 = ($Y - $k10 * 10000) / 1000;
    if ((($k10 + $k1) - $N) % 4 == 0) {
        $k5 = (($k10 + $k1) - $N) / 4;
        $k1 -= $k5 * 5;
        if ($k5 < 0 || $k1 < 0) continue;
 
        $answer = "{$k10} {$k5} {$k1}";
        break;
    }
}
 
echo $answer . PHP_EOL;

Measured memory_bytes: 4604
def main():
    x, y = map(int, input().split())

    if 0 <= x <= y or x <= y <= 0:
        ans = abs(abs(x) - abs(y))

    elif x <= 0 <= y or y <= 0 <= x:
        ans = abs(abs(x) - abs(y)) + 1

    elif y < x < 0 or 0 < y < x:
        ans = abs(abs(x) - abs(y)) + 2

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

int main()
{
    int A;
    int B;
    int C[210000];
    cin >> A;
    cin >> B;
    double D[1100];
    double E[210000];

    for(int i=0; i < A ;i++){
        cin >> C[i];
    }

    for(int i=0; i < 1001 ;i++){
        D[i] = (double)((i+1)*0.5);        
    }
    

    
    E[0] = D[C[0]];
    for(int i=1; i<A; i++){
        E[i] += E[i-1] + D[C[i]];
    }

    double max = 0;
    double tmp;
    for(int i=B-1;i < A ;i++){
        if(i==B-1) tmp = E[i];
        else tmp = E[i]-E[i-B];
        if (tmp > max){
            max = tmp;
        }
    }

    cout << std::setprecision(10);
    cout  << max << endl;

}


Measured memory_bytes: 2688
n = int(input())
a = list(map(int, input().split()))

cnt = 0
flag = 0
for i in range(n - 1):
    if flag == 0:
        if a[i] < a[i + 1]:
            flag = 1
        elif a[i] > a[i + 1]:
            flag = -1
    elif flag == 1:
        if a[i] < a[i + 1]:
            flag = 1
        elif a[i] > a[i + 1]:
            flag = 0
            cnt += 1
    elif flag == -1:
        if a[i] > a[i + 1]:
            flag = -1
        if a[i] < a[i + 1]:
            flag = 0
            cnt += 1
print(cnt + 1)


Measured memory_bytes: 14436
import bisect

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

ans = 0
for b in B:
    ai = bisect.bisect_left(A, b)
    ci = N - bisect.bisect_right(C, b)
    ans += ai * ci

print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<int> M(N,0);
  int high = 0;
  int ans = 0;
  REP(i,N) {
    cin >> M[i];
    if (high <= M[i] ) {
      high = M[i];
      ans++;
    }
  }
  cout << ans << endl;
}
      
    
  

Measured memory_bytes: 256
open System
open System.Collections.Generic
open System.Linq
open System

let Puts = Console.WriteLine : 'a -> unit
let Reads () = Console.ReadLine().Split()
let ReadDouble () = Reads() |> (fun x -> x.[0], x.[1])
let ReadTriple () = Reads() |> (fun x -> x.[0], x.[1], x.[2])
let ReadQuadruple () = Reads() |> (fun x -> x.[0], x.[1], x.[2], x.[3])

let FuncDouble f1 f2 (t1, t2) = (f1 t1, f2 t2)
let FuncTriple f1 f2 f3 (t1, t2, t3) = (f1 t1, f2 t2, f3 t3)
let FuncQuadruple f1 f2 f3 f4 (t1, t2, t3, t4) = (f1 t1, f2 t2, f3 t3, f4 t4)

let ReadIntTriple () = ReadTriple () |> FuncTriple int int int
let ReadIntDouble () = ReadDouble () |> FuncDouble int int

let ensmallen l = l % 1000000007L

let manhattan x y = abs (fst x - fst y) + abs (snd x - snd y)


let sayYESNO b = if b then Puts "YES" else Puts "NO"

// main code

let h, w = ReadIntDouble()

Seq.replicate (w+2) '#' |> String.Concat |> Console.WriteLine

for _ in 1..h do
    Console.Write "#"
    Console.ReadLine() |> Console.Write
    Console.WriteLine "#"

Seq.replicate (w+2) '#' |> String.Concat |>Console.WriteLine


Measured memory_bytes: 11348
int dist[100][100],freezer[100],I=1<<29,N,M,L,K,A,H,i,j,k,l;
W(){for(k=0;k<N;k++)for(i=0;i<N;i++)for(j=0;j<N;j++)if(dist[i][j]>dist[i][k]+dist[k][j])dist[i][j]=dist[i][k]+dist[k][j];}
int main(){for(;scanf("%d%d%d%d%d%d",&N,&M,&L,&K,&A,&H),N;){
	memset(dist,0,sizeof(dist));
	memset(freezer,0,sizeof(freezer));
	for(i=0;i<N;i++)for(j=i+1;j<N;j++)dist[i][j]=dist[j][i]=I;
	freezer[A]=freezer[H]=1;
	for(i=0;i<L;i++)scanf("%d",&j),freezer[j]=1;
	for(i=0;i<K;i++)scanf("%d%d%d",&j,&k,&l),dist[j][k]=dist[k][j]=l;
	W();
	for(i=0;i<N;i++)for(j=0;j<N;j++)if(!freezer[i]||!freezer[j]||dist[i][j]>M)dist[i][j]=I;
	W();
	l=dist[A][H];
	printf(l==I?"Help!\n":"%d\n",2*l-(l<M?l:M));
}exit(0);}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
#define INF -(1LL << 50)

int main() {
  int N;
  cin >> N;
  long a[3*N];
  for (int i=0; i<3*N; i++)
    cin >> a[i];
  priority_queue<int, vector<int>, greater<int>> f;
  priority_queue<int, vector<int>> l;
  long fsum[N+1], lsum[N+1], sum = 0, ans = INF;
  for (int i=0; i<N; i++) {
    f.push(a[i]);
    sum += a[i];
  }
  fsum[0] = sum;
  for (int i=0; i<N; i++) {
    f.push(a[N+i]);
    sum += a[N+i];
    sum -= f.top();
    f.pop();
    fsum[i+1] = sum;
  }
  sum = 0;
  for (int i=1; i<=N; i++) {
    l.push(a[3*N-i]);
    sum += a[3*N-i];
  }
  lsum[N] = sum;
  for (int i=1; i<=N; i++) {
    l.push(a[2*N-i]);
    sum += a[2*N-i];
    sum -= l.top();
    l.pop();
    lsum[N-i] = sum;
  }
  for (int i=0; i<=N; i++)
    ans = max(ans, fsum[i]-lsum[i]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5112
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int X;
	
	cin>>X;
	
	cout<<X/500 * 1000 + (X - X/500*500)/5*5<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 1000000
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};

/* ----------------------------------------------------------------------------------- */

void solve() {
	int n, k, ans = 0;
	cin >> n >> k;
	while(n > 0) {
		n /= k;
		ans++;
	}
	cout << ans << endl;
}

int main() {
	solve();

	// __test {
	// 	solve();
	// }
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a;
  cin>>n>>a;
  vector<int> x(n);
  for(int i=0;i<n;i++)
    cin>>x.at(i);
  vector<vector<vector<int64_t>>> c(n+1,vector<vector<int64_t>>(n+1,vector<int64_t>(n*a+1,0)));
  for(int i=0;i<n;i++)
    c[i][0][0]=1;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
      for(int k=0;k<=a*n;k++)
        c[i][j][k]=c[i-1][j][k]+(k>=x.at(i-1)?c[i-1][j-1][k-x.at(i-1)]:0);
  int64_t s=0;
  for(int i=1;i<=n;i++)
    s+=c[n][i][a*i];
  cout<<s<<endl;
}

Measured memory_bytes: 55120
import sys
def input():
	return sys.stdin.readline().strip()

N = 1407
K = 38

num_all = [[0]*K for _ in range(N)]

for i in range(K):
	num_all[0][i] = i + 1
num = 1
for i in range(K):
	for j in range(K - 1):
		num_all[num][0] = i + 1
		num += 1
num = K + 1
for i in range(1, K):
	for j in range(1, K):
		num_all[i][j] = num
		num += 1

for n in range(2, K + 1):
	for j in range(K - 1):
		for i in range(K - 1):
			num = K + 1 + j*(K - 1) + i
			loc = K + (n - 2)*(K - 1) + ((i + j*(n - 2))%(K - 1))
			num_all[loc][j + 1] = num


def list_print(A):
	length = len(A)
	for i in range(length - 1):
		print(A[i], end="")
		print(" ", end="")
	print(A[- 1])

list_print([N, K])
  
for i in range(N):
	list_print(num_all[i])

Measured memory_bytes: 59608
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

    int r;
    cin>>r;    
	
	cout<<(r*r);








    return 0;
}

Measured memory_bytes: 256