akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

std::vector<int> pre(1001*1001, -1);
bool flag = true;
//-------------------------------------------------------------------
int MAX_V = 1001*1001;
vvi G = vv(MAX_V, 0, 0, int);
vvi rG = vv(MAX_V, 0, 0, int);
vector<bool> used(MAX_V);
vector<int> cmp(MAX_V);
vector<int> vs;
void add_edge(int from, int to){ G[from].push_back(to), rG[to].push_back(from);}
void dfs(int v){
  used[v] = true;
  for(int i=0;i<G[v].size();i++) if(!used[G[v][i]]) dfs(G[v][i]);
  vs.push_back(v);
}
void rdfs(int v, int k){
  used[v] = true;
  cmp[v] = k;
  for(int i=0;i<rG[v].size();i++) {
    if(!used[rG[v][i]]) {
      rdfs(rG[v][i], k);
      flag = false;
    }
  }
}
int scc(int V){
  for(int i=0;i<MAX_V;i++) used[i] = false;
  vs.clear();
  for(int i=0;i<=V;i++) if(!used[i]) dfs(i);
  for(int i=0;i<MAX_V;i++) used[i] = false;
  int k = 0;
  for(int i=vs.size()-1;i>=0;i--) if(!used[vs[i]]) rdfs(vs[i], k++);
  return k;
}
std::vector<int> mpath(1001*1001, -1);

int f(int now){
  if(mpath[now]!=-1) return mpath[now];
  int d = 0;
  for(int i=0;i<G[now].size();i++) d = max(d, f(G[now][i]));
  d++;
  mpath[now] = d;
  return d;
}
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  vvi A = vv(N+1, N, 0, int);
  vector<int> nyu(1001*1001, 1);
  for(int i=1;i<=N;i++) for(int j=1;j<=N-1;j++) scanf("%d", &A[i][j]);
  for(int i=1;i<=N;i++) {
    for(int j=1;j<=N-2;j++) {
      add_edge(min(i,A[i][j])*1001+max(i,A[i][j]), min(i,A[i][j+1])*1001+max(i,A[i][j+1]));
      nyu[min(i,A[i][j+1])*1001+max(i,A[i][j+1])] = 0;
    }
  }
  scc(1001*1001);
  if(!flag){
    std::cout << -1 << '\n';
    return 0;
  }
  int ans = 0;
  for(int i=0;i<1001*1001;i++) if(nyu[i]==1) ans = max(f(i), ans);
  std::cout << ans << '\n';
  return 0;
}


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

int main()
{
    while(true)
    {
        long N; cin >> N;
        if(N == 0) return 0;
        string S; cin >> S;

        long a = (long)1 << 52;
        rep(i, S.size())
        {
            if(S[i] == '1')
            {
                a |= (long)1 << (51 - i);
            }
        }

        long sisu = 0;
        long kasu = a;
        long goal = (long)1 << 53;
        rep(i, 53)
        {
            long want = goal - kasu;
            long cnt = (want + a - 1) / a;

            //cout << "i=" << i << " cnt=" << cnt << endl;
            if(N < cnt)
            {
                kasu += a * N;
                break;
            }

            kasu += a * cnt;
            sisu++;
            N -= cnt;
            
            kasu >>= 1;
            a >>= 1;
        }

        cout << bitset<12>(sisu) <<  bitset<52>(kasu) << "\n";
    }
}



Measured memory_bytes: 3160
#include <iostream>
#include<algorithm>
#include<set>
#include<iterator>
#include<map>
#include<unordered_map>
#include<vector>
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define pb push_back
#define F first
#define S second

int32_t main() {
   
    string a,b;
    cin>>a>>b;
    
    string s = a+b;
    
    int n = stoi(s);
    
    int x = sqrt(n);
    
    if(x*x==n)
        cout<<"Yes";
    else
        cout<<"No";
    
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  map<string, int> mp;
  int n, m, sum = 0;
  cin >> n;
  rep(i,n)
  {
    string s;
    cin >> s;
    mp[s]++;
  }
  cin >> m;
  rep(i,m)
  {
    string s;
    cin >> s;
    mp[s]--;
  }
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    sum = max(sum, itr->second);
  }
  cout << sum;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
#define ll long long 
#define jaldi_chal  ios_base::sync_with_stdio(0); cin.tie(0);
#define tr(c,i) for(auto i=(c).begin(); i != (c).end(); i++)
#define REP(i,k) for( ll i=0;i<k;i++)
#define REW(i,a,b) for(ll i=a;i<=b;i++)
#define M 1000000007
#define F first
#define dbg(x)  cout<<#x<<" " <<x<<endl;
#define S second
#define inf 1e10
#define endl "\n"


int main() {
jaldi_chal
ll n,m;
cin>>n>>m;
ll a[n+1][m+1];

REW(i,1,n)
{
    REW(j,1,m)
    {
        char c;
        cin>>c;
        if(c=='.') a[i][j]=1;
        else a[i][j]=0;
      //  cout<<a[i][j]<<" ";
    }
   // cout<<endl;
}
ll dp[n+1][m+1];
memset(dp,0,sizeof(dp));
REW(i,1,n) {
    if(a[i][1]==0) break;
    dp[i][1]=1;
}
REW(i,1,m) 
{
    if(a[1][i]==0) break;
    dp[1][i]=1;
}
ll ans=0;

REW(i,2,n)
{
    REW(j,2,m)
    {
        if(a[i][j]==0) dp[i][j]=0;
        else{
            dp[i][j]=(dp[i][j-1]%M+dp[i-1][j]%M)%M;
        }
        //cout<<dp[i][j]<<" ";
    }
   // cout<<endl;
}
cout<<dp[n][m];

	return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include<cstring>
#define max(x,y) x>y?x:y
using namespace std;
const int maxn=1011111;
int f[maxn];
int d[maxn];
int find(int x)
{
    if(f[x]==x)
        return x;
 
    int r=find(f[x]);
    d[x]=d[f[x]]+d[x];
    return f[x]=r; 
}
int fix(int x,int y,int z)
{
    int fx=find(x);
    int fy=find(y);
    if(fx==fy)
        return z==d[y]-d[x];
    f[fy]=fx;
    d[fy]=d[x]+z-d[y];
    return 1;
}
int main()
{
    int n,m;
    int lose=1;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        f[i]=i;
    for(int i=1;i<=m;i++)
    {
        int x,y,z;
        cin>>x>>y>>z;
 
        if(lose)
            lose=fix(x,y,z);
 
    }
 
    if(lose)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, m;
    cin >> n >> m;
    vi ps(n+1, 0);
    int c = 0, p = 0;
    rep(i, m) {
        int tc;
        string tp;
        cin >> tc >> tp;
        if (ps[tc] < 0) continue;
        if (tp == "AC") {
            c++;
            p += ps[tc];
            ps[tc] = -1;
        }
        else ps[tc]++;
    }
    cout << c << ' ' << p << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int m[4][2];
int main()
{
  float l,r;
  while(cin >> l >> r){
    if(l > 1.1) m[0][0]++;
    else if(l > 0.6) m[1][0]++;
    else if(l > 0.2) m[2][0]++;
    else m[3][0]++;
    if(r > 1.1) m[0][1]++;
    else if(r > 0.6) m[1][1]++;
    else if(r > 0.2) m[2][1]++;
    else m[3][1]++;
  }
  int i;
  for(i=0;i<4;i++){
    cout << m[i][0] << " " << m[i][1] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
using namespace std;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int N;
    int a[200];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    double ave = 0;
    for(int i = 0; i < N; i++){
        ave += a[i];
    }
    ave /= N;

    int frame= N - 1;
    double min = abs(ave - a[N - 1]);
    for(int i = N - 1; i >= 0; i--){
        if(abs(ave - a[i]) <= min){
            min = abs(ave - a[i]);
            frame = i;
        }
    }
    cout << frame << endl;
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int64 mpow(int64 a, int64 b){
	if(b==0) return 1;
	if(b%2) return a*mpow(a, b-1)%mod;
	int64 ret = mpow(a, b/2);
	return ret*ret%mod;
}

int64 comb(int64 a, int64 b){
	int64 res = 1;
	REP(i, b){
		res = (res*(a-i)%mod*mpow(i+1, mod-2)%mod);
	}
	return res;
}

int main(void){
	int64 N, M;
	cin >> N >> M;
	int64 res = 1;
	for(int64 i = 2;i <= sqrt(M)+1;i++){
		int32 cnt = 0;
		while(M%i == 0){
			M/=i;
			cnt++;
		}
		res *= comb(N+cnt-1, cnt);
		res %= mod;
	}
	if(M != 1)
		res = res*N%mod;
	cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 1100
#define INF ((int)1e9+9)

int main(){
	int n, a[MAX], q, com, b, e;
	
	cin>>n;
	
	for(int i = 0; i < n; i++) cin>>a[i];
	
	cin>>q;
	
	for(int i = 0; i < q; i++){
		cin>>com>>b>>e;
		int ma = -INF, mi = INF;
		for(int j = b; j < e; j++) ma = max(a[j], ma), mi = min(a[j], mi);
		cout<<(com?ma:mi)<<endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define FO(i,a,b) for (int i = (a); i < (b); i++)

string s;
int main() {
    cin >> s;
    if (s.length() >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
        printf ("Yes\n");
    } else {
        printf ("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
    int N, K;
    cin >> N >> K;
    int num_kind_of_A;
    set<int> A;
    map<int, int> map_A;
    int require_num=0;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        if(map_A.count(a)){
            map_A[a]++;
        }
        else{
            map_A[a] = 1;
        }
        A.insert(a) ;
    }// complete set A
    int size_setA = map_A.size();
    if(size_setA <= K){
        require_num = 0;
    }
    else{
        int require_kid_num = size_setA - K;
        priority_queue<int, vector<int>, greater<int>> pq;  // 最小の要素を取り出すために pq を定義
        for(pair<int ,int> j : map_A){
            int num = j.second;
            pq.push(num);            // pq に map のAに対応する個数を挿入
        }
        for(int k=0;k<require_kid_num;k++){
            int incre ;
            incre = pq.top() ;
            require_num = require_num + incre;
            pq.pop();
        }
    }
    cout << require_num << endl;
}

Measured memory_bytes: 22808
n,m=list(map(int,input().split()))
l=0
r=10**5+1
for _ in range(m):
  ll,rr=list(map(int,input().split()))
  l=max(l,ll)
  r=min(r,rr)
print(r-l+1 if r-l+1>=0 else 0)

Measured memory_bytes: 3060
#include<stdio.h>
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int n,m,k,i,s=0,d[100010]={};
  scanf("%d %d %d",&n,&m,&k);
  for(i=0;i<n;i++)scanf("%d",&d[i+1]);
  d[n+1]=k+m;
  d[0]=-m;
  for(i=0;i<=n;i++)s+=MAX(0,d[i+1]-d[i]-m-m);
  printf("%d\n",s);
  return 0;
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

using namespace std::chrono;

int main(void)
{
    IOS
    const int A = 26;
    const int M = 1e3;
    const int TL = 1700;
    auto stime = system_clock::now();
    int D; cin >> D;
    vector<int> c(A);
    REP(i,A) cin >> c[i];
    vector<vector<int>> s(D,vector<int>(A));
    REP(i,D) REP(j,A) cin >> s[i][j];

    vector<int> last(A,-1);
    vector<int> ans(D);
    REP(i,D) {
        int mx = 0,a = -1;
        REP(j,A) {
            int tmp = (i-last[j])*c[j] + s[i][j];
            if (mx < tmp) {
                mx = tmp;
                a = j;
            }
        }
        ans[i]=a;
        last[a] = i;
    }
    auto calc = [&](const vector<int> &a){
        vector<int> l(A,-1);
        int score = 0;
        REP(i,D) {
            score += s[i][a[i]];
            l[a[i]] = i;
            REP(j,A) {
                score -= c[j]* (i-l[j]);
            }
        }
        return score;
    };

    int maxscore = calc(ans);

    random_device seed_gen;
    mt19937 engine(seed_gen());
    while(true) {
        auto time = system_clock::now();
        int t = duration_cast<milliseconds>(time-stime).count();
        if (t >= TL) break;

        REP(_,M) {
            vector<int> a(ans);
            int s1 = engine() % D;
            int s2 = engine() % D;
            swap(a[s1],a[s2]);
            int tmp = calc(a);
            if (maxscore < tmp) {
                swap(ans,a);
                maxscore = tmp;
            }
        }
    }

    REP(i,D) OUT(ans[i]+1)

    return 0;
}

Measured memory_bytes: 3628
from collections import deque

def new_color(s, i, rgb):
  for color in rgb:
    if color != s[i] and color != s[i + 1]:
      break
  return s[:i] + color * 2 + s[i + 2:]

def solve(s):
  length = len(s)
  monos = ["r" * length, "g" * length, "b" * length]
  if s in monos:
    print(0)
    return
  dic = {s:0}
  rgb = "rgb"
  que = deque()
  app = que.append
  pop = que.popleft
  que.append((s, 0))

  while que:
    colors, score = pop()
    score += 1
    temp = colors[0]

    for i in range(1, length):
      ci = colors[i]
      if ci != temp:
        new = new_color(colors, i - 1, rgb)

        if new in monos:
          print(score)
          return

        if new not in dic:
          dic[new] = score
          app((new, score))

      temp = ci

  print("NA")

def main():
  while True:
    s = input()
    if s == "0":
      break
    solve(s)

main()


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

#define N 1000000007

long pow(long m ,long n){
    
    if (n==0) return 1;
    
    if (n%2 == 0) return pow((m*m) % N, n/2) % N;
    else        return (pow((m*m) % N, n/2) * m) % N;
}


int main(){
    
    int m , n;
    long ans = 0;
    
    cin >> m >> n;
    
    ans = pow(m, n);
    
    printf("%ld\n", ans);
    
    return 0;
}

Measured memory_bytes: 1152
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

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

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

int main(){
  int N,x,y,z,cnt;
  cin>>N;
  int C[10100]={};

  for(x=1;x<=100;x++){
    for(y=1;y<=100;y++){
      for(z=1;(x*x+y*y+z*z+x*y+x*z+y*z)<=10010;z++){
        C[x*x+y*y+z*z+x*y+x*z+y*z]++;
      }
    }
  }
  for(int i=1;i<=N;i++){
    cout<<C[i]<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3668
#include <stdio.h>

int main(void) {
	
	int a, b, c;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if (a == b) printf("%d", c);
	else if (a == c) printf("%d", b);
	else if (b == c) printf("%d", a);
	
	return 0;
	
}

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

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

	for (int i = 0; i < n - 1; i++) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
	}

	for (int i = 0; i < n - 2; i++) {
		if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}

	cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200010


int main() {
	char a[N + 1];
	f(i, N + 1)a[i] = 0;
	int n, k;
	int x, y, z;
	int s, ans;
	bool v = true;
	ans = 0;
	scanf("%s", a);
	n = strlen(a);
	x = 1;
	y = 1;
	ans = 1;
	while(true){
      		if (x >= n)break;
		if (x < (n - 1)) {
			if (a[x] != a[x - 1]) {
				ans++;
				x++;
				y = 1;
}
			else {
				if (y == 1) {
					ans++;
					x += 2;
					y = 2;
				}
				else {
					ans++;
					x++;
					y = 1;
				}
			}
		}
		else {
			if (a[x] != a[x - 1])ans++;
			else if (y == 2)ans++;
			break;
		}
	}

	printf("%d\n", ans);


	return 0;
}

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

using namespace std;
using ll = long long;

int n;
ll ans;

int main(){
	cin >> n;
	vector<int> a(n), b(n), c(n);
	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; ++i) cin >> c[i];
	
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	
	for(int i = 0; i < n; ++i){
		ll x = lower_bound(a.begin(), a.end(), b[i])-a.begin();
		ll y = c.end()-upper_bound(c.begin(), c.end(), b[i]);
		ans += x * y;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

typedef long long ll;

ll N;
ll p[100000];

int main(){
    cin >> N;
    int c = 0;
    for(int i=0;i<N;i++) cin >> p[i];
    for(int i=0;i<N-1;i++){
        if(i+1 == p[i]){
            c++;
            ll n = p[i];
            p[i] = p[i+1];
            p[i+1] = n;
        }
    }
    if(p[N-1] == N) c++;
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#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> a(n);
  rep(i, n){
    cin >> a.at(i);
  }
  int count = 0;
  rep(i, n-2){
    int A = a.at(i+1) - a.at(i);
    int B = a.at(i+2) - a.at(i+1);
    if(A*B>0){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

#include <atcoder/all>
using namespace atcoder;

vector<int> dx = {0,0,1,-1};
vector<int> dy = {1,-1,0,0};

int main(){
    int n,m;
    cin >> n >> m;
    mf_graph<int> G(n*m+2);
    auto id = [&](int i,int j){return i+j*n;};
    vector<string> maze(n);
    rep(i,n) cin >> maze[i];
    int s = n*m;
    int t = n*m+1;
    rep(i,n)rep(j,m){
        if(maze[i][j]=='#') continue;
 
        if((i+j)%2==0) G.add_edge(s,id(i,j),1);
        else G.add_edge(id(i,j),t,1);
 
        rep(k,4){
            int new_i = i + dx[k];
            int new_j = j + dy[k];
            if(new_i<0||n<=new_i||new_j<0||m<=new_j) continue;
            if(maze[new_i][new_j]=='#') continue;
 
            if((i+j)%2==0) G.add_edge(id(i,j),id(new_i,new_j),1);
        }
    }
    cout << G.flow(s,t) << endl;

    auto edges = G.edges();

    for(auto e:edges){
        if(e.from == s|| e.to == t || e.flow == 0) continue;

        int i = e.from % n,j = e.from / n;
        int ii = e.to % n,jj = e.to / n;

        if(i+1==ii){
            maze[i][j] = 'v';
            maze[ii][jj] = '^';
        }else if(i-1==ii){
            maze[i][j] = '^';
            maze[ii][jj] = 'v';
        }else if(j+1==jj){
            maze[i][j] = '>';
            maze[ii][jj] = '<';
        }else{
            maze[i][j] = '<';
            maze[ii][jj] = '>';
        }
    }

    rep(i,n){
        cout << maze[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5564
import sys

R, C, K = map(int, sys.stdin.readline().split())

grid = [[0 for _ in range(C)] for _ in range(R)]
for _ in range(K):
    r, c, v = map(int, sys.stdin.readline().split())
    grid[r-1][c-1] = v

# r行目、c列目にいるときに、その行でアイテムをi個取得している場合の最大価値
dp0 = [[0 for _ in range(C+1)] for _ in range(R+1)]
dp1 = [[0 for _ in range(C+1)] for _ in range(R+1)]
dp2 = [[0 for _ in range(C+1)] for _ in range(R+1)]
dp3 = [[0 for _ in range(C+1)] for _ in range(R+1)]
# print(dp)
for r in range(R):
    for c in range(C):
        # 取らない
        dp0[r+1][c] = max((dp0[r][c], dp1[r][c], dp2[r][c], dp3[r][c]))
        dp1[r][c+1] = max(dp1[r][c], dp1[r][c])
        dp2[r][c+1] = max(dp2[r][c], dp2[r][c])
        dp3[r][c+1] = max(dp3[r][c], dp3[r][c])

        if grid[r][c] == 0:
            continue
        # 取る
        dp0[r+1][c] = max(dp0[r][c] + grid[r][c], dp0[r+1][c])
        dp0[r+1][c] = max(dp1[r][c] + grid[r][c], dp0[r+1][c])
        dp0[r+1][c] = max(dp2[r][c] + grid[r][c], dp0[r+1][c])

        dp1[r][c+1] = max(dp0[r][c] + grid[r][c], dp1[r][c+1])
        dp2[r][c+1] = max(dp1[r][c] + grid[r][c], dp2[r][c+1])
        dp3[r][c+1] = max(dp2[r][c] + grid[r][c], dp3[r][c+1])

# print(dp0)
# print(dp1)
# print(dp2)
# print(dp3)
# print(max((dp0[R][C], dp1[R][C], dp2[R][C], dp3[R][C])))
print(dp0[R][C-1])

Measured memory_bytes: 469224
#include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <sstream>

using namespace std;

const int N_MAX = 1000000;

void round_robin_scheduling(queue<pair<string, int> > q, int quantum){
  int cur_time = 0;
  pair<string, int> p_i;
  
  while(!q.empty()){
    p_i = q.front(); q.pop();

    int timediff = p_i.second - quantum;    
    if(timediff > 0){
      p_i.second -= quantum;
      q.push(p_i);
      cur_time += quantum;
    }
    else{
      cur_time += p_i.second;
      cout << p_i.first << " " << cur_time << endl;
    }
    
  }
}

int main(){
  int n, quantum;

  cin >> n >> quantum;
  pair<string, int> p_t;
  queue<pair< string, int> > q;
  
  for(int i=0; i<n; i++){
    cin >> p_t.first >> p_t.second;
    q.push(p_t);
  }
  
  round_robin_scheduling(q, quantum);
  return 0;
}



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

typedef long long int ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N, M, A, B, C, T;

mat calc(mat &X, mat &Y) {
    mat ret(X.size(), vec(Y[0].size()));

    int row = X.size();
    int colume = Y[0].size();
    if (X[0].size() != Y.size()) return ret;
    for (int i = 0; i < row; i++) {
        for (int j = 0; j < colume; j++) {
            for (int k = 0; k < X[i].size(); k++) {
                ret[i][j] += (X[i][k] * Y[k][j]) % M;
                ret[i][j] %= M;
            }
        }
    }

    return ret;
}

mat dfs(mat& X, int Times) {
    if (Times == 0) {
        mat ret(X.size(), vec(X[0].size()));
        for (int i = 0; i < X.size() && i < X[0].size(); i++) ret[i][i] = 1;
        return ret;
    }
    auto Y = dfs(X, Times / 2);
    auto YY = calc(Y, Y);
    if (Times % 2) {
        auto ret = calc(X, YY);
        return ret;
    } else {
        return YY;
    }
}

void solve() {
    mat d(N, vec(N));
    mat v(N, vec(1));
    for (auto& i : v) for (auto &j : i) cin >> j;
    for (int i = 0; i < N; i++) {
        d[i][i] = B;
        if (i + 1 < N) d[i+1][i] = A;
        if (i + 1 < N) d[i][i+1] = C;
    }

    auto d_start = dfs(d, T);
    auto ans = calc(d_start, v);

    for (int i = 0; i < N - 1; i++) cout << ans[i][0] << " "; cout << ans[N-1][0] << endl;
}

int main() {
    while (cin >> N >> M >> A >> B >> C >> T, A || B || C || N || M || T) solve();

    return 0;
}

Measured memory_bytes: 3224
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, n;std::cin >> n;
  set<ll> s;
  re(i, n){
    std::cin >> a;
    s.insert(a);
  }
  std::cout << (s.size()==n?"YES":"NO") << '\n';
  return 0;
}


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

int a[100001] = {0}, b[100001] = {0};

int main () {
    int n, m, temp;
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {cin >> temp; b[temp]++;}
    a[1] = b[1] == 0 ? 1 : 0;
    a[2] = b[2] == 0 ? (b[1] == 0 ? 2 : 1) : 0;
    for (int i = 3; i <= n; i++) if (!b[i]) a[i] = (a[i-1] + a[i-2]) % 1000000007;
    cout << a[n] << endl;
    return 0;
}

Measured memory_bytes: 4356
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const int INF = 1e9;

struct Edge {
    int from, to, cost;
};

int main() {
    int N, M; cin >> N >> M;
    vector<Edge> edge(M);
    vector<vector<int>> dist(N, vector<int>(N, INF));
    for (int i = 0; i < M; i++) {
        int a, b, c; cin >> a >> b >> c; a--; b--;
        edge[i].from = a; edge[i].to = b; edge[i].cost = c;
        dist[a][b] = dist[b][a] = c;
    }

    // ワーシャルフロイド法
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < N; k++) {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < M; i++) {
        if (edge[i].cost != dist[edge[i].from][edge[i].to]) ans++;
    }

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

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


int main()
{
	int M, D;
	cin >> M >> D;
	int ans = 0;
	for( int i = 1; i <= M; i++ ) {
		for( int j = 2; j <= D; j++ ) {
			int d10 = j / 10;
			if( d10 < 2 ) continue;
			int d1 = j % 10;
			if( d1 < 2 ) continue;
			if( d1 * d10 == i ) ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int a[n+1],b[n+1];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) cin>>b[i];
  a[n]=b[n]=0;
  for(int i=0;i<n;i++)
    a[n]^=a[i],b[n]^=b[i];
  map<int,int> x,y;
  for(int i=0;i<=n;i++) x[a[i]]++;
  for(int i=0;i<=n;i++) y[b[i]]++;
  if(x!=y){
    cout<<-1<<endl;
    return 0;
  }
  
  vector<int> v(n+1);
  for(int i=0;i<=n;i++) v[i]=a[i];
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  map<int,int> m;
  for(int i=0;i<(int)v.size();i++) m[v[i]]=i;
  vector<int> G[v.size()];
  int used[v.size()];
  memset(used,0,sizeof(used));
  for(int i=0;i<=n;i++)
    if(a[i]!=b[i]) G[m[a[i]]].push_back(m[b[i]]);
  int cnt=0;
  for(int i=0;i<(int)v.size();i++){
    if(used[i]) continue;
    if(G[i].empty()) continue;
    cnt++;
    queue<int> q;
    q.push(i);
    while(!q.empty()){
      int k=q.front();q.pop();
      if(used[k]) continue;
      used[k]=1;
      for(int u:G[k])
	if(!used[u]) q.push(u);
    }
  }
  if(G[m[a[n]]].empty()) cnt++;
  if(a[n]!=b[n]){
    if(G[m[b[n]]].empty()) cnt++;
    else cnt--;
  }
  int ans=0;
  for(int i=0;i<(int)v.size();i++) ans+=G[i].size();
  cout<<ans+cnt-1<<endl;
  return 0;
}


Measured memory_bytes: 27648
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)2e9 + 7)
#define INF ((int)2e9)
#define INFLL ((LL)2e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (2 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 2, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 1) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 2;
    LL sum = a;
    while(b){
        if(b&2)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

PII operator+(const PII &a, const PII &b){
    return PII(a.first + b.first, a.second + b.second);
}

vector<vector<int> > xc(100001), yc(100001);

PII func(PII p){
    PII res(0, 0);
    if(!xc[p.first].empty()){
        vector<int> line = xc[p.first];
        xc[p.first].clear();
        ++res.first;
        for(auto &i:line){
            res = res + func(PII(p.first, i));
        }
    }
    if(!yc[p.second].empty()){
        vector<int> line = yc[p.second];
        yc[p.second].clear();
        ++res.second;
        for(auto &i:line){
            res = res + func(PII(i, p.second));
        }
    }
    return res;
}

signed  main(){
    string s="aiueo";
    char d;
    cin >> d;
    cout <<(s.find(d)!=-1?"vowel":"consonant")<<endl;
    return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    using ii = pair<int, int>;
    int n;
    cin >> n;
    vector<ii> as;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        as.emplace_back(a, b);
    }
    sort(as.begin(), as.end());
    for (int i = 0; i < n; i++) {
        cout << as[i].first << " " << as[i].second << endl;
    }
}


Measured memory_bytes: 3880
def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list


a, b, c = map(int, input().split())
div = make_divisor_list(c)
cnt = 0
for i in range(a, b + 1):
    if i in div:
        cnt += 1

print(cnt)


Measured memory_bytes: 5600
import math

a,b,x = list(map(int,input().split()))


l = x/(a*a)

if l<=b/2.0:
    f = b**2.0/(2.0*a*l)
else:
    f = 2.0*(b-l)/a
ans = math.degrees(math.atan(f))
print(ans)

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

int main() {
    int N;
    cin >> N;
    vector<string> s(N);
    unordered_map<string, ll> mp;
    rep(i, N) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
        mp[s[i]]++;
    }

    ll ans = 0;
    rep(i, N) {
        string tmp = s[i];
        if (mp[tmp] > 0) ans += mp[tmp]-1;
        mp[tmp]--;
    }

    cout << ans << endl;

}


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

int main() {
	string s, t;
	cin >> s;
	cin >> t;
	int m = s.size();
	int n = t.size();
	int cols = m+1, rows = n+1;
	int dp[n+1][m+1];
	for(int i = 0; i < rows; i++){
		dp[i][0] = 0;
	}
	for(int i = 0; i < cols; i++){
		dp[0][i] = 0;
	}
	
	string ans = "";
	for(int i = 1; i < rows; i++){
		for(int j = 1; j < cols; j++){
			if (s[j-1] == t[i-1]){
				dp[i][j] = dp[i-1][j-1] + 1;
			}
			else{
				if (dp[i-1][j] > dp[i][j-1]){
					dp[i][j] = dp[i-1][j];
				}
				else{
					dp[i][j] = dp[i][j-1];
				}
			}
		}
	}
	//cout << "\n" << rows << " " << cols << "\n\n";
	/*
	for(int i = 0; i < rows; i++){
		for(int j = 0; j < cols; j++)
		    cout << dp[i][j] << " ";
		cout << "\n";
	}
	*/
	int i = rows - 1, j = cols - 1;
	while(i > 0 && j > 0){
		if (s[j-1] == t[i-1]){
			ans = s[j-1] + ans;
			i--;
			j--;
		}
		else{
			if (dp[i-1][j] > dp[i][j-1]){
				i = i-1;
			}
			else{
				j = j-1;
			}
		}
		//cout << "i, j, ans = " << i << " " << j << " " << ans << "\n";
	}
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 38808
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

int findDigitSum(int n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}

int main(void){
    int n;cin>>n;
    int A=0,B=0;
    int a[n];for(int i=0;i<n;i++){cin>>a[i];}
    sort(a,a+n,greater<int>());
    for(int i=0;i<n;i++){
        if(i%2==0)A+=a[i];
        else B+=a[i];
    }

    cout<<A-B<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
typedef long long ll;

int ft_sqrt(int nb)
{
	int i = 1;
	int cnt = 0;
	while (i <= nb)
	{
		if (i % 2)
		{
			nb -= i;
			cnt++;
		}
		i++;
	}
	// if (nb == 0)
		return cnt;
	// return 0;
}

int main()
{
	int x;
	scanf("%d", &x);
	int max = 0;
	int j,k,i = 1;
	int n = 1;
	while (i <= x)
	{
		// printf("%d : %d\n", i, ft_sqrt(i));
		j = 0;
		while (j <= sqrt(i))
		{
			n = 1;
			k = 0;
			while (k < x)
			{
				n *= j;
				if (n == i)
				{
					if (i > max)
						max = i;
					break ;
				}
				k++;
			}
			j++;
		}
		i++;
	}
	printf("%d", max);
	return (0);
}

Measured memory_bytes: 128
<?php
fscanf(STDIN,"%d",$n);
for($i = 1; $i <= $n; $i++){
	if($i % 2 !== 0){
      $oddNum[] = odd;
    }elseif($i % 2 === 0){
      $evenNum[] = even;
    }
}
$oddResult = count($oddNum);
$probability = (int)$oddResult/(int)$n;
echo $probability;
  ?>

Measured memory_bytes: 3700
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int N = sc.nextInt();
    long T = sc.nextInt();
    long[] t = sc.nextLongList(N);
    
    long now = 0;
    for (int i = 1; i < N; i ++) {
      now += Math.min(T, t[i] - t[i - 1]);
    }
    now += T;
    System.out.println(now);
  }

}


class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 25084
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    vector<vector<ll>> a(2000,vector<ll>(2000,0));
    ll n;
    cin>>n;
    for(int i=0;i<n;i++){
        ll x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        a[x1][y1]++;
        a[x1][y2]--;
        a[x2][y1]--;
        a[x2][y2]++;
    }
    for(int i=0;i<2000;i++){
        for(int t=1;t<2000;t++){
            a[i][t]+=a[i][t-1];
        }
    }
    ll ans=0;
    for(int i=0;i<2000;i++){
        for(int t=1;t<2000;t++){
            a[t][i]+=a[t-1][i];
        }
    }
    for(int i=0;i<2000;i++){
        for(int t=0;t<2000;t++){
            ans=max(ans,a[i][t]);
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
}



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

using namespace std;

int main() {
    int a, b, c;

    cin >> a >> b >> c;

    if (((a < c) && (c < b)) || ((b < c) && (c < a)))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 256
N,X,Y=map(int,input().split())
answers=[0]*(N-1)
for i in range(1,N+1):
    numbers=[a for a in range(1,N+1) if a!=i]
    for j in numbers:
        answer=min(abs(i-j),abs(X-i)+1+abs(j-Y),abs(i-Y)+1+abs(j-X))
        answers[answer-1]+=1
for a in answers:
    print(a//2)
    

Measured memory_bytes: 54364
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N; cin >> N;
  vector<int> A(N), B; for (int &a: A) cin >> a; B = A, sort(rbegin(B), rend(B));
  for (int a : A) cout << B[a == B[0]] << "\n";}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define fr(i,n) for(i = 0; i <n; i++)
#define rep(i,n) for(i = 1; i <= n; i++)
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>
#define intCeil(a,b) ((a)+(b)-1)/(b)

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int main()
{
    fastinput;
    LL n,i,j,k,t,temp,tc;
    string s;
    cin>>s;
    LL cnt=1;
    if(s=="RRR")
    {
        cnt=3;
    }
    else if(s=="RRS" || s=="SRR")
    {
        cnt=2;
    }
    else if(s=="SSS")
    {
        cnt=0;
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3648
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  string S;

  cin >> S;

  if (S[0] == S[1] && S[1] == S[2])
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string a[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string s;
  cin>>s;
  rep(i,7){
    if(s==a[i]){
      cout<<7-i<<endl;
    }
  }
  
	  
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rrepn(i, n) for (int i = ((int)(n)); i > 0; --i)
#define SZ(x) ((int)(x).size())
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(std::vector<long long> x) {
    rep(i, 5) {
        if (x[i] == 0) cout << i + 1 << endl;
    }
}

int main() {
    std::vector<long long> x(5);
    for (int i = 0; i < 5; i++) {
        scanf("%lld", &x[i]);
    }
    solve(std::move(x));
    return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}



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

    int n; cin >> n;
    vll a(n); REP(i, n) cin >> a[i];
    ll total = accumulate(ALL(a), 0ll);

    a.resize(2 * n);
    REP(i, n) a[i + n] = a[i];

    auto check = [&](ll x) {
        // 大きさx以上を3つ切り出せるか?
        int m = 0, r = 0;
        ll suml = 0, sumr = 0;
        REP(l, n) {
            while (m < 2 * n and suml < x) suml += a[m], sumr -= a[m], ++m;
            while (r < 2 * n and sumr < x) sumr += a[r], ++r;
            if (suml < x or sumr < x) break;
            if (total - suml - sumr >= x) return true;
            suml -= a[l];
        }
        return false;
    };

    ll left = 0, right = total / 3 + 1;
    while (right - left > 1) {
        ll mid = (left + right) / 2;
        (check(mid) ? left : right) = mid;
    }
    cout << left << endl;

    return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 2e5+10;
const int INF = 1e7;

string S;
int dp[1<<26];

ll solve() {
    REP (i, 1<<26) dp[i] = INF;

    int h = 0;
    REP (i, S.size()) {
        h ^= 1<<(S[i]-'a');
        if (__builtin_popcount(h) <= 1) {
            dp[h] = 1;
            continue;
        }
        dp[h]++;
        REP (j, 26) CHMIN(dp[h], dp[h^(1<<j)]+1);
    }
    return dp[h];
}

int main() {
    cin >> S;
    cout << solve() << endl;
}

Measured memory_bytes: 262660