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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    set<int32> s;
    REP(i,3){
        int32 a;
        cin >> a;
        s.insert(a);
    }
    Yes(s.size() == 2);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
XY = {}
for i in range(N):
    x,y = map(int,input().split())
    XY[(x,y)] = 1
dis = {}

ans = N

for x,y in XY.keys():
    for xx,yy in XY.keys():
        if x != xx or y != yy:
            temp = (xx-x,yy-y)
            if not(temp in dis):
                dis[temp] = 1

for p,q in dis:
    test = 0
    copy = XY.copy()
    for x,y in copy:
            if (x+p,y+q) in copy.keys():
                test += 1
    if N - test < ans:
        ans = N - test
print(ans)
    

Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 0; i < n - 2; ++i) {
        if (s.substr(i, 3) == "ABC") ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>


using namespace std;



int main(void){
    int H,W;
    scanf("%d %d",&H,&W);
    int po[H][W];
    for(int i=0;i<H;i++)for(int j=0;j<W;j++)scanf("%d",&po[i][j]);
    int karipo[H][W];
    for(int i=0;i<H;i++)for(int j=0;j<W;j++)karipo[i][j]=po[i][j];
    int ans=0;
    for(int i=0;i<H;i++)for(int j=0;j<W;j++){
        if(i==H-1&&j==W-1)break;
        int yoko=i%2==0?j:W-1-j;
        int nexti,nextyoko;
        if(i%2==0&&yoko==W-1){
            nexti=i+1;
            nextyoko=W-1;
        }
        else if(i%2==1&&yoko==0){
            nexti=i+1;
            nextyoko=0;
        }
        else if(i%2==0){
            nexti=i;
            nextyoko=yoko+1;
        }
        else{
            nexti=i;
            nextyoko=yoko-1;
        }
        if(karipo[i][yoko]%2==1){
            karipo[nexti][nextyoko]++;
            ans++;
        }
    }
    printf("%d\n",ans);
        for(int i=0;i<H;i++)for(int j=0;j<W;j++){
        if(i==H-1&&j==W-1)break;
        int yoko=i%2==0?j:W-1-j;
        int nexti,nextyoko;
        if(i%2==0&&yoko==W-1){
            nexti=i+1;
            nextyoko=W-1;
        }
        else if(i%2==1&&yoko==0){
            nexti=i+1;
            nextyoko=0;
        }
        else if(i%2==0){
            nexti=i;
            nextyoko=yoko+1;
        }
        else{
            nexti=i;
            nextyoko=yoko-1;
        }
        if(po[i][yoko]%2==1){
            po[nexti][nextyoko]++;
            printf("%d %d %d %d\n",i+1,yoko+1,nexti+1,nextyoko+1);
        }
    }
  
    return 0;
}

Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int H, N;
int A[1010], B[1010];
ll dp[1010][20101];

int main()
{
    cin >> H >> N;
    int maxa = 0;
    rep(i, 0, N)
    {
        cin >> A[i] >> B[i];
        maxa = max(maxa, A[i]);
    }

    for (int i = 0; i <= N; i++)
    {
        for (int j = 0; j <= H + maxa; j++)
        {
            dp[i][j] = inf;
        }
    }

    dp[0][0] = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < H + maxa; j++)
        {
            if (i == 0 && j != 0)
            {
                dp[0][j] = inf;
            }
            if (j >= A[i])
            {
                dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - A[i]] + B[i]);
            }
            else
            {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }

    ll ans = inf;
    for (int i = H; i < H + maxa; i++)
    {
        ans = min(ans, dp[N][i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 157056
N = int(input())
ans = 0

for i in range(1,N+1):
    #print(i)
    
    if i % 3 == 0 and i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        ans = ans + i
    
print(ans) 

Measured memory_bytes: 9172
n=int(input())
d = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for i in range (n):
  d[input()] += 1;
print('AC x ', d['AC'])
print('WA x ', d['WA'])
print('TLE x ', d['TLE'])
print('RE x ', d['RE'])

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

int main(){
  string s;
  cin >> s;
  for(int i = 1; i < 4; i++){
    if(s[i] == s[i-1]){
      cout << "Bad";
      return 0;
    }
  }
  cout << "Good";
}


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

#ifdef ONLINE_JUDGE
#define freopen \
  if (0) freopen
#define cerr \
  if (0) cerr
#endif

#define fi first
#define se second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)

#define sqr(a) ((a)*1ll * (a))
#define sz(a) (int)a.size()
#define len(a) (int)a.length()
#define all(a) a.begin(), a.end()
#define nl '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pi;

const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

vector<int> fact;

int powm(int n, int p) {
  int res = 1;
  while (p > 0) {
    if (p & 1) 
      res = (res * 1ll * n) % mod;
    p >>= 1;
    n = (n * 1ll * n) % mod;
  }
  return res;
}

int inv(int n) {
  return powm(n, mod - 2);
}

int binom(int n, int k) {
  return (fact[n] * 1ll * inv((fact[k] * 1ll * fact[n - k]) % mod)) % mod;
}

void solve() {
  fact.resize(1e6);
  fact[0] = 1;
  rep(i, 1, 1e6) {
    fact[i] = (fact[i - 1] * 1ll * i) % mod;
  }

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

  int l = n + m + k;
  int res = 0;
  int l_sum = 0;
  int r_sum = 0;
  int row_sum = 1;
  rep(i, n, l) {
    int mid_sum = row_sum;
    if (i - n - k > 0) {
      int prev_left = max(0, i - 1 - n - k);
      l_sum += binom(i - 1 - n, prev_left);
      l_sum %= mod;
      mid_sum = (mod + mid_sum) - l_sum;
      mid_sum %= mod;
    }
    if (m < i - n) {
      int prev_right = min(i - 1 - n, m);
      r_sum += binom(i - 1 - n, prev_right);
      r_sum %= mod;
      mid_sum = (mod + mid_sum) - r_sum;
      mid_sum %= mod;
    }
    int temp = (mid_sum * 1ll * binom(i - 1, n - 1)) % mod;
    res += (temp * 1ll * powm(3, l - i)) % mod;
    res %= mod;
    row_sum = (row_sum * 1ll * 2) % mod;
    l_sum = (l_sum * 1ll * 2) % mod;
    r_sum = (r_sum * 1ll * 2) % mod;
  }

  cout << res;
}

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

  freopen(".in", "r", stdin);

  solve();

  return 0;
}


Measured memory_bytes: 7064
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
char a,b;
cin>>a>>b;
int a1=a;
int b1=b;
if (a1>b1)
cout<<">";
else if(a1==b1)
cout<<"=";
else
cout<<"<";
return 0;
}

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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
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; }

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


int main() {
    cout<<fixed<<setprecision(10);

    ll n,k; cin>>n>>k;
    vint a(n); rep(i,n) {cin>>a[i]; a[i]--;}


    vint dist(n,-1);
    dist[0] = 0;

    ll cnt = 0;
    ll cur = 0;
    ll ans;
    while(true){
        cnt++;
        ll to = a[cur];
        if(cnt==k) {ans = to; break;}
        if(dist[to] != -1){
            ll t = dist[cur] - dist[to] + 1;
            ll res = k - cnt;
            auto it = find(ALL(dist), dist[to] + res%t);
            ans = it - dist.begin();
            break;
        }else{
            dist[to] = cnt;
        }
        cur = to;

    }


    cout<<ans+1<<endl;

    return 0;

}

Measured memory_bytes: 6436
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n;
    cin >> n;
    int ans = 0;
    rep(i,n) {
        int a;
        cin >> a;
        ans += a;
    }
    ans -= n;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

ans = 'No'
for i in range(N-M+1):
    for j in range(N-M+1):
        C = [A[k][i:i+M] for k in range(j, j+M)]
        if B == C:
            ans = 'Yes'
print(ans)

Measured memory_bytes: 9196
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
int a,b;
cin >> a >> b;
cout << (a+b)/2 << endl;
}



Measured memory_bytes: 3096
/*

*/
#include<bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,a,n) for(int i=(a);i<(n);i++)
#define all(a) (a).begin(), (a).end()

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n,k; 
  cin>>n>>k;
  map<int, int> mp;
  for(int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    ++mp[a];
  }
  vector<int> v;
  for(auto it = mp.begin(); it != mp.end(); ++it) {
    v.push_back(it->second);
  }
  sort(v.begin(), v.end());
  int ans = 0;
  if(v.size() > k)
    for(int i = 0; i < v.size() - k; ++i) ans += v[i];
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 10744
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int a;
    cin >> a;
    if(a / 100 == a % 10){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
	long long int N, a[10000], b[10000], asum = 0, bsum = 0, count1 = 0, count2 = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		asum += a[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> b[i];
		bsum += b[i];
	}
	for (int i = 0; i < N; i++) {
		if (a[i] > b[i]) count1 += a[i] - b[i];
		if (a[i] < b[i]) count2 += (b[i] - a[i] + 1) / 2;
	}
	if (max(count1, count2) <= bsum - asum) cout << "Yes";
	else cout << "No";
}

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

static const int MAX = 200000;


int main() {
  int n;
  cin >> n;
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      if (n == i * j) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;
#define piii 3.14159265358979323846264338327950


bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}

//////////////////////////////////////////////////// Lets Do It ////////////////////////////////////////////////////////

void solve(){

    ll n=5;
    intarr(a,n);
    loop(i,0,n){
        if(a[i]==0){
            cout<<i+1; return;
        }
    }


    return;
} 
 
int main()
{
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, K, Q;
    cin >> N >> K >> Q;
    vector<ll> score(N, K);
    REP(i, Q)
    {
        ll a;
        cin >> a;
        a--;
        score[a]++;
    }
    REP(i, N) 
    {
        string ans;
        if (score[i] - Q > 0) ans = "Yes";
        else ans = "No";
        cout << ans << endl;
    }
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 2147483647;
int prime = 10e9+7;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;




signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int m;
    cin >> n >> m;
    REP(i,m){
        int tmp;
        cin >> tmp;
        n -= tmp;
    }
    (n>=0)?print(n):print("-1");

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

//key以上の初めてのitr
int nibul(auto a,auto b){return lower_bound(All(a),b) - a.begin();}
//key以下の最後のitr
int nibuu(auto a,auto b){return upper_bound(All(a),b) - a.begin()-1;}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 3652
#include <stdio.h>

int main(void){
    
    long long int i,n,a,b,k;
    long long int num[100001]={0};
    
    scanf( "%lld %lld",&n,&k );
    
    for( i = 0; i < n; i++ ){
        scanf( "%lld %lld",&a,&b);
        num[a] = num[a] + b;
        
    }
    
    for( i = 1; i < 100001; i++ ){
        k = k - num[i];
        if( k <= 0 ){
            printf( "%lld",i );
            break;
        }
    }
    
    
    
    
   
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int n;
vector<vector<int>> graph;
vector<bool> check;

void dfs(int x, int d, vector<int> &y) {
  check[x] = true;
  y[x] = d;
  for (int i = 0; i < graph[x].size(); i ++) {
    if (!check[graph[x][i]]) dfs(graph[x][i], d + 1, y);
  }
}

int main() {
  cin >> n;
  graph = vector<vector<int>>(n);
  for (int i = 0; i < n - 1; i ++) {
    int a, b; cin >> a >> b;
    a -- ,b --;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  vector<int> from_one(n), from_n(n);
  check = vector<bool>(n, false);
  dfs(0, 0, from_one);
  check = vector<bool>(n, false);
  dfs(n - 1, 0, from_n);

  int sum_from_one = 0, sum_from_n = 0;
  rep(i, n) {
    if (from_one[i] <= from_n[i]) sum_from_one ++;
    else sum_from_n ++;
  }

  if (sum_from_one > sum_from_n) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
}

Measured memory_bytes: 11264
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <iomanip>
#include <queue>
#include <cmath>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vector<T>>;
using vl = vector<ll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const long double EPS = 1e-11;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<min(min(a%2*b*c,b%2*a*c),c%2*a*b)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <functional>
#include <algorithm>
#include <complex>
#include <map>
#include <cmath>
#include <string>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <istream>
//-----------------------------------------------------define--------------------------------------------------------------------//
#define PB push_buck
#define MP make_pair
#define MAX 100000
//-------------------------------------------------------typedef----------------------------------------------------------------//
typedef long long ll;

using namespace std;

char a;
//------------------------------------------------------------------------------------------------------------------------------//
int main() {
	cin >> a;
	if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int fib(int b, int i);
int n[44];
int main(void)
{
	int b;
	int i = 2;
	
	scanf("%d", &b);
	fib(b, i);
	
	printf("%d\n", n[b]);
	
	return (0);
}

int fib(int b, int i){
		
	n[0] = 1;
	n[1] = 1;
	
	if (b >= 2){
		n[i] = n[i - 1] + n[i - 2];
		if (i < b){
			i++;
			fib(b, i);
		}
	}
	else {
		i = 1;
	}
	
	
	return (n[i]);
}

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

#define rep(i, s, n) for (Int i = s; i < (Int)(n); i++)
#define rrep(i, n, s) for (Int i = n - 1; i >= s; i--)
#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).end()
 
double EPS = 1e-10;
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int k;
    cin >> k;
    vector<Int> res(10);
    rep(i, 0, 10) res[i] = i;
    Int i = 1;
    while ((Int)res.size() <= k) {
        Int p = res[i] % 10;
        rep(j, -1, 2) {
            Int d = p + j;
            if (d < 0 or 9 < d) continue;
            res.push_back(res[i] * 10 + d);
        }
        i++;
    }
    // rep(i, 0, k + 1) cout << res[i] << " ";
    // cout << endl;
    dump(res[k]);
    return 0;
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N, X;
    cin >> N >> X;
    vector<ll> A(N), S(N-1);

    rep(i, 0, N){
        cin >> A[i];
    }
    
    rep(i, 0, N-1){
        S[i] = A[i] + A[i+1];
    }
    
    ll ans = 0;
    rep(i, 0, N-1){
        if(max(0LL, S[i]-X) > A[i+1]){
            ans += S[i]-X;
            if(i != N-2) S[i+1] -= max(0LL, A[i+1]);
        }else{
            ans += max(0LL, S[i]-X);
            if(i != N-2) S[i+1] -= max(0LL, S[i]-X);
        }
    }

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

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<numeric>
#include<climits>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;

int main(void) {
	map<char, int> alphabet;
	for (char i = 'a'; i <= 'z'; i++)
	{
		alphabet[i] = 0;
	}


	string s;
	string tmp;
	while (getline(cin, tmp)){
		s += tmp;
	}


	for (int i = 0; i < s.size(); i++)
	{
		if ('a' <= s[i] && 'z' >= s[i]) {
			alphabet[s[i]]++;
		}
		else if ('A' <= s[i] && 'Z' >= s[i]) {
			alphabet[s[i] + ('a' - 'A')]++;
		}
	}

	for (char i = 'a'; i <= 'z'; i++)
	{
		cout << i << " : " << alphabet[i] << endl;
	}
}


Measured memory_bytes: 3192
s = input()
l = []
for i in range(len(s)):
	l.append(s.count(s[i]))
r = []
for x in l:
	if(x%2!=0):
		r.append(False)
	else:
		r.append(True)

if(all(r)):
	print("Yes")
else:
	print("No")


Measured memory_bytes: 9012
/* Problem A */
#include <stdio.h>

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

    scanf("%d %d",&a,&b);

    if(a+b > a-b){
        max = a+b;
    } else {
        max = a-b;
    }

    if(max < a*b){
        max = a*b;
    }

    printf("%d\n",max);
    
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void){
	int n,m,l;
	int i,j,k;
	int a[110][110];
	int b[110][110];
	long long c[110][110]={0};
	scanf("%d %d %d",&n,&m,&l);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
		scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<l;j++){
		scanf("%d",&b[i][j]);
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			for(k=0;k<m;k++){
				c[i][j]+=a[i][k]*b[k][j];
			}
			if(j!=0) printf(" ");
			printf("%ld",c[i][j]);
		}
		puts("");
	}
	return 0;
}



Measured memory_bytes: 2052
seq=input().strip().split(' ')
mystack=[]
while len(seq) !=0:
    ob=seq.pop(0)
    if ob in ['+','*','-']:
        x = mystack.pop()
        y = mystack.pop()
        if ob =='+':
            mystack.append(y+x)
        elif ob =='*':
            mystack.append(y*x)
        elif ob =='-':
            mystack.append(y-x)
    else :
        mystack.append(int(ob))
print(mystack.pop())



Measured memory_bytes: 5596
a = []
for i in iter(input, '0 0'):
    a.append(list(map(int, i.split())))
for i in range(len(a)):
    for j in range(a[i][0]):
        if (j == 0) | (j == a[i][0]-1):
            for k in range(a[i][1]):
                print('#', end='')    
            print()
        else:
            for k in range(a[i][1]):
                if (k== 0) | (k == a[i][1]-1):
                    print('#', end='')
                else:
                    print('.', end='')
            print()
    print()


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

int main(){
	int car[100];
	int input;
	int i = 0;

	while(cin >> input){
		if(input == 0){
			i--;
			cout << car[i] << endl;
		}else{
			car[i] = input;
			i++;
		}
	}
}

Measured memory_bytes: 1160
x1, y1, x2, y2 = map(int, input().split())

if x1 >= x2 and y1 >= y2:
    x3 = x2 + (y1 - y2)
    y3 = y2 - (x1 - x2)
    x4 = x3 + (x1 - x2)
    y4 = y3 + (y1 - y2)
elif x1 >= x2 and y1 < y2:
    x3 = x2 - (y2 - y1)
    y3 = y2 - (x1 - x2)
    x4 = x3 + (x1 - x2)
    y4 = y3 - (y2 - y1)
elif x1 < x2 and y1 >= y2:
    x3 = x2 + (y1 - y2)
    y3 = y2 + (x2 - x1)
    x4 = x3 - (x2 - x1)
    y4 = y3 + (y1 - y2)
else:
    x3 = x2 - (y2 - y1)
    y3 = y2 + (x2 - x1)
    x4 = x3 - (x2 - x1)
    y4 = y3 - (y2 - y1)

print("{} {} {} {}".format(x3, y3, x4, y4))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(ll i=x; i>(n); i--)
#define ALL(n) begin(n),end(n)
#define MAX 1000
#define VMAX 10000
#define SENTINEL 2000000000
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
ll N,A[MAX],B[MAX],T[VMAX+1],s;

ll solve(){
    ll ans = 0;
    bool V[MAX];
    REP(i,N){
        B[i]=A[i];
        V[i]=false;
    }
    sort(B,B+N);
    REP(i,N)T[B[i]]=i;
    REP(i,N){
        if(V[i])continue;
        ll cur = i;
        ll S = 0;
        ll m = VMAX;
        ll an = 0;
        while(1){
            V[cur] = true;
            an++;
            ll v = A[cur];
            m = min(m,v);
            S +=v;
            cur = T[v];
            if(V[cur])break;
        }
        ans += min(S+(an-2)*m,m+S+(an+1)*s);
    }
    return ans;
}
int main(){
    cin >> N;
    s = VMAX;
    REP(i,N){
        cin >> A[i];
        s = min(s,A[i]);
    }
    ll ans = solve();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3240
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define str string
#define ld long double
#define vec vector
#define vll vec<ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define kai "\n"
#define yuque priority_queue
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mie min_element
#define mae max_element
#define tos to_string
#define sep setprecision
#define lob lower_bound
#define upb upper_bound
#define nep next_permutation
#define MOD 1000000007ll
#define MIN (1e-10)
#define equal(a,b) (abs((a)-(b))<MIN)
#define v2 ten
#define chokusen senbun
#define tenten senbun
#define takaku vec<ten>
using namespace std;
void solve();
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed;
	solve();
}
struct pea{
	ll f,s;
	bool operator<(const pea &p)const{
		return f!=p.f?f<p.f:s<p.s;
	};
};
struct tri{
	ll f,s,t;
	bool operator<(const tri &p)const{
		if(f!=p.f)return f<p.f;
		if(s!=p.s)return s<p.s;
		return t<p.t;
	};
};
class ten{
public:
	ld x,y;
	ten operator+(ten p){return{x+p.x,y+p.y};}
	ten operator-(ten p){return{x-p.x,y-p.y};}
	ten operator*(ld k){return{k*x,k*y};}
	ten operator/(ld k){return{x/k,y/k};}
	ld abs(){return sqrt(abs2());}
	ld abs2(){return x*x+y*y;};
	bool operator<(const ten &p)const{return x!=p.x?x<p.x:y<p.y;};
	bool operator==(const ten &p)const{return (-MIN<x-p.x)&&(x-p.x<MIN)&&(-MIN<y-p.y)&&(y-p.y<MIN);};
	ld naiseki(v2 b){return x*b.x+y*b.y;}
	ld gaiseki(v2 b){return x*b.y-y*b.x;}
};
struct senbun{ten p1,p2;};
struct en{ten o;ld r;};
ll pow2(ll a,ll b,ll p=MOD){
	if(b==-1)return pow2(a,p-2);
	ll res=1;
	if(b>0){
		res=pow2(a,b/2);
		if(b%2==0)res=res*res%p;
		else res=res*res%p*a%p;
	}
	return res;
}
void solve(){
	ll a,b;cin>>a>>b;
	cout<<pow2(a,b)<<kai;
}


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

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

  int scoreAlice = 0;
  int scoreBob = 0;

  vector<int> vec(n);

  for (int i=0;i<n;i++) {
    cin >> vec.at(i);
  }

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

  reverse(vec.begin(), vec.end());

  for (int i=0;i<n;i++) {
    if (i % 2 == 0) {
      scoreAlice += vec.at(i);
    } else {
      scoreBob += vec.at(i);
    }
  }

  cout << scoreAlice - scoreBob << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,i,j,ans;cin >> n;ans = 0;
  int d[n];
  for(i=0;i<n;i++) cin >> d[i];
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++) ans += d[i]*d[j];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

const int MAXN=200000;

int a[MAXN];

int main(){
    int N;cin >> N;
    int whole = 0;
    rep(i,N){
        cin >> a[i];
        whole ^= a[i];
    }

    rep(i,N){
        cout << (whole ^ a[i]) << " ";
    }

    cout << endl;
    
    return 0;
}

Measured memory_bytes: 4316
#include <iostream>
#include <cstdlib>
#include <cstring>

void trace(char *v, char *s, int N){
	int i;
	for(i=0; i<N-1; i++){
		std::cout << s[i] << v[i] << " ";
	}
	std::cout << s[N-1] << v[N-1] << std::endl;
}


void bubbleSort(char *v, char *s, int N){
	int i,j,flag;
	char xv,xs;
	flag = 1;
	while (flag){
		flag = 0;
		for (j=N-1; j>0; j--){
			if (v[j] < v[j-1]){
				xv = v[j]; v[j] = v[j-1]; v[j-1] = xv;
				xs = s[j]; s[j] = s[j-1]; s[j-1] = xs;
				flag = 1;
			}
		}
	}
}

void selectionSort(char *v, char *s, int N){
	int i,j,minj;
	char xv, xs;
	for (i=0;i<N; i++){
		minj = i;
		for (j=i; j<N; j++){
			if (v[minj] > v[j]){
				minj = j;
			}
		}
		if (i!=minj){
			xv = v[i]; v[i] = v[minj]; v[minj] = xv;
			xs = s[i]; s[i] = s[minj]; s[minj] = xs;
		}
	}
}

int main(){
	int N,i;
	char *bv, *sv, *bs, *ss;
	char suit, value;
	std::cin >> N;
	bv = new char[N];
	sv = new char[N];
	bs = new char[N];
	ss = new char[N];
	for (i=0; i<N; i++){
		std::cin >> suit >> value;
		bs[i] = suit; ss[i] = suit;
		bv[i] = value; sv[i] = value;
	}
	bubbleSort(bv, bs, N);
	trace(bv, bs, N);
	std::cout << "Stable" << std::endl;
	
	selectionSort(sv, ss, N);
	trace(sv, ss, N);
	if (std::strcmp(bs,ss)==0){
		std::cout << "Stable" << std::endl;
	}
	else{
		std::cout << "Not stable" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3092
import sys, math
from pprint import pprint
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
S = rs()

if N % 2 == 1:
	print('No')
	exit()

if S[:N//2]==S[N//2:]:
	print('Yes')
else:
	print('No')


Measured memory_bytes: 38384
#include <stdio.h>
#include <stdlib.h>
int f(int *a,int *b)
{
    int i,s=0;
    for(i=0;a+i!=b;i++)
        s+=a[i];
    return s;
}
int main()
{
    int n,i,m;
    scanf("%d",&n);
    int a[n],b[n];
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<n;i++)
        scanf("%d",&b[i]);
    for(i=0;i<n;i++)
    {
        if(f(a,a+i+1)+f(b+i,b+n)>m)m=f(a,a+i+1)+f(b+i,b+n);
    }
    printf("%d\n",m);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
using namespace std;
template <class T> inline void read(T &n) {
	n=0;register char ch;while(!isdigit(ch=getchar()));
	for(n=ch^48;isdigit(ch=getchar());n=(n<<3)+(n<<1)+(ch^48));
}
int n;
int main() {
	read(n);
	if(n<=9)cout<<n;
	else if(n>9&&n<100)cout<<9;
	else if(n>=100&&n<1000)cout<<n-90;
	else if(n>=1000&&n<10000)cout<<909;
	else if(n>=10000&&n<100000)cout<<n-9090;
	else cout<<90909;
    return 0;
}



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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1e9+7;
#define INF (1 << 30)
#define REP(i,m,n) for(int i=(int)m; i < (int)n; ++i)
#define rep(i,n) REP(i,0,n)

typedef vector<vector<P> > Graph;
vector<int> dijkstra(int s, Graph &G){
    priority_queue<P,vector<P>,greater<P>> que;
    int n = G.size();
    vector<int> dist(n);
    dist.assign(n,INF);
    dist[s] = 0;
    que.push(P(0, s));

    while(!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        rep(i,G[v].size()) {
            if(dist[G[v][i].first] > dist[v]+G[v][i].second){
                dist[G[v][i].first] = dist[v]+G[v][i].second;
                que.push(P(dist[G[v][i].first],G[v][i].first));
            }
        }
    }
    return dist;
}

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

    int n; cin >> n;
    Graph edge(n+1);
    rep(i, n) {
        // P(ノード番号, 重さ)
        edge[i].push_back(P(i+1, 1));
        int x = 6;
        while(i+x <= n) {
            edge[i].push_back(P(i+x, 1));
            x *= 6;
        }
        int y = 9;
        while(i+y <= n) {
            edge[i].push_back(P(i+y, 1));
            y *= 9;
        }
    }

    vector<int> dist =  dijkstra(0, edge);
    cout << dist[n] << '\n';
    return 0;
}

Measured memory_bytes: 17024
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

int N;
int a[100000];

void NO()
{
	cout << "No" << endl;
	exit(0);
}

void YES()
{
	cout << "Yes" << endl;
	exit(0);
}

signed main()
{
	cin >> N;
	int max = 0;
	REP(i, N)
	{
		cin >> a[i];
		max = MAX(a[i], max);
	}

	int cnt = 0;
	REP(i, N)
	{
		if (a[i] != max && a[i] != max - 1)
		{
			NO();
		}
		if (a[i] == max)
		{
			cnt++;
		}
	}

	if (max == N - 1)
	{
		if (cnt == N)
		{
			YES();
		}
	}

	int c = N - (max - 1);
	int d = MIN((N - max) * 2, N);
	if (c <= cnt && cnt <= d)
	{
		YES();
	}
	else
	{
		NO();
	}
}

Measured memory_bytes: 1152
from heapq import heappop, heappush, heapify

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

L = A[:N]
heapify(L)
sumL = [sum(A[:N])]

for i in range(N):
    x = heappop(L)
    if x < A[N + i]:
        sumL.append(sumL[-1] - x + A[N + i])
        heappush(L, A[N + i])
    else:
        sumL.append(sumL[-1])
        heappush(L, x)

R = list(map(lambda x: -x, A[2 * N:]))
heapify(R)
sumR = [sum(A[2 * N:])]

for i in range(N):
    x = -heappop(R)
    if x > A[2 * N - 1 - i]:
        sumR.append(sumR[-1] - x + A[2 * N - 1 - i])
        heappush(R, -A[2 * N - 1 - i])
    else:
        sumR.append(sumR[-1])
        heappush(R, -x)

res = -10**18

for i in range(N + 1):
    res = max(res, sumL[i] - sumR[-1 - i])

print(res)

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

long long FloorSum(long long n, long long m, long long a, long long b) {
    long long ans = 0;
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) {
        ans += n * (b / m);
        b %= m;
    }

    long long y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += FloorSum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}

using ll = long long;
int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int Q; cin >> Q;
    while(Q--){
        ll N,M,A,B; cin >> N >> M >> A >> B;
        cout << FloorSum(N,M,A,B) << endl;
    }
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int a,b,d;
    cin>>a>>b;
    double c=((a+b)/2.0)+.5;
    d=c;
    cout<<d<<NL;
    return 0;
}


Measured memory_bytes: 256
local n, m, k = io.read("*n", "*n", "*n")

local edge = {}
local avoid = {}
for i = 1, n do
  edge[i] = {}
  avoid[i] = {}
end

for i = 1, m do
  local a, b = io.read("*n", "*n")
  edge[a][b], edge[b][a] = true, true
end
for i = 1, k do
  local c, d = io.read("*n", "*n")
  avoid[c][d], avoid[d][c] = true, true
end
local parent = {}
for i = 1, n do
  parent[i] = i
end

local function uf_findroot(idx)
  local idx_update = idx
  while parent[idx] ~= idx do
    idx = parent[idx]
  end
  while parent[idx_update] ~= idx do
    parent[idx_update], idx_update = idx, parent[idx_update]
  end
  return idx
end

for i = 1, n do
  local src = i
  local rs = uf_findroot(src)
  for dst, _u in pairs(edge[src]) do
    -- table.insert(tasks, dst)
    local rd = uf_findroot(dst)
    parent[rd], parent[dst] = rs, rs
  end
end
local groups = {}
for i = 1, n do
  local r = uf_findroot(i)
  if not groups[r] then
    groups[r] = 1
  else
    groups[r] = groups[r] + 1
  end
end
local ret = {}
for i = 1, n do
  local root = uf_findroot(i)
  local cnt = groups[root] - 1
  for dst, _u in pairs(edge[i]) do
    local r = uf_findroot(dst)
    if r == root then cnt = cnt - 1 end
  end
  for dst, _u in pairs(avoid[i]) do
    local r = uf_findroot(dst)
    if r == root then cnt = cnt - 1 end
  end
  ret[i] = cnt
end
print(table.concat(ret, " "))


Measured memory_bytes: 31608
def check(l):
    a = l[1]
    l.sort()
    if a == l[1] and l.count(a) == 1:
        return True
    else:
        return  False

n = int(input())
p = list(map(lambda x:int(x),input().split()))
cnt = 0
for i in range(3,n+1):
    if check(p[i-3:i]):
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <cstdlib>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int A[3][3];
  for (int r = 0; r < 3; ++r) {
    for (int c = 0; c < 3; ++c) {
      cin >> A[r][c];
    }
  }

  int N; cin >> N;
  set<int> b;
  for (int i = 0; i < N; ++i) {
    int x; cin >> x;
    b.insert(x);
  }

  // row check
  for (int r = 0; r < 3; ++r) {
    bool ok = true;
    for (int c = 0; c < 3; ++c) {
      if (!b.count(A[r][c])) {
        ok = false;
      }
    }
    if (ok) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  // col check
  for (int c = 0; c < 3; ++c) {
    bool ok = true;
    for (int r = 0; r < 3; ++r) {
      if (!b.count(A[r][c])) {
        ok = false;
      }
    }
    if (ok) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  // naname check
  bool ok = true;
  for (int i = 0; i < 3; ++i) {
    if (!b.count(A[i][i])) ok = false;
  }
  if (ok) {
    cout << "Yes" << endl;
    return 0;
  }

  // naname check
  ok = true;
  for (int i = 0; i < 3; ++i) {
    if (!b.count(A[i][2-i])) ok = false;
  }
  if (ok) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define false 1
#define true 0
using namespace std;
int main (){
int a,b,N,s,f,ans=true;
cin>>a>>b;
cin>>N;
for (int i=0;i<N;i++){
        cin>>s>>f;
        if ( (s<=a&&f>=b) || (s>a&&s<b) || (f<b&&f>a) ){
                ans=false;
        }
        //cout<<ans<<"CHECK"<<endl;
        //ans=true;
}

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



Measured memory_bytes: 3136
n = int(input())
li_1 = [list(map(int,input().split())) for i in range(n)]
li = [[0,0,0]] + li_1
for i in range(n):
  x = abs(li[i][1]-li[i+1][1])
  y = abs(li[i][2]-li[i+1][2])
  t = li[i+1][0] - li[i][0]
  c = t - x - y
  if c < 0 or c%2 == 1:
    print("No")
    break
  elif i == n-1:
    print("Yes")

Measured memory_bytes: 28068
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S.size() 配列名.Length()
using namespace std;
typedef unsigned long long ll;

int main(void){
	int n;
	cin >> n;
	int h[n + 1]; rep(i, n) cin >> h[i + 1];

	int dp[100000];

	dp[1] = 0;
	dp[0] = 0;
	dp[2] = abs(h[2] - h[1]);

	for(int i = 3; i <= n; i++){
		dp[i] = min( dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2]
		+ abs(h[i - 2] - h[i]) );
	}

	cout << dp[n] << endl;

}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
using namespace std;
int N,mx;
int main() {
    scanf("%d",&N);
    for (int i = 0,H;i < N;i++) {
        scanf("%d",&H);
        if (mx-1 > H) return printf("No\n"),0;
        mx = max(mx,H);
    }
    printf("Yes\n");
}


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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=1e5+5;
int n,a[MAXN];
int dp[5005][5005];
int dfs(int i,int j){
	if(dp[i][j]!=-1)return dp[i][j];
	if(i+1>n||j>a[i+1])return dp[i][j]=(!dfs(i,j+1));
	return dp[i][j]=(!(dfs(i+1,j)&dfs(i,j+1)));
}
int main() {
//	srand((unsigned)time(NULL));
//	n=30;
//	for(int i=1;i<=n;++i)a[i]=rand()%20+1;
	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	sort(a+1,a+n+1);reverse(a+1,a+n+1);
	for(int i=1;i<=n+1;++i){
		if(a[i]==i){
			int j;
			for(j=i;j<=n;++j)if(a[j]!=a[i])break;
			--j;
			if((j-i+1)&1)puts("Second");
			else puts("First");
			return 0;
		}
		if(a[i]<i){
			assert(i>1);
			if(a[i]==i-1){
				int j;
				for(j=i;j<=n;++j)if(a[j]!=a[i])break;
				--j;
				bool x=((j-i+1)&1)?0:1;
				bool y=((a[i-1]-i+1)&1)?0:1;
				if(!(x&y))puts("First");
				else puts("Second");
			}else{
				if((a[i-1]-i+1)&1)puts("First");
				else puts("Second");
			}
			return 0;
		}
	}
	for(int i=1;i<=n;++i)cout<<a[i]<<" ";cout<<endl;

	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=n;++i){
		int j;
		for(j=i;j<=n;++j)if(a[j]!=a[i])break;
		--j;
		if((j-i+1)&1)dp[i][a[i]]=0;
		else dp[i][a[i]]=1;
	}
	if(dfs(1,1))cout<<"First"<<endl;
	else cout<<"Second"<<endl;
	for(int i=a[1];i>=1;--i){
		for(int j=1;j<=n;++j)if(a[j]<i)break;else cout<<dfs(j,i)<<" ";
		cout<<endl;
	}
	return 0;
}

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

void get_bit(bool *bit, int N, int v)
{
    for (int i = 0; i < N; i++) {
        if (v & (1 << i)) {
            bit[i] = true;
        }
    }
}

int main(int argc, const char * argv[]) {
    int H, W, K;
    cin >> H >> W >> K;
    
    char **mat = new char*[H];
    for (int i = 0; i < H; i++) {
        mat[i] = new char[W];
    }
    
    int black = 0;
    int *black_g = new int[H];
    int *black_r = new int[W];
    
    for (int i = 0; i < H; i++) {
        int b = 0;
        for (int j = 0; j < W; j++) {
            cin >> mat[i][j];
            if (mat[i][j] == '#') {
                b++;
            }
        }
        black_g[i] = b;
        black += b;
    }
    
    const int BLACK = black;
    
    for (int j = 0; j < W; j++) {
        int b = 0;
        for (int i = 0; i < H; i++) {
            if (mat[i][j] == '#'){
                b++;
            }
        }
        black_r[j] = b;
    }
    
    int g_bit = 0;
    for (int i = 0; i < H; i++) {
        g_bit += (1 << i);
    }
    
    int r_bit = 0;
    for (int j = 0; j < W; j++) {
        r_bit += (1 << j);
    }

    bool *g_idx = new bool[H];
    bool *r_idx = new bool[W];
    int ans = 0;
    for (int i = 0; i <= g_bit; i++) {
        int black0 = BLACK;
        
        memset(g_idx, false, sizeof(bool) * H);
        get_bit(g_idx, H, i);
        for (int k = 0; k < H; k++) {
            if (g_idx[k]) {
                black0 -= black_g[k];
            }
        }
        
        for (int j = 0; j <= r_bit; j++) {
            black = black0;
            
            memset(r_idx, false, sizeof(bool) * W);
            get_bit(r_idx, W, j);
            
            for (int l = 0; l < W; l++) {
                if (r_idx[l]) {
                    black -= black_r[l];
                }
            }
            
            // 重複して引いたものを戻す。
            for (int k = 0; k < H; k++) {
                if (!g_idx[k]) {continue;}
                for (int l = 0; l < W; l++) {
                    if (!r_idx[l]) { continue;}

                    if (mat[k][l] == '#'){
                        black++;
                    }
                }
            }
            
            if (K == black) {
                ans++;
            }
        }
    }
    
    cout << ans << endl;
    
    
    delete[] black_g;
    delete[] black_r;
    
    for (int i = 0; i < H; i++) {
        delete[] mat[i];
    }
    delete[] mat;
    
    return 0;
}

Measured memory_bytes: 3216
#include <stdio.h>

int main(){
  char s[2][3];
  scanf("%s",s[0]);
  scanf("%s",s[1]);
  if(s[0][0]==s[1][2]&&s[0][1]==s[1][1]&&s[0][2]==s[1][0]) printf("YES");
  else printf("NO");
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
typedef long long int LL;
const int INF=1e9+7;

int main(){
	LL n,m;
	LL s=0;
	cin>>n>>m;
	s=(n/m)*(n/m)*(n/m);
	if(m%2==0){
		m/=2;
		n=((n/m)+1)/2;
		s+=n*n*n;
	}
	cout<<s<<endl;
	
	return 0;
}


Measured memory_bytes: 256