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

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

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


void calc_primefactorization(long long in, vector<vector<long long> >& out){
	
	long long N = in, Ntmp;
	long long p,e,p_init = 2;
	vector<long long> out_tmp(2);
	
	if( in == 1 ){
		out_tmp[0] = 1;
		out_tmp[1] = 1;
	}
	else{
		while( 1 ){

			Ntmp = N;
				
			p = N;
			e = 1;

			for(long long i = p_init;i * i <= N;i++){
						
				if( Ntmp % i == 0 ){
					e = 0;
					while( 1 ){
						if( Ntmp % i != 0 ){
							break;
						}
						else{
							Ntmp = Ntmp / i;
							e++;
						}
					}
					p = i;
					break;
				}
				
			}
			
			out_tmp[0] = p;
			out_tmp[1] = e;
			out.push_back(out_tmp);
			
			for(int i = 0;i < e;i++){
				N = N / p;
			}
			
			if( N == 1 ){
				break;
			}
			
		}
	}
	
}

int bitmask(int n){
	
	int a = 1;
	
	return ( a << (n - 1) );
	
}

long long s_buy(long long& money, int price){
	
	long long stock = 0;
	
	stock = money / price;
	
	if( price * stock > money ){
		stock--;
	}
	
	money = money - stock * price;
	
	/*
	while(1){
		
		if( money - price < 0 ){
			break;
		}
		
		money = money - price;
		stock++;
		
	}
	*/
	
	return stock;
	
}

int main(){
	
	int N;
	
	cin >> N;
	
	vector<int> A(N), Signal(N - 1);
	
	for(int i = 0;i < N;i++){
		cin >> A[i];
	}
	
	long long money = 1000;
	long long stock = 0;
	
	for(int i = 0;i < N - 1;i++){
		if( A[i] < A[i + 1] ){
			Signal[i] = 1;
		}
		else if( A[i] > A[i + 1] ){
			Signal[i] = -1;
		}
	}
	
	for(int i = 0;i < N - 1;i++){
		if( Signal[i] == 1 ){//buy
			money = money + A[i] * stock;
			stock = s_buy( money, A[i] );
		}
		else if( Signal[i] == -1 ){//sell
			money = money + A[i] * stock;
			stock = 0;
		}
		else{//stay
		}
	}
	
	money = money + A[N - 1] * stock;
	
	cout << money;
	
	return 0;
	
}


Measured memory_bytes: 3608
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;


#[fastout]
fn main() {
    input! {
    n: usize,
    mut s: [Chars; n]
    }
    let mut ss = vec!["".to_string(); n];
    for i in 0..n {
        s[i].sort();
        ss[i] = s[i].clone().into_iter().collect::<String>();
    }
    ss.sort();
    ss.push("".to_string());
    let mut ans = 0;
    let mut l = 0;
    for i in 1..=n {
        if ss[l] != ss[i] {
            let t = i - l;
            ans += t * (t - 1) / 2;
            l = i;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 19640
h, w = map(int, input().split( ))

c=[[0 for _ in range(w)]]
DP = [[0 for _ in range(w+1)] for __ in range(h+1)]
for _ in range(h):
    c_tmp = list(map(int, input().split( )))
    c.append(c_tmp)


for i in range(w):
    for j in range(1,h+1):
        if c[j][i] == 1:
            DP[j][i] = 0
        else:
            DP[j][i] = DP[j-1][i]+1

#for i in range(1,h+1):
#    print(*DP[i])
S = []
ans = []
Tst =  [[0 for _ in range(w)] for __ in range(h+1)]
for j in range(1,h+1):
    #S = []
    for i in range(w+1):
        if len(S) > 0:
            if S[-1][0] <= DP[j][i]:
                S.append([DP[j][i],1])
            
            else:#if S[-1] > DP[j][i]:
                tmp = 0
                while len(S) > 0 and S[-1][0] > DP[j][i]:
                    pp = S.pop()
                    tmp += pp[1]
                    ans.append(pp[0]*tmp)
                    Tst[j][i-1] = pp[0]*tmp
                S.append([DP[j][i],tmp+1])
                
        else:
            S.append([DP[j][i],1])
#print()
#for i in range(1,h+1):
#    print(*Tst[i])
#print()
try:
    print(max(ans))
except:
    print(0)





Measured memory_bytes: 224936
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

lld fac[200001]; 

void getfac(lld p)
{
    fac[0] = 1; 
    for (lld i=1 ; i<=200000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


long long int gcd(lld b,lld a)
{
    if(a<b) return gcd(a,b);
    if(a%b==0) return b;
    return gcd(a%b , b);
}

//vector< vector <lld > > v(100001);
lld p1=1000000007,p2=998244353;
lld l,r,mid,ans;
lld n,m,i,j,k;
lld x,y,n1,a,b,n2,h,z,c;
queue<lld> q;
lld d,p=1000000000;

void solve()
{
    cin>>n;
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
            if(i*j==n) 
            {
                cout<<"Yes";
                return;
            }
        }
    }
    cout<<"No";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    //cin>>t;
    //cout<<t;
    //getfac(p2);
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
            solve();
        cout<<"\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int a, b;
  cin >> a >> b;
  if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)  cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  random_device rnd;
  mt19937 mt(rnd());
  int D;
  cin >> D;
  vector<int> c(26);
  for (int i = 0; i < 26; i++){
    cin >> c[i];
  }
  vector<vector<int>> s(D, vector<int>(26));
  for (int i = 0; i < D; i++){
    for (int j = 0; j < 26; j++){
      cin >> s[i][j];
    }
  }
  vector<int> last(26, -1);
  for (int i = 0; i < D; i++){
    int t = min(5, D - i);
    vector<vector<int>> L(t, vector<int>(26, 0));
    for (int j = 0; j < t; j++){
      for (int k = 0; k < 26; k++){
        L[j][k] = c[k] * (i + j - last[k]);
      }
    }
    /*
    for (int j = 0; j < t; j++){
      for (int k = 0; k < 26; k++){
        cout << L[j][k] << ' ';
      }
      cout << endl;
    }
    */
    int mx = 0;
    int a = 0;
    vector<int> best(t);
    for (int j = 0; j < 20000; j++){
      vector<vector<int>> L2 = L;
      vector<int> next(t, 0);
      if (j < 10000){
        for (int k = 0; k < t; k++){
          next[k] = mt() % 26;
        }
      } else if (j < 19000){
        next = best;
        for (int k = 0; k < 3; k++){
          int pos = mt() % t;
          int upd = mt() % 26;
          next[pos] = upd;
        }
      } else {
        next = best;
        for (int k = 0; k < 2; k++){
          int pos = mt() % t;
          int upd = mt() % 26;
          next[pos] = upd;
        }
      }
      //calculate diff
      int diff = 0;
      for (int k = 0; k < t; k++){
        diff += s[i + k][next[k]];
        for (int l = k; l < t; l++){
          diff += L2[l][next[k]] - (l - k) * c[next[k]];
          L2[l][next[k]] = (l - k) * c[next[k]];
        }
      }
      if (diff > mx){
        mx = diff;
        best = next;
        /*
        cout << "best: " << endl;
        for (int k = 0; k < t; k++){
          cout << best[k] << ' ';
        }
        cout << endl;
        cout << "mx = " << mx << endl;
        */
      }
    }
    cout << best[0] + 1 << endl;
    last[best[0]] = i;
  }
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep_ll(i,n) for(ll i = 0; i < (ll)(n); i++)

using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;

const long double PI = (acos(-1));
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
 
int main(){

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

    priority_queue<int> q;
    rep(i,n) {
        int a;
        cin >> a;
        q.push(a);//入力
    }
    rep(i, m){
        int a = q.top();//最大値の取得
        q.pop();//最大要素を削除
        q.push(a/2);
    }
    ll ans = 0;
    rep(i,n){
        ans+=q.top(); q.pop();
    }
    cout << ans;
   return 0;
}

Measured memory_bytes: 892
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> PL;

void solve(){
	int A[100010] = {};
	int n; scanf("%d", &n);
	int ans = 0;
	rep(i, n){
		int x; scanf("%d", &x);
		if(A[x] == 0)++ans, A[x] = 1;
	}
	if(ans % 2 == 0)--ans;
	printf("%d\n", ans);
}

int main(){
	int Tc = 1; //scanf("%d", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
const int N = 1e6 + 10, OO = 0x3f3f3f3f, mod = 100000007;

#define PI acos(-1)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rloop(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define xloop(i, a, b) for (int i = int(a); i <= int(b); i++)
#define ALL(v) ((v).begin()), ((v).end())
#define SZ(v) ((int)((v).size()))
#define sc1(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d %d", &a, &b)
#define vi vector<int>
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1}; //4 Direction
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; //8 direction
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2};
//int dy[] = {1, 2, 2, 1, -1, -2, -2, -1}; //Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

//-- "كلٌّ من يسعى لابد يصل .. كلٌّ من يسعى مضمون له الوصول" --//

int n, a[N] , cnt[N] , vis[N];

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

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

  int GCD = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i){
    scanf("%d", a + i);
    cnt[a[i]]++;
    GCD = gcd(GCD, a[i]);
  }

  bool tmam = 1;
  int cntMultiple = 0;
  //for every Prime -- multiple of prime -- cnt of each multiple
  for (int i = 2; i < N; ++i){ // for loop on primes
    cntMultiple = 0;
    if(vis[i] == 0)
    {
      for (int j = i; j < N; j += i){ // for loop for multiples of primes
        vis[j] = 1; // 2 4 6 8 10 ....
        cntMultiple += cnt[j];
      }
      if(cntMultiple > 1)
        tmam = 0;
    }
    if(!tmam)
      break;
  }

  if(tmam) // pairwise co-prime
    cout << "pairwise coprime\n";
  else if(GCD == 1 && !tmam)
    cout << "setwise coprime\n";
  else
    cout << "not coprime\n";

  return 0;
}


Measured memory_bytes: 15360
#include<bits/stdc++.h>
using namespace std;
#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define all(obj) (obj).begin(),(obj).end()
typedef long long ll;
ll mod=ll(1e9)+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x;cin>>x;
  ll i=100,cnt=0;
  while(i<x){
    i*=1.01;
    cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
typedef long long ll;
typedef long double ld;

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> x(n), s(n-k+1);
    rep(i, n) cin >> x[i];
    
    rep(i, n-k+1){
        int left = x[i];
        int right = x[i+k-1];
        
        if(left > 0 && right > 0){
            s[i] = abs(right);
            continue;
        }
        if(left < 0 && right < 0){
            s[i] = abs(left);
            continue;
        }
        s[i] = min(abs(left)*2 + abs(right), abs(left) + abs(right)*2);
    }
//    rep(i, n-k+1) cout << s[i] << endl;
    int ans = *min_element(s.begin(), s.end());
    cout << ans << el;
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
int n,m;
pair<int,int> pii[10004];

void solve() {
    int d,p;
    rep(i,n) {
        cin>>d>>p;
        pii[i] = make_pair(-p,d);
    }
    sort(pii,pii+n);
    int ans=0;

    rep(i,n) {
        int p2 = -pii[i].first;
        int dist = pii[i].second;
        //cout<<(-pii[i].first)<<","<<dist<<","<<pii[i].second<<endl;
        if(m-dist<0) {
            ans += (dist-m)*p2;
            m = 0;
        }
        else {
            m-=dist;
        }

    }
    cout<<ans<<endl;
    rep(i,n) {
        pii[i] = make_pair(0,0);
    }

}

int main() {
    while(cin>>n>>m) {
        if(n+m==0) return 0;
        solve();

    }

    return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#include <memory>
using namespace std; 

typedef long long ll; 
typedef unsigned long long ull;
typedef unsigned uint; 
typedef long double l_double;

#define vtr vector
#define PB push_back
#define EB emplace_back
#define gcd __gcd
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define type(var) static_cast<type>(var)
#define TEST uint _ {}; cin >> _; while (_--)
#define PI (3.1415926535897932384626433832795)
#define MOD 1'00'00'00'007
#define EPS 1e-9
#define deb(x) cout<< #x << " --> " << x << endl;

template<typename T>
void vtrS(const vector<T> &ARR) 
{ for (T const &val: ARR) cout<<val<<" "; cout<<endl; }

template<typename T>
void vtrV(const vector<T> &ARR) 
{ for (T const &val: ARR) cout<<val<<endl; }

template<typename T>
void read_vvtr(vector<vector<T>> &ARR) 
{ for (vector<T> &i: ARR) for (T &j: i) cin >> j; }

template<typename T>
void vvtrS(const vector<vector<T>> &ARR) 
{ for (vector<T> const &i: ARR) { for (T const &j: i) cout<<j<<" "; cout<<endl; } }

template<typename T>
void vvtrNS(const vector<vector<T>> &ARR) 
{ for (vector<T> const &i: ARR) { for (T const &j: i) cout<<j; cout<<endl; } }

template<typename T>
T cntDigits(const T &N) { return (floor(log10(N)) + 1); }

template<typename T>
bool isPowOfTwo(const T &N) { return (N && (!(N&(N-1)))); }

template<typename T>
T lcm(T a, T b) { return ((a*b)/gcd(a, b)); }
// --------------------------------------------------------------------------------

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<boolalpha;
    cout<<fixed<<setprecision(6); 
    // --------------------------------------
    
    double W {}, H {}, x {}, y {};
    cin >> W >> H >> x >> y;

	cout<<((W*H)/2)<<" "<<((abs((W/2) - x) < EPS && abs((H/2) - y) < EPS) ? 1: 0)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int A, B, M, AA[100100], BB[100100];
int main() {
	int i;
	scanf("%d%d%d", &A, &B, &M);
	for (i = 1; i <= A; ++i) scanf("%d", &AA[i]);
	for (i = 1; i <= B; ++i) scanf("%d", &BB[i]);
	int Res = (int) 1e9;
	for (i = 1; i <= M; ++i) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		Res = min(Res, AA[a] + BB[b] - c);
	}
	int ARes = 1e9, BRes = 1e9;
	for (i = 1; i <= A; ++i) ARes = min(ARes, AA[i]);
	for (i = 1; i <= A; ++i) BRes = min(BRes, BB[i]);
	Res = min(Res, ARes + BRes);
	printf("%d\n", Res);
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
const int mod = 1e9+7;

int main(){
    int N, M, X, sum_before, sum_after;
    cin >> N >> M >> X;
    vector <int> a(M);
    for(int i=0; i<M; i++){
        cin >> a[i];
    }

    for(int i=0;i < M; i++){
        if(a[i] < X){
            sum_before++;
        }
    }
    sum_after = a.size() - sum_before;

    if(sum_before > sum_after){
        cout << sum_after;
    }else{
        cout << sum_before;
    }
}

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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

typedef long long ll;

const int mod = 1e9+7;
const int N = 1e3+3;
int cnt[N];

void f(int n){
  vector<int> isp(n+1, 1);
  for (int i = 2; i <= n; ++i){
    if(isp[i] and n%i==0){
      while(n%i==0){
        cnt[i]++;
        n/=i;
      }
    }
  }
}


int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int n;  cin >> n;
  ll ans = 1;
  for (int i = 2; i <= n; ++i){
    f(i);
  }
  for (int i = 0; i <= n; ++i){
    ans *= cnt[i]+1;
    ans %= mod;
  }
  cout << ans << "\n";
  return 0;
}

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

int main() {
    vector<ll> l;
    l.push_back(2);
    l.push_back(1);
    for (int i = 2; i < 87; i++) {
        l.push_back(l[i - 1] + l[i - 2]);
    }

    int n;
    cin >> n;
    cout << l[n] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
using namespace std;
string s,t;
int ans;
int main(){
	cin>>s>>t;
	for(int i=0;i<3;i++){
		if(s[i]==t[i]) ans++;
	}
	cout<<ans<<endl;
system ("pause");
return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
    string S;

    cin >> S;

    if(S == "ABC"){
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" << endl;
    }

}

Measured memory_bytes: 3104
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value


void solve() {

	string S;
	cin >> S;

	vi stack;

	int cnt = 0;
	stack.eb(S[0]);
	for (int i = 1; i < S.length(); i++) {
		stack.eb(S[i]);
		if (stack.size() >= 2 && stack.back() != *(stack.end() - 2)) {
			cnt += 2;
			stack.pop_back();
			stack.pop_back();
		}
	}

	cout << cnt << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

Measured memory_bytes: 972
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int d[4] = {};
    rep(i, 0, 4) cin >> d[i];
    int l = d[0] + d[1];
    int r = d[2] + d[3];
    if(l == r) cout << "Balanced" << endl;
    else if(l < r) cout << "Right" << endl;
    else cout << "Left" << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
N = int(readline())
dp = [[0]*3 for i in range(N)]
dp[0] = list(map(int,readline().split()))
for i in range(1,N):
    a,b,c = map(int,readline().split())
    dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a
    dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b
    dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c
print(max(dp[N-1]))


Measured memory_bytes: 22772
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		if(a%10==3){System.out.println("bon");
                   }
        else{if(a%10==0 ||a%10==1 ||a%10==6 ||a%10==8 ){System.out.println("pon");}
            else{System.out.println("hon");}}
		
	}
}


Measured memory_bytes: 35776
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  string S; cin >> S;
  cout << S.substr(0,3) << endl;
  return 0;
}


Measured memory_bytes: 3596
inp = list(map(int, input().split(" ")))

a = inp[0]
b = inp[1]
c = inp[2]
d = inp[3]

result = "No"

if abs(a-c) <= d:
    result = "Yes"
elif abs(a-b) <= d and abs(b-c) <= d:
    result = "Yes"
    
print(result)

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

struct Edge {
  int to;
};

typedef vector<vector<Edge> > Graph;

int dfsA(const Graph &g, int v, int pre, int &times, vector<int> &num,
         vector<int> &ap) {
  int res = num[v] = times++;
  bool flag = false;
  int c = 0;
  for(int i = 0; i < g[v].size(); ++i) {
    int nv = g[v][i].to;
    int t;
    if(num[nv] == -1) {
      t = dfsA(g, nv, v, times, num, ap);
      ++c;
      if(~pre && t >= num[v]) {
        flag = true;
      }
    } else {
      t = num[nv];
    }
    if(nv != pre) {
      res = min(res, t);
    }
  }
  if(pre == -1 && c > 1) flag = true;
  if(flag) ap.push_back(v);
  return res;
}

vector<int> getArticulationPoint(const Graph &g) {
  vector<int> res;
  int n = g.size();
  int times = 0;
  vector<int> num(n, -1);
  for(int i = 0; i < n; ++i) {
    if(num[i] == -1) {
      dfsA(g, i, -1, times, num, res);
    }
  }
  return res;
}

int main() {
  int N, M;
  cin >> N >> M;
  Graph G(N);
  for(int i = 0; i < M; ++i) {
    int s, t;
    cin >> s >> t;
    G[s].push_back((Edge){t});
    G[t].push_back((Edge){s});
  }
  vector<int> ap = getArticulationPoint(G);
  sort(ap.begin(), ap.end());
  for(int i = 0; i < ap.size(); ++i) {
    cout << ap[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
const int MOD = 1000000007;

int main()
{
  int A,B;
  cin >> A >> B;
  if(A == 1)A += 100;
  if(B == 1)B += 100;
  cout << (A == B ? "Draw" : (A > B ? "Alice" : "Bob")) << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;

//long long num[5000000];
long long a[1000000];
long long a_sum[1000000];
long long num_o[1000000];
map<long long,long long> num;
int main()
{
    long long N;
    cin>>N;
    for(long long i=1;i<=N;i++)
        cin>>a[i];
    num[0] = 1;
    long long sum = 0;
    long long res = 0;
    long long af = 0;
    for(long long i=1;i<=N;i++)
    {
        sum+=a[i];
        if(!num.count(sum))
            num[sum] = 1;
        else
        {
            res+=num[sum];
            num[sum]++;
        }

    }

    cout << res<<endl;
}


Measured memory_bytes: 16896
#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);
    int32 n;
    cin >> n;
    map<int32,int32> b;
    REP(i,n){
        int32 a;
        cin >> a;
        b[a]++;
    }
    if(b.size() > 2){
        Yes(false);
    }else if(b.size() == 1){
        Yes(n >= b.begin()->first * 2 || n - 1 == b.begin()->first);
    }else{
        Yes(b.begin()->first + 1 == (++b.begin())->first && ((++b.begin())->first - b.begin()->second) * 2 <= (++b.begin())->second && b.begin()->second < (++b.begin())->first);
    }

    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(0);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;

int main(void){
  ll A;
  string B;
  
  I(A);
  I(B);

  ll d1 = (ll)(B[0] - '0');
  ll f1 = (ll)(B[2] - '0');
  ll f2 = (ll)(B[3] - '0');

  ret += A * d1;
  ret += (A / 10) * f1;
  ret += (A / 100) * f2;

  ll _b = (A % 10) * 10 * f1;
  ll _c = (A % 100) * f2;
  ret += (_b + _c) / 100;
  
  P(ret);

}


Measured memory_bytes: 3624
char m[14][14];

solve(i,j){
  m[i][j]='0';
  if(m[i][j-1]-'0')solve(i,j-1);
  if(m[i][j-2]-'0')solve(i,j-2);
  if(m[i][j-3]-'0')solve(i,j-3);
  if(m[i-1][j]-'0')solve(i-1,j);
  if(m[i-2][j]-'0')solve(i-2,j);
  if(m[i-3][j]-'0')solve(i-3,j);
  if(m[i+1][j]-'0')solve(i+1,j);
  if(m[i+2][j]-'0')solve(i+2,j);
  if(m[i+3][j]-'0')solve(i+3,j);
  if(m[i][j+1]-'0')solve(i,j+1);
  if(m[i][j+2]-'0')solve(i,j+2);
  if(m[i][j+3]-'0')solve(i,j+3);
}

main(c){
  int n,h=10,i,j;
  for(scanf("%d",&n);c<=n;c++){
    printf("Data %d:\n",c);
    memset(m,'0',sizeof(m));
    for(i=3;i<=h;m[i][11]='0',i++)
      scanf("%s",m[i]+3);
    scanf("%d%d",&i,&j);
    solve(j+2,i+2);
    for(i=3;i<=h;printf("%s\n",m[i]+3),i++)
      m[i][11]=0;
  }
  return 0;
}

Measured memory_bytes: 612
let () =
  Scanf.scanf "%d\n" @@ fun x ->
  Printf.printf "%d\n"
    (if 400 <= x && x < 600 then 8
     else if 600 <= x && x < 800 then 7
     else if 800 <= x && x < 1000 then 6
     else if 1000 <= x && x < 1200 then 5
     else if 1200 <= x && x < 1400 then 4
     else if 1400 <= x && x < 1600 then 3
     else if 1600 <= x && x < 1800 then 2
     else 1)

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
vector<pii> e;
void addedge(int a,int b)
{
    e.emplace_back(a,b);
}
int main()
{
    int n;scanf("%d",&n);
    if(n<3||(n-(n&-n))==0)printf("No\n");
    else{
        printf("Yes\n");
        addedge(1,2),addedge(2,3),addedge(3,n+1);
        addedge(1,3+n),addedge(3+n,2+n);
        for(int i=4;i+1<=n;i+=2)
            addedge(1,i),addedge(i,i+1),addedge(1,i+1+n),addedge(i+1+n,i+n);
        if(!(n&1))
        {
            int k=(n-1)^n;
            addedge(k+n,n),addedge(n-2,n*2);
        }
        for(pii p:e)printf("%d %d\n",p.first,p.second);
    }
}

Measured memory_bytes: 3952
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,A,B=MAP()
S=input()

sm=bsm=0
for i in range(N):
    if S[i]=='a':
        if sm<A+B:
            sm+=1
            Yes()
        else:
            No()
    elif S[i]=='b':
        if sm<A+B and bsm<B:
            sm+=1
            bsm+=1
            Yes()
        else:
            No()
    else:
        No()
    

Measured memory_bytes: 4144
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int a,n,ans=0,vis[11]={0},k;
cin>>n;
k=n;
for(int i=1;i<=n;i++){
	cin>>a;
	if(1<=a&&a<=399)vis[1]++;
	else if(a<800)vis[2]++;
	else if(a<1200)vis[3]++;
	else if(a<1600)vis[4]++;
	else if(a<2000)vis[5]++;
	else if(a<2400)vis[6]++;
	else if(a<2800)vis[7]++;
	else if(a<3200)vis[8]++;
}
for(int i=1;i<=8;i++){
	if(vis[i])ans++;
	if(i==8&&ans==0){
		ans=1;
	}
}
cout<<ans<<" ";
for(int i=1;i<=8;i++){
	n-=vis[i];
}
if(k!=n)
cout<<ans+n;
else cout<<min(ans+n-1,8);
	return 0;
}
/*
Rating 1-399 : gray
Rating 400-799 : brown
Rating 800-1199 : green
Rating 1200-1599 : cyan
Rating 1600-1999 : blue
Rating 2000-2399 : yellow
Rating 2400-2799 : orange
Rating 2800-3199 : red

*/

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S, T, ABCD):

    S_ = [0]
    for c in S:
        S_.append((1 if c == 'A' else 2) + S_[-1])
    T_ = [0]
    for c in T:
        T_.append((1 if c == 'A' else 2) + T_[-1])

    for a, b, c, d in ABCD:
        s = (S_[b]-S_[a-1]) % 3
        t = (T_[d]-T_[c-1]) % 3
        if s == t:
            print('YES')
        else:
            print('NO')


def main():
    S = read_str()
    T = read_str()
    q = read_int()
    ABCD = [read_int_n() for _ in range(q)]
    slv(S, T, ABCD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 44996
package main

// ABC077C - Snuke Festival
// https://atcoder.jp/contests/abc077/tasks/arc084_a

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}
func lowerbound(v []int, k int) int {
	l, r := -1, len(v)
	for r-l > 1 {
		m := l + (r-l)/2
		if v[m] >= k {
			r = m
		} else {
			l = m
		}
	}
	return r
}

func upperbound(v []int, k int) int {
	l, r := -1, len(v)
	for r-l > 1 {
		m := l + (r-l)/2
		if v[m] > k {
			r = m
		} else {
			l = m
		}
	}
	return r
}

func main() {
	var N int
	fmt.Scan(&N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt(sc)
	}
	B := make([]int, N)
	for i := 0; i < N; i++ {
		B[i] = nextInt(sc)
	}
	C := make([]int, N)
	for i := 0; i < N; i++ {
		C[i] = nextInt(sc)
	}
	sort.Ints(A)
	sort.Ints(C)
	ans := 0
	for j := 0; j < len(B); j++ {
		// A<B[j]となる数とB[j]<Cとなる数の積を求める。
		// 真ん中の値を固定するのが核心
		x := lowerbound(A, B[j])
		y := upperbound(C, B[j])
		ans += x * (len(C) - y)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
#include<iostream>
using namespace std;
int main(){
int n,m;
int a[55],b[55];
cin>>n>>m;
for(int i=0;i<m;i++){
    cin>>a[i]>>b[i];
    a[i]-=1;
    b[i]-=1;
}
int ans[55];
for(int i=0;i<n;i++){
    ans[i] = 0;
}

for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
        if(a[j]==i||b[j]==i){
            ans[i]+=1;
        }
      }
  }
        for(int i=0;i<n;i++){
            cout<<ans[i]<<endl;
        }
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            int N = Integer.parseInt(in.next());
            int[] d = new int[N];
            for (int i = 0; i < N; i++) {
                d[i] = Integer.parseInt(in.next());
            }
            int ans = 0;
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    ans += d[i] * d[j];
                }
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 22612
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string today;
            today = Console.ReadLine(); //標準入力

            if (string.Equals(today, "Sunny"))
            {
                Console.WriteLine("Cloudy");//改行付き出力
            }
            else if (string.Equals(today, "Cloudy"))
            {
                Console.WriteLine("Rainy");//改行付き出力
            }
            else
            {
                Console.WriteLine("Sunny");//改行付き出力
            }
        }
    }
}


Measured memory_bytes: 11092
from collections import defaultdict
def main():
    n,m=map(int,input().split())
    aa=list(map(int,input().split()))
    s=sum(aa)
    aa=list(reversed(sorted(aa)))
    if aa[m-1] >= s / (4*m):
        print('Yes')
    else:
        print('No')
main()

Measured memory_bytes: 3316
#include<iostream>
#include<map>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int a[100005]={0};
    int correct=0;int wrong=0;
    for(int i=0;i<m;i++){
        int problem;
        cin>>problem;
        string verdict;
        cin>>verdict;
        if(verdict=="AC" && a[problem]!=-1){
            correct++;
            wrong+=a[problem];
            a[problem]=-1;
        }
        else if(verdict=="WA" && a[problem]>=0){
            a[problem]++;
        }
    }
cout<<correct<<" "<<wrong<<endl;
return 0;
}

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

using namespace std;

int N;
vector<int> stones;
vector<int> dp;
int best(int i) {
  if(i >= N) {
    return -1;
  } else {
    if(dp[i] != -1) {
      return dp[i];
    } else {
      int res = best(i+1) + abs(stones[i]-stones[i+1]);
      res = min(res, best(i+2) + abs(stones[i]-stones[i+2]));

      if(i == N-1) {
	res = 0;
      } else if(i == N-2) {
	res =abs(stones[i]-stones[i+1]);
      }
      
      dp[i] = res;
      return res;
      
    }
  }
}

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

  cin >> N;

  for(int i = 0; i < N; i++) {
    int h;
    cin >> h;
    stones.push_back(h);
    dp.push_back(-1);
  }

  cout << best(0);
  
}





Measured memory_bytes: 7540
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) 
{
    ll n, d;
    cin >>n >>d;
    ll r = 0;
    r = n / (d*2+1);
    if (n % (d*2+1) != 0) r++;
    mes(r);
}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int sum = sc.nextInt() + sc.nextInt() + sc.nextInt() + sc.nextInt();
		System.out.println(sum / 60);
		System.out.println(sum % 60);
	}

}

Measured memory_bytes: 12000
lst = []
seki = 0
n = 1
while seki <= 100100:
  seki = n*n
  lst.append(seki)
  n += 1
  
a,b = map(str, input().split())
ab = int(a+b)
if ab in lst:
  print("Yes")
else:
  print("No")

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

typedef long long ll;
const int N = 100005;

int dst[N];
int vstd[N];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n;
	cin>>n;
	
	priority_queue<pair<int,int> > pq;
	
	memset(dst,0x7f,sizeof dst);
	
	for(int i=1;i<min(10,n+1);i++){
		dst[i%n] = i;
		pq.push({-i,i%n});
	}
	
	while(!pq.empty()){
		int x = pq.top().second;
		pq.pop();
		if(vstd[x])continue;
		vstd[x] = true;
		for(int i=0;i<10;i++){
			int y = (x*10+i)%n;
			if(dst[x] + i%10 < dst[y]){
				dst[y] = dst[x] + i%10;
				pq.push({-dst[y],y});
			}
		}
	}
	
	cout<<dst[0];
	
	return 0;
}


Measured memory_bytes: 6040
N , M = map(int , input().split())
A = []
B = []
flg = False

for i in range(N):
    A.append([j for j in input()])
for i in range(M):
    B.append([j for j in input()])

for i in range(N-M+1):
    for k in range(N-M+1):
        if flg:
            break
        flg = True
        for j in range(M):
            for l in range(M):
                if B[j][l] != A[j+i][l+k]:
                    flg = False
                    
            
 
if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
 
using namespace std;
 
typedef long long ll;
 
const int maxn = 22;
ll n = 0;
int len = 0;
int num[maxn];
 
int dp[maxn];
int vis[maxn];
 
int dfs(int l, int d) {
    if (l == -1) return 0;
    if (vis[l] && !d) return dp[l];
    int m = d?num[l]:9;
    int ret = 0;
    for (int i = 0; i <= m; i++) {
        ret = max(ret, i+dfs(l-1, d&(i==m)));
    }
    if (!d) {
        vis[l] = 1; dp[l] = ret;
    }
    return ret;
}
 
int main() {
    cin >> n;
    while (n) {
        num[len++] = n%10;
        n /= 10;
    }
    int ans = dfs(len-1, 1);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
using namespace std;
static const int N=100;
static const int WHITE=1;
static const int GRAY=2;
static const int BLACK=3;

int n,M[N][N];
int color[N],d[N],f[N],nt[N],tt;

int next(int u)
{
    for(int v=nt[u];v<n;v++)
    {
        nt[u]=v+1;
        if(M[u][v]) return v;
    }
    return -1;
}

void dfs_visit(int r)
{
    for(int i=0;i<n;i++) ;
    stack<int> S;
    S.push(r);
    color[r]=GRAY;
    d[r]=++tt;

    while(!S.empty())
    {
        int u=S.top();
        int v=next(u);
        if(v!=-1)
        {
            if(color[v]==WHITE)
            {
                color[v]=GRAY;
                d[v]=++tt;
                S.push(v);
            }
        }
        else
        {
          S.pop();
          color[u]=BLACK;
          f[u]=++tt;
        }
    }

}

void dfs()
{
    for(int i=0;i<n;i++)
    {
        color[i]=WHITE;
        nt[i]=0;
    }
    tt=0;

    for(int u=0;u<n;u++)
    {
        if(color[u]==WHITE) dfs_visit(u);
    }

    for(int i=0;i<n;i++)
    {
      cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
    }
}

int main()
{
    int u,k,v;
    cin>>n;
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
    {
        M[i][j]=0;
    }

    for(int i=0;i<n;i++)
    {
        cin>>u>>k;
        u--;
        for(int j=0;j<k;j++)
        {
            cin>>v;
            v--;
            M[u][v]=1;
        }
    }
    dfs();
    return 0;
}



Measured memory_bytes: 3140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_164_SheepAndWolves
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var array = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int S = array[0];
            int W = array[1];

            if (S > W)
            {
                Console.WriteLine("safe");
            }
            else
            {
                Console.WriteLine("unsafe");
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27940
from collections import deque

n = int(input())
A = list(map(int, input().split()))
ans = deque([])
num = deque([])

def make_divisors(t):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if t % i == 0:
            divisors.add(i)
            if i != t // i:
                divisors.add(t//i)

    # divisors.sort()
    return divisors


for i in range(n-1, -1, -1):
    if A[i] == 0:
        continue
    else:
        ans.appendleft(i+1)
        check = make_divisors(i+1)
        for j in check:
            A[j-1] = not A[j-1]

print(len(ans))
for i in ans:
    print(i)


Measured memory_bytes: 72284
N,M = map(int,input().split())
P = list(map(lambda x: int(x)-1,input().split()))

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    def check(self, x, y):
        return self.find(x) == self.find(y)

uf = UnionFind(N)

for _ in range(M):
    x,y = map(int,input().split())
    uf.union(x-1,y-1)

Ans = 0
for i,p in enumerate(P):
    Ans += 1 if uf.check(i,p) else 0

print(Ans)

Measured memory_bytes: 14008
import numpy as np
import copy

H, W, K = map(int, input().split())
if H == 1:
    d = list(map(str, input().split()))
    X = list(d[0])
    black = 0
    for i in range(W):
        if X[i] == "#":
            black += 1

    t = 0
    s = "0" + str(W) + "b"

    #消すバージョン
    if K == 0:
        t += 2**W

    #消さない
    for i in range(2**W):
        black_xx = black
        WW = format(i, s)
        for j in range(W):
            if WW[j] == "1" and X[j] == "#":
                black_xx -= 1
        if black_xx == K:
            t += 1

    print(t)

elif W == 1:
    X = []
    for i in range(H):
        X.append(input())
    black = 0
    for i in range(H):
        if X[i] == "#":
            black += 1

    t = 0
    s = "0" + str(H) + "b"

    #消すバージョン
    if K == 0:
        t += 2**H

    #消さない
    for i in range(2**H):
        black_xx = black
        HH = format(i, s)
        for j in range(H):
            if HH[j] == "1" and X[j] == "#":
                black_xx -= 1
        if black_xx == K:
            t += 1

    print(t)



else:
    d = list(map(str, input().split()))
    X = list(d[0])
    for i in range(H - 1):
        d = list(map(str, input().split()))
        d = list(d[0])
        X = np.vstack((X, d))

    black = 0
    for i in range(X.shape[0]):
        for j in range(X.shape[1]):
            if X[i,j] == "#":
                black += 1

    t = 0
    s1 = "0" + str(H) + "b"
    s2 = "0" + str(W) + "b"
    for i in range(2**H):
        for j in range(2**W):

            XX = copy.copy(X)
            black_xx = black
            HH = format(i, s1)
            WW = format(j, s2)

            for ii in range(H):
                if HH[ii] == "1":
                    for iii in range(W):
                        if XX[ii,iii] == "#":
                            black_xx -= 1
                            XX[ii,iii] = "."
            for jj in range(W):
                if WW[jj] == "1":
                    for jjj in range(H):
                        if XX[jjj,jj] == "#":
                            black_xx -= 1
                            XX[jjj,jj] = "."
            if black_xx == K:
                t += 1

    print(t)


Measured memory_bytes: 26708