akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout << x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

const ll MOD = 1e9 + 7;
const int INF = 55;
ll dp [INF] [INF * INF];

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->


int main()
{

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

    IOS;

   string s;
   cin>>s;

   ll ans1 = 0, ans2=0;

   loop(i,s.length())
   {
     if(s[i]== 'A') {
        ans1 = i;
        break;
     }

     
   }


   for(int i=s.length()-1; i>=0; i--)
   {
     if(s[i] == 'Z')
     {
        ans2 = i;
        break;
     }
   }

   cout<<ans2-ans1+1<<endl;


}


Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;

int N;
vector<int> A;

int main(void) {
	cin >> N;
	A.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i];

	sort(A.begin(), A.end(), greater<int>());
	int Alice = 0;
	int Bob = 0;
	for (int i = 0; i < N; ++i) {
		if (i % 2 == 0)
			Alice += A[i];
		else
			Bob += A[i];
	}
	int ans = Alice - Bob;

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

const int INF = 100000000;

struct edge {
  int to, cap, rev;
};

class FordFolkerson {
 public:
  FordFolkerson(int n) {
    N = n;
    G = vector<vector<edge> >(n, vector<edge>());
    used = vector<bool>(n, false);
  }

  void add_edge(int from, int to, int cap) {
    G[from].push_back((edge{to, cap, (int)G[to].size()}));
    G[to].push_back((edge{from, 0, (int)G[from].size() - 1}));
  }

  int max_flow(int s, int t) {
    int flow = 0;
    while (true) {
      clear_used();
      int f = dfs(s, t, INF);
      if (f == 0) {
        break;
      }
      flow += f;
    }
    return flow;
  }

 private:
  vector<vector<edge> > G;
  vector<bool> used;
  int N;
  void clear_used() {
    for (int i = 0; i < N; i++) used[i] = false;
  }

  int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
      edge &e = G[v][i];
      if (!used[e.to] && e.cap > 0) {
        int d = dfs(e.to, t, min(f, e.cap));
        if (d > 0) {
          e.cap -= d;
          G[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }
};

int main() {
  int v, e;
  cin >> v >> e;
  FordFolkerson ff(v);
  for (int i = 0; i < e; i++) {
    int u, v, c;
    cin >> u >> v >> c;
    ff.add_edge(u, v, c);
  }
  cout << ff.max_flow(0, v - 1) << endl;
}


Measured memory_bytes: 3180
#include "bits/stdc++.h"

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    size_t N, K;
    cin >> N >> K;
    long double res = 0;
    long double base = 1. / (double) N;
    for (int64_t i = 1; i <= N; ++i) {
        int64_t norm = i;
        long double half = 1.;
        while (true) {
            if (norm >= K) {
                break;
            }
            norm *= 2;
            half *= 0.5;
        }
        res += base * half;
    }
    cout << fixed << setprecision(12);
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    int n;
    cin >> n;
    vector <int> a(n), b(n);
    for (int i = 0; i < n; ++i) 
        cin >> a[i];
    for (int i = 0; i < n; ++i)
        cin >> b[i];

    auto wa = a;
    auto wb = b;
    sort(all(wa));
    sort(all(wb));
    for (int i = 0; i < n; ++i) {
        if (wa[i] > wb[i]) {
            cout << "No" << endl;
            exit(0);
        }   
    }
    for (int i = 1; i < n; ++i) {
        if (wa[i] <= wb[i - 1]) {
            cout << "Yes" << endl;
            exit(0);
        }   
    }   
    vector <ii> a1, b1;
    for (int i = 0; i < n; ++i) {
        a1.app(mp(a[i], i));
        b1.app(mp(b[i], i));
    }
    sort(all(a1));
    sort(all(b1));

    vector <int> p(n);
    for (int i = 0; i < n; ++i)
        p[a1[i].s] = b1[i].s;

    int cyc = 0;
    vector <bool> used(n);
    for (int i = 0; i < n; ++i) {
        if (!used[i]) {
            cyc++;
            int u = i;
            while (!used[u]) {
                used[u] = 1;
                u = p[u];
            }   
        }   
    }   
    if (cyc == 1) {
        cout << "No" << endl;
    }   
    else {
        cout << "Yes" << endl;
    }   
}

Measured memory_bytes: 10216
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>

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

const long long INF = 1LL << 60;


int main() {
  int N, W;
  cin >> N >> W;
  vector<ll> w(N);
  vector<ll> v(N);
  vector<vector<ll> > dp(N+10, vector<ll>(W+10, 0));

  rep(i, N){
    cin >> w[i] >> v[i];
  }

  for(int i = 0; i < N; i++){
    for (int sum_w = 0; sum_w <= W; sum_w++) {
      // i 番目の品物を選ぶ場合
      if (sum_w - w[i] >= 0) {
          dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - w[i]] + v[i]);
      }

      // i 番目の品物を選ばない場合
      dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w]);
    }
  }

  cout << dp[N][W] << endl;

}


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

using namespace std;

int N;
double* heads;
double* tails;
double* p;

void getfactorials()
{
    heads[0] = 1;
    tails[0] = 1;
    for(int i=1; i <= N; i++)
    {
        heads[i] = p[i] * heads[i-1];
        tails[i] = (1 - p[i]) * tails[i-1];
    }
}


int main()
{
    cin>>N;
    double result = 0;
    int noOfHeads = N-1;
    int noOfTails = 1;

    p = new double[N+1];

    for(int i=1; i <= N; i++)
    {
        cin>>p[i];
    }
    p[0] = 1;

    heads = new double[N+1];
    tails = new double[N+1];
    getfactorials();

    double dp[N][N];
    dp[0][0] = 0;

    for(int i=1; i < N; i++){
        dp[i][0] = heads[i];
        dp[0][i] = tails[i];
    }

    for(int i=1; i < N; i++){
        for(int j=1; j < N; j++){
            dp[i][j] = dp[i-1][j] * p[i+j] + dp[i][j-1] * (1 - p[i+j]);
        }
    }

//    cout<<endl;
//    for(int i=0; i < N; i++){
//        for(int j=0; j < N; j++){
//            cout<<dp[i][j]<<" ";
//        }
//        cout<<endl;
//    }
//    cout<<endl;

    result += heads[N];
    while(noOfHeads > noOfTails){
        result += dp[noOfHeads][noOfTails];
        noOfHeads--;
        noOfTails++;
    }
    printf("%.10f", result);

    return 0;
}

Measured memory_bytes: 74056
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  while(1){
    cin >> x >> y;
    if ( x == 0 && y==0 ) {
        break;
    }
    if (x<y) {
        cout << x << " " << y << endl;
    } else {
        cout << y << " " << x << endl;
    }
  }
}


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

int w,h;
vector<vector<int> > m;
int dx[] = {0, 0,1,-1,1, 1,-1,-1};
int dy[] = {1,-1,0, 0,1,-1, 1,-1};

void dfs(int y, int x){
  m[y][x] = 0;
  
  for(int i=0; i<8; i++){
    int nx = x + dx[i];    
    int ny = y + dy[i];
    if(nx >= w || nx < 0 || ny >= h || ny < 0) continue;
    if(m[ny][nx] == 1)
      dfs(ny,nx);
  }

}



int main(){

  while(1){
    cin >> w >> h;
    if(!w and !h) break;

    m = vector<vector<int> >(h,vector<int>(w));
    
    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
	cin >> m[i][j];
      }
    }

    int ans = 0;
    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
	if(m[i][j] == 1){
	  dfs(i,j);
	  ans++;
	}
      }
    }
    cout << ans << endl;
  }

}

Measured memory_bytes: 1308
n,m = map(int,input().split())
map_li = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    map_li[a].append(b)
    map_li[b].append(a)

ans_li = [-1]*n
queue=[0]
visited = [False]*n

while queue:
    x = queue.pop(0)
    for g in map_li[x]:
        if visited[g]==False:
            queue.append(g)
            if ans_li[g]==-1:
                ans_li[g]=x
                visited[g]=True 
if -1 in ans_li[1:]:
    print('No')
else:
    print('Yes')
    for ans in ans_li[1:]:
        print(ans+1)

Measured memory_bytes: 35144
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>










int h,w,t,t2,c[30];
char a;




void solve()
{
	for(int i=0;i<26;i++)c[i]=0;
	cin>>h>>w;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin>>a;
			c[a-'a']++;
		}
	}
	if(h%2==0&&w%2==0)
	{
		for(int i=0;i<26;i++)
		{
			if(c[i]%4!=0)
			{
				cout<<"No\n";
				return;
			}
		}
		cout<<"Yes\n";
	}
	else
	{
		t=(h/2)*(w/2);
		for(int i=0;i<26;i++)
		{
			t2=c[i]/4;
			if(t2>=t)
			{
				c[i]-=4*t;
				t=0;
				break;
			}
			else
			{
				c[i]-=4*t2;
				t-=t2;
			}
		}
		if(t>0)
		{
			cout<<"No\n";
			return;
		}
		t=0;
		for(int i=0;i<26;i++)if(c[i]%2==1)t++;
		if(t==0)
		{
			if(h%2==1&&w%2==1)cout<<"No\n";
			else cout<<"Yes\n";
		}
		else if(t==1&&h%2==1&&w%2==1)cout<<"Yes\n";
		else cout<<"No\n";
	}
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    // ios::sync_with_stdio(false);
    // cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int d;
    cin >> d;
    vi  c(26);
    REP(i, 26) cin >> c[i];
    vvl s(d, vl(26));
    REP(i, d) REP(j, 26) cin >> s[i][j];

    vi last(26);
    ll ans = 0;
    vi a(d);
    REP(i, d) {
        ll ans2 = -LINF;
        ll ans_i = -1;
        REP(x, 26) {
            ll tmp = s[i][x];
            REP(j, 26) {
                if (x != j) tmp -= c[j] * ((i + 1) - last[j]);
            }
            if (chmax(ans2, tmp)) ans_i = x;
        }
        last[ans_i] = i + 1;
        ans += ans2;
        // cout << ans_i + 1 << endl;
        a[i] = ans_i + 1;
    }
    mt19937 mt{ random_device{}() };
    uniform_int_distribution<int> dist_d(1, d);
    uniform_int_distribution<int> dist_c(1, 26);
    REP(_, 200000) {
        vi lst(26);
        ll ans_n = 0;
        int x = dist_d(mt);
        int y = dist_c(mt);
        REP(i, d) {
            int t = a[i];
            if (x - 1 == i) t = y;
            ans_n += s[i][t - 1];
            lst[t - 1] = i + 1;
            REP(j, 26) if (t - 1 != j) ans_n -= c[j] * ((i + 1) - lst[j]);
        }

        if (ans_n > ans) {
            a[x - 1] = y;
            ans = ans_n;
        }
    }
    printlnv(a);
}


Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int n, k;
  cin >> n >> k;

  ll ans = pow(n / k, 3);
  if (k % 2 == 0) {
    ans += pow((n / (k / 2)) - (n / k), 3);
  }

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


Measured memory_bytes: 256
# 3:57-
class Array
  def abs; map{|k| k.abs } end
  def diff; s = self[0]; self[1...(self.size)].map{|k|d=k-s; s=k; d} end
end

n, k = gets.to_s.split.map{|t| t.to_i }
a    = gets.to_s.split.map{|t| t.to_i }.sort

if a.include?(k)
  puts "POSSIBLE"
  exit
end

# s = 10 ** 9
# l = 1
# a.each do |t|
#   s = t if s > t
#   l = t if l < t
# end

s = a[0]
l = a[-1]

d = a.diff
d.delete(0)
d = d.abs.uniq.sort

s = d[0] if d.any? && s > d[0]


while l % s > 0
  
  break
  
end

puts k % s == 0 && k <= l ? "POSSIBLE" : "IMPOSSIBLE"


Measured memory_bytes: 12928
#include <iostream>
#include <cstring>

using namespace std;
int u[200001],v[200001],vis[200001];
int first[200005],nextI[200005];

int main()
{
    int n,m,k,kk,flag=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        first[i]=-1;
    for(int i=0;i<m;i++)
    {
        cin>>u[i]>>v[i];
        nextI[i]=first[u[i]];
        first[u[i]]=i;
    }
    k=first[1];
    while(k!=-1)
    {
        kk=first[v[k]];
        while(kk!=-1)
        {
            if(v[kk]==n)flag=1;
            kk=nextI[kk];
        }
        k=nextI[k];
    }
    if(flag)cout<<"POSSIBLE";
    else cout<<"IMPOSSIBLE";
}


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

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

Measured memory_bytes: 2560
L = "qwertasdfgzxcvb"

while 1:
    x = raw_input()
    if x == "#":
        break
    lst = []
    ans = 0
    for i in range(len(x)):
        if x[i] in L:
            lst.append("L")
            if i != 0:
                if lst[i-1] == "R":
                    ans += 1
        else:
            lst.append("R")
            if i != 0:
                if lst[i-1] == "L":
                    ans += 1
    print ans

Measured memory_bytes: 6296
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>


size_t ceil_pow2(size_t n)
{
    size_t res = 1;
    while (res < n) res <<= 1;
    return res;
}

template<class M, class F>
class SegTree
{
    size_t N;
    F f;
    std::vector<M> a;

    M query_r(size_t L, size_t R, size_t k, size_t l, size_t r)
    {
        if (r <= L || R <= l)
            return a[0];
        else if (L <= l && r <= R)
            return a[k];
        else
        {
            size_t c = l + (r - l) / 2;
            M m1 = query_r(L, R, 2*k  , l, c);
            M m2 = query_r(L, R, 2*k+1, c, r);
            return f(m1, m2);
        }
    }

public:

    explicit SegTree(size_t n, F f, M e)
    : N(ceil_pow2(n)), f(f), a(2 * N, e)
    {}
    
    template<class InItr>
    explicit SegTree(InItr first, InItr last, F f, M e)
    : SegTree(std::distance(first, last), f, e)
    {
        size_t i = 0;
        InItr it = first;
        while (it != last)
        {
            update(i++, *it++);
        }
    }

    void update(size_t i, M x)
    {
        i += N;
        a[i] = x;
        
        for (size_t ii = i / 2; ii > 0; ii /= 2)
        {
            a[ii] = f(a[2*ii], a[2*ii+1]);
        }
    }

    M query(size_t L, size_t R)
    {
        return query_r(L, R, 1, 0, N);
    }

};

/*
template<class InItr>
auto make_segtree_min(InItr first, InItr last)
{
    using NumT = typename std::iterator_traits<InItr>::value_type;
    const NumT &(*fmin)(const NumT&, const NumT&) = std::min;
    const NumT e = std::numeric_limits<NumT>::max();
    return SegTree(first, last, fmin, e);
}
*/

int main()
{
    int n, q;
    std::cin >> n >> q;

    int (*fmin)(int,int) = [](int a, int b){ return std::min(a, b); };
    SegTree<int, decltype(fmin)> st(n, fmin, 2147483647);

    for (int iq = 0; iq < q; ++iq)
    {
        int com, x, y;
        std::cin >> com >> x >> y;
        if (com == 0)
        {
            st.update(x, y);
        }
        else
        {
            std::cout << st.query(x, y+1) << std::endl;
        }
        
    }
}



Measured memory_bytes: 3892
#include <stdio.h>
int main(void){
  int N;
  int i;
  int s=0;
  
  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    int l,r;
    int a=0;
    scanf("%d %d",&l,&r);
    a=r-l+1;
    s=s+a;
  }
  
  printf("%d",s);
  
  return 0;
}

Measured memory_bytes: 1716
open System

let N = stdin.ReadLine()|>int
let H = stdin.ReadLine().Split()|>Array.map int
[<EntryPoint>]
let main argv =
    [for i in [0..N-1] do yield (if (H.[i]>=([for j in [0..i] do yield H.[j]]|>List.max)) then 1 else 0)]
    |>List.sum
    |>stdout.WriteLine
    0

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

int main(){
    string S;
    cin >> S;
    int N=S.length();
    int i=0,j;
    int check=0;

    while(check==0){
        j=0;
        i++;
        while(1){
            if(S[j]!=S[(N/2-i+j)])break;
            j++;
            if(j==N/2-i){
                check=1;
                break;
            }
        }
    }

    cout << 2*j << endl;

    return 0;
}

Measured memory_bytes: 3560
void main() {
  problem();
}

void problem() {
  auto a = scan!long;

  long solve() {
    return a == 0 ? 1 : 0;
  }

  solve().writeln;
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

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


Measured memory_bytes: 2736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n;
    cin >> n;

    ll a[n];
    vector<ll> p;
    vector<ll> m;

    rep(i, 0, n){
        cin >> a[i];
        if(a[i] >= 0){
            p.push_back(a[i]);
        }else{
            m.push_back(a[i]);
        }
    }


    sort(p.begin(), p.end(), greater<ll>());
    sort(m.begin(), m.end());

    pair<ll, ll> ans[n - 1];
    rep(i, 0, n - 1){
        if(p.size() == 0){
            ans[i] = pair<ll, ll>(m[m.size() - 1], m[m.size() - 2]);
            p.push_back(m[m.size() - 1] - m[m.size() - 2]);
            m.pop_back();
            m.pop_back();
        }else if(m.size() == 0){
            ans[i] = pair<ll, ll>(p[p.size() - 1], p[p.size() - 2]);
            m.push_back(p[p.size() - 1] - p[p.size() - 2]);
            p.pop_back();
            p.pop_back();
        }else if(p.size() > m.size()){
            ans[i] = pair<ll, ll>(m[m.size() - 1], p[p.size() - 1]);
            m[m.size() - 1] = m[m.size() - 1] - p[p.size() - 1];
            p.pop_back();
        }else{
            ans[i] = pair<ll, ll>(p[p.size() - 1], m[m.size() - 1]);
            p[p.size() - 1] = p[p.size() - 1] - m[m.size() - 1];
            m.pop_back();
        }
    }

    cout << p[0] << endl;
    rep(i, 0, n - 1){
        cout << ans[i].first << " " << ans[i].second << endl;
    }

    return 0;
}


Measured memory_bytes: 5108
def solve():
    n = int(input())
    h =[]
    for i in range(n):
        w = input()
        if i == 0:
            h.append(w)
            continue
        if w in h:
            print('No')
            exit()
        if h[i-1][-1] != w[0]:
            print('No')
            exit()
        h.append(w)
    print('Yes')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9128
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B, C = get_ints

if A * C < B
  puts C
else
  puts B/A
end


Measured memory_bytes: 14460
import java.util.*;

/**
 * B
 */
public class Main {

    public void run() {

        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int[] A = new int[H+1];

        for(int i=1; i<=H; i++) {
            A[i] = sc.nextInt();
        }

        for(int i=H/2; i>=1; i--) {
            maxHeapify(A, i);
        }

        for(int i=1; i<=H; i++) {

            if (i == H) {
                System.out.println(" "+A[i]);
                break;
            }
            System.out.print(" "+A[i]);

        }


    }

    protected void maxHeapify(int[] A, int i) {

        int H = A.length-1;

        int l = left(i);
        int r = right(i);

        int largest;

        if(l<=H && A[l]>A[i]) {
            largest = l;
        } else {
            largest = i;
        }

        if(r<=H && A[r]>A[largest]) {
            largest = r;
        }

        if(largest != i) {

            int tmp = A[i];

            A[i] = A[largest];
            A[largest] = tmp;

            maxHeapify(A, largest);

        }
        
    }

    protected int left(int i) {

        int res = i*2;

        return res;
    }

    protected int right(int i) {

        int res = i*2+1;

        return res;
    }

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


Measured memory_bytes: 166060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] P = new int[N];
		for(int i=0; i<N; i++) {
			P[i] = sc.nextInt();
		}
		sc.close();
		int a = 0;
		int b = P[0];
		for(int i=0; i<N; i++) {
			if(P[i] <= b) {
				a++;
				b = P[i];
			}
		}
		System.out.println(a);
	}

}

Measured memory_bytes: 64536
def array_integer(a)
	0.upto(a.count) {|x|
		a[x] = a[x].to_i
	}
	return a
end

eof = false

until eof do
	h,w = array_integer(STDIN.gets.split(" "))
	
	if h == 0 && w == 0 then
		return
	end

    mark = "#"
	1.upto(h) {|y|
		1.upto(w) {|x|
			if x == 1 || x == w || y == 1 || y == h then
				mark = "#"
			else
				mark = "."
			end
			
			print mark
		}
		print "\n"
	}

	print "\n"
end



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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;





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

	VI l(n);
	REP(i, n)cin >> l[i];
	sort(ALL(l));
	int tmp = 0;
	REP(i, n - 1)tmp += l[i];

	if (tmp > l[n - 1])cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())
A =list(map(int,input().split(' ')))
B = list(map(int,input().split(' ')))

if sum(A)< sum(B):
	print(-1)
	exit()

T = [x-y for x,y in zip(A,B)]
M = [t for t in T if t < 0]
P = [t for t in T if t >= 0]

ans = 0
ans += len(M)
b = sum(M)
P.sort()
P=P[::-1]
for p in P:
	if b >= 0:
		break
	b+=p
	ans += 1
#print(T)
#print(M)
#print(P)
print(ans)



Measured memory_bytes: 18356
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let H: usize = read();
    let W: usize = read();
    let K: usize = read();
    let mut vec: Vec<Vec<char>> = vec![];
    for _ in 0..H {
        vec.push(read::<String>().chars().collect())
    }
    let ans = dfs(0, vec![], H, W, K, &vec);
    println!("{}", ans)
}

fn dfs(now: usize, which: Vec<bool>, h: usize, w: usize, k: usize, map: &Vec<Vec<char>>) -> usize {
    if now == h + w {
        let hs = &which[0..h];
        let ws = &which[h..h + w];
        let mut count = 0;
        for (i, row) in map.iter().enumerate() {
            for (j, &cell) in row.iter().enumerate() {
                // true: 塗っているなので、黒くない
                if hs[i] || ws[j] {
                    continue;
                }
                if cell == '#' {
                    count += 1;
                }
            }
        }
        return if count == k { 1 } else { 0 };
    }
    let mut w1 = which.clone();
    w1.push(true);
    let a = dfs(now + 1, w1, h, w, k, map);
    let mut w1 = which;
    w1.push(false);
    let b = dfs(now + 1, w1, h, w, k, map);
    a + b
}


Measured memory_bytes: 2152
def draw_chessboard(w, h)
  h.times do |i|
    s = "#." * ((w + 2) / 2)
    puts s[i % 2, w]
  end
end

while line = gets.chomp
  break if line == "0 0"
  h, w = line.split(" ").map(&:to_i)
  draw_chessboard(w, h)
  puts
end

Measured memory_bytes: 8804
// https://atcoder.jp/contests/abc142/tasks/abc142_a

#include <bits/stdc++.h>
using namespace std;
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n' 

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

    long double N;
    cin >> N;

    int odd = (N+1)/2;

    // watch(odd)
    long double ans = odd/N;

    cout << fixed << setprecision(10) << ans << endl;
}


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

void solve(){
  int a, b; cin >> a >> b;
  cout << (a + b) % 24 << endl;
  return;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <map>
using namespace std;

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

static const double PI=6*asin(0.5);

char t;
stack<char> qu;

int main(){
	while(cin>>t){
		qu.push(t);
	}
	while(!qu.empty()){
		cout<<qu.top();
		qu.pop();
	}
	cout<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_K 110
#define MAX_ROOT_N 80010

ll N, K;
ll dp[MAX_K][MAX_ROOT_N];
ll sum[MAX_K][MAX_ROOT_N];      // dfs で i までみていて、 pat の [1, j] までの累積和
vector< pair<ll, ll> > pat;     // N / j を求めたときに、現れるユニークな数と、その回数

// [lb, ub) の範囲で val 以下の要素で最大のもののインデックスを返す
// なければ -1 を返す
// 同じ数が複数ある場合は一番小さいインデックスを返す
static inline ll bin_search4(const vector< pair<ll, ll> >& v, ll lb, ll ub, ll val) {
    lb--; ub--;
    while(ub - lb > 1) {
        ll mid = (lb + ub) / 2;
        if(v[mid].first >= val) { ub = mid; }
        else { lb = mid; }
    }
    // この時点で lb + 1 = ub
    if(v[ub].first <= val) { return ub; }
    if(lb < 0 || v[lb].first > val) { return -1; }
    return lb;
}

// i まで見ていて、現在の値が pat[j].first のときのパターン数
ll dfs(ll i, ll j) {
    if(i >= K) { return 1; }
    assert(i >= 0 && j >= 0);
    assert(i < MAX_K && j < MAX_ROOT_N);

    ll& ret = dp[i][j];
    if(~ret) { return ret; }
    ret = 0;

    j = pat[j].first;

    ll next_j = N / j;
    // next_j が、 pat のインデックスでいうとどこにあたるか
    ll next_j_ind = bin_search4(pat, 0, pat.size(), next_j);
    // [1, next_j_ind] の和が答え
    assert(next_j_ind >= 0);
    assert(next_j_ind < MAX_ROOT_N);

    if(~sum[i][next_j_ind]) { return sum[i][next_j_ind]; }

    for(int k = 0; k <= next_j_ind; ++k) {
        sum[i][k] = (dfs(i+1, k) * pat[k].second) % MOD;
        if(k != 0) {
            sum[i][k] += sum[i][k-1];
            sum[i][k] %= MOD;
        }
    }

    ret = sum[i][next_j_ind];
    return ret;
}

ll solve() {
    // j が [1,N] のうち、 N/j したときに出現する商の値のパターン一覧と、
    // その商が何回出てくるのかの数を pat に格納しておく
    // O(√N)
    for(ll j = 1; j <= N; ++j) {
        ll next_j = N / j;
        ll cnt = (N % j) / next_j;
        pat.push_back(make_pair(j, cnt + 1));
        j += cnt;
    }

    MINUS(dp);
    MINUS(sum);
    return dfs(0, 0);
}

signed main()
{
    cin >> N >> K;

    ll ans = solve();
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 138868
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>

#define int long long
#define rr register

#define MAXN 1000010
#define inf 1e18

using namespace std;

inline int read() {
	int s = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch)) {f |= ch == '-'; ch = getchar();}
	while (isdigit(ch)) {s = s * 10 + (ch ^ 48); ch = getchar();}
	return f ? -s : s;
}
int n, ans;

int a[MAXN];

map<int, int> v, m;

signed main() {
    n = read();
    for (rr int i = 1; i <= n; i++) {
        a[i] = read();
        m[i + a[i]]++;
        // cout << i + a[i] << "\n";
    }
    for (rr int i = 1; i <= n; i++) {
        ans += m[i - a[i]];
    }
    cout << ans;
}

Measured memory_bytes: 27836
#include<bits/stdc++.h>
#include <unordered_map>
using namespace std;
typedef long long ll;
const int N = 1e6 + 10;
const int MOD = 1e9 + 7;

char s[10][10];

int idx[10][10];
int sum;
int main() {
	// freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i][j] == '#') {
				sum++;
			}
		}
	}// 统计总的黑色格子个数
	int cnt = 0;// 结果个数
	for(int i = 0 ; i < (1 << (n + m));i++){
		memset(idx, 0, sizeof idx);
		int ele = sum;
		int x = i;
		for (int j = 0; j < n; j++) {
			int d = x & 1;
			if (d) {
				for (int k = 0; k < m; k++) {
					if (s[j][k] == '#' && !idx[j][k]) {
						ele --;
						idx[j][k] = 1;
					}
				}
			}
			x >>= 1;
		}// 枚举行
		for (int j = 0; j < m; j++) {
			int d = x & 1;
			if (d) {
				for (int k = 0; k < n; k++) {
					if (s[k][j] == '#' && !idx[k][j]) {
						ele --;
						idx[k][j] = 1;
					}
				}
			}
			x >>= 1;
		}// 枚举列
		if (ele == k) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

int main(){
    int n, q, l, r;
    cin >> n >> q;
    int S[n+1]={0}, A[n]={0};
    char C[n];
    for(int i=0;i<n;i++) cin >> C[i];
    for(int i=0;i+1<=n;i++) {
        if(C[i]=='A'&&C[i+1]=='C') A[i+1]=1;
        S[i+1]=S[i]+A[i]; 
    }
    for(int i=0;i<q;i++){
        cin >> l >> r;
        cout << S[r] - S[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FASTIO ios::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, n) for(int (i) = 0; (i) < (int)(n); ++(i))
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

int main() {
	FASTIO;
	ll a, b, c, d, ans = -1000000000000000000;
	cin >> a >> b >> c >> d;
    ans = max(max(a*c, a*d), max(b*c, b*d));
	cout << ans << endl;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));


		  try{
				  //????????\???
			  //??\????????????a????????????????????°??¨??????????????????????????°???????±???????
			     String ab = input.readLine();
	             int a=Integer.parseInt(ab);
		         int count=1;

		         //??\??????????????°???a?????§??°?????????
		         for(int i=0; i<a; i++){
		        	 //a????????§??????????????????a?????????

		        	 if(count%3==0){
		        		 System.out.print(" "+count);
		        	 }else{
		        		 //???????????¨?????°????????????
		        		 int x=count;
		        		 //x???????????????????????°??°?????????
		        		 while(x!=0){
		        			if(x%10==3){
		        				System.out.print(" "+count);
		        				break;
		        			}else{
		        				x=x/10;
		        				}

		        		 }
		        	 }
		        	 count++;

		         }
		         System.out.println("");


		    }catch(IOException e) {System.out.println("Exception : " + e);
		    }//?????????

	}
}

Measured memory_bytes: 26724
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
typedef pair<lint, lint> P;

signed main(){
  lint N; cin >> N;
  vector<P> a(2010);
  for( lint i = 0; i < N; i++ ){
    lint x; cin >> x;
    a[i] = P(x, i);
  }
  sort( a.begin(), a.end(), greater<P>() );
  lint ans = 0;
  vector<vector<lint> > dp(2010, vector<lint> (2010, 0));
  for( lint l = 0; l < N; l++ ){
    for( lint r = 0; r < N; r++ ){
      if( l + r == N ){
        ans = max( ans, dp[l][r] );
        break;
      }
      dp[l + 1][r] = max( dp[l + 1][r], dp[l][r] + a[l + r].first * abs(l - a[l + r].second) );
      dp[l][r + 1] = max( dp[l][r + 1], dp[l][r] + a[l + r].first * abs((N - r - 1) - a[l + r].second) );
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 34944
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  int count=0;
  for(int i=0;i<s.length();i++)
  {
    if(s[i]==t[i])
      count++;
    
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];

		int max = Integer.MIN_VALUE;
		int subMax = Integer.MIN_VALUE;
		for(int i = 0; i < n; i++) {
			int temp = scan.nextInt();
			a[i] = temp;
			if(temp >= max) {
				subMax = max;
				max = temp;
			}else if(temp >= subMax) {
				subMax = temp;
			}
		}
		for(int i = 0; i < n; i++) {
			if(a[i] == max) {
				System.out.println(subMax);
			}else {
				System.out.println(max);
			}
		}
	}
}


Measured memory_bytes: 105520
#include <bits/stdc++.h>
using namespace std;
int n, m, ans;
vector<int> mp[100005];
int pre[100005];
queue<int> q;
int main()
{
    scanf("%d %d", &n, &m);
    while (m--)
    {
        int x, y;
        scanf("%d %d", &x, &y);
        mp[x].push_back(y);
        mp[y].push_back(x);
    }
    q.push(1);
    while (q.size())
    {
        int t = q.front();
        q.pop();
        for (int x : mp[t])
        {
            if (!pre[x])
            {
                pre[x] = t;
                q.push(x);
            }
        }
    }
    for (int i = 2; i <= n; i++)
    {
        if (!pre[i])
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    for (int i = 2; i <= n; i++)
        printf("%d\n", pre[i]);
    return 0;
}

Measured memory_bytes: 10580
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    rep(i, h) {
        rep(j, w) {
            string s;
            cin >> s;

            if(s == "snuke") {
                int t = 0;
                for(char c = 'A'; c <= 'Z'; c++) {
                    if(t == j) {
                        cout << c << i+1 << endl;
                        return 0;
                    }
                    t++;
                }
            }
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
n_list = [[] for i in range(n)]
k_list = [[] for j in range(n)]

for i in range(n):
    if a[i] == 0:
        n_list[i].append(a[i])
        if a[i]%2 == 1:
            k_list[i].append(a[i])
        n_list[i].append(a[i]+1)
        if (a[i]+1)%2 == 1:
            k_list[i].append(a[i]+1)
    elif a[i] == 9:
        n_list[i].append(a[i])
        if a[i]%2 == 1:
            k_list[i].append(a[i])
        n_list[i].append(a[i]-1)
        if (a[i]-1)%2 == 1:
            k_list[i].append(a[i]-1)
    else:
        n_list[i].append(a[i]-1)
        if (a[i]-1)%2 == 1:
            k_list[i].append(a[i]-1)
        n_list[i].append(a[i])
        if a[i]%2 == 1:
            k_list[i].append(a[i])
        n_list[i].append(a[i]+1)
        if (a[i]+1)%2 == 1:
            k_list[i].append(a[i]+1)

ans = 0
k_s = 1
n_s = 1
for i in range(n):
    n_s = n_s*len(n_list[i])
    k_s = k_s*len(k_list[i])

print(n_s-k_s)


Measured memory_bytes: 9248
#include<bits/stdc++.h>
using namespace std;
int main() {
   int n, m; 
   cin >> n >> m;
   int s = 0;
   for(int i = 0; i < m; i++) {
      int a;
      cin >> a;
      s += a;
   }
   cout << max(n - s, -1);
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>

using namespace std;

class C {
	int N, M;
	vector<vector<int>> edges;
public:
	void solve()
	{

		if (bruteforce()) cout << "POSSIBLE" << endl;
		else cout << "IMPOSSIBLE" << endl;

	}

	bool bruteforce()
	{

		for (int moveOne : edges[0])
		{
			for (int moveTwo : edges[moveOne])
			{
				if (moveTwo == N - 1)
					return true;
			}
		}

		return false;

	}

	C()
	{
		cin >> N >> M;
		edges.resize(N);

		int a, b;
		for (int i{ 0 }; i < M; i++)
		{
			cin >> a >> b;
			a--; b--;

			edges[a].push_back(b);
			edges[b].push_back(a);
		}
	}
};


int main()
{
	C solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 12016
X = int(input())

i = 0
p = 0
d = {}
while True:
    d[i] = i**5
    if d[i] - p > X*2:
        break
    p = d[i]
    i+=1

rd = list(d.items())
rd.reverse()


for p in range(len(rd)):
    k, v = rd[p]

    for q in range(p+1, len(rd)):
        kn, vn = rd[q]

        if v - vn == X:
            print(k, kn)
            exit()
        elif v + vn == X:
            print(k, kn*-1)
            exit()



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

typedef long long ll;

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

    vector<vector<ll>> dp(n + 1, vector<ll>(3));

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

    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}



Measured memory_bytes: 5760
#include <iostream>
#include <queue>

using namespace std;

const int no_edge = -1;
const int edge = 1;
const int first_visit_label = 1;
const int no_distance = -1;

int main() {
  int vertex_num;
  cin >> vertex_num;

  vector<vector<int>> matrix_graph(
    vertex_num,
    vector<int>(vertex_num, no_edge)
  );

  for(int i = 0; i < vertex_num; i++) {
    int vertex_label;
    int adjacency_num;
    cin >> vertex_label >> adjacency_num;
    for(int j = 0; j < adjacency_num; j++) {
      int adjacency_label;
      cin >> adjacency_label;
      matrix_graph[vertex_label - 1][adjacency_label - 1] = edge;
    }
  }

  queue<int> will_visit_labels;
  vector<int> distances(vertex_num, no_distance);
  distances[first_visit_label - 1] = 0;
  will_visit_labels.push(first_visit_label);

  while(!will_visit_labels.empty()) {
    int current_label = will_visit_labels.front();
    will_visit_labels.pop();

    for(int i = 0; i < vertex_num; i++) {
      int will_visit_label = i + 1;
      if(matrix_graph[current_label - 1][will_visit_label - 1] == no_edge) {
        continue;
      }
      if(distances[will_visit_label - 1] != no_distance) {
        continue;
      }
      distances[will_visit_label - 1] = distances[current_label - 1] + 1;
      will_visit_labels.push(will_visit_label);
    }
  }

  for(int i = 0; i < vertex_num; i++) {
    cout << i + 1 << ' ' << distances[i] << endl;
  }
}



Measured memory_bytes: 3140
#include<cstdio>
#include<algorithm>
using namespace std;

int gcd(int a,int b)
{
	int c;
	while(b>0)
    {
        c=a%b;
        a=b;
        b=c;
    }
    return a;
}
int ggcd(int a,int b,int c)
{
    return gcd(gcd(a,b),c);
}
int main()
{
    long long sum=0;
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                sum+=ggcd(i,j,k);
            }
        }
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

#define NIL -1
#define N 500001

//struct Node{
//	int val;
//	Node *p, *l, *r;
//};

struct Node {
	int val;
	Node *p, *l, *r;
	Node(int v) :val(v), p(NULL), l(NULL), r(NULL){}
	Node() :val(0), p(NULL), l(NULL), r(NULL){}
};

Node T[N];
int D[N], H[N];

Node *root;

void insert(int k){
	Node *y = NULL;
	Node *x = root;
	Node *z = new Node(k);

	while (x != NULL && x->val != k){
		y = x;
		if (k > x->val) x = x->r;
		else x = x->l;
	}
	z->p = y;
	if (y == NULL) root = z;
	else{
		if (k < y->val) y->l = z;
		else y->r = z;
	}
}

Node *find(int val){
	Node *p = root;
	while (p != NULL && p->val != val) {
		if (val < p->val) p = p->l;
		else p = p->r;
	}
	return p;
}

void ino(Node *p){
	if (p == NULL) return;
	ino(p->l);
	printf(" %d", p->val);
	ino(p->r);
}

void preo(Node *p){
	if (p == NULL) return;
	printf(" %d", p->val);
	preo(p->l);
	preo(p->r);
}

Node *mi(Node *z){
	while (z->l != NULL) z = z->l;
	return z;
}

Node *suc(Node *z){
	if (z->r != NULL) return mi(z->r);
	Node *y = z->p;
	while (y != NULL && z == y->r) {
		z = y;
		y = y->p;
	}
	return y;
}

void del(Node *z){
	Node *y = NULL;
	Node *x = NULL;

	if (NULL == z->l || NULL == z->r) y = z;
	else y = suc(z);

	if (NULL != y->l) x = y->l;
	else x = y->r;

	if (NULL != x) x->p = y->p;

	if (NULL == y->p) root = x;
	else {
		if (y == y->p->l) y->p->l = x;
		else y->p->r = x;
	}

	if (y != z) z->val = y->val;
	delete y;
}


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

	int val;
	string com;
	for (int i = 0; i < n; ++i) {
		cin >> com;
		if (com[0] == 'f'){
			cin >> val;
			Node *p = find(val);
			cout << ((p == NULL) ? "no" : "yes") << endl;
		}
		else if (com[0] == 'i'){
			cin >> val;
			insert(val);
		}
		else if (com[0] == 'p'){
			ino(root); cout << "\n";
			preo(root); cout << "\n";
		}
		else if (com[0] == 'd'){
			cin >> val;
			del(find(val));
		}
	}

	return 0;
}

//yes
//yes
//yes
//no
//no
//no
//yes
//yes
//1 2 3 7 8 22
//8 2 1 3 7 22
//1 2 8 22
//8 2 1 22

Measured memory_bytes: 37660
#include <bits/stdc++.h>
#define lli long long int
#define MAX(A,B) A>B?A:B
#define MIN(A,B) (A)<(B)?(A):(B)
#define gcd(A,B) __gcd(A,B)
#define lcm(A,B) A/(__gcd(A,B))*B
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define ld long double
#define mod 1000000007LL
#define usecppio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<int,double> pid;

char grid[55][55];
int main()
{
    int h,w;
    int c = 0;
    scanf("%d%d",&h,&w);
    for (int i = 1; i<=h; i++)
        scanf("%s",grid[i]);
    for (int i = 1; i<h; i++)
    {
        for (int j = 1; j<w; j++)
        {
            if (grid[i][j] == '#' && grid[i][j-1] != '#' && grid[i-1][j] != '#' && grid[i+1][j] != '#' && grid[i][j+1] != '#')
            {
                c++;
            }
        }
    }
    if (c==0)
        printf("Yes");
    else
        printf("No");
}

Measured memory_bytes: 256