akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)


const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}
//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	int t = -1;
	int f = vec.size();
	while (f - t > 1) {
		int m = (t + f) / 2;
		if (vec[m] < xx) {
			t = m;
		}
		else {
			f = m;
		}
	}
	return f;
}
template<typename T>
void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>
void vecin(vector<TT>& vec) { 
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}


// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す
// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx == 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}





signed main() {
	char c;
	cin >> c;
	if (c <= 'z' && c >= 'a') {
		cout << "a" << endl;
	}
	else cout << "A" << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define forn(i,a,b) for (int i = a; i <= b; i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define pi pair <int, int>
#define sz(x) (int)((x).size())
#define int long long

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

const ll inf = 0x3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int N = 2e5 + 11;

int n,x;
vector<int>v[N];

pi dfs(int nod, int p){
    int w = 1;
    int b = 1;
    for(auto it: v[nod]){
        if(it == p)continue;
        pi d = dfs(it,nod);
        w = (w * (d.ff + d.ss))%mod;
        b = (b * d.ff)%mod;
    }

    return mp(w,b);
}

int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0); cerr.tie(0); cout.tie(0);

    cin >> n;

    for(int i = 2; i <= n; i++){
        int o,u;
        cin >> o >> u;
        v[o].pb(u);
        v[u].pb(o);
    }

    pi p = dfs(1,0);


    rc((p.ff + p.ss + mod)%mod);
return 0;
}

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

int main(){

const int MAX_NO=100000;
int m[MAX_NO],f[MAX_NO],r[MAX_NO];
char hyouka[MAX_NO];
int a=0;
int b=0;

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

cin>>m[i]>>f[i]>>r[i];

a++;

for(int i=1;i<20000000;i++){
b++;
b--;
b++;
b--;
}

if(m[i]==-1 && f[i]==-1 && r[i]==-1){
goto aa;
}

if(m[i]==-1 || f[i]==-1){
hyouka[i]='F';
}

else if((m[i]+f[i])>=80){
hyouka[i]='A';
}
else if((m[i]+f[i])>=65){
hyouka[i]='B';
}

else if((m[i]+f[i])>=50){
hyouka[i]='C';
}

else if((m[i]+f[i])>=30 && r[i]<50){
hyouka[i]='D';
}
else if((m[i]+f[i])>=30 && r[i]>=50){
hyouka[i]='C';
}

else if((m[i]+f[i])<30){
hyouka[i]='F';
}

}

aa:;

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

cout<<hyouka[i]<<endl;

}

return 0;
}

Measured memory_bytes: 1172
#include<stdio.h>
#include<math.h>
#define MAX 1000000
int cnt,A[MAX];
void insertionSort(int *A,int n,int g){
  int i,j,v;
  for(i=g;i<n;i++){
    v = A[i];
    j = i - g;
    while( j >= 0 && A[j] > v ){
      A[j+g] = A[j];
      j = j - g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(int *A,int n){
  int i,m;
  cnt=0;
  m = pow(n,1.25);
  if(m>=100) m=100;
  int G[m];
  G[0]=1;
  for(i=1;i<m;i++){
    if((G[i]=3*G[i-1]+1)>n) break;
  }
  m=i;
  for(i=m-1;i>=0;i--){
    insertionSort(A,n,G[i]);
  }
    printf("%d\n",m);
    for(i=m-1;i>0;i--) printf("%d ",G[i]);
    printf("%d\n",G[i]);
    printf("%d\n",cnt);
    for(i=0;i<n;i++) printf("%d\n",A[i]);
}

int main(){
  int i,n,A[MAX];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  shellSort(A,n);
  return 0;
}



Measured memory_bytes: 5804
def comb(a, b):
    if (a < b) or (a < 0) or (b < 0):
        return 0
    res = 1
    for i in range(b):
        res *= a - i
        res //= i + 1
    return res

def solve(n, k):
    s = str(n)
    d = len(s)
    def f(i, t, ok):
        if ok:
            return comb(d-i, t) * (9**t)
        elif t == 0:
            return 1
        elif i == d:
            return 0
        if s[i] == "0":
            return f(i+1, t, False)
        res = f(i+1, t, True)
        if t > 0:
            for j in range(1, 10):
                if int(s[i]) > j:
                    res += f(i+1, t-1, True)
                elif int(s[i]) == j:
                    res += f(i+1, t-1, False)
                else:
                    break
        return res
    return f(0, k, False)

n = int(input())
k = int(input())
print(solve(n, k))

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int main(void){
    while(1){
        int a,b,cnt=0;
        cin >> a >> b;
        if(a==0&&b==0) break;
        else{
            for(int i=1;i<=a;i++){
                for(int j=i+1;j<=a;j++){
                    if(1<=b-i-j&&b-i-j<=a&&j<b-i-j) cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
}



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

int main(){
  string s, t, u;
  int a, b;
  cin>>s>>t;
  cin>>a>>b;
  cin>>u;
  if(u==s)
    cout<<a-1<<" "<<b<<endl;
  else if(u==t)
    cout<<a<<" "<<b-1<<endl;
}

Measured memory_bytes: 3628
#include <stdio.h>

/* output function */
void trace(int A[], int N){
    int i;
    for( i = 0; i < N; i++ ){
        if( i > 0) printf(" "); // single space to separate elments
        printf("%d", A[i]);
    }
    printf("\n");
}

/* Selction Sort (0-origin) */
void SelectionSort(int A[], int N){
    int i, j, v, minj;
    int c = 0; // number of swap operations

    for( i = 0; i < N; i++){
        
        minj = i;
        
        for( j = i; j < N; j++){
            if( A[j] < A[minj]) minj = j;
        }

        if(i != minj){
            v = A[i];
            A[i] = A[minj];
            A[minj] = v;
            c++; // count up
        }
    }

    /* print sorted sequence */
    trace(A, N); 
    /* print the number of swap operations */
    printf("%d\n",c);
}

/* main function */
int main(){
    int N, i;
    int A[100];

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

    SelectionSort(A, N);

    return 0;    
}


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

int main(){
  int64_t H,N;
  cin>>H>>N;
  int64_t ans=0;
  for(int i=0;i<N;++i){
    int64_t A;
    cin>>A;
    ans += A;
  }

  if(ans>=H) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=sqrt(n);i>1;i--){
        if(n%i==0){
            ans=i-1+n/i-1;
            break;
        }
    }
    if(ans==0){
        cout<<n-1<<endl;
    } else {
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> dp(N + 1, N);
    dp[0] = 0;
    dp[1] = 1;
    for (int i = 6; i <= N; i *= 6) dp[i] = 1;
    for (int i = 9; i <= N; i *= 9) dp[i] = 1;
    for (int i = 2; i <= N; i++) {
        dp[i] = dp[i - 1] + 1;
        for (int j = 6; i - j >= 0; j *= 6) {
            auto t = dp[i - j] + 1;
            if (t < dp[i]) dp[i] = t;
        }
        for (int j = 9; i - j >= 0; j *= 9) {
            auto t = dp[i - j] + 1;
            if (t < dp[i]) dp[i] = t;
        }
    }
    cout << dp[N] << endl;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1'000'000'007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp[101][4][4][4];
void solve()
{
  int n;
  cin >> n;
  dp[0][3][3][3] = 1;

  for(int len = 0; len <= n; ++len) {
    for(int i1 = 0; i1 < 4; ++i1) {
      for(int i2 = 0; i2 < 4; ++i2) {
        for(int i3 = 0; i3 < 4; ++i3) {
          if (dp[len][i1][i2][i3].x == 0) continue;

          for(int c = 0; c < 4; ++c)
          { // cut
            if (c == 2 && i1 == 1 && i2 == 0) continue; // AGC
            if (c == 1 && i1 == 2 && i2 == 0) continue; // ACG
            if (c == 2 && i1 == 0 && i2 == 1) continue; // GAC
            if (c == 2 && i2 == 1 && i3 == 0) continue; // AG C
            if (c == 2 && i1 == 1 && i3 == 0) continue; // A GC

            dp[len + 1][c][i1][i2] += dp[len][i1][i2][i3];
          }
        }
      }
    }
  }

  mint ans = 0;
  for(int i1 = 0; i1 < 4; ++i1) {
    for(int i2 = 0; i2 < 4; ++i2) {
      for(int i3 = 0; i3 < 4; ++i3) {
        ans += dp[n][i1][i2][i3];
      }
    }
  }

  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3680
#include<stdio.h>

int main(){
	int i,a,b,c,cnt,tmp;
	scanf("%d",&cnt);
	for(i=0;i<cnt;i++){
		scanf("%d %d %d",&a,&b,&c);
		if(a > b){
			tmp = a;
			a = b;
			b = tmp;
		}
		if(b > c){
			tmp = b;
			b = c;
			c = tmp;
		}
		if(c*c == b*b + a*a) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  while (1) {
    int n,x; cin>>n>>x;
    if (n==0 && x==0) return 0;

    ll ans = 0;
    for (int i=1; i<=n; i++) {
      for (int j=i+1; j<=n; j++) {
        for (int k=j+1; k<=n; k++) {
          if (i+j+k == x) ans++;
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3132
#include <iostream>
#include <string>
#define ll long long
using namespace std;

const int MOD = 1000000007;

int main() {
  string S;
  cin >> S;

  int len = S.size();
  ll a = 0, ab = 0, abc = 0, all_s = 1;

  for (int i = 0; i < len; i++) {
    if (S[i] == 'A')
      a = (a + all_s) % MOD;
    else if (S[i] == 'B')
      ab = (ab + a) % MOD;
    else if (S[i] == 'C')
      abc = (abc + ab) % MOD;
    else if (S[i] == '?') {
      abc   = (abc * 3 + ab) % MOD;
      ab    = (ab * 3 + a) % MOD;
      a     = (a * 3 + all_s) % MOD;
      all_s = (all_s * 3) % MOD;
    }
  }
  cout << abc << endl;
}

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

int main(){
    int N;
    cin>>N;
    ll a[N];
    for(int i=0;i<N;i++)scanf("%lld", &a[i]);
    ll mi,ma,su;
    mi=a[0];
    ma=a[0];
    su=0;
    for(int i=0; i<N; i++){
        if(mi > a[i])mi=a[i];
        if(ma < a[i])ma=a[i];
        su+=a[i];
    }
    printf("%lld %lld %lld\n", mi, ma, su);
    return 0;
}


Measured memory_bytes: 3212
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int n = Integer.parseInt(sc.next());
            if (n == 0) break;

            List<Integer> S = new ArrayList<>();
            double ave = 0.0;
            for (int i = 0; i < n; i++) {
                S.add(Integer.parseInt(sc.next()));
                ave += S.get(i);
            }
            ave /= n;

            double ans = 0.0;
            for (int i = 0; i < n; i++) {
                ans += Math.pow((S.get(i) - ave), 2.0);
            }
            ans /= n;

            System.out.println(Math.sqrt(ans));
        }
    }
}

Measured memory_bytes: 29948
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


const int MAXN = 100010;

class UnionFind {
    int par[MAXN];
    int rank[MAXN];

public:
    UnionFind(int n){
        rep(i, n){
            par[i] = i;
            rank[i] = 0;
        }
    }

    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }
};

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

    int n, m, x, y, tmp;
    vector<int> p;
    vector<pair<int, int>> xy;
    p.push_back(0);

    cin >> n >> m;
    rep(i, n){
        cin >> tmp;
        p.push_back(tmp);
    }
    rep(i, m){
        cin >> x >> y;
        xy.push_back(make_pair(x, y));
    }

    UnionFind tree(n+1);
    for(auto e : xy){
        tree.unite(e.first, e.second);
    }

    ll res = 0;
    reps(i, 1, n+1){
        if(p[i] == i){
            res++;
        }else if(tree.same(i, p[i])){
            res++;
        }
    }

    cout << res << endl;

    return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 200000
i64 N;
i64 A[MAX_N + 1]; // 1-indexed


void solve() {
  i64 box[MAX_N + 1]; // box[i] = 0 or 1 no ball or not
  for (i64 i = N; i >= 1; i--) {
    i64 n = N / i;
    i64 j = i * (N / i);
    i64 s = 0;
    while(j > i) {
      s += box[j];
      j -= i;
    }
    if (s % 2 == A[i]) {
      box[i] = 0;
    } else {
      box[i] = 1;
    }
  }

  i64 s = 0;
  REPS(i, N) {
    s += box[i];
  }
  cout << s << endl;
  s = 0;
  REPS(i, N) {
    if (box[i] == 1) {
      if (s > 0) cout << " ";
      cout << i;
      s++;
    }
  }
  cout << endl;
}


int main() {
  cin >> N;
  REPS(i, N) cin >> A[i];

  solve();

  return 0;
}

Measured memory_bytes: 3968
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << fixed << setprecision(10) << ((double)W * (double)H / 2) << " "
       << ((x + x == W) && (y + y == H)) << endl;
  return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n    = s.size();
    string t = "keyence";
    int nt   = t.size();
    if (n < nt) {
        cout << "NO"
             << "\n";
        return 0;
    }
    if (s.substr(0, nt) == t || s.substr(n - nt, nt) == t) {
        cout << "YES"
             << "\n";
        return 0;
    }
    for (int i = 1; i < nt; ++i) {
        int fi = i, la = nt - i;
        // cout << s.substr(0, fi) << " " << s.substr(n - la, la) << "\n";
        if (s.substr(0, i) == t.substr(0, i) && s.substr(n - la, la) == t.substr(nt - la, la)) {
            cout << "YES"
                 << "\n";
            return 0;
        }
    }
    cout << "NO"
         << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<malloc.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	 int n,i,j,s=0,t;
	 cin>>n;
	 for(i=1;i<n-1;i++)
//	 for(j=1,t=(n/i)+1;j<=t;j++)
	 {
	 	s+=(n-1)/i;
	 }
	 cout<<s+1;
}

Measured memory_bytes: 3616
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize(4)
//#pragma GCC optimize("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <bits/extc++.h>
#define fi first
#define se second
#define db double
#define mp make_pair
#define pb push_back
#define mt make_tuple
//#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 1000000007
#define ld long double
//#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
#define bpc __builtin_popcount
#define base 1000000000000000000ll
#define fin freopen("a.txt","r",stdin)
#define fout freopen("a.txt","w",stdout)
#define fio ios::sync_with_stdio(false);cin.tie(0)
#define mr mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void sub(ll &a,ll b){a-=b;if(a<0)a+=mod;}
inline void add(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}
template<typename T>inline T const& MAX(T const &a,T const &b){return a>b?a:b;}
template<typename T>inline T const& MIN(T const &a,T const &b){return a<b?a:b;}
inline ll mul(ll a,ll b,ll c){return (a*b-(ll)((ld)a*b/c)*c+c)%c;}
inline ll qp(ll a,ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod,b>>=1;}return ans;}
inline ll qp(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=mul(ans,a,c);a=mul(a,a,c),b>>=1;}return ans;}

using namespace std;
//using namespace __gnu_pbds;

const ld pi = acos(-1);
const ull ba=233;
const db eps=1e-5;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=1000+10,maxn=2000000+10,inf=0x3f3f3f3f;

int ans[N][N];
int main()
{
    int n,m,a,b;scanf("%d%d%d%d",&n,&m,&a,&b);
    int x=2*min(m-a,a);
    for(int i=1;i<=b;i++)
    {
        for(int j=1;j<=x;j++)ans[i][j]=j&1;
        for(int j=x+1;j<=m;j++)ans[i][j]=0;
    }
    for(int i=b+1;i<=n;i++)
    {
        for(int j=1;j<=x;j++)ans[i][j]=!(j&1);
        for(int j=x+1;j<=m;j++)ans[i][j]=1;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)printf("%d",ans[i][j]);
        puts("");
    }
    return 0;
}
/********************

********************/


Measured memory_bytes: 5120
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <queue>
using namespace std;
int pos[110000];
int erfen(int n, int x)
{
    int l = 1, r = n, ans = 1;
    while(l<=r)
    {
        int mid = (l+r)/2;
        if(pos[mid]<=x)
        {
            ans = mid;
            l = mid+1;
        }
        else
            r = mid-1;
    }
    return ans;
}
int main()
{
    int d, n, m;
    while(scanf("%d", &d), d)
    {
        scanf("%d %d", &n, &m);
        for(int i=1; i<n; i++)
            scanf("%d", &pos[i]);

        sort(pos+1, pos+n);

        long long ans = 0;
        for(int i=1; i<=m; i++)
        {
            int x;
            scanf("%d", &x);
            if(x<=pos[1])
                ans += min(pos[1]-x, x);
            else
            {
                int Index = erfen(n-1, x);
                if(Index == n-1)
                    ans += min(x-pos[n-1], d-x);
                else
                    ans += min(x-pos[Index], pos[Index+1]-x);
            }

        }

        printf("%lld\n", ans);
    }
    return 0;
}



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

#define ll long long
#define vec vector<ll>
#define sortv(a); sort(a.begin(), a.end());
#define rev(a); reverse(a.begin(), a.end());
#define FOR(i,a,b) for (ll i = (ll)(a); i < (b); i++)
#define ROF(i,a,b) for (ll i = (ll)(b)-1; i >= (a); i--)
#define printarray(a) FOR(Q,0,(int)(a).size()) cout<<(a)[Q]<<" "; cout<<'\n';

ll MOD = 1000000007;
ll INF = 1LL << 60;

/*****************************************************************************/
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	// freopen("input.txt", "r", stdin);
	int n;cin>>n;
	ll b[n];ll a[n];
	FOR(i,0,n)cin>>b[i];
	FOR(i,0,n)a[i]=b[i];
	FOR(i,1,n)a[i]+=a[i-1];
	int l=0;
	int r=2;
	ll out=INF,minn,maxx;
	FOR(i,1,n-2) {
		ll temp,l1,l2,r1,r2,cum;
		while(l<i) {
			l1=a[l];
			l2=a[i]-a[l];
			cum=abs(l1-l2);
			if (l+1==i) break;
			temp=abs(a[l+1]-(a[i]-a[l+1]));
			if (temp<cum) {
				l++;
			} else {
				break;
			}
		}
		while(r<n-1) {
			r1=a[r]-a[i];
			r2=a[n-1]-a[r];
			cum=abs(r1-r2);
			if (r+1==n-1) break;
			temp=abs(a[r+1]-a[i]-(a[n-1]-a[r+1]));
			if (temp<cum) {
				r++;
			} else {
				break;
			}
		}
		minn=min(min(min(r1, r2),l1),l2);
		maxx=max(max(max(r1, r2),l1),l2);
		// cout<<i<<" "<<l<<" "<<r<<" "<<l1<<" "<<l2<<" "<<r1<<" "<<r2<<" "<<minn<<" "<<maxx<<'\n';
		out=min(out,abs(maxx-minn));
	}

	if (n==4) {
		minn=*min_element(b,b+4);
		maxx=*max_element(b,b+4);
		out=min(out,abs(maxx-minn));
	}
	cout<<out;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll n,q;
string s;
vector<pair<char,char>> a;

bool isOk(ll mid, bool flg){
  ll pos=mid;
  rep(i,q){
    char now=s[pos];
    char t=a[i].first, d=a[i].second;
    if(now==t){
      if(d=='R') pos++;
      else pos--;
    }
    if(flg){
      if(pos>=n) return false;
      if(pos<0) return true;
    }else{
      if(pos>=n) return true;
      if(pos<0) return false;
    }
  }
  
  return false;
}


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n>>q;
  a.resize(q);
  cin>>s;
  rep(i,q){
    char t,d; cin>>t>>d;
    a[i]={t,d};
  }
  ll ans=0;
  ll ok=-1, ng=n;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    if(isOk(mid,true)) ok=mid;
    else ng=mid;
  }
  ans+=ok+1;
  
  ok=n, ng=-1;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    if(isOk(mid,false)) ok=mid;
    else ng=mid;
  }
  ans+=n-ok;
  cout<<n-ans<<endl;
}

Measured memory_bytes: 1104
#include <stdio.h>
#include <string.h>

int main()
{   char z[1000];
    gets(z);
    if((z[(strlen(z)-1)])!='s')
    {
        printf("%ss", z);
    }
    else if((z[(strlen(z)-1)])=='s')
    {
        printf("%ses", z);
    }


    return 0;
}

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

static const int MMAX = 20;
static const int NMAX = 50000;
static const int INFTY = (1<<29);

int main(){
    int n,m;
    int C[21];
    int T[NMAX+1];
    
    cin >> n >> m;
    for(int i=1; i<=m; i++){
        cin >> C[i];
    }
    
    for(int i=0;i<=NMAX; i++){
        T[i] = INFTY;
    }
    T[0] = 0;
    for(int i=1; i<=m; i++){
        for(int j=0; j+C[i]<=n; j++){
            T[j+C[i]] = min(T[j+C[i]], T[j]+1);
        }
    }
    
    cout << T[n] << endl;
}

Measured memory_bytes: 3280
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int N = sc.nextInt();
        int max = 0;
        int pre = -1;
        int first = 0;
        int last = 0;
        for (int i = 0; i < N; i++) {
            int data = sc.nextInt();
            if (pre == -1) {
                first = data;
            } else {
                int dist = data - pre;
                if (dist > max)
                    max = dist;
            }
            if (i == N - 1)
                last = data;
            pre = data;
        }
        if (K - last + first > max)
            max = K - last + first;
        System.out.println(K - max);

    }
}


Measured memory_bytes: 64780
# modular inverse for positive a and b and nCk mod MOD depending on modinv

def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

MOD = 10 ** 9 + 7

N,K = map(int,input().split())

a = list(map(int,input().split()))
a.sort()

Combination = []

for i in range(N):
    if i < K - 1:
        Combination.append(0)
    elif i == K - 1:
        Combination.append(1)
    else:
        Combination.append(Combination[-1] * i * modinv(i - K + 1, MOD) % MOD)

        
ans = 0

for i in range(N):
    ans += a[i] * Combination[i]
    ans -= a[i] * Combination[N - i - 1]
    ans %= MOD

print(ans)

Measured memory_bytes: 91452
n, y = [int(i) for i in input().split(" ")]
a = 0
f = False

while y - 1000 * n - 9000 * a >= 0:
    r = (y - 1000 * n - 9000 * a)
    b = r // 4000
    if r % 4000 == 0 and n - a - b >= 0:
        print(a, b, n - a - b)
        f = True
        break
    a += 1

if not f:
    print(-1, -1, -1)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) { //gcdを返す
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}

int main(){
	vl A(3);
	cin >> A[0] >> A[1] >> A[2];
	sort(A.begin(), A.end());
	if(A[0] + A[1] == A[2]){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <functional>
#include <stdexcept>
#include <streambuf>
#include <exception>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <typeinfo>
#include <utility>
#include <complex>
#include <numeric>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <locale>
#include <memory>
#include <iosfwd>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <ios>
#include <new>
#include <set>
 
#define int long long
#define ll long long 
#define F first
#define S second
#define make make_pair
#define pb push_back
#define sz(x) (ll)(x.size()) 
#define all(x) x.begin (), x.end ()

using namespace std;

typedef long double ld;

const int MOD = (int)1e9 + 7;
const int N = (int)2e6+ 222;
const ll INF = (ll)1e18;
const double eps = (double)1e-6;

int n;

void solve () {
    cin >> n;
    cout << n * n;
}

signed main () {
    #ifdef Maga
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int t = 1;
    while (t --) {
    	solve ();
    }
    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                       \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define pb push_back
#define ll long long
/*

to make a change to a sort do this : 

sort (a.begin(), a.end(), [&](int x , int y){
	return x<y;
})

*/
struct Q
{
	ll x, y;
	ll operator*(Q b)
	{
		// cout << x << " "<< y<<endl;
		// cout << b.y << " "<< b.x << endl;
		return (x * b.y - y * b.x);
	}
	void read()
	{
		cin >> x >> y;
	}
	Q operator-(Q b)
	{
		return {x - b.x, y - b.y};
	}
	double operator%(Q b)
	{
		return sqrt(pow(x - b.x, 2) + pow(y - b.y, 2));
	}
};
bool inters(Q a, Q b, Q c, Q d)
{
	for (int i = 0; i < 2; i++)
	{
		Q zg = (b - a), zg1 = (b - c), zg2 = (b - d);
		ll v1 = zg * zg1, v2 = zg * zg2;
		if (v1 * v2 > 0)
		{
			return false;
		}
		else if (v1 == 0 && v2 == 0)
		{
			if (max(a.x, b.x) < min(c.x, d.x) || max(a.y, b.y) < min(c.y, d.y))
			{
				return false;
			}
		}
		swap(a, c);
		swap(b, d);
	}
	return true;
}
bool inter(Q a, Q b, Q c, Q d)
{
	if ((b - a) * (c - a) == 0) // check if b a (c) is coliner
	{
		if (((c.x <= b.x && c.x >= a.x) || (c.x <= a.x && c.x >= b.x)) && ((c.y <= b.y && c.y >= a.y) || (c.y <= a.y && c.y >= b.y)))
			return true;
		else
			return false;
	}
	else if ((b - a) * (d - a) == 0) // check if b a (d) is coliner
	{
		if (((d.x <= b.x && d.x >= a.x) || (d.x <= a.x && d.x >= b.x)) && ((d.y <= b.y && d.y >= a.y) || (d.y <= a.y && d.y >= b.y)))
			return true;
		else
			return false;
	}
	else if ((d - c) * (a - c) == 0) // check if d c (a) is coliner
	{
		if (((a.x <= d.x && a.x >= c.x) || (a.x <= c.x && a.x >= d.x)) && ((a.y <= d.y && a.y >= c.y) || (a.y <= c.y && a.y >= d.y)))
			return true;
		else
			return false;
	}
	else if ((d - c) * (b - c) == 0) // check if d c (b) is coliner
	{
		if (((b.x <= d.x && b.x >= c.x) || (b.x <= c.x && b.x >= d.x)) && ((b.y <= d.y && b.y >= c.y) || (b.y <= c.y && b.y >= d.y)))
			return true;
		else
			return false;
	}
	else
	{

		bool a1 = true, a2 = true, a3 = true, a4 = true;
		if ((a - c) * (d - c) < 0)
		{
			a1 = false;
		}
		if ((b - c) * (d - c) < 0)
		{
			a2 = false;
		}
		if ((c - a) * (b - a) < 0)
		{
			a3 = false;
		}
		if ((d - a) * (b - a) < 0)
		{
			a4 = false;
		}
		if (a1 != a2 && a3 != a4)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
}

int main()
{
	FAST_IO
char a;
cin >> a;
if (a =='z')cout << "a"<<endl;else 
cout << char (a+1) <<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
typedef long long int ll;
const ll MODP = 1000000007LL;


using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;


typedef long long int ll;



ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}

ll invMod(ll a, ll m) {
  ll x, y;
  if (extgcd(a, m, x, y) == 1) return (x + m) % m;
  else                         return 0; // unsolvable
}


ll powmod(ll n, ll m){ //TODO: 繰り返し二乗法に改善
	ll ret = 1;
	for(int i=0;i<m;i++){
		ret = (ret * n) % MODP;
	}
	return ret;
}


ll comb(ll n, ll m){
	if (m<0 || n<m) return 0; //failsafe
	ll ret = 1;
	for(int i=1;i<=m;i++){
		ret = (ret * (n-m+i)) % MODP;
		ret = (ret * invMod(i, MODP)) % MODP;
	}
	return ret % MODP;
}



ll n;
static ll f[1000010];

int main(void){
	cin >> n;
	f[0] = 1;
	for(ll i=1;i<=n+4;i++){
		f[i] = (f[i-1] * i) % MODP;
	}
	ll ans = f[n], ans2 = 0;
	for(ll i=(n+1)/2;i<n;i++){
		ll val = (f[i] * f[i-1]) % MODP;
		//
		val = (val * f[n-1-i]) % MODP;
		ll denom = (f[2*i-n] * f[n-1-i]) % MODP;
		val = val * invMod(denom, MODP) % MODP;
		ans2 = (ans2 + val) % MODP;
	}
	ans = (ans - ans2 + MODP) % MODP;
	cout << ans << endl;











	return 0;
}


Measured memory_bytes: 8064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        
        String a = s.substring(0, (s.length()-1)/2);
        String b = s.substring(((s.length()+3)/2)-1);
        String ans = "Yes";
        int cnt = (int)Math.floor(a.length()/2);
        int flg = 1;
        
        for(int i=0; i<Math.floor(s.length()/2); i++){
            if(s.charAt(i)!=s.charAt(s.length()-1-i)){
                ans = "No";
                flg = 0;
                break;
            }
        }
        
        if(flg==1){
            for(int i=0; i<cnt; i++){
                if(a.charAt(i)!=a.charAt(a.length()-1-i)){
                    ans = "No";
                    break;
                }
                if(b.charAt(i)!=b.charAt(b.length()-1-i)){
                    ans = "No";
                    break;
                }
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <string>


using namespace std;


int main()
{
   
   int n,k;
   string S;
   
   cin >> n >> k >> S;
   
   if(S[k-1]=='A')S[k-1]='a';
   if(S[k-1]=='B')S[k-1]='b';
   if(S[k-1]=='C')S[k-1]='c';

   cout << S << endl;

	return 0;
}

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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

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

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

vector<pi> Solve(vi a){
	int n=a.size();
	int x=max_element(ALL(a))-a.begin();
	vector<pi> ans;
	REP(i,n)
		ans.PB(pi(x,i));
	REP(i,n-1)
		ans.PB(pi(i,i+1));
	return ans;
}
void Output(vector<pi> op){
	cout<<op.size()<<endl;
	for(auto p:op)
		cout<<p.first+1<<" "<<p.second+1<<endl;
	exit(0);
}

signed main(){
	int n=read();
	vi a(n);REP(i,n)a[i]=read();
	int mx=*max_element(ALL(a)),mn=*min_element(ALL(a));
	vector<pi> ans;
	if(mx>=-mn)
		ans=Solve(a);
	else{
		for(auto&v:a)v*=-1;
		reverse(ALL(a));
		ans=Solve(a);
		for(auto&p:ans){
			p.first=n-1-p.first;
			p.second=n-1-p.second;
		}
	}
	Output(ans);
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

const int mod = 998244353;

int mul(int a, int b) {
  return (long long) a * b % mod;
}

void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

const int maxn = (int) 2e5 + 5, maxx = (int) 1e6 + 5;
int inv[maxx];
int lDiv[maxx], pid[maxx];
vector<int> pr;

void precalc() {
  inv[1] = 1;
  for (int i = 2; i < maxx; i++) {
    inv[i] = (mod - (long long) (mod / i) * inv[mod % i] % mod) % mod;
  }
  pid[1] = -1;
  for (int i = 2; i < maxx; i++) {
    if (!lDiv[i]) {
      lDiv[i] = i;
      pid[i] = sz(pr);
      pr.push_back(i);
    } else {
      pid[i] = -1;
    }
    for (int j = 0; j < sz(pr) && pr[j] <= lDiv[i]; j++) {
      int p = pr[j] * i;
      if (p >= maxx) {
        break;
      }
      lDiv[p] = pr[j];
    }
  }
}

int n;
int a[maxn];

bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  return true;
}

int sum[maxx];

void solve() {
  for (int i = 1; i < maxx; i++) {
    sum[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    add(sum[a[i]], a[i]);
  }
  for (int i = 1; i < maxx; i++) {
    for (int j = 2 * i; j < maxx; j += i) {
      add(sum[i], sum[j]);
    }
  }
  for (int i = 1; i < maxx; i++) {
    sum[i] = mul(sum[i], sum[i]);
  }
  for (int i = maxx - 1; i >= 1; i--) {
    for (int j = 2 * i; j < maxx; j += i) {
      add(sum[i], mod - sum[j]);
    }
  }
  int res = 0;
  for (int i = 1; i < maxx; i++) {
    add(res, mul(sum[i], inv[i]));
  }
  for (int i = 0; i < n; i++) {
    add(res, mod - a[i]);
  }
  res = mul(res, inv[2]);
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 17144
/**akshaykumar99**/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;

#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;
 
int main()
{
    IOS();
	int n,i,j,k;
	cin>>n;
	string s;
	cin>>s;
	vector<int> v[10];
	f(i,0,n)
	{
		v[s[i]-'0'].pu(i);
	}
	f(i,0,10)
	{
		sort(all(v[i]));
	}
	int ans=0;
	f(i,0,10)
	{
		int w=0;
		if(v[i].size()>=3)
			ans++;
		if(!v[i].empty())
		{
			if(v[i].size()>=2)
			{
				f(j,0,10)
				{
					if(i!=j)
					{
						auto x=upper_bound(all(v[j]),v[i][1]);
						if(x!=v[j].end())
							w++;
						if(w==1)
						{
							ans++;
							w=0;
						}
					}
				}
			}
			w=0;
			f(j,0,10)
			{
				if(i!=j && !v[j].empty() )
				{
					auto x=upper_bound(all(v[j]),v[i][0]);
					if(x!=v[j].end() && (x-v[j].begin())!=v[j].size()-1)
						w++;
					if(w==1)
					{
						ans++;
						w=0;
					}
				}
			}
			f(j,0,10)
			{	
				w=0;
				if(i!=j && !v[j].empty() )
				{
					auto x=upper_bound(all(v[j]),v[i][0]);
					if(x!=v[j].end())
						w++;
					if(w==1)
					{
						f(k,0,10)
						{
							if(k!=j && !v[k].empty() )
							{
								auto ww=upper_bound(all(v[k]),v[j][x-v[j].begin()]);
								if(ww!=v[k].end())
									w++;
								if(w==2)
								{
									ans++;
									w=1;
								}
							}
						}
					}
				}
			}
		}
	}
	cout<<ans<<'\n';


    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll a, b, c;
	cin >> a >> b >> c;
	cout << ((a == b && b == c) ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

print(II()**3)


Measured memory_bytes: 3064